From: <svn...@op...> - 2009-07-09 10:34:42
|
Author: bellmich Date: Thu Jul 9 12:34:31 2009 New Revision: 1162 URL: http://libsyncml.opensync.org/changeset/1162 Log: migrated transports/obex_client from SmlError to GError Modified: trunk/libsyncml/transports/obex_client.c trunk/libsyncml/transports/obex_client_internals.h trunk/libsyncml/transports/obex_client_samsung.c trunk/libsyncml/transports/obex_client_vendor_internals.h Modified: trunk/libsyncml/transports/obex_client.c ============================================================================== --- trunk/libsyncml/transports/obex_client.c Thu Jul 9 12:33:42 2009 (r1161) +++ trunk/libsyncml/transports/obex_client.c Thu Jul 9 12:34:31 2009 (r1162) @@ -58,13 +58,13 @@ #ifndef WIN32 -static SmlBool obex_cable_at( - SmlTransportObexClientEnv *userdata, - const char *cmd, - char *rspbuf, - int rspbuflen, - int timeout, - SmlError **error) +static gboolean +obex_cable_at (SmlTransportObexClientEnv *userdata, + const gchar *cmd, + gchar *rspbuf, + gint rspbuflen, + gint timeout, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %s, %p, %i, %i, %p)", __func__, userdata, VA_STRING(cmd), rspbuf, rspbuflen, timeout, error); CHECK_ERROR_REF @@ -73,7 +73,7 @@ struct timeval tv; gint fd; - SmlBool statusOnly = FALSE; + gboolean statusOnly = FALSE; char *answer = NULL; char *answer_end = NULL; @@ -97,7 +97,7 @@ fd = userdata->fd; rspbuf[0] = 0; if(fd < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The file descriptor for the cable AT command is not legal (%d).", fd); goto error; @@ -108,7 +108,7 @@ cmdlen = strlen(cmd); if(write(fd, cmd, cmdlen) < cmdlen) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The command cannot be written (completely) to the file descriptor."); goto error; } @@ -125,7 +125,7 @@ if(select(fd+1, &ttyset, NULL, NULL, &tv)) { actual = read(fd, &tmpbuf[total], sizeof(tmpbuf) - total); if(actual < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "read failed with return code %i.", actual); goto error; @@ -134,7 +134,7 @@ /* Answer didn't come within the length of the buffer. Cancel! */ if(total == sizeof(tmpbuf)) { - smlErrorSet(error, SML_ERROR_NOT_IMPLEMENTED, + g_set_error(error, SML_ERROR, SML_ERROR_NOT_IMPLEMENTED, "The size of the answer to the AT command %s was too large for the internal buffer.", VA_STRING(cmd)); goto error; @@ -145,7 +145,7 @@ ) { /* check for an error */ if (!strncasecmp("ERROR", answer+1, 5)) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The AT command %s failed.", VA_STRING(cmd)); goto error; @@ -168,7 +168,7 @@ } } else { /* Anser didn't come in time. Cancel */ - smlErrorSet(error, SML_ERROR_INTERNAL_IO_ERROR, + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_IO_ERROR, "The read operation for the answer of the AT command was timed out."); goto error; } @@ -189,7 +189,7 @@ smlTrace(TRACE_INTERNAL, "%s: answer size=%d", __func__, answer_size); if( (answer_size) >= rspbuflen ) { - smlErrorSet(error, SML_ERROR_NOT_IMPLEMENTED, + g_set_error(error, SML_ERROR, SML_ERROR_NOT_IMPLEMENTED, "The size of the answer to the AT command %s was too large.", VA_STRING(cmd)); goto error; @@ -200,7 +200,7 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; error: - smlTrace(TRACE_EXIT, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT, "%s - %s", __func__, (*error)->message); return FALSE; } @@ -228,7 +228,7 @@ return 0; } -SmlTransportObexVendorType smlTransportObexClientGetVendor(const char *manufacturer) +SmlTransportObexVendorType smlTransportObexClientGetVendor(const gchar *manufacturer) { smlTrace(TRACE_ENTRY, "%s(%s)", __func__, VA_STRING(manufacturer)); smlAssert(manufacturer); @@ -247,11 +247,11 @@ return vendor; } -static int smlTransportObexClientCableConnect(obex_t *handle, gpointer ud) +static gint smlTransportObexClientCableConnect(obex_t *handle, gpointer ud) { smlTrace(TRACE_ENTRY, "%s", __func__); - SmlError *error = NULL; + GError *error = NULL; SmlTransportObexClientEnv *userdata = (SmlTransportObexClientEnv *) ud; struct termios newtio; char rspbuf[201]; @@ -259,7 +259,7 @@ userdata->fd = open(userdata->path, O_RDWR|O_NONBLOCK|O_NOCTTY); if (userdata->fd < 0) { - smlErrorSet(&error, SML_ERROR_INTERNAL_IO_ERROR, + g_set_error(&error, SML_ERROR, SML_ERROR_INTERNAL_IO_ERROR, "A valid file descriptor must be non-negative."); goto error; } @@ -279,7 +279,7 @@ goto error; if (strcasecmp("OK", rspbuf)) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The ATZ command was answered with %s.", rspbuf); goto error; @@ -318,7 +318,7 @@ case SML_OBEX_VENDOR_SAMSUNG: smlTrace(TRACE_INTERNAL, "%s: Samsung detected", __func__); if (!smlTransportObexVendorSamsungInit(userdata)) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The intialization for Samsung failed."); goto error; } @@ -340,7 +340,7 @@ goto error; if (strcasecmp("CONNECT", rspbuf)) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The command AT+CPROT=0 failed with answer %s.", rspbuf); goto error; @@ -348,14 +348,14 @@ // fcntl(userdata->fd, F_SETFL, O_NONBLOCK); return 0; error: - perror(smlErrorPrint(&error)); + perror(error->message); smlTransportObexClientCableDisconnect(handle, userdata); - smlTrace(TRACE_ERROR, "%s - %s", __func__, smlErrorPrint(&error)); - smlErrorDeref(&error); + smlTrace(TRACE_ERROR, "%s - %s", __func__, error->message); + g_error_free(error); return -1; } -static int smlTransportObexClientCableWrite(obex_t *handle, gpointer ud, guint8 *buf, int buflen) { +static gint smlTransportObexClientCableWrite(obex_t *handle, gpointer ud, guint8 *buf, gint buflen) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %i)", __func__, handle, ud, buf, buflen); SmlTransportObexClientEnv *userdata = (SmlTransportObexClientEnv *) ud; @@ -414,11 +414,11 @@ #endif -static void smlTransportObexClientEvent(obex_t *handle, obex_object_t *object, int mode, int event, int obex_cmd, int obex_rsp) +static void smlTransportObexClientEvent(obex_t *handle, obex_object_t *object, gint mode, gint event, gint obex_cmd, gint obex_rsp) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %i, %i, %i, %i)", __func__, handle, object, mode, event, obex_cmd, obex_rsp); SmlTransportObexClientEnv *env = OBEX_GetUserData(handle); - SmlError *error = NULL; + GError *error = NULL; switch (event) { case OBEX_EV_PROGRESS: @@ -431,13 +431,13 @@ if (obex_rsp != OBEX_RSP_SUCCESS) { switch(obex_cmd) { case OBEX_CMD_CONNECT: - smlErrorSet(&error, SML_ERROR_INTERNAL_MISCONFIGURATION, + g_set_error(&error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "The OBEX client cannot connect to the configured device or resource (%s - 0x%x).", OBEX_ResponseToString(obex_rsp), obex_rsp); break; default: - smlErrorSet(&error, SML_ERROR_INTERNAL_IO_ERROR, + g_set_error(&error, SML_ERROR, SML_ERROR_INTERNAL_IO_ERROR, "%s (0x%x)", OBEX_ResponseToString(obex_rsp), obex_rsp); @@ -471,14 +471,14 @@ } if (!env->connection_id) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Missing connection id"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Missing connection id"); smlSafeCFree(&who); goto error; } smlTrace(TRACE_INTERNAL, "%s: Got who: %s", __func__, VA_STRING(who)); if (!who || strcmp(who, "SYNCML-SYNC")) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Missing or wrong who response"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Missing or wrong who response"); smlSafeCFree(&who); goto error; } @@ -514,7 +514,7 @@ } if (!length) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Got zero length!"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Got zero length!"); goto error; } @@ -538,12 +538,12 @@ } if (!length) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Missing length"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Missing length"); goto error; } if (!body) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Missing body"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Missing body"); goto error; } @@ -569,11 +569,11 @@ } } else { /* This is a normal error. */ - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Link Error: %s - 0x%x", OBEX_ResponseToString(obex_rsp), obex_rsp); smlTrace(TRACE_INTERNAL, "%s - %s", - __func__, smlErrorPrint(&error)); + __func__, error->message); goto error; } break; @@ -587,18 +587,18 @@ error: smlTransportReceiveEvent(env->tsp, NULL, SML_TRANSPORT_EVENT_ERROR, NULL, error); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&error)); - smlErrorDeref(&error); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, error->message); + g_error_free(error); env->busy = FALSE; env->error = TRUE; return; } -static SmlBool smlTransportObexClientSetConfigOption( - SmlTransport *tsp, - const char *name, - const char *value, - SmlError **error) +static gboolean +smlTransportObexClientSetConfigOption (SmlTransport *tsp, + const gchar *name, + const gchar *value, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %s, %s, %p)", __func__, tsp, VA_STRING(name), VA_STRING(value), error); CHECK_ERROR_REF @@ -610,7 +610,7 @@ /* This transport does not accept NULL as value. */ if (!value) { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "The configuration option %s requires a value.", name); goto error; } @@ -670,7 +670,8 @@ if (!strcasecmp(SML_TRANSPORT_CONFIG_DATASTORE_NOTE, value)) datastore = SML_TRANSPORT_OBEX_DATASTORE_NOTE; if (!datastore) { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, "Unknown datastore %s found.", value); + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, + "Unknown datastore %s found.", value); goto error; } SmlTransportObexDatastoreType *type = smlTryMalloc0(sizeof(SmlTransportObexDatastoreType), error); @@ -680,22 +681,23 @@ env->datastores = g_list_append(env->datastores, type); smlTrace(TRACE_INTERNAL, "%s: Datastore %i detected", __func__, datastore); } else { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, "Unknown parameter %s found.", name); + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, + "Unknown parameter %s found.", name); goto error; } 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; } -static SmlBool smlTransportObexClientSetConnectionType( - SmlTransport *tsp, - SmlTransportConnectionType type, - SmlError **error) +static gboolean +smlTransportObexClientSetConnectionType (SmlTransport *tsp, + SmlTransportConnectionType type, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, tsp, type, error); CHECK_ERROR_REF @@ -722,14 +724,14 @@ env->obexhandle = OBEX_Init(OBEX_TRANS_USB, smlTransportObexClientEvent, 0); break; default: - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown obex type"); - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown obex type"); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } if (!env->obexhandle) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to open connection"); - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to open connection"); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } @@ -750,7 +752,9 @@ return TRUE; } -static SmlBool smlTransportObexClientInit(SmlTransport *tsp, SmlError **error) +static gboolean +smlTransportObexClientInit (SmlTransport *tsp, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, tsp, error); CHECK_ERROR_REF @@ -763,20 +767,20 @@ switch (env->type) { case SML_TRANSPORT_CONNECTION_TYPE_NET: if (!env->path) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The hostname or address is missing."); goto error; } break; case SML_TRANSPORT_CONNECTION_TYPE_BLUETOOTH: if (!env->path) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The bluetooth address is missing."); goto error; } #ifndef ENABLE_BLUETOOTH_SDPLIB if (!env->port) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The bluetooth channel is missing."); goto error; } @@ -800,11 +804,13 @@ if (env->model) smlSafeCFree(&(env->model)); smlSafeFree((gpointer *)&env); - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } -static SmlBool smlTransportObexClientFinalize(void *data, SmlError **error) +static gboolean +smlTransportObexClientFinalize (void *data, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, data, error); CHECK_ERROR_REF @@ -842,7 +848,7 @@ smlAssert(data); SmlTransportObexClientEnv *env = data; int fd = 0; - SmlError *error = NULL; + GError *error = NULL; unsigned int obex_intf_cnt; obex_interface_t *obex_intf; env->isDisconnected = FALSE; @@ -857,14 +863,14 @@ struct hostent *hostinfo = gethostbyname (env->path); if (!hostinfo) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unknown host %s", env->path); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unknown host %s", env->path); goto error; } addr.sin_addr = *(struct in_addr *) hostinfo->h_addr_list[0]; fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Cannot create socket: %s", strerror(errno)); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Cannot create socket: %s", strerror(errno)); goto error; } @@ -874,7 +880,7 @@ smlTrace(TRACE_INTERNAL, "%s: peer addr = %d %s %i", __func__, hostinfo->h_addr_list[0], VA_STRING(addrstr), env->port); if (connect(fd, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Cannot connect socket: %s", strerror(errno)); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Cannot connect socket: %s", strerror(errno)); goto error_close; } smlTrace(TRACE_INTERNAL, "%s: connect done", __func__); @@ -886,14 +892,14 @@ smlTrace(TRACE_INTERNAL, "%s: found %i interfaces", __func__, obex_intf_cnt); if (obex_intf_cnt <= 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, "There are no valid USB interfaces."); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "There are no valid USB interfaces."); goto error; } else if (env->port >= obex_intf_cnt) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unable to find the USB interface number %i", env->port); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unable to find the USB interface number %i", env->port); goto error; } else { if (GET_OBEX_RESULT(OBEX_InterfaceConnect(env->obexhandle, &obex_intf[env->port])) < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The interface cannot be connected. %s (%i).", strerror(errno), errno); goto error; @@ -914,7 +920,7 @@ sdp_session_t *sdp_session = sdp_connect(BDADDR_ANY, &bdaddr, SDP_RETRY_IF_BUSY); if (!sdp_session) { - smlErrorSet(&error, SML_ERROR_GENERIC, "The Bluetooth connect to search for the channel failed."); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The Bluetooth connect to search for the channel failed."); goto error; } unsigned char syncml_client_uuid[] = { @@ -932,8 +938,8 @@ sdp_list_free(attribute, 0); sdp_list_free(class, 0); - smlErrorSet( - &error, SML_ERROR_GENERIC, + g_set_error( + &error, SML_ERROR, SML_ERROR_GENERIC, "The service search on the Bluetooth device failed."); goto error; } @@ -962,7 +968,7 @@ #endif if (GET_OBEX_RESULT(BtOBEX_TransportConnect(env->obexhandle, BDADDR_ANY, &bdaddr, channel)) < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The Bluetooth connect failed. %s (%i).", strerror(errno), errno); goto error; @@ -970,14 +976,14 @@ smlTrace(TRACE_INTERNAL, "%s: bluetooth connect done", __func__); #else - smlErrorSet(&error, SML_ERROR_GENERIC, "Bluetooth not enabled"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Bluetooth not enabled"); goto error; #endif } else if (env->type == SML_TRANSPORT_CONNECTION_TYPE_IRDA) { smlTrace(TRACE_INTERNAL, "%s: connecting to IrDA service %s", __func__, env->irda_service ? env->irda_service : "OBEX"); if (GET_OBEX_RESULT(IrOBEX_TransportConnect(env->obexhandle, env->irda_service)) < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The IrDA connect failed. %s (%i).", strerror(errno), errno); goto error; @@ -992,18 +998,18 @@ /* Open the file descriptor */ fd = open(env->path, O_RDWR | O_NOCTTY); if (fd == -1) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unable to open %s: %s", env->path, strerror(errno)); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unable to open %s: %s", env->path, strerror(errno)); goto error; } /* Lock it*/ if (lockf(fd, F_TLOCK, 0)) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unable to lock %s: %s", env->path, strerror(errno)); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unable to lock %s: %s", env->path, strerror(errno)); goto error_close; } if (tcgetattr(fd, &tio)) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unable to get attr from %s", env->path); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unable to get attr from %s", env->path); goto error_unlock; } @@ -1024,7 +1030,7 @@ cfsetospeed(&tio, B115200); if (tcsetattr(fd, TCSANOW, &tio)) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unable to set attr from %s", env->path); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unable to set attr from %s", env->path); goto error_unlock; } tcflush(fd, TCIFLUSH); @@ -1036,7 +1042,7 @@ && env->type != SML_TRANSPORT_CONNECTION_TYPE_IRDA) { /* Start the obex transport */ if (GET_OBEX_RESULT(FdOBEX_TransportSetup(env->obexhandle, fd, fd, 4096)) < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The OBEX transport setup failed. %s (%i).", strerror(errno), errno); goto error_unlock; @@ -1046,7 +1052,7 @@ /* Make a new connect object */ obex_object_t *obj = OBEX_ObjectNew(env->obexhandle, OBEX_CMD_CONNECT); if (!obj) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unable to create new connect object"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unable to create new connect object"); goto error_transport_close; } @@ -1058,7 +1064,7 @@ env->busy = TRUE; /* Now we need to send the request */ if (GET_OBEX_RESULT(OBEX_Request(env->obexhandle, obj)) < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The OBEX request failed. %s (%i).", strerror(errno), errno); goto error_free_obj; @@ -1073,12 +1079,12 @@ while (env->busy) { int result = OBEX_HandleInput(env->obexhandle, 20); if (result < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The connect request was not successful (%i).", result); goto error; } else if (result == 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The connect request was timed out."); goto error; } @@ -1100,8 +1106,8 @@ close(fd); error: smlTransportReceiveEvent(env->tsp, NULL, SML_TRANSPORT_EVENT_ERROR, NULL, error); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&error)); - smlErrorDeref(&error); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, error->message); + g_error_free(error); } static void smlTransportObexClientDisconnect(void *data, void *linkdata) @@ -1109,7 +1115,7 @@ smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, data, linkdata); smlAssert(data); SmlTransportObexClientEnv *env = data; - SmlError *error = NULL; + GError *error = NULL; if (env->isDisconnected) { /* This is a bug. If the transport is disconnected @@ -1128,7 +1134,7 @@ /* Make a new disconnect object */ obex_object_t *obj = OBEX_ObjectNew(env->obexhandle, OBEX_CMD_DISCONNECT); if (!obj) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unable to create new disconnect object"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unable to create new disconnect object"); goto error; } @@ -1140,14 +1146,14 @@ env->busy = TRUE; /* Now we need to send the request */ if (GET_OBEX_RESULT(OBEX_Request(env->obexhandle, obj)) < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The OBEX request cannot be sent. %s (%i).", strerror(errno), errno); goto error_free_obj; } if (env->error) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unable to send disconnect request. Bailing out"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unable to send disconnect request. Bailing out"); goto error; } @@ -1163,12 +1169,12 @@ int result = OBEX_HandleInput(env->obexhandle, 1); /* timeout and success are not relevant */ if (result < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The disconnect request was not accepted (%i).", result); goto error; } else if (result == 0 && !env->busy && !env->isDisconnected) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The disconnect request was timed out."); goto error; } @@ -1197,11 +1203,15 @@ OBEX_ObjectDelete(env->obexhandle, obj); error: smlTransportReceiveEvent(env->tsp, NULL, SML_TRANSPORT_EVENT_ERROR, NULL, error); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&error)); - smlErrorDeref(&error); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, error->message); + g_error_free(error); } -static void smlTransportObexClientSend(void *userdata, void *link_, SmlTransportData *data, SmlError *error) +static void +smlTransportObexClientSend (void *userdata, + void *link_, + SmlTransportData *data, + GError *error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, userdata, link_, data, error); smlAssert(error || data); @@ -1218,7 +1228,7 @@ /* Make a new put command */ obex_object_t *obj = OBEX_ObjectNew(env->obexhandle, OBEX_CMD_PUT); if (!obj) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unable to create new put object"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unable to create new put object"); goto error; } @@ -1243,7 +1253,7 @@ target = SML_ELEMENT_SAN; break; default: - smlErrorSet(&error, SML_ERROR_GENERIC, "Unknown mime type"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unknown mime type"); goto error_free_obj; } smlTrace(TRACE_INTERNAL, "%s: Target %s", __func__, VA_STRING(target)); @@ -1253,7 +1263,7 @@ unsigned int unicodesize = OBEX_CharToUnicode(unicode, (const unsigned char *)target, 2 * strlen(target) + 2); if (unicodesize == -1) { - smlErrorSet(&error, SML_ERROR_GENERIC, "unable to convert to unicode"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "unable to convert to unicode"); goto error_free_obj; }*/ @@ -1273,7 +1283,7 @@ env->busy = TRUE; /* Now we need to send the request */ if (GET_OBEX_RESULT(OBEX_Request(env->obexhandle, obj)) < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The OBEX request cannot be sent. %s (%i).", strerror(errno), errno); goto error_free_obj; @@ -1283,19 +1293,19 @@ while (env->busy) { int result = OBEX_HandleInput(env->obexhandle, 20); if (result < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The request was not successful (%d).", result); goto error; } else if (result == 0 && !env->busy) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The request was timed out."); goto error; } } if (env->error) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unable to send put request. Bailing out"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unable to send put request. Bailing out"); goto error; } @@ -1309,7 +1319,7 @@ /* Make a new get command */ obj = OBEX_ObjectNew(env->obexhandle, OBEX_CMD_GET); if (!obj) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unable to create new get object"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unable to create new get object"); goto error; } @@ -1340,7 +1350,7 @@ target = SML_ELEMENT_SAN; break; default: - smlErrorSet(&error, SML_ERROR_GENERIC, "Unknown mime type"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unknown mime type"); goto error_free_obj; } @@ -1360,7 +1370,7 @@ env->busy = TRUE; /* Now we need to send the request */ if (GET_OBEX_RESULT(OBEX_Request(env->obexhandle, obj)) < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The OBEX request cannot be sent. %s (%i).", strerror(errno), errno); goto error_free_obj; @@ -1371,12 +1381,12 @@ while (env->busy) { int result = OBEX_HandleInput(env->obexhandle, 20); if (result < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The answer was not received successfully (%i).", result); goto error; } else if (result == 0 && !env->busy) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The answer was timed out."); goto error; } @@ -1389,11 +1399,14 @@ OBEX_ObjectDelete(env->obexhandle, obj); error: smlTransportReceiveEvent(env->tsp, NULL, SML_TRANSPORT_EVENT_ERROR, NULL, error); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, error->message); + g_error_free(error); return; } -SmlBool smlTransportObexClientNew(SmlTransport *tsp, SmlError **error) +gboolean +smlTransportObexClientNew (SmlTransport *tsp, + GError **error) { CHECK_ERROR_REF smlAssert(tsp); Modified: trunk/libsyncml/transports/obex_client_internals.h ============================================================================== --- trunk/libsyncml/transports/obex_client_internals.h Thu Jul 9 12:33:42 2009 (r1161) +++ trunk/libsyncml/transports/obex_client_internals.h Thu Jul 9 12:34:31 2009 (r1162) @@ -49,27 +49,27 @@ SmlTransportConnectionType type; SmlTransport *tsp; obex_t *obexhandle; - uint32_t connection_id; - char *path; - unsigned int port; - char *irda_service; - char *at_command; - char *manufacturer; - char *model; + guint32 connection_id; + gchar *path; + guint port; + gchar *irda_service; + gchar *at_command; + gchar *manufacturer; + gchar *model; GList *datastores; - int fd; - int state; - char *databuf; - int *databuflen; - int connected; + gint fd; + gint state; + gchar *databuf; + gint *databuflen; + gint connected; #ifndef WIN32 struct termios oldtio; #endif - SmlBool busy; - SmlBool error; + gboolean busy; + gboolean error; SmlMimeType mimetype; - SmlBool isDisconnected; + gboolean isDisconnected; } SmlTransportObexClientEnv; gboolean smlTransportObexClientNew (SmlTransport *tsp, GError **error); Modified: trunk/libsyncml/transports/obex_client_samsung.c ============================================================================== --- trunk/libsyncml/transports/obex_client_samsung.c Thu Jul 9 12:33:42 2009 (r1161) +++ trunk/libsyncml/transports/obex_client_samsung.c Thu Jul 9 12:34:31 2009 (r1162) @@ -1,6 +1,6 @@ /* * libsyncml - A syncml protocol implementation - * 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 @@ -24,7 +24,7 @@ #include <libsyncml/sml_transport_internals.h> #include "obex_client_internals.h" -SmlBool smlTransportObexVendorSamsungInit(SmlTransportObexClientEnv *env) +gboolean smlTransportObexVendorSamsungInit(SmlTransportObexClientEnv *env) { smlTrace(TRACE_EXIT, "%s(%p, %s)", __func__, VA_STRING(env->model)); Modified: trunk/libsyncml/transports/obex_client_vendor_internals.h ============================================================================== --- trunk/libsyncml/transports/obex_client_vendor_internals.h Thu Jul 9 12:33:42 2009 (r1161) +++ trunk/libsyncml/transports/obex_client_vendor_internals.h Thu Jul 9 12:34:31 2009 (r1162) @@ -1,6 +1,6 @@ /* * libsyncml - A syncml protocol implementation - * 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 @@ -21,6 +21,6 @@ #ifndef _OBEX_CLIENT_SAMSUNG_INTERNALS_H_ #define _OBEX_CLIENT_SAMSUNG_INTERNALS_H_ -SmlBool smlTransportObexVendorSamsungInit(SmlTransportObexClientEnv *env); +gboolean smlTransportObexVendorSamsungInit(SmlTransportObexClientEnv *env); #endif //_OBEX_CLIENT_SAMSUNG_INTERNALS_H_ |