From: <svn...@op...> - 2009-07-03 14:13:12
|
Author: bellmich Date: Fri Jul 3 16:13:03 2009 New Revision: 1149 URL: http://libsyncml.opensync.org/changeset/1149 Log: migrated sml_session from SmlError to GError Modified: trunk/libsyncml/objects/sml_auth_internals.h trunk/libsyncml/sml_session.c trunk/libsyncml/sml_session.h trunk/libsyncml/sml_session_internals.h Modified: trunk/libsyncml/objects/sml_auth_internals.h ============================================================================== --- trunk/libsyncml/objects/sml_auth_internals.h Fri Jul 3 15:10:54 2009 (r1148) +++ trunk/libsyncml/objects/sml_auth_internals.h Fri Jul 3 16:13:03 2009 (r1149) @@ -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 @@ -42,10 +42,10 @@ char *smlAuthGetCredString( SmlAuthType type, - const char *username, - const char *password, - const char *b64_nonce, - SmlError **error); + const gchar *username, + const gchar *password, + const gchar *b64_nonce, + GError **error); #endif //_SML_AUTH_INTERNALS_H_ /*@}*/ Modified: trunk/libsyncml/sml_session.c ============================================================================== --- trunk/libsyncml/sml_session.c Fri Jul 3 15:10:54 2009 (r1148) +++ trunk/libsyncml/sml_session.c Fri Jul 3 16:13:03 2009 (r1149) @@ -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 @@ -54,11 +54,17 @@ SmlStatus *status; SmlStatusReplyCb callback; void *callbackUserdata; - SmlBool final; - SmlBool end; + gboolean final; + gboolean end; } SmlSessionCommand; -void smlSessionDispatchEvent(SmlSession *session, SmlSessionEventType type, SmlCommand *cmd, SmlCommand *parent, SmlStatus *headerreply, SmlError *error) +void +smlSessionDispatchEvent (SmlSession *session, + SmlSessionEventType type, + SmlCommand *cmd, + SmlCommand *parent, + SmlStatus *headerreply, + const GError *error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p, %p)", __func__, session, type, cmd, parent, headerreply, error); smlAssert(session); @@ -69,7 +75,8 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -static void _smlSessionFreePendingReplies(SmlSession *session) +static void +_smlSessionFreePendingReplies (SmlSession *session) { while (session->pendingReplies) { smlSafeFree((gpointer *)&(session->pendingReplies->data)); @@ -91,7 +98,10 @@ * @return TRUE if successful, FALSE otherwise * */ -static SmlBool _smlSessionFlushInternal(SmlSession *session, SmlBool final, SmlError **error) +static gboolean +_smlSessionFlushInternal (SmlSession *session, + gboolean final, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, session, final, error); CHECK_ERROR_REF @@ -100,7 +110,7 @@ char *data = NULL; unsigned int size = 0; - SmlBool end = FALSE; + gboolean end = FALSE; /* Add the latest header */ if (!smlAssemblerAddHeader(session->assembler, session, error)) @@ -124,7 +134,7 @@ SmlTransportData *tspdata = smlTransportDataNew(data, size, session->type, TRUE, error); if (!tspdata) - goto error_free_data; + goto error; data = NULL; if (end && session->sessionType == SML_SESSION_TYPE_SERVER) @@ -166,22 +176,27 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - -error_free_data: - smlSafeCFree(&data); error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + if (data) + smlSafeCFree(&data); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -static void _check_reply(SmlSession *session, SmlStatus *status, void *userdata) +static void +_check_reply (SmlSession *session, + SmlStatus *status, + void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, status, userdata); smlTrace(TRACE_EXIT, "%s", __func__); } -static void _smlSessionFragmentStatus(SmlSession *session, SmlStatus *status, void *userdata) +static void +_smlSessionFragmentStatus (SmlSession *session, + SmlStatus *status, + void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, status, userdata); //SmlError *error = NULL; @@ -205,7 +220,14 @@ return;*/ } -static SmlCommand *_smlSessionFragmentSend(SmlSession *session, SmlCommand *orig_cmd, SmlCommand *parent, unsigned int space, unsigned int start, unsigned int complete_size, SmlError **error) +static SmlCommand* +_smlSessionFragmentSend (SmlSession *session, + SmlCommand *orig_cmd, + SmlCommand *parent, + gsize space, + gsize start, + gsize complete_size, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %i, %i, %i, %p)", __func__, session, orig_cmd, parent, space, start, complete_size, error); CHECK_ERROR_REF @@ -234,12 +256,12 @@ SmlItem *frag_item = smlItemNewForData(data + start, space, error); if (!frag_item) - goto error_free_cmd; + goto error; frag_cmd->private.change.items = g_list_append (NULL, frag_item); if (!frag_cmd->private.change.items) { smlItemUnref(frag_item); - goto error_free_cmd; + goto error; } frag_item->moreData = TRUE; @@ -308,22 +330,28 @@ smlTrace(TRACE_EXIT, "%s: %p", __func__, frag_cmd); return frag_cmd; - -error_free_cmd: - smlCommandUnref(frag_cmd); error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + if (frag_cmd) + smlCommandUnref(frag_cmd); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -static SmlAssemblerResult _smlSessionStartCommandInternal(SmlSession *session, SmlCommand *cmd, SmlCommand *parent, SmlStatusReplyCb callback, void *userdata, SmlBool addToCommandStack, SmlError **error) +static SmlAssemblerResult +_smlSessionStartCommandInternal (SmlSession *session, + SmlCommand *cmd, + SmlCommand *parent, + SmlStatusReplyCb callback, + void *userdata, + gboolean addToCommandStack, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %p, %i, %p)", __func__, session, cmd, parent, callback, userdata, addToCommandStack, error); smlAssert(session); smlAssert(cmd); CHECK_ERROR_REF SmlPendingStatus *pending = NULL; - SmlBool fragmented = FALSE; + gboolean fragmented = FALSE; if (parent && !session->hasCommand) { GList *c = NULL; @@ -364,14 +392,15 @@ if ((sendingmaxobjsize > 0) && (size > (unsigned int)sendingmaxobjsize)) { - smlErrorSet(error, SML_ERROR_SIZE_MISMATCH, "Item (%ub) is larger than the limit (%db)", size, smlSessionGetRemoteMaxObjSize(session)); + g_set_error(error, SML_ERROR, SML_ERROR_SIZE_MISMATCH, + "Item (%ub) is larger than the limit (%db)", size, smlSessionGetRemoteMaxObjSize(session)); goto error; } if (!session->frag_command) cmd->size = size; item->moreData = TRUE; - int space = 0; + gsize space = 0; if (!smlAssemblerGetSpace(session->assembler, &space, parent, cmd, error)) goto error; cmd->size = 0; @@ -438,7 +467,7 @@ break; case SML_ASSEMBLER_RESULT_MISMATCH: if (cmd->pushedBack) { - smlErrorSet(error, SML_ERROR_GENERIC, "Command is too large"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Command is too large"); goto error; } cmd->pushedBack = TRUE; @@ -515,13 +544,15 @@ smlTrace(TRACE_EXIT, "%s", __func__); return SML_ASSEMBLER_RESULT_OK; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return SML_ASSEMBLER_RESULT_ERROR; } -static SmlBool _smlSessionEndCommandInternal(SmlSession *session, SmlCommand *parent, SmlError **error) +static gboolean +_smlSessionEndCommandInternal (SmlSession *session, + SmlCommand *parent, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, parent, error); smlAssert(session); @@ -534,13 +565,13 @@ 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 void _smlSessionCommandFree(SmlSessionCommand *sesscmd) +static void +_smlSessionCommandFree (SmlSessionCommand *sesscmd) { if (sesscmd->cmd) smlCommandUnref(sesscmd->cmd); @@ -554,14 +585,16 @@ smlSafeFree((gpointer *)&sesscmd); } -static void _smlSessionCommandHandler(void *message, void *userdata) +static void +_smlSessionCommandHandler (void *message, + void *userdata) { smlTrace(TRACE_ENTRY, "%s", __func__); smlAssert(message); smlAssert(userdata); SmlSessionCommand *sesscmd = message; SmlSession *session = userdata; - SmlError *error = NULL; + GError *error = NULL; //SmlPendingStatus *pending = NULL; smlTrace(TRACE_INTERNAL, "%s: session cmd type %i", __func__, sesscmd->type); @@ -605,7 +638,7 @@ case SML_SESSION_STATUS:; unsigned int cmdRef, msgRef = 0; if (!smlAssemblerGetNextCmdRef(session->assembler, &cmdRef, &msgRef)) { - smlErrorSet(&error, SML_ERROR_GENERIC, "No more statuses were needed"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "No more statuses were needed"); goto error; } @@ -654,24 +687,26 @@ smlTrace(TRACE_EXIT, "%s", __func__); return; - error: smlSessionDispatchEvent(session, SML_SESSION_EVENT_ERROR, NULL, NULL, NULL, error); _smlSessionCommandFree(sesscmd); + g_error_free(error); return; } -SmlBool smlSessionReceiveHeader(SmlSession *session, SmlHeader *header, SmlError **error) +gboolean +smlSessionReceiveHeader (SmlSession *session, + SmlHeader *header, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, header, error); smlAssert(session); smlAssert(header); CHECK_ERROR_REF - GError *gerror = NULL; /* check and set the counters */ if (header->messageID <= session->lastReceivedMessageID) { - smlErrorSet(error, SML_ERROR_GENERIC, "Message ID not incremented"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Message ID not incremented"); goto error; } session->lastReceivedMessageID = header->messageID; @@ -728,7 +763,7 @@ session->target = sml_location_new_with_options( header->responseURI, sml_location_get_name(session->orgTarget), - &gerror); + error); if (!session->target) goto error; smlSessionDispatchEvent(session, SML_SESSION_EVENT_RESPONSE_URI, NULL, NULL, NULL, NULL); @@ -754,20 +789,21 @@ smlTrace(TRACE_INTERNAL, "%s: update session target to header source %s", __func__, header_source); - if (!sml_location_set_uri(session->target, header_source, &gerror)) + if (!sml_location_set_uri(session->target, header_source, error)) goto error; } } smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: - GERROR_TO_SML_ERROR(gerror,error) - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -SmlBool smlSessionDispatchStatus(SmlSession *session, SmlStatus *status, SmlError **error) +gboolean +smlSessionDispatchStatus (SmlSession *session, + SmlStatus *status, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, status, error); smlAssert(status); @@ -830,7 +866,8 @@ if (session->cred->type == SML_AUTH_TYPE_MD5 && status->chal->type != SML_AUTH_TYPE_MD5) { - smlErrorSet(error, SML_ERROR_AUTH_REJECTED, "The remote peer tries to enforce an authentication method which violates the local security policy (syncml:auth-md5 is required)."); + g_set_error(error, SML_ERROR, SML_ERROR_AUTH_REJECTED, + "The remote peer tries to enforce an authentication method which violates the local security policy (syncml:auth-md5 is required)."); goto error; } smlTrace(TRACE_INTERNAL, "%s - authentication type conforms to security policy", __func__); @@ -867,7 +904,7 @@ * We have to check every handler. */ GList *o = NULL; - SmlBool foundPending = FALSE; + gboolean foundPending = FALSE; for (o = session->pendingReplies; o; o = o ? o->next : NULL ) { SmlPendingStatus *pending = o->data; smlTrace(TRACE_INTERNAL, "%s: check cmd %i of msg %i", __func__, pending->cmdID, pending->msgID); @@ -928,12 +965,12 @@ * If there is no callback available * then this is a normal error. */ - smlErrorSet(error, errorCode, "The SAN alert was rejected."); + g_set_error(error, SML_ERROR, errorCode, "The SAN alert was rejected."); goto error; } } - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Received unwanted status %s of command %d in message %d", status->data, status->cmdRef, status->msgRef); goto error; @@ -941,11 +978,12 @@ 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 smlSessionCheck(SmlSession *session) +gboolean +smlSessionCheck (SmlSession *session) { smlAssert(session); @@ -955,7 +993,7 @@ return FALSE; } - SmlBool result; + gboolean result; if (!smlAssemblerIsStatusMissing(session->assembler)) { result = smlQueueCheck(session->command_queue); @@ -969,17 +1007,19 @@ return result; } -SmlBool smlSessionTryLock(SmlSession *session) +gboolean +smlSessionTryLock (SmlSession *session) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, session); smlAssert(session); smlAssert(session->dispatch_mutex); - SmlBool ret = g_mutex_trylock(session->dispatch_mutex); + gboolean ret = g_mutex_trylock(session->dispatch_mutex); smlTrace(TRACE_EXIT, "%s - %d", __func__, ret); return ret; } -void smlSessionLock(SmlSession *session) +void +smlSessionLock (SmlSession *session) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, session); smlAssert(session); @@ -988,7 +1028,8 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -void smlSessionUnlock(SmlSession *session) +void +smlSessionUnlock (SmlSession *session) { smlTrace(TRACE_ENTRY, "%s", __func__); smlAssert(session); @@ -1024,7 +1065,10 @@ smlTrace(TRACE_EXIT, "%s - done", __func__); } -SmlBool smlSessionReceiveBody(SmlSession *session, SmlParser *parser, SmlError **error) +gboolean +smlSessionReceiveBody (SmlSession *session, + SmlParser *parser, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, parser, error); smlAssert(session); @@ -1033,7 +1077,7 @@ SmlStatus *status = NULL; SmlCommand *cmd = NULL; SmlParserResult result = SML_PARSER_RESULT_ERROR; - SmlBool isSan = TRUE; + gboolean isSan = TRUE; if (session->sessionType == SML_SESSION_TYPE_SERVER) isSan = FALSE; @@ -1052,7 +1096,7 @@ /* Now lets go through the available statuses (if any) */ while (1) { if (!smlParserGetStatus(parser, &status, error)) - goto error_free_status; + goto error; if (!status) break; @@ -1084,7 +1128,7 @@ /* Call the callback*/ if (!smlSessionDispatchStatus(session, status, error)) - goto error_free_status; + goto error; smlStatusUnref(status); } @@ -1093,7 +1137,7 @@ while (1) { result = smlParserGetCommand(parser, &cmd, error); if (result == SML_PARSER_RESULT_ERROR) - goto error_free_cmd; + goto error; if (result == SML_PARSER_RESULT_OTHER) break; @@ -1110,15 +1154,15 @@ /* Reserve the place for the status in the assembler */ if (!smlAssemblerReserveStatus(session->assembler, cmd->cmdID, session->lastReceivedMessageID, session->lastCommandID, error)) - goto error_free_cmd; + goto error; /* send status 407 */ SmlStatus *reply = smlCommandNewReply( cmd, SML_ERROR_AUTH_REQUIRED, error); if (!reply) - goto error_free_cmd; + goto error; if (!smlSessionSendReply(session, reply, error)) - goto error_free_cmd; + goto error; smlStatusUnref(reply); smlCommandUnref(cmd); continue; @@ -1129,12 +1173,12 @@ session->lastCommandID++; /* Reserve the place for the status in the assembler */ if (!smlAssemblerReserveStatus(session->assembler, cmd->cmdID, session->lastReceivedMessageID, session->lastCommandID, error)) - goto error_free_cmd; + goto error; /* Store the parent */ if (session->parentCommand) { - smlErrorSet(error, SML_ERROR_GENERIC, "Already had a parent"); - goto error_free_cmd; + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Already had a parent"); + goto error; } /* If we are a server, we just mimick the behaviour of the client regarding @@ -1175,10 +1219,10 @@ __func__); SmlStatus *reply = smlCommandNewReply(cmd, SML_ERROR_AUTH_REQUIRED, error); if (!reply) - goto error_free_cmd; + goto error; if (!smlSessionSendReply(session, reply, error)) - goto error_free_cmd; + goto error; smlStatusUnref(reply); } @@ -1187,17 +1231,17 @@ session->lastCommandID++; /* Reserve the place for the status in the assembler */ if (!smlAssemblerReserveStatus(session->assembler, cmd->cmdID, session->lastReceivedMessageID, session->lastCommandID, error)) - goto error_free_cmd; + goto error; /* Here we catch Alerts for the next message */ if (cmd->type == SML_COMMAND_TYPE_ALERT) { if (cmd->private.alert.type == SML_ALERT_NEXT_MESSAGE) { SmlStatus *reply = smlCommandNewReply(cmd, SML_NO_ERROR, error); if (!reply) - goto error_free_cmd; + goto error; if (!smlSessionSendReply(session, reply, error)) - goto error_free_cmd; + goto error; smlStatusUnref(reply); @@ -1233,9 +1277,9 @@ * different chunks except the first one. */ if (cmd->size) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Only the first chunk can have the size set"); - goto error_free_cmd; + goto error; } /* Copy the item data of the first new item. @@ -1246,12 +1290,12 @@ unsigned int size = 0; SmlItem *item = g_list_nth_data(cmd->private.change.items, 0); if (!item) - goto error_free_cmd; + goto error; if (!smlItemGetData(item, &data, &size, error)) - goto error_free_cmd; + goto error; lastItem = g_list_nth_data(session->incomingBuffer->private.change.items, g_list_length(session->incomingBuffer->private.change.items) - 1); if (!smlItemAddData(lastItem, data, size, error)) - goto error_free_cmd; + goto error; lastItem->moreData = item->moreData; smlTrace(TRACE_INTERNAL, "%s: Appended %i to buffer. Buffer size: %i. Required: %i", @@ -1287,13 +1331,13 @@ /* We have a size mismatch */ SmlStatus *reply = smlCommandNewReply(cmd, SML_ERROR_SIZE_MISMATCH, error); if (!reply) - goto error_free_cmd; + goto error; if (!smlSessionSendReply(session, reply, error)) - goto error_free_cmd; + goto error; smlStatusUnref(reply); - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Chunked item size mismatch"); - goto error_free_cmd; + goto error; } /* The original command is no longer needed. @@ -1316,8 +1360,9 @@ */ if (!cmd->size) { - smlErrorSet(error, SML_ERROR_GENERIC, "First MoreData item didn't have size set"); - goto error_free_cmd; + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "First MoreData item didn't have size set"); + goto error; } session->incomingBuffer = cmd; @@ -1339,10 +1384,10 @@ SmlStatus *reply = smlCommandNewReply(cmd, SML_CHUNK_ACCEPTED, error); if (!reply) - goto error_free_cmd; + goto error; if (!smlSessionSendReply(session, reply, error)) - goto error_free_cmd; + goto error; smlStatusUnref(reply); @@ -1355,7 +1400,7 @@ if (cmd->type == SML_COMMAND_TYPE_RESULTS) { /* Call the callback*/ if (!smlSessionDispatchStatus(session, cmd->private.results.status, error)) - goto error_free_status; + goto error; } else { /* Dispatch the command */ cmd->msgID = session->lastReceivedMessageID; @@ -1370,10 +1415,10 @@ __func__); SmlStatus *reply = smlCommandNewReply(cmd, SML_ERROR_AUTH_REQUIRED, error); if (!reply) - goto error_free_cmd; + goto error; if (!smlSessionSendReply(session, reply, error)) - goto error_free_cmd; + goto error; smlStatusUnref(reply); } @@ -1402,7 +1447,7 @@ case SML_PARSER_RESULT_STATUS: goto parse_status; default: - goto error_free_cmd; + goto error; } } @@ -1411,10 +1456,10 @@ * A package can consists of several messages if MaxMsgSize * is smaller then the exchange data. */ - SmlBool final = FALSE; - SmlBool end = FALSE; + gboolean final = FALSE; + gboolean end = FALSE; if (!smlParserEnd(parser, &final, &end, error)) - goto error_free_cmd; + goto error; /* Dispatch the final event before we enter the following loop. Otherwise if upper layers depend on the final event we might end in a deadlock. */ @@ -1566,7 +1611,12 @@ if ((!session->waiting && pending->msgID < session->lastMessageID) || (session->waiting && pending->msgID < session->lastMessageID - 1)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Didn't receive a reply for pending status (actual message %i, received message %i, cmdID %i, msgID %i)", session->lastMessageID, session->lastReceivedMessageID, pending->cmdID, pending->msgID); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Didn't receive a reply for pending status (actual message %i, received message %i, cmdID %i, msgID %i)", + session->lastMessageID, + session->lastReceivedMessageID, + pending->cmdID, + pending->msgID); goto error; } } @@ -1585,7 +1635,8 @@ * Summary: there is a bug in this library or in the remote peer. */ if (session->incomingBuffer) { - smlErrorSet(error, SML_ERROR_GENERIC, "Incoming buffer was open when final arrived"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Incoming buffer was open when final arrived"); smlCommandUnref(session->incomingBuffer); session->incomingBuffer = NULL; goto error; @@ -1688,7 +1739,7 @@ * an error of the library or the remote * peer. */ - smlErrorSet(error, SML_ERROR_BAD_REQUEST, + g_set_error(error, SML_ERROR, SML_ERROR_BAD_REQUEST, "The message from the remote peer does not contain a command."); goto error; } @@ -1715,19 +1766,19 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - -error_free_cmd: +error: if (cmd) smlCommandUnref(cmd); -error_free_status: if (status) smlStatusUnref(status); -error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -void smlSessionSetEventCallback(SmlSession *session, SmlSessionEventCallback callback, void *userdata) +void +smlSessionSetEventCallback (SmlSession *session, + SmlSessionEventCallback callback, + void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, callback, userdata); smlAssert(session); @@ -1738,7 +1789,10 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -void smlSessionSetDataCallback(SmlSession *session, SmlSessionDataCallback callback, void *userdata) +void +smlSessionSetDataCallback (SmlSession *session, + SmlSessionDataCallback callback, + void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, callback, userdata); smlAssert(session); @@ -1749,14 +1803,17 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -const char *smlSessionGetSessionID(SmlSession *session) +const gchar* +smlSessionGetSessionID (SmlSession *session) { smlAssert(session); return session->sessionID; } -void smlSessionSetSessionID(SmlSession *session, const char *sessionID) +void +smlSessionSetSessionID (SmlSession *session, + const gchar *sessionID) { smlAssert(session); @@ -1765,26 +1822,31 @@ session->sessionID = g_strdup(sessionID); } -SmlProtocolVersion smlSessionGetVersion(SmlSession *session) +SmlProtocolVersion +smlSessionGetVersion (SmlSession *session) { smlAssert(session); return session->version; } -SmlLocation *smlSessionGetSource(SmlSession *session) +SmlLocation* +smlSessionGetSource (SmlSession *session) { smlAssert(session); return session->source; } -SmlLocation *smlSessionGetTarget(SmlSession *session) +SmlLocation* +smlSessionGetTarget (SmlSession *session) { smlAssert(session); return session->target; } -void smlSessionRegisterCred(SmlSession *session, SmlCred *cred) +void +smlSessionRegisterCred (SmlSession *session, + SmlCred *cred) { smlAssert(session); smlAssert(session->sessionType == SML_SESSION_TYPE_CLIENT); @@ -1837,7 +1899,16 @@ * @returns The new session or NULL if an error occured * */ -SmlSession *smlSessionNew(SmlSessionType sessionType, SmlMimeType mimetype, SmlProtocolVersion version, SmlProtocolType protocol, SmlLocation *target, SmlLocation *source, const char *sessionID, unsigned int messageID, SmlError **error) +SmlSession* +smlSessionNew (SmlSessionType sessionType, + SmlMimeType mimetype, + SmlProtocolVersion version, + SmlProtocolType protocol, + SmlLocation *target, + SmlLocation *source, + const gchar *sessionID, + guint messageID, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%i, %i, %i, %i, %p, %p, %s, %i, %p)", __func__, sessionType, mimetype, version, protocol, target, source, VA_STRING(sessionID), messageID, error); CHECK_ERROR_REF @@ -1886,11 +1957,11 @@ * from this session */ session->assembler = smlAssemblerNew(mimetype, 0, error); if (!session->assembler) - goto error_free_session; + goto error; smlAssemblerSetOption(session->assembler, "USE_STRTABLE", "1"); if (!smlAssemblerStart(session->assembler, session, error)) - goto error_free_session; + goto error; /* Do not call smlAssemblerAddHeader here. It is nice to know * if the header is is too large for the maximum message size @@ -1902,20 +1973,20 @@ session->command_queue = smlQueueNew(error); if (!session->command_queue) - goto error_free_session; + goto error; smlQueueSetHandler(session->command_queue, (SmlQueueHandler)_smlSessionCommandHandler, session); smlTrace(TRACE_EXIT, "%s: %p", __func__, session); return session; - -error_free_session: - smlSessionUnref(session); error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + if (session) + smlSessionUnref(session); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -SmlSession *smlSessionRef(SmlSession *session) +SmlSession* +smlSessionRef (SmlSession *session) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, session); smlAssert(session); @@ -1926,7 +1997,8 @@ return session; } -void smlSessionUnref(SmlSession *session) +void +smlSessionUnref (SmlSession *session) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, session); smlAssert(session); @@ -2015,7 +2087,10 @@ * @return TRUE if successful, FALSE otherwise * */ -SmlBool smlSessionFlush(SmlSession *session, SmlBool final, SmlError **error) +gboolean +smlSessionFlush (SmlSession *session, + gboolean final, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, session, final, error); smlAssert(session); @@ -2038,9 +2113,8 @@ 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; } @@ -2062,7 +2136,9 @@ * @return TRUE if successful, FALSE otherwise * */ -SmlBool smlSessionEnd(SmlSession *session, SmlError **error) +gboolean +smlSessionEnd (SmlSession *session, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, session, error); smlAssert(session); @@ -2124,15 +2200,15 @@ g_mutex_unlock(session->reportEnd); smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: g_mutex_unlock(session->reportEnd); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } /* This is for the client side of ResponseURI support. */ -void smlSessionRestoreTargetURI(SmlSession *session) +void +smlSessionRestoreTargetURI (SmlSession *session) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, session); smlAssert(session); @@ -2155,10 +2231,10 @@ } /* This is for the server side of ResponseURI support. */ -SmlBool smlSessionSetResponseURI( - SmlSession *session, - const char *responseURI, - SmlError **error) +gboolean +smlSessionSetResponseURI (SmlSession *session, + const gchar *responseURI, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %s, %p)", __func__, session, VA_STRING(responseURI), error); CHECK_ERROR_REF @@ -2175,7 +2251,9 @@ return TRUE; } -void smlSessionUseStringTable(SmlSession *session, SmlBool useStringtable) +void +smlSessionUseStringTable (SmlSession *session, + gboolean useStringtable) { smlTrace(TRACE_ENTRY, "%s(%p, %i)", __func__, session, useStringtable); smlAssert(session); @@ -2185,7 +2263,9 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -void smlSessionUseNumberOfChanges(SmlSession *session, SmlBool support) +void +smlSessionUseNumberOfChanges (SmlSession *session, + gboolean support) { smlTrace(TRACE_ENTRY, "%s(%p, %i)", __func__, session, support); smlAssert(session); @@ -2195,7 +2275,9 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -void smlSessionUseLargeObjects(SmlSession *session, SmlBool support) +void +smlSessionUseLargeObjects (SmlSession *session, + gboolean support) { smlTrace(TRACE_ENTRY, "%s(%p, %i)", __func__, session, support); smlAssert(session); @@ -2205,7 +2287,9 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -void smlSessionUseOnlyReplace(SmlSession *session, SmlBool onlyReplace) +void +smlSessionUseOnlyReplace (SmlSession *session, + gboolean onlyReplace) { smlTrace(TRACE_ENTRY, "%s(%p, %i)", __func__, session, onlyReplace); smlAssert(session); @@ -2216,43 +2300,9 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -/* FIXME: DEPRECATED */ -void smlSessionSetSendingLimit(SmlSession *session, unsigned int limit) -{ - smlSessionSetRemoteMaxMsgSize(session, limit); -} - -/* FIXME: DEPRECATED */ -unsigned int smlSessionGetSendingLimit(SmlSession *session) -{ - return smlSessionGetRemoteMaxMsgSize(session); -} - -/* FIXME: DEPRECATED */ -void smlSessionSetReceivingLimit(SmlSession *session, unsigned int limit) -{ - smlSessionSetLocalMaxMsgSize(session, limit); -} - -/* FIXME: DEPRECATED */ -void smlSessionSetSendingMaxMsgSize(SmlSession *session, unsigned int size) -{ - smlSessionSetRemoteMaxMsgSize(session, size); -} - -/* FIXME: DEPRECATED */ -unsigned int smlSessionGetSendingMaxMsgSize(SmlSession *session) -{ - return smlSessionGetRemoteMaxMsgSize(session); -} - -/* FIXME: DEPRECATED */ -void smlSessionSetReceivingMaxMsgSize(SmlSession *session, unsigned int size) -{ - smlSessionSetLocalMaxMsgSize(session, size); -} - -void smlSessionSetRemoteMaxMsgSize(SmlSession *session, unsigned int size) +void +smlSessionSetRemoteMaxMsgSize (SmlSession *session, + gsize size) { smlTrace(TRACE_ENTRY, "%s(%p, %u)", __func__, session, size); smlAssert(session); @@ -2262,13 +2312,16 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -unsigned int smlSessionGetRemoteMaxMsgSize(SmlSession *session) +gsize +smlSessionGetRemoteMaxMsgSize (SmlSession *session) { smlAssert(session); return smlAssemblerGetRemoteMaxMsgSize(session->assembler); } -void smlSessionSetLocalMaxMsgSize(SmlSession *session, unsigned int size) +void +smlSessionSetLocalMaxMsgSize (SmlSession *session, + gsize size) { smlTrace(TRACE_ENTRY, "%s(%p, %u)", __func__, session, size); smlAssert(session); @@ -2284,42 +2337,13 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -unsigned int smlSessionGetLocalMaxMsgSize(SmlSession *session) +gsize +smlSessionGetLocalMaxMsgSize (SmlSession *session) { smlAssert(session); return session->localMaxMsgSize; } -/* FIXME: DEPRECATED */ -void smlSessionSetSendingMaxObjSize(SmlSession *session, int limit) -{ - smlSessionSetRemoteMaxObjSize(session, limit); -} - -/* FIXME: DEPRECATED */ -void smlSessionSetRequestedMaxObjSize(SmlSession *session, int limit) -{ - smlSessionSetRemoteMaxObjSize(session, limit); -} - -/* FIXME: DEPRECATED */ -int smlSessionGetSendingMaxObjSize(SmlSession *session) -{ - return smlSessionGetRemoteMaxObjSize(session); -} - -/* FIXME: DEPRECATED */ -void smlSessionSetReceivingMaxObjSize(SmlSession *session, unsigned int limit) -{ - smlSessionSetLocalMaxObjSize(session, limit); -} - -/* FIXME: DEPRECATED */ -unsigned int smlSessionGetReceivingMaxObjSize(SmlSession *session) -{ - return smlSessionGetLocalMaxObjSize(session); -} - /** Sets the maximum obj size for the remote peer. * If we try to send an item to the remote * side which is larger than this limit we return an error @@ -2330,7 +2354,9 @@ * > 0 means that a limit is set * * */ -void smlSessionSetRemoteMaxObjSize(SmlSession *session, unsigned int limit) +void +smlSessionSetRemoteMaxObjSize (SmlSession *session, + gsize limit) { smlTrace(TRACE_ENTRY, "%s(%p, %i)", __func__, session, limit); smlAssert(session); @@ -2344,7 +2370,8 @@ * requested limit are set, this function will return the smaller one of both. * * Otherwise it will return the larger number. */ -unsigned int smlSessionGetRemoteMaxObjSize(SmlSession *session) +gsize +smlSessionGetRemoteMaxObjSize (SmlSession *session) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, session); smlAssert(session); @@ -2368,7 +2395,9 @@ * limit is violated) * * */ -void smlSessionSetLocalMaxObjSize(SmlSession *session, unsigned int limit) +void +smlSessionSetLocalMaxObjSize (SmlSession *session, + gsize limit) { smlTrace(TRACE_ENTRY, "%s(%p, %u)", __func__, session, limit); smlAssert(session); @@ -2401,7 +2430,8 @@ smlTrace(TRACE_EXIT, "%s => %d", __func__, session->localMaxObjSize); } -unsigned int smlSessionGetLocalMaxObjSize(SmlSession *session) +gsize +smlSessionGetLocalMaxObjSize (SmlSession *session) { smlAssert(session); return session->localMaxObjSize; @@ -2427,7 +2457,13 @@ * @return TRUE if successful, FALSE otherwise * */ -SmlBool smlSessionSendCommand(SmlSession *session, SmlCommand *cmd, SmlCommand *parent, SmlStatusReplyCb callback, void *userdata, SmlError **error) +gboolean +smlSessionSendCommand (SmlSession *session, + SmlCommand *cmd, + SmlCommand *parent, + SmlStatusReplyCb callback, + void *userdata, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %p, %p)", __func__, session, cmd, parent, callback, userdata, error); smlAssert(session); @@ -2442,9 +2478,8 @@ 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; } @@ -2459,7 +2494,13 @@ * @return TRUE if successful, FALSE otherwise * */ -SmlBool smlSessionStartCommand(SmlSession *session, SmlCommand *cmd, SmlCommand *parent, SmlStatusReplyCb callback, void *userdata, SmlError **error) +gboolean +smlSessionStartCommand (SmlSession *session, + SmlCommand *cmd, + SmlCommand *parent, + SmlStatusReplyCb callback, + void *userdata, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %p, %p)", __func__, session, cmd, parent, callback, userdata, error); smlAssert(session); @@ -2486,9 +2527,8 @@ 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; } @@ -2500,7 +2540,10 @@ * @return TRUE if successful, FALSE otherwise * */ -SmlBool smlSessionEndCommand(SmlSession *session, SmlCommand *parent, SmlError **error) +gboolean +smlSessionEndCommand (SmlSession *session, + SmlCommand *parent, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, parent, error); smlAssert(session); @@ -2521,9 +2564,8 @@ 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; } @@ -2541,7 +2583,10 @@ * @return TRUE if successful, FALSE otherwise * */ -SmlBool smlSessionSendReply(SmlSession *session, SmlStatus *status, SmlError **error) +gboolean +smlSessionSendReply (SmlSession *session, + SmlStatus *status, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, status, error); smlAssert(session); @@ -2560,9 +2605,8 @@ 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; } Modified: trunk/libsyncml/sml_session.h ============================================================================== --- trunk/libsyncml/sml_session.h Fri Jul 3 15:10:54 2009 (r1148) +++ trunk/libsyncml/sml_session.h Fri Jul 3 16:13:03 2009 (r1149) @@ -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 @@ -41,72 +41,55 @@ } SmlSessionEventType; typedef void (* SmlSessionEventCallback) (SmlSession *session, SmlSessionEventType type, SmlCommand *command, SmlCommand *parent, SmlStatus *reply, const GError *error, void *userdata); -typedef void (* SmlSessionDataCallback) (SmlSession *session, SmlTransportData *data, void *userdata); +typedef void (* SmlSessionDataCallback) (SmlSession *session, SmlTransportData *data, void *userdata); /* Session Management */ -SmlSession *smlSessionNew(SmlSessionType sessionType, SmlMimeType mimetype, SmlProtocolVersion version, SmlProtocolType protocol, SmlLocation *target, SmlLocation *source, const char *sessionID, unsigned int messageID, GError **error); -SmlSession *smlSessionRef(SmlSession *session); -void smlSessionUnref(SmlSession *session); -void smlSessionSetEventCallback(SmlSession *session, SmlSessionEventCallback callback, void *userdata); -void smlSessionSetDataCallback(SmlSession *session, SmlSessionDataCallback callback, void *userdata); +SmlSession* smlSessionNew (SmlSessionType sessionType, SmlMimeType mimetype, SmlProtocolVersion version, SmlProtocolType protocol, SmlLocation *target, SmlLocation *source, const gchar *sessionID, guint messageID, GError **error); +SmlSession* smlSessionRef (SmlSession *session); +void smlSessionUnref (SmlSession *session); +void smlSessionSetEventCallback (SmlSession *session, SmlSessionEventCallback callback, void *userdata); +void smlSessionSetDataCallback (SmlSession *session, SmlSessionDataCallback callback, void *userdata); /* Session Control */ -SmlBool smlSessionFlush(SmlSession *session, SmlBool final, SmlError **error); -SmlBool smlSessionEnd(SmlSession *session, SmlError **error); -void smlSessionUseStringTable(SmlSession *session, SmlBool useStringtable); -void smlSessionUseOnlyReplace(SmlSession *session, SmlBool onlyReplace); -void smlSessionUseNumberOfChanges(SmlSession *session, SmlBool support); -void smlSessionUseLargeObjects(SmlSession *session, SmlBool support); - -void smlSessionSetRemoteMaxMsgSize(SmlSession *session, unsigned int size); -void smlSessionSetLocalMaxMsgSize(SmlSession *session, unsigned int size); -unsigned int smlSessionGetRemoteMaxMsgSize(SmlSession *session); -unsigned int smlSessionGetLocalMaxMsgSize(SmlSession *session); - -void smlSessionSetLocalMaxObjSize(SmlSession *session, unsigned int limit); -void smlSessionSetRemoteMaxObjSize(SmlSession *session, unsigned int limit); -unsigned int smlSessionGetLocalMaxObjSize(SmlSession *session); -unsigned int smlSessionGetRemoteMaxObjSize(SmlSession *session); - -const char *smlSessionGetSessionID(SmlSession *session); -void smlSessionSetSessionID(SmlSession *session, const char *sessionID); -SmlProtocolVersion smlSessionGetVersion(SmlSession *session); -void smlSessionDispatchEvent(SmlSession *session, SmlSessionEventType type, SmlCommand *cmd, SmlCommand *parent, SmlStatus *headerreply, SmlError *error); -SmlLocation *smlSessionGetSource(SmlSession *session); -SmlLocation *smlSessionGetTarget(SmlSession *session); +gboolean smlSessionFlush (SmlSession *session, gboolean final, GError **error); +gboolean smlSessionEnd (SmlSession *session, GError **error); +void smlSessionUseStringTable (SmlSession *session, gboolean useStringtable); +void smlSessionUseOnlyReplace (SmlSession *session, gboolean onlyReplace); +void smlSessionUseNumberOfChanges (SmlSession *session, gboolean support); +void smlSessionUseLargeObjects (SmlSession *session, gboolean support); + +void smlSessionSetRemoteMaxMsgSize (SmlSession *session, gsize size); +void smlSessionSetLocalMaxMsgSize (SmlSession *session, gsize size); +gsize smlSessionGetRemoteMaxMsgSize (SmlSession *session); +gsize smlSessionGetLocalMaxMsgSize (SmlSession *session); + +void smlSessionSetLocalMaxObjSize (SmlSession *session, gsize limit); +void smlSessionSetRemoteMaxObjSize (SmlSession *session, gsize limit); +gsize smlSessionGetLocalMaxObjSize (SmlSession *session); +gsize smlSessionGetRemoteMaxObjSize (SmlSession *session); + +const gchar* smlSessionGetSessionID (SmlSession *session); +void smlSessionSetSessionID (SmlSession *session, const gchar *sessionID); +SmlProtocolVersion smlSessionGetVersion (SmlSession *session); +void smlSessionDispatchEvent (SmlSession *session, SmlSessionEventType type, SmlCommand *cmd, SmlCommand *parent, SmlStatus *headerreply, const GError *error); +SmlLocation* smlSessionGetSource (SmlSession *session); +SmlLocation* smlSessionGetTarget (SmlSession *session); /* This function MUST NOT be used for servers. * This function is only used to set the credentials for a client. */ -void smlSessionRegisterCred(SmlSession *session, SmlCred *cred); +void smlSessionRegisterCred (SmlSession *session, SmlCred *cred); /* Session Data input */ -SmlBool smlSessionReceiveHeader(SmlSession *session, SmlHeader *header, GError **error); -SmlBool smlSessionReceiveBody(SmlSession *session, SmlParser *parser, GError **error); +gboolean smlSessionReceiveHeader (SmlSession *session, SmlHeader *header, GError **error); +gboolean smlSessionReceiveBody (SmlSession *session, SmlParser *parser, GError **error); /* Session Command input */ -SmlBool smlSessionSendCommand(SmlSession *session, SmlCommand *cmd, SmlCommand *parent, SmlStatusReplyCb callback, void *userdata, SmlError **error); -SmlBool smlSessionStartCommand(SmlSession *session, SmlCommand *cmd, SmlCommand *parent, SmlStatusReplyCb callback, void *userdata, SmlError **error); -SmlBool smlSessionEndCommand(SmlSession *session, SmlCommand *parent, SmlError **error); -SmlBool smlSessionSendReply(SmlSession *session, SmlStatus *status, GError **error); - -SmlBool smlSessionCheck(SmlSession *session); -void smlSessionDispatch(SmlSession *session); - -/* expire date: 20090120 */ -void smlSessionSetSendingLimit(SmlSession *session, unsigned int limit) LIBSYNCML_DEPRECATED; -void smlSessionSetReceivingLimit(SmlSession *session, unsigned int limit) LIBSYNCML_DEPRECATED; -unsigned int smlSessionGetSendingLimit(SmlSession *session) LIBSYNCML_DEPRECATED; - -/* expire date: 20090626 */ -void smlSessionSetSendingMaxMsgSize(SmlSession *session, unsigned int size) LIBSYNCML_DEPRECATED; -void smlSessionSetReceivingMaxMsgSize(SmlSession *session, unsigned int size) LIBSYNCML_DEPRECATED; -unsigned int smlSessionGetSendingMaxMsgSize(SmlSession *session) LIBSYNCML_DEPRECATED; - -/* expire date: 20090626 */ -void smlSessionSetSendingMaxObjSize(SmlSession *session, int limit) LIBSYNCML_DEPRECATED; -void smlSessionSetRequestedMaxObjSize(SmlSession *session, int limit) LIBSYNCML_DEPRECATED; -int smlSessionGetSendingMaxObjSize(SmlSession *session) LIBSYNCML_DEPRECATED; -void smlSessionSetReceivingMaxObjSize(SmlSession *session, unsigned int limit) LIBSYNCML_DEPRECATED; -unsigned int smlSessionGetReceivingMaxObjSize(SmlSession *session) LIBSYNCML_DEPRECATED; +gboolean smlSessionSendCommand (SmlSession *session, SmlCommand *cmd, SmlCommand *parent, SmlStatusReplyCb callback, void *userdata, GError **error); +gboolean smlSessionStartCommand (SmlSession *session, SmlCommand *cmd, SmlCommand *parent, SmlStatusReplyCb callback, void *userdata, GError **error); +gboolean smlSessionEndCommand (SmlSession *session, SmlCommand *parent, GError **error); +gboolean smlSessionSendReply (SmlSession *session, SmlStatus *status, GError **error); + +gboolean smlSessionCheck (SmlSession *session); +void smlSessionDispatch (SmlSession *session); #endif //_SML_SESSION_H_ Modified: trunk/libsyncml/sml_session_internals.h ============================================================================== --- trunk/libsyncml/sml_session_internals.h Fri Jul 3 15:10:54 2009 (r1148) +++ trunk/libsyncml/sml_session_internals.h Fri Jul 3 16:13:03 2009 (r1149) @@ -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 @@ -38,12 +38,12 @@ SmlSessionDataCallback dataCallback; void *dataCallbackUserdata; - char *sessionID; + gchar *sessionID; SmlLocation *target; SmlLocation *orgTarget; SmlLocation *source; - char *responseURI; + gchar *responseURI; SmlChal *chal; SmlCred *cred; @@ -51,32 +51,32 @@ * These are the limits which are send to the remote peer * but they are not the remote limits. */ - unsigned int localMaxMsgSize; - unsigned int localMaxObjSize; + gsize localMaxMsgSize; + gsize localMaxObjSize; GList *pendingReplies; - unsigned long lastMessageID; - unsigned long lastReceivedMessageID; - unsigned long lastCommandID; + guint lastMessageID; + guint lastReceivedMessageID; + guint lastCommandID; GList *commands; - SmlBool final; - SmlBool authenticate; - SmlBool established; + gboolean final; + gboolean authenticate; + gboolean established; SmlMimeType type; SmlQueue *command_queue; - SmlBool waiting; - SmlBool sending; + gboolean waiting; + gboolean sending; GList *commandStack; - SmlBool hasCommand; - SmlBool assmHasHeader; + gboolean hasCommand; + gboolean assmHasHeader; - SmlBool end; + gboolean end; GMutex *reportEnd; - SmlBool reportedEnd; + gboolean reportedEnd; SmlCommand *parentCommand; @@ -88,29 +88,26 @@ SmlCommand *frag_command; /* How much of the item of the frag_command already * got sent */ - unsigned int frag_size; + gsize frag_size; SmlStatusReplyCb frag_callback; void *frag_userdata; - SmlBool active; + gboolean active; GMutex *dispatch_mutex; }; struct SmlPendingStatus { - unsigned int cmdID; - unsigned int msgID; + guint cmdID; + guint msgID; SmlStatusReplyCb callback; void *userdata; }; -SmlBool smlSessionTryLock(SmlSession *session); -void smlSessionLock(SmlSession *session); -void smlSessionUnlock(SmlSession *session); - -void smlSessionRestoreTargetURI(SmlSession *session); -SmlBool smlSessionSetResponseURI( - SmlSession *session, - const char *responseURI, - GError **error); +gboolean smlSessionTryLock (SmlSession *session); +void smlSessionLock (SmlSession *session); +void smlSessionUnlock (SmlSession *session); + +void smlSessionRestoreTargetURI (SmlSession *session); +gboolean smlSessionSetResponseURI (SmlSession *session, const gchar *responseURI, GError **error); #endif //_SML_SESSION_INTERNALS_H_ |