00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "transport.h"
00022 #include "libsyncml/sml_error_internals.h"
00023 #include "libsyncml/sml_support.h"
00024
00025 SmlBool smlDataSyncTransportObexClientInit(
00026 SmlDataSyncObject *dsObject,
00027 SmlError **error)
00028 {
00029 smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, dsObject, error);
00030 CHECK_ERROR_REF
00031
00032 if (dsObject->url &&
00033 !smlTransportSetConfigOption(
00034 dsObject->tsp,
00035 SML_TRANSPORT_CONFIG_URL, dsObject->url,
00036 error))
00037 goto error;
00038
00039 smlTrace(TRACE_EXIT, "%s - TRUE", __func__);
00040 return TRUE;
00041 error:
00042 smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error));
00043 return FALSE;
00044 }
00045
00046 SmlBool smlDataSyncTransportObexClientConnect(SmlDataSyncObject *dsObject, SmlError **error)
00047 {
00048 smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, dsObject, error);
00049 CHECK_ERROR_REF
00050
00051
00052
00053 if (!smlTransportConnect(dsObject->tsp, error))
00054 goto error;
00055
00056
00057
00058 SmlNotificationVersion sanVersion = SML_SAN_VERSION_UNKNOWN;
00059 switch(dsObject->version)
00060 {
00061 case SML_VERSION_10:
00062 sanVersion = SML_SAN_VERSION_10;
00063 break;
00064 case SML_VERSION_11:
00065 sanVersion = SML_SAN_VERSION_11;
00066 break;
00067 case SML_VERSION_12:
00068 sanVersion = SML_SAN_VERSION_12;
00069 break;
00070 case SML_VERSION_UNKNOWN:
00071 smlErrorSet(error, SML_ERROR_GENERIC, "Unknown SyncML SAN Version.");
00072 goto error;
00073 break;
00074 }
00075
00076 SmlNotification *san = smlNotificationNew(
00077 sanVersion,
00078 SML_SAN_UIMODE_UNSPECIFIED,
00079 SML_SAN_INITIATOR_USER, 1,
00080 dsObject->identifier, "/",
00081 dsObject->useWbxml ? SML_MIMETYPE_WBXML : SML_MIMETYPE_XML,
00082 error);
00083 if (!san)
00084 goto error;
00085
00086 smlNotificationSetManager(san, dsObject->manager);
00087
00088
00089 if (dsObject->username != NULL && strlen(dsObject->username))
00090 {
00091 SmlCred *cred = smlCredNewAuth(
00092 SML_AUTH_TYPE_MD5,
00093 dsObject->username,
00094 dsObject->password,
00095 error);
00096 if (!cred)
00097 goto error;
00098 smlNotificationSetCred(san, cred);
00099 smlCredUnref(cred);
00100 cred = NULL;
00101 }
00102
00103 GList *o = dsObject->datastores;
00104 for (; o; o = o->next) {
00105 SmlDataSyncDatastore *datastore = o->data;
00106 if (!smlDsServerAddSan(datastore->server, san, error))
00107 goto error;
00108 }
00109
00110 if (!smlNotificationSend(san, dsObject->tsp, error))
00111 goto error;
00112
00113 smlNotificationFree(san);
00114 san = NULL;
00115
00116 smlTrace(TRACE_EXIT, "%s", __func__);
00117 return TRUE;
00118 error:
00119 smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error));
00120 return FALSE;
00121 }
00122