From: <svn...@op...> - 2009-03-13 13:52:55
|
Author: bellmich Date: Fri Mar 13 14:52:48 2009 New Revision: 972 URL: http://libsyncml.opensync.org/changeset/972 Log: added support for the case that a client sends alert 200 and receives alert 200 but needs to update to a SLOW-SYNC alert 201 because of an internal problem like wrong anchors NOTE: This code is untested because I failed to simulate this until now. Modified: trunk/libsyncml/data_sync_api/data_sync_client.c Modified: trunk/libsyncml/data_sync_api/data_sync_client.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_client.c Fri Mar 13 13:34:48 2009 (r971) +++ trunk/libsyncml/data_sync_api/data_sync_client.c Fri Mar 13 14:52:48 2009 (r972) @@ -101,10 +101,47 @@ &error); if (h == SML_ALERT_UNKNOWN || error) goto error; + /* There is only one situation where the callback can return + * something different than type. If the client requested an + * alert type 200, the server requested an alert type 200 too + * and after this there is a problem detected on the client + * then the returned type can be 201 SLOW-SYNC. + * + * If this happens then a new alert 201 and a status 508 must + * be send. + */ if (h != type) { - smlErrorSet(&error, SML_ERROR_GENERIC, - "It is not possible to change the alert type after an OMA DS client received the alerts from the OMA DS server."); - goto error; + if (h != SML_ALERT_SLOW_SYNC) { + smlErrorSet(&error, SML_ERROR_GENERIC, + "It is not possible to change the alert type after an OMA DS client received the alerts from the OMA DS server."); + goto error; + } else { + /* send alert 201 */ + SmlLocation *source = NULL; + source = smlLocationNew(datastore->sourceUri, NULL, &error); + if (!source) + goto error; + SmlCommand *alert = NULL; + alert = smlCommandNewAlert( + SML_ALERT_SLOW_SYNC, + smlDsSessionGetTarget(datastore->session), + source, + NULL, datastore->localNext, + NULL, &error); + if (!alert) { + smlLocationUnref(source); + goto error; + } + smlLocationUnref(source); + if (!smlSessionSendCommand(dsObject->session, alert, NULL, NULL, NULL, &error)) { + smlCommandUnref(alert); + goto error; + } + smlCommandUnref(alert); + + /* send status 508 */ + ret = FALSE; + } } } |