From: <svn...@op...> - 2009-08-07 17:41:03
|
Author: bellmich Date: Fri Aug 7 19:40:49 2009 New Revision: 1234 URL: http://libsyncml.opensync.org/changeset/1234 Log: - updated to reduced SmlLocation API - removed disabled changes feature (replaced with easier direct space calculation) Modified: trunk/libsyncml/sml_elements.c trunk/libsyncml/sml_elements.h trunk/libsyncml/sml_elements_internals.h trunk/libsyncml/sml_parse.c Modified: trunk/libsyncml/sml_elements.c ============================================================================== --- trunk/libsyncml/sml_elements.c Fri Aug 7 19:38:36 2009 (r1233) +++ trunk/libsyncml/sml_elements.c Fri Aug 7 19:40:49 2009 (r1234) @@ -26,7 +26,7 @@ #include "sml_parse.h" #include "sml_command.h" -#include "data_sync_api/sml_location_internals.h" +#include "data_sync_api/sml_location.h" SmlAnchor* smlAnchorNew (const gchar *last, @@ -370,13 +370,6 @@ } void -smlItemSetDisable (SmlItem *item, - gboolean disable) -{ - item->disabled = disable; -} - -void smlItemSetSource (SmlItem *item, SmlLocation *source) { Modified: trunk/libsyncml/sml_elements.h ============================================================================== --- trunk/libsyncml/sml_elements.h Fri Aug 7 19:38:36 2009 (r1233) +++ trunk/libsyncml/sml_elements.h Fri Aug 7 19:40:49 2009 (r1234) @@ -67,7 +67,6 @@ gsize smlItemGetSize (SmlItem *item); const char* smlItemGetContent (SmlItem *item); gboolean smlItemStealData (SmlItem *item, gchar **data, gsize *size, GError **error); -void smlItemSetDisable (SmlItem *item, gboolean disable); void smlItemSetMoreData (SmlItem *item, gboolean enable); gboolean smlItemGetMoreData (SmlItem *item); Modified: trunk/libsyncml/sml_elements_internals.h ============================================================================== --- trunk/libsyncml/sml_elements_internals.h Fri Aug 7 19:38:36 2009 (r1233) +++ trunk/libsyncml/sml_elements_internals.h Fri Aug 7 19:40:49 2009 (r1234) @@ -52,7 +52,6 @@ gchar *contenttype; gboolean moreData; - gboolean disabled; /** If set to true, libsyncml will omit the cdata tags */ gboolean raw; }; Modified: trunk/libsyncml/sml_parse.c ============================================================================== --- trunk/libsyncml/sml_parse.c Fri Aug 7 19:38:36 2009 (r1233) +++ trunk/libsyncml/sml_parse.c Fri Aug 7 19:40:49 2009 (r1234) @@ -30,7 +30,7 @@ #include "sml_elements.h" #include "sml_notification.h" -#include "data_sync_api/sml_location_internals.h" +#include "data_sync_api/sml_location.h" #include "parser/sml_xml_assm.h" #include "parser/sml_xml_parse.h" @@ -171,9 +171,8 @@ smlNotificationSetManager(san, parser->manager); smlNotificationSetMimeType(san, SML_MIMETYPE_XML); smlNotificationSetSessionType(san, SML_SESSION_TYPE_CLIENT); - SmlLocation *target = sml_location_new_with_options("/", NULL, error); - if (!target) - goto error; + SmlLocation *target = sml_location_new(); + sml_location_set_uri(target, "/"); smlNotificationSetTarget(san, target); g_object_unref(target); target = NULL; @@ -596,6 +595,11 @@ smlAssert(assm->functions.start_cmd); smlAssert(assm->functions.rem_cmd); smlAssert(smlCommandGetType(cmd) == SML_COMMAND_TYPE_ADD || smlCommandGetType(cmd) == SML_COMMAND_TYPE_REPLACE); + /* only one change per command is supported by libsyncml + * It is possible to parse commands with more items + * but it is not supported to send more items than one + */ + smlAssert(smlCommandGetNumChanges(cmd) == 1); unsigned int parentID = 0; gsize limit = smlAssemblerGetRemoteMaxMsgSize(assm); @@ -614,10 +618,6 @@ parentID = smlCommandGetID(parent); } - /* disable the items */ - smlCommandDisableChanges(cmd); - - gboolean noCmdID = FALSE; if (!smlCommandGetID(cmd)) { noCmdID = TRUE; @@ -635,6 +635,12 @@ int size = 0; if (!(size = smlAssemblerCheckSize(assm, FALSE, error))) goto error_remove; + + /* Now calculate the size without the data of the item. + * The data can be splitted into several chunks. + * Please see SupportLargeObj and MoreData. + */ + size -= strlen(sml_change_item_get_data(smlCommandGetNthChange(cmd, 0))); if (limit <= size) *space = 0; @@ -645,9 +651,6 @@ if (!assm->functions.rem_cmd(assm->assm_userdata, parentID, error)) goto error_remove; - /* enable the items again */ - smlCommandEnableChanges(cmd); - if (noCmdID) smlCommandSetID(cmd, 0); @@ -657,7 +660,6 @@ error_remove: assm->functions.rem_cmd(assm->assm_userdata, parentID, NULL); error_enable_item: - smlCommandEnableChanges(cmd); if (noCmdID) smlCommandSetID(cmd, 0); error: |