00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "../syncml.h"
00022 #include "../syncml_internals.h"
00023 #include "../sml_error_internals.h"
00024
00025 #include <libsyncml/data_sync_api/defines.h>
00026 #include <libsyncml/data_sync_api/standard.h>
00027 #include <libsyncml/data_sync_api/callbacks.h>
00028
00029 #include "data_sync.h"
00030
00038 #include "../sml_session_internals.h"
00039 #include "../sml_manager_internals.h"
00040
00041 SmlBool smlDataSyncAbort(
00042 SmlDataSyncObject *dsObject,
00043 SmlError **error)
00044 {
00045 smlTrace(TRACE_ENTRY, "%s", __func__);
00046
00047
00048 if (!dsObject->session->sending && !dsObject->session->waiting)
00049 {
00050
00051 smlTrace(TRACE_INTERNAL, "%s: A careful abort is possible.", __func__);
00052
00053
00054 goto WORKAROUND;
00055 } else {
00056
00057 WORKAROUND:
00058 smlTrace(TRACE_INTERNAL, "%s: A hard abort is required.", __func__);
00059
00060 if (SML_DATA_SYNC_STATE_CONNECTED <= dsObject->internalState &&
00061 dsObject->internalState < SML_DATA_SYNC_STATE_DISCONNECT_IN_PROGRESS)
00062 {
00063 dsObject->internalState = SML_DATA_SYNC_STATE_DISCONNECT_IN_PROGRESS;
00064
00065 SmlLink *link_ = smlManagerSessionGetLink(
00066 dsObject->manager,
00067 dsObject->session,
00068 error);
00069 if (!link_ && *error)
00070 goto error;
00071
00072 if (!smlTransportDisconnect(dsObject->tsp, link_, error))
00073 goto error;
00074 }
00075 }
00076
00077 smlTrace(TRACE_EXIT, "%s", __func__);
00078 return TRUE;
00079 error:
00080 smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error));
00081 return FALSE;
00082 }
00083