From: <svn...@op...> - 2009-07-05 11:04:50
|
Author: bellmich Date: Sun Jul 5 13:04:42 2009 New Revision: 1153 URL: http://libsyncml.opensync.org/changeset/1153 Log: migrated sml_transport from SmlError to GError Modified: trunk/libsyncml/sml_transport.c trunk/libsyncml/sml_transport.h trunk/libsyncml/sml_transport_internals.h trunk/libsyncml/transports/http_client_internals.h trunk/libsyncml/transports/http_server_internals.h trunk/libsyncml/transports/obex_client_internals.h trunk/libsyncml/transports/obex_server_internals.h Modified: trunk/libsyncml/sml_transport.c ============================================================================== --- trunk/libsyncml/sml_transport.c Fri Jul 3 16:55:04 2009 (r1152) +++ trunk/libsyncml/sml_transport.c Sun Jul 5 13:04:42 2009 (r1153) @@ -43,7 +43,8 @@ */ /*@{*/ -static SmlBool smlTransportIsServer(SmlTransport *tsp) +static gboolean +smlTransportIsServer (SmlTransport *tsp) { smlAssert(tsp); if (tsp->type == SML_TRANSPORT_HTTP_SERVER) @@ -53,7 +54,10 @@ return FALSE; } -void smlTransportSetEventCallback(SmlTransport *tsp, SmlTransportEventCb callback, void *userdata) +void +smlTransportSetEventCallback (SmlTransport *tsp, + SmlTransportEventCb callback, + void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, tsp, callback, userdata); smlAssert(tsp); @@ -81,7 +85,11 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -SmlBool smlTransportSend(SmlTransport *tsp, SmlLink *link_, SmlTransportData *data, SmlError **error) +gboolean +smlTransportSend (SmlTransport *tsp, + SmlLink *link_, + SmlTransportData *data, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, tsp, link_, data, error); CHECK_ERROR_REF @@ -116,13 +124,14 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -void smlTransportWorkerHandler(void *message, void *userdata) +void +smlTransportWorkerHandler (void *message, + void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, message, userdata); smlAssert(message); @@ -184,7 +193,12 @@ return; } -SmlBool smlTransportReceiveEvent(SmlTransport *tsp, SmlLink *link_, SmlTransportEventType type, SmlTransportData *data, SmlError *error) +gboolean +smlTransportReceiveEvent (SmlTransport *tsp, + SmlLink *link_, + SmlTransportEventType type, + SmlTransportData *data, + const GError *error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %i, %p, %p)", __func__, tsp, link_, type, data, error); smlAssert(tsp); @@ -219,15 +233,14 @@ g_warning("The transport layer already caches an error " \ "because the event callback is not present until now." \ "The received error is ignored. %s", - smlErrorPrint(&error)); + error->message); // do not free the error here because you are not the owner of the error } if (!tsp->cached_error && error) { // we stop all communications here - smlTrace(TRACE_INTERNAL, "%s: init failed in transport protocol -> %s", __func__, smlErrorPrint(&error)); + smlTrace(TRACE_INTERNAL, "%s: init failed in transport protocol -> %s", __func__, error->message); tsp->state = SML_TRANSPORT_ERROR; - tsp->cached_error = error; - smlErrorRef(&error); + tsp->cached_error = g_error_copy(error); } } else { smlTrace(TRACE_INTERNAL, "%s: callback available", __func__); @@ -235,7 +248,7 @@ { /* First we have to send the cached error. */ smlTrace(TRACE_INTERNAL, "%s: cached error detected - %s", __func__, - smlErrorPrint(&(tsp->cached_error))); + tsp->cached_error->message); g_atomic_int_inc(&(tsp->event_callback_ref_count)); ret = tsp->event_callback( tsp, NULL, @@ -331,7 +344,7 @@ __func__, g_atomic_int_dec_and_test(&(tsp->event_callback_ref_count))); } if (tsp->cached_error) { - smlErrorDeref(&(tsp->cached_error)); + g_error_free(tsp->cached_error); tsp->cached_error = NULL; } } /* end of tsp->event_callback */ @@ -340,19 +353,8 @@ return ret; } -/* FIXME: DEPRECATED */ -SmlBool smlTransportRunAsync(SmlTransport *tsp, SmlError **error) -{ - smlTrace(TRACE_ERROR, "%s(%p,%p)", __func__, tsp, error); - CHECK_ERROR_REF - /* All transports run in asynchronous mode. - * Therefore this function should never be called. - * The functions always returns TRUE to avoid any complications. - */ - return TRUE; -} - -static void _smlTransportStop(SmlTransport *tsp) +static void +_smlTransportStop(SmlTransport *tsp) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, tsp); @@ -366,13 +368,9 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -/* FIXME: DEPRECATED */ -void smlTransportStop(SmlTransport *tsp) -{ - _smlTransportStop(tsp); -} - -SmlBool smlTransportConnect(SmlTransport *tsp, SmlError **error) +gboolean +smlTransportConnect (SmlTransport *tsp, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, tsp, error); CHECK_ERROR_REF @@ -384,14 +382,14 @@ if (smlTransportIsServer(tsp)) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Only a transport client can be actively connected."); goto error; } if (tsp->connected) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "A transport client can be connected only once."); goto error; } @@ -409,13 +407,15 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -SmlBool smlTransportDisconnect(SmlTransport *tsp, SmlLink *link_, SmlError **error) +gboolean +smlTransportDisconnect (SmlTransport *tsp, + SmlLink *link_, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, tsp, link_, error); CHECK_ERROR_REF @@ -425,7 +425,7 @@ if (!tsp->connected) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The transport is not connected and so it cannot be disconnected."); goto error; } @@ -436,7 +436,7 @@ if (link_ && !smlTransportIsServer(tsp)) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "A transport client has no link " \ "because there is only one connection."); goto error; @@ -473,7 +473,7 @@ if (!link_ && smlTransportIsServer(tsp) && tsp->connections) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "A server shutdown is requested " \ "but there are still open connections (%d).", tsp->connections); @@ -488,7 +488,7 @@ { if (tsp != link_->tsp) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The link %p is registered at another transport layer %p than this one %p.", link_, link_->tsp, tsp); goto error; @@ -497,7 +497,7 @@ g_mutex_lock(tsp->links_mutex); if (!g_hash_table_lookup(tsp->links, link_)) { g_mutex_unlock(tsp->links_mutex); - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The link %p is not registered at the transport layer %p", link_, tsp); goto error; @@ -522,19 +522,24 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)); return FALSE; } -SmlTransportType smlTransportGetType(SmlTransport *tsp) +SmlTransportType +smlTransportGetType (SmlTransport *tsp) { smlAssert(tsp); return tsp->type; } -SmlTransportData *smlTransportDataNew(char *data, unsigned long size, SmlMimeType mimetype, SmlBool ownsData, SmlError **error) +SmlTransportData* +smlTransportDataNew (gchar *data, + gsize size, + SmlMimeType mimetype, + gboolean ownsData, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %d, %i, %i, %p)", __func__, data, size, mimetype, ownsData, error); CHECK_ERROR_REF @@ -554,13 +559,13 @@ smlTrace(TRACE_EXIT, "%s: %p", __func__, cmd); return cmd; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -SmlTransportData *smlTransportDataRef(SmlTransportData *data) +SmlTransportData* +smlTransportDataRef (SmlTransportData *data) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, data); smlAssert(data); @@ -571,7 +576,8 @@ return data; } -void smlTransportDataDeref(SmlTransportData *data) +void +smlTransportDataDeref(SmlTransportData *data) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, data); smlAssert(data); @@ -589,15 +595,18 @@ smlTrace(TRACE_EXIT, "%s: Freed", __func__); } -void smlTransportSetError(SmlTransport *tsp, SmlLink *link_, SmlError **error) +void +smlTransportSendError (SmlTransport *tsp, + SmlLink *link_, + const GError *error) { - smlTrace(TRACE_ENTRY, "%s(%p, %p, %p(%p))", __func__, tsp, link_, error, error ? *error : NULL); + smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, tsp, link_, error); /* Do no use CHECK_ERROR_REF here. - * SmlError **error contains an error which should be send. + * GError *error contains an error which should be send. */ smlAssert(tsp); - SmlError *locerror = NULL; + GError *locerror = NULL; SmlTransportCommand *cmd = smlTryMalloc0(sizeof(SmlTransportCommand), &locerror); if (!cmd) return; @@ -609,9 +618,8 @@ smlLinkRef(cmd->link); } - if (error && *error) { - cmd->error = *error; - smlErrorRef(error); + if (error) { + cmd->error = g_error_copy(error); } //Call the fin function @@ -620,7 +628,10 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -SmlLink *smlLinkNew(SmlTransport *tsp, void *link_data, SmlError **error) +SmlLink* +smlLinkNew (SmlTransport *tsp, + void *link_data, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, tsp, link_data, error); CHECK_ERROR_REF @@ -641,24 +652,13 @@ smlTrace(TRACE_EXIT, "%s: %p", __func__, link_); return link_; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -/* FIXME: DEPRECATED */ -SmlLink *smlLinkFind(SmlTransport *tsp, void *link_data) -{ - /* The function always returns NULL. - * The function is not removed to protect the intergrity of the library. - * Actually no user of this function is known. - */ - smlTrace(TRACE_INTERNAL, "%s(%p, %p)", __func__, tsp, link_data); - return NULL; -} - -SmlLink *smlLinkRef(SmlLink *link_) +SmlLink* +smlLinkRef (SmlLink *link_) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, link_); smlAssert(link_); @@ -669,7 +669,8 @@ return link_; } -void smlLinkDeref(SmlLink *link_) +void +smlLinkDeref (SmlLink *link_) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, link_); smlAssert(link_); @@ -718,7 +719,9 @@ * @returns The new transport or NULL in the case of an error * */ -SmlTransport *smlTransportNew(SmlTransportType type, SmlError **error) +SmlTransport* +smlTransportNew (SmlTransportType type, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%i, %p)", __func__, type, error); CHECK_ERROR_REF @@ -739,38 +742,38 @@ #ifdef ENABLE_HTTP case SML_TRANSPORT_HTTP_SERVER: if (!smlTransportHttpServerNew(tsp, error)) - goto error_free_tsp; + goto error; break; case SML_TRANSPORT_HTTP_CLIENT: if (!smlTransportHttpClientNew(tsp, error)) - goto error_free_tsp; + goto error; break; #else case SML_TRANSPORT_HTTP_SERVER: case SML_TRANSPORT_HTTP_CLIENT: - smlErrorSet(error, SML_ERROR_GENERIC, "HTTP Transport not enabled in this build"); - goto error_free_tsp; + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "HTTP Transport not enabled in this build"); + goto error; #endif #ifdef ENABLE_OBEX case SML_TRANSPORT_OBEX_CLIENT: if (!smlTransportObexClientNew(tsp, error)) - goto error_free_tsp; + goto error; break; case SML_TRANSPORT_OBEX_SERVER: if (!smlTransportObexServerNew(tsp, error)) - goto error_free_tsp; + goto error; break; #else case SML_TRANSPORT_OBEX_SERVER: case SML_TRANSPORT_OBEX_CLIENT: - smlErrorSet(error, SML_ERROR_GENERIC, "OBEX Transport not enabled in this build"); - goto error_free_tsp; + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "OBEX Transport not enabled in this build"); + goto error; #endif } tsp->command_queue = smlQueueNew(error); if (!tsp->command_queue) - goto error_free_tsp; + goto error; /* links must be tracked to detect server connections * which are not cleaned up before server finalization @@ -794,11 +797,10 @@ smlTrace(TRACE_EXIT, "%s: %p", __func__, tsp); return tsp; - -error_free_tsp: - smlTransportFree(tsp); error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + if (tsp) + smlTransportFree(tsp); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } @@ -807,7 +809,8 @@ * @param tsp The transport to free * */ -void smlTransportFree(SmlTransport *tsp) +void +smlTransportFree (SmlTransport *tsp) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, tsp); smlAssert(tsp); @@ -815,13 +818,14 @@ if (tsp->command_queue) smlQueueFree(tsp->command_queue); - SmlError *error = NULL; + GError *error = NULL; if (tsp->transport_data && !tsp->functions.finalize(tsp->transport_data, &error)) { g_warning("The library libsyncml cannot free the transport. %s", - smlErrorPrint(&error)); - smlErrorDeref(&error); + error->message); + g_error_free(error); + error = NULL; } if (tsp->context) @@ -854,8 +858,9 @@ if (tsp->cached_error) { g_warning("The transport layer is cleaned up and an error is ignored. %s", - smlErrorPrint(&(tsp->cached_error))); - smlErrorDeref(&(tsp->cached_error)); + tsp->cached_error->message); + g_error_free(tsp->cached_error); + tsp->cached_error = NULL; } /* free the memory */ @@ -880,11 +885,11 @@ * @returns TRUE if the call succeded or FALSE in the case of an error * */ -SmlBool smlTransportSetConfigOption( - SmlTransport *tsp, - const char *name, - const char *value, - SmlError **error) +gboolean +smlTransportSetConfigOption (SmlTransport *tsp, + const gchar *name, + const gchar *value, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %s, %s, %p)", __func__, tsp, VA_STRING(name), strcmp(name, "PASSWORD") ? VA_STRING(value) : "***sensitive***", error); /* Do not change the assertion to simple return FALSE stuff @@ -898,7 +903,7 @@ if (!name) { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "The name of the configuration option is missing."); goto error; } @@ -909,7 +914,7 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; error: - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } @@ -928,10 +933,10 @@ * @returns TRUE if the call succeded or FALSE in the case of an error * */ -SmlBool smlTransportSetConnectionType( - SmlTransport *tsp, - SmlTransportConnectionType type, - SmlError **error) +gboolean +smlTransportSetConnectionType (SmlTransport *tsp, + SmlTransportConnectionType type, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, tsp, type, error); /* Do not change the assertion to simple return FALSE stuff @@ -966,7 +971,9 @@ * @returns TRUE if the call succeded or FALSE in the case of an error * */ -SmlBool smlTransportInitialize(SmlTransport *tsp, SmlError **error) +gboolean +smlTransportInitialize (SmlTransport *tsp, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, tsp, error); CHECK_ERROR_REF @@ -977,7 +984,7 @@ tsp->context = g_main_context_new(); if (!tsp->context) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Cannot create new GMainContext for asynchronous transport."); goto error; } @@ -1020,7 +1027,7 @@ tsp->context = NULL; } error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } @@ -1038,10 +1045,10 @@ * @returns TRUE if the call succeded or FALSE in the case of an error * */ -SmlBool smlTransportSetResponseURI( - SmlTransport *tsp, - const char *uri, - SmlError **error) +gboolean +smlTransportSetResponseURI (SmlTransport *tsp, + const gchar *uri, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %s, %p)", __func__, tsp, VA_STRING(uri), error); /* Do not change the assertion to simple return FALSE stuff @@ -1065,9 +1072,9 @@ } } -static SmlBool smlTransportDetachQueueCallback( - gpointer data, - SmlError **error) +static gboolean +smlTransportDetachQueueCallback (gpointer data, + GError **error) { smlTrace(TRACE_ENTRY, "%s", __func__); CHECK_ERROR_REF @@ -1078,9 +1085,9 @@ return TRUE; } -static SmlBool smlTransportDispatchQueueCallback( - gpointer data, - SmlError **error) +static gboolean +smlTransportDispatchQueueCallback (gpointer data, + GError **error) { smlTrace(TRACE_ENTRY, "%s", __func__); CHECK_ERROR_REF @@ -1101,7 +1108,9 @@ * @returns TRUE if the call succeded or FALSE in the case of an error * */ -SmlBool smlTransportFinalize(SmlTransport *tsp, SmlError **error) +gboolean +smlTransportFinalize (SmlTransport *tsp, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, tsp, error); CHECK_ERROR_REF @@ -1110,14 +1119,14 @@ if (tsp->connected && !smlTransportIsServer(tsp)) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "If a client transport is connected then it cannot be finalized."); goto error; } if (tsp->state != SML_TRANSPORT_INITIALIZED && tsp->state != SML_TRANSPORT_ERROR) { - smlErrorSet(error, SML_ERROR_GENERIC, "Transport was not in the state \"Initialized\""); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Transport was not in the state \"Initialized\""); goto error; } @@ -1177,13 +1186,15 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -char * smlTransportGetResponseURI(SmlLink *link_, SmlSession *session, SmlError **error) +gchar* +smlTransportGetResponseURI (SmlLink *link_, + SmlSession *session, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, link_, session, error); /* Do not change the assertion to simple return FALSE stuff Modified: trunk/libsyncml/sml_transport.h ============================================================================== --- trunk/libsyncml/sml_transport.h Fri Jul 3 16:55:04 2009 (r1152) +++ trunk/libsyncml/sml_transport.h Sun Jul 5 13:04:42 2009 (r1153) @@ -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 @@ -23,52 +23,44 @@ #define _SML_TRANSPORT_H_ typedef enum SmlTransportEventType { - SML_TRANSPORT_EVENT_CONNECT_DONE, - SML_TRANSPORT_EVENT_DISCONNECT_DONE, - SML_TRANSPORT_EVENT_ERROR, - SML_TRANSPORT_EVENT_DATA + SML_TRANSPORT_EVENT_UNKNOWN = 0, + SML_TRANSPORT_EVENT_CONNECT_DONE = 1, + SML_TRANSPORT_EVENT_DISCONNECT_DONE = 2, + SML_TRANSPORT_EVENT_ERROR = 3, + SML_TRANSPORT_EVENT_DATA = 4 } SmlTransportEventType; typedef enum { - SML_TRANSPORT_CONNECTION_TYPE_UNKNOWN = 0, - SML_TRANSPORT_CONNECTION_TYPE_SERIAL = 1, + SML_TRANSPORT_CONNECTION_TYPE_UNKNOWN = 0, + SML_TRANSPORT_CONNECTION_TYPE_SERIAL = 1, SML_TRANSPORT_CONNECTION_TYPE_BLUETOOTH = 2, - SML_TRANSPORT_CONNECTION_TYPE_IRDA = 3, - SML_TRANSPORT_CONNECTION_TYPE_NET = 4, - SML_TRANSPORT_CONNECTION_TYPE_USB = 5 + SML_TRANSPORT_CONNECTION_TYPE_IRDA = 3, + SML_TRANSPORT_CONNECTION_TYPE_NET = 4, + SML_TRANSPORT_CONNECTION_TYPE_USB = 5 } SmlTransportConnectionType; typedef gboolean (* SmlTransportEventCb) (SmlTransport *tsp, SmlLink *link, SmlTransportEventType type, SmlTransportData *data, const GError *error, void *userdata); -SmlTransport *smlTransportNew(SmlTransportType type, SmlError **error); -void smlTransportFree(SmlTransport *tsp); +SmlTransport* smlTransportNew (SmlTransportType type, GError **error); +void smlTransportFree (SmlTransport *tsp); -SmlBool smlTransportSetConfigOption(SmlTransport *tsp, const char *name, const char *value, SmlError **error); -SmlBool smlTransportSetConnectionType(SmlTransport *tsp, SmlTransportConnectionType type, SmlError **error); -SmlBool smlTransportInitialize(SmlTransport *tsp, SmlError **error); - -void smlTransportSetEventCallback(SmlTransport *tsp, SmlTransportEventCb callback, void *userdata); -SmlBool smlTransportFinalize(SmlTransport *tsp, SmlError **error); -SmlBool smlTransportConnect(SmlTransport *tsp, SmlError **error); -SmlBool smlTransportDisconnect(SmlTransport *tsp, SmlLink *link, GError **error); -SmlBool smlTransportSend(SmlTransport *tsp, SmlLink *link, SmlTransportData *data, GError **error); -SmlTransportData *smlTransportDataNew(char *data, unsigned long size, SmlMimeType mimetype, SmlBool ownsData, GError **error); -SmlTransportData *smlTransportDataRef(SmlTransportData *data); -void smlTransportDataDeref(SmlTransportData *data); -SmlLink *smlLinkNew(SmlTransport *tsp, void *link_data, SmlError **error); -SmlLink *smlLinkRef(SmlLink *link); -void smlLinkDeref(SmlLink *link); -void smlTransportSetError(SmlTransport *tsp, SmlLink *link, SmlError **error); -SmlTransportType smlTransportGetType(SmlTransport *tsp); -SmlTransport *smlManagerGetTransport(SmlManager *manager); - -/* This function will only be removed from the header. */ -SmlBool smlTransportRunAsync(SmlTransport *tsp, SmlError **error) LIBSYNCML_DEPRECATED; /* expire date: 20090728 */ -void smlTransportStop(SmlTransport *tsp) LIBSYNCML_DEPRECATED; /* expire date: 20090815 */ -/* The function always returns NULL. - * The function is not removed to protect the intergrity of the library. - * Actually no user of this function is known. - */ -SmlLink *smlLinkFind(SmlTransport *tsp, void *link_data) LIBSYNCML_DEPRECATED; /* expire data: 20091223 */ +gboolean smlTransportSetConfigOption (SmlTransport *tsp, const gchar *name, const gchar *value, GError **error); +gboolean smlTransportSetConnectionType (SmlTransport *tsp, SmlTransportConnectionType type, GError **error); +gboolean smlTransportInitialize (SmlTransport *tsp, GError **error); + +void smlTransportSetEventCallback (SmlTransport *tsp, SmlTransportEventCb callback, void *userdata); +gboolean smlTransportFinalize (SmlTransport *tsp, GError **error); +gboolean smlTransportConnect (SmlTransport *tsp, GError **error); +gboolean smlTransportDisconnect (SmlTransport *tsp, SmlLink *link, GError **error); +gboolean smlTransportSend (SmlTransport *tsp, SmlLink *link, SmlTransportData *data, GError **error); +SmlTransportData* smlTransportDataNew (gchar *data, gsize size, SmlMimeType mimetype, gboolean ownsData, GError **error); +SmlTransportData* smlTransportDataRef (SmlTransportData *data); +void smlTransportDataDeref (SmlTransportData *data); +SmlLink* smlLinkNew (SmlTransport *tsp, void *link_data, GError **error); +SmlLink* smlLinkRef (SmlLink *link); +void smlLinkDeref (SmlLink *link); +void smlTransportSendError (SmlTransport *tsp, SmlLink *link, const GError *error); +SmlTransportType smlTransportGetType (SmlTransport *tsp); +SmlTransport* smlManagerGetTransport (SmlManager *manager); #endif //_SML_TRANSPORT_H_ Modified: trunk/libsyncml/sml_transport_internals.h ============================================================================== --- trunk/libsyncml/sml_transport_internals.h Fri Jul 3 16:55:04 2009 (r1152) +++ trunk/libsyncml/sml_transport_internals.h Sun Jul 5 13:04:42 2009 (r1153) @@ -1,7 +1,7 @@ /* * libsyncml - A syncml protocol implementation * Copyright (C) 2005 Armin Bauer <arm...@op...> - * Copyright (C) 2007-2008 Michael Bell <mic...@op...> + * Copyright (C) 2007-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 @@ -24,28 +24,28 @@ #include "sml_queue_internals.h" -typedef SmlBool (* SmlTransportSetConfigOptionFn) (SmlTransport *tsp, const char *name, const char *value, SmlError **error); -typedef SmlBool (* SmlTransportSetConnectionTypeFn) (SmlTransport *tsp, SmlTransportConnectionType type, SmlError **error); -typedef SmlBool (* SmlTransportInitializeFn) (SmlTransport *tsp, SmlError **error); +typedef gboolean (* SmlTransportSetConfigOptionFn) (SmlTransport *tsp, const gchar *name, const gchar *value, GError **error); +typedef gboolean (* SmlTransportSetConnectionTypeFn) (SmlTransport *tsp, SmlTransportConnectionType type, GError **error); +typedef gboolean (* SmlTransportInitializeFn) (SmlTransport *tsp, GError **error); /* This function is used for transport clients * to support redirects from the server. * Example: Funambol works with such redirects * because of Tomcat's session management. */ -typedef SmlBool (* SmlTransportSetResponseUriFn) (SmlTransport *tsp, const char *uri, SmlError **error); +typedef gboolean (* SmlTransportSetResponseUriFn) (SmlTransport *tsp, const gchar *uri, GError **error); /* This function is used to add some kind of session id * to the URL of the server. This is necessary to * avoid session hijacking. */ -typedef char * (* SmlTransportGetResponseUriFn) (SmlLink *link, SmlSession *session, SmlError **error); +typedef gchar * (* SmlTransportGetResponseUriFn) (SmlLink *link, SmlSession *session, GError **error); -typedef SmlBool (* SmlTransportFinalizeFn) (void *data, SmlError **error); +typedef gboolean (* SmlTransportFinalizeFn) (void *data, GError **error); -typedef void (* SmlTransportConnectFn) (void *data); +typedef void (* SmlTransportConnectFn) (void *data); typedef void (* SmlTransportDisconnectFn) (void *data, void *link_data); -typedef void (* SmlTransportSendFn) (void *userdata, void *link_data, SmlTransportData *data, SmlError *error); +typedef void (* SmlTransportSendFn) (void *userdata, void *link_data, SmlTransportData *data, GError *error); typedef struct SmlTransportFunctions { SmlTransportSetConfigOptionFn set_config_option; @@ -60,10 +60,10 @@ } SmlTransportFunctions; typedef enum SmlTransportState { - SML_TRANSPORT_UNINITIALIZED, - SML_TRANSPORT_INITIALIZED, - SML_TRANSPORT_CONNECTED, - SML_TRANSPORT_ERROR + SML_TRANSPORT_UNINITIALIZED = 0, + SML_TRANSPORT_INITIALIZED = 1, + SML_TRANSPORT_CONNECTED = 2, + SML_TRANSPORT_ERROR = 3 } SmlTransportState; struct SmlTransport { @@ -80,12 +80,12 @@ SmlTransportEventCb event_callback; void *event_callback_userdata; gint event_callback_ref_count; - SmlError *cached_error; + GError *cached_error; - SmlBool connected; + gboolean connected; GHashTable *links; GMutex *links_mutex; - unsigned int connections; + gsize connections; GMutex *connections_mutex; }; @@ -96,9 +96,10 @@ }; typedef enum SmlTransportCommandType { - SML_TRANSPORT_CMD_SEND, - SML_TRANSPORT_CMD_CONNECT, - SML_TRANSPORT_CMD_DISCONNECT + SML_TRANSPORT_CMD_UNKNOWN = 0, + SML_TRANSPORT_CMD_SEND = 1, + SML_TRANSPORT_CMD_CONNECT = 2, + SML_TRANSPORT_CMD_DISCONNECT = 3 } SmlTransportCommandType; typedef struct SmlTransportCommand { @@ -106,19 +107,19 @@ SmlTransportData *data; const void *config; SmlLink *link; - SmlError *error; + GError *error; } SmlTransportCommand; struct SmlTransportData { - char *data; - unsigned long size; + gchar *data; + gsize size; SmlMimeType type; - SmlBool ownsData; + gboolean ownsData; gint32 refCount; /** This field specifies if the data transported * here needs an reply from the other side. If it does not * need one, the transports might take special precautions */ - SmlBool needsAnswer; + gboolean needsAnswer; /** This is only needed to switch the mime type when using the OBEX Transporting * and sending a SyncML 1.2 SAN package. The transport send() function for OBEX transport * make use of a PUT/GET command sequence. To avoid that GET command request with mimetype @@ -132,10 +133,10 @@ SmlMimeType type_get; }; -void smlTransportWorkerHandler(void *message, void *userdata); -SmlBool smlTransportReceiveEvent(SmlTransport *tsp, SmlLink *link, SmlTransportEventType type, SmlTransportData *data, SmlError *error); +void smlTransportWorkerHandler (void *message, void *userdata); +gboolean smlTransportReceiveEvent (SmlTransport *tsp, SmlLink *link, SmlTransportEventType type, SmlTransportData *data, const GError *error); -SmlBool smlTransportSetResponseURI(SmlTransport *tsp, const char *uri, GError **error); -char *smlTransportGetResponseURI(SmlLink *link, SmlSession *session, GError **error); +gboolean smlTransportSetResponseURI (SmlTransport *tsp, const gchar *uri, GError **error); +gchar* smlTransportGetResponseURI (SmlLink *link, SmlSession *session, GError **error); #endif //_SML_TRANSPORT_INTERNALS_H_ Modified: trunk/libsyncml/transports/http_client_internals.h ============================================================================== --- trunk/libsyncml/transports/http_client_internals.h Fri Jul 3 16:55:04 2009 (r1152) +++ trunk/libsyncml/transports/http_client_internals.h Sun Jul 5 13:04:42 2009 (r1153) @@ -1,7 +1,7 @@ /* * libsyncml - A syncml protocol implementation * Copyright (C) 2005 Armin Bauer <arm...@op...> - * Copyright (C) 2007-2008 Michael Bell <mic...@op...> + * Copyright (C) 2007-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 @@ -52,6 +52,6 @@ SmlBool disconnectDone; } SmlTransportHttpClientEnv; -SmlBool smlTransportHttpClientNew(SmlTransport *tsp, SmlError **error); +gboolean smlTransportHttpClientNew (SmlTransport *tsp, GError **error); #endif //_HTTP_CLIENT_INTERNALS_H_ Modified: trunk/libsyncml/transports/http_server_internals.h ============================================================================== --- trunk/libsyncml/transports/http_server_internals.h Fri Jul 3 16:55:04 2009 (r1152) +++ trunk/libsyncml/transports/http_server_internals.h Sun Jul 5 13:04:42 2009 (r1153) @@ -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 @@ -56,6 +56,6 @@ SmlLink *link; } SmlLinkHttpServerEnv; -SmlBool smlTransportHttpServerNew(SmlTransport *tsp, SmlError **error); +gboolean smlTransportHttpServerNew (SmlTransport *tsp, GError **error); #endif //_HTTP_SERVER_INTERNALS_H_ Modified: trunk/libsyncml/transports/obex_client_internals.h ============================================================================== --- trunk/libsyncml/transports/obex_client_internals.h Fri Jul 3 16:55:04 2009 (r1152) +++ trunk/libsyncml/transports/obex_client_internals.h Sun Jul 5 13:04:42 2009 (r1153) @@ -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 @@ -72,6 +72,6 @@ SmlBool isDisconnected; } SmlTransportObexClientEnv; -SmlBool smlTransportObexClientNew(SmlTransport *tsp, SmlError **error); +gboolean smlTransportObexClientNew (SmlTransport *tsp, GError **error); #endif //_OBEX_CLIENT_INTERNALS_H_ Modified: trunk/libsyncml/transports/obex_server_internals.h ============================================================================== --- trunk/libsyncml/transports/obex_server_internals.h Fri Jul 3 16:55:04 2009 (r1152) +++ trunk/libsyncml/transports/obex_server_internals.h Sun Jul 5 13:04:42 2009 (r1153) @@ -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 @@ -58,6 +58,6 @@ SmlTransportData *send_data; } SmlLinkObexServerEnv; -SmlBool smlTransportObexServerNew(SmlTransport *tsp, SmlError **error); +gboolean smlTransportObexServerNew (SmlTransport *tsp, GError **error); #endif //_OBEX_SERVER_INTERNALS_H_ |