You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
(56) |
Apr
(109) |
May
(15) |
Jun
(3) |
Jul
(37) |
Aug
(96) |
Sep
(40) |
Oct
(4) |
Nov
(54) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(47) |
Feb
(30) |
Mar
(102) |
Apr
(120) |
May
(68) |
Jun
(54) |
Jul
(53) |
Aug
(122) |
Sep
(190) |
Oct
(71) |
Nov
(85) |
Dec
(108) |
2007 |
Jan
(72) |
Feb
(190) |
Mar
(53) |
Apr
(101) |
May
(145) |
Jun
(148) |
Jul
(167) |
Aug
(143) |
Sep
(23) |
Oct
(198) |
Nov
(223) |
Dec
(195) |
2008 |
Jan
(100) |
Feb
(129) |
Mar
(79) |
Apr
(77) |
May
(34) |
Jun
(95) |
Jul
(112) |
Aug
(160) |
Sep
(82) |
Oct
(124) |
Nov
(199) |
Dec
(355) |
2009 |
Jan
(436) |
Feb
(89) |
Mar
(298) |
Apr
(189) |
May
(33) |
Jun
(88) |
Jul
(105) |
Aug
(44) |
Sep
(181) |
Oct
(87) |
Nov
(75) |
Dec
(1) |
2010 |
Jan
(63) |
Feb
(21) |
Mar
(3) |
Apr
(1) |
May
(1) |
Jun
(3) |
Jul
(26) |
Aug
(37) |
Sep
(26) |
Oct
(15) |
Nov
(13) |
Dec
|
From: <svn...@op...> - 2009-09-01 11:41:47
|
Author: dgollub Date: Tue Sep 1 13:41:32 2009 New Revision: 5721 URL: http://www.opensync.org/changeset/5721 Log: Drop ticket1084 branch. Development for #1084 continous in /trunk refs #1084 Deleted: branches/opensync-ticket1084/ |
Author: dgollub Date: Tue Sep 1 13:40:46 2009 New Revision: 5720 URL: http://www.opensync.org/changeset/5720 Log: Merged ticket #1084 branch To speed up trunk development refs #1084 Added: trunk/misc/schemas/capabilities.xsd - copied unchanged from r5719, branches/opensync-ticket1084/misc/schemas/capabilities.xsd trunk/opensync/capabilities/opensync_capabilities_objtype.c - copied unchanged from r5719, branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities_objtype.c trunk/opensync/capabilities/opensync_capabilities_objtype.h - copied unchanged from r5719, branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities_objtype.h trunk/opensync/capabilities/opensync_capabilities_objtype_internals.h - copied unchanged from r5719, branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities_objtype_internals.h trunk/opensync/capabilities/opensync_capabilities_objtype_private.h - copied unchanged from r5719, branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities_objtype_private.h trunk/opensync/format/opensync_merger.c - copied unchanged from r5719, branches/opensync-ticket1084/opensync/format/opensync_merger.c trunk/opensync/format/opensync_merger.h - copied unchanged from r5719, branches/opensync-ticket1084/opensync/format/opensync_merger.h trunk/opensync/format/opensync_merger_private.h - copied unchanged from r5719, branches/opensync-ticket1084/opensync/format/opensync_merger_private.h Modified: trunk/ (props changed) trunk/opensync.sym trunk/opensync/CMakeLists.txt trunk/opensync/capabilities/opensync-capabilities_internals.h trunk/opensync/capabilities/opensync_capabilities.c trunk/opensync/capabilities/opensync_capabilities.h trunk/opensync/capabilities/opensync_capabilities_internals.h trunk/opensync/capabilities/opensync_capabilities_private.h trunk/opensync/capabilities/opensync_capability.c trunk/opensync/capabilities/opensync_capability.h trunk/opensync/capabilities/opensync_capability_internals.h trunk/opensync/capabilities/opensync_capability_private.h trunk/opensync/client/opensync_client.c trunk/opensync/client/opensync_client_proxy.c trunk/opensync/db/opensync_db_internals.h (props changed) trunk/opensync/engine/opensync_engine.c trunk/opensync/engine/opensync_mapping_entry_engine.c trunk/opensync/engine/opensync_obj_engine.c trunk/opensync/engine/opensync_sink_engine.c trunk/opensync/format/opensync_format_env.h trunk/opensync/format/opensync_objformat.c trunk/opensync/format/opensync_objformat.h trunk/opensync/format/opensync_objformat_internals.h trunk/opensync/format/opensync_objformat_private.h trunk/opensync/group/opensync_member.c trunk/opensync/group/opensync_member_internals.h trunk/opensync/helper/opensync_sink_state_db.c (props changed) trunk/opensync/helper/opensync_sink_state_db.h (props changed) trunk/opensync/helper/opensync_sink_state_db_internals.h (props changed) trunk/opensync/helper/opensync_sink_state_db_private.h (props changed) trunk/opensync/opensync-capabilities.h trunk/opensync/opensync.h trunk/opensync/version/opensync_version.c trunk/tests/CMakeLists.txt trunk/tests/capabilities-tests/check_capabilities.c trunk/tests/data/capabilities/capabilities.xml trunk/tests/data/multisync_conflict_changetype_choose/configs/group/1/mock-sync.conf (props changed) trunk/tests/data/multisync_conflict_changetype_choose/configs/group/1/syncmember.conf (props changed) trunk/tests/data/multisync_conflict_changetype_choose/configs/group/2/mock-sync.conf (props changed) trunk/tests/data/multisync_conflict_changetype_choose/configs/group/2/syncmember.conf (props changed) trunk/tests/data/multisync_conflict_changetype_choose/configs/group/3/mock-sync.conf (props changed) trunk/tests/data/multisync_conflict_changetype_choose/configs/group/3/syncmember.conf (props changed) trunk/tests/data/multisync_conflict_data_choose/configs/group/1/mock-sync.conf (props changed) trunk/tests/data/multisync_conflict_data_choose/configs/group/1/syncmember.conf (props changed) trunk/tests/data/multisync_conflict_data_choose/configs/group/2/mock-sync.conf (props changed) trunk/tests/data/multisync_conflict_data_choose/configs/group/2/syncmember.conf (props changed) trunk/tests/data/multisync_conflict_data_choose/configs/group/3/mock-sync.conf (props changed) trunk/tests/data/multisync_conflict_data_choose/configs/group/3/syncmember.conf (props changed) trunk/tests/data/multisync_conflict_data_duplicate2/configs/group/1/mock-sync.conf (props changed) trunk/tests/data/multisync_conflict_data_duplicate2/configs/group/1/syncmember.conf (props changed) trunk/tests/data/multisync_conflict_data_duplicate2/configs/group/2/mock-sync.conf (props changed) trunk/tests/data/multisync_conflict_data_duplicate2/configs/group/2/syncmember.conf (props changed) trunk/tests/data/multisync_conflict_data_duplicate2/configs/group/3/mock-sync.conf (props changed) trunk/tests/data/multisync_conflict_data_duplicate2/configs/group/3/syncmember.conf (props changed) trunk/wrapper/opensync-merger.i Modified: trunk/opensync.sym ============================================================================== --- trunk/opensync.sym Tue Sep 1 11:49:03 2009 (r5719) +++ trunk/opensync.sym Tue Sep 1 13:40:46 2009 (r5720) @@ -1,19 +1,30 @@ -osync_capabilities_assemble -osync_capabilities_get_first +osync_capabilities_get_format +osync_capabilities_get_objtype osync_capabilities_new -osync_capabilities_parse +osync_capabilities_objtype_get_caps +osync_capabilities_objtype_new +osync_capabilities_objtype_ref +osync_capabilities_objtype_unref osync_capabilities_ref osync_capabilities_unref -osync_capability_add_key -osync_capability_get_child -osync_capability_get_key_count +osync_capability_get_displayname +osync_capability_get_max +osync_capability_get_maxoccurs +osync_capability_get_min osync_capability_get_name -osync_capability_get_next -osync_capability_get_nth_key -osync_capability_get_parent -osync_capability_get_prev -osync_capability_has_key +osync_capability_get_parameter +osync_capability_get_type +osync_capability_get_valenums osync_capability_new +osync_capability_ref +osync_capability_set_displayname +osync_capability_set_max +osync_capability_set_maxoccurs +osync_capability_set_min +osync_capability_set_name +osync_capability_set_parameter +osync_capability_set_type +osync_capability_unref osync_change_compare osync_change_get_changetype osync_change_get_data @@ -319,6 +330,11 @@ osync_member_set_objtype_enabled osync_member_set_pluginname osync_member_unref +osync_merger_new +osync_merger_ref +osync_merger_set_finalize_func +osync_merger_set_initialize_func +osync_merger_unref osync_obj_engine_command osync_obj_engine_event osync_obj_engine_finalize @@ -345,13 +361,11 @@ osync_objformat_set_copy_func osync_objformat_set_create_func osync_objformat_set_demarshal_func -osync_objformat_set_demerge_func osync_objformat_set_destroy_func osync_objformat_set_duplicate_func osync_objformat_set_finalize_func osync_objformat_set_initialize_func osync_objformat_set_marshal_func -osync_objformat_set_merge_func osync_objformat_set_print_func osync_objformat_set_revision_func osync_objformat_set_validate_func Modified: trunk/opensync/CMakeLists.txt ============================================================================== --- trunk/opensync/CMakeLists.txt Tue Sep 1 11:49:03 2009 (r5719) +++ trunk/opensync/CMakeLists.txt Tue Sep 1 13:40:46 2009 (r5720) @@ -6,6 +6,7 @@ SET( libopensync_LIB_SRCS archive/opensync_archive.c capabilities/opensync_capabilities.c + capabilities/opensync_capabilities_objtype.c capabilities/opensync_capability.c client/opensync_client.c client/opensync_client_proxy.c @@ -34,6 +35,7 @@ format/opensync_objformat.c format/opensync_objformat_sink.c format/opensync_time.c + format/opensync_merger.c group/opensync_group.c group/opensync_group_env.c group/opensync_member.c Modified: trunk/opensync/capabilities/opensync-capabilities_internals.h ============================================================================== --- trunk/opensync/capabilities/opensync-capabilities_internals.h Tue Sep 1 11:49:03 2009 (r5719) +++ trunk/opensync/capabilities/opensync-capabilities_internals.h Tue Sep 1 13:40:46 2009 (r5720) @@ -24,6 +24,7 @@ #define OPENSYNC_CAPABILITIES_INTERNALS_H_COLLECT #include "opensync_capabilities_internals.h" +#include "opensync_capabilities_objtype_internals.h" #include "opensync_capability_internals.h" #endif /* OPENSYNC_CAPABILITIES_INTERNALS_H_COLLECT */ Modified: trunk/opensync/capabilities/opensync_capabilities.c ============================================================================== --- trunk/opensync/capabilities/opensync_capabilities.c Tue Sep 1 11:49:03 2009 (r5719) +++ trunk/opensync/capabilities/opensync_capabilities.c Tue Sep 1 13:40:46 2009 (r5720) @@ -32,50 +32,7 @@ #include "opensync_capabilities_private.h" -OSyncCapabilitiesObjType *osync_capabilitiesobjtype_new(OSyncCapabilities *capabilities, xmlNodePtr node, OSyncError **error) -{ - OSyncCapabilitiesObjType *objtype = NULL; - osync_assert(capabilities); - osync_assert(node); - - objtype = osync_try_malloc0(sizeof(OSyncCapabilitiesObjType), error); - if(!objtype) { - osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error)); - return NULL; - } - - objtype->child_count = 0; - objtype->first_child = NULL; - objtype->last_child = NULL; - objtype->next = NULL; - objtype->node = node; - - if(!capabilities->first_objtype) - capabilities->first_objtype = objtype; - if(capabilities->last_objtype) - capabilities->last_objtype->next = objtype; - capabilities->last_objtype = objtype; - - return objtype; -} - -OSyncCapabilitiesObjType *osync_capabilitiesobjtype_get(OSyncCapabilities *capabilities, const char *objtype) -{ - OSyncCapabilitiesObjType *tmp = NULL; - osync_assert(capabilities); - osync_assert(objtype); - - tmp = capabilities->first_objtype; - for(; tmp != NULL; tmp = tmp->next) { - if(!strcmp((const char *)tmp->node->name, objtype)) - break; - } - return tmp; -} - -/* end of private part */ - -OSyncCapabilities *osync_capabilities_new(OSyncError **error) +OSyncCapabilities *osync_capabilities_new(const char *capsformat, OSyncError **error) { OSyncCapabilities *capabilities = NULL; osync_trace(TRACE_ENTRY, "%s(%p)", __func__, error); @@ -87,21 +44,47 @@ } capabilities->ref_count = 1; - capabilities->first_objtype = NULL; - capabilities->last_objtype = NULL; capabilities->doc = xmlNewDoc(BAD_CAST "1.0"); - capabilities->doc->children = xmlNewDocNode(capabilities->doc, NULL, (xmlChar *)"capabilities", NULL); + capabilities->doc->children = xmlNewDocNode(capabilities->doc, NULL, (xmlChar *)"Caps", NULL); capabilities->doc->_private = capabilities; + + osync_capabilities_set_format(capabilities, capsformat); osync_trace(TRACE_EXIT, "%s: %p", __func__, capabilities); return capabilities; } +OSyncCapabilities *osync_capabilities_ref(OSyncCapabilities *capabilities) +{ + osync_assert(capabilities); + + g_atomic_int_inc(&(capabilities->ref_count)); + + return capabilities; +} + +void osync_capabilities_unref(OSyncCapabilities *capabilities) +{ + osync_assert(capabilities); + + if (g_atomic_int_dec_and_test(&(capabilities->ref_count))) { + OSyncList *l; + for (l = capabilities->objtypes; l; l = l->next) { + OSyncCapabilitiesObjType *objtype; + objtype = (OSyncCapabilitiesObjType *) l->data; + osync_capabilities_objtype_unref(objtype); + /* TODO unlink from list */ + } + osync_xml_free_doc(capabilities->doc); + osync_free(capabilities); + } +} + OSyncCapabilities *osync_capabilities_parse(const char *buffer, unsigned int size, OSyncError **error) { - OSyncCapability *capability = NULL; OSyncCapabilities *capabilities = NULL; xmlNodePtr cur = NULL; + xmlChar *capsformat; osync_trace(TRACE_ENTRY, "%s(%p, %u, %p)", __func__, buffer, size, error); osync_assert(buffer); @@ -112,8 +95,6 @@ } capabilities->ref_count = 1; - capabilities->first_objtype = NULL; - capabilities->last_objtype = NULL; capabilities->doc = xmlReadMemory(buffer, size, NULL, NULL, XML_PARSE_NOBLANKS); if(capabilities->doc == NULL) { osync_free(capabilities); @@ -121,149 +102,125 @@ goto error; } capabilities->doc->_private = capabilities; + + + /* Get CapsFormat Name */ + capsformat = xmlGetProp(capabilities->doc->children, (const xmlChar*)"CapsFormat"); + osync_capabilities_set_format(capabilities, (const char *) capsformat); + xmlFree(capsformat); cur = xmlDocGetRootElement(capabilities->doc); cur = cur->children; for(; cur != NULL; cur = cur->next) { - OSyncCapabilitiesObjType *capabilitiesobjtype = osync_capabilitiesobjtype_new(capabilities, cur, error); - if(!capabilitiesobjtype) { + + if (cur->type != XML_ELEMENT_NODE) + continue; + + OSyncCapabilitiesObjType *capabilitiesobjtype = osync_capabilities_objtype_parse(capabilities, cur, error); + if (!capabilitiesobjtype) { osync_capabilities_unref(capabilities); goto error; } - - if (!(capability = osync_capability_new_node(capabilitiesobjtype, cur, error))) - goto error; - - if (!osync_capability_parse(capability, cur->children, &capabilitiesobjtype->first_child, &capabilitiesobjtype->last_child, &capabilitiesobjtype->child_count, error)) - goto error_and_free; - } - + osync_trace(TRACE_EXIT, "%s: %p", __func__, capabilities); return capabilities; -error_and_free: - if (capability) - osync_capability_free(capability); error: osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error)); return NULL; } -OSyncCapabilities *osync_capabilities_ref(OSyncCapabilities *capabilities) +osync_bool osync_capabilities_assemble(OSyncCapabilities *capabilities, char **buffer, unsigned int *size, OSyncError **error) { + xmlDocPtr doc = NULL; + xmlNodePtr root; + char *version_str; + const char *capsformat; + OSyncList *l; osync_assert(capabilities); - - g_atomic_int_inc(&(capabilities->ref_count)); - return capabilities; -} + capsformat = osync_capabilities_get_format(capabilities); -void osync_capabilities_unref(OSyncCapabilities *capabilities) -{ - osync_assert(capabilities); - - if (g_atomic_int_dec_and_test(&(capabilities->ref_count))) { - OSyncCapabilitiesObjType *objtype, *tmp; - objtype = capabilities->first_objtype; - while(objtype) - { - osync_capability_free(objtype->capability); - - tmp = objtype->next; - osync_free(objtype); - objtype = tmp; - } - osync_xml_free_doc(capabilities->doc); - osync_free(capabilities); + if (!capsformat) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "Can't assamble capabilities: Capabilities Format not set."); + goto error; } -} -OSyncCapability *osync_capabilities_get_first(OSyncCapabilities *capabilities, const char *objtype) -{ - OSyncCapability *res = NULL; - OSyncCapabilitiesObjType *tmp = NULL; - osync_assert(capabilities); - osync_assert(objtype); + doc = capabilities->doc; + + /* Set version for capabilities configuration */ + version_str = osync_strdup_printf("%u.%u", OSYNC_CAPS_MAJOR_VERSION, OSYNC_CAPS_MINOR_VERSION); + xmlSetProp(doc->children, (const xmlChar*)"Version", (const xmlChar *)version_str); + osync_free(version_str); + + /* Set CapsFormat Name */ + xmlSetProp(doc->children, (const xmlChar*)"CapsFormat", (const xmlChar *)capsformat); + + root = doc->children; + + for (l = capabilities->objtypes; l; l = l->next) { + OSyncCapabilitiesObjType *capobjtype; + capobjtype = (OSyncCapabilitiesObjType *) l->data; + if (!osync_capabilities_objtype_assemble(capobjtype, root, error)) + goto error; + } + + /* XXX Ugly cast, but we try to fit here the opensync API pattern of unsigned size/length types */ + xmlDocDumpFormatMemoryEnc(doc, (xmlChar **) buffer, (int *) size, NULL, 1); - tmp = osync_capabilitiesobjtype_get(capabilities, objtype); - if(tmp) - res = tmp->first_child; - return res; -} + return TRUE; + +/* +error_oom: + osync_error_set(error, OSYNC_ERROR_GENERIC, "Couldn't allocate memory to assemble capabilities file."); +*/ +error: + osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error)); + return FALSE; +} -osync_bool osync_capabilities_assemble(OSyncCapabilities *capabilities, char **buffer, int *size) +osync_bool osync_capabilities_save(OSyncCapabilities *capabilities, const char *file, OSyncError **error) { + unsigned int size; + char *buffer; + osync_bool ret; + + osync_trace(TRACE_ENTRY, "%s(%p, %s, %p)", __func__, capabilities, __NULLSTR(file), error); + osync_assert(capabilities); - osync_assert(buffer); - osync_assert(size); + osync_assert(file); + + ret = osync_capabilities_assemble(capabilities, &buffer, &size, error); + if (!ret) + goto error; + + ret = osync_file_write(file, buffer, size, 0600, error); + osync_free(buffer); + + if (!ret) + goto error; - xmlDocDumpFormatMemoryEnc(capabilities->doc, (xmlChar **) buffer, size, NULL, 1); + osync_trace(TRACE_EXIT, "%s", __func__); return TRUE; -} -void osync_capabilities_sort(OSyncCapabilities *capabilities) -{ - unsigned int index; - OSyncCapabilitiesObjType *objtype; - OSyncCapability *cur; - - objtype = capabilities->first_objtype; - for(; objtype != NULL; objtype = objtype->next) - { - void **list = NULL; - if(objtype->child_count <= 1) - continue; - - list = g_malloc0(sizeof(OSyncCapability *) * objtype->child_count); - - index = 0; - for(cur = objtype->first_child; cur != NULL; cur = osync_capability_get_next(cur)) { - list[index] = cur; - index++; - xmlUnlinkNode(cur->node); - } - - qsort(list, objtype->child_count, sizeof(OSyncCapability *), osync_capability_compare_stdlib); - - /** bring the capabilities and xmldoc in a consistent state */ - objtype->first_child = ((OSyncCapability *)list[0])->node->_private; - objtype->last_child = ((OSyncCapability *)list[objtype->child_count - 1])->node->_private; - - for(index = 0; index < objtype->child_count; index++) { - cur = (OSyncCapability *)list[index]; - xmlAddChild(objtype->node, cur->node); - - if(index < objtype->child_count-1) - cur->next = (OSyncCapability *)list[index+1]; - else - cur->next = NULL; - - if(index) - cur->prev = (OSyncCapability *)list[index-1]; - else - cur->prev = NULL; - } - - g_free(list); - } +error: + osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error)); + return FALSE; } OSyncCapabilities *osync_capabilities_load(const char *file, OSyncError **error) { unsigned int size; - char *buffer, *filename; + char *buffer; OSyncCapabilities *capabilities; osync_bool b; osync_trace(TRACE_ENTRY, "%s(%s, %p)", __func__, file, error); osync_assert(file); - filename = osync_strdup_printf("%s%c%s", OPENSYNC_CAPABILITIESDIR, G_DIR_SEPARATOR, file); - - b = osync_file_read(filename, &buffer, &size, error); - osync_free(filename); + b = osync_file_read(file, &buffer, &size, error); if(!b) { osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error)); return NULL; @@ -280,76 +237,69 @@ return capabilities; } -osync_bool osync_capabilities_member_has_capabilities(OSyncMember *member) -{ - char *filename = NULL; - gboolean res = FALSE; - - osync_trace(TRACE_ENTRY, "%s(%p)", __func__, member); - osync_assert(member); - - filename = osync_strdup_printf("%s%ccapabilities.xml", osync_member_get_configdir(member), G_DIR_SEPARATOR); - res = g_file_test(filename, G_FILE_TEST_IS_REGULAR); - osync_free(filename); - - osync_trace(TRACE_EXIT, "%s: %i", __func__, res); - return res; -} - -OSyncCapabilities* osync_capabilities_member_get_capabilities(OSyncMember *member, OSyncError** error) +OSyncCapabilities *osync_capabilities_load_identifier(const char *file, OSyncError **error) { - unsigned int size; - char* buffer, *filename; + char *filename; OSyncCapabilities *capabilities; - osync_bool res; - osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, member, error); - osync_assert(member); - - filename = osync_strdup_printf("%s%ccapabilities.xml", osync_member_get_configdir(member), G_DIR_SEPARATOR); - res = osync_file_read(filename, &buffer, &size, error); - osync_free(filename); + osync_trace(TRACE_ENTRY, "%s(%s, %p)", __func__, file, error); + osync_assert(file); - if(!res) { - osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error)); - return NULL; - } + filename = osync_strdup_printf("%s%c%s", OPENSYNC_CAPABILITIESDIR, G_DIR_SEPARATOR, file); - capabilities = osync_capabilities_parse(buffer, size, error); - osync_free(buffer); - if(!capabilities) { - osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error)); - return NULL; - } - - /* Sort capabilities, to avoid user modified unsorted capalities: #813 */ - osync_capabilities_sort(capabilities); + capabilities = osync_capabilities_load(filename, error); + if (!capabilities) + goto error; osync_trace(TRACE_EXIT, "%s: %p", __func__, capabilities); return capabilities; + +error: + osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error)); + return NULL; } -osync_bool osync_capabilities_member_set_capabilities(OSyncMember *member, OSyncCapabilities* capabilities, OSyncError** error) +const char *osync_capabilities_get_format(OSyncCapabilities *capabilities) { - int size; - char* buffer, *filename; - osync_bool res; + osync_assert(capabilities); + return capabilities->format; +} - osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, member, capabilities, error); - osync_assert(member); +void osync_capabilities_set_format(OSyncCapabilities *capabilities, const char *capsformat) +{ osync_assert(capabilities); + osync_assert(capsformat); + + if (capabilities->format) + osync_free(capabilities->format); + + capabilities->format = osync_strdup(capsformat); +} + +OSyncCapabilitiesObjType *osync_capabilities_get_objtype(OSyncCapabilities *capabilities, const char *objtype) +{ + OSyncList *l = NULL; + OSyncCapabilitiesObjType *capobjtype = NULL; + osync_assert(capabilities); + osync_assert(objtype); - osync_capabilities_assemble(capabilities, &buffer, &size); - filename = osync_strdup_printf("%s%ccapabilities.xml", osync_member_get_configdir(member), G_DIR_SEPARATOR); - res = osync_file_write(filename, buffer, size, 0600, error); - osync_free(filename); - osync_free(buffer); - if(!res) { - osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error)); - return FALSE; - } + l = capabilities->objtypes; + for(; l != NULL; l = l->next) { + capobjtype = (OSyncCapabilitiesObjType *) l->data; + if(!strcmp(osync_capabilities_objtype_get_name(capobjtype), objtype)) + break; + } + + return capobjtype; +} + + +void osync_capabilities_add_objtype(OSyncCapabilities *capabilities, OSyncCapabilitiesObjType *capabilitiesobjtype) +{ + osync_assert(capabilities); + osync_assert(capabilitiesobjtype); + - osync_trace(TRACE_EXIT, "%s: %i", __func__, res); - return res; + capabilities->objtypes = osync_list_append(capabilities->objtypes, capabilitiesobjtype); } Modified: trunk/opensync/capabilities/opensync_capabilities.h ============================================================================== --- trunk/opensync/capabilities/opensync_capabilities.h Tue Sep 1 11:49:03 2009 (r5719) +++ trunk/opensync/capabilities/opensync_capabilities.h Tue Sep 1 13:40:46 2009 (r5720) @@ -36,19 +36,11 @@ /** * @brief Creates a new capabilities object + * @param capsformat Name of the used capabilities format * @param error The error which will hold the info in case of an error * @return The pointer to the newly allocated capabilities object or NULL in case of error */ -OSYNC_EXPORT OSyncCapabilities *osync_capabilities_new(OSyncError **error); - -/** - * @brief Creates a new capabilities object from an xml document. - * @param buffer The pointer to the xml document - * @param size The size of the xml document - * @param error The error which will hold the info in case of an error - * @return The pointer to the newly allocated capabilities object or NULL in case of error - */ -OSYNC_EXPORT OSyncCapabilities *osync_capabilities_parse(const char *buffer, unsigned int size, OSyncError **error); +OSYNC_EXPORT OSyncCapabilities *osync_capabilities_new(const char *capsformat, OSyncError **error); /** * @brief Increments the reference counter @@ -63,24 +55,15 @@ */ OSYNC_EXPORT void osync_capabilities_unref(OSyncCapabilities *capabilities); - /** - * @brief Get the first capability for a given objtype from the capabilities + * @brief Get the first capabilitiesobjtype for a given objtype from the capabilities * @param capabilities The pointer to a capabilities object * @param objtype The name of the objtype (e.g.: contact) - * @return The first capability for a given objtype from the capabilities + * @return The capabilitiesobjtype for a given objtype from the capabilities */ -OSYNC_EXPORT OSyncCapability *osync_capabilities_get_first(OSyncCapabilities *capabilities, const char *objtype); +OSYNC_EXPORT OSyncCapabilitiesObjType *osync_capabilities_get_objtype(OSyncCapabilities *capabilities, const char *objtype); -/** - * @brief Dump the capabilities into memory. - * @param capabilities The pointer to a capabilities object - * @param buffer The pointer to the buffer which will hold the xml document - * @param size The pointer to the buffer which will hold the size of the xml document - * @return The xml document and the size of it. It's up to the caller to free - * the buffer. Always it return TRUE. - */ -OSYNC_EXPORT osync_bool osync_capabilities_assemble(OSyncCapabilities *capabilities, char **buffer, int *size); +OSYNC_EXPORT const char *osync_capabilities_get_format(OSyncCapabilities *capabilities); /*@}*/ Modified: trunk/opensync/capabilities/opensync_capabilities_internals.h ============================================================================== --- trunk/opensync/capabilities/opensync_capabilities_internals.h Tue Sep 1 11:49:03 2009 (r5719) +++ trunk/opensync/capabilities/opensync_capabilities_internals.h Tue Sep 1 13:40:46 2009 (r5720) @@ -23,7 +23,6 @@ #ifndef OPENSYNC_CAPABILITIES_INTERNALS_H_ #define OPENSYNC_CAPABILITIES_INTERNALS_H_ -typedef struct OSyncCapabilitiesObjType OSyncCapabilitiesObjType; /** * @defgroup OSyncCapabilitiesInternalAPI OpenSync Capabilities Internals @@ -40,47 +39,61 @@ */ OSYNC_TEST_EXPORT void osync_capabilities_sort(OSyncCapabilities *capabilities); +/** + * @brief Save a capabilities object in a file + * @param capabilities The pointer to a capabilities object + * @param file The name of the file + * @param error The error which will hold the info in case of an error + * @return TRUE on success, FALSE otherwise + */ +OSYNC_TEST_EXPORT osync_bool osync_capabilities_save(OSyncCapabilities *capabilities, const char *file, OSyncError **error); /** - * @brief Load a capabilities object from a prepackaged file + * @brief Load a capabilities object from a file * @param file The name of the file * @param error The error which will hold the info in case of an error * @return The pointer to the newly allocated capabilities object or NULL in case of error */ -OSyncCapabilities *osync_capabilities_load(const char *file, OSyncError **error); +OSYNC_TEST_EXPORT OSyncCapabilities *osync_capabilities_load(const char *file, OSyncError **error); /** - * @brief Checks if the capabilities are already cached - * @param member The member which should be tested for cached capabilities - * @return TRUE if the capabilities for this member are cached otherwise FALSE + * @brief Load a capabilities object from a prepackaged file + * + * The location of the prepackaged file is: OPENSYNC_CAPABILITIESDIR/$file + * + * @param file The name of the file + * @param error The error which will hold the info in case of an error + * @return The pointer to the newly allocated capabilities object or NULL in case of error */ -osync_bool osync_capabilities_member_has_capabilities(OSyncMember *member); +OSYNC_TEST_EXPORT OSyncCapabilities *osync_capabilities_load_identifier(const char *file, OSyncError **error); /** - * @brief Get the cached capabilities of a member. The cache capabilities is stored as - * "capabilities.xml" in the member directory. This function should be only used - * internal. To get the current capabilities of a member please use: - * osync_member_get_capabilities() - * - * @param member The pointer to a member object + * @brief Dump the capabilities into memory. + * @param capabilities The pointer to a capabilities object * @param error The error which will hold the info in case of an error - * @return The objtype of the xmlformat + * @return The xml document and the size of it. It's up to the caller to free + * the buffer. Always it return TRUE. */ -OSyncCapabilities* osync_capabilities_member_get_capabilities(OSyncMember *member, OSyncError** error); +OSYNC_TEST_EXPORT osync_bool osync_capabilities_assemble(OSyncCapabilities *capabilities, char **buffer, unsigned int *size, OSyncError **error); /** - * @brief Set the capabilities of a member. The capabilities get cached in the member directory - * as "capabilities.xml". This function should be only used internal. To set member - * capabilities, please use: - * osync_member_set_capabilities() - * - * @param member The pointer to a member object - * @param capabilities The pointer to a capabilities object + * @brief Creates a new capabilities object from an xml document. + * @param buffer The pointer to the xml document + * @param size The size of the xml document * @param error The error which will hold the info in case of an error - * @return TRUE on success otherwise FALSE + * @return The pointer to the newly allocated capabilities object or NULL in case of error */ -osync_bool osync_capabilities_member_set_capabilities(OSyncMember *member, OSyncCapabilities* capabilities, OSyncError** error); +OSYNC_TEST_EXPORT OSyncCapabilities *osync_capabilities_parse(const char *buffer, unsigned int size, OSyncError **error); /*@}*/ + +OSYNC_TEST_EXPORT void osync_capabilities_add_objtype(OSyncCapabilities *capabilities, OSyncCapabilitiesObjType *capsobjtype); + +OSYNC_TEST_EXPORT void osync_capabilities_set_format(OSyncCapabilities *capabilities, const char *capsformat); + +OSYNC_TEST_EXPORT OSyncCapabilityParameter *osync_capability_parameter_new(OSyncError **error); +OSYNC_TEST_EXPORT OSyncCapabilityParameter *osync_capability_parameter_ref(OSyncCapabilityParameter *capparam); +OSYNC_TEST_EXPORT void osync_capability_parameter_unref(OSyncCapabilityParameter *capparam); + #endif /*OPENSYNC_CAPABILITIES_INTERNAL_H_*/ Modified: trunk/opensync/capabilities/opensync_capabilities_private.h ============================================================================== --- trunk/opensync/capabilities/opensync_capabilities_private.h Tue Sep 1 11:49:03 2009 (r5719) +++ trunk/opensync/capabilities/opensync_capabilities_private.h Tue Sep 1 13:40:46 2009 (r5720) @@ -34,55 +34,19 @@ /*@{*/ /** - * @brief Represent a CapabilitiesObjType object - */ -struct OSyncCapabilitiesObjType { - /** The pointer to the next objtype */ - OSyncCapabilitiesObjType *next; - /** The pointer to the root capability */ - OSyncCapability *capability; - /** The pointer to the first capability */ - OSyncCapability *first_child; - /** The pointer to the last capability */ - OSyncCapability *last_child; - /** Counter which holds the number of capabilities for one objtype*/ - unsigned int child_count; - /** The wrapped xml node */ - xmlNodePtr node; -}; - -/** * @brief Represent a Capabilities object */ struct OSyncCapabilities { /** The reference counter for this object */ int ref_count; - /** The pointer to the first objtype */ - OSyncCapabilitiesObjType *first_objtype; - /** The pointer to the last objtype */ - OSyncCapabilitiesObjType *last_objtype; + /** Capabilities Format */ + char *format; + /** ObjTypes **/ + OSyncList *objtypes; /* OSyncCapabilitiesObjType */ /** The wrapped xml document */ xmlDocPtr doc; }; -/** - * @brief Creates a new capabilitiesobjtype object which will be added to the end of capabilitiesobjtype of the capabilities object. - * The returned object will be freed with the capabilities object. - * @param capabilities The pointer to a capabilities object - * @param node The node must be already inserted at the end of childs of the xmlDoc root element - * @param error The error which will hold the info in case of an error - * @return The pointer to the newly allocated capabilitiesobjtype object or NULL in case of error - */ -OSyncCapabilitiesObjType *osync_capabilitiesobjtype_new(OSyncCapabilities *capabilities, xmlNodePtr node, OSyncError **error); - -/** - * @brief Get the first capabilitiesobjtype for a given objtype from the capabilities - * @param capabilities The pointer to a capabilities object - * @param objtype The name of the objtype (e.g.: contact) - * @return The capabilitiesobjtype for a given objtype from the capabilities - */ -OSyncCapabilitiesObjType *osync_capabilitiesobjtype_get(OSyncCapabilities *capabilities, const char *objtype); - /*@}*/ #endif /*OPENSYNC_CAPABILITIES_PRIVATE_H_*/ Modified: trunk/opensync/capabilities/opensync_capability.c ============================================================================== --- trunk/opensync/capabilities/opensync_capability.c Tue Sep 1 11:49:03 2009 (r5719) +++ trunk/opensync/capabilities/opensync_capability.c Tue Sep 1 13:40:46 2009 (r5720) @@ -30,241 +30,318 @@ #include "opensync_capability_private.h" -OSyncCapability *osync_capability_new_node(OSyncCapabilitiesObjType *capabilitiesobjtype, xmlNodePtr node, OSyncError **error) +int osync_capability_compare_stdlib(const void *capability1, const void *capability2) { - OSyncCapability *capability = NULL; + return strcmp(osync_capability_get_name(*(OSyncCapability **)capability1), osync_capability_get_name(*(OSyncCapability **)capability2)); +} + +OSyncCapability *osync_capability_parse(OSyncCapabilitiesObjType *capabilitiesobjtype, xmlNodePtr node, OSyncError **error) +{ + xmlNode *cur; + OSyncCapability *cap = NULL; osync_assert(capabilitiesobjtype); osync_assert(node); - - capability = osync_try_malloc0(sizeof(OSyncCapability), error); - if(!capability) { - osync_trace(TRACE_ERROR, "%s: %s" , __func__, osync_error_print(error)); - return NULL; + + cur = node; + + cap = osync_capability_new(capabilitiesobjtype, error); + if (!cap) + goto error; + + cur = cur->children; + for (; cur != NULL; cur = cur->next) { + char *str = NULL; + + if (cur->type != XML_ELEMENT_NODE) + continue; + + str = (char*)xmlNodeGetContent(cur); + if (!str) + continue; + + if (!xmlStrcmp(cur->name, BAD_CAST "Name")) + osync_capability_set_name(cap, str); + else if (!xmlStrcmp(cur->name, BAD_CAST "DisplayName")) + osync_capability_set_displayname(cap, str); + else if (!xmlStrcmp(cur->name, BAD_CAST "MaxOccurs")) + osync_capability_set_maxoccurs(cap, atoi(str)); + else if (!xmlStrcmp(cur->name, BAD_CAST "Max")) + osync_capability_set_max(cap, atoi(str)); + else if (!xmlStrcmp(cur->name, BAD_CAST "Min")) + osync_capability_set_min(cap, atoi(str)); + else if (!xmlStrcmp(cur->name, BAD_CAST "Parameter")) + ; //TODO + else if (!xmlStrcmp(cur->name, BAD_CAST "Type")) + ; //TODO + else if (!xmlStrcmp(cur->name, BAD_CAST "ValEnum")) + osync_list_prepend(cap->valenum, osync_strdup(str)); + + osync_xml_free(str); } - capability->next = NULL; - capability->node = node; - capability->prev = capabilitiesobjtype->last_child; - node->_private = capability; - - capabilitiesobjtype->capability = capability; - - return capability; + return cap; + +error: + osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error)); + return NULL; } -OSyncCapability *osync_capability_new_capability(OSyncCapability *parent, xmlNodePtr node, OSyncError **error) +osync_bool osync_capability_assemble(OSyncCapability *cap, xmlNodePtr node, OSyncError **error) { - OSyncCapability *capability = NULL; + char *tmp; + xmlNode *cur; + OSyncList *l; + osync_assert(cap); osync_assert(node); - - capability = osync_try_malloc0(sizeof(OSyncCapability), error); - if (!capability) { - osync_trace(TRACE_ERROR, "%s: %s" , __func__, osync_error_print(error)); - return NULL; - } - - capability->next = NULL; - capability->node = node; - capability->parent = parent; - node->_private = capability; - - if (parent) { - capability->prev = parent->child; - if (capability->prev) - capability->prev->next = capability; - parent->child = capability; + cur = xmlNewChild(node, NULL, (xmlChar*)"Cap", NULL); + if (!cur) + goto error_oom; + + /* DisplayName */ + if (!xmlNewChild(cur, NULL, (xmlChar*)"DisplayName", + (xmlChar*)osync_capability_get_displayname(cap))) + goto error_oom; + + /* MaxOccurs */ + tmp = osync_strdup_printf("%u", osync_capability_get_maxoccurs(cap)); + if (!tmp) + goto error_oom; + + if (!xmlNewChild(cur, NULL, (xmlChar*)"MaxOccurs", (xmlChar*)tmp)) + goto error_oom; + + /* Max */ + tmp = osync_strdup_printf("%u", osync_capability_get_max(cap)); + if (!tmp) + goto error_oom; + + if (!xmlNewChild(cur, NULL, (xmlChar*)"Max", (xmlChar*)tmp)) + goto error_oom; + + /* Min */ + tmp = osync_strdup_printf("%u", osync_capability_get_min(cap)); + if (!tmp) + goto error_oom; + + if (!xmlNewChild(cur, NULL, (xmlChar*)"Min", (xmlChar*)tmp)) + goto error_oom; + + /* Name */ + if (!xmlNewChild(cur, NULL, (xmlChar*)"Name", + (xmlChar*)osync_capability_get_name(cap))) + goto error_oom; + + /* Parameter TODO */ + /* Type TODO */ + + /* ValEnum */ + for (l = cap->valenum; l; l = l->next) { + if (!xmlNewChild(cur, NULL, (xmlChar*)"ValEnum", + (xmlChar*)l->data)) + goto error_oom; } - - return capability; + + return TRUE; + +error_oom: + osync_error_set(error, OSYNC_ERROR_GENERIC, "No memory left to assemble capability."); +/* +error: +*/ + osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error)); + return FALSE; } -osync_bool osync_capability_parse(OSyncCapability *parent, xmlNodePtr node, OSyncCapability **first_child, OSyncCapability **last_child, unsigned int *child_count, OSyncError **error) +OSyncCapability *osync_capability_new(OSyncCapabilitiesObjType *capobjtype, OSyncError **error) { OSyncCapability *capability = NULL; - unsigned int count = 0; - - if (first_child) - *first_child = NULL; + osync_trace(TRACE_ENTRY, "%s(%p, %s, %p)", __func__, capobjtype, error); + osync_assert(capobjtype); + + capability = osync_try_malloc0(sizeof(OSyncCapability), error); + if(!capability) + goto error; - while (node != NULL) { + osync_capabilities_objtype_add_capability(capobjtype, capability); + + osync_trace(TRACE_EXIT, "%s: %p", __func__, capability); + return capability; - capability = osync_capability_new_capability(parent, node, error); - if (!capability) - goto error; +error: + osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error)); + return NULL; - if (first_child && !(*first_child)) { - *first_child = capability; - } +} - count++; +OSyncCapability *osync_capability_ref(OSyncCapability *capability) +{ + osync_assert(capability); + + g_atomic_int_inc(&(capability->ref_count)); - if (node->children && node->children->type == XML_ELEMENT_NODE) - if (!osync_capability_parse(capability, node->children, NULL, NULL, NULL, error)) - goto error_and_free; + return capability; +} - node = node->next; +void osync_capability_unref(OSyncCapability *capability) +{ + osync_assert(capability); + + if (g_atomic_int_dec_and_test(&(capability->ref_count))) { + /* TODO free struct members */ + osync_free(capability); } +} - if (last_child) - *last_child = capability; +const char *osync_capability_get_name(OSyncCapability *capability) +{ + osync_assert(capability); + + return (const char *) capability->name; +} - if (child_count) - *child_count = count; +void osync_capability_set_name(OSyncCapability *capability, const char *name) +{ + osync_assert(capability); + osync_assert(name); - return TRUE; + if (capability->name) + osync_free(capability->name); -error_and_free: - osync_capability_free(capability); -error: + capability->name = osync_strdup(name); +} - if (last_child) - *last_child = NULL; - if (first_child) - *first_child = NULL; +const char *osync_capability_get_displayname(OSyncCapability *capability) +{ + osync_assert(capability); - osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error)); - return FALSE; + return (const char *) capability->displayname; +} + +void osync_capability_set_displayname(OSyncCapability *capability, const char *displayname) +{ + osync_assert(capability); + osync_assert(displayname); + if (capability->displayname) + osync_free(capability->displayname); + + capability->displayname = osync_strdup(displayname); } -void osync_capability_free(OSyncCapability *capability) +unsigned int osync_capability_get_maxoccurs(OSyncCapability *capability) { - OSyncCapability *tmp; osync_assert(capability); - while (capability->child) { - tmp = osync_capability_get_next(capability->child); - osync_capability_free(capability->child); - capability->child = tmp; - } - - osync_free(capability); + return capability->maxoccurs; } -int osync_capability_compare_stdlib(const void *capability1, const void *capability2) +void osync_capability_set_maxoccurs(OSyncCapability *capability, unsigned int maxoccurs) { - return strcmp(osync_capability_get_name(*(OSyncCapability **)capability1), osync_capability_get_name(*(OSyncCapability **)capability2)); + osync_assert(capability); + + capability->maxoccurs = maxoccurs; } -OSyncCapability *osync_capability_new(OSyncCapabilities *capabilities, const char *objtype, const char *name, OSyncError **error) +unsigned int osync_capability_get_max(OSyncCapability *capability) { - OSyncCapabilitiesObjType *capabilitiesobjtype = NULL; - xmlNodePtr node = NULL; - OSyncCapability *capability = NULL; - osync_trace(TRACE_ENTRY, "%s(%p, %s, %s, %p)", __func__, capabilities, objtype, name, error); - osync_assert(capabilities); - osync_assert(objtype); - osync_assert(name); - - capabilitiesobjtype = osync_capabilitiesobjtype_get(capabilities, objtype); - if(!capabilitiesobjtype) { - xmlNodePtr node = xmlNewTextChild(xmlDocGetRootElement(capabilities->doc), NULL, BAD_CAST objtype, NULL); - capabilitiesobjtype = osync_capabilitiesobjtype_new(capabilities, node, error); - if(!capabilitiesobjtype) { - xmlUnlinkNode(node); - xmlFreeNode(node); - osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error)); - return NULL; - } - } - - node = xmlNewTextChild(capabilitiesobjtype->node, NULL, (xmlChar *)name, NULL); - capability = osync_capability_new_node(capabilitiesobjtype, node, error); - if(!capability) { - xmlUnlinkNode(node); - xmlFreeNode(node); - osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error)); - return NULL; - } - - osync_trace(TRACE_EXIT, "%s: %p", __func__, capability); - return capability; + osync_assert(capability); + + return capability->max; } -const char *osync_capability_get_name(OSyncCapability *capability) +void osync_capability_set_max(OSyncCapability *capability, unsigned int max) { osync_assert(capability); - - return (const char *) capability->node->name; + + capability->max = max; } -OSyncCapability *osync_capability_get_next(OSyncCapability *capability) +unsigned int osync_capability_get_min(OSyncCapability *capability) { - osync_return_val_if_fail(capability, NULL); - - return capability->next; + osync_assert(capability); + + return capability->min; } -OSyncCapability *osync_capability_get_prev(OSyncCapability *capability) +void osync_capability_set_min(OSyncCapability *capability, unsigned int min) { - osync_return_val_if_fail(capability, NULL); - - return capability->prev; + osync_assert(capability); + + capability->min = min; } -OSyncCapability *osync_capability_get_child(OSyncCapability *capability) +OSyncCapabilityParameter *osync_capability_get_parameter(OSyncCapability *capability) { - osync_return_val_if_fail(capability, NULL); - - return capability->child; + osync_assert(capability); + + return capability->parameter; } -OSyncCapability *osync_capability_get_parent(OSyncCapability *capability) +void osync_capability_set_parameter(OSyncCapability *capability, OSyncCapabilityParameter *parameter) { - osync_return_val_if_fail(capability, NULL); - - return capability->parent; + osync_assert(capability); + osync_assert(parameter); + + if (capability->parameter) + osync_capability_parameter_unref(capability->parameter); + + capability->parameter = osync_capability_parameter_ref(parameter); } -osync_bool osync_capability_has_key(OSyncCapability *capability) +OSyncCapabilityType osync_capability_get_type(OSyncCapability *capability) { osync_assert(capability); - if(capability->node->children) - return TRUE; - else - return FALSE; + return capability->type; } -unsigned int osync_capability_get_key_count(OSyncCapability *capability) +void osync_capability_set_type(OSyncCapability *capability, OSyncCapabilityType type) { - unsigned int count; - xmlNodePtr child = NULL; + osync_assert(capability); + + capability->type = type; +} +OSyncList *osync_capability_get_valenums(OSyncCapability *capability) +{ osync_assert(capability); - - child = capability->node->xmlChildrenNode; - - for(count=0 ; child != NULL; child = child->next) - count++; - - return count; + + return capability->valenum; } -const char *osync_capability_get_nth_key(OSyncCapability *capability, unsigned int nth) +OSyncCapabilityParameter *osync_capability_parameter_new(OSyncError **error) { - unsigned int count = 0; - xmlNodePtr child = NULL; + OSyncCapabilityParameter *capparam; - osync_assert(capability); - - child = capability->node->xmlChildrenNode; - - for(count=0; child != NULL; child = child->next) { - if(count == nth) - return (const char *)child->name; - count++; - } - + capparam = osync_try_malloc0(sizeof(OSyncCapabilityParameter), error); + if (!capparam) + goto error; + + capparam->ref_count = 1; + + return capparam; + +error: return NULL; } -void osync_capability_add_key(OSyncCapability *capability, const char *name) +OSyncCapabilityParameter *osync_capability_parameter_ref(OSyncCapabilityParameter *capparam) { - osync_assert(capability); - osync_assert(name); - - xmlNewTextChild(capability->node, NULL, (xmlChar*)name, NULL); + osync_assert(capparam); + g_atomic_int_inc(&(capparam->ref_count)); + return capparam; +} + +void osync_capability_parameter_unref(OSyncCapabilityParameter *capparam) +{ + osync_assert(capparam); + + if (g_atomic_int_dec_and_test(&(capparam->ref_count))) { + osync_trace(TRACE_ENTRY, "%s(%p)", __func__, capparam); + osync_trace(TRACE_EXIT, "%s", __func__); + } + } + Modified: trunk/opensync/capabilities/opensync_capability.h ============================================================================== --- trunk/opensync/capabilities/opensync_capability.h Tue Sep 1 11:49:03 2009 (r5719) +++ trunk/opensync/capabilities/opensync_capability.h Tue Sep 1 13:40:46 2009 (r5720) @@ -31,17 +31,45 @@ */ /*@{*/ +/** @brief Capability value types + * + **/ +typedef enum { + /** None */ + OSYNC_CAPABILITY_TYPE_NONE = 0, + /** bool */ + OSYNC_CAPABILITY_TYPE_BOOL, + /** char */ + OSYNC_CAPABILITY_TYPE_CHAR, + /** double */ + OSYNC_CAPABILITY_TYPE_DOUBLE, + /** int */ + OSYNC_CAPABILITY_TYPE_INT, + /** long */ + OSYNC_CAPABILITY_TYPE_LONG, + /** long long */ + OSYNC_CAPABILITY_TYPE_LONGLONG, + /** unsigned int */ + OSYNC_CAPABILITY_TYPE_UINT, + /** unsigned long */ + OSYNC_CAPABILITY_TYPE_ULONG, + /** unsigned long long */ + OSYNC_CAPABILITY_TYPE_ULONGLONG, + /** String (char *) */ + OSYNC_CAPABILITY_TYPE_STRING +} OSyncCapabilityType; + /** * @brief Creates a new capability object which will be added to the end of capabilities of the capabilities object. * The returned object will be freed with the capabilities object. - * @param capabilities The pointer to a capabilities object - * @param objtype The name of the objtype (e.g.: contact) - * @param name The name of the capability + * @param capobjtype The pointer to a capabilities objtype object * @param error The error which will hold the info in case of an error * @return The pointer to the newly allocated capability object or NULL in case of error */ -OSYNC_EXPORT OSyncCapability *osync_capability_new(OSyncCapabilities *capabilities, const char *objtype, const char *name, OSyncError **error); +OSYNC_EXPORT OSyncCapability *osync_capability_new(OSyncCapabilitiesObjType* capobjtype, OSyncError **error); +OSYNC_EXPORT OSyncCapability *osync_capability_ref(OSyncCapability *capability); +OSYNC_EXPORT void osync_capability_unref(OSyncCapability *capability); /** * @brief Get the name of the capability @@ -51,61 +79,105 @@ OSYNC_EXPORT const char *osync_capability_get_name(OSyncCapability *capability); /** - * @brief Get the next capability + * @brief Set the name of the capability + * @param capability The pointer to a capability object + * @param name The name of the capability to set + */ +OSYNC_EXPORT void osync_capability_set_name(OSyncCapability *capability, const char *name); + +/** + * @brief Get the display name of the capability + * @param capability The pointer to a capability object + * @return The display name of the capability + */ +OSYNC_EXPORT const char *osync_capability_get_displayname(OSyncCapability *capability); + +/** + * @brief Set the display name of the capability + * @param capability The pointer to a capability object + * @param displayname The displayname of the capability to set + */ +OSYNC_EXPORT void osync_capability_set_displayname(OSyncCapability *capability, const char *displayname); + +/** + * @brief Get max occurs of the capability + * @param capability The pointer to a capability object + * @return The number of max occurs of the capability + */ +OSYNC_EXPORT unsigned int osync_capability_get_maxoccurs(OSyncCapability *capability); + +/** + * @brief Set max occurs of the capability + * @param capability The pointer to a capability object + * @param maxoccurs The number of max occurs of the capability object + */ +OSYNC_EXPORT void osync_capability_set_maxoccurs(OSyncCapability *capability, unsigned int maxoccurs); + +/** + * @brief Get max length/size of the capability value + * @param capability The pointer to a capability object + * @return The max length/size of the capability value + */ +OSYNC_EXPORT unsigned int osync_capability_get_max(OSyncCapability *capability); + +/** + * @brief Set the max length/size of the capability value * @param capability The pointer to a capability object - * @return The pointer to the next capability or NULL if there is no more capability + * @param max The max lenth/size of the capability value */ -OSYNC_EXPORT OSyncCapability *osync_capability_get_next(OSyncCapability *capability); +OSYNC_EXPORT void osync_capability_set_max(OSyncCapability *capability, unsigned int max); /** - * @brief Get the previous capability + * @brief Get min length/size of the capability value * @param capability The pointer to a capability object - * @return The pointer to the previous capability or NULL if there is no more capability + * @return The min length/size of the capability value */ -OSYNC_EXPORT OSyncCapability *osync_capability_get_prev(OSyncCapability *capability); +OSYNC_EXPORT unsigned int osync_capability_get_min(OSyncCapability *capability); /** - * @brief Get the child capability + * @brief Set the min length/size of the capability value * @param capability The pointer to a capability object - * @return The pointer to the child capability or NULL if there is no more capability + * @param min The min lenth/size of the capability value */ -OSYNC_EXPORT OSyncCapability *osync_capability_get_child(OSyncCapability *capability); +OSYNC_EXPORT void osync_capability_set_min(OSyncCapability *capability, unsigned int min); /** - * @brief Get the parent capability + * @brief Get capability parameter of this capability object * @param capability The pointer to a capability object - * @return The pointer to the parent capability or NULL if there is no more capability + * @return Pointer to the capability parameter of this capability object */ -OSYNC_EXPORT OSyncCapability *osync_capability_get_parent(OSyncCapability *capability); +OSYNC_EXPORT OSyncCapabilityParameter *osync_capability_get_parameter(OSyncCapability *capability); /** - * @brief Check if the capability has a key + * @brief Set the capability parameter of the capability object * @param capability The pointer to a capability object - * @return TRUE if the capability has a key otherwise FALSE + * @param parameter the parameter to set for the capability object */ -OSYNC_EXPORT osync_bool osync_capability_has_key(OSyncCapability *capability); +OSYNC_EXPORT void osync_capability_set_parameter(OSyncCapability *capability, OSyncCapabilityParameter *parameter); /** - * @brief Get the count of keys of a capability + * @brief Get capability type of this capability object * @param capability The pointer to a capability object - * @return The count of keys of the capability + * @return Type of this capability */ -OSYNC_EXPORT unsigned int osync_capability_get_key_count(OSyncCapability *capability); +OSYNC_EXPORT OSyncCapabilityType osync_capability_get_type(OSyncCapability *capability); /** - * @brief Get the name of the nth key of a capability + * @brief Set capability type for capability object * @param capability The pointer to a capability object - * @param nth The number of the key - * @return The name of the nth key of the capability or NULL in case of error + * @param type The type to set for the capability object */ -OSYNC_EXPORT const char *osync_capability_get_nth_key(OSyncCapability *capability, unsigned int nth); +OSYNC_EXPORT void osync_capability_set_type(OSyncCapability *capability, OSyncCapabilityType type); /** - * @brief Add a key to a capability + * @brief Get valenum of this capability objects. Contains possible value of + * this capability object + * * @param capability The pointer to a capability object - * @param name The name of the key + * @return Returns OSyncList with strings (const char*) with possible values + * of this capability object */ -OSYNC_EXPORT void osync_capability_add_key(OSyncCapability *capability, const char *name); +OSYNC_EXPORT OSyncList *osync_capability_get_valenums(OSyncCapability *capability); /* const char* list */ /*@}*/ Modified: trunk/opensync/capabilities/opensync_capability_internals.h ============================================================================== --- trunk/opensync/capabilities/opensync_capability_internals.h Tue Sep 1 11:49:03 2009 (r5719) +++ trunk/opensync/capabilities/opensync_capability_internals.h Tue Sep 1 13:40:46 2009 (r5720) @@ -39,23 +39,11 @@ * @param error The error which will hold the info in case of an error * @return The pointer to the newly allocated capability object or NULL in case of error */ -OSyncCapability *osync_capability_new_node(OSyncCapabilitiesObjType *objtype, xmlNodePtr node, OSyncError **error); +OSyncCapability *osync_capability_parse(OSyncCapabilitiesObjType *objtype, xmlNodePtr node, OSyncError **error); -/** - * @brief Multi-level parsing of OSyncCapability based on a given XML Node. - * - * This function create a Capability-tree out of the given xmlNode pointer. This function - * is calling it self in a recursion and parses all siblings and child of the given xmlNode pointer. - * - * @param parent The parent OSyncCapability - * @param node The node to start parsing the capabilities. - * @param first_child Reference to a pointer to store the first parsed OSyncCapability child - * @param last_child Reference to a pointer to store the last parsed OSyncCapability child - * @param child_count Reference to unsinged int to count the childs of the capability node - * @param error The error which will hold the info in case of an error - * @returns TRUE on success, FALSE on error - */ -osync_bool osync_capability_parse(OSyncCapability *parent, xmlNodePtr node, OSyncCapability **first_child, OSyncCapability **last_child, unsigned int *child_count, OSyncError **error); + +/* TODO - Doxygen */ +osync_bool osync_capability_assemble(OSyncCapability *cap, xmlNodePtr node, OSyncError **error); /** * @brief Frees a capability object Modified: trunk/opensync/capabilities/opensync_capability_private.h ============================================================================== --- trunk/opensync/capabilities/opensync_capability_private.h Tue Sep 1 11:49:03 2009 (r5719) +++ trunk/opensync/capabilities/opensync_capability_private.h Tue Sep 1 13:40:46 2009 (r5720) @@ -35,18 +35,48 @@ * @brief Represents a Capability object */ struct OSyncCapability { - /** The pointer to the parent capability */ - OSyncCapability *parent; - /** The pointer to the child capability */ - OSyncCapability *child; - /** The pointer to the next capability */ - OSyncCapability *next; - /** The pointer to the previous capability */ - OSyncCapability *prev; - /** The wrapped xml node */ - xmlNodePtr node; + /** CapabilityObjType parent object */ + OSyncCapabilitiesObjType *capobjtype; + /** DisplayName */ + char *displayname; + /** MaxOccurs */ + unsigned int maxoccurs; + /** Max */ + unsigned int max; + /** Min */ + unsigned int min; + /** Name */ + char *name; + /** Parameter */ + OSyncCapabilityParameter *parameter; + /** Type */ + OSyncCapabilityType type; + /** ValEnum */ + OSyncList *valenum; /* char* */ + /** Value */ + char *value; + + /** Reference counting */ + int ref_count; }; +struct OSyncCapabilityParameter { + /** DisplayName */ + char *displayname; + /** Name */ + char *name; + /** Type */ + OSyncCapabilityType type; + /** ValEnum */ + OSyncList *valenum; /* char* */ + /** Value */ + char *value; + + /** Reference counting */ + int ref_count; +}; + + /*@}*/ #endif /* OPENSYNC_CAPABILITY_PRIVATE_H_ */ Modified: trunk/opensync/client/opensync_client.c ============================================================================== --- trunk/opensync/client/opensync_client.c Tue Sep 1 11:49:03 2009 (r5719) +++ trunk/opensync/client/opensync_client.c Tue Sep 1 13:40:46 2009 (r5720) @@ -37,6 +37,7 @@ #include "opensync-format.h" #include "opensync-capabilities.h" +#include "capabilities/opensync_capabilities_internals.h" #include "opensync-version.h" #include "version/opensync_version_internals.h" @@ -833,7 +834,7 @@ OSyncVersion *version = NULL; OSyncCapabilities *capabilities = NULL; char* buffer = NULL; - int size = 0; + unsigned int size = 0; unsigned int num_res = 0; OSyncPluginResource *resource = NULL; OSyncList *objtypesinks = NULL; @@ -897,7 +898,7 @@ capabilities = osync_plugin_info_get_capabilities(client->plugin_info); if (capabilities) { osync_message_write_int(reply, 1); - if(!osync_capabilities_assemble(capabilities, &buffer, &size)) + if (!osync_capabilities_assemble(capabilities, &buffer, &size, error)) goto error_free_message; osync_message_write_string(reply, buffer); g_free(buffer); Modified: trunk/opensync/client/opensync_client_proxy.c ============================================================================== --- trunk/opensync/client/opensync_client_proxy.c Tue Sep 1 11:49:03 2009 (r5719) +++ trunk/opensync/client/opensync_client_proxy.c Tue Sep 1 13:40:46 2009 (r5720) @@ -30,6 +30,8 @@ #include "plugin/opensync_objtype_sink_internals.h" #include "opensync-capabilities.h" +#include "capabilities/opensync_capabilities_internals.h" + #include "opensync-group.h" #include "opensync-plugin.h" #include "opensync-format.h" Modified: trunk/opensync/engine/opensync_engine.c ========================... [truncated message content] |
From: <svn...@op...> - 2009-09-01 09:49:20
|
Author: dgollub Date: Tue Sep 1 11:49:03 2009 New Revision: 5719 URL: http://www.opensync.org/changeset/5719 Log: Add missing symbols Modified: branches/opensync-ticket1084/opensync.sym Modified: branches/opensync-ticket1084/opensync.sym ============================================================================== --- branches/opensync-ticket1084/opensync.sym Sat Aug 15 14:36:27 2009 (r5718) +++ branches/opensync-ticket1084/opensync.sym Tue Sep 1 11:49:03 2009 (r5719) @@ -330,6 +330,11 @@ osync_member_set_objtype_enabled osync_member_set_pluginname osync_member_unref +osync_merger_new +osync_merger_ref +osync_merger_set_finalize_func +osync_merger_set_initialize_func +osync_merger_unref osync_obj_engine_command osync_obj_engine_event osync_obj_engine_finalize @@ -356,13 +361,11 @@ osync_objformat_set_copy_func osync_objformat_set_create_func osync_objformat_set_demarshal_func -osync_objformat_set_demerge_func osync_objformat_set_destroy_func osync_objformat_set_duplicate_func osync_objformat_set_finalize_func osync_objformat_set_initialize_func osync_objformat_set_marshal_func -osync_objformat_set_merge_func osync_objformat_set_print_func osync_objformat_set_revision_func osync_objformat_set_validate_func |
From: <svn...@op...> - 2009-08-20 12:39:05
|
Author: bellmich Date: Thu Aug 20 14:38:51 2009 New Revision: 1257 URL: http://libsyncml.opensync.org/changeset/1257 Log: added support for Samsung E250i with Teleca SyncML Client Actually the mobile does not work because the server authentication is still missing. Modified: trunk/libsyncml/transports/obex_client_samsung.c Modified: trunk/libsyncml/transports/obex_client_samsung.c ============================================================================== --- trunk/libsyncml/transports/obex_client_samsung.c Mon Aug 10 11:28:41 2009 (r1256) +++ trunk/libsyncml/transports/obex_client_samsung.c Thu Aug 20 14:38:51 2009 (r1257) @@ -110,6 +110,13 @@ } smlSafeCFree(&tmp); } + } else if ( + /* Teleca SyncML Client */ + !g_strcasecmp("E250i", env->model) + ) + { + smlTrace(TRACE_INTERNAL, "%s: Teleca SyncML Client", __func__); + env->at_command = g_strdup_printf("AT$TSSPCSW=1"); } else { g_warning("Unknown Samsung mobile device %s - using default AT command.", env->model); |
From: <svn...@op...> - 2009-08-15 12:36:49
|
Author: scriptor Date: Sat Aug 15 14:36:27 2009 New Revision: 5718 URL: http://www.opensync.org/changeset/5718 Log: I have removed one debug setting that had accidentally crept into the svn repository. Modified: plugins/ldap-sync/src/ldap_plugin.h Modified: plugins/ldap-sync/src/ldap_plugin.h ============================================================================== --- plugins/ldap-sync/src/ldap_plugin.h Sat Aug 15 14:36:00 2009 (r5717) +++ plugins/ldap-sync/src/ldap_plugin.h Sat Aug 15 14:36:27 2009 (r5718) @@ -150,7 +150,7 @@ ///< ldap_format_convert_xmlinternal2ldap() -// undef DEBUG_auth +#undef DEBUG_auth #undef DEBUG_configuration #undef DEBUG_detection #undef DEBUG_ldapdata_from_server |
From: <svn...@op...> - 2009-08-15 12:36:18
|
Author: scriptor Date: Sat Aug 15 14:36:00 2009 New Revision: 5717 URL: http://www.opensync.org/changeset/5717 Log: I have increased the general timeout from 5 minutes to 8 minutes. At least sometimes it seems, that this is necessary for the test "osynctool_add_mod_del_all_four_xmlfiles". Modified: plugins/ldap-sync/CTestConfig.cmake plugins/ldap-sync/tests/CMakeLists.txt Modified: plugins/ldap-sync/CTestConfig.cmake ============================================================================== --- plugins/ldap-sync/CTestConfig.cmake Thu Aug 13 23:00:54 2009 (r5716) +++ plugins/ldap-sync/CTestConfig.cmake Sat Aug 15 14:36:00 2009 (r5717) @@ -22,7 +22,7 @@ IF (RUN_LONG_TESTS) SET ( TIMEOUT 3600 CACHE STRING "General timeout value." FORCE ) ELSE(RUN_LONG_TESTS) - SET ( TIMEOUT 300 CACHE STRING "General timeout value." FORCE ) + SET ( TIMEOUT 480 CACHE STRING "General timeout value." FORCE ) ENDIF(RUN_LONG_TESTS) SET ( CTEST_TEST_TIMEOUT ${TIMEOUT} CACHE STRING "The most natural variable for a timeout setting does NOT work. Great!" FORCE ) Modified: plugins/ldap-sync/tests/CMakeLists.txt ============================================================================== --- plugins/ldap-sync/tests/CMakeLists.txt Thu Aug 13 23:00:54 2009 (r5716) +++ plugins/ldap-sync/tests/CMakeLists.txt Sat Aug 15 14:36:00 2009 (r5717) @@ -22,7 +22,7 @@ IF (RUN_LONG_TESTS) SET ( TIMEOUT 3600 CACHE STRING "General timeout value." FORCE ) ELSE(RUN_LONG_TESTS) - SET ( TIMEOUT 300 CACHE STRING "General timeout value." FORCE ) + SET ( TIMEOUT 480 CACHE STRING "General timeout value." FORCE ) ENDIF(RUN_LONG_TESTS) SET ( CTEST_TEST_TIMEOUT ${TIMEOUT} CACHE STRING "The most natural variable for a timeout setting does NOT work. Great!" FORCE ) |
From: <svn...@op...> - 2009-08-13 21:01:06
|
Author: scriptor Date: Thu Aug 13 23:00:54 2009 New Revision: 5716 URL: http://www.opensync.org/changeset/5716 Log: Changed test.conf to the settings usable for slapd by openldap. Please note: tests/test.conf must be in line with the settings in tests/ldap-sync.conf. However, the authentication specific tests work independently from tests/ldap-sync.conf. Each authentication method and each LDAP server has its own version of an ldap-sync.conf. Modified: plugins/ldap-sync/tests/test.conf Modified: plugins/ldap-sync/tests/test.conf ============================================================================== --- plugins/ldap-sync/tests/test.conf Thu Aug 13 23:00:30 2009 (r5715) +++ plugins/ldap-sync/tests/test.conf Thu Aug 13 23:00:54 2009 (r5716) @@ -11,10 +11,10 @@ # ldapadd etc. only. It is NOT used for the ldap-sync plugin of libopensync. ### Examples for slapd from openldap for the ldap utilities from openldap: ### #AUTH="-Y DIGEST-MD5 -U ldap_user -w secret -Q" -#AUTH="-Y GSSAPI -Q" +AUTH="-Y GSSAPI -Q" ### Example for ns-slapd from the fedora directory server for the ldap ### utilities from openldap: ### -AUTH="-x -D cn=ldap_user,ou=People,dc=example,dc=com -w secret -h localhost -p 3890" +#AUTH="-x -D cn=ldap_user,ou=People,dc=example,dc=com -w secret -h localhost -p 3890" ######################### |
From: <svn...@op...> - 2009-08-13 21:00:41
|
Author: scriptor Date: Thu Aug 13 23:00:30 2009 New Revision: 5715 URL: http://www.opensync.org/changeset/5715 Log: I have removed the target "ldap_plugin_auth", as ldap_plugin_auth.c does not exist any more. Modified: plugins/ldap-sync/tests/CMakeLists.txt Modified: plugins/ldap-sync/tests/CMakeLists.txt ============================================================================== --- plugins/ldap-sync/tests/CMakeLists.txt Thu Aug 13 23:00:08 2009 (r5714) +++ plugins/ldap-sync/tests/CMakeLists.txt Thu Aug 13 23:00:30 2009 (r5715) @@ -552,9 +552,6 @@ INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ${OPENSYNC_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIRS} ${LIBXSLT_INCLUDE_DIRS} ) LINK_DIRECTORIES( ${OPENSYNC_LIBRARY_DIRS} ${GLIB2_LIBRARY_DIRS} ${LIBXML2_LIBRARY_DIRS} ${LIBXSLT_LIBRARY_DIRS} ) - ADD_EXECUTABLE( ldap_plugin_auth ldap_plugin_auth.c ) - TARGET_LINK_LIBRARIES( ldap_plugin_auth ${OPENSYNC_LIBRARIES} ${GLIB2_LIBRARIES} ${LIBXML2_LIBRARY_DIRS} ${LIBXSLT_LIBRARIES} ) - ADD_TEST( plugin_auth_simple_slapd ${TESTDIR}/check_plugin_auth "plugin_auth_simple_slapd" ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/tests/ldap-sync.conf_simple_slapd" ) ADD_TEST( plugin_auth_digest_md5_slapd ${TESTDIR}/check_plugin_auth "plugin_auth_digest_md5_slapd" ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/tests/ldap-sync.conf_digest_md5_slapd" ) |
From: <svn...@op...> - 2009-08-13 21:00:22
|
Author: scriptor Date: Thu Aug 13 23:00:08 2009 New Revision: 5714 URL: http://www.opensync.org/changeset/5714 Log: 1. I have added "make coverage". 2. I have written a workaround for the problem, that INCLUDE(OpenSyncInternal) sets the CMAKE_BUILD_TYPE for the plugin to the value that is being used for libopensync itself, regardless of what has been defined on the cmake command line for the plugin. With this workaround -DCMAKE_BUILD_TYPE works again. Added: plugins/ldap-sync/tests/coverage.sh.cmake (contents, props changed) Modified: plugins/ldap-sync/CMakeLists.txt Modified: plugins/ldap-sync/CMakeLists.txt ============================================================================== --- plugins/ldap-sync/CMakeLists.txt Wed Aug 12 22:40:23 2009 (r5713) +++ plugins/ldap-sync/CMakeLists.txt Thu Aug 13 23:00:08 2009 (r5714) @@ -45,6 +45,7 @@ FIND_PACKAGE( LibGCrypt REQUIRED ) FIND_PACKAGE( LibSASL2 REQUIRED ) FIND_PACKAGE( LibGSSAPIV2 ) +FIND_PACKAGE( Check ) # By default use openldap, if available. @@ -100,18 +101,42 @@ +# Test configuration +OPTION( ENABLE_UNITTESTS "Should the test suite be built? " OFF ) +IF ( CHECK_FOUND ) + SET( ENABLE_UNITTESTS ON ) +ELSE ( CHECK_FOUND ) + SET( ENABLE_UNITTESTS OFF ) +ENDIF ( CHECK_FOUND ) + + +# Workaround for wrong setting of CMAKE_BUILD_TYPE: First of two steps: +IF (CMAKE_BUILD_TYPE) + SET(CORRECT_CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING "The CMAKE_BUILD_TYPE definition in /usr/local/share/libopensync1/cmake/modules/OpenSyncInternal.cmake overrides even the command line settings here. This variable aims to fix this." FORCE ) +ENDIF (CMAKE_BUILD_TYPE) +# Set some defaults INCLUDE( Testing ) +INCLUDE( ShowStatus ) INCLUDE( OpenSyncInternal ) +# Now, that CMAKE_BUILD_TYPE has been corrupted by OpenSyncInternal.cmake +# we reset it to the what has been configured here: +IF (CORRECT_CMAKE_BUILD_TYPE) + SET( CMAKE_BUILD_TYPE "${CORRECT_CMAKE_BUILD_TYPE}" ) +ENDIF (CORRECT_CMAKE_BUILD_TYPE) + + SET( LDAP_PLUGIN_OPENSYNC_CONFIGDIR "${SHARE_INSTALL_DIR}/libopensync1/defaults" CACHE PATH "OpenSync plugin configuration directory: Where the style sheets can be found." ) SET( LDAP_PLUGIN_OPENSYNC_SCHEMASDIR "${SHARE_INSTALL_DIR}/libopensync1/schemas" CACHE PATH "OpenSync XML schemata directory." ) ADD_SUBDIRECTORY( src ) -ADD_SUBDIRECTORY( tests ) +IF (ENABLE_UNITTESTS) + ADD_SUBDIRECTORY( tests ) +ENDIF (ENABLE_UNITTESTS) ADD_SUBDIRECTORY( misc ) @@ -130,6 +155,11 @@ CONFIGURE_FILE( "config.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/config.h" ) +################### make coverage ########################## +CONFIGURE_FILE( "tests/coverage.sh.cmake" "${CMAKE_CURRENT_BINARY_DIR}/tests/coverage.sh") +ADD_CUSTOM_TARGET(coverage + "${CMAKE_CURRENT_BINARY_DIR}/tests/coverage.sh") + ######## The MacroEnsureOutOfSourceBuild.cmake fails sometimes... ######### MESSAGE(STATUS "CMAKE_SOURCE_DIR = ${CMAKE_SOURCE_DIR}" ) @@ -152,8 +182,11 @@ ##################### debugging cmake... ################################# # "cmake ... -DCMAKE_BUILD_TYPE=Whatever" sometimes does not work. +# Actually, it NEVER works here...What's going on? MESSAGE(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}" ) - +SHOW_STATUS( ENABLE_UNITTESTS "Build the test suite:\t\t" ) +SHOW_STATUS( RUN_LONG_TESTS "Run rather time consuming tests, as well:" ) +SHOW_STATUS( RUN_AUTH_TESTS "Run the authentication specific tests, too:" ) ########################################################################## Added: plugins/ldap-sync/tests/coverage.sh.cmake ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/coverage.sh.cmake Thu Aug 13 23:00:08 2009 (r5714) @@ -0,0 +1,92 @@ +#!/bin/sh + +SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}" +BINARY_DIR="${CMAKE_CURRENT_BINARY_DIR}" + + + +if test -z "$SOURCE_DIR"; then + echo "ERROR: \$SOURCE_DIR is empty. Exiting." + exit 1 +fi + +if test -z "$BINARY_DIR"; then + echo "ERROR: \$BINARY_DIR is empty. Exiting." + exit 1 +fi + + +echo -n "Checking Code Coverage of unit tests" +DATE=$( date +%Y%m%d%H%M%S ) + +if [ -d .svn ]; then + REV=`LANG=C svn info | grep Revision | cut -c 11-` + echo " for SVN Revision: $REV" + TITLE="ldap_plugin_SVN_"$REV"_"$DATE +else + echo ":" + TITLE="ldap_plugin_"$DATE +fi +echo $TITLE + +if ! [ -d $BINARY_DIR/coverage/html ]; then + mkdir -p $BINARY_DIR/coverage/html +fi + +## create gcda files +RESULT=`find $BINARY_DIR -name "*.gcda" -print | wc -l` +if [ "$RESULT" == "0" ]; then + ctest -R . +fi + +## analyze statistics +lcov \ + --test-name "$TITLE" \ + --base-directory $SOURCE_DIR \ + --directory $BINARY_DIR \ + --quiet \ + --capture \ + --output-file $BINARY_DIR/coverage/$TITLE.info +genhtml --legend -t "$TITLE" -o $BINARY_DIR/coverage/html/$TITLE $BINARY_DIR/coverage/$TITLE.info &> /dev/null + +if test -d "$BINARY_DIR/coverage/html"; then + cd $BINARY_DIR/coverage/html/ + if [ -e LATEST ]; + then rm -f LATEST; + fi + ln -s $TITLE LATEST + cd $BINARY_DIR +else + echo "WARNING: \"$BINARY_DIR/coverage/html\" does not exist. Ignoring for now." +fi + +## cleanup gcda files +#lcov \ +# --test-name "$TITLE" \ +# --base-directory $SOURCE_DIR \ +# --directory $BINARY_DIR \ +# --quiet \ +# --zerocounters \ +# --output-file coverage/$TITLE.info + +echo -n "Code Coverage is: " +grep " %</td>" coverage/html/$TITLE/index.html | sed -e "s/^[^>]*>//g" -e "s/<[^>]*>//g" +echo "" + +if test -e "$BINARY_DIR/coverage/html/$TITLE/index.html"; then + echo "Now, have a look at " + echo + echo -e "\t$BINARY_DIR/coverage/html/$TITLE/index.html" +else + echo "ERROR: $BINARY_DIR/coverage/html/$TITLE/index.html has not been created. So the lcov command must have failed." +fi + +echo +echo -e "\nTroubleshooting:\n If the Code Coverage number is quite low (less then 51%):" +echo -e "\t-Did you run any unit tests before $0?" +echo -e "\t-Did you build with -DCMAKE_BUILD_TYPE=\"Profiling\"?" +echo -e "\t-Run ALL available unit tests!" +echo -e "\t-Check if testcases in unit test are disabled!" +echo -e "\t-Fix unit tests and their test cases!" +echo -e "\t-Write new and more test cases!" +exit 0 |
From: <svn...@op...> - 2009-08-12 20:40:55
|
Author: scriptor Date: Wed Aug 12 22:40:23 2009 New Revision: 5713 URL: http://www.opensync.org/changeset/5713 Log: I have removed a misleading WARNING. Port 389 is perfectly ok for encryption: This would be the STARTTLS version as opposed to port 636 (LDAP over SSL; ldaps://). Modified: plugins/ldap-sync/src/ldap_connect.c Modified: plugins/ldap-sync/src/ldap_connect.c ============================================================================== --- plugins/ldap-sync/src/ldap_connect.c Tue Aug 11 17:17:09 2009 (r5712) +++ plugins/ldap-sync/src/ldap_connect.c Wed Aug 12 22:40:23 2009 (r5713) @@ -164,10 +164,6 @@ sinkenv->url = g_strdup_printf("%s://%s:%i", sinkenv->protocol, sinkenv->servername, sinkenv->serverport); } else { - if (sinkenv->serverport != 636) { - ldap_plugin_printf("%s:%i: WARNING: serverport has been configured as %i instead of 636. Are you sure, that this is really correct?", __FILE__, __LINE__, sinkenv->serverport); - } - sinkenv->url = g_strdup_printf("%s://%s:%i", sinkenv->protocol, sinkenv->servername, sinkenv->serverport); } |
From: <svn...@op...> - 2009-08-11 15:17:19
|
Author: scriptor Date: Tue Aug 11 17:17:09 2009 New Revision: 5712 URL: http://www.opensync.org/changeset/5712 Log: Fixed wrong argument list. Modified: plugins/ldap-sync/src/ldap_format.c Modified: plugins/ldap-sync/src/ldap_format.c ============================================================================== --- plugins/ldap-sync/src/ldap_format.c Sun Aug 9 23:25:06 2009 (r5711) +++ plugins/ldap-sync/src/ldap_format.c Tue Aug 11 17:17:09 2009 (r5712) @@ -2903,7 +2903,7 @@ osync_bool ldap_plugin_parse_attribute_list(const int entry_list_index, const LDAPMod *mod, xmlChar **name, xmlChar **value, xmlChar **attr1_name, xmlChar **attr1_value, xmlChar **attr2_name, xmlChar **attr2_value, osync_bool *call_continue, OSyncError **error) { - osync_trace(TRACE_ENTRY, "%s(%i, %p, %p, %p, %p, %p, %p, %p, %p)", __func__, index, mod, name, value, attr1_name, attr1_value, attr2_name, attr2_value, call_continue, error); + osync_trace(TRACE_ENTRY, "%s(%i, %p, %p, %p, %p, %p, %p, %p, %i, %p)", __func__, entry_list_index, mod, name, value, attr1_name, attr1_value, attr2_name, attr2_value, call_continue, error); if (mod == NULL) { |
From: <svn...@op...> - 2009-08-10 09:28:59
|
Author: bellmich Date: Mon Aug 10 11:28:41 2009 New Revision: 1256 URL: http://libsyncml.opensync.org/changeset/1256 Log: fixed state handled of OBEX client transport Modified: branches/libsyncml-0.5.x/libsyncml/sml_transport_internals.h branches/libsyncml-0.5.x/libsyncml/transports/obex_client.c branches/libsyncml-0.5.x/libsyncml/transports/obex_client_internals.h Modified: branches/libsyncml-0.5.x/libsyncml/sml_transport_internals.h ============================================================================== --- branches/libsyncml-0.5.x/libsyncml/sml_transport_internals.h Mon Aug 10 11:28:03 2009 (r1255) +++ branches/libsyncml-0.5.x/libsyncml/sml_transport_internals.h Mon Aug 10 11:28:41 2009 (r1256) @@ -63,6 +63,8 @@ SML_TRANSPORT_UNINITIALIZED, SML_TRANSPORT_INITIALIZED, SML_TRANSPORT_CONNECTED, + SML_TRANSPORT_DATA_ERROR, + SML_TRANSPORT_DISCONNECTED, SML_TRANSPORT_ERROR } SmlTransportState; Modified: branches/libsyncml-0.5.x/libsyncml/transports/obex_client.c ============================================================================== --- branches/libsyncml-0.5.x/libsyncml/transports/obex_client.c Mon Aug 10 11:28:03 2009 (r1255) +++ branches/libsyncml-0.5.x/libsyncml/transports/obex_client.c Mon Aug 10 11:28:41 2009 (r1256) @@ -484,14 +484,16 @@ } smlSafeCFree(&who); + env->state = SML_TRANSPORT_CONNECTED; smlTransportReceiveEvent(env->tsp, NULL, SML_TRANSPORT_EVENT_CONNECT_DONE, NULL, NULL); break; case OBEX_CMD_DISCONNECT:; - if (!env->isDisconnected) + if (SML_TRANSPORT_CONNECTED <= env->state && + env->state < SML_TRANSPORT_DISCONNECTED) { env->busy = FALSE; - env->isDisconnected = TRUE; OBEX_TransportDisconnect(env->obexhandle); + env->state = SML_TRANSPORT_DISCONNECTED; smlTransportReceiveEvent(env->tsp, NULL, SML_TRANSPORT_EVENT_DISCONNECT_DONE, NULL, NULL); } break; @@ -560,11 +562,12 @@ if (obex_rsp == 0) { /* This is a disconnect. */ - if (!env->isDisconnected) + if (SML_TRANSPORT_CONNECTED <= env->state && + env->state < SML_TRANSPORT_DISCONNECTED) { env->busy = FALSE; - env->isDisconnected = TRUE; OBEX_TransportDisconnect(env->obexhandle); + env->state = SML_TRANSPORT_DISCONNECTED; smlTransportReceiveEvent(env->tsp, NULL, SML_TRANSPORT_EVENT_DISCONNECT_DONE, NULL, NULL); } } else { @@ -787,6 +790,8 @@ break; } + env->state = SML_TRANSPORT_INITIALIZED; + smlTrace(TRACE_EXIT, "%s - TRUE", __func__); return TRUE; error: @@ -845,7 +850,6 @@ SmlError *error = NULL; unsigned int obex_intf_cnt; obex_interface_t *obex_intf; - env->isDisconnected = FALSE; if (env->type == SML_TRANSPORT_CONNECTION_TYPE_NET) { smlTrace(TRACE_INTERNAL, "%s: connecting to inet address %s:%d", @@ -1111,13 +1115,25 @@ SmlTransportObexClientEnv *env = data; SmlError *error = NULL; - if (env->isDisconnected) { + if (env->state < SML_TRANSPORT_CONNECTED) { + /* This is a bug. If the transport is not connected + * then there is no reason for a disconnect. + * Nevertheless this mistake should not be fatal. + */ + smlTrace(TRACE_EXIT_ERROR, + "%s - disconnect called on a never connected transport", + __func__); + g_warning("%s called on never connected OBEX connection.", __func__); + return; + } + + if (env->state == SML_TRANSPORT_DISCONNECTED) { /* This is a bug. If the transport is disconnected * then there is no reason for a second disconnect. * Nevertheless this mistake should not be fatal. */ smlTrace(TRACE_EXIT_ERROR, - "%s - disconnect called on already disconnected transport", + "%s - disconnect called on an already disconnected transport", __func__); g_warning("%s called on disconnected OBEX connection.", __func__); return; @@ -1167,7 +1183,7 @@ "The disconnect request was not accepted (%i).", result); goto error; - } else if (result == 0 && !env->busy && !env->isDisconnected) { + } else if (result == 0 && !env->busy && env->state != SML_TRANSPORT_DISCONNECTED) { smlErrorSet(&error, SML_ERROR_GENERIC, "The disconnect request was timed out."); goto error; @@ -1182,11 +1198,11 @@ /* Note: The disconnect is signaled by OBEX_EV_LINKERR or OBEX_CMD_DISCONNECT. * We only signal disconnect here if a phone does not answer. */ - if (!env->isDisconnected) + if (env->state < SML_TRANSPORT_DISCONNECTED) { env->busy = FALSE; - env->isDisconnected = TRUE; OBEX_TransportDisconnect(env->obexhandle); + env->state = SML_TRANSPORT_DISCONNECTED; smlTransportReceiveEvent(env->tsp, NULL, SML_TRANSPORT_EVENT_DISCONNECT_DONE, NULL, NULL); } @@ -1411,6 +1427,7 @@ return FALSE; tsp->transport_data = env; env->tsp = tsp; + env->state = SML_TRANSPORT_UNINITIALIZED; return TRUE; } Modified: branches/libsyncml-0.5.x/libsyncml/transports/obex_client_internals.h ============================================================================== --- branches/libsyncml-0.5.x/libsyncml/transports/obex_client_internals.h Mon Aug 10 11:28:03 2009 (r1255) +++ branches/libsyncml-0.5.x/libsyncml/transports/obex_client_internals.h Mon Aug 10 11:28:41 2009 (r1256) @@ -59,17 +59,15 @@ GList *datastores; int fd; - int state; char *databuf; int *databuflen; - int connected; #ifndef WIN32 struct termios oldtio; #endif SmlBool busy; SmlBool error; SmlMimeType mimetype; - SmlBool isDisconnected; + SmlTransportState state; } SmlTransportObexClientEnv; SmlBool smlTransportObexClientNew(SmlTransport *tsp, SmlError **error); |
From: <svn...@op...> - 2009-08-10 09:28:16
|
Author: bellmich Date: Mon Aug 10 11:28:03 2009 New Revision: 1255 URL: http://libsyncml.opensync.org/changeset/1255 Log: fixed wrong trace statements Modified: branches/libsyncml-0.5.x/libsyncml/sml_transport.c Modified: branches/libsyncml-0.5.x/libsyncml/sml_transport.c ============================================================================== --- branches/libsyncml-0.5.x/libsyncml/sml_transport.c Mon Aug 10 11:26:00 2009 (r1254) +++ branches/libsyncml-0.5.x/libsyncml/sml_transport.c Mon Aug 10 11:28:03 2009 (r1255) @@ -272,7 +272,7 @@ if (tsp->connected) g_error("A connect event was received " \ "but the transport layer is already connected."); - smlTrace(TRACE_INTERNAL, "%s: connect + no link"); + smlTrace(TRACE_INTERNAL, "%s: connect + no link", __func__); tsp->connected = TRUE; } @@ -284,7 +284,7 @@ if (!tsp->connected) g_error("A disconnect event was received " \ "but there is no connected transport."); - smlTrace(TRACE_INTERNAL, "%s: disconnect + no link"); + smlTrace(TRACE_INTERNAL, "%s: disconnect + no link", __func__); tsp->connected = FALSE; } @@ -297,7 +297,7 @@ g_error("A connect event with a link was received " \ "but the link does not contain the required " \ "transport environment."); - smlTrace(TRACE_INTERNAL, "%s: connect + link"); + smlTrace(TRACE_INTERNAL, "%s: connect + link", __func__); g_mutex_lock(tsp->connections_mutex); tsp->connections++; g_mutex_unlock(tsp->connections_mutex); @@ -312,7 +312,7 @@ g_error("A disconnect event with a link was received " \ "but the link still contains the " \ "transport environment."); - smlTrace(TRACE_INTERNAL, "%s: disconnect + link"); + smlTrace(TRACE_INTERNAL, "%s: disconnect + link", __func__); g_mutex_lock(tsp->connections_mutex); tsp->connections--; g_mutex_unlock(tsp->connections_mutex); |
From: <svn...@op...> - 2009-08-10 09:26:12
|
Author: bellmich Date: Mon Aug 10 11:26:00 2009 New Revision: 1254 URL: http://libsyncml.opensync.org/changeset/1254 Log: removed useless variable connected Modified: trunk/libsyncml/transports/obex_client_internals.h Modified: trunk/libsyncml/transports/obex_client_internals.h ============================================================================== --- trunk/libsyncml/transports/obex_client_internals.h Mon Aug 10 11:25:40 2009 (r1253) +++ trunk/libsyncml/transports/obex_client_internals.h Mon Aug 10 11:26:00 2009 (r1254) @@ -61,7 +61,6 @@ gint fd; gchar *databuf; gint *databuflen; - gint connected; #ifndef WIN32 struct termios oldtio; #endif |
From: <svn...@op...> - 2009-08-10 09:25:53
|
Author: bellmich Date: Mon Aug 10 11:25:40 2009 New Revision: 1253 URL: http://libsyncml.opensync.org/changeset/1253 Log: fixed minor issues of the state handling Modified: trunk/libsyncml/transports/obex_client.c Modified: trunk/libsyncml/transports/obex_client.c ============================================================================== --- trunk/libsyncml/transports/obex_client.c Mon Aug 10 11:14:18 2009 (r1252) +++ trunk/libsyncml/transports/obex_client.c Mon Aug 10 11:25:40 2009 (r1253) @@ -1191,7 +1191,7 @@ "The disconnect request was not accepted (%i).", result); goto error; - } else if (result == 0 && !env->busy && env->state < SML_TRANSPORT_DISCONNECTED) { + } else if (result == 0 && !env->busy && env->state != SML_TRANSPORT_DISCONNECTED) { g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The disconnect request was timed out."); goto error; @@ -1206,8 +1206,7 @@ /* Note: The disconnect is signaled by OBEX_EV_LINKERR or OBEX_CMD_DISCONNECT. * We only signal disconnect here if a phone does not answer. */ - if (SML_TRANSPORT_CONNECTED <= env->state && - env->state < SML_TRANSPORT_DISCONNECTED) + if (env->state < SML_TRANSPORT_DISCONNECTED) { env->busy = FALSE; OBEX_TransportDisconnect(env->obexhandle); |
From: <svn...@op...> - 2009-08-10 09:14:32
|
Author: bellmich Date: Mon Aug 10 11:14:18 2009 New Revision: 1252 URL: http://libsyncml.opensync.org/changeset/1252 Log: fixed the state handling of OBEX client transport Modified: trunk/libsyncml/sml_transport_internals.h trunk/libsyncml/transports/obex_client.c trunk/libsyncml/transports/obex_client_internals.h Modified: trunk/libsyncml/sml_transport_internals.h ============================================================================== --- trunk/libsyncml/sml_transport_internals.h Mon Aug 10 11:13:47 2009 (r1251) +++ trunk/libsyncml/sml_transport_internals.h Mon Aug 10 11:14:18 2009 (r1252) @@ -65,7 +65,9 @@ SML_TRANSPORT_UNINITIALIZED = 0, SML_TRANSPORT_INITIALIZED = 1, SML_TRANSPORT_CONNECTED = 2, - SML_TRANSPORT_ERROR = 3 + SML_TRANSPORT_DATA_ERROR = 3, + SML_TRANSPORT_DISCONNECTED = 4, + SML_TRANSPORT_ERROR = 5 } SmlTransportState; struct SmlTransport { Modified: trunk/libsyncml/transports/obex_client.c ============================================================================== --- trunk/libsyncml/transports/obex_client.c Mon Aug 10 11:13:47 2009 (r1251) +++ trunk/libsyncml/transports/obex_client.c Mon Aug 10 11:14:18 2009 (r1252) @@ -486,14 +486,16 @@ } smlSafeCFree(&who); + env->state = SML_TRANSPORT_CONNECTED; smlTransportReceiveEvent(env->tsp, NULL, SML_TRANSPORT_EVENT_CONNECT_DONE, NULL, NULL); break; case OBEX_CMD_DISCONNECT:; - if (!env->isDisconnected) + if (SML_TRANSPORT_CONNECTED <= env->state && + env->state < SML_TRANSPORT_DISCONNECTED) { env->busy = FALSE; - env->isDisconnected = TRUE; OBEX_TransportDisconnect(env->obexhandle); + env->state = SML_TRANSPORT_DISCONNECTED; smlTransportReceiveEvent(env->tsp, NULL, SML_TRANSPORT_EVENT_DISCONNECT_DONE, NULL, NULL); } break; @@ -562,11 +564,12 @@ if (obex_rsp == 0) { /* This is a disconnect. */ - if (!env->isDisconnected) + if (SML_TRANSPORT_CONNECTED <= env->state && + env->state < SML_TRANSPORT_DISCONNECTED) { env->busy = FALSE; - env->isDisconnected = TRUE; OBEX_TransportDisconnect(env->obexhandle); + env->state = SML_TRANSPORT_DISCONNECTED; smlTransportReceiveEvent(env->tsp, NULL, SML_TRANSPORT_EVENT_DISCONNECT_DONE, NULL, NULL); } } else { @@ -793,6 +796,8 @@ break; } + env->state = SML_TRANSPORT_INITIALIZED; + smlTrace(TRACE_EXIT, "%s - TRUE", __func__); return TRUE; error: @@ -853,7 +858,6 @@ GError *error = NULL; unsigned int obex_intf_cnt; obex_interface_t *obex_intf; - env->isDisconnected = FALSE; if (env->type == SML_TRANSPORT_CONNECTION_TYPE_NET) { smlTrace(TRACE_INTERNAL, "%s: connecting to inet address %s:%d", @@ -1119,13 +1123,25 @@ SmlTransportObexClientEnv *env = data; GError *error = NULL; - if (env->isDisconnected) { + if (env->state < SML_TRANSPORT_CONNECTED) { + /* This is a bug. If the transport is not connected + * then there is no reason for a disconnect. + * Nevertheless this mistake should not be fatal. + */ + smlTrace(TRACE_EXIT_ERROR, + "%s - disconnect called on a never connected transport", + __func__); + g_warning("%s called on never connected OBEX connection.", __func__); + return; + } + + if (env->state == SML_TRANSPORT_DISCONNECTED) { /* This is a bug. If the transport is disconnected * then there is no reason for a second disconnect. * Nevertheless this mistake should not be fatal. */ smlTrace(TRACE_EXIT_ERROR, - "%s - disconnect called on already disconnected transport", + "%s - disconnect called on an already disconnected transport", __func__); g_warning("%s called on disconnected OBEX connection.", __func__); return; @@ -1175,7 +1191,7 @@ "The disconnect request was not accepted (%i).", result); goto error; - } else if (result == 0 && !env->busy && !env->isDisconnected) { + } else if (result == 0 && !env->busy && env->state < SML_TRANSPORT_DISCONNECTED) { g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The disconnect request was timed out."); goto error; @@ -1190,11 +1206,12 @@ /* Note: The disconnect is signaled by OBEX_EV_LINKERR or OBEX_CMD_DISCONNECT. * We only signal disconnect here if a phone does not answer. */ - if (!env->isDisconnected) + if (SML_TRANSPORT_CONNECTED <= env->state && + env->state < SML_TRANSPORT_DISCONNECTED) { env->busy = FALSE; - env->isDisconnected = TRUE; OBEX_TransportDisconnect(env->obexhandle); + env->state = SML_TRANSPORT_DISCONNECTED; smlTransportReceiveEvent(env->tsp, NULL, SML_TRANSPORT_EVENT_DISCONNECT_DONE, NULL, NULL); } @@ -1426,6 +1443,7 @@ return FALSE; tsp->transport_data = env; env->tsp = tsp; + env->state = SML_TRANSPORT_UNINITIALIZED; return TRUE; } Modified: trunk/libsyncml/transports/obex_client_internals.h ============================================================================== --- trunk/libsyncml/transports/obex_client_internals.h Mon Aug 10 11:13:47 2009 (r1251) +++ trunk/libsyncml/transports/obex_client_internals.h Mon Aug 10 11:14:18 2009 (r1252) @@ -59,7 +59,6 @@ GList *datastores; gint fd; - gint state; gchar *databuf; gint *databuflen; gint connected; @@ -69,7 +68,7 @@ gboolean busy; gboolean error; SmlMimeType mimetype; - gboolean isDisconnected; + SmlTransportState state; } SmlTransportObexClientEnv; gboolean smlTransportObexClientNew (SmlTransport *tsp, GError **error); |
From: <svn...@op...> - 2009-08-10 09:14:03
|
Author: bellmich Date: Mon Aug 10 11:13:47 2009 New Revision: 1251 URL: http://libsyncml.opensync.org/changeset/1251 Log: fixed some wrong trace statements Modified: trunk/libsyncml/sml_transport.c Modified: trunk/libsyncml/sml_transport.c ============================================================================== --- trunk/libsyncml/sml_transport.c Fri Aug 7 21:37:16 2009 (r1250) +++ trunk/libsyncml/sml_transport.c Mon Aug 10 11:13:47 2009 (r1251) @@ -290,7 +290,7 @@ if (tsp->connected) g_error("A connect event was received " \ "but the transport layer is already connected."); - smlTrace(TRACE_INTERNAL, "%s: connect + no link"); + smlTrace(TRACE_INTERNAL, "%s: connect + no link", __func__); tsp->connected = TRUE; } @@ -302,7 +302,7 @@ if (!tsp->connected) g_error("A disconnect event was received " \ "but there is no connected transport."); - smlTrace(TRACE_INTERNAL, "%s: disconnect + no link"); + smlTrace(TRACE_INTERNAL, "%s: disconnect + no link", __func__); tsp->connected = FALSE; } @@ -315,7 +315,7 @@ g_error("A connect event with a link was received " \ "but the link does not contain the required " \ "transport environment."); - smlTrace(TRACE_INTERNAL, "%s: connect + link"); + smlTrace(TRACE_INTERNAL, "%s: connect + link", __func__); g_mutex_lock(tsp->connections_mutex); tsp->connections++; g_mutex_unlock(tsp->connections_mutex); @@ -330,7 +330,7 @@ g_error("A disconnect event with a link was received " \ "but the link still contains the " \ "transport environment."); - smlTrace(TRACE_INTERNAL, "%s: disconnect + link"); + smlTrace(TRACE_INTERNAL, "%s: disconnect + link", __func__); g_mutex_lock(tsp->connections_mutex); tsp->connections--; g_mutex_unlock(tsp->connections_mutex); |
From: <svn...@op...> - 2009-08-09 21:25:21
|
Author: scriptor Date: Sun Aug 9 23:25:06 2009 New Revision: 5711 URL: http://www.opensync.org/changeset/5711 Log: AUTH: I have added a set of authentication specific tests. They are all disabled by default, and can be run by calling cmake with -DRUN_AUTH_TESTS=on The authentication specific tests require two fully configured and running LDAP servers: slapd from openldap and ns-slapd from the fedora-directory-server (recently renamed to "389-directory-server"). And, of course, both servers need to be configured in a way, that allows as many SASL mechanisms as possible. After all, it is the LDAP plugin of opensync that is to tested here. For people who face Segmentation faults while playing with SSL/TLS: libopenldap-2.4.15, as it ships with Fedora 11, has a bug: See: http://www.openldap.org/lists/openldap-commit/200903/msg00006.html http://www.openldap.org/devel/cvsweb.cgi/libraries/libldap/tls_o.c.diff?r1=1.6&r2=1.7&hideattic=1&sortbydate=0&f=h http://www.openldap.org/devel/cvsweb.cgi/libraries/libldap/tls_o.c.diff?r1=1.5.2.2&r2=1.5.2.3&hideattic=1&sortbydate=0&f=h Added: plugins/ldap-sync/tests/check_mozldap_auth (contents, props changed) plugins/ldap-sync/tests/check_openldap_auth (contents, props changed) plugins/ldap-sync/tests/check_plugin_auth (contents, props changed) plugins/ldap-sync/tests/ldap-sync.conf_cram_md5_nsslapd plugins/ldap-sync/tests/ldap-sync.conf_cram_md5_slapd plugins/ldap-sync/tests/ldap-sync.conf_digest_md5_nsslapd plugins/ldap-sync/tests/ldap-sync.conf_digest_md5_slapd plugins/ldap-sync/tests/ldap-sync.conf_external1_nsslapd plugins/ldap-sync/tests/ldap-sync.conf_external1_slapd plugins/ldap-sync/tests/ldap-sync.conf_external2_nsslapd plugins/ldap-sync/tests/ldap-sync.conf_external2_slapd plugins/ldap-sync/tests/ldap-sync.conf_gssapi_nsslapd plugins/ldap-sync/tests/ldap-sync.conf_gssapi_slapd plugins/ldap-sync/tests/ldap-sync.conf_login_nsslapd plugins/ldap-sync/tests/ldap-sync.conf_login_slapd plugins/ldap-sync/tests/ldap-sync.conf_ntlm_nsslapd plugins/ldap-sync/tests/ldap-sync.conf_ntlm_slapd plugins/ldap-sync/tests/ldap-sync.conf_plain_nsslapd plugins/ldap-sync/tests/ldap-sync.conf_plain_slapd plugins/ldap-sync/tests/ldap-sync.conf_simple_nsslapd plugins/ldap-sync/tests/ldap-sync.conf_simple_slapd Modified: plugins/ldap-sync/tests/CMakeLists.txt plugins/ldap-sync/tests/test.conf Modified: plugins/ldap-sync/tests/CMakeLists.txt ============================================================================== --- plugins/ldap-sync/tests/CMakeLists.txt Sun Aug 9 22:32:06 2009 (r5710) +++ plugins/ldap-sync/tests/CMakeLists.txt Sun Aug 9 23:25:06 2009 (r5711) @@ -5,6 +5,7 @@ # or where the errors are known to me. OPTION ( RUN_LONG_TESTS "Should the tests with osynctool running under valgrind be run? They take quite some time." off) +OPTION ( RUN_AUTH_TESTS "Should the tests about authentication towards the LDAP server be run?" off ) SET ( TESTDIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE STRING "Path where the test scripts are located.") SET ( XSLDIR "${CMAKE_SOURCE_DIR}/src/xslt" CACHE STRING "Path where the stylesheeets are located.") @@ -365,6 +366,75 @@ # This set of tests checks whether the LDAP server is sufficiently # configured to allow read and write access. This is, of course, # prerequisite for the opensync plugin to do anything useful. +IF (RUN_AUTH_TESTS) + + IF (LDAPSEARCH_EXECUTABLE) + + ADD_TEST( openldap_auth_simple_slapd ${TESTDIR}/check_openldap_auth "AUTH_OPENLDAP_SIMPLE_SLAPD" ) + + ADD_TEST( openldap_auth_digest_md5_slapd ${TESTDIR}/check_openldap_auth "AUTH_OPENLDAP_DIGEST_MD5_SLAPD" ) + + ADD_TEST( openldap_auth_cram_md5_slapd ${TESTDIR}/check_openldap_auth "AUTH_OPENLDAP_CRAM_MD5_SLAPD" ) + + ADD_TEST( openldap_auth_ntlm_slapd ${TESTDIR}/check_openldap_auth "AUTH_OPENLDAP_NTLM_SLAPD" ) + + ADD_TEST( openldap_auth_login_slapd ${TESTDIR}/check_openldap_auth "AUTH_OPENLDAP_LOGIN_SLAPD" ) + + ADD_TEST( openldap_auth_plain_slapd ${TESTDIR}/check_openldap_auth "AUTH_OPENLDAP_PLAIN_SLAPD" ) + + ADD_TEST( openldap_auth_gssapi_slapd ${TESTDIR}/check_openldap_auth "AUTH_OPENLDAP_GSSAPI_SLAPD" ) + + ADD_TEST( openldap_auth_external1_slapd ${TESTDIR}/check_openldap_auth "AUTH_OPENLDAP_EXTERNAL1_SLAPD" ) + + ADD_TEST( openldap_auth_external2_slapd ${TESTDIR}/check_openldap_auth "AUTH_OPENLDAP_EXTERNAL2_SLAPD" ) + + + ADD_TEST( openldap_auth_simple_nsslapd ${TESTDIR}/check_openldap_auth "AUTH_OPENLDAP_SIMPLE_NSSLAPD" ) + + ADD_TEST( openldap_auth_digest_md5_nsslapd ${TESTDIR}/check_openldap_auth "AUTH_OPENLDAP_DIGEST_MD5_NSSLAPD" ) + + ADD_TEST( openldap_auth_cram_md5_nsslapd ${TESTDIR}/check_openldap_auth "AUTH_OPENLDAP_CRAM_MD5_NSSLAPD" ) + + ADD_TEST( openldap_auth_ntlm_nsslapd ${TESTDIR}/check_openldap_auth "AUTH_OPENLDAP_NTLM_NSSLAPD" ) + + ADD_TEST( openldap_auth_gssapi_nsslapd ${TESTDIR}/check_openldap_auth "AUTH_OPENLDAP_GSSAPI_NSSLAPD" ) + + ENDIF (LDAPSEARCH_EXECUTABLE) + + + ADD_TEST( mozldap_auth_simple_slapd ${TESTDIR}/check_mozldap_auth "AUTH_MOZLDAP_SIMPLE_SLAPD" ) + + ADD_TEST( mozldap_auth_digest_md5_slapd ${TESTDIR}/check_mozldap_auth "AUTH_MOZLDAP_DIGEST_MD5_SLAPD" ) + + # ADD_TEST( mozldap_auth_cram_md5_slapd ${TESTDIR}/check_mozldap_auth "AUTH_MOZLDAP_CRAM_MD5_SLAPD" ) + + ADD_TEST( mozldap_auth_ntlm_slapd ${TESTDIR}/check_mozldap_auth "AUTH_MOZLDAP_NTLM_SLAPD" ) + + # ADD_TEST( mozldap_auth_login_slapd ${TESTDIR}/check_mozldap_auth "AUTH_MOZLDAP_LOGIN_SLAPD" ) + + # ADD_TEST( mozldap_auth_plain_slapd ${TESTDIR}/check_mozldap_auth "AUTH_MOZLDAP_PLAIN_SLAPD" ) + + ADD_TEST( mozldap_auth_gssapi_slapd ${TESTDIR}/check_mozldap_auth "AUTH_MOZLDAP_GSSAPI_SLAPD" ) + + + ADD_TEST( mozldap_auth_simple_nsslapd ${TESTDIR}/check_mozldap_auth "AUTH_MOZLDAP_SIMPLE_NSSLAPD" ) + + ADD_TEST( mozldap_auth_digest_md5_nsslapd ${TESTDIR}/check_mozldap_auth "AUTH_MOZLDAP_DIGEST_MD5_NSSLAPD" ) + + ADD_TEST( mozldap_auth_cram_md5_nsslapd ${TESTDIR}/check_mozldap_auth "AUTH_MOZLDAP_CRAM_MD5_NSSLAPD" ) + + ADD_TEST( mozldap_auth_ntlm_nsslapd ${TESTDIR}/check_mozldap_auth "AUTH_MOZLDAP_NTLM_NSSLAPD" ) + + # ADD_TEST( mozldap_auth_login_nsslapd ${TESTDIR}/check_mozldap_auth "AUTH_MOZLDAP_LOGIN_NSSLAPD" ) + + # ADD_TEST( mozldap_auth_plain_nsslapd ${TESTDIR}/check_mozldap_auth "AUTH_MOZLDAP_PLAIN_NSSLAPD" ) + + ADD_TEST( mozldap_auth_gssapi_nsslapd ${TESTDIR}/check_mozldap_auth "AUTH_MOZLDAP_GSSAPI_NSSLAPD" ) + +ENDIF (RUN_AUTH_TESTS) + + + IF (LDAPSEARCH_EXECUTABLE) ADD_TEST( ldap_objtypes ${TESTDIR}/check_ldap_base_entries_objtype) @@ -477,6 +547,59 @@ ADD_TEST( check_fastsync ${TESTDIR}/check_fastsync "check_fastsync" ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} ) +IF (RUN_AUTH_TESTS) + + INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ${OPENSYNC_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIRS} ${LIBXSLT_INCLUDE_DIRS} ) + LINK_DIRECTORIES( ${OPENSYNC_LIBRARY_DIRS} ${GLIB2_LIBRARY_DIRS} ${LIBXML2_LIBRARY_DIRS} ${LIBXSLT_LIBRARY_DIRS} ) + + ADD_EXECUTABLE( ldap_plugin_auth ldap_plugin_auth.c ) + TARGET_LINK_LIBRARIES( ldap_plugin_auth ${OPENSYNC_LIBRARIES} ${GLIB2_LIBRARIES} ${LIBXML2_LIBRARY_DIRS} ${LIBXSLT_LIBRARIES} ) + + ADD_TEST( plugin_auth_simple_slapd ${TESTDIR}/check_plugin_auth "plugin_auth_simple_slapd" ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/tests/ldap-sync.conf_simple_slapd" ) + + ADD_TEST( plugin_auth_digest_md5_slapd ${TESTDIR}/check_plugin_auth "plugin_auth_digest_md5_slapd" ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/tests/ldap-sync.conf_digest_md5_slapd" ) + + ADD_TEST( plugin_auth_cram_md5_slapd ${TESTDIR}/check_plugin_auth "plugin_auth_cram_md5_slapd" ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/tests/ldap-sync.conf_cram_md5_slapd" ) + + ADD_TEST( plugin_auth_ntlm_slapd ${TESTDIR}/check_plugin_auth "plugin_auth_ntlm_slapd" ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/tests/ldap-sync.conf_ntlm_slapd" ) + + ADD_TEST( plugin_auth_login_slapd ${TESTDIR}/check_plugin_auth "plugin_auth_login_slapd" ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/tests/ldap-sync.conf_login_slapd" ) + + ADD_TEST( plugin_auth_plain_slapd ${TESTDIR}/check_plugin_auth "plugin_auth_plain_slapd" ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/tests/ldap-sync.conf_plain_slapd" ) + + ADD_TEST( plugin_auth_gssapi_slapd ${TESTDIR}/check_plugin_auth "plugin_auth_gssapi_slapd" ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/tests/ldap-sync.conf_gssapi_slapd" ) + + ADD_TEST( plugin_auth_external1_slapd ${TESTDIR}/check_plugin_auth "plugin_auth_external1_slapd" ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/tests/ldap-sync.conf_external1_slapd" ) + + ADD_TEST( plugin_auth_external2_slapd ${TESTDIR}/check_plugin_auth "plugin_auth_external1_slapd" ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/tests/ldap-sync.conf_external2_slapd" ) + + + ADD_TEST( plugin_auth_simple_nsslapd ${TESTDIR}/check_plugin_auth "plugin_auth_simple_slapd" ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/tests/ldap-sync.conf_simple_nsslapd" ) + + ADD_TEST( plugin_auth_digest_md5_nsslapd ${TESTDIR}/check_plugin_auth "plugin_auth_simple_slapd" ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/tests/ldap-sync.conf_digest_md5_nsslapd" ) + + ADD_TEST( plugin_auth_cram_md5_nsslapd ${TESTDIR}/check_plugin_auth "plugin_auth_simple_slapd" ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/tests/ldap-sync.conf_cram_md5_nsslapd" ) + + ADD_TEST( plugin_auth_ntlm_nsslapd ${TESTDIR}/check_plugin_auth "plugin_auth_simple_slapd" ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/tests/ldap-sync.conf_ntlm_nsslapd" ) + + # ADD_TEST( plugin_auth_login_nsslapd ${TESTDIR}/check_plugin_auth "plugin_auth_simple_slapd" ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/tests/ldap-sync.conf_login_nsslapd" ) + + # ADD_TEST( plugin_auth_plain_nsslapd ${TESTDIR}/check_plugin_auth "plugin_auth_simple_slapd" ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/tests/ldap-sync.conf_plain_nsslapd" ) + + ADD_TEST( plugin_auth_gssapi_nsslapd ${TESTDIR}/check_plugin_auth "plugin_auth_simple_slapd" ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/tests/ldap-sync.conf_gssapi_nsslapd" ) + + # ADD_TEST( plugin_auth_external1_nsslapd ${TESTDIR}/check_plugin_auth "plugin_auth_simple_slapd" ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/tests/ldap-sync.conf_external1_nsslapd" ) + + # ADD_TEST( plugin_auth_external2_nsslapd ${TESTDIR}/check_plugin_auth "plugin_auth_simple_slapd" ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/tests/ldap-sync.conf_external2_nsslapd" ) + + +ENDIF (RUN_AUTH_TESTS) + + + + + + IF (LDAPADD_EXECUTABLE) IF (LDAPMODIFY_EXECUTABLE) Added: plugins/ldap-sync/tests/check_mozldap_auth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_mozldap_auth Sun Aug 9 23:25:06 2009 (r5711) @@ -0,0 +1,75 @@ +#!/bin/bash + + +FILE=$0 +SOURCE_DIR=`dirname $FILE ` +if test ! -d "$SOURCE_DIR"; then + echo "$FILE:$LINENO: ERROR: $SOURCE_DIR is not a directory. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/test.conf"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +source "$SOURCE_DIR/test.conf" + +if test -n "$1"; then + PRE="$1" + AUTH=${!PRE} +fi + +if test -z "$AUTH"; then + echo "$FILE:$LINENO: ERROR: \$AUTH is empty. Exiting."; + exit 1 +fi + +if test -f "/usr/lib/mozldap/ldapsearch"; then + MOZLDAPSEARCH="/usr/lib/mozldap/ldapsearch" +elif test -f "/usr/lib64/mozldap/ldapsearch"; then + MOZLDAPSEARCH="/usr/lib64/mozldap/ldapsearch" +else + echo "$FILE:$LINENO: ERROR: mozldap/ldapsearch could not be found."; + exit 1 +fi + + +if test ! -f "$MOZLDAPSEARCH"; then + echo "$FILE:$LINENO: ERROR: mozldap/ldapsearch could not be found. Exiting." + exit 1 +fi + +if test ! -x "$MOZLDAPSEARCH"; then + echo "$FILE:$LINENO: ERROR: mozldap/ldapsearch could be found, but is not executable. Exiting." + exit 1 +fi + + +WHOAMI=$(which whoami 2>/dev/null) +if test -n "$WHOAMI"; then + if test -x "$WHOAMI"; then + echo -n "This script $FILE is running under the login name: "; + $WHOAMI; + fi +fi + + +echo -e "\n\n" +echo "AUTH = \"$AUTH\"" +echo -e "\n\n" + +cmd="$MOZLDAPSEARCH $AUTH -s base -b \"\" \"\"" +echo "cmd = \"$cmd\"" +echo -e "\n\n" + +eval $cmd +rv=$? +if test $rv -ne 0; then + echo -e "$FILE:$LINENO: ERROR: ldapsearch could not find \"$BASE_CONTACT\". Exiting." + echo "Command was:" + echo "$cmd" + exit 1 +fi + + Added: plugins/ldap-sync/tests/check_openldap_auth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_openldap_auth Sun Aug 9 23:25:06 2009 (r5711) @@ -0,0 +1,71 @@ +#!/bin/bash + + +FILE=$0 +SOURCE_DIR=`dirname $FILE ` +if test ! -d "$SOURCE_DIR"; then + echo "$FILE:$LINENO: ERROR: $SOURCE_DIR is not a directory. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/test.conf"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +source "$SOURCE_DIR/test.conf" +echo -e "\n\n\n" +if test -n "$1"; then + PRE="$1" + + _AUTH=${!PRE} +else + echo "$FILE:$LINENO: ERROR: \$1 has not been provided. Exiting."; + exit 1 +fi + +if test -z "$_AUTH"; then + echo "$FILE:$LINENO: ERROR: \$_AUTH is empty. Exiting."; + exit 1 +fi + +LDAPSEARCH=$(which ldapsearch 2>/dev/null) + +if test ! -f "$LDAPSEARCH"; then + echo "$FILE:$LINENO: ERROR: ldapsearch could not be found. Exiting." + exit 1 +fi + +if test ! -x "$LDAPSEARCH"; then + echo "$FILE:$LINENO: ERROR: ldapsearch could be found, but is not executable. Exiting." + exit 1 +fi + + +WHOAMI=$(which whoami 2>/dev/null) +if test -n "$WHOAMI"; then + if test -x "$WHOAMI"; then + echo -n "This script $FILE is running under the login name: "; + $WHOAMI; + fi +fi + + +echo -e "\n\n" +echo "_AUTH = \"$_AUTH\"" +echo -e "\n\n" + +cmd="$LDAPSEARCH $_AUTH -LLL -s base -b \"\" " +echo "cmd = \"$cmd\"" +echo -e "\n\n" + +eval $cmd +rv=$? +if test $rv -ne 0; then + echo -e "$FILE:$LINENO: ERROR: ldapsearch could not find \"$BASE_CONTACT\". Exiting." + echo "Command was:" + echo "$cmd" + exit 1 +fi + + Added: plugins/ldap-sync/tests/check_plugin_auth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_plugin_auth Sun Aug 9 23:25:06 2009 (r5711) @@ -0,0 +1,90 @@ +#!/bin/bash + +# Call as check_plugin_auth /path/to/ldap-sync/build/dir /path/to/ldap-sync/src/dir /path/to/ldap-sync_auth_file +# +# E.g.: +# ./check_connect testname /home/user1/dev/plugins/ldap-sync/build_debug /home/user1/dev/plugins/ldap-sync + +set -x + +FILE=$0 +test_name="$1" +PLUGINNAME="ldap-sync" +PLUGINPATH="$2/src" +CFG="$3" + + + +OSYNCPLUGIN=$(which osyncplugin 2>/dev/null) +if test ! -f "$OSYNCPLUGIN"; then + echo "$FILE:$LINENO: ERROR: osyncplugin could not be found. Exiting." + exit 1 +fi + +if test ! -x "$OSYNCPLUGIN"; then + echo "$FILE:$LINENO: ERROR: osyncplugin could be found, but it is not executable. Exiting." + exit 1 +fi + + +SOURCE_DIR=`dirname $FILE` +if test ! -d "$SOURCE_DIR"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR\" is not a directory. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/test.conf"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +source "$SOURCE_DIR/test.conf" +source "$SOURCE_DIR/check_osynctool_common.inc" + +enable_tracing "$test_name" + + + +echo "PLUGINPATH = \"$PLUGINPATH\"" +echo "CFG = \"$CFG\"" + + +if test ! -f "$CFG"; then + echo "$FILE:$LINENO: ERROR: \"$CFG\" does not exist. Exiting." + exit 1 +fi + +if test ! -r "$CFG"; then + echo "$FILE:$LINENO: ERROR: \"$CFG\" does exist, but it is not readable. Exiting." + exit 1 +fi + + + + + + + +echo "${PLUGINPATH} ${CFG}" + +TMPDIR=`mktemp -d /tmp/ldap_sync_test.XXXXXX` || exit 1 + +cmd="$OSYNCPLUGIN --plugin $PLUGINNAME --pluginpath $PLUGINPATH --config $CFG --configdir $TMPDIR --initialize --connect --disconnect --finalize" + +echo -e "\n\n" +echo "cmd = $cmd" +echo -e "\n\n" +eval $cmd +rv=$? + + +if test -d "$TMPDIR"; then + rm -rf "$TMPDIR" +fi + + +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: osyncplugin has failed. Exiting." + exit 1 +fi + Added: plugins/ldap-sync/tests/ldap-sync.conf_cram_md5_nsslapd ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/ldap-sync.conf_cram_md5_nsslapd Sun Aug 9 23:25:06 2009 (r5711) @@ -0,0 +1,191 @@ +<?xml version="1.0"?> +<config version="1.0"> + <AdvancedOptions> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>binddn</Name> + <Type>string</Type> + <Value>cn=ldap_user,ou=people,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>authcid</Name> + <Type>string</Type> + <Value>ldap_user</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>password</Name> + <Type>string</Type> + <Value>secret</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>anonymous</Name> + <Type>string</Type> + <Value>0</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>authmech</Name> + <Type>string</Type> + <Value>CRAM-MD5</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>encryption</Name> + <Type>string</Type> + <Value>0</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>ldap_read</Name> + <Type>string</Type> + <Value>1</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>ldap_write</Name> + <Type>string</Type> + <Value>1</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_contact</Name> + <Type>string</Type> + <Value>ou=addressbook,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_contact</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_contact</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_event</Name> + <Type>string</Type> + <Value>ou=calendar,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_event</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_event</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_todo</Name> + <Type>string</Type> + <Value>ou=todo,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_todo</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_todo</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_note</Name> + <Type>string</Type> + <Value>o=notes,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_note</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_note</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + </AdvancedOptions> + <Connection> + <ActiveConnection>Network</ActiveConnection> + <Network> + <Address>localhost</Address> + <Port>3890</Port> + <Protocol>ldap</Protocol> + </Network> + </Connection> + <Resources> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-inetorgperson</Name> + </Format> + </Formats> + <ObjType>contact</ObjType> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-event</Name> + </Format> + </Formats> + <ObjType>event</ObjType> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-todo</Name> + </Format> + </Formats> + <ObjType>todo</ObjType> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-note</Name> + </Format> + </Formats> + <ObjType>note</ObjType> + </Resource> + </Resources> +</config> Added: plugins/ldap-sync/tests/ldap-sync.conf_cram_md5_slapd ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/ldap-sync.conf_cram_md5_slapd Sun Aug 9 23:25:06 2009 (r5711) @@ -0,0 +1,191 @@ +<?xml version="1.0"?> +<config version="1.0"> + <AdvancedOptions> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>binddn</Name> + <Type>string</Type> + <Value>cn=ldap_user,ou=people,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>authcid</Name> + <Type>string</Type> + <Value>ldap_user</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>password</Name> + <Type>string</Type> + <Value>secret</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>anonymous</Name> + <Type>string</Type> + <Value>0</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>authmech</Name> + <Type>string</Type> + <Value>CRAM-MD5</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>encryption</Name> + <Type>string</Type> + <Value>0</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>ldap_read</Name> + <Type>string</Type> + <Value>1</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>ldap_write</Name> + <Type>string</Type> + <Value>1</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_contact</Name> + <Type>string</Type> + <Value>ou=addressbook,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_contact</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_contact</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_event</Name> + <Type>string</Type> + <Value>ou=calendar,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_event</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_event</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_todo</Name> + <Type>string</Type> + <Value>ou=todo,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_todo</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_todo</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_note</Name> + <Type>string</Type> + <Value>o=notes,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_note</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_note</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + </AdvancedOptions> + <Connection> + <ActiveConnection>Network</ActiveConnection> + <Network> + <Address>localhost</Address> + <Port>389</Port> + <Protocol>ldap</Protocol> + </Network> + </Connection> + <Resources> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-inetorgperson</Name> + </Format> + </Formats> + <ObjType>contact</ObjType> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-event</Name> + </Format> + </Formats> + <ObjType>event</ObjType> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-todo</Name> + </Format> + </Formats> + <ObjType>todo</ObjType> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-note</Name> + </Format> + </Formats> + <ObjType>note</ObjType> + </Resource> + </Resources> +</config> Added: plugins/ldap-sync/tests/ldap-sync.conf_digest_md5_nsslapd ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/ldap-sync.conf_digest_md5_nsslapd Sun Aug 9 23:25:06 2009 (r5711) @@ -0,0 +1,191 @@ +<?xml version="1.0"?> +<config version="1.0"> + <AdvancedOptions> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>binddn</Name> + <Type>string</Type> + <Value>cn=ldap_user,ou=people,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>authcid</Name> + <Type>string</Type> + <Value>ldap_user</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>password</Name> + <Type>string</Type> + <Value>secret</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>anonymous</Name> + <Type>string</Type> + <Value>0</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>authmech</Name> + <Type>string</Type> + <Value>DIGEST-MD5</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>encryption</Name> + <Type>string</Type> + <Value>0</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>ldap_read</Name> + <Type>string</Type> + <Value>1</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>ldap_write</Name> + <Type>string</Type> + <Value>1</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_contact</Name> + <Type>string</Type> + <Value>ou=addressbook,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_contact</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_contact</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_event</Name> + <Type>string</Type> + <Value>ou=calendar,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_event</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_event</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_todo</Name> + <Type>string</Type> + <Value>ou=todo,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_todo</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_todo</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_note</Name> + <Type>string</Type> + <Value>o=notes,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_note</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_note</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + </AdvancedOptions> + <Connection> + <ActiveConnection>Network</ActiveConnection> + <Network> + <Address>localhost</Address> + <Port>3890</Port> + <Protocol>ldap</Protocol> + </Network> + </Connection> + <Resources> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-inetorgperson</Name> + </Format> + </Formats> + <ObjType>contact</ObjType> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-event</Name> + </Format> + </Formats> + <ObjType>event</ObjType> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-todo</Name> + </Format> + </Formats> + <ObjType>todo</ObjType> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-note</Name> + </Format> + </Formats> + <ObjType>note</ObjType> + </Resource> + </Resources> +</config> Added: plugins/ldap-sync/tests/ldap-sync.conf_digest_md5_slapd ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/ldap-sync.conf_digest_md5_slapd Sun Aug 9 23:25:06 2009 (r5711) @@ -0,0 +1,191 @@ +<?xml version="1.0"?> +<config version="1.0"> + <AdvancedOptions> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>binddn</Name> + <Type>string</Type> + <Value>cn=ldap_user,ou=people,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>authcid</Name> + <Type>string</Type> + <Value>ldap_user</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>password</Name> + <Type>string</Type> + <Value>secret</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>anonymous</Name> + <Type>string</Type> + <Value>0</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>authmech</Name> + <Type>string</Type> + <Value>DIGEST-MD5</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>encryption</Name> + <Type>string</Type> + <Value>0</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>ldap_read</Name> + <Type>string</Type> + <Value>1</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>ldap_write</Name> + <Type>string</Type> + <Value>1</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_contact</Name> + <Type>string</Type> + <Value>ou=addressbook,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_contact</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_contact</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_event</Name> + <Type>string</Type> + <Value>ou=calendar,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_event</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_event</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_todo</Name> + <Type>string</Type> + <Value>ou=todo,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_todo</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_todo</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_note</Name> + <Type>string</Type> + <Value>o=notes,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_note</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_note</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + </AdvancedOptions> + <Connection> + <ActiveConnection>Network</ActiveConnection> + <Network> + <Address>localhost</Address> + <Port>389</Port> + <Protocol>ldap</Protocol> + </Network> + </Connection> + <Resources> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-inetorgperson</Name> + </Format> + </Formats> + <ObjType>contact</ObjType> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-event</Name> + </Format> + </Formats> + <ObjType>event</ObjType> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-todo</Name> + </Format> + </Formats> + <ObjType>todo</ObjType> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-note</Name> + </Format> + </Formats> + <ObjType>note</ObjType> + </Resource> + </Resources> +</config> Added: plugins/ldap-sync/tests/ldap-sync.conf_external1_nsslapd ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/ldap-sync.conf_external1_nsslapd Sun Aug 9 23:25:06 2009 (r5711) @@ -0,0 +1,206 @@ +<?xml version="1.0"?> +<config version="1.0"> + <AdvancedOptions> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>binddn</Name> + <Type>string</Type> + <Value>cn=ldap_user,ou=People,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>authcid</Name> + <Type>string</Type> + <Value>ldap_user</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>authzid</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>realm</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>password</Name> + <Type>string</Type> + <Value>secret</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>anonymous</Name> + <Type>string</Type> + <Value>0</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>authmech</Name> + <Type>string</Type> + <Value>EXTERNAL</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>encryption</Name> + <Type>string</Type> + <Value>1</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>ldap_read</Name> + <Type>string</Type> + <Value>1</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>ldap_write</Name> + <Type>string</Type> + <Value>1</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_contact</Name> + <Type>string</Type> + <Value>ou=addressbook,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_contact</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_contact</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_event</Name> + <Type>string</Type> + <Value>ou=calendar,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_event</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_event</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_todo</Name> + <Type>string</Type> + <Value>ou=todo,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_todo</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_todo</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_note</Name> + <Type>string</Type> + <Value>o=notes,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_note</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_note</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + </AdvancedOptions> + <Connection> + <ActiveConnection>Network</ActiveConnection> + <Network> + <Address>jl2.example.com</Address> + <Port>6360</Port> + <Protocol>ldaps</Protocol> + </Network> + </Connection> + <Resources> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-inetorgperson</Name> + </Format> + </Formats> + <ObjType>contact</ObjType> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-event</Name> + </Format> + </Formats> + <ObjType>event</ObjType> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-todo</Name> + </Format> + </Formats> + <ObjType>todo</ObjType> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-note</Name> + </Format> + </Formats> + <ObjType>note</ObjType> + </Resource> + </Resources> +</config> Added: plugins/ldap-sync/tests/ldap-sync.conf_external1_slapd ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/ldap-sync.conf_external1_slapd Sun Aug 9 23:25:06 2009 (r5711) @@ -0,0 +1,206 @@ +<?xml version="1.0"?> +<config version="1.0"> + <AdvancedOptions> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>binddn</Name> + <Type>string</Type> + <Value>cn=ldap_user,ou=people,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>authcid</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>authzid</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>realm</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>password</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>anonymous</Name> + <Type>string</Type> + <Value>0</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>authmech</Name> + <Type>string</Type> + <Value>EXTERNAL</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>encryption</Name> + <Type>string</Type> + <Value>1</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>ldap_read</Name> + <Type>string</Type> + <Value>1</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>ldap_write</Name> + <Type>string</Type> + <Value>1</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_contact</Name> + <Type>string</Type> + <Value>ou=addressbook,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_contact</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_contact</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_event</Name> + <Type>string</Type> + <Value>ou=calendar,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_event</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_event</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_todo</Name> + <Type>string</Type> + <Value>ou=todo,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_todo</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_todo</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_note</Name> + <Type>string</Type> + <Value>o=notes,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_note</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_note</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + </AdvancedOptions> + <Connection> + <ActiveConnection>Network</ActiveConnection> + <Network> + <Address>localhost</Address> + <Port>636</Port> + <Protocol>ldaps</Protocol> + </Network> + </Connection> + <Resources> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-inetorgperson</Name> + </Format> + </Formats> + <ObjType>contact</ObjType> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-event</Name> + </Format> + </Formats> + <ObjType>event</ObjType> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-todo</Name> + </Format> + </Formats> + <ObjType>todo</ObjType> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-note</Name> + </Format> + </Formats> + <ObjType>note</ObjType> + </Resource> + </Resources> +</config> Added: plugins/ldap-sync/tests/ldap-sync.conf_external2_nsslapd ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/ldap-sync.conf_external2_nsslapd Sun Aug 9 23:25:06 2009 (r5711) @@ -0,0 +1,206 @@ +<?xml version="1.0"?> +<config version="1.0"> + <AdvancedOptions> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>binddn</Name> + <Type>string</Type> + <Value>cn=ldap_user,ou=People,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>authcid</Name> + <Type>string</Type> + <Value>ldap_user</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>authzid</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>realm</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>password</Name> + <Type>string</Type> + <Value>secret</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>anonymous</Name> + <Type>string</Type> + <Value>0</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>authmech</Name> + <Type>string</Type> + <Value>EXTERNAL</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>encryption</Name> + <Type>string</Type> + <Value>1</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>ldap_read</Name> + <Type>string</Type> + <Value>1</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>ldap_write</Name> + <Type>string</Type> + <Value>1</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_contact</Name> + <Type>string</Type> + <Value>ou=addressbook,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_contact</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_contact</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_event</Name> + <Type>string</Type> + <Value>ou=calendar,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_event</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_event</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_todo</Name> + <Type>string</Type> + <Value>ou=todo,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_todo</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_todo</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_note</Name> + <Type>string</Type> + <Value>o=notes,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_note</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_note</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + </AdvancedOptions> + <Connection> + <ActiveConnection>Network</ActiveConnection> + <Network> + <Address>jl2.example.com</Address> + <Port>3890</Port> + <Protocol>ldap</Protocol> + </Network> + </Connection> + <Resources> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-inetorgperson</Name> + </Format> + </Formats> + <ObjType>contact</ObjType> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-event</Name> + </Format> + </Formats> + <ObjType>event</ObjType> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-todo</Name> + </Format> + </Formats> + <ObjType>todo</ObjType> + </Resource> + <Resource> + <Enabled>1</Enabled> + <Formats> + <Format> + <Name>ldap-note</Name> + </Format> + </Formats> + <ObjType>note</ObjType> + </Resource> + </Resources> +</config> Added: plugins/ldap-sync/tests/ldap-sync.conf_external2_slapd ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/ldap-sync.conf_external2_slapd Sun Aug 9 23:25:06 2009 (r5711) @@ -0,0 +1,206 @@ +<?xml version="1.0"?> +<config version="1.0"> + <AdvancedOptions> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>binddn</Name> + <Type>string</Type> + <Value>cn=ldap_user,ou=people,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>authcid</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>authzid</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>realm</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>password</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>anonymous</Name> + <Type>string</Type> + <Value>0</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>authmech</Name> + <Type>string</Type> + <Value>EXTERNAL</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>encryption</Name> + <Type>string</Type> + <Value>1</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>ldap_read</Name> + <Type>string</Type> + <Value>1</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>ldap_write</Name> + <Type>string</Type> + <Value>1</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_contact</Name> + <Type>string</Type> + <Value>ou=addressbook,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_contact</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_contact</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_event</Name> + <Type>string</Type> + <Value>ou=calendar,dc=example,dc=com</Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchfilter_event</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>storebase_event</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> + <MaxOccurs>2147483647</MaxOccurs> + <Max>2147483647</Max> + <Name>searchbase_todo</Name> + <Type>string</Type> + <Value>ou=todo,dc=example,dc=com</Value> + <... [truncated message content] |
From: <svn...@op...> - 2009-08-09 20:32:19
|
Author: scriptor Date: Sun Aug 9 22:32:06 2009 New Revision: 5710 URL: http://www.opensync.org/changeset/5710 Log: AUTH: I have fixed (resp. added) the support for "realms" and "authzid". Both of them now be configured, as required by certain authentication mechanisms. "authzid" is relevant for proxy authentication. Besides, I have fixed wrong return values in ldap_plugin_encrypt_connection(). This belongs to SSL/TLS. Moreover, I've done some cosmetics. For people playing with SSL/TLS, be it for encryption only, or for authentication purposes (= SASL/EXTERNAL), libopenldap-2.4.15, as it ships with Fedora 11, has a bug: See: http://www.openldap.org/lists/openldap-commit/200903/msg00006.html http://www.openldap.org/devel/cvsweb.cgi/libraries/libldap/tls_o.c.diff?r1=1.6&r2=1.7&hideattic=1&sortbydate=0&f=h http://www.openldap.org/devel/cvsweb.cgi/libraries/libldap/tls_o.c.diff?r1=1.5.2.2&r2=1.5.2.3&hideattic=1&sortbydate=0&f=h Modified: plugins/ldap-sync/src/ldap-sync plugins/ldap-sync/src/ldap_connect.c plugins/ldap-sync/src/ldap_plugin.c plugins/ldap-sync/src/ldap_plugin.h plugins/ldap-sync/src/ldap_sasl.c Modified: plugins/ldap-sync/src/ldap-sync ============================================================================== --- plugins/ldap-sync/src/ldap-sync Sun Aug 2 20:37:34 2009 (r5709) +++ plugins/ldap-sync/src/ldap-sync Sun Aug 9 22:32:06 2009 (r5710) @@ -26,6 +26,12 @@ <Value>secret</Value> </AdvancedOption> + <AdvancedOption> + <Name>realm</Name> + <Type>string</Type> + <Value></Value> + </AdvancedOption> + <AdvancedOption> <!-- Anonymous bind --> <Name>anonymous</Name> Modified: plugins/ldap-sync/src/ldap_connect.c ============================================================================== --- plugins/ldap-sync/src/ldap_connect.c Sun Aug 2 20:37:34 2009 (r5709) +++ plugins/ldap-sync/src/ldap_connect.c Sun Aug 9 22:32:06 2009 (r5710) @@ -609,7 +609,6 @@ } - osync_trace(TRACE_EXIT, "%s", __func__); return TRUE; @@ -784,7 +783,7 @@ * @param sinkenv The object type specific environment. * @param error The libopensync error pointer. * - * @returns LDAP_SUCCESS on success, LDAP_PARAM_ERROR otherwise. + * @returns TRUE on success, FALSE in case of any error. */ osync_bool ldap_plugin_encrypt_connection (OSyncContext *ctx, sink_environment *sinkenv, OSyncError **error) @@ -823,14 +822,14 @@ osync_trace(TRACE_EXIT, "%s", __func__); - return LDAP_SUCCESS; + return TRUE; error: if (!osync_error_is_set(error)) osync_error_set(error, OSYNC_ERROR_GENERIC, "Unknown reason.\n"); - osync_context_report_osyncwarning(ctx, *error); + osync_context_report_osyncerror(ctx, *error); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); return FALSE; } @@ -869,8 +868,8 @@ unsigned sasl_flags = LDAP_SASL_AUTOMATIC; struct berval passwd = { 0, NULL }; lutilSASLdefaults *defaults = NULL; - const char *authmech = NULL, *binddn = NULL, *bindpwd = NULL, *authcid = NULL; - char *tmp_authmech = NULL, *tmp_binddn = NULL, *tmp_authcid = NULL; + const char *authmech = NULL, *binddn = NULL, *bindpwd = NULL, *authcid = NULL, *authzid = NULL, *realm = NULL; + char *tmp_authmech = NULL, *tmp_binddn = NULL, *tmp_authcid = NULL, *tmp_authzid = NULL, *tmp_realm = NULL; osync_bool rv = TRUE; int ldap_errno = 0; @@ -900,7 +899,8 @@ bindpwd = sinkenv->bindpwd; authmech = sinkenv->authmech; authcid = sinkenv->authcid; - + authzid = sinkenv->authzid; + realm = sinkenv->realm; } else { #ifdef DEBUG_auth @@ -911,6 +911,8 @@ bindpwd = ""; authmech = "SIMPLE"; authcid = ""; + authzid = ""; + realm = ""; } @@ -958,10 +960,12 @@ passwd.bv_len = strlen( passwd.bv_val ); tmp_authmech = g_strdup(authmech); tmp_authcid = g_strdup(authcid); + tmp_authzid = g_strdup(authzid); + tmp_realm = g_strdup(realm); // Load default parameters into a libldap specific struct - defaults = ldap_plugin_lutil_sasl_defaults(sinkenv->ld, tmp_authmech, NULL, tmp_authcid, passwd.bv_val, NULL); + defaults = ldap_plugin_lutil_sasl_defaults(sinkenv->ld, tmp_authmech, tmp_realm, tmp_authcid, passwd.bv_val, tmp_authzid); if (defaults == NULL) { osync_error_set(error, OSYNC_ERROR_NO_CONNECTION, "%s:%i: ERROR: defaults = NULL. ldap_plugin_lutil_sasl_defaults() has failed.\n", __FILE__, __LINE__); rv = FALSE; @@ -994,13 +998,20 @@ // Does not work: // ldap_plugin_list_libldap_sasl_mechanisms(ctx, sinkenv, error); } else { - ldap_plugin_printf("%s:%i: ERROR: Could not call ldap_plugin_list_sasl_mechanisms(), because both sinkenv->url and sinkenv->servername are NULL or empty.", __FILE__, __LINE__); + ldap_plugin_printf("%s:%i: ERROR: Could not call ldap_plugin_list_sasl_libsasl2_mechanisms(), because both sinkenv->url and sinkenv->servername are NULL or empty.", __FILE__, __LINE__); } } // LDAP_AUTH_METHOD_NOT_SUPPORTED, LDAP_AUTH_UNKNOWN else if (ldap_errno == LDAP_LOCAL_ERROR) { if (ldap_error && ldap_error[0] && tmp_authmech && tmp_authmech[0]) { if (!strcmp(tmp_authmech, "GSSAPI")) { if (strstr(ldap_error, "Unspecified GSS failure")) { + /* + For "gss_accept_sec_context", see: + + /root/rpmbuild/SOURCES/krb5-1.6.3/src/lib/gssapi/mechglue/g_accept_sec_context.c + + */ + if ( strstr(ldap_error, "No credentials cache found") || strstr(ldap_error, "Ticket expired") @@ -1070,6 +1081,16 @@ tmp_authcid = NULL; } + if (tmp_authzid) { + g_free(tmp_authzid); + tmp_authzid = NULL; + } + + if (tmp_realm) { + g_free(tmp_realm); + tmp_realm = NULL; + } + if (defaults) { if (defaults->mech) { g_free(defaults->mech); Modified: plugins/ldap-sync/src/ldap_plugin.c ============================================================================== --- plugins/ldap-sync/src/ldap_plugin.c Sun Aug 2 20:37:34 2009 (r5709) +++ plugins/ldap-sync/src/ldap_plugin.c Sun Aug 9 22:32:06 2009 (r5710) @@ -627,6 +627,7 @@ sinkenv->bindpwd = NULL; sinkenv->authcid = NULL; sinkenv->authzid = NULL; + sinkenv->realm = NULL; sinkenv->searchbase = NULL; sinkenv->searchfilter = NULL; sinkenv->storebase = NULL; @@ -697,6 +698,9 @@ if (!strcmp(name, "authzid")) sinkenv->authzid = g_strdup(val); + if (!strcmp(name, "realm")) + sinkenv->realm = g_strdup(val); + if (!strcmp(name, "anonymous")) { #ifdef DEBUG_auth ldap_plugin_printf("%s:%i: Previous setting of anonymous was: %i", __FILE__, __LINE__, sinkenv->anonymous); Modified: plugins/ldap-sync/src/ldap_plugin.h ============================================================================== --- plugins/ldap-sync/src/ldap_plugin.h Sun Aug 2 20:37:34 2009 (r5709) +++ plugins/ldap-sync/src/ldap_plugin.h Sun Aug 9 22:32:06 2009 (r5710) @@ -363,6 +363,8 @@ char *authzid; ///< authzid If the user wants to act on behalf of ///< someone else. Proxy authorization: Authenticate ///< as one person, act as a different person. + char *realm; ///< Name of a group of users; independend of the + ///< domain name char *bindpwd; ///< Bind password char *searchbase; ///< Base DN for any searches char *searchfilter; ///< Search filter Modified: plugins/ldap-sync/src/ldap_sasl.c ============================================================================== --- plugins/ldap-sync/src/ldap_sasl.c Sun Aug 2 20:37:34 2009 (r5709) +++ plugins/ldap-sync/src/ldap_sasl.c Sun Aug 9 22:32:06 2009 (r5710) @@ -196,11 +196,14 @@ #ifdef DEBUG_auth - ldap_plugin_printf("%s:%i: SASL defaults:", __FILE__, __LINE__); - ldap_plugin_printf("mech = %s", defaults->mech ? defaults->mech : "(null)"); - ldap_plugin_printf("realm = %s", defaults->realm ? defaults->realm : "(null)"); - ldap_plugin_printf("authcid = %s", defaults->authcid ? defaults->authcid : "(null)"); - ldap_plugin_printf("authzid = %s", defaults->authzid ? defaults->authzid : "(null)"); + ldap_plugin_printf("\n%s:%i: SASL defaults:", __FILE__, __LINE__); + ldap_plugin_printf("mech = \"%s\"", defaults->mech ? defaults->mech : "(null)"); + + ldap_plugin_printf("authcid = \"%s\"", defaults->authcid ? defaults->authcid : "(null)"); + ldap_plugin_printf("passwd = \"%s\"", defaults->passwd ? defaults->passwd : "(null)"); + ldap_plugin_printf("authzid = \"%s\"", defaults->authzid ? defaults->authzid : "(null)"); + ldap_plugin_printf("realm = \"%s\"", defaults->realm ? defaults->realm : "(null)"); + ldap_plugin_printf("\n"); #endif |
From: <svn...@op...> - 2009-08-07 19:37:27
|
Author: bellmich Date: Fri Aug 7 21:37:16 2009 New Revision: 1250 URL: http://libsyncml.opensync.org/changeset/1250 Log: added missing include file Modified: trunk/tests/check_ds.c Modified: trunk/tests/check_ds.c ============================================================================== --- trunk/tests/check_ds.c Fri Aug 7 21:35:28 2009 (r1249) +++ trunk/tests/check_ds.c Fri Aug 7 21:37:16 2009 (r1250) @@ -30,6 +30,8 @@ #include <libsyncml/sml_elements_internals.h> #include <libsyncml/data_sync_api/sml_location.h> +#include <string.h> + typedef struct SmlSessionThread { GMainContext *context; GSourceFuncs *functions; |
From: <svn...@op...> - 2009-08-07 19:35:42
|
Author: bellmich Date: Fri Aug 7 21:35:28 2009 New Revision: 1249 URL: http://libsyncml.opensync.org/changeset/1249 Log: automatic conversion from SmlChangeItem to SmlDataSyncChangeItem script follows ... set -e rm trunk/libsyncml/data_sync_api/* svn revert -R trunk svn revert -R trunk/cmake/modules FILES=`find trunk -type f -print | grep -v svn | grep -v cmake | grep -v "\.xml" | grep -v "\.wbmxl"` for FILE in $FILES; do echo -n File $FILE ... sed -i 's%SmlChangeItem%SmlDataSyncChangeItem%g' $FILE sed -i 's%sml_change_item%sml_data_sync_change_item%g' $FILE sed -i 's%CHANGE_ITEM%DATA_SYNC_CHANGE_ITEM%g' $FILE echo DONE done svn mv trunk/libsyncml/data_sync_api/sml_change_item.c trunk/libsyncml/data_sync_api/sml_data_sync_change_item.c svn mv trunk/libsyncml/data_sync_api/sml_change_item.h trunk/libsyncml/data_sync_api/sml_data_sync_change_item.h svn mv trunk/libsyncml/data_sync_api/sml_change_item_internals.h trunk/libsyncml/data_sync_api/sml_data_sync_change_item_internals.h Added: trunk/libsyncml/data_sync_api/sml_data_sync_change_item.c - copied, changed from r1230, trunk/libsyncml/data_sync_api/sml_change_item.c trunk/libsyncml/data_sync_api/sml_data_sync_change_item.h - copied, changed from r1230, trunk/libsyncml/data_sync_api/sml_change_item.h trunk/libsyncml/data_sync_api/sml_data_sync_change_item_internals.h - copied, changed from r1230, trunk/libsyncml/data_sync_api/sml_change_item_internals.h Deleted: trunk/libsyncml/data_sync_api/sml_change_item.c trunk/libsyncml/data_sync_api/sml_change_item.h trunk/libsyncml/data_sync_api/sml_change_item_internals.h Modified: trunk/libsyncml/CMakeLists.txt trunk/libsyncml/data_sync_api/data_sync.c trunk/libsyncml/data_sync_api/data_sync_callbacks.c trunk/libsyncml/data_sync_api/data_sync_callbacks.h trunk/libsyncml/data_sync_api/sml_data_sync_enum_types.c trunk/libsyncml/data_sync_api/sml_data_sync_enum_types.h trunk/libsyncml/data_sync_api/standard.h trunk/libsyncml/objects/sml_ds_server.c trunk/libsyncml/objects/sml_ds_server.h trunk/libsyncml/objects/sml_ds_server_internals.h trunk/libsyncml/parser/sml_xml_assm.c trunk/libsyncml/parser/sml_xml_parse.c trunk/libsyncml/sml_command.c trunk/libsyncml/sml_command.h trunk/libsyncml/sml_parse.c trunk/libsyncml/sml_session.c trunk/tests/check_data_sync_api_change_item.c trunk/tests/check_ds.c trunk/tests/check_session.c trunk/tests/check_sync.c trunk/tests/check_wbxml_assembler.c trunk/tests/check_xml_assembler.c trunk/tests/check_xml_parser.c trunk/tests/support.h Modified: trunk/libsyncml/CMakeLists.txt ============================================================================== --- trunk/libsyncml/CMakeLists.txt Fri Aug 7 19:57:20 2009 (r1248) +++ trunk/libsyncml/CMakeLists.txt Fri Aug 7 21:35:28 2009 (r1249) @@ -24,7 +24,7 @@ data_sync_api/data_sync_client.c data_sync_api/data_sync_server.c data_sync_api/sml_location.c - data_sync_api/sml_change_item.c + data_sync_api/sml_data_sync_change_item.c data_sync_api/sml_map_item.c data_sync_api/sml_data_sync_enum_types.c data_sync_api/transport_http_client.c @@ -82,7 +82,7 @@ INSTALL( FILES data_sync_api/sml_data_sync_enum_types.h data_sync_api/sml_location.h - data_sync_api/sml_change_item.h + data_sync_api/sml_data_sync_change_item.h data_sync_api/sml_map_item.h data_sync_api/defines.h data_sync_api/standard.h Modified: trunk/libsyncml/data_sync_api/data_sync.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync.c Fri Aug 7 19:57:20 2009 (r1248) +++ trunk/libsyncml/data_sync_api/data_sync.c Fri Aug 7 21:35:28 2009 (r1249) @@ -39,7 +39,7 @@ #include "data_sync_loop.h" #include "transport.h" #include "libsyncml/objects/sml_ds_server.h" -#include "libsyncml/data_sync_api/sml_change_item_internals.h" +#include "libsyncml/data_sync_api/sml_data_sync_change_item_internals.h" /* ********************************* */ /* object creation and configuration */ @@ -615,22 +615,22 @@ smlAssert(type); /* create a new change */ - SmlChangeItem *change = sml_change_item_new(); + SmlDataSyncChangeItem *change = sml_data_sync_change_item_new(); /* fill the new change */ - sml_change_item_set_action(change, type); + sml_data_sync_change_item_set_action(change, type); SmlLocation *loc = sml_location_new(); sml_location_set_uri(loc, name); - if (!sml_change_item_set_location(change, loc, error)) + if (!sml_data_sync_change_item_set_location(change, loc, error)) goto error; - sml_change_item_set_userdata (change, userdata); + sml_data_sync_change_item_set_userdata (change, userdata); /* determine the datastore */ SmlDataSyncDatastore *datastore = smlDataSyncGetDatastoreFromSource(dsObject, source, error); if (!datastore) goto error; - sml_change_item_set_data_store(change, datastore); - if (!sml_change_item_set_content_type(change, datastore->contentType, error)) + sml_data_sync_change_item_set_data_store(change, datastore); + if (!sml_data_sync_change_item_set_content_type(change, datastore->contentType, error)) goto error; /* copy data */ @@ -651,10 +651,10 @@ appClassLength == strlen(SML_CONTENT_TYPE_AUDIO) ) ) { /* binary data must be base64 encoded */ - if (!sml_change_item_set_binary_data(change, data, size, error)) + if (!sml_data_sync_change_item_set_binary_data(change, data, size, error)) goto error; } else { - if (!sml_change_item_set_data(change, data, size, error)) + if (!sml_data_sync_change_item_set_data(change, data, size, error)) goto error; } } @@ -724,7 +724,7 @@ int i = 0; for (i = 0; i < num; i++) { - SmlChangeItem *change = g_list_nth_data(datastore->changes, i); + SmlDataSyncChangeItem *change = g_list_nth_data(datastore->changes, i); if (!smlDsSessionQueueChange( datastore->session, change, @@ -918,7 +918,7 @@ smlDsServerFree(datastore->server); while(datastore->changes) { - SmlChangeItem *change = datastore->changes->data; + SmlDataSyncChangeItem *change = datastore->changes->data; datastore->changes = g_list_remove( datastore->changes, change); Modified: trunk/libsyncml/data_sync_api/data_sync_callbacks.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_callbacks.c Fri Aug 7 19:57:20 2009 (r1248) +++ trunk/libsyncml/data_sync_api/data_sync_callbacks.c Fri Aug 7 21:35:28 2009 (r1249) @@ -30,7 +30,7 @@ #include "data_sync_devinf.h" #include "libsyncml/objects/sml_ds_server.h" #include "libsyncml/sml_manager.h" -#include "sml_change_item_internals.h" +#include "sml_data_sync_change_item_internals.h" /* **************************************** */ /* ***** Management Callbacks ***** */ @@ -542,7 +542,7 @@ gboolean smlDataSyncChangeCallback( SmlDsSession *dsession, - SmlChangeItem *item, + SmlDataSyncChangeItem *item, void *userdata, GError **error) { @@ -552,15 +552,15 @@ SmlDataSyncDatastore *datastore = userdata; smlAssert(item); - smlAssert(sml_change_item_get_action(item)); + smlAssert(sml_data_sync_change_item_get_action(item)); smlAssert(datastore); smlAssert(datastore->dsObject); smlAssert(datastore->dsObject->changeCallback); /* some mobiles sends replace commands during slow-sync */ if (datastore->alertType == SML_ALERT_SLOW_SYNC && - sml_change_item_get_action(item) == SML_CHANGE_REPLACE) - sml_change_item_set_action(item, SML_CHANGE_ADD); + sml_data_sync_change_item_get_action(item) == SML_CHANGE_REPLACE) + sml_data_sync_change_item_set_action(item, SML_CHANGE_ADD); /* decode base64 data if necessary */ gchar *data = NULL; @@ -579,22 +579,22 @@ appClassLength == strlen(SML_CONTENT_TYPE_AUDIO) ) ) { /* binary data must be base64 encoded */ - data = (char *) g_base64_decode(sml_change_item_get_data(item), &length); + data = (char *) g_base64_decode(sml_data_sync_change_item_get_data(item), &length); if (!data) { g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The base 64 decoding of glib failed."); goto error; } } else { - data = g_strdup(sml_change_item_get_data(item)); + data = g_strdup(sml_data_sync_change_item_get_data(item)); length = strlen(data); } /* perform callback */ if (!datastore->dsObject->changeCallback( datastore->dsObject, datastore->sourceUri, - sml_change_item_get_action(item), - sml_location_get_uri(sml_change_item_get_location(item)), + sml_data_sync_change_item_get_action(item), + sml_location_get_uri(sml_data_sync_change_item_get_location(item)), data, length, datastore->dsObject->changeUserdata, error)) @@ -618,8 +618,8 @@ GError *error = NULL; smlAssert(userdata); - SmlChangeItem *change = userdata; - SmlDataSyncDatastore *datastore = sml_change_item_get_data_store(change); + SmlDataSyncChangeItem *change = userdata; + SmlDataSyncDatastore *datastore = sml_data_sync_change_item_get_data_store(change); SmlDataSyncObject *dsObject = datastore->dsObject; smlAssert(dsObject); @@ -627,7 +627,7 @@ !dsObject->changeStatusCallback( dsObject, smlStatusGetCode(status), - sml_change_item_get_userdata(change), &error)) + sml_data_sync_change_item_get_userdata(change), &error)) goto error; smlTrace(TRACE_EXIT, "%s", __func__); Modified: trunk/libsyncml/data_sync_api/data_sync_callbacks.h ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_callbacks.h Fri Aug 7 19:57:20 2009 (r1248) +++ trunk/libsyncml/data_sync_api/data_sync_callbacks.h Fri Aug 7 21:35:28 2009 (r1249) @@ -75,7 +75,7 @@ gboolean smlDataSyncChangeCallback( SmlDsSession *dsession, - SmlChangeItem *item, + SmlDataSyncChangeItem *item, void *userdata, GError **error); Copied and modified: trunk/libsyncml/data_sync_api/sml_data_sync_change_item.c (from r1230, trunk/libsyncml/data_sync_api/sml_change_item.c) ============================================================================== --- trunk/libsyncml/data_sync_api/sml_change_item.c Fri Aug 7 19:35:36 2009 (r1230, copy source) +++ trunk/libsyncml/data_sync_api/sml_data_sync_change_item.c Fri Aug 7 21:35:28 2009 (r1249) @@ -1,4 +1,4 @@ -/* sml_change_item.c +/* sml_data_sync_change_item.c * * Copyright (C) 2009 Michael Bell <mic...@op...> * @@ -18,12 +18,12 @@ * Boston, MA 02110-1301 USA */ -#include "sml_change_item_internals.h" +#include "sml_data_sync_change_item_internals.h" #include "sml_data_sync_enum_types.h" #include "../sml_error_internals.h" #include <string.h> -G_DEFINE_TYPE (SmlChangeItem, sml_change_item, G_TYPE_OBJECT) +G_DEFINE_TYPE (SmlDataSyncChangeItem, sml_data_sync_change_item, G_TYPE_OBJECT) enum { @@ -38,7 +38,7 @@ PROP_USERDATA }; -struct _SmlChangeItemPrivate +struct _SmlDataSyncChangeItemPrivate { SmlChangeType type; SmlLocation* loc; @@ -51,35 +51,35 @@ }; static void -sml_change_item_get_property (GObject *object, +sml_data_sync_change_item_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { switch (property_id) { case PROP_TYPE: - g_value_set_enum (value, SML_CHANGE_ITEM (object)->priv->type); + g_value_set_enum (value, SML_DATA_SYNC_CHANGE_ITEM (object)->priv->type); break; case PROP_LOCATION: - g_value_set_object (value, SML_CHANGE_ITEM (object)->priv->loc); + g_value_set_object (value, SML_DATA_SYNC_CHANGE_ITEM (object)->priv->loc); break; case PROP_DATA: - g_value_set_string (value, SML_CHANGE_ITEM (object)->priv->data); + g_value_set_string (value, SML_DATA_SYNC_CHANGE_ITEM (object)->priv->data); break; case PROP_PLANNED_SIZE: - g_value_set_uint64 (value, SML_CHANGE_ITEM (object)->priv->planned_size); + g_value_set_uint64 (value, SML_DATA_SYNC_CHANGE_ITEM (object)->priv->planned_size); break; case PROP_CONTENT_TYPE: - g_value_set_string (value, SML_CHANGE_ITEM (object)->priv->content_type); + g_value_set_string (value, SML_DATA_SYNC_CHANGE_ITEM (object)->priv->content_type); break; case PROP_MISSING_DATA: - g_value_set_boolean (value, SML_CHANGE_ITEM (object)->priv->missing_data); + g_value_set_boolean (value, SML_DATA_SYNC_CHANGE_ITEM (object)->priv->missing_data); break; case PROP_DATA_STORE: - g_value_set_pointer (value, SML_CHANGE_ITEM (object)->priv->data_store); + g_value_set_pointer (value, SML_DATA_SYNC_CHANGE_ITEM (object)->priv->data_store); break; case PROP_USERDATA: - g_value_set_pointer (value, SML_CHANGE_ITEM (object)->priv->userdata); + g_value_set_pointer (value, SML_DATA_SYNC_CHANGE_ITEM (object)->priv->userdata); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -87,40 +87,40 @@ } static void -sml_change_item_set_property (GObject *object, +sml_data_sync_change_item_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { switch (property_id) { case PROP_TYPE: - SML_CHANGE_ITEM (object)->priv->type = g_value_get_enum (value); + SML_DATA_SYNC_CHANGE_ITEM (object)->priv->type = g_value_get_enum (value); break; case PROP_LOCATION: - if (SML_CHANGE_ITEM (object)->priv->loc) - g_object_unref (SML_CHANGE_ITEM (object)->priv->loc); - SML_CHANGE_ITEM (object)->priv->loc = SML_LOCATION (value); - g_object_ref(SML_CHANGE_ITEM (object)->priv->loc); + if (SML_DATA_SYNC_CHANGE_ITEM (object)->priv->loc) + g_object_unref (SML_DATA_SYNC_CHANGE_ITEM (object)->priv->loc); + SML_DATA_SYNC_CHANGE_ITEM (object)->priv->loc = SML_LOCATION (value); + g_object_ref(SML_DATA_SYNC_CHANGE_ITEM (object)->priv->loc); break; case PROP_DATA: - g_free (SML_CHANGE_ITEM (object)->priv->data); - SML_CHANGE_ITEM (object)->priv->data = g_strdup (g_value_get_string (value)); + g_free (SML_DATA_SYNC_CHANGE_ITEM (object)->priv->data); + SML_DATA_SYNC_CHANGE_ITEM (object)->priv->data = g_strdup (g_value_get_string (value)); break; case PROP_PLANNED_SIZE: - SML_CHANGE_ITEM (object)->priv->planned_size = g_value_get_uint64 (value); + SML_DATA_SYNC_CHANGE_ITEM (object)->priv->planned_size = g_value_get_uint64 (value); break; case PROP_CONTENT_TYPE: - g_free (SML_CHANGE_ITEM (object)->priv->content_type); - SML_CHANGE_ITEM (object)->priv->content_type = g_strdup (g_value_get_string (value)); + g_free (SML_DATA_SYNC_CHANGE_ITEM (object)->priv->content_type); + SML_DATA_SYNC_CHANGE_ITEM (object)->priv->content_type = g_strdup (g_value_get_string (value)); break; case PROP_MISSING_DATA: - SML_CHANGE_ITEM (object)->priv->missing_data = g_value_get_boolean (value); + SML_DATA_SYNC_CHANGE_ITEM (object)->priv->missing_data = g_value_get_boolean (value); break; case PROP_DATA_STORE: - SML_CHANGE_ITEM (object)->priv->data_store = (SmlDataSyncDatastore *) g_value_get_pointer(value); + SML_DATA_SYNC_CHANGE_ITEM (object)->priv->data_store = (SmlDataSyncDatastore *) g_value_get_pointer(value); break; case PROP_USERDATA: - SML_CHANGE_ITEM (object)->priv->userdata = (void *) g_value_get_pointer(value); + SML_DATA_SYNC_CHANGE_ITEM (object)->priv->userdata = (void *) g_value_get_pointer(value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -128,9 +128,9 @@ } static void -sml_change_item_finalize (GObject *object) +sml_data_sync_change_item_finalize (GObject *object) { - SmlChangeItem *self = (SmlChangeItem *) object; + SmlDataSyncChangeItem *self = (SmlDataSyncChangeItem *) object; if (self->priv->loc) g_object_unref(self->priv->loc); g_free(self->priv->data); @@ -142,22 +142,22 @@ self->priv->content_type = NULL; self->priv->data_store = NULL; self->priv->userdata = NULL; - G_OBJECT_CLASS (sml_change_item_parent_class)->finalize (object); + G_OBJECT_CLASS (sml_data_sync_change_item_parent_class)->finalize (object); } static void -sml_change_item_class_init (SmlChangeItemClass *klass) +sml_data_sync_change_item_class_init (SmlDataSyncChangeItemClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (SmlChangeItemPrivate)); + g_type_class_add_private (klass, sizeof (SmlDataSyncChangeItemPrivate)); - object_class->get_property = sml_change_item_get_property; - object_class->set_property = sml_change_item_set_property; - object_class->finalize = sml_change_item_finalize; + object_class->get_property = sml_data_sync_change_item_get_property; + object_class->set_property = sml_data_sync_change_item_set_property; + object_class->finalize = sml_data_sync_change_item_finalize; /** - * SmlChangeItem:location: + * SmlDataSyncChangeItem:location: * * The location property. */ @@ -169,7 +169,7 @@ G_TYPE_OBJECT, G_PARAM_READWRITE)); /** - * SmlChangeItem:data: + * SmlDataSyncChangeItem:data: * * The property. */ @@ -181,7 +181,7 @@ NULL, G_PARAM_READWRITE)); /** - * SmlChangeItem:planned_size: + * SmlDataSyncChangeItem:planned_size: * * The property. */ @@ -195,7 +195,7 @@ 0, G_PARAM_READWRITE)); /** - * SmlChangeItem:content_type: + * SmlDataSyncChangeItem:content_type: * * The property. */ @@ -207,7 +207,7 @@ NULL, G_PARAM_READWRITE)); /** - * SmlChangeItem:missing_data: + * SmlDataSyncChangeItem:missing_data: * * The MoreData flag property. */ @@ -219,7 +219,7 @@ FALSE, G_PARAM_READWRITE)); /** - * SmlChangeItem:data_store: + * SmlDataSyncChangeItem:data_store: * * The data store property. */ @@ -233,54 +233,54 @@ } static void -sml_change_item_init (SmlChangeItem *self) +sml_data_sync_change_item_init (SmlDataSyncChangeItem *self) { self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - SML_TYPE_CHANGE_ITEM, - SmlChangeItemPrivate); + SML_TYPE_DATA_SYNC_CHANGE_ITEM, + SmlDataSyncChangeItemPrivate); } /** - * sml_change_item_new: + * sml_data_sync_change_item_new: * - * Creates a new instance of #SmlChangeItem. + * Creates a new instance of #SmlDataSyncChangeItem. * - * Return value: the newly created #SmlChangeItem instance + * Return value: the newly created #SmlDataSyncChangeItem instance */ -SmlChangeItem* -sml_change_item_new (void) +SmlDataSyncChangeItem* +sml_data_sync_change_item_new (void) { - return g_object_new (SML_TYPE_CHANGE_ITEM, NULL); + return g_object_new (SML_TYPE_DATA_SYNC_CHANGE_ITEM, NULL); } /** - * sml_change_item_get_location: - * @self: A #SmlChangeItem + * sml_data_sync_change_item_get_location: + * @self: A #SmlDataSyncChangeItem * * Gets the location property. * * Return value: */ SmlLocation* -sml_change_item_get_location (SmlChangeItem *self) +sml_data_sync_change_item_get_location (SmlDataSyncChangeItem *self) { - g_return_val_if_fail (SML_IS_CHANGE_ITEM (self), NULL); + g_return_val_if_fail (SML_IS_DATA_SYNC_CHANGE_ITEM (self), NULL); return self->priv->loc; } /** - * sml_change_item_set_location: - * @self: A #SmlChangeItem + * sml_data_sync_change_item_set_location: + * @self: A #SmlDataSyncChangeItem * @loc: * * Sets the location property. */ gboolean -sml_change_item_set_location (SmlChangeItem *self, +sml_data_sync_change_item_set_location (SmlDataSyncChangeItem *self, SmlLocation* loc, GError **error) { - sml_return_val_error_if_fail (SML_IS_CHANGE_ITEM (self), FALSE, error, SML_ERROR_GENERIC, "There must be a SmlChangeItem object."); + sml_return_val_error_if_fail (SML_IS_DATA_SYNC_CHANGE_ITEM (self), FALSE, error, SML_ERROR_GENERIC, "There must be a SmlDataSyncChangeItem object."); sml_return_val_error_if_fail (!loc || sml_location_get_uri(loc), FALSE, error, SML_ERROR_GENERIC, "The location must have an URI."); if (self->priv->loc) @@ -292,35 +292,35 @@ } /** - * sml_change_item_get_data: - * @self: A #SmlChangeItem + * sml_data_sync_change_item_get_data: + * @self: A #SmlDataSyncChangeItem * * Gets the data property. * * Return value: */ G_CONST_RETURN gchar* -sml_change_item_get_data (SmlChangeItem *self) +sml_data_sync_change_item_get_data (SmlDataSyncChangeItem *self) { - g_return_val_if_fail (SML_IS_CHANGE_ITEM (self), NULL); + g_return_val_if_fail (SML_IS_DATA_SYNC_CHANGE_ITEM (self), NULL); return self->priv->data; } /** - * sml_change_item_set_data: - * @self: A #SmlChangeItem + * sml_data_sync_change_item_set_data: + * @self: A #SmlDataSyncChangeItem * @data: * @size: * * Sets the data property. */ gboolean -sml_change_item_set_data (SmlChangeItem *self, +sml_data_sync_change_item_set_data (SmlDataSyncChangeItem *self, const gchar* data, gsize size, GError **error) { - sml_return_val_error_if_fail (SML_IS_CHANGE_ITEM (self), FALSE, error, SML_ERROR_GENERIC, "There must be a SmlChangeItem object."); + sml_return_val_error_if_fail (SML_IS_DATA_SYNC_CHANGE_ITEM (self), FALSE, error, SML_ERROR_GENERIC, "There must be a SmlDataSyncChangeItem object."); sml_return_val_error_if_fail (data != NULL, FALSE, error, SML_ERROR_GENERIC, "The data must be different from NULL."); sml_return_val_error_if_fail (strlen(data), FALSE, error, SML_ERROR_GENERIC, "The data must not be the empty word."); @@ -338,20 +338,20 @@ } /** - * sml_change_item_set_binary_data: - * @self: A #SmlChangeItem + * sml_data_sync_change_item_set_binary_data: + * @self: A #SmlDataSyncChangeItem * @data: * @size: * * Sets the data property. */ gboolean -sml_change_item_set_binary_data (SmlChangeItem *self, +sml_data_sync_change_item_set_binary_data (SmlDataSyncChangeItem *self, const gchar* data, gsize size, GError **error) { - sml_return_val_error_if_fail (SML_IS_CHANGE_ITEM (self), FALSE, error, SML_ERROR_GENERIC, "There must be a SmlChangeItem object."); + sml_return_val_error_if_fail (SML_IS_DATA_SYNC_CHANGE_ITEM (self), FALSE, error, SML_ERROR_GENERIC, "There must be a SmlDataSyncChangeItem object."); sml_return_val_error_if_fail (size, FALSE, error, SML_ERROR_GENERIC, "The size must be present."); g_free (self->priv->data); @@ -363,63 +363,63 @@ } /** - * sml_change_item_get_planned_size: - * @self: A #SmlChangeItem + * sml_data_sync_change_item_get_planned_size: + * @self: A #SmlDataSyncChangeItem * * Gets the planned size property. * * Return value: */ gsize -sml_change_item_get_planned_size (SmlChangeItem *self) +sml_data_sync_change_item_get_planned_size (SmlDataSyncChangeItem *self) { - g_return_val_if_fail (SML_IS_CHANGE_ITEM (self), 0); + g_return_val_if_fail (SML_IS_DATA_SYNC_CHANGE_ITEM (self), 0); return self->priv->planned_size; } /** - * sml_change_item_set_planned_size: - * @self: A #SmlChangeItem + * sml_data_sync_change_item_set_planned_size: + * @self: A #SmlDataSyncChangeItem * @planned_size: * * Sets the planned size property. */ void -sml_change_item_set_planned_size (SmlChangeItem *self, +sml_data_sync_change_item_set_planned_size (SmlDataSyncChangeItem *self, gsize planned_size) { - g_return_if_fail (SML_IS_CHANGE_ITEM (self)); + g_return_if_fail (SML_IS_DATA_SYNC_CHANGE_ITEM (self)); self->priv->planned_size = planned_size; } /** - * sml_change_item_get_content_type: - * @self: A #SmlChangeItem + * sml_data_sync_change_item_get_content_type: + * @self: A #SmlDataSyncChangeItem * * Gets the content-type property. * * Return value: */ G_CONST_RETURN gchar* -sml_change_item_get_content_type (SmlChangeItem *self) +sml_data_sync_change_item_get_content_type (SmlDataSyncChangeItem *self) { - g_return_val_if_fail (SML_IS_CHANGE_ITEM (self), NULL); + g_return_val_if_fail (SML_IS_DATA_SYNC_CHANGE_ITEM (self), NULL); return self->priv->content_type; } /** - * sml_change_item_set_content_type: - * @self: A #SmlChangeItem + * sml_data_sync_change_item_set_content_type: + * @self: A #SmlDataSyncChangeItem * @content_type: * * Sets the content-type property. */ gboolean -sml_change_item_set_content_type (SmlChangeItem *self, +sml_data_sync_change_item_set_content_type (SmlDataSyncChangeItem *self, const gchar* content_type, GError **error) { - sml_return_val_error_if_fail (SML_IS_CHANGE_ITEM (self), FALSE, error, SML_ERROR_GENERIC, "There must be a SmlChangeItem object."); + sml_return_val_error_if_fail (SML_IS_DATA_SYNC_CHANGE_ITEM (self), FALSE, error, SML_ERROR_GENERIC, "There must be a SmlDataSyncChangeItem object."); sml_return_val_error_if_fail (content_type != NULL, FALSE, error, SML_ERROR_GENERIC, "The content-type must be different from NULL."); sml_return_val_error_if_fail (strlen(content_type), FALSE, error, SML_ERROR_GENERIC, "The content-type must be different from the empty word."); @@ -432,161 +432,161 @@ } /** - * sml_change_item_get_missing_data: - * @self: A #SmlChangeItem + * sml_data_sync_change_item_get_missing_data: + * @self: A #SmlDataSyncChangeItem * * Gets the MoreData flag property. * * Return value: */ gboolean -sml_change_item_get_missing_data (SmlChangeItem *self) +sml_data_sync_change_item_get_missing_data (SmlDataSyncChangeItem *self) { - g_return_val_if_fail (SML_IS_CHANGE_ITEM (self), FALSE); + g_return_val_if_fail (SML_IS_DATA_SYNC_CHANGE_ITEM (self), FALSE); return self->priv->missing_data; } /** - * sml_change_item_set_missing_data: - * @self: A #SmlChangeItem + * sml_data_sync_change_item_set_missing_data: + * @self: A #SmlDataSyncChangeItem * @missing_data: * * Sets the MoreData flag property. */ void -sml_change_item_set_missing_data (SmlChangeItem *self, +sml_data_sync_change_item_set_missing_data (SmlDataSyncChangeItem *self, gboolean missing_data) { - g_return_if_fail (SML_IS_CHANGE_ITEM (self)); + g_return_if_fail (SML_IS_DATA_SYNC_CHANGE_ITEM (self)); self->priv->missing_data = missing_data; } /** - * sml_change_item_get_action: - * @self: A #SmlChangeItem + * sml_data_sync_change_item_get_action: + * @self: A #SmlDataSyncChangeItem * * Gets the change type property. * * Return value: */ SmlChangeType -sml_change_item_get_action (SmlChangeItem *self) +sml_data_sync_change_item_get_action (SmlDataSyncChangeItem *self) { - g_return_val_if_fail (SML_IS_CHANGE_ITEM (self), FALSE); + g_return_val_if_fail (SML_IS_DATA_SYNC_CHANGE_ITEM (self), FALSE); return self->priv->type; } /** - * sml_change_item_set_action: - * @self: A #SmlChangeItem + * sml_data_sync_change_item_set_action: + * @self: A #SmlDataSyncChangeItem * @missing_data: * * Sets the change type property. */ void -sml_change_item_set_action (SmlChangeItem *self, +sml_data_sync_change_item_set_action (SmlDataSyncChangeItem *self, SmlChangeType type) { - g_return_if_fail (SML_IS_CHANGE_ITEM (self)); + g_return_if_fail (SML_IS_DATA_SYNC_CHANGE_ITEM (self)); self->priv->type = type; } /** - * sml_change_item_get_data_store: - * @self: A #SmlChangeItem + * sml_data_sync_change_item_get_data_store: + * @self: A #SmlDataSyncChangeItem * * Gets the data store property. * * Return value: */ SmlDataSyncDatastore* -sml_change_item_get_data_store (SmlChangeItem *self) +sml_data_sync_change_item_get_data_store (SmlDataSyncChangeItem *self) { - g_return_val_if_fail (SML_IS_CHANGE_ITEM (self), FALSE); + g_return_val_if_fail (SML_IS_DATA_SYNC_CHANGE_ITEM (self), FALSE); return self->priv->data_store; } /** - * sml_change_item_set_data_store: - * @self: A #SmlChangeItem + * sml_data_sync_change_item_set_data_store: + * @self: A #SmlDataSyncChangeItem * @ds: * * Sets the change type property. */ void -sml_change_item_set_data_store (SmlChangeItem *self, +sml_data_sync_change_item_set_data_store (SmlDataSyncChangeItem *self, SmlDataSyncDatastore *ds) { - g_return_if_fail (SML_IS_CHANGE_ITEM (self)); + g_return_if_fail (SML_IS_DATA_SYNC_CHANGE_ITEM (self)); self->priv->data_store = ds; } /** - * sml_change_item_get_userdata: - * @self: A #SmlChangeItem + * sml_data_sync_change_item_get_userdata: + * @self: A #SmlDataSyncChangeItem * * Gets the userdata property. * * Return value: */ void* -sml_change_item_get_userdata (SmlChangeItem *self) +sml_data_sync_change_item_get_userdata (SmlDataSyncChangeItem *self) { - g_return_val_if_fail (SML_IS_CHANGE_ITEM (self), FALSE); + g_return_val_if_fail (SML_IS_DATA_SYNC_CHANGE_ITEM (self), FALSE); return self->priv->userdata; } /** - * sml_change_item_set_userdata: - * @self: A #SmlChangeItem + * sml_data_sync_change_item_set_userdata: + * @self: A #SmlDataSyncChangeItem * @userdata: * * Sets the userdata property. */ void -sml_change_item_set_userdata (SmlChangeItem *self, +sml_data_sync_change_item_set_userdata (SmlDataSyncChangeItem *self, void *userdata) { - g_return_if_fail (SML_IS_CHANGE_ITEM (self)); + g_return_if_fail (SML_IS_DATA_SYNC_CHANGE_ITEM (self)); self->priv->userdata = userdata; } /** - * sml_change_item_get_fragment: - * @self: A #SmlChangeItem + * sml_data_sync_change_item_get_fragment: + * @self: A #SmlDataSyncChangeItem * * */ -SmlChangeItem* -sml_change_item_get_fragment (SmlChangeItem *self, +SmlDataSyncChangeItem* +sml_data_sync_change_item_get_fragment (SmlDataSyncChangeItem *self, gsize start, gsize max_size, GError **error) { - sml_return_val_error_if_fail (SML_IS_CHANGE_ITEM (self), NULL, error, SML_ERROR_GENERIC, "There must be a SmlChangeItem object."); + sml_return_val_error_if_fail (SML_IS_DATA_SYNC_CHANGE_ITEM (self), NULL, error, SML_ERROR_GENERIC, "There must be a SmlDataSyncChangeItem object."); sml_return_val_error_if_fail (self->priv->data, NULL, error, SML_ERROR_GENERIC, "There must be some data."); sml_return_val_error_if_fail (max_size, NULL, error, SML_ERROR_GENERIC, "There is no maximum size set."); - SmlChangeItem *frag = sml_change_item_new(); - sml_return_val_error_if_fail (frag, NULL, error, SML_ERROR_GENERIC, "Cannot create new instance of SmlChangeItem - out of memory."); + SmlDataSyncChangeItem *frag = sml_data_sync_change_item_new(); + sml_return_val_error_if_fail (frag, NULL, error, SML_ERROR_GENERIC, "Cannot create new instance of SmlDataSyncChangeItem - out of memory."); if (start == 0 && max_size < strlen(self->priv->data)) - sml_change_item_set_planned_size(frag, strlen(self->priv->data)); + sml_data_sync_change_item_set_planned_size(frag, strlen(self->priv->data)); - if (!sml_change_item_set_data(frag, self->priv->data + start, max_size, error)) + if (!sml_data_sync_change_item_set_data(frag, self->priv->data + start, max_size, error)) goto error; if (start + max_size < strlen(self->priv->data)) - sml_change_item_set_missing_data(frag, TRUE); + sml_data_sync_change_item_set_missing_data(frag, TRUE); else - sml_change_item_set_missing_data(frag, FALSE); + sml_data_sync_change_item_set_missing_data(frag, FALSE); - if (sml_change_item_get_location(self) != NULL && - !sml_change_item_set_location(frag, sml_change_item_get_location(self), error)) + if (sml_data_sync_change_item_get_location(self) != NULL && + !sml_data_sync_change_item_set_location(frag, sml_data_sync_change_item_get_location(self), error)) goto error; - if (sml_change_item_get_content_type(self) != NULL && - !sml_change_item_set_content_type(frag, sml_change_item_get_content_type(self), error)) + if (sml_data_sync_change_item_get_content_type(self) != NULL && + !sml_data_sync_change_item_set_content_type(frag, sml_data_sync_change_item_get_content_type(self), error)) goto error; return frag; @@ -597,18 +597,18 @@ } /** - * sml_change_item_attach_fragment: - * @self: A #SmlChangeItem + * sml_data_sync_change_item_attach_fragment: + * @self: A #SmlDataSyncChangeItem * * */ gboolean -sml_change_item_attach_fragment (SmlChangeItem *self, - SmlChangeItem *frag, +sml_data_sync_change_item_attach_fragment (SmlDataSyncChangeItem *self, + SmlDataSyncChangeItem *frag, GError **error) { - sml_return_val_error_if_fail (SML_IS_CHANGE_ITEM (self), FALSE, error, SML_ERROR_GENERIC, "There must be a SmlChangeItem object."); - sml_return_val_error_if_fail (SML_IS_CHANGE_ITEM (frag), FALSE, error, SML_ERROR_GENERIC, "There must be a fragmentation object."); + sml_return_val_error_if_fail (SML_IS_DATA_SYNC_CHANGE_ITEM (self), FALSE, error, SML_ERROR_GENERIC, "There must be a SmlDataSyncChangeItem object."); + sml_return_val_error_if_fail (SML_IS_DATA_SYNC_CHANGE_ITEM (frag), FALSE, error, SML_ERROR_GENERIC, "There must be a fragmentation object."); sml_return_val_error_if_fail (frag->priv->data, FALSE, error, SML_ERROR_GENERIC, "The fragment does not contain any data."); sml_return_val_error_if_fail (strlen(frag->priv->data), FALSE, error, SML_ERROR_GENERIC, "The fragment does only contain an empty string."); sml_return_val_error_if_fail ((!self->priv->content_type && !frag->priv->content_type) || Copied and modified: trunk/libsyncml/data_sync_api/sml_data_sync_change_item.h (from r1230, trunk/libsyncml/data_sync_api/sml_change_item.h) ============================================================================== --- trunk/libsyncml/data_sync_api/sml_change_item.h Fri Aug 7 19:35:36 2009 (r1230, copy source) +++ trunk/libsyncml/data_sync_api/sml_data_sync_change_item.h Fri Aug 7 21:35:28 2009 (r1249) @@ -1,4 +1,4 @@ -/* sml_change_item.h +/* sml_data_sync_change_item.h * * Copyright (C) 2009 Michael Bell <mic...@op...> * @@ -18,8 +18,8 @@ * Boston, MA 02110-1301 USA */ -#ifndef __SML_CHANGE_ITEM_H__ -#define __SML_CHANGE_ITEM_H__ +#ifndef __SML_DATA_SYNC_CHANGE_ITEM_H__ +#define __SML_DATA_SYNC_CHANGE_ITEM_H__ #include <glib-object.h> #include <libsyncml/data_sync_api/sml_location.h> @@ -34,42 +34,42 @@ SML_CHANGE_DELETE = 3 } SmlChangeType; -#define SML_TYPE_CHANGE_ITEM (sml_change_item_get_type()) -#define SML_CHANGE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SML_TYPE_CHANGE_ITEM, SmlChangeItem)) -#define SML_CHANGE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SML_TYPE_CHANGE_ITEM, SmlChangeItemClass)) -#define SML_IS_CHANGE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SML_TYPE_CHANGE_ITEM)) -#define SML_IS_CHANGE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SML_TYPE_CHANGE_ITEM)) -#define SML_CHANGE_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SML_TYPE_CHANGE_ITEM, SmlChangeItemClass)) - -typedef struct _SmlChangeItem SmlChangeItem; -typedef struct _SmlChangeItemClass SmlChangeItemClass; -typedef struct _SmlChangeItemPrivate SmlChangeItemPrivate; +#define SML_TYPE_DATA_SYNC_CHANGE_ITEM (sml_data_sync_change_item_get_type()) +#define SML_DATA_SYNC_CHANGE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SML_TYPE_DATA_SYNC_CHANGE_ITEM, SmlDataSyncChangeItem)) +#define SML_DATA_SYNC_CHANGE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SML_TYPE_DATA_SYNC_CHANGE_ITEM, SmlDataSyncChangeItemClass)) +#define SML_IS_DATA_SYNC_CHANGE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SML_TYPE_DATA_SYNC_CHANGE_ITEM)) +#define SML_IS_DATA_SYNC_CHANGE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SML_TYPE_DATA_SYNC_CHANGE_ITEM)) +#define SML_DATA_SYNC_CHANGE_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SML_TYPE_DATA_SYNC_CHANGE_ITEM, SmlDataSyncChangeItemClass)) + +typedef struct _SmlDataSyncChangeItem SmlDataSyncChangeItem; +typedef struct _SmlDataSyncChangeItemClass SmlDataSyncChangeItemClass; +typedef struct _SmlDataSyncChangeItemPrivate SmlDataSyncChangeItemPrivate; -struct _SmlChangeItem +struct _SmlDataSyncChangeItem { GObject parent; /*< private >*/ - SmlChangeItemPrivate *priv; + SmlDataSyncChangeItemPrivate *priv; }; -struct _SmlChangeItemClass +struct _SmlDataSyncChangeItemClass { GObjectClass parent_class; }; -GType sml_change_item_get_type (void); -SmlChangeItem* sml_change_item_new (void); -SmlLocation* sml_change_item_get_location (SmlChangeItem *self); -gboolean sml_change_item_set_location (SmlChangeItem *self, SmlLocation* remote, GError **error); -G_CONST_RETURN gchar* sml_change_item_get_data (SmlChangeItem *self); -gboolean sml_change_item_set_data (SmlChangeItem *self, const gchar *data, gsize size, GError **error); -gboolean sml_change_item_set_binary_data (SmlChangeItem *self, const gchar *data, gsize size, GError **error); -G_CONST_RETURN gchar* sml_change_item_get_content_type (SmlChangeItem *self); -gboolean sml_change_item_set_content_type (SmlChangeItem *self, const gchar* content_type, GError **error); -SmlChangeType sml_change_item_get_action (SmlChangeItem *self); -void sml_change_item_set_action (SmlChangeItem *self, SmlChangeType kind); +GType sml_data_sync_change_item_get_type (void); +SmlDataSyncChangeItem* sml_data_sync_change_item_new (void); +SmlLocation* sml_data_sync_change_item_get_location (SmlDataSyncChangeItem *self); +gboolean sml_data_sync_change_item_set_location (SmlDataSyncChangeItem *self, SmlLocation* remote, GError **error); +G_CONST_RETURN gchar* sml_data_sync_change_item_get_data (SmlDataSyncChangeItem *self); +gboolean sml_data_sync_change_item_set_data (SmlDataSyncChangeItem *self, const gchar *data, gsize size, GError **error); +gboolean sml_data_sync_change_item_set_binary_data (SmlDataSyncChangeItem *self, const gchar *data, gsize size, GError **error); +G_CONST_RETURN gchar* sml_data_sync_change_item_get_content_type (SmlDataSyncChangeItem *self); +gboolean sml_data_sync_change_item_set_content_type (SmlDataSyncChangeItem *self, const gchar* content_type, GError **error); +SmlChangeType sml_data_sync_change_item_get_action (SmlDataSyncChangeItem *self); +void sml_data_sync_change_item_set_action (SmlDataSyncChangeItem *self, SmlChangeType kind); G_END_DECLS -#endif /* __SML_CHANGE_ITEM_H__ */ +#endif /* __SML_DATA_SYNC_CHANGE_ITEM_H__ */ Copied and modified: trunk/libsyncml/data_sync_api/sml_data_sync_change_item_internals.h (from r1230, trunk/libsyncml/data_sync_api/sml_change_item_internals.h) ============================================================================== --- trunk/libsyncml/data_sync_api/sml_change_item_internals.h Fri Aug 7 19:35:36 2009 (r1230, copy source) +++ trunk/libsyncml/data_sync_api/sml_data_sync_change_item_internals.h Fri Aug 7 21:35:28 2009 (r1249) @@ -1,4 +1,4 @@ -/* sml_change_item_internals.h +/* sml_data_sync_change_item_internals.h * * Copyright (C) 2009 Michael Bell <mic...@op...> * @@ -18,26 +18,26 @@ * Boston, MA 02110-1301 USA */ -#ifndef __SML_CHANGE_ITEM_INTERNALS_H__ -#define __SML_CHANGE_ITEM_INTERNALS_H__ +#ifndef __SML_DATA_SYNC_CHANGE_ITEM_INTERNALS_H__ +#define __SML_DATA_SYNC_CHANGE_ITEM_INTERNALS_H__ #include <glib-object.h> -#include <libsyncml/data_sync_api/sml_change_item.h> +#include <libsyncml/data_sync_api/sml_data_sync_change_item.h> #include <libsyncml/data_sync_api/data_sync.h> G_BEGIN_DECLS -gsize sml_change_item_get_planned_size (SmlChangeItem *self); -void sml_change_item_set_planned_size (SmlChangeItem *self, gsize planned_size); -gboolean sml_change_item_get_missing_data (SmlChangeItem *self); -void sml_change_item_set_missing_data (SmlChangeItem *self, gboolean missing_data); -gboolean sml_change_item_attach_fragment (SmlChangeItem *self, SmlChangeItem *fragment, GError **error); -SmlChangeItem* sml_change_item_get_fragment (SmlChangeItem *self, gsize start, gsize max_size, GError **error); -void* sml_change_item_get_userdata (SmlChangeItem *self); -void sml_change_item_set_userdata (SmlChangeItem *self, void *userdata); -SmlDataSyncDatastore* sml_change_item_get_data_store (SmlChangeItem *self); -void sml_change_item_set_data_store (SmlChangeItem *self, SmlDataSyncDatastore *ds); +gsize sml_data_sync_change_item_get_planned_size (SmlDataSyncChangeItem *self); +void sml_data_sync_change_item_set_planned_size (SmlDataSyncChangeItem *self, gsize planned_size); +gboolean sml_data_sync_change_item_get_missing_data (SmlDataSyncChangeItem *self); +void sml_data_sync_change_item_set_missing_data (SmlDataSyncChangeItem *self, gboolean missing_data); +gboolean sml_data_sync_change_item_attach_fragment (SmlDataSyncChangeItem *self, SmlDataSyncChangeItem *fragment, GError **error); +SmlDataSyncChangeItem* sml_data_sync_change_item_get_fragment (SmlDataSyncChangeItem *self, gsize start, gsize max_size, GError **error); +void* sml_data_sync_change_item_get_userdata (SmlDataSyncChangeItem *self); +void sml_data_sync_change_item_set_userdata (SmlDataSyncChangeItem *self, void *userdata); +SmlDataSyncDatastore* sml_data_sync_change_item_get_data_store (SmlDataSyncChangeItem *self); +void sml_data_sync_change_item_set_data_store (SmlDataSyncChangeItem *self, SmlDataSyncDatastore *ds); G_END_DECLS -#endif /* __SML_CHANGE_ITEM_INTERNALS_H__ */ +#endif /* __SML_DATA_SYNC_CHANGE_ITEM_INTERNALS_H__ */ Modified: trunk/libsyncml/data_sync_api/sml_data_sync_enum_types.c ============================================================================== --- trunk/libsyncml/data_sync_api/sml_data_sync_enum_types.c Fri Aug 7 19:57:20 2009 (r1248) +++ trunk/libsyncml/data_sync_api/sml_data_sync_enum_types.c Fri Aug 7 21:35:28 2009 (r1249) @@ -10,9 +10,9 @@ */ -/* enumerations from "sml_change_item.h" */ +/* enumerations from "sml_data_sync_change_item.h" */ -#include <libsyncml/data_sync_api/sml_change_item.h> +#include <libsyncml/data_sync_api/sml_data_sync_change_item.h> GType sml_change_type_get_type (void) Modified: trunk/libsyncml/data_sync_api/sml_data_sync_enum_types.h ============================================================================== --- trunk/libsyncml/data_sync_api/sml_data_sync_enum_types.h Fri Aug 7 19:57:20 2009 (r1248) +++ trunk/libsyncml/data_sync_api/sml_data_sync_enum_types.h Fri Aug 7 21:35:28 2009 (r1249) @@ -15,7 +15,7 @@ G_BEGIN_DECLS -/* enumerations from "sml_change_item.h" */ +/* enumerations from "sml_data_sync_change_item.h" */ GType sml_change_type_get_type (void) G_GNUC_CONST; #define SML_DATA_SYNC_TYPE_CHANGE_TYPE (sml_change_type_get_type ()) G_END_DECLS Modified: trunk/libsyncml/data_sync_api/standard.h ============================================================================== --- trunk/libsyncml/data_sync_api/standard.h Fri Aug 7 19:57:20 2009 (r1248) +++ trunk/libsyncml/data_sync_api/standard.h Fri Aug 7 21:35:28 2009 (r1249) @@ -35,7 +35,7 @@ #include <libsyncml/data_sync_api/defines.h> #include <libsyncml/data_sync_api/sml_location.h> -#include <libsyncml/data_sync_api/sml_change_item.h> +#include <libsyncml/data_sync_api/sml_data_sync_change_item.h> #include <libsyncml/data_sync_api/sml_map_item.h> #ifdef __cplusplus Modified: trunk/libsyncml/objects/sml_ds_server.c ============================================================================== --- trunk/libsyncml/objects/sml_ds_server.c Fri Aug 7 19:57:20 2009 (r1248) +++ trunk/libsyncml/objects/sml_ds_server.c Fri Aug 7 21:35:28 2009 (r1249) @@ -38,10 +38,10 @@ GList *c = NULL; for (c = dsession->pendingChanges; c; c = c->next) { SmlWriteContext *ctx = c->data; - SmlLocation *loc = sml_change_item_get_location(ctx->item); + SmlLocation *loc = sml_data_sync_change_item_get_location(ctx->item); const char *uri = sml_location_get_full_uri(loc); if (!strcmp(uid, uri) && - sml_change_item_get_action(ctx->item) == type) { + sml_data_sync_change_item_get_action(ctx->item) == type) { g_mutex_unlock(dsession->pendingChangesLock); smlTrace(TRACE_EXIT, "%s: %p", __func__, ctx); return ctx; @@ -612,7 +612,7 @@ gsize i; for (i=0; i < smlCommandGetNumChanges(cmd); i++) { - SmlChangeItem *item = smlCommandGetNthChange(cmd, i); + SmlDataSyncChangeItem *item = smlCommandGetNthChange(cmd, i); if (!item) { g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, @@ -1074,7 +1074,7 @@ //Send a change to the remote side gboolean smlDsSessionQueueChange (SmlDsSession *dsession, - SmlChangeItem *item, + SmlDataSyncChangeItem *item, SmlDsSessionChangeStatusCb callback, void *userdata, GError **error) Modified: trunk/libsyncml/objects/sml_ds_server.h ============================================================================== --- trunk/libsyncml/objects/sml_ds_server.h Fri Aug 7 19:57:20 2009 (r1248) +++ trunk/libsyncml/objects/sml_ds_server.h Fri Aug 7 21:35:28 2009 (r1249) @@ -39,7 +39,7 @@ typedef void (* SmlDsSessionConnectCb) (SmlDsSession *dsession, void *userdata); typedef gboolean (* SmlDsSessionAlertCb) (SmlDsSession *dsession, SmlAlertType type, const gchar *last, const gchar *next, void *userdata); typedef void (* SmlDsSessionSyncCb) (SmlDsSession *dsession, gsize numchanges, void *userdata); -typedef gboolean (* SmlDsSessionChangeCb) (SmlDsSession *dsession, SmlChangeItem *item, void *userdata, GError **error); +typedef gboolean (* SmlDsSessionChangeCb) (SmlDsSession *dsession, SmlDataSyncChangeItem *item, void *userdata, GError **error); typedef void (* SmlDsSessionChangeStatusCb) (SmlDsSession *dsession, SmlStatus *status, void *userdata); typedef void (* SmlDsSessionMapCb) (SmlDsSession *dsession, SmlMapItem *item, void *userdata); @@ -65,7 +65,7 @@ void smlDsSessionGetChanges (SmlDsSession *dsession, SmlDsSessionChangeCb chgCallback, void *userdata); void smlDsSessionGetSync (SmlDsSession *dsession, SmlDsSessionSyncCb chgCallback, void *userdata); gboolean smlDsSessionSendSync (SmlDsSession *dsession, gsize num_changes, SmlStatusReplyCb callback, void *userdata, GError **error); -gboolean smlDsSessionQueueChange (SmlDsSession *dsession, SmlChangeItem *item, SmlDsSessionChangeStatusCb callback, void *userdata, GError **error); +gboolean smlDsSessionQueueChange (SmlDsSession *dsession, SmlDataSyncChangeItem *item, SmlDsSessionChangeStatusCb callback, void *userdata, GError **error); gboolean smlDsSessionCloseSync (SmlDsSession *dsession, GError **error); void smlDsSessionGetMapping (SmlDsSession *dsession, SmlDsSessionMapCb mapCallback, void *userdata); gboolean smlDsSessionQueueMap (SmlDsSession *dsession, SmlMapItem *item, GError **error); Modified: trunk/libsyncml/objects/sml_ds_server_internals.h ============================================================================== --- trunk/libsyncml/objects/sml_ds_server_internals.h Fri Aug 7 19:57:20 2009 (r1248) +++ trunk/libsyncml/objects/sml_ds_server_internals.h Fri Aug 7 21:35:28 2009 (r1249) @@ -34,7 +34,7 @@ typedef struct SmlWriteContext { SmlDsSessionChangeStatusCb callback; - SmlChangeItem *item; + SmlDataSyncChangeItem *item; SmlStatus *status; void *userdata; SmlDsSession *session; Modified: trunk/libsyncml/parser/sml_xml_assm.c ============================================================================== --- trunk/libsyncml/parser/sml_xml_assm.c Fri Aug 7 19:57:20 2009 (r1248) +++ trunk/libsyncml/parser/sml_xml_assm.c Fri Aug 7 21:35:28 2009 (r1249) @@ -26,7 +26,7 @@ #include "libsyncml/sml_error_internals.h" #include "libsyncml/data_sync_api/sml_map_item_internals.h" -#include "libsyncml/data_sync_api/sml_change_item_internals.h" +#include "libsyncml/data_sync_api/sml_data_sync_change_item_internals.h" #include "sml_xml_assm_internals.h" #include <string.h> @@ -464,7 +464,7 @@ } gboolean -smlChangeItemAssemble (SmlChangeItem *item, +smlChangeItemAssemble (SmlDataSyncChangeItem *item, SmlXmlAssembler *assm, GError **error) { @@ -510,7 +510,7 @@ gboolean fillSource = TRUE; SmlSessionType sessionType = assm->session->sessionType; const char *opt = smlAssemblerGetOption(assm->assembler, "ONLY_REPLACE"); - if (sml_change_item_get_action(item) == SML_CHANGE_ADD) + if (sml_data_sync_change_item_get_action(item) == SML_CHANGE_ADD) { if (opt && atoi(opt) && /* remote peer supports ONLY_REPLACE */ sessionType == SML_SESSION_TYPE_SERVER) { @@ -531,34 +531,34 @@ } /* Target */ - if (!fillSource && sml_change_item_get_location(item)) { - if (!smlLocationAssemble(sml_change_item_get_location(item), assm, SML_ELEMENT_TARGET, error)) + if (!fillSource && sml_data_sync_change_item_get_location(item)) { + if (!smlLocationAssemble(sml_data_sync_change_item_get_location(item), assm, SML_ELEMENT_TARGET, error)) goto error; } /* Source */ - if (fillSource && sml_change_item_get_location(item)) { - if (!smlLocationAssemble(sml_change_item_get_location(item), assm, SML_ELEMENT_SOURCE, error)) + if (fillSource && sml_data_sync_change_item_get_location(item)) { + if (!smlLocationAssemble(sml_data_sync_change_item_get_location(item), assm, SML_ELEMENT_SOURCE, error)) goto error; } /* SourceParent */ - if (fillSource && sml_change_item_get_location(item) && - sml_location_get_parent_uri(sml_change_item_get_location(item))) { - if (!smlLocationAssemble(sml_change_item_get_location(item), assm, SML_ELEMENT_SOURCE_PARENT, error)) + if (fillSource && sml_data_sync_change_item_get_location(item) && + sml_location_get_parent_uri(sml_data_sync_change_item_get_location(item))) { + if (!smlLocationAssemble(sml_data_sync_change_item_get_location(item), assm, SML_ELEMENT_SOURCE_PARENT, error)) goto error; } /* TargetParent */ - if (!fillSource && sml_change_item_get_location(item) && - sml_location_get_parent_uri(sml_change_item_get_location(item))) { - if (!smlLocationAssemble(sml_change_item_get_location(item), assm, SML_ELEMENT_TARGET_PARENT, error)) + if (!fillSource && sml_data_sync_change_item_get_location(item) && + sml_location_get_parent_uri(sml_data_sync_change_item_get_location(item))) { + if (!smlLocationAssemble(sml_data_sync_change_item_get_location(item), assm, SML_ELEMENT_TARGET_PARENT, error)) goto error; } /* Data */ - if (sml_change_item_get_data(item)) { - const gchar *data = sml_change_item_get_data(item); + if (sml_data_sync_change_item_get_data(item)) { + const gchar *data = sml_data_sync_change_item_get_data(item); gsize size = strlen(data);; if (!_smlXmlAssemblerAddData(assm, SML_ELEMENT_DATA, data, size, FALSE, error)) @@ -566,7 +566,7 @@ } /* MoreData */ - if (sml_change_item_get_missing_data(item)) { + if (sml_data_sync_change_item_get_missing_data(item)) { if (!_smlXmlAssemblerAddString(assm, SML_ELEMENT_MOREDATA, "", error)) goto error; @@ -703,14 +703,14 @@ /* libsyncml only supports one item per change command */ smlAssert(g_list_length(change->private.change.items) == 1); - SmlChangeItem *item = g_list_nth_data(change->private.change.items, 0); + SmlDataSyncChangeItem *item = g_list_nth_data(change->private.change.items, 0); if (!item) { g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "One item of the item list is NULL."); goto error; } - if (!sml_change_item_get_content_type(item)) { + if (!sml_data_sync_change_item_get_content_type(item)) { g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing contenttype"); goto error; @@ -720,7 +720,7 @@ if (!_smlXmlAssemblerStartNode(assm, SML_ELEMENT_META, error)) goto error; - if (!_smlXmlAssemblerAddStringNS(assm, SML_ELEMENT_TYPE, SML_NAMESPACE_METINF, sml_change_item_get_content_type(item), error)) + if (!_smlXmlAssemblerAddStringNS(assm, SML_ELEMENT_TYPE, SML_NAMESPACE_METINF, sml_data_sync_change_item_get_content_type(item), error)) goto error; /* We will add the max obj size node, if USE_LARGEOBJECTS is true or not set at all. Modified: trunk/libsyncml/parser/sml_xml_parse.c ============================================================================== --- trunk/libsyncml/parser/sml_xml_parse.c Fri Aug 7 19:57:20 2009 (r1248) +++ trunk/libsyncml/parser/sml_xml_parse.c Fri Aug 7 21:35:28 2009 (r1249) @@ -25,7 +25,7 @@ #include <libsyncml/sml_session_internals.h> #include "libsyncml/sml_error_internals.h" #include "libsyncml/data_sync_api/sml_location.h" -#include "libsyncml/data_sync_api/sml_change_item_internals.h" +#include "libsyncml/data_sync_api/sml_data_sync_change_item_internals.h" #include "sml_xml_parse_internals.h" #include <string.h> @@ -1139,15 +1139,15 @@ if (!item) goto error; - /* convert SmlItem to SmlChangeItem */ + /* convert SmlItem to SmlDataSyncChangeItem */ - SmlChangeItem *citem = sml_change_item_new(); + SmlDataSyncChangeItem *citem = sml_data_sync_change_item_new(); if (!citem) { smlItemUnref(item); - g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Cannot create new instance of SmlChangeItem - out of memory."); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Cannot create new instance of SmlDataSyncChangeItem - out of memory."); goto error; } - sml_change_item_set_action(citem, (*cmd)->private.change.type); + sml_data_sync_change_item_set_action(citem, (*cmd)->private.change.type); /* message from OMA DS client: * - ADD + source URI => automatically mapped item @@ -1159,33 +1159,33 @@ * => second check the source URI for a not yet mapped item */ if (smlItemGetTarget(item)) { - if (!sml_change_item_set_location(citem, smlItemGetTarget(item), error)) { + if (!sml_data_sync_change_item_set_location(citem, smlItemGetTarget(item), error)) { smlItemUnref(item); g_object_unref(citem); goto error; } } else { - if (!sml_change_item_set_location(citem, smlItemGetSource(item), error)) { + if (!sml_data_sync_change_item_set_location(citem, smlItemGetSource(item), error)) { smlItemUnref(item); g_object_unref(citem); goto error; } } if (smlItemGetContent(item) && - !sml_change_item_set_data(citem, smlItemGetContent(item), smlItemGetSize(item), error)) { + !sml_data_sync_change_item_set_data(citem, smlItemGetContent(item), smlItemGetSize(item), error)) { smlItemUnref(item); g_object_unref(citem); goto error; } if (smlItemGetContentType(item) && - !sml_change_item_set_content_type(citem, smlItemGetContentType(item), error)) { + !sml_data_sync_change_item_set_content_type(citem, smlItemGetContentType(item), error)) { smlItemUnref(item); g_object_unref(citem); goto error; } if (smlItemGetMoreData(item)) { - sml_change_item_set_missing_data(citem, TRUE); - sml_change_item_set_planned_size(citem, (*cmd)->size); + sml_data_sync_change_item_set_missing_data(citem, TRUE); + sml_data_sync_change_item_set_planned_size(citem, (*cmd)->size); } if (!source && smlItemGetSource(item)) { source = smlItemGetSource(item); @@ -1231,10 +1231,10 @@ guint i; for (i=0; i < g_list_length((*cmd)->private.change.items); i++) { - SmlChangeItem *item = g_list_nth_data((*cmd)->private.change.items, i); - if (sml_change_item_get_content_type(item) == NULL && + SmlDataSyncChangeItem *item = g_list_nth_data((*cmd)->private.change.items, i); + if (sml_data_sync_change_item_get_content_type(item) == NULL && contenttype && - !sml_change_item_set_content_type(item, contenttype, error)) { + !sml_data_sync_change_item_set_content_type(item, contenttype, error)) { goto error; } } Modified: trunk/libsyncml/sml_command.c ============================================================================== --- trunk/libsyncml/sml_command.c Fri Aug 7 19:57:20 2009 (r1248) +++ trunk/libsyncml/sml_command.c Fri Aug 7 21:35:28 2009 (r1249) @@ -25,7 +25,7 @@ #include "sml_support.h" #include "parser/sml_xml_assm.h" -#include <libsyncml/data_sync_api/sml_change_item_internals.h> +#include <libsyncml/data_sync_api/sml_data_sync_change_item_internals.h> SmlCommandType smlCommandTypeFromString (const gchar *name, @@ -414,7 +414,7 @@ guint i; for (i = 0; i < g_list_length(cmd->private.change.items); i++) { - SmlChangeItem *item = g_list_nth_data(cmd->private.change.items, i); + SmlDataSyncChangeItem *item = g_list_nth_data(cmd->private.change.items, i); g_object_unref(item); } g_list_free(cmd->private.change.items); @@ -446,14 +446,14 @@ } SmlCommand* -smlCommandNewChange (SmlChangeItem *item, +smlCommandNewChange (SmlDataSyncChangeItem *item, GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, item, error); CHECK_ERROR_REF SmlCommand *cmd = NULL; - switch (sml_change_item_get_action(item)) { + switch (sml_data_sync_change_item_get_action(item)) { case SML_CHANGE_ADD: cmd = smlCommandNew(SML_COMMAND_TYPE_ADD, error); break; @@ -1018,7 +1018,7 @@ return g_list_length(cmd->private.change.items); } -SmlChangeItem* +SmlDataSyncChangeItem* smlCommandGetNthChange (SmlCommand *cmd, gsize n) { @@ -1049,10 +1049,10 @@ { smlAssert(cmd); - SmlChangeItem *item = g_list_nth_data(cmd->private.change.items, n); - if (!sml_change_item_get_data(item)) + SmlDataSyncChangeItem *item = g_list_nth_data(cmd->private.change.items, n); + if (!sml_data_sync_change_item_get_data(item)) return 0; - return strlen(sml_change_item_get_data(item)); + return strlen(sml_data_sync_change_item_get_data(item)); } SmlCommand* @@ -1063,14 +1063,14 @@ { smlAssert(orig_cmd); - SmlChangeItem *frag_item = NULL; + SmlDataSyncChangeItem *frag_item = NULL; SmlCommand *frag_cmd = NULL; - SmlChangeItem *orig_item = g_list_nth_data(orig_cmd->private.change.items, 0); + SmlDataSyncChangeItem *orig_item = g_list_nth_data(orig_cmd->private.change.items, 0); /* create item fragment */ - frag_item = sml_change_item_get_fragment(orig_item, start, space, error); + frag_item = sml_data_sync_change_item_get_fragment(orig_item, start, space, error); if (!frag_item) goto error; @@ -1092,7 +1092,7 @@ * command. */ if (start == 0) - frag_cmd->size = strlen(sml_change_item_get_data(orig_item)); + frag_cmd->size = strlen(sml_data_sync_change_item_get_data(orig_item)); return frag_cmd; error: @@ -1119,7 +1119,7 @@ smlAssert(target); while(1) { - SmlChangeItem *item = g_list_nth_data(source->private.change.items, start); + SmlDataSyncChangeItem *item = g_list_nth_data(sour... [truncated message content] |
From: <svn...@op...> - 2009-08-07 17:57:34
|
Author: bellmich Date: Fri Aug 7 19:57:20 2009 New Revision: 1248 URL: http://libsyncml.opensync.org/changeset/1248 Log: updated test framework Modified: trunk/tests/CMakeLists.txt trunk/tests/check_data_sync_api_change_item.c trunk/tests/check_data_sync_api_map_item.c trunk/tests/check_devinf.c trunk/tests/check_ds.c trunk/tests/check_manager.c trunk/tests/check_session.c trunk/tests/check_sync.c trunk/tests/check_wbxml_assembler.c trunk/tests/check_xml_assembler.c trunk/tests/check_xml_parser.c trunk/tests/support.h Modified: trunk/tests/CMakeLists.txt ============================================================================== --- trunk/tests/CMakeLists.txt Fri Aug 7 19:56:42 2009 (r1247) +++ trunk/tests/CMakeLists.txt Fri Aug 7 19:57:20 2009 (r1248) @@ -91,14 +91,10 @@ SML_START_TEST( "change_item" data_sync_api_change_item check_data_sync_api_change_item.c ${TEST_TARGET_LIBRARIES} ) SML_ADD_TESTCASE( change_item_new ) - SML_ADD_TESTCASE( change_item_set_local ) - SML_ADD_TESTCASE( change_item_set_local_null ) - SML_ADD_TESTCASE( change_item_set_local_missing_uri ) - SML_ADD_TESTCASE( change_item_get_local ) - SML_ADD_TESTCASE( change_item_set_remote ) - SML_ADD_TESTCASE( change_item_set_remote_null ) - SML_ADD_TESTCASE( change_item_set_remote_missing_uri ) - SML_ADD_TESTCASE( change_item_get_remote ) + SML_ADD_TESTCASE( change_item_set_location ) + SML_ADD_TESTCASE( change_item_set_location_null ) + SML_ADD_TESTCASE( change_item_set_location_missing_uri ) + SML_ADD_TESTCASE( change_item_get_location ) SML_ADD_TESTCASE( change_item_set_data ) SML_ADD_TESTCASE( change_item_set_data_with_limit ) SML_ADD_TESTCASE( change_item_set_data_with_length ) Modified: trunk/tests/check_data_sync_api_change_item.c ============================================================================== --- trunk/tests/check_data_sync_api_change_item.c Fri Aug 7 19:56:42 2009 (r1247) +++ trunk/tests/check_data_sync_api_change_item.c Fri Aug 7 19:57:20 2009 (r1248) @@ -32,108 +32,19 @@ } END_TEST -START_TEST (change_item_set_local) +START_TEST (change_item_set_location) { setup_testbed(NULL); GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - - SmlChangeItem *item = sml_change_item_new(); - sml_fail_unless(item != NULL, NULL); - - sml_fail_unless(sml_change_item_set_local(item, location, &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - - g_object_unref(location); - g_object_unref(item); -} -END_TEST - -START_TEST (change_item_set_local_null) -{ - setup_testbed(NULL); - - GError *error = NULL; - - SmlChangeItem *item = sml_change_item_new(); - sml_fail_unless(item != NULL, NULL); - - sml_fail_unless(sml_change_item_set_local(item, NULL, &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - - g_object_unref(item); -} -END_TEST - -START_TEST (change_item_set_local_missing_uri) -{ - setup_testbed(NULL); - - GError *error = NULL; - SmlLocation *location = sml_location_new(); - sml_fail_unless(location != NULL, NULL); - - SmlChangeItem *item = sml_change_item_new(); - sml_fail_unless(item != NULL, NULL); - - sml_fail_unless(!sml_change_item_set_local(item, location, &error), "The location must have an URI."); - sml_fail_unless(error != NULL, NULL); - - g_error_free(error); - g_object_unref(location); - g_object_unref(item); -} -END_TEST - -START_TEST (change_item_get_local) -{ - setup_testbed(NULL); - - GError *error = NULL; - SmlLocation *location = sml_location_new(); - sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - - SmlChangeItem *item = sml_change_item_new(); - sml_fail_unless(item != NULL, NULL); - - sml_fail_unless(sml_change_item_get_local(item) == NULL, "The local location is not set until now."); - - sml_fail_unless(sml_change_item_set_local(item, location, &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - - sml_fail_unless(sml_change_item_get_local(item) != NULL, "The local location must be set now."); - sml_fail_unless(sml_change_item_get_local(item) == location, "The local location must be 1234."); - - sml_fail_unless(sml_change_item_set_local(item, NULL, &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - - sml_fail_unless(sml_change_item_get_local(item) == NULL, "The local location was deleted."); - - g_object_unref(location); - g_object_unref(item); -} -END_TEST - -START_TEST (change_item_set_remote) -{ - setup_testbed(NULL); - - GError *error = NULL; - SmlLocation *location = sml_location_new(); - sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); SmlChangeItem *item = sml_change_item_new(); sml_fail_unless(item != NULL, NULL); - sml_fail_unless(sml_change_item_set_remote(item, location, &error), "%s", error?error->message:"No GError set."); + sml_fail_unless(sml_change_item_set_location(item, location, &error), "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); g_object_unref(location); @@ -141,7 +52,7 @@ } END_TEST -START_TEST (change_item_set_remote_null) +START_TEST (change_item_set_location_null) { setup_testbed(NULL); @@ -150,14 +61,14 @@ SmlChangeItem *item = sml_change_item_new(); sml_fail_unless(item != NULL, NULL); - sml_fail_unless(sml_change_item_set_remote(item, NULL, &error), "%s", error?error->message:"No GError set."); + sml_fail_unless(sml_change_item_set_location(item, NULL, &error), "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); g_object_unref(item); } END_TEST -START_TEST (change_item_set_remote_missing_uri) +START_TEST (change_item_set_location_missing_uri) { setup_testbed(NULL); @@ -168,7 +79,7 @@ SmlChangeItem *item = sml_change_item_new(); sml_fail_unless(item != NULL, NULL); - sml_fail_unless(!sml_change_item_set_remote(item, location, &error), "The location must have an URI."); + sml_fail_unless(!sml_change_item_set_location(item, location, &error), "The location must have an URI."); sml_fail_unless(error != NULL, NULL); g_error_free(error); @@ -177,31 +88,30 @@ } END_TEST -START_TEST (change_item_get_remote) +START_TEST (change_item_get_location) { setup_testbed(NULL); GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); SmlChangeItem *item = sml_change_item_new(); sml_fail_unless(item != NULL, NULL); - sml_fail_unless(sml_change_item_get_remote(item) == NULL, "The remote location is not set until now."); + sml_fail_unless(sml_change_item_get_location(item) == NULL, "The location is not set until now."); - sml_fail_unless(sml_change_item_set_remote(item, location, &error), "%s", error?error->message:"No GError set."); + sml_fail_unless(sml_change_item_set_location(item, location, &error), "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_change_item_get_remote(item) != NULL, "The remote location must be set now."); - sml_fail_unless(sml_change_item_get_remote(item) == location, "The remote location must be 1234."); + sml_fail_unless(sml_change_item_get_location(item) != NULL, "The location must be set now."); + sml_fail_unless(sml_change_item_get_location(item) == location, "The location must be 1234."); - sml_fail_unless(sml_change_item_set_remote(item, NULL, &error), "%s", error?error->message:"No GError set."); + sml_fail_unless(sml_change_item_set_location(item, NULL, &error), "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_change_item_get_remote(item) == NULL, "The remote location was deleted."); + sml_fail_unless(sml_change_item_get_location(item) == NULL, "The location was deleted."); g_object_unref(location); g_object_unref(item); @@ -285,7 +195,7 @@ SmlChangeItem *item = sml_change_item_new(); sml_fail_unless(item != NULL, NULL); - sml_fail_unless(sml_change_item_set_local(item, NULL, &error), "%s", error?error->message:"No GError set."); + sml_fail_unless(sml_change_item_set_location(item, NULL, &error), "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); g_object_unref(item); @@ -389,8 +299,6 @@ { setup_testbed(NULL); - GError *error = NULL; - SmlChangeItem *item = sml_change_item_new(); sml_fail_unless(item != NULL, NULL); @@ -412,8 +320,6 @@ { setup_testbed(NULL); - GError *error = NULL; - SmlChangeItem *item = sml_change_item_new(); sml_fail_unless(item != NULL, NULL); @@ -545,8 +451,7 @@ SmlChangeItem *frag = sml_change_item_get_fragment(item, 0, 10, &error); sml_fail_unless(frag != NULL, "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_change_item_get_local(frag) == NULL, NULL); - sml_fail_unless(sml_change_item_get_remote(frag) == NULL, NULL); + sml_fail_unless(sml_change_item_get_location(frag) == NULL, NULL); sml_fail_unless(sml_change_item_get_content_type(frag) == NULL, NULL); sml_fail_unless(sml_change_item_get_missing_data(frag) == TRUE, NULL); /* only the first element contains the size */ @@ -560,12 +465,9 @@ SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); - sml_fail_unless(sml_change_item_set_local(item, location, &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_change_item_set_remote(item, location, &error), "%s", error?error->message:"No GError set."); + sml_fail_unless(sml_change_item_set_location(item, location, &error), "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); sml_fail_unless(sml_change_item_set_content_type(item, "text/plain", &error), "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); @@ -575,8 +477,7 @@ frag = sml_change_item_get_fragment(item, 10, 10, &error); sml_fail_unless(frag != NULL, "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_change_item_get_local(frag) == location, NULL); - sml_fail_unless(sml_change_item_get_remote(frag) == location, NULL); + sml_fail_unless(sml_change_item_get_location(frag) == location, NULL); sml_fail_unless(sml_change_item_get_content_type(frag) != NULL, NULL); sml_fail_unless(strcmp(sml_change_item_get_content_type(frag), "text/plain") == 0, NULL); sml_fail_unless(sml_change_item_get_missing_data(frag) == TRUE, NULL); @@ -590,8 +491,7 @@ frag = sml_change_item_get_fragment(item, 20, 16, &error); sml_fail_unless(frag != NULL, "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_change_item_get_local(frag) == location, NULL); - sml_fail_unless(sml_change_item_get_remote(frag) == location, NULL); + sml_fail_unless(sml_change_item_get_location(frag) == location, NULL); sml_fail_unless(sml_change_item_get_content_type(frag) != NULL, NULL); sml_fail_unless(strcmp(sml_change_item_get_content_type(frag), "text/plain") == 0, NULL); sml_fail_unless(sml_change_item_get_missing_data(frag) == FALSE, NULL); @@ -622,8 +522,7 @@ SmlChangeItem *frag = sml_change_item_get_fragment(item, 0, strlen(data)+1, &error); sml_fail_unless(frag != NULL, "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_change_item_get_local(frag) == NULL, NULL); - sml_fail_unless(sml_change_item_get_remote(frag) == NULL, NULL); + sml_fail_unless(sml_change_item_get_location(frag) == NULL, NULL); sml_fail_unless(sml_change_item_get_content_type(frag) == NULL, NULL); sml_fail_unless(sml_change_item_get_missing_data(frag) == FALSE, NULL); sml_fail_unless(sml_change_item_get_planned_size(frag) == 0, NULL); @@ -712,8 +611,7 @@ sml_fail_unless(strlen(sml_change_item_get_data(item)) == strlen(data1) + strlen(data2), NULL); sml_fail_unless(sml_change_item_get_missing_data(item) == TRUE, NULL); - sml_fail_unless(sml_change_item_get_local(item) == NULL, NULL); - sml_fail_unless(sml_change_item_get_remote(item) == NULL, NULL); + sml_fail_unless(sml_change_item_get_location(item) == NULL, NULL); sml_fail_unless(sml_change_item_get_content_type(item) == NULL, NULL); g_object_unref(frag); frag = NULL; @@ -722,12 +620,9 @@ SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); - sml_fail_unless(sml_change_item_set_local(item, location, &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_change_item_set_remote(item, location, &error), "%s", error?error->message:"No GError set."); + sml_fail_unless(sml_change_item_set_location(item, location, &error), "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); sml_fail_unless(sml_change_item_set_content_type(item, "text/plain", &error), "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); @@ -739,9 +634,7 @@ sml_fail_unless(sml_change_item_set_data(frag, data3, 0, &error), "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); sml_change_item_set_missing_data(frag, FALSE); - sml_fail_unless(sml_change_item_set_local(frag, location, &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_change_item_set_remote(frag, location, &error), "%s", error?error->message:"No GError set."); + sml_fail_unless(sml_change_item_set_location(frag, location, &error), "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); sml_fail_unless(sml_change_item_set_content_type(frag, "text/plain", &error), "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); @@ -751,8 +644,7 @@ sml_fail_unless(strlen(sml_change_item_get_data(item)) == strlen(data1) + strlen(data2) + strlen(data3), NULL); sml_fail_unless(sml_change_item_get_missing_data(item) == FALSE, NULL); - sml_fail_unless(sml_change_item_get_local(item) == location, NULL); - sml_fail_unless(sml_change_item_get_remote(item) == location, NULL); + sml_fail_unless(sml_change_item_get_location(item) == location, NULL); sml_fail_unless(strcmp(sml_change_item_get_content_type(item), "text/plain") == 0, NULL); g_object_unref(frag); frag = NULL; @@ -826,8 +718,7 @@ sml_fail_unless(strlen(sml_change_item_get_data(item)) == strlen(data1) + strlen(data2), NULL); sml_fail_unless(sml_change_item_get_missing_data(item) == FALSE, NULL); - sml_fail_unless(sml_change_item_get_local(item) == NULL, NULL); - sml_fail_unless(sml_change_item_get_remote(item) == NULL, NULL); + sml_fail_unless(sml_change_item_get_location(item) == NULL, NULL); sml_fail_unless(sml_change_item_get_content_type(item) == NULL, NULL); g_object_unref(frag); frag = NULL; Modified: trunk/tests/check_data_sync_api_map_item.c ============================================================================== --- trunk/tests/check_data_sync_api_map_item.c Fri Aug 7 19:56:42 2009 (r1247) +++ trunk/tests/check_data_sync_api_map_item.c Fri Aug 7 19:57:20 2009 (r1248) @@ -38,8 +38,7 @@ GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -76,10 +75,8 @@ GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_location_set_name(location, "my 1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); + sml_location_set_name(location, "my 1234"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -100,10 +97,8 @@ GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_location_set_parent_uri(location, "56", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); + sml_location_set_parent_uri(location, "56"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -144,8 +139,7 @@ GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -170,8 +164,7 @@ GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -208,10 +201,8 @@ GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_location_set_name(location, "my 1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); + sml_location_set_name(location, "my 1234"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -232,10 +223,8 @@ GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_location_set_parent_uri(location, "56", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); + sml_location_set_parent_uri(location, "56"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -276,8 +265,7 @@ GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -302,8 +290,7 @@ GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -329,8 +316,7 @@ GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -355,8 +341,7 @@ GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -381,12 +366,10 @@ GError *error = NULL; SmlLocation *local = sml_location_new(); sml_fail_unless(local != NULL, NULL); - sml_fail_unless(sml_location_set_uri(local, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(local, "1234"); SmlLocation *remote = sml_location_new(); sml_fail_unless(remote != NULL, NULL); - sml_fail_unless(sml_location_set_uri(remote, "5678", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(remote, "5678"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -401,7 +384,7 @@ sml_fail_unless(error == NULL, NULL); /* add name */ - sml_fail_unless(sml_location_set_name(local, "my 1234", &error), "%s", error?error->message:"No GError set."); + sml_location_set_name(local, "my 1234"); sml_fail_unless(!sml_map_item_is_compliant(item, NULL), "The item is not compliant."); sml_fail_unless(!sml_map_item_is_compliant(item, &error), "The item is not compliant."); @@ -421,12 +404,10 @@ GError *error = NULL; SmlLocation *local = sml_location_new(); sml_fail_unless(local != NULL, NULL); - sml_fail_unless(sml_location_set_uri(local, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(local, "1234"); SmlLocation *remote = sml_location_new(); sml_fail_unless(remote != NULL, NULL); - sml_fail_unless(sml_location_set_uri(remote, "5678", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(remote, "5678"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -441,7 +422,7 @@ sml_fail_unless(error == NULL, NULL); /* add parent */ - sml_fail_unless(sml_location_set_parent_uri(remote, "56", &error), "%s", error?error->message:"No GError set."); + sml_location_set_parent_uri(remote, "56"); sml_fail_unless(!sml_map_item_is_compliant(item, NULL), "The item is not compliant."); sml_fail_unless(!sml_map_item_is_compliant(item, &error), "The item is not compliant."); @@ -461,8 +442,7 @@ GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); Modified: trunk/tests/check_devinf.c ============================================================================== --- trunk/tests/check_devinf.c Fri Aug 7 19:56:42 2009 (r1247) +++ trunk/tests/check_devinf.c Fri Aug 7 19:57:20 2009 (r1248) @@ -23,7 +23,7 @@ #include <libsyncml/objects/sml_auth.h> #include <libsyncml/objects/sml_devinf_obj.h> -#include <libsyncml/data_sync_api/sml_location_internals.h> +#include <libsyncml/data_sync_api/sml_location.h> #include "libsyncml/parser/sml_xml_parse.h" #include <string.h> @@ -45,7 +45,7 @@ unsigned int defaultMaxMsgSize = 10240; unsigned int defaultMaxObjSize = 1024000; -static void _manager_event(SmlManager *manager, SmlManagerEventType type, SmlSession *session, GError *error, void *userdata) +static void _manager_event(SmlManager *manager, SmlManagerEventType type, SmlSession *session, const GError *error, void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p)", __func__, manager, type, session, error, userdata); managerTracker *tracker = userdata; @@ -123,9 +123,9 @@ sml_fail_unless(smlManagerStart(servermanager, &error), NULL); sml_fail_unless(error == NULL, NULL); - SmlLocation *loc = sml_location_new_with_options("test", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "test"); /* The authenticator */ SmlAuthenticator *auth2 = smlAuthNew(&error); @@ -252,13 +252,13 @@ sml_fail_unless(smlManagerStart(servermanager, &error), NULL); sml_fail_unless(error == NULL, NULL); - SmlLocation *loc = sml_location_new_with_options("test", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "test"); - SmlLocation *loc1 = sml_location_new_with_options("test", NULL, &gerror); + SmlLocation *loc1 = sml_location_new(); sml_fail_unless(loc1 != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc1, "test"); /* The devinf obj */ SmlDevInf *devinf = sml_dev_inf_new(); Modified: trunk/tests/check_ds.c ============================================================================== --- trunk/tests/check_ds.c Fri Aug 7 19:56:42 2009 (r1247) +++ trunk/tests/check_ds.c Fri Aug 7 19:57:20 2009 (r1248) @@ -28,7 +28,7 @@ #include <libsyncml/objects/sml_ds_server_internals.h> #include <libsyncml/sml_session_internals.h> #include <libsyncml/sml_elements_internals.h> -#include <libsyncml/data_sync_api/sml_location_internals.h> +#include <libsyncml/data_sync_api/sml_location.h> typedef struct SmlSessionThread { GMainContext *context; @@ -269,32 +269,28 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -static gboolean _recv_changes(SmlDsSession *dsession, SmlChangeType type, const char *uid, char *data, gsize size, const char *contenttype, void *userdata, GError **error) +static gboolean _recv_changes(SmlDsSession *dsession, SmlChangeItem *item, void *userdata, GError **error) { - smlTrace(TRACE_ENTRY, "%s(%p, %i, %s, %s, %i, %s, %p, %p)", __func__, dsession, type, VA_STRING(uid), VA_STRING(data), size, VA_STRING(contenttype), userdata, error); + smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, dsession, item, userdata, error); - if (type == SML_CHANGE_ADD) { + if (sml_change_item_get_action(item) == SML_CHANGE_ADD) { g_atomic_int_add(&adds_received, 1); - g_assert(!strcmp(uid, "uid")); - g_assert(!strncmp(data, "data", size)); - g_assert(size == 4); - } else if (type == SML_CHANGE_REPLACE) { + g_assert(!strcmp(sml_location_get_uri(sml_change_item_get_location(item)), "uid")); + g_assert(!strncmp(sml_change_item_get_data(item), "data", strlen(sml_change_item_get_data(item)))); + g_assert(strlen(sml_change_item_get_data(item)) == 4); + } else if (sml_change_item_get_action(item) == SML_CHANGE_REPLACE) { g_atomic_int_add(&modifies_received, 1); - g_assert(!strcmp(uid, "uid")); - g_assert(!strncmp(data, "newdata", size)); - g_assert(size == 7); - } else if (type == SML_CHANGE_DELETE) { + g_assert(!strcmp(sml_location_get_uri(sml_change_item_get_location(item)), "uid")); + g_assert(!strncmp(sml_change_item_get_data(item), "newdata", strlen(sml_change_item_get_data(item)))); + g_assert(strlen(sml_change_item_get_data(item)) == 7); + } else if (sml_change_item_get_action(item) == SML_CHANGE_DELETE) { g_atomic_int_add(&deletes_received, 1); - g_assert(!strcmp(uid, "uid")); - g_assert(!data); - g_assert(size == 0); + g_assert(!strcmp(sml_location_get_uri(sml_change_item_get_location(item)), "uid")); + g_assert(!sml_change_item_get_data(item)); } else { - sml_fail_unless(FALSE, "An unexpected SyncML change type %d was received.", type); + sml_fail_unless(FALSE, "An unexpected SyncML change type %d was received.", sml_change_item_get_action(item)); } - if (data) - smlSafeCFree(&data); - smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; } @@ -399,11 +395,10 @@ { setup_testbed(NULL); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "/vcards"); SmlDsServer *server = smlDsServerNew(SML_ELEMENT_TEXT_VCARD, loc, &error); sml_fail_unless(server != NULL, NULL); sml_fail_unless(error == NULL, NULL); @@ -418,11 +413,10 @@ { setup_testbed(NULL); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "/vcards"); SmlDsServer *server = smlDsClientNew(SML_ELEMENT_TEXT_VCARD, loc, loc, &error); sml_fail_unless(server != NULL, NULL); sml_fail_unless(error == NULL, NULL); @@ -522,11 +516,10 @@ /* General setup */ setup_testbed(NULL); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "/vcards"); SmlDsServer *client = smlDsClientNew(SML_ELEMENT_TEXT_VCARD, loc, loc, &error); _server_corr *client_corr = g_malloc0(sizeof(_server_corr)); @@ -634,12 +627,10 @@ /* General setup */ setup_testbed(NULL); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); - + sml_location_set_uri(loc, "/vcards"); SmlDsServer *client = smlDsClientNew(SML_ELEMENT_TEXT_VCARD, loc, loc, &error); _server_corr *client_corr = g_malloc0(sizeof(_server_corr)); @@ -760,11 +751,10 @@ /* General setup */ setup_testbed(NULL); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "/vcards"); SmlDsServer *client = smlDsClientNew(SML_ELEMENT_TEXT_VCARD, loc, loc, &error); @@ -909,11 +899,10 @@ /* General setup */ setup_testbed(NULL); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "/vcards"); SmlDsServer *client = smlDsClientNew(SML_ELEMENT_TEXT_VCARD, loc, loc, &error); @@ -1077,11 +1066,10 @@ /* General setup */ setup_testbed(NULL); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "/vcards"); SmlDsServer *client = smlDsClientNew(SML_ELEMENT_TEXT_VCARD, loc, loc, &error); @@ -1138,8 +1126,6 @@ smlDsSessionGetAlert(client_corr->dsession, _recv_alert, GINT_TO_POINTER(1)); - - while (alerts_received != 2) { smlDsSessionDispatch(client_corr->dsession); usleep(500); @@ -1147,7 +1133,9 @@ smlDsSessionSendSync(client_corr->dsession, 0, _sync_reply, GINT_TO_POINTER(1), &error); - sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); smlDsSessionCloseSync(client_corr->dsession, &error); @@ -1257,11 +1245,10 @@ /* General setup */ setup_testbed(NULL); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "/vcards"); SmlDsServer *client = smlDsClientNew(SML_ELEMENT_TEXT_VCARD, loc, loc, &error); @@ -1327,7 +1314,9 @@ smlDsSessionSendSync(client_corr->dsession, 1, _sync_reply, GINT_TO_POINTER(1), &error); - sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); smlDsSessionCloseSync(client_corr->dsession, &error); @@ -1350,7 +1339,9 @@ smlDsSessionSendSync(server_corr->dsession, 1, _sync_reply, GINT_TO_POINTER(1), &error); - sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); smlDsSessionCloseSync(server_corr->dsession, &error); @@ -1371,11 +1362,15 @@ } SmlMapItem *item = sml_map_item_new(); - SmlLocation *local = sml_location_new_with_options("uid", NULL, &error); + SmlLocation *local = sml_location_new(); + sml_fail_unless(local != NULL, NULL); + sml_location_set_uri(local, "uid"); sml_map_item_set_local(item, local, &error); g_object_unref(local); local = NULL; - SmlLocation *remote = sml_location_new_with_options("newuid", NULL, &error); + SmlLocation *remote = sml_location_new(); + sml_fail_unless(remote != NULL, NULL); + sml_location_set_uri(remote, "newuid"); sml_map_item_set_remote(item, remote, &error); g_object_unref(remote); remote = NULL; @@ -1463,11 +1458,10 @@ /* General setup */ setup_testbed(NULL); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "/vcards"); SmlDsServer *client = smlDsClientNew(SML_ELEMENT_TEXT_VCARD, loc, loc, &error); @@ -1533,7 +1527,9 @@ smlDsSessionSendSync(client_corr->dsession, 1, _sync_reply, GINT_TO_POINTER(1), &error); - sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, SML_CHANGE_DELETE, "uid", NULL, 0, SML_ELEMENT_TEXT_VCARD, _delete_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_DELETE, "uid", NULL, 0, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, TEST_CHANGE_ITEM, _delete_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); smlDsSessionCloseSync(client_corr->dsession, &error); @@ -1556,7 +1552,9 @@ smlDsSessionSendSync(server_corr->dsession, 1, _sync_reply, GINT_TO_POINTER(1), &error); - sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, SML_CHANGE_DELETE, "uid", NULL, 0, SML_ELEMENT_TEXT_VCARD, _delete_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_DELETE, "uid", NULL, 0, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, TEST_CHANGE_ITEM, _delete_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); smlDsSessionCloseSync(server_corr->dsession, &error); @@ -1649,11 +1647,10 @@ /* General setup */ setup_testbed(NULL); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "/vcards"); SmlDsServer *client = smlDsClientNew(SML_ELEMENT_TEXT_VCARD, loc, loc, &error); @@ -1719,13 +1716,19 @@ smlDsSessionSendSync(client_corr->dsession, 0, _sync_reply, GINT_TO_POINTER(1), &error); - sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, SML_CHANGE_REPLACE, "uid", "newdata", 7, SML_ELEMENT_TEXT_VCARD, _modify_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_REPLACE, "uid", "newdata", 7, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, TEST_CHANGE_ITEM, _modify_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, SML_CHANGE_DELETE, "uid", NULL, 0, SML_ELEMENT_TEXT_VCARD, _delete_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_DELETE, "uid", NULL, 0, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, TEST_CHANGE_ITEM, _delete_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); smlDsSessionCloseSync(client_corr->dsession, &error); @@ -1748,13 +1751,19 @@ smlDsSessionSendSync(server_corr->dsession, 0, _sync_reply, GINT_TO_POINTER(1), &error); - sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, SML_CHANGE_REPLACE, "uid", "newdata", 7, SML_ELEMENT_TEXT_VCARD, _modify_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_REPLACE, "uid", "newdata", 7, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, TEST_CHANGE_ITEM, _modify_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, SML_CHANGE_DELETE, "uid", NULL, 0, SML_ELEMENT_TEXT_VCARD, _delete_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_DELETE, "uid", NULL, 0, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, TEST_CHANGE_ITEM, _delete_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); smlDsSessionCloseSync(server_corr->dsession, &error); @@ -1775,11 +1784,15 @@ } SmlMapItem *item = sml_map_item_new(); - SmlLocation *local = sml_location_new_with_options("uid", NULL, &error); + SmlLocation *local = sml_location_new(); + sml_fail_unless(local != NULL, NULL); + sml_location_set_uri(local, "uid"); sml_map_item_set_local(item, local, &error); g_object_unref(local); local = NULL; - SmlLocation *remote = sml_location_new_with_options("newuid", NULL, &error); + SmlLocation *remote = sml_location_new(); + sml_fail_unless(remote != NULL, NULL); + sml_location_set_uri(remote, "newuid"); sml_map_item_set_remote(item, remote, &error); g_object_unref(remote); remote = NULL; @@ -1869,11 +1882,10 @@ /* General setup */ setup_testbed(NULL); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "/vcards"); SmlDsServer *client = smlDsClientNew(SML_ELEMENT_TEXT_VCARD, loc, loc, &error); @@ -1938,7 +1950,9 @@ int i = 0; for (i = 0; i < num; i++) { - sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); } @@ -1963,7 +1977,9 @@ smlDsSessionSendSync(server_corr->dsession, 0, _sync_reply, GINT_TO_POINTER(1), &error); for (i = 0; i < num; i++) { - sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); } @@ -1986,11 +2002,15 @@ for (i = 0; i < num; i++) { SmlMapItem *item = sml_map_item_new(); - SmlLocation *local = sml_location_new_with_options("uid", NULL, &error); + SmlLocation *local = sml_location_new(); + sml_fail_unless(local != NULL, NULL); + sml_location_set_uri(local, "uid"); sml_map_item_set_local(item, local, &error); g_object_unref(local); local = NULL; - SmlLocation *remote = sml_location_new_with_options("newuid", NULL, &error); + SmlLocation *remote = sml_location_new(); + sml_fail_unless(remote != NULL, NULL); + sml_location_set_uri(remote, "newuid"); sml_map_item_set_remote(item, remote, &error); g_object_unref(remote); remote = NULL; @@ -2082,11 +2102,10 @@ /* General setup */ setup_testbed(NULL); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "/vcards"); SmlDsServer *client = smlDsClientNew(SML_ELEMENT_TEXT_VCARD, loc, loc, &error); @@ -2151,7 +2170,9 @@ int i = 0; for (i = 0; i < num; i++) { - sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); } @@ -2173,7 +2194,9 @@ smlDsSessionSendSync(server_corr->dsession, 0, _sync_reply, GINT_TO_POINTER(1), &error); for (i = 0; i < num; i++) { - sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); } @@ -2193,11 +2216,15 @@ for (i = 0; i < num; i++) { SmlMapItem *item = sml_map_item_new(); - SmlLocation *local = sml_location_new_with_options("uid", NULL, &error); + SmlLocation *local = sml_location_new(); + sml_fail_unless(local != NULL, NULL); + sml_location_set_uri(local, "uid"); sml_map_item_set_local(item, local, &error); g_object_unref(local); local = NULL; - SmlLocation *remote = sml_location_new_with_options("newuid", NULL, &error); + SmlLocation *remote = sml_location_new(); + sml_fail_unless(remote != NULL, NULL); + sml_location_set_uri(remote, "newuid"); sml_map_item_set_remote(item, remote, &error); g_object_unref(remote); remote = NULL; @@ -2396,21 +2423,27 @@ smlDsSessionSendSync(client_corr1->dsession, 0, _sync_reply, GINT_TO_POINTER(1), &error); int i = 0; for (i = 0; i < num; i++) { - sml_fail_unless(smlDsSessionQueueChange(client_corr1->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(client_corr1->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); } smlDsSessionCloseSync(client_corr1->dsession, &error); smlDsSessionSendSync(client_corr2->dsession, 0, _sync_reply, GINT_TO_POINTER(1), &error); for (i = 0; i < num; i++) { - sml_fail_unless(smlDsSessionQueueChange(client_corr2->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(client_corr2->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); } smlDsSessionCloseSync(client_corr2->dsession, &error); smlDsSessionSendSync(client_corr3->dsession, 0, _sync_reply, GINT_TO_POINTER(1), &error); for (i = 0; i < num; i++) { - sml_fail_unless(smlDsSessionQueueChange(client_corr3->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(client_corr3->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); } smlDsSessionCloseSync(client_corr3->dsession, &error); @@ -2438,21 +2471,27 @@ smlDsSessionSendSync(server_corr1->dsession, 0, _sync_reply, GINT_TO_POINTER(1), &error); for (i = 0; i < num; i++) { - sml_fail_unless(smlDsSessionQueueChange(server_corr1->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(server_corr1->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); } smlDsSessionCloseSync(server_corr1->dsession, &error); smlDsSessionSendSync(server_corr2->dsession, 0, _sync_reply, GINT_TO_POINTER(1), &error); for (i = 0; i < num; i++) { - sml_fail_unless(smlDsSessionQueueChange(server_corr2->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(server_corr2->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); } smlDsSessionCloseSync(server_corr2->dsession, &error); smlDsSessionSendSync(server_corr3->dsession, 0, _sync_reply, GINT_TO_POINTER(1), &error); for (i = 0; i < num; i++) { - sml_fail_unless(smlDsSessionQueueChange(server_corr3->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(server_corr3->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); } smlDsSessionCloseSync(server_corr3->dsession, &error); Modified: trunk/tests/check_manager.c ============================================================================== --- trunk/tests/check_manager.c Fri Aug 7 19:56:42 2009 (r1247) +++ trunk/tests/check_manager.c Fri Aug 7 19:57:20 2009 (r1248) @@ -22,7 +22,7 @@ #include "tests/support.h" #include <libsyncml/sml_session_internals.h> -#include <libsyncml/data_sync_api/sml_location_internals.h> +#include <libsyncml/data_sync_api/sml_location.h> #include <libsyncml/sml_error_internals.h> #define NUM_SESSIONS 30 @@ -108,7 +108,7 @@ setup_testbed(NULL); } -static void _manager_event(SmlManager *manager, SmlManagerEventType type, SmlSession *session, GError *error, void *userdata) +static void _manager_event(SmlManager *manager, SmlManagerEventType type, SmlSession *session, const GError *error, void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p)", __func__, manager, type, session, error, userdata); managerTracker *tracker = userdata; @@ -510,7 +510,6 @@ { reset_testbed(); - GError *gerror = NULL; GError *error = NULL; SmlTransport *server = smlTransportNew(SML_TRANSPORT_HTTP_SERVER, &error); SmlTransport *client = smlTransportNew(SML_TRANSPORT_HTTP_CLIENT, &error); @@ -536,9 +535,9 @@ sml_fail_unless(smlManagerStart(servermanager, &error), NULL); sml_fail_unless(error == NULL, NULL); - SmlLocation *loc = sml_location_new_with_options("test", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "test"); sml_fail_unless(smlManagerObjectRegister(servermanager, SML_COMMAND_TYPE_ALERT, NULL, loc, NULL, NULL, _recv_alert, NULL, NULL, &error), NULL); sml_fail_unless(error == NULL, NULL); @@ -630,9 +629,10 @@ { reset_testbed(); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("test", NULL, &gerror); + SmlLocation *loc = sml_location_new(); + sml_fail_unless(loc != NULL, NULL); + sml_location_set_uri(loc, "test"); SmlTransport *server = smlTransportNew(SML_TRANSPORT_HTTP_SERVER, &error); SmlTransport *client = smlTransportNew(SML_TRANSPORT_HTTP_CLIENT, &error); Modified: trunk/tests/check_session.c ============================================================================== --- trunk/tests/check_session.c Fri Aug 7 19:56:42 2009 (r1247) +++ trunk/tests/check_session.c Fri Aug 7 19:57:20 2009 (r1248) @@ -1,7 +1,7 @@ /* * libsyncml - A syncml protocol implementation * Copyright (C) 2005 Armin Bauer <arm...@op...> - * Copyright (C) 2008 Michael Bell <mic...@op...> + * Copyright (C) 2008-2009 Michael Bell <mic...@op...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -26,7 +26,7 @@ #include <libsyncml/sml_command_internals.h> #include <libsyncml/sml_transport_internals.h> #include <libsyncml/objects/sml_auth.c> -#include <libsyncml/data_sync_api/sml_location_internals.h> +#include <libsyncml/data_sync_api/sml_location.h> #include <libsyncml/sml_notification.h> @@ -320,9 +320,9 @@ GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/test", NULL, &error); + SmlLocation *loc = sml_location_new(); + sml_location_set_uri(loc, "/test"); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(error == NULL, NULL); SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); sml_fail_unless(session != NULL, NULL); @@ -341,9 +341,9 @@ GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/test", NULL, &error); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(loc, "/test"); SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); @@ -385,51 +385,42 @@ g_atomic_int_inc(¤t_cmd_id); if (GPOINTER_TO_INT(userdata) == 3 && command->type == SML_COMMAND_TYPE_ADD) { - smlAssert(command->private.change.items); - smlAssert(g_list_length(command->private.change.items)); - SmlItem *item = g_list_nth_data(command->private.change.items, 0); + smlAssert(smlCommandGetNumChanges(command)); + SmlChangeItem *item = smlCommandGetNthChange(command, 0); smlAssert(item); - smlAssert(smlItemCheck(item)); + //smlAssert(smlItemCheck(item)); - char *data = NULL; - gsize size = 0; - smlAssert(smlItemGetData(item, &data, &size, &locerror)); + const char *data = sml_change_item_get_data(item); - smlAssert(size == 8); + smlAssert(strlen(data) == 8); smlAssert(!strncmp(data, "datadata", 8)); } if (GPOINTER_TO_INT(userdata) == 4 && command->type == SML_COMMAND_TYPE_ADD) { - smlAssert(command->private.change.items); - smlAssert(g_list_length(command->private.change.items)); - SmlItem *item = g_list_nth_data(command->private.change.items, 0); + smlAssert(smlCommandGetNumChanges(command)); + SmlChangeItem *item = smlCommandGetNthChange(command, 0); smlAssert(item); - smlAssert(smlItemCheck(item)); + //smlAssert(smlItemCheck(item)); - char *data = NULL; - gsize size = 0; - smlAssert(smlItemGetData(item, &data, &size, &locerror)); + const char *data = sml_change_item_get_data(item); - smlAssert(size == 20); + smlAssert(strlen(data) == 20); smlAssert(!strncmp(data, "datadatadatadatatest", 20)); } if (GPOINTER_TO_INT(userdata) == 5 && command->type == SML_COMMAND_TYPE_ADD) { - smlAssert(command->private.change.items); - smlAssert(g_list_length(command->private.change.items)); - SmlItem *item = g_list_nth_data(command->private.change.items, 0); + smlAssert(smlCommandGetNumChanges(command)); + SmlChangeItem *item = smlCommandGetNthChange(command, 0); smlAssert(item); - smlAssert(smlItemCheck(item)); + //smlAssert(smlItemCheck(item)); - char *data = NULL; - gsize size = 0; - smlAssert(smlItemGetData(item, &data, &size, &locerror)); + const char *data = sml_change_item_get_data(item); - if (size != 4) { - smlAssert(size == item_size); + if (strlen(data) != 4) { + smlAssert(strlen(data) == item_size); smlAssert(!strncmp(data, item_data, item_size)); } else { - smlAssert(size == 4); + smlAssert(strlen(data) == 4); smlAssert(!strncmp(data, "data", 4)); } } @@ -535,9 +526,9 @@ GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/test", NULL, &error); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(loc, "/test"); SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session, &to_session); @@ -576,9 +567,9 @@ GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/test", NULL, &error); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(loc, "/test"); SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session, &to_session); @@ -618,9 +609,9 @@ GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/test", NULL, &error); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(loc, "/test"); const char *input = "<SyncML xmlns=\"SYNCML:SYNCML1.2\"><SyncHdr><VerProto>SyncML/1.1</VerProto><VerDTD>1.2</VerDTD><MsgID>1</MsgID><SessionID>1</SessionID><Target><LocURI>/test</LocURI></Target><Source><LocURI>/test</LocURI></Source></SyncHdr><SyncBody><Alert><CmdID>1</CmdID><Item><Target><LocURI>/test</LocURI></Target><Source><LocURI>/test</LocURI></Source><Meta><Anchor xmlns=\"syncml:metinf\"><Next>last</Next><Last>next</Last></Anchor></Meta></Item><Data>200</Data></Alert><Final></Final></SyncBody></SyncML>"; @@ -671,9 +662,9 @@ GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/test", NULL, &error); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(loc, "/test"); SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session, &to_session); @@ -751,9 +742,9 @@ GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/test", NULL, &error); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(loc, "/test"); SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session, &to_session); @@ -829,9 +820,9 @@ GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/test", NULL, &error); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(loc, "/test"); SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session, &to_session); @@ -926,9 +917,9 @@ GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/test", NULL, &error); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(loc, "/test"); SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session,... [truncated message content] |
From: <svn...@op...> - 2009-08-07 17:56:54
|
Author: bellmich Date: Fri Aug 7 19:56:42 2009 New Revision: 1247 URL: http://libsyncml.opensync.org/changeset/1247 Log: added forgotten C file of data sync enum types Modified: trunk/libsyncml/CMakeLists.txt Modified: trunk/libsyncml/CMakeLists.txt ============================================================================== --- trunk/libsyncml/CMakeLists.txt Fri Aug 7 19:55:39 2009 (r1246) +++ trunk/libsyncml/CMakeLists.txt Fri Aug 7 19:56:42 2009 (r1247) @@ -26,6 +26,7 @@ data_sync_api/sml_location.c data_sync_api/sml_change_item.c data_sync_api/sml_map_item.c + data_sync_api/sml_data_sync_enum_types.c data_sync_api/transport_http_client.c data_sync_api/transport_http_server.c data_sync_api/transport_obex_client.c |
From: <svn...@op...> - 2009-08-07 17:55:50
|
Author: bellmich Date: Fri Aug 7 19:55:39 2009 New Revision: 1246 URL: http://libsyncml.opensync.org/changeset/1246 Log: added forgotten enum types Modified: trunk/libsyncml/CMakeLists.txt Modified: trunk/libsyncml/CMakeLists.txt ============================================================================== --- trunk/libsyncml/CMakeLists.txt Fri Aug 7 19:54:58 2009 (r1245) +++ trunk/libsyncml/CMakeLists.txt Fri Aug 7 19:55:39 2009 (r1246) @@ -79,6 +79,7 @@ ## install header files of data sync API INSTALL( FILES + data_sync_api/sml_data_sync_enum_types.h data_sync_api/sml_location.h data_sync_api/sml_change_item.h data_sync_api/sml_map_item.h |
From: <svn...@op...> - 2009-08-07 17:55:11
|
Author: bellmich Date: Fri Aug 7 19:54:58 2009 New Revision: 1245 URL: http://libsyncml.opensync.org/changeset/1245 Log: - adapted to reduced SmlLocation API - integrated SmlChangeItem API - disabled find function of write context because the function is never used Modified: trunk/libsyncml/objects/sml_ds_server.c trunk/libsyncml/objects/sml_ds_server.h trunk/libsyncml/objects/sml_ds_server_internals.h Modified: trunk/libsyncml/objects/sml_ds_server.c ============================================================================== --- trunk/libsyncml/objects/sml_ds_server.c Fri Aug 7 19:53:35 2009 (r1244) +++ trunk/libsyncml/objects/sml_ds_server.c Fri Aug 7 19:54:58 2009 (r1245) @@ -29,6 +29,7 @@ #include <libsyncml/sml_command.h> #include <libsyncml/sml_elements.h> +/* static SmlWriteContext *_write_context_find(SmlDsSession *dsession, const gchar *uid, SmlChangeType type) { smlTrace(TRACE_ENTRY, "%s(%p, %s, %i)", __func__, dsession, VA_STRING(uid), type); @@ -37,7 +38,10 @@ GList *c = NULL; for (c = dsession->pendingChanges; c; c = c->next) { SmlWriteContext *ctx = c->data; - if (!strcmp(uid, ctx->uid) && ctx->type == type) { + SmlLocation *loc = sml_change_item_get_location(ctx->item); + const char *uri = sml_location_get_full_uri(loc); + if (!strcmp(uid, uri) && + sml_change_item_get_action(ctx->item) == type) { g_mutex_unlock(dsession->pendingChangesLock); smlTrace(TRACE_EXIT, "%s: %p", __func__, ctx); return ctx; @@ -48,6 +52,7 @@ smlTrace(TRACE_EXIT_ERROR, "%s: Not found", __func__); return NULL; } +*/ static void _write_context_free(SmlWriteContext *ctx) { @@ -56,8 +61,8 @@ if (ctx->status) smlStatusUnref(ctx->status); - if (ctx->uid) - smlSafeCFree(&(ctx->uid)); + if (ctx->item) + g_object_unref(ctx->item); smlSafeFree((gpointer *)&ctx); @@ -73,8 +78,6 @@ return; } - smlTrace(TRACE_INTERNAL, "%s: Dispatching: uid %s, Type %i, result %i", __func__, VA_STRING(ctx->uid), ctx->type, smlStatusGetCode(ctx->status)); - ctx->callback(dsession, ctx->status, ctx->userdata); g_mutex_lock(dsession->pendingChangesLock); @@ -609,33 +612,17 @@ gsize i; for (i=0; i < smlCommandGetNumChanges(cmd); i++) { - SmlItem *item = smlCommandGetNthChange(cmd, i); + SmlChangeItem *item = smlCommandGetNthChange(cmd, i); if (!item) { g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Item %i of the command's item list is NULL.", i); goto error; } - /* We'd rather use the target of the change since it already the mapped - * uid (if we are a client for example). If it is not given we use the - * source uri. This has then to be translated by the sync engine of course */ - if ((!smlItemGetSource(item) && !smlItemGetTarget(item))) { - g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, - "Cannot determine UID because source an target are missing on item %i.", i); - goto error; - } - - char *data = NULL; - gsize size = 0; - if (!smlItemStealData(item, &data, &size, &error)) - goto error; - if (!dsession->recvChangeCallback(dsession, - smlCommandGetChangeType(cmd), - smlItemGetTarget(item) ? sml_location_get_uri(smlItemGetTarget(item)) : sml_location_get_uri(smlItemGetSource(item)), - data, size, - smlItemGetContentType(item), - dsession->recvChangeCallbackUserdata, &error)) + item, + dsession->recvChangeCallbackUserdata, + &error)) goto error; } @@ -658,17 +645,17 @@ dsession->recvChanges = g_list_delete_link(dsession->recvChanges, dsession->recvChanges); } - /* unlock the final event at the manager - * - * If this is called from a test case then the datastore - * is sometimes not registered at a SmlManager. - */ - if (dsession->server->manager) - { - dsession->finalLock = FALSE; - smlManagerSessionFinalLockUnref(dsession->server->manager, dsession->session); - } - else + /* unlock the final event at the manager + * + * If this is called from a test case then the datastore + * is sometimes not registered at a SmlManager. + */ + if (dsession->server->manager) + { + dsession->finalLock = FALSE; + smlManagerSessionFinalLockUnref(dsession->server->manager, dsession->session); + } + else smlTrace(TRACE_INTERNAL, "%s - no manager so should be a test", __func__); } else if (dsession->recvMap && dsession->recvMappingCallback) { while (dsession->recvMap) { @@ -904,7 +891,6 @@ { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, cmd, userdata); SmlDsSession *dsession = userdata; - GError *error = NULL; g_mutex_lock(dsession->lock); @@ -915,11 +901,6 @@ smlTrace(TRACE_EXIT, "%s", __func__); return; -error: - g_mutex_unlock(dsession->lock); - smlSessionDispatchEvent(session, SML_SESSION_EVENT_ERROR, NULL, NULL, NULL, error); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, error->message); - g_error_free(error); } /** @brief Gets a already received alert @@ -1093,16 +1074,12 @@ //Send a change to the remote side gboolean smlDsSessionQueueChange (SmlDsSession *dsession, - SmlChangeType type, - const gchar *uid, - const gchar *data, - gsize size, - const gchar *contenttype, + SmlChangeItem *item, SmlDsSessionChangeStatusCb callback, void *userdata, GError **error) { - smlTrace(TRACE_ENTRY, "%s(%p, %i, %s, %p, %i, %s, %p, %p, %p)", __func__, dsession, type, VA_STRING(uid), data, size, VA_STRING(contenttype), callback, userdata, error); + smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %p)", __func__, dsession, item, callback, userdata, error); smlAssert(dsession); CHECK_ERROR_REF @@ -1115,7 +1092,7 @@ goto error; } - cmd = smlCommandNewChange(type, uid, data, size, contenttype, error); + cmd = smlCommandNewChange(item, error); if (!cmd) goto error; @@ -1125,8 +1102,8 @@ ctx->callback = callback; ctx->userdata = userdata; - ctx->uid = g_strdup(uid); - ctx->type = type; + ctx->item = item; + g_object_ref(item); ctx->session = dsession; g_mutex_lock(dsession->pendingChangesLock); @@ -1143,7 +1120,7 @@ return TRUE; error: if (ctx) { - smlSafeCFree(&(ctx->uid)); + g_object_unref(ctx->item); smlSafeFree((gpointer *)&ctx); } if (cmd) @@ -1199,9 +1176,6 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; -error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); - return FALSE; } /** @brief Closes the map command Modified: trunk/libsyncml/objects/sml_ds_server.h ============================================================================== --- trunk/libsyncml/objects/sml_ds_server.h Fri Aug 7 19:53:35 2009 (r1244) +++ trunk/libsyncml/objects/sml_ds_server.h Fri Aug 7 19:54:58 2009 (r1245) @@ -36,11 +36,12 @@ typedef struct SmlDsServer SmlDsServer; typedef struct SmlDsSession SmlDsSession; -typedef void (* SmlDsSessionConnectCb) (SmlDsSession *dsession, void *userdata); -typedef gboolean (* SmlDsSessionAlertCb) (SmlDsSession *dsession, SmlAlertType type, const gchar *last, const gchar *next, void *userdata); -typedef void (* SmlDsSessionSyncCb) (SmlDsSession *dsession, gsize numchanges, void *userdata); -typedef gboolean (* SmlDsSessionChangeCb) (SmlDsSession *dsession, SmlChangeType type, const gchar *uid, gchar *data, gsize size, const gchar *contenttype, void *userdata, GError **error); -typedef void (* SmlDsSessionChangeStatusCb) (SmlDsSession *dsession, SmlStatus *status, void *userdata); +typedef void (* SmlDsSessionConnectCb) (SmlDsSession *dsession, void *userdata); +typedef gboolean (* SmlDsSessionAlertCb) (SmlDsSession *dsession, SmlAlertType type, const gchar *last, const gchar *next, void *userdata); +typedef void (* SmlDsSessionSyncCb) (SmlDsSession *dsession, gsize numchanges, void *userdata); +typedef gboolean (* SmlDsSessionChangeCb) (SmlDsSession *dsession, SmlChangeItem *item, void *userdata, GError **error); +typedef void (* SmlDsSessionChangeStatusCb) (SmlDsSession *dsession, SmlStatus *status, void *userdata); +typedef void (* SmlDsSessionMapCb) (SmlDsSession *dsession, SmlMapItem *item, void *userdata); SmlDsServer* smlDsServerNew (const gchar *type, SmlLocation *location, GError **error); SmlDsServer* smlDsClientNew (const gchar *type, SmlLocation *location, SmlLocation *target, GError **error); @@ -64,8 +65,9 @@ void smlDsSessionGetChanges (SmlDsSession *dsession, SmlDsSessionChangeCb chgCallback, void *userdata); void smlDsSessionGetSync (SmlDsSession *dsession, SmlDsSessionSyncCb chgCallback, void *userdata); gboolean smlDsSessionSendSync (SmlDsSession *dsession, gsize num_changes, SmlStatusReplyCb callback, void *userdata, GError **error); -gboolean smlDsSessionQueueChange (SmlDsSession *dsession, SmlChangeType type, const gchar *uid, const gchar *data, gsize size, const gchar *contenttype, SmlDsSessionChangeStatusCb callback, void *userdata, GError **error); +gboolean smlDsSessionQueueChange (SmlDsSession *dsession, SmlChangeItem *item, SmlDsSessionChangeStatusCb callback, void *userdata, GError **error); gboolean smlDsSessionCloseSync (SmlDsSession *dsession, GError **error); +void smlDsSessionGetMapping (SmlDsSession *dsession, SmlDsSessionMapCb mapCallback, void *userdata); gboolean smlDsSessionQueueMap (SmlDsSession *dsession, SmlMapItem *item, GError **error); gboolean smlDsSessionCloseMap (SmlDsSession *dsession, SmlStatusReplyCb callback, void *userdata, GError **error); const gchar* smlDsSessionGetLocation (SmlDsSession *dsession); Modified: trunk/libsyncml/objects/sml_ds_server_internals.h ============================================================================== --- trunk/libsyncml/objects/sml_ds_server_internals.h Fri Aug 7 19:53:35 2009 (r1244) +++ trunk/libsyncml/objects/sml_ds_server_internals.h Fri Aug 7 19:54:58 2009 (r1245) @@ -32,14 +32,11 @@ #include "sml_ds_server.h" -typedef void (* SmlDsSessionMapCb) (SmlDsSession *dsession, SmlMapItem *item, void *userdata); - typedef struct SmlWriteContext { SmlDsSessionChangeStatusCb callback; - gchar *uid; + SmlChangeItem *item; SmlStatus *status; void *userdata; - SmlChangeType type; SmlDsSession *session; } SmlWriteContext; @@ -121,7 +118,5 @@ SmlDsSession* smlDsSessionNew (SmlDsServer *server, SmlSession *session, GError **error); void smlDsSessionFree (SmlDsSession *dsession); -void smlDsSessionGetMapping (SmlDsSession *dsession, SmlDsSessionMapCb mapCallback, void *userdata); - #endif //_SML_DS_SERVER_INTERNALS_H_ /*@}*/ |