You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
(56) |
Apr
(109) |
May
(15) |
Jun
(3) |
Jul
(37) |
Aug
(96) |
Sep
(40) |
Oct
(4) |
Nov
(54) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(47) |
Feb
(30) |
Mar
(102) |
Apr
(120) |
May
(68) |
Jun
(54) |
Jul
(53) |
Aug
(122) |
Sep
(190) |
Oct
(71) |
Nov
(85) |
Dec
(108) |
2007 |
Jan
(72) |
Feb
(190) |
Mar
(53) |
Apr
(101) |
May
(145) |
Jun
(148) |
Jul
(167) |
Aug
(143) |
Sep
(23) |
Oct
(198) |
Nov
(223) |
Dec
(195) |
2008 |
Jan
(100) |
Feb
(129) |
Mar
(79) |
Apr
(77) |
May
(34) |
Jun
(95) |
Jul
(112) |
Aug
(160) |
Sep
(82) |
Oct
(124) |
Nov
(199) |
Dec
(355) |
2009 |
Jan
(436) |
Feb
(89) |
Mar
(298) |
Apr
(189) |
May
(33) |
Jun
(88) |
Jul
(105) |
Aug
(44) |
Sep
(181) |
Oct
(87) |
Nov
(75) |
Dec
(1) |
2010 |
Jan
(63) |
Feb
(21) |
Mar
(3) |
Apr
(1) |
May
(1) |
Jun
(3) |
Jul
(26) |
Aug
(37) |
Sep
(26) |
Oct
(15) |
Nov
(13) |
Dec
|
From: <svn...@op...> - 2009-07-08 09:20:03
|
Author: bellmich Date: Wed Jul 8 11:19:54 2009 New Revision: 1156 URL: http://libsyncml.opensync.org/changeset/1156 Log: migrated objects/sml_devinf_obj from SmlError to GError Modified: trunk/libsyncml/objects/sml_devinf_obj.c trunk/libsyncml/objects/sml_devinf_obj.h trunk/libsyncml/objects/sml_devinf_obj_internals.h Modified: trunk/libsyncml/objects/sml_devinf_obj.c ============================================================================== --- trunk/libsyncml/objects/sml_devinf_obj.c Tue Jul 7 16:59:09 2009 (r1155) +++ trunk/libsyncml/objects/sml_devinf_obj.c Wed Jul 8 11:19:54 2009 (r1156) @@ -48,10 +48,10 @@ /* functions to manage SmlDevInfAgentSession */ -static SmlDevInfAgentSession* _new_session( - SmlDevInfAgent *agent, - SmlSession *session, - SmlError **error) +static SmlDevInfAgentSession* +_new_session (SmlDevInfAgent *agent, + SmlSession *session, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, agent, session, error); @@ -70,13 +70,13 @@ return as; error: smlSafeFree((gpointer *) &as); - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return NULL; } -static SmlDevInfAgentSession* _get_session( - SmlDevInfAgent *agent, - SmlSession *session) +static SmlDevInfAgentSession* +_get_session (SmlDevInfAgent *agent, + SmlSession *session) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, agent, session); @@ -89,7 +89,8 @@ return as; } -static void _free_session (gpointer data) +static void +_free_session (gpointer data) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, data); @@ -105,10 +106,13 @@ /* functions to manage SmlDevInfAgent */ -static void _get_devinf_reply(SmlSession *session, SmlStatus *status, void *userdata) +static void +_get_devinf_reply (SmlSession *session, + SmlStatus *status, + void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, status, userdata); - SmlError *error = NULL; + GError *error = NULL; SmlDevInfAgent *agent = userdata; if (smlStatusIsResult(status)) { @@ -126,13 +130,15 @@ /* verify that it is a real result with data */ if (result->type != SML_COMMAND_TYPE_RESULTS) { - smlErrorSet(&error, SML_ERROR_GENERIC, "devinf command was not a result"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, + "devinf command was not a result"); goto error; } SmlItem *item = result->private.results.status->item; if (!item) { - smlErrorSet(&error, SML_ERROR_GENERIC, "devinf result did not have a item"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, + "devinf result did not have a item"); goto error; } @@ -163,21 +169,27 @@ smlTrace(TRACE_EXIT, "%s", __func__); return; - error: smlSessionDispatchEvent(session, SML_SESSION_EVENT_ERROR, NULL, NULL, 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 _devinf_reply(SmlSession *session, SmlStatus *status, void *userdata) +static void +_devinf_reply (SmlSession *session, + SmlStatus *status, + void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, status, userdata); smlTrace(TRACE_EXIT, "%s", __func__); } -static SmlBool _send_devinf(SmlDevInfAgent *agent, SmlSession *session, SmlCommand *get, SmlError **error) +static gboolean +_send_devinf (SmlDevInfAgent *agent, + SmlSession *session, + SmlCommand *get, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, agent, session, get, error); CHECK_ERROR_REF @@ -195,7 +207,7 @@ session->sessionType == SML_SESSION_TYPE_SERVER && !sml_dev_inf_get_support_large_objs(agent->devinf)) { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "OMA DS Server must support large object handling if SyncML 1.1 or higher is used."); goto error; } @@ -207,13 +219,13 @@ { if (smlSessionGetLocalMaxMsgSize(session) < 1) { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "If large object support is enabled then MaxMsgSize must be set."); goto error; } if (smlSessionGetLocalMaxObjSize(session) < 1) { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "If large object support is enabled then MaxObjSize must be set."); goto error; } @@ -311,17 +323,19 @@ 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 _recv_devinf(SmlSession *session, SmlCommand *cmd, void *userdata) +static void +_recv_devinf (SmlSession *session, + SmlCommand *cmd, + void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, cmd, userdata); SmlDevInfAgent *agent = userdata; - SmlError *error = NULL; + GError *error = NULL; char *data = NULL; unsigned int size = 0; @@ -352,35 +366,39 @@ smlTrace(TRACE_EXIT, "%s", __func__); return; - error: smlSessionDispatchEvent(session, SML_SESSION_EVENT_ERROR, NULL, NULL, 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 _request_devinf(SmlSession *session, SmlCommand *cmd, void *userdata) +static void +_request_devinf (SmlSession *session, + SmlCommand *cmd, + void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, cmd, userdata); SmlDevInfAgent *agent = userdata; - SmlError *error = NULL; + GError *error = NULL; if (!_send_devinf(agent, session, cmd, &error)) goto error; smlTrace(TRACE_EXIT, "%s", __func__); return; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&error)); + smlSessionDispatchEvent(session, SML_SESSION_EVENT_ERROR, NULL, NULL, NULL, error); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, error->message); + g_error_free(error); } -SmlDevInfAgent *smlDevInfAgentNew(SmlDevInf *devinf, SmlError **error) +SmlDevInfAgent* +smlDevInfAgentNew (SmlDevInf *devinf, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, devinf, error); CHECK_ERROR_REF smlAssert(devinf); - GError *gerror = NULL; SmlDevInfAgent *agent = smlTryMalloc0(sizeof(SmlDevInfAgent), error); if (!agent) @@ -389,20 +407,21 @@ agent->devinf = devinf; agent->sessions = g_hash_table_new_full(NULL, NULL, NULL, _free_session); if (!agent->sessions) { - smlErrorSet(error, SML_ERROR_INTERNAL_NO_MEMORY, "Cannot create new hash table."); + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_NO_MEMORY, + "Cannot create new hash table."); goto error; } if (!sml_dev_inf_get_man(devinf) && - !sml_dev_inf_set_man(devinf, "OpenSync", &gerror)) + !sml_dev_inf_set_man(devinf, "OpenSync", error)) goto error; if (!sml_dev_inf_get_mod(devinf) && - !sml_dev_inf_set_mod(devinf, "libsyncml", &gerror)) + !sml_dev_inf_set_mod(devinf, "libsyncml", error)) goto error; if (!sml_dev_inf_get_oem(devinf)) { #ifdef WIN32 - if (!sml_dev_inf_set_oem(devinf, "Microsoft (R)", &gerror)) + if (!sml_dev_inf_set_oem(devinf, "Microsoft (R)", error)) goto error; DWORD dwVersion = GetVersion(); DWORD dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion))); @@ -412,40 +431,36 @@ char szVersion[1024]; sprintf(szVersion, "%d.%d (%d)", dwMajorVersion, dwMinorVersion, dwBuild); - if (!sml_dev_inf_set_fwv(devinf, szVersion, &gerror)) + if (!sml_dev_inf_set_fwv(devinf, szVersion, error)) goto error; #else struct utsname *buf = malloc(sizeof(struct utsname)); if (uname(buf) == 0) { - if (!sml_dev_inf_set_oem(devinf, buf->sysname, &gerror)) + if (!sml_dev_inf_set_oem(devinf, buf->sysname, error)) goto error; - if (!sml_dev_inf_set_fwv(devinf, buf->release, &gerror)) + if (!sml_dev_inf_set_fwv(devinf, buf->release, error)) goto error; } smlSafeFree((gpointer *)&buf); #endif } if (!sml_dev_inf_get_swv(devinf) && - !sml_dev_inf_set_swv(devinf, VERSION, &gerror)) + !sml_dev_inf_set_swv(devinf, VERSION, error)) goto error; smlTrace(TRACE_EXIT, "%s: %p", __func__, agent); return agent; - error: - if (gerror) { - smlErrorSet(error, gerror->code, "%s", gerror->message); - g_error_free(gerror); - } if (agent) smlSafeFree((gpointer *) &agent); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -void smlDevInfAgentFree(SmlDevInfAgent *agent) +void +smlDevInfAgentFree (SmlDevInfAgent *agent) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, agent); smlAssert(agent); @@ -458,27 +473,12 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -/* FIXME: DEPRECATED */ -void smlDevInfAgentSetDevInf(SmlDevInfAgent *agent, SmlDevInf *devinf) -{ - smlTrace(TRACE_ERROR, "%s(%p, %p)", __func__, agent, devinf); - smlAssertMsg(NULL, "This function is a design bug."); -} - -/* FIXME: DEPRECATED */ -SmlDevInf *smlDevInfAgentGetDevInf(SmlDevInfAgent *agent) -{ - smlTrace(TRACE_ERROR, "%s(%p, %p)", __func__, agent); - smlAssertMsg(NULL, "This function is a design bug."); - return NULL; -} - /* Set the devinf of the remote peer. */ -SmlBool smlDevInfAgentSetSessionDevInf( - SmlDevInfAgent *agent, - SmlSession *session, - SmlDevInf *devinf, - SmlError **error) +gboolean +smlDevInfAgentSetSessionDevInf (SmlDevInfAgent *agent, + SmlSession *session, + SmlDevInf *devinf, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, agent, session, devinf, error); @@ -500,12 +500,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; } /* Get the devinf that was sent in the session. Returns FALSE if no devinf was received yet. */ -SmlDevInf *smlDevInfAgentGetSessionDevInf(SmlDevInfAgent *agent, SmlSession *session) +SmlDevInf* +smlDevInfAgentGetSessionDevInf (SmlDevInfAgent *agent, + SmlSession *session) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, agent, session); @@ -525,7 +527,10 @@ } /** Issues a put request on the session if needed */ -SmlBool smlDevInfAgentSendDevInf(SmlDevInfAgent *agent, SmlSession *session, SmlError **error) +gboolean +smlDevInfAgentSendDevInf (SmlDevInfAgent *agent, + SmlSession *session, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, agent, session, error); CHECK_ERROR_REF @@ -536,14 +541,16 @@ 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; } /** Issues a Get request for the devinf on the session if needed */ -SmlBool smlDevInfAgentRequestDevInf(SmlDevInfAgent *agent, SmlSession *session, SmlError **error) +gboolean +smlDevInfAgentRequestDevInf (SmlDevInfAgent *agent, + SmlSession *session, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, agent, session, error); CHECK_ERROR_REF @@ -588,33 +595,35 @@ 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 smlDevInfAgentRegisterSession(SmlDevInfAgent *agent, SmlManager *manager, SmlSession *session, SmlError **error) +gboolean +smlDevInfAgentRegisterSession (SmlDevInfAgent *agent, + SmlManager *manager, + SmlSession *session, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, agent, manager, session, error); CHECK_ERROR_REF smlAssert(agent); smlAssert(manager); - GError *gerror = NULL; SmlLocation *devinf10 = NULL; SmlLocation *devinf11 = NULL; SmlLocation *devinf12 = NULL; - devinf12 = sml_location_new_with_options("./devinf12", NULL, &gerror); + devinf12 = sml_location_new_with_options("./devinf12", NULL, error); if (!devinf12) goto error; - devinf11 = sml_location_new_with_options("./devinf11", NULL, &gerror); + devinf11 = sml_location_new_with_options("./devinf11", NULL, error); if (!devinf12) goto error; - devinf10 = sml_location_new_with_options("./devinf10", NULL, &gerror); + devinf10 = sml_location_new_with_options("./devinf10", NULL, error); if (!devinf12) goto error; @@ -732,7 +741,6 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: if (devinf10) g_object_unref(devinf10); @@ -740,26 +748,27 @@ g_object_unref(devinf11); if (devinf12) g_object_unref(devinf12); - 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 smlDevInfAgentRegister(SmlDevInfAgent *agent, SmlManager *manager, SmlError **error) +gboolean +smlDevInfAgentRegister (SmlDevInfAgent *agent, + SmlManager *manager, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, agent, manager, error); CHECK_ERROR_REF - SmlBool retval = smlDevInfAgentRegisterSession(agent, manager, NULL, error); + gboolean retval = smlDevInfAgentRegisterSession(agent, manager, NULL, error); if (!retval) 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; } Modified: trunk/libsyncml/objects/sml_devinf_obj.h ============================================================================== --- trunk/libsyncml/objects/sml_devinf_obj.h Tue Jul 7 16:59:09 2009 (r1155) +++ trunk/libsyncml/objects/sml_devinf_obj.h Wed Jul 8 11:19:54 2009 (r1156) @@ -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 @@ -35,23 +35,15 @@ // only the SmlDevInf pointer of smlDevInfAgentNew is the local DevInf // all other SmlDevInf pointers are the DevInf of the remote peer -SmlDevInfAgent *smlDevInfAgentNew(SmlDevInf *devinf, GError **error); -void smlDevInfAgentFree(SmlDevInfAgent *agent); -gboolean smlDevInfAgentRegisterSession(SmlDevInfAgent *agent, SmlManager *manager, SmlSession *session, GError **error); -gboolean smlDevInfAgentRegister(SmlDevInfAgent *agent, SmlManager *manager, GError **error); -gboolean smlDevInfAgentSendDevInf(SmlDevInfAgent *agent, SmlSession *session, GError **error); -gboolean smlDevInfAgentRequestDevInf(SmlDevInfAgent *agent, SmlSession *session, GError **error); - -gboolean smlDevInfAgentSetSessionDevInf(SmlDevInfAgent *agent, SmlSession *session, SmlDevInf *devinf, GError **error); -SmlDevInf *smlDevInfAgentGetSessionDevInf(SmlDevInfAgent *agent, SmlSession *session); - -/* These functions can only work in a single session environemnt. - * This is a design bug. The functions are not removed immediately - * to avoid breaking applications which ignore the device information. - * These functions always fire an assertion. - */ -void smlDevInfAgentSetDevInf(SmlDevInfAgent *agent, SmlDevInf *devinf) LIBSYNCML_DEPRECATED; -SmlDevInf *smlDevInfAgentGetDevInf(SmlDevInfAgent *agent) LIBSYNCML_DEPRECATED; +SmlDevInfAgent* smlDevInfAgentNew (SmlDevInf *devinf, GError **error); +void smlDevInfAgentFree (SmlDevInfAgent *agent); +gboolean smlDevInfAgentRegisterSession (SmlDevInfAgent *agent, SmlManager *manager, SmlSession *session, GError **error); +gboolean smlDevInfAgentRegister (SmlDevInfAgent *agent, SmlManager *manager, GError **error); +gboolean smlDevInfAgentSendDevInf (SmlDevInfAgent *agent, SmlSession *session, GError **error); +gboolean smlDevInfAgentRequestDevInf (SmlDevInfAgent *agent, SmlSession *session, GError **error); + +gboolean smlDevInfAgentSetSessionDevInf (SmlDevInfAgent *agent, SmlSession *session, SmlDevInf *devinf, GError **error); +SmlDevInf* smlDevInfAgentGetSessionDevInf (SmlDevInfAgent *agent, SmlSession *session); #endif //_SML_DEVINF_OBJ_H_ /*@}*/ Modified: trunk/libsyncml/objects/sml_devinf_obj_internals.h ============================================================================== --- trunk/libsyncml/objects/sml_devinf_obj_internals.h Tue Jul 7 16:59:09 2009 (r1155) +++ trunk/libsyncml/objects/sml_devinf_obj_internals.h Wed Jul 8 11:19:54 2009 (r1156) @@ -1,6 +1,7 @@ /* * libsyncml - A syncml protocol implementation * Copyright (C) 2005 Armin Bauer <arm...@op...> + * Copyright (C) 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 @@ -31,8 +32,8 @@ typedef struct SmlDevInfAgentSession { /* states */ - SmlBool devinfSent; - SmlBool devinfRequested; + gboolean devinfSent; + gboolean devinfRequested; /* remote device information */ SmlDevInf *recvDevInf; |
From: <svn...@op...> - 2009-07-08 09:13:17
|
Author: dgollub Date: Wed Jul 8 11:13:11 2009 New Revision: 5697 URL: http://www.opensync.org/changeset/5697 Log: Fixed outstanding compiler warnings (with BUILD_TYPE=Hacking) of unused variables in various places. Modified: branches/opensync-ticket1084/opensync/engine/opensync_obj_engine.c branches/opensync-ticket1084/opensync/group/opensync_member.c Modified: branches/opensync-ticket1084/opensync/engine/opensync_obj_engine.c ============================================================================== --- branches/opensync-ticket1084/opensync/engine/opensync_obj_engine.c Wed Jul 8 11:11:08 2009 (r5696) +++ branches/opensync-ticket1084/opensync/engine/opensync_obj_engine.c Wed Jul 8 11:13:11 2009 (r5697) @@ -205,7 +205,6 @@ { OSyncList *m = NULL; OSyncList *e = NULL; - osync_bool found_similar = FALSE; OSyncConvCmpResult result = OSYNC_CONV_DATA_MISMATCH; osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, mapping_engines, change, sinkengine, mapping_engine); Modified: branches/opensync-ticket1084/opensync/group/opensync_member.c ============================================================================== --- branches/opensync-ticket1084/opensync/group/opensync_member.c Wed Jul 8 11:11:08 2009 (r5696) +++ branches/opensync-ticket1084/opensync/group/opensync_member.c Wed Jul 8 11:13:11 2009 (r5697) @@ -987,7 +987,6 @@ { char *filename; OSyncCapabilities *capabilities; - osync_bool res; osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, member, error); osync_assert(member); |
From: <svn...@op...> - 2009-07-08 09:11:20
|
Author: dgollub Date: Wed Jul 8 11:11:08 2009 New Revision: 5696 URL: http://www.opensync.org/changeset/5696 Log: Fixed compiler warning about signedess issue, due to API change of osync_capabilities_assemble() which changed from int* to unsigned int* for the size parameter. Modified: branches/opensync-ticket1084/opensync/client/opensync_client.c Modified: branches/opensync-ticket1084/opensync/client/opensync_client.c ============================================================================== --- branches/opensync-ticket1084/opensync/client/opensync_client.c Wed Jul 8 11:10:35 2009 (r5695) +++ branches/opensync-ticket1084/opensync/client/opensync_client.c Wed Jul 8 11:11:08 2009 (r5696) @@ -37,6 +37,7 @@ #include "opensync-format.h" #include "opensync-capabilities.h" +#include "capabilities/opensync_capabilities_internals.h" #include "opensync-version.h" #include "version/opensync_version_internals.h" @@ -833,7 +834,7 @@ OSyncVersion *version = NULL; OSyncCapabilities *capabilities = NULL; char* buffer = NULL; - int size = 0; + unsigned int size = 0; unsigned int num_res = 0; OSyncPluginResource *resource = NULL; OSyncList *objtypesinks = NULL; |
From: <svn...@op...> - 2009-07-08 09:10:41
|
Author: dgollub Date: Wed Jul 8 11:10:35 2009 New Revision: 5695 URL: http://www.opensync.org/changeset/5695 Log: Added and exported missing declartions/symbols of osync_capability_{,un}ref() Fixed compiler warnings about unused variables, goto statments. Modified: branches/opensync-ticket1084/opensync.sym branches/opensync-ticket1084/opensync/capabilities/opensync_capability.c branches/opensync-ticket1084/opensync/capabilities/opensync_capability.h branches/opensync-ticket1084/opensync/capabilities/opensync_capability_internals.h Modified: branches/opensync-ticket1084/opensync.sym ============================================================================== --- branches/opensync-ticket1084/opensync.sym Wed Jul 8 11:05:24 2009 (r5694) +++ branches/opensync-ticket1084/opensync.sym Wed Jul 8 11:10:35 2009 (r5695) @@ -1,10 +1,10 @@ osync_capabilities_get_format -osync_capabilities_objtype_ref -osync_capabilities_objtype_unref osync_capabilities_get_objtype osync_capabilities_new osync_capabilities_objtype_get_caps osync_capabilities_objtype_new +osync_capabilities_objtype_ref +osync_capabilities_objtype_unref osync_capabilities_ref osync_capabilities_unref osync_capability_get_displayname @@ -16,6 +16,7 @@ osync_capability_get_type osync_capability_get_valenums osync_capability_new +osync_capability_ref osync_capability_set_displayname osync_capability_set_max osync_capability_set_maxoccurs @@ -23,6 +24,7 @@ osync_capability_set_name osync_capability_set_parameter osync_capability_set_type +osync_capability_unref osync_change_compare osync_change_get_changetype osync_change_get_data Modified: branches/opensync-ticket1084/opensync/capabilities/opensync_capability.c ============================================================================== --- branches/opensync-ticket1084/opensync/capabilities/opensync_capability.c Wed Jul 8 11:05:24 2009 (r5694) +++ branches/opensync-ticket1084/opensync/capabilities/opensync_capability.c Wed Jul 8 11:10:35 2009 (r5695) @@ -146,14 +146,15 @@ error_oom: osync_error_set(error, OSYNC_ERROR_GENERIC, "No memory left to assemble capability."); +/* error: +*/ osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error)); return FALSE; } OSyncCapability *osync_capability_new(OSyncCapabilitiesObjType *capobjtype, OSyncError **error) { - OSyncList *l; OSyncCapability *capability = NULL; osync_trace(TRACE_ENTRY, "%s(%p, %s, %p)", __func__, capobjtype, error); osync_assert(capobjtype); Modified: branches/opensync-ticket1084/opensync/capabilities/opensync_capability.h ============================================================================== --- branches/opensync-ticket1084/opensync/capabilities/opensync_capability.h Wed Jul 8 11:05:24 2009 (r5694) +++ branches/opensync-ticket1084/opensync/capabilities/opensync_capability.h Wed Jul 8 11:10:35 2009 (r5695) @@ -68,6 +68,9 @@ */ OSYNC_EXPORT OSyncCapability *osync_capability_new(OSyncCapabilitiesObjType* capobjtype, OSyncError **error); +OSYNC_EXPORT OSyncCapability *osync_capability_ref(OSyncCapability *capability); +OSYNC_EXPORT void osync_capability_unref(OSyncCapability *capability); + /** * @brief Get the name of the capability * @param capability The pointer to a capability object Modified: branches/opensync-ticket1084/opensync/capabilities/opensync_capability_internals.h ============================================================================== --- branches/opensync-ticket1084/opensync/capabilities/opensync_capability_internals.h Wed Jul 8 11:05:24 2009 (r5694) +++ branches/opensync-ticket1084/opensync/capabilities/opensync_capability_internals.h Wed Jul 8 11:10:35 2009 (r5695) @@ -41,6 +41,10 @@ */ OSyncCapability *osync_capability_parse(OSyncCapabilitiesObjType *objtype, xmlNodePtr node, OSyncError **error); + +/* TODO - Doxygen */ +osync_bool osync_capability_assemble(OSyncCapability *cap, xmlNodePtr node, OSyncError **error); + /** * @brief Frees a capability object * @param capability The pointer to a capability object |
From: <svn...@op...> - 2009-07-08 09:05:31
|
Author: dgollub Date: Wed Jul 8 11:05:24 2009 New Revision: 5694 URL: http://www.opensync.org/changeset/5694 Log: Silence compiler warning about signdess issue. xmlChar* uses unsigned char * (IIRC). To fit the OpenSync API pattern we use for most characters const char*. If there is a cleaner way to fit the needs of API, let me know. Modified: branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities_objtype.c Modified: branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities_objtype.c ============================================================================== --- branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities_objtype.c Wed Jul 8 11:02:29 2009 (r5693) +++ branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities_objtype.c Wed Jul 8 11:05:24 2009 (r5694) @@ -62,7 +62,8 @@ osync_assert(!xmlStrcmp(node->name, (const xmlChar *)"ObjType")); objtype = xmlGetProp(node, (const xmlChar *)"Name"); - if (!(capobjtype = osync_capabilities_objtype_new(capabilities, BAD_CAST objtype, error))) + /* XXX: Bad cast from unsigned char* to const char* - is there a better way? */ + if (!(capobjtype = osync_capabilities_objtype_new(capabilities, (const char *) objtype, error))) goto error; osync_xml_free(objtype); |
From: <svn...@op...> - 2009-07-08 09:02:37
|
Author: dgollub Date: Wed Jul 8 11:02:29 2009 New Revision: 5693 URL: http://www.opensync.org/changeset/5693 Log: Changed signature of osync_capabilities_assemble() Use for size a unsigned int for, to honor OpenSync' common API pattern of types for size and lengths values. Modified: branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities.c branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities_internals.h Modified: branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities.c ============================================================================== --- branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities.c Wed Jul 8 11:00:02 2009 (r5692) +++ branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities.c Wed Jul 8 11:02:29 2009 (r5693) @@ -132,7 +132,7 @@ return NULL; } -osync_bool osync_capabilities_assemble(OSyncCapabilities *capabilities, char **buffer, int *size, OSyncError **error) +osync_bool osync_capabilities_assemble(OSyncCapabilities *capabilities, char **buffer, unsigned int *size, OSyncError **error) { xmlDocPtr doc = NULL; xmlNodePtr root; @@ -167,7 +167,8 @@ goto error; } - xmlDocDumpFormatMemoryEnc(doc, (xmlChar **) buffer, size, NULL, 1); + /* XXX Ugly cast, but we try to fit here the opensync API pattern of unsigned size/length types */ + xmlDocDumpFormatMemoryEnc(doc, (xmlChar **) buffer, (int *) size, NULL, 1); return TRUE; Modified: branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities_internals.h ============================================================================== --- branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities_internals.h Wed Jul 8 11:00:02 2009 (r5692) +++ branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities_internals.h Wed Jul 8 11:02:29 2009 (r5693) @@ -74,7 +74,7 @@ * @return The xml document and the size of it. It's up to the caller to free * the buffer. Always it return TRUE. */ -OSYNC_TEST_EXPORT osync_bool osync_capabilities_assemble(OSyncCapabilities *capabilities, char **buffer, int *size, OSyncError **error); +OSYNC_TEST_EXPORT osync_bool osync_capabilities_assemble(OSyncCapabilities *capabilities, char **buffer, unsigned int *size, OSyncError **error); /** * @brief Creates a new capabilities object from an xml document. |
From: <svn...@op...> - 2009-07-08 09:00:10
|
Author: dgollub Date: Wed Jul 8 11:00:02 2009 New Revision: 5692 URL: http://www.opensync.org/changeset/5692 Log: Fixed more compiler warnings about unused variables and goto statements. Modified: branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities.c Modified: branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities.c ============================================================================== --- branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities.c Wed Jul 8 10:58:10 2009 (r5691) +++ branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities.c Wed Jul 8 11:00:02 2009 (r5692) @@ -135,7 +135,7 @@ osync_bool osync_capabilities_assemble(OSyncCapabilities *capabilities, char **buffer, int *size, OSyncError **error) { xmlDocPtr doc = NULL; - xmlNodePtr cur, root; + xmlNodePtr root; char *version_str; const char *capsformat; OSyncList *l; @@ -171,8 +171,10 @@ return TRUE; +/* error_oom: osync_error_set(error, OSYNC_ERROR_GENERIC, "Couldn't allocate memory to assemble capabilities file."); +*/ error: osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error)); return FALSE; @@ -236,8 +238,7 @@ OSyncCapabilities *osync_capabilities_load_identifier(const char *file, OSyncError **error) { - unsigned int size; - char *buffer, *filename; + char *filename; OSyncCapabilities *capabilities; osync_trace(TRACE_ENTRY, "%s(%s, %p)", __func__, file, error); |
From: <svn...@op...> - 2009-07-08 08:58:17
|
Author: dgollub Date: Wed Jul 8 10:58:10 2009 New Revision: 5691 URL: http://www.opensync.org/changeset/5691 Log: Fix compiler warning about unused code Modified: branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities.c Modified: branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities.c ============================================================================== --- branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities.c Wed Jul 8 10:56:51 2009 (r5690) +++ branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities.c Wed Jul 8 10:58:10 2009 (r5691) @@ -82,7 +82,6 @@ OSyncCapabilities *osync_capabilities_parse(const char *buffer, unsigned int size, OSyncError **error) { - OSyncCapability *capability = NULL; OSyncCapabilities *capabilities = NULL; xmlNodePtr cur = NULL; xmlChar *capsformat; @@ -128,9 +127,6 @@ osync_trace(TRACE_EXIT, "%s: %p", __func__, capabilities); return capabilities; -error_and_free: - if (capability) - osync_capability_free(capability); error: osync_trace(TRACE_EXIT_ERROR, "%s: %s" , __func__, osync_error_print(error)); return NULL; |
From: <svn...@op...> - 2009-07-08 08:57:04
|
Author: dgollub Date: Wed Jul 8 10:56:51 2009 New Revision: 5690 URL: http://www.opensync.org/changeset/5690 Log: Added missing declartion of osynnc_capabilities_{,un}ref() Fixes gcc compiler warnings Modified: branches/opensync-ticket1084/opensync.sym branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities_objtype.h Modified: branches/opensync-ticket1084/opensync.sym ============================================================================== --- branches/opensync-ticket1084/opensync.sym Sat Jun 27 22:58:53 2009 (r5689) +++ branches/opensync-ticket1084/opensync.sym Wed Jul 8 10:56:51 2009 (r5690) @@ -1,4 +1,6 @@ osync_capabilities_get_format +osync_capabilities_objtype_ref +osync_capabilities_objtype_unref osync_capabilities_get_objtype osync_capabilities_new osync_capabilities_objtype_get_caps Modified: branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities_objtype.h ============================================================================== --- branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities_objtype.h Sat Jun 27 22:58:53 2009 (r5689) +++ branches/opensync-ticket1084/opensync/capabilities/opensync_capabilities_objtype.h Wed Jul 8 10:56:51 2009 (r5690) @@ -41,6 +41,9 @@ OSYNC_EXPORT OSyncCapabilitiesObjType *osync_capabilities_objtype_new(OSyncCapabilities *capabilities, const char *objtype, OSyncError **error); +OSYNC_EXPORT OSyncCapabilitiesObjType *osync_capabilities_objtype_ref(OSyncCapabilitiesObjType *capsobjtype); +OSYNC_EXPORT void osync_capabilities_objtype_unref(OSyncCapabilitiesObjType *capsobjtype); + OSYNC_EXPORT OSyncList *osync_capabilities_objtype_get_caps(OSyncCapabilitiesObjType *capsobjtype); /*@}*/ |
From: <svn...@op...> - 2009-07-07 15:04:53
|
Author: bellmich Date: Tue Jul 7 16:59:09 2009 New Revision: 1155 URL: http://libsyncml.opensync.org/changeset/1155 Log: migrated objects/sml_auth from SmlError to GError Modified: trunk/libsyncml/objects/sml_auth.c trunk/libsyncml/objects/sml_auth.h trunk/libsyncml/objects/sml_auth_internals.h Modified: trunk/libsyncml/objects/sml_auth.c ============================================================================== --- trunk/libsyncml/objects/sml_auth.c Tue Jul 7 16:47:34 2009 (r1154) +++ trunk/libsyncml/objects/sml_auth.c Tue Jul 7 16:59:09 2009 (r1155) @@ -29,11 +29,7 @@ #include <libsyncml/sml_command_internals.h> #include "libsyncml/sml_error_internals.h" -static SmlStatus *_smlAuthHeaderReply( - SmlSession *session, - SmlErrorType code, - SmlAuthType auth, - SmlError **error); +static SmlStatus* _smlAuthHeaderReply(SmlSession *session, SmlErrorType code, SmlAuthType auth, GError **error); void _status_callback(SmlSession *session, SmlStatus *status, void *userdata) { @@ -49,7 +45,7 @@ smlAssert(userdata); SmlStatus *reply = NULL; SmlAuthenticator *auth = userdata; - SmlError *error = NULL; + GError *error = NULL; if (session->sessionType == SML_SESSION_TYPE_CLIENT) { /* If this is an OMA DS client then there will be no @@ -112,11 +108,12 @@ { auth->state = SML_AUTH_ACCEPTED; } else { - smlErrorSet(&error, SML_ERROR_AUTH_REJECTED, + g_set_error(&error, SML_ERROR, SML_ERROR_AUTH_REJECTED, "Auth rejected for username %s", sml_location_get_name(session->source)); smlSessionDispatchEvent(session, SML_SESSION_EVENT_ERROR, NULL, NULL, NULL, error); - smlErrorDeref(&error); + g_error_free(error); + error = NULL; auth->state = SML_ERROR_AUTH_REJECTED; } } else { @@ -156,17 +153,17 @@ return; error: smlSessionDispatchEvent(session, SML_SESSION_EVENT_ERROR, NULL, NULL, 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); return; } -char *smlAuthGetCredString( - SmlAuthType type, - const char *username, - const char *password, - const char *b64_nonce, - SmlError **error) +gchar* +smlAuthGetCredString (SmlAuthType type, + const gchar *username, + const gchar *password, + const gchar *b64_nonce, + GError **error) { smlTrace(TRACE_ENTRY, "%s", __func__); CHECK_ERROR_REF @@ -179,7 +176,7 @@ char *plain = g_strjoin(":", username, password, NULL); cred = g_base64_encode((unsigned char *) plain, strlen(plain)); if (!cred) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The syncml:auth-basic credential cannot be base64 encoded."); smlSafeCFree(&plain); goto error; @@ -212,7 +209,7 @@ smlSafeCFree(&auth); cred = g_base64_encode(digest, 16); if (!cred) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The username:password part of the syncml:auth-md5 "\ "credential cannot be base64 encoded."); goto error; @@ -223,7 +220,7 @@ smlSafeCFree(&auth); cred = g_base64_encode(digest, 16); if (!cred) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The complete syncml:auth-md5 credential cannot be base64 encoded."); goto error; } @@ -231,7 +228,7 @@ break; default: smlTrace(TRACE_ERROR, "%s - unknown authentication type", __func__); - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown auth format"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown auth format"); goto error; } @@ -240,12 +237,18 @@ error: smlTrace(TRACE_EXIT_ERROR, "%s - cannot create credential string"); if (*error == NULL) - smlErrorSet(error, SML_ERROR_GENERIC, "Cannot create credential string for user %s.", - username); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Cannot create credential string for user %s.", + username); return NULL; } -SmlBool smlAuthVerify(SmlChal *chal, SmlCred *cred, const char *username, const char *password, SmlError **error) +gboolean +smlAuthVerify (SmlChal *chal, + SmlCred *cred, + const gchar *username, + const gchar *password, + GError **error) { smlTrace(TRACE_ENTRY, "%s", __func__); CHECK_ERROR_REF @@ -272,7 +275,7 @@ smlTrace(TRACE_INTERNAL, "%s - replace syncml:auth-basic by syncml:auth-md5", __func__); } else { /* This is a security event. */ - smlErrorSet(error, SML_ERROR_AUTH_REJECTED, + g_set_error(error, SML_ERROR, SML_ERROR_AUTH_REJECTED, "The type of the authentication was changed to a lower security level."); goto error; } @@ -300,7 +303,7 @@ break; default: smlTrace(TRACE_ERROR, "%s - unknown authentication type", __func__); - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown auth format"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown auth format"); goto error; } smlTrace(TRACE_INTERNAL, "%s - credential string calculated", __func__); @@ -319,12 +322,14 @@ error: smlTrace(TRACE_EXIT_ERROR, "%s - auth rejected"); if (*error == NULL) - smlErrorSet(error, SML_ERROR_AUTH_REJECTED, "Authentication rejected for username %s.", - username); + g_set_error(error, SML_ERROR, SML_ERROR_AUTH_REJECTED, + "Authentication rejected for username %s.", + username); return FALSE; } -SmlAuthenticator *smlAuthNew(SmlError **error) +SmlAuthenticator* +smlAuthNew (GError **error) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, error); CHECK_ERROR_REF @@ -337,14 +342,14 @@ smlTrace(TRACE_EXIT, "%s: %p", __func__, auth); return auth; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -void smlAuthFree(SmlAuthenticator *auth) +void +smlAuthFree (SmlAuthenticator *auth) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, auth); smlAssert(auth); @@ -354,7 +359,10 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -SmlBool smlAuthRegister(SmlAuthenticator *auth, SmlManager *manager, SmlError **error) +gboolean +smlAuthRegister (SmlAuthenticator *auth, + SmlManager *manager, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, auth, manager, error); CHECK_ERROR_REF @@ -367,7 +375,9 @@ return TRUE; } -void smlAuthSetState(SmlAuthenticator *auth, SmlErrorType type) +void +smlAuthSetState (SmlAuthenticator *auth, + SmlErrorType type) { smlTrace(TRACE_ENTRY, "%s(%p, %i)", __func__, auth, type); smlAssert(auth); @@ -377,21 +387,11 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -/* FIXME: DEPRECATED*/ -SmlStatus *smlAuthHeaderReply( - SmlSession *session, - SmlAuthType code, - SmlError **error) { - CHECK_ERROR_REF - g_warning("SmlAuthType of smlAuthHeaderReply is used as SmlErrorType."); - return _smlAuthHeaderReply(session, (SmlErrorType) code, SML_AUTH_TYPE_BASIC, error); -} - -static SmlStatus *_smlAuthHeaderReply( - SmlSession *session, - SmlErrorType code, - SmlAuthType auth, - SmlError **error) +static SmlStatus* +_smlAuthHeaderReply (SmlSession *session, + SmlErrorType code, + SmlAuthType auth, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %i, %p)", __func__, session, code, auth, error); CHECK_ERROR_REF @@ -410,18 +410,17 @@ code == SML_ERROR_AUTH_REQUIRED) { reply->chal = smlChalNew(auth, error); if (!reply->chal) - goto error_free_reply; + goto error; session->chal = reply->chal; smlChalRef(session->chal); } smlTrace(TRACE_EXIT, "%s: %p", __func__, reply); return reply; - -error_free_reply: - smlStatusUnref(reply); error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + if (reply) + smlStatusUnref(reply); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } @@ -434,7 +433,7 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -void smlAuthSetEnable(SmlAuthenticator *auth, SmlBool enabled) +void smlAuthSetEnable(SmlAuthenticator *auth, gboolean enabled) { smlTrace(TRACE_ENTRY, "%s(%p, %i)", __func__, auth, enabled); smlAssert(auth); @@ -444,7 +443,7 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -SmlBool smlAuthIsEnabled(SmlAuthenticator *auth) +gboolean smlAuthIsEnabled(SmlAuthenticator *auth) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, auth); smlAssert(auth); Modified: trunk/libsyncml/objects/sml_auth.h ============================================================================== --- trunk/libsyncml/objects/sml_auth.h Tue Jul 7 16:47:34 2009 (r1154) +++ trunk/libsyncml/objects/sml_auth.h Tue Jul 7 16:59:09 2009 (r1155) @@ -31,24 +31,21 @@ #define _SML_AUTH_H_ typedef struct SmlAuthenticator SmlAuthenticator; -typedef SmlBool (* SmlAuthVerifyCb)(SmlChal *chal, SmlCred *cred, const gchar *username, void *userdata, GError **error); +typedef gboolean (* SmlAuthVerifyCb)(SmlChal *chal, SmlCred *cred, const gchar *username, void *userdata, GError **error); -SmlAuthenticator *smlAuthNew(GError **error); -void smlAuthFree(SmlAuthenticator *auth); -SmlBool smlAuthRegister(SmlAuthenticator *auth, SmlManager *manager, GError **error); -void smlAuthSetState(SmlAuthenticator *auth, SmlErrorType type); -void smlAuthSetVerifyCallback(SmlAuthenticator *auth, SmlAuthVerifyCb callback, void *userdata); -void smlAuthSetEnable(SmlAuthenticator *auth, SmlBool enabled); -SmlBool smlAuthIsEnabled(SmlAuthenticator *auth); +SmlAuthenticator* smlAuthNew (GError **error); +void smlAuthFree (SmlAuthenticator *auth); +gboolean smlAuthRegister (SmlAuthenticator *auth, SmlManager *manager, GError **error); +void smlAuthSetState (SmlAuthenticator *auth, SmlErrorType type); +void smlAuthSetVerifyCallback (SmlAuthenticator *auth, SmlAuthVerifyCb callback, void *userdata); +void smlAuthSetEnable (SmlAuthenticator *auth, gboolean enabled); +gboolean smlAuthIsEnabled (SmlAuthenticator *auth); /* This can be used from within the SmlAuthVerifyCb to do the authentication itself. */ -SmlBool smlAuthVerify(SmlChal *chal, SmlCred *cred, const gchar *username, const gchar *password, GError **error); +gboolean smlAuthVerify (SmlChal *chal, SmlCred *cred, const gchar *username, const gchar *password, GError **error); /* set required authentication type if this is a server */ void smlAuthSetType(SmlAuthenticator *auth, SmlAuthType code); -/* expire date: 20090813 */ -SmlStatus *smlAuthHeaderReply(SmlSession *session, SmlAuthType code, SmlError **error) LIBSYNCML_DEPRECATED; - #endif //_SML_AUTH_H_ /*@}*/ Modified: trunk/libsyncml/objects/sml_auth_internals.h ============================================================================== --- trunk/libsyncml/objects/sml_auth_internals.h Tue Jul 7 16:47:34 2009 (r1154) +++ trunk/libsyncml/objects/sml_auth_internals.h Tue Jul 7 16:59:09 2009 (r1155) @@ -36,11 +36,11 @@ SmlErrorType state; SmlAuthVerifyCb verifyCallback; void *verifyCallbackUserdata; - SmlBool enabled; + gboolean enabled; SmlAuthType type; }; -char *smlAuthGetCredString( +gchar *smlAuthGetCredString( SmlAuthType type, const gchar *username, const gchar *password, |
From: <svn...@op...> - 2009-07-07 14:47:57
|
Author: bellmich Date: Tue Jul 7 16:47:34 2009 New Revision: 1154 URL: http://libsyncml.opensync.org/changeset/1154 Log: - migrated data sync API from SmlError to GError - fixed some warnings because of not handled enum elements Modified: trunk/libsyncml/data_sync_api/callbacks.h trunk/libsyncml/data_sync_api/data_sync.c trunk/libsyncml/data_sync_api/data_sync.h trunk/libsyncml/data_sync_api/data_sync_abort.c trunk/libsyncml/data_sync_api/data_sync_callbacks.c trunk/libsyncml/data_sync_api/data_sync_callbacks.h trunk/libsyncml/data_sync_api/data_sync_client.c trunk/libsyncml/data_sync_api/data_sync_client.h trunk/libsyncml/data_sync_api/data_sync_common.c trunk/libsyncml/data_sync_api/data_sync_common.h trunk/libsyncml/data_sync_api/data_sync_devinf.c trunk/libsyncml/data_sync_api/data_sync_devinf.h trunk/libsyncml/data_sync_api/data_sync_loop.c trunk/libsyncml/data_sync_api/data_sync_loop.h trunk/libsyncml/data_sync_api/data_sync_server.c trunk/libsyncml/data_sync_api/data_sync_server.h trunk/libsyncml/data_sync_api/standard.h trunk/libsyncml/data_sync_api/transport.h trunk/libsyncml/data_sync_api/transport_http_client.c trunk/libsyncml/data_sync_api/transport_http_server.c trunk/libsyncml/data_sync_api/transport_obex_client.c trunk/libsyncml/objects/sml_auth.h trunk/libsyncml/objects/sml_devinf_obj.h trunk/libsyncml/objects/sml_ds_server.h trunk/libsyncml/objects/sml_ds_server_internals.h trunk/libsyncml/sml_manager.c trunk/libsyncml/sml_transport.c Modified: trunk/libsyncml/data_sync_api/callbacks.h ============================================================================== --- trunk/libsyncml/data_sync_api/callbacks.h Sun Jul 5 13:04:42 2009 (r1153) +++ trunk/libsyncml/data_sync_api/callbacks.h Tue Jul 7 16:47:34 2009 (r1154) @@ -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 @@ -41,63 +41,60 @@ SmlDataSyncObject *dsObject, SmlDataSyncEventType type, void *userdata, - SmlError *error); + const GError *error); typedef SmlAlertType (* SmlDataSyncGetAlertTypeCallback) ( SmlDataSyncObject *dsObject, - const char *source, + const gchar *source, SmlAlertType type, void *userdata, - SmlError **error); -typedef SmlBool (* SmlDataSyncChangeCallback) ( + GError **error); +typedef gboolean (* SmlDataSyncChangeCallback) ( SmlDataSyncObject *dsObject, - const char *source, + const gchar *source, SmlChangeType type, - const char *uid, - char *data, - unsigned int size, + const gchar *uid, + gchar *data, + gsize size, void *userdata, - SmlError **error); -/* FIXME: newuid must be removed before next API break */ -/* FIXME: DEPRECATED */ -typedef SmlBool (* SmlDataSyncChangeStatusCallback) ( + GError **error); +typedef gboolean (* SmlDataSyncChangeStatusCallback) ( SmlDataSyncObject *dsObject, - unsigned int code, - const char *newuid, + guint code, void *userdata, - SmlError **error); -typedef SmlBool (* SmlDataSyncMappingCallback) ( + GError **error); +typedef gboolean (* SmlDataSyncMappingCallback) ( SmlDataSyncObject *dsObject, - const char *source, - const char *orig, - const char *newuid, + const gchar *source, + const gchar *orig, + const gchar *newuid, void *userdata, - SmlError **error); -typedef char *(* SmlDataSyncGetAnchorCallback) ( + GError **error); +typedef gchar *(* SmlDataSyncGetAnchorCallback) ( SmlDataSyncObject *dsObject, - const char *name, + const gchar *name, void *userdata, - SmlError **error); -typedef SmlBool (* SmlDataSyncSetAnchorCallback) ( + GError **error); +typedef gboolean (* SmlDataSyncSetAnchorCallback) ( SmlDataSyncObject *dsObject, - const char *name, - const char *value, + const gchar *name, + const gchar *value, void *userdata, - SmlError **error); -typedef SmlBool (* SmlDataSyncWriteDevInfCallback) ( + GError **error); +typedef gboolean (* SmlDataSyncWriteDevInfCallback) ( SmlDataSyncObject *dsObject, SmlDevInf *devinf, void *userdata, - SmlError **error); + GError **error); typedef SmlDevInf *(* SmlDataSyncReadDevInfCallback) ( SmlDataSyncObject *dsObject, - const char *devid, + const gchar *devid, void *userdata, - SmlError **error); -typedef SmlBool (* SmlDataSyncHandleRemoteDevInfCallback) ( + GError **error); +typedef gboolean (* SmlDataSyncHandleRemoteDevInfCallback) ( SmlDataSyncObject *dsObject, SmlDevInf *devinf, void *userdata, - SmlError **error); + GError **error); /* functions to register the callbacks */ Modified: trunk/libsyncml/data_sync_api/data_sync.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync.c Sun Jul 5 13:04:42 2009 (r1153) +++ trunk/libsyncml/data_sync_api/data_sync.c Tue Jul 7 16:47:34 2009 (r1154) @@ -43,10 +43,10 @@ /* object creation and configuration */ /* ********************************* */ -SmlDataSyncObject *smlDataSyncNew( - SmlSessionType dsType, - SmlTransportType tspType, - SmlError **error) +SmlDataSyncObject* +smlDataSyncNew (SmlSessionType dsType, + SmlTransportType tspType, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%d, %d, %p)", __func__, dsType, tspType, error); CHECK_ERROR_REF @@ -90,8 +90,8 @@ dsObject->funcTspConnect = smlDataSyncTransportHttpClientConnect; break; default: - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, - "Unknown transport type %d used in __func__.", + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, + "Unknown transport type %d used in %s.", tspType, __func__); goto error; break; @@ -107,7 +107,7 @@ dsObject->funcDsConnect = NULL; break; default: - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "Unknown data sync type %d used in %s.", dsType, __func__); goto error; @@ -122,7 +122,7 @@ smlTransportFree(dsObject->tsp); smlDataSyncObjectUnref(&dsObject); } - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return NULL; } @@ -131,11 +131,11 @@ g_atomic_int_inc(&(dsObject->refCount)); } -SmlBool smlDataSyncSetOption( - SmlDataSyncObject *dsObject, - const char *name, - const char *value, - SmlError **error) +gboolean +smlDataSyncSetOption (SmlDataSyncObject *dsObject, + const gchar *name, + const gchar *value, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %s, %s, %p)", __func__, dsObject, VA_STRING(name), VA_STRING(value), error); CHECK_ERROR_REF @@ -162,7 +162,7 @@ if (!strcmp("1.2", value)) dsObject->version = SML_VERSION_12; if (dsObject->version == SML_VERSION_UNKNOWN) { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "Unknown SyncML version %s.", value); goto error; } @@ -175,7 +175,7 @@ dsObject->authType = SML_AUTH_TYPE_UNKNOWN; } else { // this is an illegal keyword - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "Unknown authentication type %s.", value); goto error; } @@ -245,15 +245,16 @@ smlTrace(TRACE_EXIT, "%s - TRUE", __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 smlDataSyncAddDatastore(SmlDataSyncObject *dsObject, - const char *contentType, - const char *target, - const char *source, - SmlError **error) +gboolean +smlDataSyncAddDatastore (SmlDataSyncObject *dsObject, + const gchar *contentType, + const gchar *target, + const gchar *source, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %s, %s, %s, %p)", __func__, dsObject, VA_STRING(contentType), VA_STRING(target), VA_STRING(source), error); CHECK_ERROR_REF @@ -333,14 +334,14 @@ smlSafeCFree(&lcCT); if (lcSource) smlSafeCFree(&lcSource); - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } -static SmlDataSyncDatastore *smlDataSyncGetDatastoreFromSource( - SmlDataSyncObject *dsObject, - const char *source, - SmlError **error) +static SmlDataSyncDatastore* +smlDataSyncGetDatastoreFromSource (SmlDataSyncObject *dsObject, + const gchar *source, + GError **error) { CHECK_ERROR_REF smlAssert(dsObject); @@ -353,7 +354,7 @@ return datastore; } - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "Cannot find datastore for source name %s.", source); return NULL; } @@ -362,10 +363,10 @@ /* register callbacks */ /* ***************************** */ -void smlDataSyncRegisterEventCallback( - SmlDataSyncObject *dsObject, - SmlDataSyncEventCallback callback, - void *userdata) +void +smlDataSyncRegisterEventCallback (SmlDataSyncObject *dsObject, + SmlDataSyncEventCallback callback, + void *userdata) { smlTrace(TRACE_ENTRY, "%s", __func__); smlAssert(dsObject); @@ -377,10 +378,10 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -void smlDataSyncRegisterGetAlertTypeCallback( - SmlDataSyncObject *dsObject, - SmlDataSyncGetAlertTypeCallback callback, - void *userdata) +void +smlDataSyncRegisterGetAlertTypeCallback (SmlDataSyncObject *dsObject, + SmlDataSyncGetAlertTypeCallback callback, + void *userdata) { smlTrace(TRACE_ENTRY, "%s", __func__); smlAssert(dsObject); @@ -392,10 +393,10 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -void smlDataSyncRegisterChangeCallback( - SmlDataSyncObject *dsObject, - SmlDataSyncChangeCallback callback, - void *userdata) +void +smlDataSyncRegisterChangeCallback (SmlDataSyncObject *dsObject, + SmlDataSyncChangeCallback callback, + void *userdata) { smlTrace(TRACE_ENTRY, "%s", __func__); smlAssert(dsObject); @@ -418,9 +419,9 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -void smlDataSyncRegisterChangeStatusCallback( - SmlDataSyncObject *dsObject, - SmlDataSyncChangeStatusCallback callback) +void +smlDataSyncRegisterChangeStatusCallback (SmlDataSyncObject *dsObject, + SmlDataSyncChangeStatusCallback callback) { smlTrace(TRACE_ENTRY, "%s", __func__); smlAssert(dsObject); @@ -432,10 +433,10 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -void smlDataSyncRegisterMapCallback( - SmlDataSyncObject *dsObject, - SmlDataSyncMappingCallback callback, - void *userdata) +void +smlDataSyncRegisterMapCallback (SmlDataSyncObject *dsObject, + SmlDataSyncMappingCallback callback, + void *userdata) { smlTrace(TRACE_ENTRY, "%s", __func__); smlAssert(dsObject); @@ -457,10 +458,10 @@ } -void smlDataSyncRegisterGetAnchorCallback( - SmlDataSyncObject *dsObject, - SmlDataSyncGetAnchorCallback callback, - void *userdata) +void +smlDataSyncRegisterGetAnchorCallback (SmlDataSyncObject *dsObject, + SmlDataSyncGetAnchorCallback callback, + void *userdata) { smlTrace(TRACE_ENTRY, "%s", __func__); smlAssert(dsObject); @@ -472,10 +473,10 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -void smlDataSyncRegisterSetAnchorCallback( - SmlDataSyncObject *dsObject, - SmlDataSyncSetAnchorCallback callback, - void *userdata) +void +smlDataSyncRegisterSetAnchorCallback (SmlDataSyncObject *dsObject, + SmlDataSyncSetAnchorCallback callback, + void *userdata) { smlTrace(TRACE_ENTRY, "%s", __func__); smlAssert(dsObject); @@ -487,10 +488,10 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -void smlDataSyncRegisterWriteDevInfCallback( - SmlDataSyncObject *dsObject, - SmlDataSyncWriteDevInfCallback callback, - void *userdata) +void +smlDataSyncRegisterWriteDevInfCallback (SmlDataSyncObject *dsObject, + SmlDataSyncWriteDevInfCallback callback, + void *userdata) { smlTrace(TRACE_ENTRY, "%s", __func__); smlAssert(dsObject); @@ -502,10 +503,10 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -void smlDataSyncRegisterReadDevInfCallback( - SmlDataSyncObject *dsObject, - SmlDataSyncReadDevInfCallback callback, - void *userdata) +void +smlDataSyncRegisterReadDevInfCallback (SmlDataSyncObject *dsObject, + SmlDataSyncReadDevInfCallback callback, + void *userdata) { smlTrace(TRACE_ENTRY, "%s", __func__); smlAssert(dsObject); @@ -517,10 +518,10 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -void smlDataSyncRegisterHandleRemoteDevInfCallback( - SmlDataSyncObject *dsObject, - SmlDataSyncHandleRemoteDevInfCallback callback, - void *userdata) +void +smlDataSyncRegisterHandleRemoteDevInfCallback (SmlDataSyncObject *dsObject, + SmlDataSyncHandleRemoteDevInfCallback callback, + void *userdata) { smlTrace(TRACE_ENTRY, "%s", __func__); smlAssert(dsObject); @@ -536,7 +537,9 @@ /* init session */ /* ***************************** */ -SmlBool smlDataSyncInit(SmlDataSyncObject *dsObject, SmlError **error) +gboolean +smlDataSyncInit (SmlDataSyncObject *dsObject, + GError **error) { smlTrace(TRACE_ENTRY, "%s", __func__); CHECK_ERROR_REF @@ -558,11 +561,12 @@ smlTrace(TRACE_EXIT, "%s - TRUE", __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 smlDataSyncRun(SmlDataSyncObject *dsObject, SmlError **error) +gboolean +smlDataSyncRun(SmlDataSyncObject *dsObject, GError **error) { smlTrace(TRACE_ENTRY, "%s", __func__); CHECK_ERROR_REF @@ -584,21 +588,21 @@ smlTrace(TRACE_EXIT, "%s - TRUE", __func__); return TRUE; error: - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } /* synchronize */ -SmlBool smlDataSyncAddChange( - SmlDataSyncObject *dsObject, - const char *source, - SmlChangeType type, - const char *name, - const char *data, - unsigned int size, - void *userdata, /* for SmlDataSyncChangeStatusCallback */ - SmlError **error) +gboolean +smlDataSyncAddChange (SmlDataSyncObject *dsObject, + const gchar *source, + SmlChangeType type, + const gchar *name, + const gchar *data, + gsize size, + void *userdata, /* for SmlDataSyncChangeStatusCallback */ + GError **error) { smlTrace(TRACE_ENTRY, "%s(%s)", __func__, VA_STRING(source)); @@ -644,7 +648,7 @@ /* binary data must be base64 encoded */ change->data = g_base64_encode((const unsigned char *) data, size); if (!change->data) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The base 64 encoding of glib failed."); goto error; } @@ -667,11 +671,13 @@ smlTrace(TRACE_EXIT, "%s - TRUE", __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 smlDataSyncSendChanges(SmlDataSyncObject *dsObject, SmlError **error) +gboolean +smlDataSyncSendChanges (SmlDataSyncObject *dsObject, + GError **error) { /* This means that all alerts were received * and all changes were added. @@ -683,7 +689,7 @@ if (dsObject->internalState >= SML_DATA_SYNC_STATE_SENT_CHANGES) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The function %s is called to late or more than once.", __func__); goto error; } else { @@ -692,7 +698,7 @@ if (dsObject->dsType == SML_SESSION_TYPE_SERVER && dsObject->actualPackage != SML_PACKAGE_4) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "This is not the server's sync package (%d).", dsObject->actualPackage); goto error; @@ -700,7 +706,7 @@ if (dsObject->dsType == SML_SESSION_TYPE_CLIENT && dsObject->actualPackage != SML_PACKAGE_3) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "This is not the client's sync package (%d).", dsObject->actualPackage); goto error; @@ -750,16 +756,16 @@ smlTrace(TRACE_EXIT, "%s - TRUE", __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 smlDataSyncAddMapping( - SmlDataSyncObject *dsObject, - const char *source, - const char *remoteID, - const char *localID, - SmlError **error) +gboolean +smlDataSyncAddMapping (SmlDataSyncObject *dsObject, + const gchar *source, + const gchar *remoteID, + const gchar *localID, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%s)", __func__, VA_STRING(source)); @@ -785,11 +791,13 @@ smlTrace(TRACE_EXIT, "%s - TRUE", __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 smlDataSyncSendMap(SmlDataSyncObject *dsObject, SmlError **error) +gboolean +smlDataSyncSendMap (SmlDataSyncObject *dsObject, + GError **error) { smlTrace(TRACE_ENTRY, "%s", __func__); CHECK_ERROR_REF @@ -799,13 +807,13 @@ if (dsObject->dsType == SML_SESSION_TYPE_SERVER) { - smlErrorSet(error, SML_ERROR_GENERIC, "An OMA DS server never sends a map."); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "An OMA DS server never sends a map."); goto error; } if (dsObject->dsType == SML_SESSION_TYPE_CLIENT && dsObject->actualPackage != SML_PACKAGE_5) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing server's sync package."); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing server's sync package."); goto error; } @@ -824,14 +832,14 @@ smlTrace(TRACE_EXIT, "%s - TRUE", __func__); return TRUE; error: - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } -const SmlLocation *smlDataSyncGetTarget( - SmlDataSyncObject *dsObject, - SmlError **error) +const SmlLocation* +smlDataSyncGetTarget (SmlDataSyncObject *dsObject, + GError **error) { smlTrace(TRACE_INTERNAL, "%s(%p, %p)", __func__, dsObject, error); smlAssert(dsObject); @@ -859,22 +867,23 @@ /* cleanup transport */ if ((*dsObject)->tsp) { - SmlError *error = NULL; + GError *error = NULL; if ((*dsObject)->dsType == SML_SESSION_TYPE_CLIENT && SML_DATA_SYNC_STATE_CONNECTED >= (*dsObject)->internalState && (*dsObject)->internalState <= SML_DATA_SYNC_STATE_DISCONNECTED && !smlTransportDisconnect((*dsObject)->tsp, NULL, &error)) { /* just ignore the error */ smlTrace(TRACE_ERROR, "%s: %s", - __func__, smlErrorPrint(&error)); - smlErrorDeref(&error); + __func__, error->message); + g_error_free(error); } /* FIXME: we have to wait here for the disconnect ... */ if ((*dsObject)->internalState >= SML_DATA_SYNC_STATE_INITIALIZED && !smlTransportFinalize((*dsObject)->tsp, &error)) { smlTrace(TRACE_ERROR, "%s: %s", - __func__, smlErrorPrint(&error)); - smlErrorDeref(&error); + __func__, error->message); + g_error_free(error); + error = NULL; } smlTransportFree((*dsObject)->tsp); } @@ -957,11 +966,11 @@ /* internal functions */ -void smlDataSyncSendEvent( - SmlDataSyncObject *dsObject, - SmlDataSyncEventType type, - void *userdata, - SmlError *error) +void +smlDataSyncSendEvent (SmlDataSyncObject *dsObject, + SmlDataSyncEventType type, + void *userdata, + const GError *error) { /* this functionworks synchronous today */ smlAssert(dsObject); Modified: trunk/libsyncml/data_sync_api/data_sync.h ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync.h Sun Jul 5 13:04:42 2009 (r1153) +++ trunk/libsyncml/data_sync_api/data_sync.h Tue Jul 7 16:47:34 2009 (r1154) @@ -37,18 +37,18 @@ /* typedef for internal function pointers */ -typedef SmlBool (* SmlFunctionDataSyncInit) ( +typedef gboolean (* SmlFunctionDataSyncInit) ( SmlDataSyncObject *dsObject, - SmlError **error); -typedef SmlBool (* SmlFunctionDataSyncConnect) ( + GError **error); +typedef gboolean (* SmlFunctionDataSyncConnect) ( SmlDataSyncObject *dsObject, - SmlError **error); -typedef SmlBool (* SmlFunctionTransportInit) ( + GError **error); +typedef gboolean (* SmlFunctionTransportInit) ( SmlDataSyncObject *dsObject, - SmlError **error); -typedef SmlBool (* SmlFunctionTransportConnect) ( + GError **error); +typedef gboolean (* SmlFunctionTransportConnect) ( SmlDataSyncObject *dsObject, - SmlError **error); + GError **error); /*! @brief This is the internal representation of the OMA DS packages. * OMA DS specifications define packages which can consist @@ -94,13 +94,13 @@ SmlDataSyncObject *dsObject; void *syncChanges; void *syncContexts; - char *sourceUri; - char *targetUri; - char *contentType; + gchar *sourceUri; + gchar *targetUri; + gchar *contentType; SmlDsServer *server; SmlDsSession *session; - char *localNext; - char *remoteNext; + gchar *localNext; + gchar *remoteNext; SmlAlertType alertType; GList *changes; } SmlDataSyncDatastore; @@ -133,33 +133,33 @@ GList *datastores; - SmlBool useNumberOfChanges; - SmlBool useTimestampAnchor; - SmlBool onlyLocaltime; - SmlBool onlyReplace; - SmlBool useStringTable; - SmlBool useWbxml; - unsigned int maxObjSize; - unsigned int maxMsgSize; - char *identifier; + gboolean useNumberOfChanges; + gboolean useTimestampAnchor; + gboolean onlyLocaltime; + gboolean onlyReplace; + gboolean useStringTable; + gboolean useWbxml; + gsize maxObjSize; + gsize maxMsgSize; + gchar *identifier; SmlAuthType authType; - char *username; - char *password; + gchar *username; + gchar *password; - char *url; - char *target; + gchar *url; + gchar *target; SmlProtocolVersion version; - char *fakeDevice; - char *fakeManufacturer; - char *fakeModel; - char *fakeSoftwareVersion; + gchar *fakeDevice; + gchar *fakeManufacturer; + gchar *fakeModel; + gchar *fakeSoftwareVersion; /* states */ SmlDataSyncInternalStateType internalState; - int refCount; + gint refCount; SmlDataSyncPackageType actualPackage; /* callbacks */ @@ -207,9 +207,9 @@ typedef struct SmlDataSyncChange { SmlDataSyncDatastore *datastore; SmlChangeType type; - char *name; - char *data; - unsigned int size; + gchar *name; + gchar *data; + gsize size; void *userdata; } SmlDataSyncChange; @@ -217,10 +217,10 @@ SmlDataSyncObject *dsObject, SmlDataSyncEventType type, void *userdata, - SmlError *error); + const GError *error); -SmlBool smlDataSyncSendMap( +gboolean smlDataSyncSendMap( SmlDataSyncObject *dsObject, - SmlError **error); + GError **error); #endif /* _SML_DATA_SYNC_INTERNALS_H_ */ Modified: trunk/libsyncml/data_sync_api/data_sync_abort.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_abort.c Sun Jul 5 13:04:42 2009 (r1153) +++ trunk/libsyncml/data_sync_api/data_sync_abort.c Tue Jul 7 16:47:34 2009 (r1154) @@ -38,9 +38,9 @@ #include "../sml_session_internals.h" #include "../sml_manager_internals.h" -SmlBool smlDataSyncAbort( - SmlDataSyncObject *dsObject, - SmlError **error) +gboolean +smlDataSyncAbort (SmlDataSyncObject *dsObject, + GError **error) { smlTrace(TRACE_ENTRY, "%s", __func__); @@ -80,7 +80,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; } Modified: trunk/libsyncml/data_sync_api/data_sync_callbacks.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_callbacks.c Sun Jul 5 13:04:42 2009 (r1153) +++ trunk/libsyncml/data_sync_api/data_sync_callbacks.c Tue Jul 7 16:47:34 2009 (r1154) @@ -44,7 +44,7 @@ SmlManager *manager, SmlManagerEventType type, SmlSession *session, - SmlError *error, + GError *error, void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p)", __func__, manager, type, session, error, userdata); @@ -121,12 +121,12 @@ case SML_MANAGER_TRANSPORT_ERROR: smlTrace(TRACE_INTERNAL, "There was an error in the transport: %s", - smlErrorPrint(&error)); + error->message); if (SML_DATA_SYNC_STATE_CONNECTED <= dsObject->internalState && dsObject->internalState < SML_DATA_SYNC_STATE_DISCONNECTED) { if (dsObject->internalState < SML_DATA_SYNC_STATE_DISCONNECT_IN_PROGRESS) { dsObject->internalState = SML_DATA_SYNC_STATE_DISCONNECT_IN_PROGRESS; - SmlError *locerror = NULL; + GError *locerror = NULL; SmlLink *link_ = smlManagerSessionGetLink( dsObject->manager, dsObject->session, @@ -142,7 +142,7 @@ * So locerror can be ignored. */ if (locerror) - smlErrorDeref(&locerror); + g_error_free(locerror); /* It is not a good idea to wait for the * disconnect here. First this is an * asynchronous software so it is always @@ -168,12 +168,12 @@ goto error; break; case SML_MANAGER_SESSION_NEW: - smlTrace(TRACE_INTERNAL, "%s: Just received a new session with ID %s", - __func__, VA_STRING(smlSessionGetSessionID(session))); + smlTrace(TRACE_INTERNAL, "%s: Just received a new session with ID %d.", + __func__, smlSessionGetSessionID(session)); if (dsObject->session) { smlTrace(TRACE_INTERNAL, - "%s: WARNING: There was an old session %s in the environment.", - __func__, VA_STRING(smlSessionGetSessionID(dsObject->session))); + "%s: WARNING: There was an old session %d in the environment.", + __func__, smlSessionGetSessionID(dsObject->session)); smlSessionUnref(dsObject->session); dsObject->session = NULL; } @@ -203,8 +203,8 @@ break; case SML_MANAGER_SESSION_FINAL: - smlTrace(TRACE_INTERNAL, "%s: Session %s reported final", - __func__, VA_STRING(smlSessionGetSessionID(session))); + smlTrace(TRACE_INTERNAL, "%s: Session %d reported final.", + __func__, smlSessionGetSessionID(session)); /* determine which package was received */ @@ -285,15 +285,15 @@ /* auto disconnect by library */ break; default: - smlErrorSet(&error, SML_ERROR_NOT_IMPLEMENTED, + g_set_error(&error, SML_ERROR, SML_ERROR_NOT_IMPLEMENTED, "The package %d is actually not supported.", dsObject->actualPackage); goto error; } break; case SML_MANAGER_SESSION_END: - smlTrace(TRACE_INTERNAL, "%s: Session %s has ended", - __func__, VA_STRING(smlSessionGetSessionID(session))); + smlTrace(TRACE_INTERNAL, "%s: Session %d has ended", + __func__, smlSessionGetSessionID(session)); SmlLink *link_ = smlManagerSessionGetLink( dsObject->manager, dsObject->session, @@ -319,18 +319,19 @@ case SML_MANAGER_SESSION_ERROR: if (session) smlTrace(TRACE_INTERNAL, - "There was an error in the session %s: %s", - VA_STRING(smlSessionGetSessionID(session)), - smlErrorPrint(&error)); + "%s: There was an error in the session %d: %s", + __func__, + smlSessionGetSessionID(session), + error->message); else smlTrace(TRACE_INTERNAL, "There was a general error in the manager. %s", - smlErrorPrint(&error)); + error->message); goto error; break; case SML_MANAGER_SESSION_WARNING: - g_warning("WARNING: %s\n", smlErrorPrint(&error)); + g_warning("WARNING: %s\n", error->message); break; default: g_warning("%s: Unknown event received: %d.", __func__, type); @@ -340,13 +341,13 @@ g_mutex_unlock(dsObject->managerMutex); smlTrace(TRACE_EXIT, "%s", __func__); return; - error: g_mutex_unlock(dsObject->managerMutex); - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(&error)); smlDataSyncSendEvent( dsObject, SML_DATA_SYNC_EVENT_ERROR, dsObject->eventUserdata, error); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, error->message); + g_error_free(error); } /* *************************************** */ @@ -396,10 +397,11 @@ #if 0 /* UNUSED */ error: - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(&error)); smlDataSyncSendEvent( dsObject, SML_DATA_SYNC_EVENT_ERROR, dsObject->eventUserdata, error); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, error->message); + g_error_free(error); #endif /* UNUSED */ } @@ -429,15 +431,14 @@ if (code >= 300 && code != SML_ERROR_REQUIRE_REFRESH) { /* This is an error. */ - SmlError *error = NULL; - smlErrorSet(&error, SML_ERROR_GENERIC, + GError *error = NULL; + g_set_error(&error, SML_ERROR, code, "The alert response signals an error - %d.", code); - smlErrorRef(&error); smlDataSyncSendEvent( datastore->dsObject, SML_DATA_SYNC_EVENT_ERROR, datastore->dsObject->eventUserdata, 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); } else { smlTrace(TRACE_EXIT, "%s", __func__); } @@ -449,12 +450,12 @@ void smlDataSyncSyncCallback( SmlDsSession *dsession, - unsigned int numchanges, + gsize numchanges, void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, dsession, numchanges, userdata); SmlDataSyncDatastore *datastore = userdata; - SmlError *error = NULL; + GError *error = NULL; /* If the device information was not sent together with the * alerts and it was not cached then the device information @@ -467,10 +468,11 @@ smlTrace(TRACE_EXIT, "%s", __func__); return; error: - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(&error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, error->message); smlDataSyncSendEvent( datastore->dsObject, SML_DATA_SYNC_EVENT_ERROR, datastore->dsObject->eventUserdata, error); + g_error_free(error); } void smlDataSyncSyncStatusCallback( @@ -515,16 +517,15 @@ // smlManagerStop(database->env->manager); // smlManagerQuit(database->env->manager); // printf(" Manager finished.\n"); - SmlError *error = NULL; - smlErrorSet(&error, smlStatusGetCode(status), + GError *error = NULL; + g_set_error(&error, SML_ERROR, smlStatusGetCode(status), "Sync failed with error %d.", smlStatusGetCode(status)); - smlErrorRef(&error); smlDataSyncSendEvent( datastore->dsObject, SML_DATA_SYNC_EVENT_ERROR, datastore->dsObject->eventUserdata, 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); } else { smlTrace(TRACE_EXIT, "%s", __func__); } @@ -534,15 +535,15 @@ /* ***** Change Callbacks ***** */ /* ************************************ */ -SmlBool smlDataSyncChangeCallback( +gboolean smlDataSyncChangeCallback( SmlDsSession *dsession, SmlChangeType type, - const char *uid, - char *data, - unsigned int size, - const char *contenttype, + const gchar *uid, + gchar *data, + gsize size, + const gchar *contenttype, void *userdata, - SmlError **error) + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %s, %p, %i, %s, %p, %p)", __func__, dsession, type, VA_STRING(uid), data, size, VA_STRING(contenttype), userdata, error); CHECK_ERROR_REF @@ -580,7 +581,7 @@ size = length; smlSafeCFree(&b64data); if (!data) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The base 64 decoding of glib failed."); goto error; } @@ -599,18 +600,17 @@ 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 smlDataSyncChangeStatusCallback( SmlDsSession *dsession, SmlStatus *status, - const char *newuid, void *userdata) { - smlTrace(TRACE_ENTRY, "%s(%p, %p, %s, %p)", __func__, dsession, status, VA_STRING(newuid), userdata); - SmlError *error = NULL; + smlTrace(TRACE_ENTRY, "%s(%p, %p, %s, %p)", __func__, dsession, status, userdata); + GError *error = NULL; smlAssert(userdata); SmlDataSyncChange *change = userdata; @@ -622,19 +622,17 @@ !dsObject->changeStatusCallback( dsObject, smlStatusGetCode(status), - newuid, change->userdata, &error)) goto error; smlTrace(TRACE_EXIT, "%s", __func__); return; error: - smlErrorRef(&error); smlDataSyncSendEvent( dsObject, SML_DATA_SYNC_EVENT_ERROR, dsObject->eventUserdata, 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); } void smlDataSyncMappingCallback( @@ -645,7 +643,7 @@ { smlTrace(TRACE_ENTRY, "%s(%p, %s, %s, %p)", __func__, dsession, VA_STRING(sml_location_get_uri(orig)), VA_STRING(sml_location_get_uri(newuid)), userdata); - SmlError *error = NULL; + GError *error = NULL; SmlDataSyncDatastore *datastore = userdata; smlAssert(datastore); @@ -664,12 +662,11 @@ smlTrace(TRACE_EXIT, "%s", __func__); return; error: - smlErrorRef(&error); smlDataSyncSendEvent( datastore->dsObject, SML_DATA_SYNC_EVENT_ERROR, datastore->dsObject->eventUserdata, 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); } /* ********************************* */ @@ -685,13 +682,14 @@ if (smlStatusGetClass(status) != SML_ERRORCLASS_SUCCESS) { SmlDataSyncDatastore *datastore = userdata; - SmlError *error = NULL; - smlErrorSet(&error, smlStatusGetCode(status), + GError *error = NULL; + g_set_error(&error, SML_ERROR, smlStatusGetCode(status), "Map of datastore %s was rejected with error code %d", datastore->sourceUri, smlStatusGetCode(status)); smlDataSyncSendEvent( datastore->dsObject, SML_DATA_SYNC_EVENT_ERROR, datastore->dsObject->eventUserdata, error); + g_error_free(error); } smlTrace(TRACE_EXIT, "%s", __func__); } @@ -700,12 +698,12 @@ /* ***** Authentication Callback ***** */ /* ******************************************* */ -SmlBool smlDataSyncVerifyUserCallback( +gboolean smlDataSyncVerifyUserCallback( SmlChal *chal, SmlCred *cred, - const char *username, + const gchar *username, void *userdata, - SmlError **error) + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %s, %p)", __func__, chal, cred, VA_STRING(username), userdata); CHECK_ERROR_REF Modified: trunk/libsyncml/data_sync_api/data_sync_callbacks.h ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_callbacks.h Sun Jul 5 13:04:42 2009 (r1153) +++ trunk/libsyncml/data_sync_api/data_sync_callbacks.h Tue Jul 7 16:47:34 2009 (r1154) @@ -31,7 +31,7 @@ SmlManager *manager, SmlManagerEventType type, SmlSession *session, - SmlError *error, + GError *error, void *userdata); /* *************************************** */ @@ -61,7 +61,7 @@ void smlDataSyncSyncCallback( SmlDsSession *dsession, - unsigned int numchanges, + gsize numchanges, void *userdata); void smlDataSyncSyncStatusCallback( @@ -73,20 +73,19 @@ /* ***** Change Callbacks ***** */ /* ************************************ */ -SmlBool smlDataSyncChangeCallback( +gboolean smlDataSyncChangeCallback( SmlDsSession *dsession, SmlChangeType type, - const char *uid, - char *data, - unsigned int size, - const char *contenttype, + const gchar *uid, + gchar *data, + gsize size, + const gchar *contenttype, void *userdata, - SmlError **smlerror); + GError **error); void smlDataSyncChangeStatusCallback( SmlDsSession *dsession, SmlStatus *status, - const char *newuid, void *userdata); void smlDataSyncMappingCallback( @@ -108,11 +107,11 @@ /* ***** Authentication Callback ***** */ /* ******************************************* */ -SmlBool smlDataSyncVerifyUserCallback( +gboolean smlDataSyncVerifyUserCallback( SmlChal *chal, SmlCred *cred, - const char *username, + const gchar *username, void *userdata, - SmlError **error); + GError **error); #endif /* _SML_DATA_SYNC_CALLBACKS_H */ Modified: trunk/libsyncml/data_sync_api/data_sync_client.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_client.c Sun Jul 5 13:04:42 2009 (r1153) +++ trunk/libsyncml/data_sync_api/data_sync_client.c Tue Jul 7 16:47:34 2009 (r1154) @@ -26,20 +26,19 @@ #include "data_sync_devinf.h" #include "libsyncml/sml_support.h" -static SmlBool smlDataSyncClientAlertCallback( - SmlDsSession *dsession, - SmlAlertType type, - const char *last, - const char *next, - void *userdata) +static gboolean +smlDataSyncClientAlertCallback (SmlDsSession *dsession, + SmlAlertType type, + const gchar *last, + const gchar *next, + void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %s, %s, %p)", __func__, dsession, type, VA_STRING(last), VA_STRING(next), userdata); SmlDataSyncDatastore *datastore = userdata; SmlDataSyncObject *dsObject = datastore->dsObject; - SmlBool ret = TRUE; - SmlError *error = NULL; - GError *gerror = NULL; + gboolean ret = TRUE; + GError *error = NULL; /* libsyncml only supports SML_ALERT_TWO_WAY and SML_ALERT_SLOW_SYNC * but some old phones reply on a SAN alert 206 with a slow sync 201 @@ -51,7 +50,8 @@ type != SML_ALERT_SLOW_SYNC && type != SML_ALERT_TWO_WAY_BY_SERVER) { - smlErrorSet(&error, SML_ERROR_NOT_IMPLEMENTED, "Unsupported alert type %d.", type); + g_set_error(&error, SML_ERROR, SML_ERROR_NOT_IMPLEMENTED, + "Unsupported alert type %d.", type); goto error; } @@ -113,7 +113,7 @@ */ if (h != type) { if (h != SML_ALERT_SLOW_SYNC) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "It is not possible to change the alert type after an OMA DS client received the alerts from the OMA DS server."); goto error; } else { @@ -121,10 +121,11 @@ SmlLocation *source = NULL; source = sml_location_new(); if (!source) { - g_set_error(&gerror, SML_ERROR, SML_ERROR_GENERIC, "Cannot create new SmlLocation object - out of memory."); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, + "Cannot create new SmlLocation object - out of memory."); goto error; } - if (!sml_location_set_uri(source, datastore->sourceUri, &gerror)) { + if (!sml_location_set_uri(source, datastore->sourceUri, &error)) { g_object_unref(source); goto error; } @@ -157,23 +158,18 @@ smlTrace(TRACE_EXIT, "%s: %i", __func__, ret); return ret; error: - if (gerror) { - smlErrorSet(&error, gerror->code, "%s", gerror->message); - g_error_free(gerror); - } - smlErrorRef(&error); smlDataSyncSendEvent( dsObject, SML_DATA_SYNC_EVENT_ERROR, dsObject->eventUserdata, 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); return FALSE; } -SmlBool smlDataSyncClientSendAlert( - SmlDataSyncDatastore *datastore, - SmlAlertType type, - SmlError **error) +gboolean +smlDataSyncClientSendAlert (SmlDataSyncDatastore *datastore, + SmlAlertType type, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %d, %p)", __func__, datastore, type, error); CHECK_ERROR_REF @@ -260,7 +256,7 @@ * This can happen if the remote peer did not trigger * the client via a SAN (e.g. OMA DS client over HTTP). */ - SmlBool ret = TRUE; + gboolean ret = TRUE; if (alertType == SML_ALERT_SLOW_SYNC && alertType != type && type != SML_ALERT_UNKNOWN) { @@ -270,7 +266,7 @@ smlTrace(TRACE_EXIT, "%s: %i", __func__, ret); return ret; error: - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } @@ -283,7 +279,7 @@ smlTrace(TRACE_ENTRY, "%s(%p, %p, %d, %p)", __func__, server, session, type, userdata); SmlDataSyncDatastore *datastore = userdata; SmlDataSyncObject *dsObject = datastore->dsObject; - SmlError *error = NULL; + GError *error = NULL; SmlErrorType ret = SML_NO_ERROR; /* soemtimes the event manager thread is too slow */ @@ -302,20 +298,20 @@ smlTrace(TRACE_EXIT, "%s: %i", __func__, ret); return ret; error: - smlErrorRef(&error); smlDataSyncSendEvent( dsObject, SML_DATA_SYNC_EVENT_ERROR, dsObject->eventUserdata, 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); return SML_ERROR_GENERIC; } -SmlBool smlDataSyncClientInit(SmlDataSyncObject *dsObject, SmlError **error) +gboolean +smlDataSyncClientInit (SmlDataSyncObject *dsObject, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, dsObject, error); CHECK_ERROR_REF - GError *gerror = NULL; /* The manager responsible for handling the other objects */ dsObject->manager = smlManagerNew(dsObject->tsp, error); @@ -341,10 +337,10 @@ /* We now create the ds server at the given location. */ SmlLocation *loc = sml_location_new(); if (!loc) { - g_set_error(&gerror, SML_ERROR, SML_ERROR_GENERIC, "Cannot create new SmlLocation object - out of memory."); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Cannot create new SmlLocation object - out of memory."); goto error; } - if (!sml_location_set_uri(loc, datastore->sourceUri, &gerror)) + if (!sml_location_set_uri(loc, datastore->sourceUri, error)) goto error; datastore->server = smlDsClientNew(datastore->contentType, loc, loc, error); @@ -385,11 +381,7 @@ return TRUE; error: - if (gerror) { - smlErrorSet(error, gerror->code, "%s", gerror->message); - g_error_free(gerror); - } - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } Modified: trunk/libsyncml/data_sync_api/data_sync_client.h ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_client.h Sun Jul 5 13:04:42 2009 (r1153) +++ trunk/libsyncml/data_sync_api/data_sync_client.h Tue Jul 7 16:47:34 2009 (r1154) @@ -23,13 +23,13 @@ #include "data_sync.h" -SmlBool smlDataSyncClientInit( +gboolean smlDataSyncClientInit( SmlDataSyncObject *dsObject, - SmlError **error); + GError **error); -SmlBool smlDataSyncClientSendAlert( +gboolean smlDataSyncClientSendAlert( SmlDataSyncDatastore *datastore, SmlAlertType type, - SmlError **error); + GError **error); #endif /* _SML_DATA_SYNC_SERVER_H_ */ Modified: trunk/libsyncml/data_sync_api/data_sync_common.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_common.c Sun Jul 5 13:04:42 2009 (r1153) +++ trunk/libsyncml/data_sync_api/data_sync_common.c Tue Jul 7 16:47:34 2009 (r1154) @@ -24,7 +24,9 @@ #include "data_sync_devinf.h" -SmlBool smlDataSyncIsTimestamp(const char *anchor, SmlBool timestampDefault) +gboolean +smlDataSyncIsTimestamp (const gchar *anchor, + gboolean timestampDefault) { smlTrace(TRACE_ENTRY, "%s(%s, %d)", __func__, VA_STRING(anchor), timestampDefault); if (anchor == NULL || strlen(anchor) < 1) @@ -46,14 +48,14 @@ } } -char *smlDataSyncGetNextAnchor( - SmlDataSyncDatastore *datastore, - const char *last, - SmlError **error) +gchar* +smlDataSyncGetNextAnchor (SmlDataSyncDatastore *datastore, + const gchar *last, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%s)", __func__, VA_STRING(last)); CHECK_ERROR_REF - SmlBool use_timestamp = TRUE; + gboolean use_timestamp = TRUE; char *next = NULL; use_timestamp = smlDataSyncIsTimestamp(last, @@ -100,6 +102,6 @@ smlTrace(TRACE_EXIT, "%s(%s)", __func__, VA_STRING(next)); return next; error: - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return NULL; } Modified: trunk/libsyncml/data_sync_api/data_sync_common.h ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_common.h Sun Jul 5 13:04:42 2009 (r1153) +++ trunk/libsyncml/data_sync_api/data_sync_common.h Tue Jul 7 16:47:34 2009 (r1154) @@ -23,11 +23,11 @@ #include "data_sync.h" -SmlBool smlDataSyncIsTimestamp(const char *anchor, SmlBool timestampDefault); +gboolean smlDataSyncIsTimestamp(const gchar *anchor, gboolean timestampDefault); -char *smlDataSyncGetNextAnchor( +gchar *smlDataSyncGetNextAnchor( SmlDataSyncDatastore *datastore, - const char *last, - SmlError **error); + const gchar *last, + GError **error); #endif /* _SML_DATA_SYNC_COMMON_H_ */ Modified: trunk/libsyncml/data_sync_api/data_sync_devinf.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_devinf.c Sun Jul 5 13:04:42 2009 (r1153) +++ trunk/libsyncml/data_sync_api/data_sync_devinf.c Tue Jul 7 16:47:34 2009 (r1154) @@ -22,43 +22,39 @@ #include "libsyncml/syncml_internals.h" #include "libsyncml/sml_error_internals.h" -static SmlDevInfProperty *_add_ctcap_property_by_name( - SmlDevInfCTCap *ctcap, - const char *name, - SmlError **error) +static SmlDevInfProperty* +_add_ctcap_property_by_name (SmlDevInfCTCap *ctcap, + const gchar *name, + GError **error) { smlTrace(TRACE_ENTRY, "%s (%s)", __func__, VA_STRING(name)); CHECK_ERROR_REF smlAssert(ctcap); smlAssert(name); - GError *gerror = NULL; SmlDevInfProperty *prop = sml_dev_inf_property_new(); if (!prop) { - smlErrorSet(error, SML_ERROR_GENERIC, "Cannot create new instance of SmlDevInfProperty - out of memory."); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Cannot create new instance of SmlDevInfProperty - out of memory."); goto error; } - if (!sml_dev_inf_property_set_prop_name(prop, name, &gerror)) + if (!sml_dev_inf_property_set_prop_name(prop, name, error)) goto error; - if (!sml_dev_inf_ctcap_add_property(ctcap, prop, &gerror)) + if (!sml_dev_inf_ctcap_add_property(ctcap, prop, error)) goto error; smlTrace(TRACE_EXIT, "%s", __func__); return prop; error: - if (gerror) { - smlErrorSet(error, gerror->code, "%s", gerror->message); - g_error_free(gerror); - } - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -static SmlDevInfProperty *_add_ctcap_property_by_name_value( - SmlDevInfCTCap *ctcap, - const char*name, - const char *value, - SmlError **error) +static SmlDevInfProperty* +_add_ctcap_property_by_name_value (SmlDevInfCTCap *ctcap, + const gchar* name, + const gchar *value, + GError **error) { smlTrace(TRACE_ENTRY, "%s (%s ::= %s)", __func__, VA_STRING(name), VA_STRING(value)); CHECK_ERROR_REF @@ -66,66 +62,57 @@ smlAssert(name); smlAssert(value); - GError *gerror = NULL; SmlDevInfProperty *prop = _add_ctcap_property_by_name(ctcap, name, error); if (!prop) goto error; - if (!sml_dev_inf_property_add_val_enum(prop, value, &gerror)) + if (!sml_dev_inf_property_add_val_enum(prop, value, error)) goto error; smlTrace(TRACE_EXIT, "%s", __func__); return prop; error: - if (gerror) { - smlErrorSet(error, gerror->code, "%s", gerror->message); - g_error_free(gerror); - } - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -static SmlDevInfPropParam *_add_property_param( - SmlDevInfProperty *prop, - const char *name, - SmlError **error) +static SmlDevInfPropParam* +_add_property_param (SmlDevInfProperty *prop, + const gchar *name, + GError **error) { smlTrace(TRACE_ENTRY, "%s (%s)", __func__, VA_STRING(name)); CHECK_ERROR_REF smlAssert(prop); smlAssert(name); - GError *gerror = NULL; SmlDevInfPropParam *param = sml_dev_inf_prop_param_new(); if (!param) { - smlErrorSet(error, SML_ERROR_GENERIC, "Cannot create new PropParam for SyncML device information."); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Cannot create new PropParam for SyncML device information."); goto error; } - if (!sml_dev_inf_prop_param_set_param_name(param, name, &gerror)) + if (!sml_dev_inf_prop_param_set_param_name(param, name, error)) goto error; - if (!sml_dev_inf_property_add_param(prop, param, &gerror)) + if (!sml_dev_inf_property_add_param(prop, param, error)) goto error; smlTrace(TRACE_EXIT, "%s", __func__); return param; error: - if (gerror) { - smlErrorSet(error, gerror->code, "%s", gerror->message); - g_error_free(gerror); - } - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } #define _ADD_PROPERTY_VAL_ENUM(text) \ - if (!sml_dev_inf_property_add_val_enum(prop, text, &gerror)) \ + if (!sml_dev_inf_property_add_val_enum(prop, text, error)) \ goto error; #define _ADD_PROPERTY_PARAM(text) \ param = _add_property_param(prop, text, error); \ if (!param) \ goto error; #define _ADD_PROP_PARAM_VAL_ENUM(text) \ - if (!sml_dev_inf_prop_param_add_val_enum(param, text, &gerror)) \ + if (!sml_dev_inf_prop_param_add_val_enum(param, text, error)) \ goto error; #define _ADD_CTCAP_PROPERTY_BY_NAME(text) \ prop = _add_ctcap_property_by_name(ctcap, text, error); \ @@ -135,11 +122,11 @@ if (!_add_ctcap_property_by_name_value(ctcap, name, value, error)) \ goto error; -static SmlBool add_devinf_ctcap( - SmlDevInf *devinf, - const char* cttype, - const char *verct, - SmlError **error) +static gboolean +add_devinf_ctcap (SmlDevInf *devinf, + const gchar *cttype, + const gchar *verct, + GError **error) { smlTrace(TRACE_ENTRY, "%s (%s %s)", __func__, VA_STRING(cttype), VA_STRING(verct)); CHECK_ERROR_REF @@ -148,8 +135,7 @@ smlAssert(verct); // first we check for an already configure CTCap - GError *gerror = NULL; - SmlDevInfContentType *ct = sml_dev_inf_content_type_new(cttype, verct, &gerror); + SmlDevInfContentType *ct = sml_dev_inf_content_type_new(cttype, verct, error); if (!ct) { goto error; } @@ -172,10 +158,10 @@ { smlTrace(TRACE_INTERNAL, "%s: vCard 2.1 detected", __func__); - SmlDevInfContentType *ct = sml_dev_inf_content_type_new(SML_ELEMENT_TEXT_VCARD, "2.1", &gerror); + SmlDevInfContentType *ct = sml_dev_inf_content_type_new(SML_ELEMENT_TEXT_VCARD, "2.1", error); if (!ct) goto error; - ctcap = sml_dev_inf_ctcap_new(ct, &gerror); + ctcap = sml_dev_inf_ctcap_new(ct, error); g_object_unref(ct); if (!ctcap) goto error; @@ -282,7 +268,7 @@ _ADD_PROPERTY_PARAM("WORK"); _ADD_PROPERTY_PARAM("HOME"); _ADD_CTCAP_PROPERTY_BY_NAME_VALUE("VERSION", "2.1") - if (!sml_dev_inf_add_ctcap(devinf, ctcap, &gerror)) + if (!sml_dev_inf_add_ctcap(devinf, ctcap, error)) goto error; } else if (!strcmp(cttype, SML_ELEMENT_TEXT_VCARD_30) && @@ -292,10 +278,10 @@ // FIXME: this is in terms of vCard 3.0 a bug smlTrace(TRACE_INTERNAL, "%s: vCard 3.0 detected", __func__); - SmlDevInfContentType *ct = sml_dev_inf_content_type_new(SML_ELEMENT_TEXT_VCARD_30, "3.0", &gerror); + SmlDevInfContentType *ct = sml_dev_inf_content_type_new(SML_ELEMENT_TEXT_VCARD_30, "3.0", error); if (!ct) goto error; - ctcap = sml_dev_inf_ctcap_new(ct, &gerror); + ctcap = sml_dev_inf_ctcap_new(ct, error); g_object_unref(ct); if (!ctcap) goto error; @@ -327,7 +313,7 @@ _ADD_CTCAP_PROPERTY_BY_NAME("NOTE") _ADD_CTCAP_PROPERTY_BY_NAME("PHOTO") _ADD_PROPERTY_PARAM("TYPE") - if (!sml_dev_inf_add_ctcap(devinf, ctcap, &gerror)) + if (!sml_dev_inf_add_ctcap(devinf, ctcap, error)) goto error; } /* Oracle collaboration Suite uses the content type to distinguish */ @@ -340,10 +326,10 @@ { smlTrace(TRACE_INTERNAL, "%s: vCalendar 1.0 detected", __func__); - SmlDevInfContentType *ct = sml_dev_inf_content_type_new(SML_ELEMENT_TEXT_VCAL, "1.0", &gerror); + SmlDevInfContentType *ct = sml_dev_inf_content_type_new(SML_ELEMENT_TEXT_VCAL, "1.0", error); if (!ct) goto error; - ctcap = sml_dev_inf_ctcap_new(ct, &gerror); + ctcap = sml_dev_inf_ctcap_new(ct, error); g_object_unref(ct); if (!ctcap) goto error; @@ -385,7 +371,7 @@ _ADD_CTCAP_PROPERTY_BY_NAME("SUMMARY") _ADD_CTCAP_PROPERTY_BY_NAME("UID") _ADD_CTCAP_PROPERTY_BY_NAME_VALUE("VERSION", "1.0") - if (!sml_dev_inf_add_ctcap(devinf, ctcap, &gerror)) + if (!sml_dev_inf_add_ctcap(devinf, ctcap, error)) goto error; } else if (!strcmp(cttype, SML_ELEMENT_TEXT_ICAL) && @@ -396,10 +382,10 @@ // FIXME: this is a bug in terms of iCal smlTrace(TRACE_INTERNAL, "%s: iCalendar (vCalendar 2.0) detected", __func__); - SmlDevInfContentType *ct = sml_dev_inf_content_type_new(SML_ELEMENT_TEXT_ICAL, "2.0", &gerror); + SmlDevInfContentType *ct = sml_dev_inf_content_type_new(SML_ELEMENT_TEXT_ICAL, "2.0", error); if (!ct) goto error; - ctcap = sml_dev_inf_ctcap_new(ct, &gerror); + ctcap = sml_dev_inf_ctcap_new(ct, error); g_object_unref(ct); if (!ctcap) goto error; @@ -440,7 +426,7 @@ _ADD_CTCAP_PROPERTY_BY_NAME("SUMMARY") _ADD_CTCAP_PROPERTY_BY_NAME("UID") _ADD_CTCAP_PROPERTY_BY_NAME_VALUE("VERSION", "2.0") - if (!sml_dev_inf_add_ctcap(devinf, ctcap, &gerror)) + if (!sml_dev_inf_add_ctcap(devinf, ctcap, error)) goto error; } else @@ -448,26 +434,22 @@ /* trace the missing stuff and create a minimal CTCap */ smlTrace(TRACE_INTERNAL, "%s: unknown content type - %s %s", __func__, VA_STRING(cttype), VA_STRING(verct)); - SmlDevInfContentType *ct = sml_dev_inf_content_type_new(cttype, verct, &gerror); + SmlDevInfContentType *ct = sml_dev_inf_content_type_new(cttype, verct, error); if (!ct) goto error; - ctcap = sml_dev_inf_ctcap_new(ct, &gerror); + ctcap = sml_dev_inf_ctcap_new(ct, error); g_object_unref(ct); if (!ctcap) goto error; - if (!sml_dev_inf_add_ctcap(devinf, ctcap, &gerror)) + if (!sml_dev_inf_add_ctcap(devinf, ctcap, error)) goto error; } smlTrace(TRACE_EXIT, "%s - content type newly added to devinf", __func__); return TRUE; error: - if (gerror) { - smlErrorSet(error, gerror->code, "%s", gerror->message); - g_error_free(gerror); - } - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } @@ -495,54 +477,53 @@ /* here start the internal API functions */ #define _ADD_DATASTORE_RX(cttype,verct) \ - ctype = sml_dev_inf_content_type_new(cttype, verct, &gerror); \ + ctype = sml_dev_inf_content_type_new(cttype, verct, error); \ if (!ctype) \ goto error; \ - if (!sml_dev_inf_data_store_add_rx(ds, ctype, &gerror)) \ + if (!sml_dev_inf_data_store_add_rx(ds, ctype, error)) \ goto error; \ g_object_unref(ctype); \ ctype = NULL; #define _ADD_DATASTORE_TX(cttype,verct) \ - ctype = sml_dev_inf_content_type_new(cttype, verct, &gerror); \ + ctype = sml_dev_inf_content_type_new(cttype, verct, error); \ if (!ctype) \ goto error; \ - if (!sml_dev_inf_data_store_add_tx(ds, ctype, &gerror)) \ + if (!sml_dev_inf_data_store_add_tx(ds, ctype, error)) \ goto error; \ g_object_unref(ctype); \ ctype = NULL; #define _SET_DATASTORE_RX_PREF(cttype,verct) \ - ctype = sml_dev_inf_content_type_new(cttype, verct, &gerror); \ + ctype = sml_dev_inf_content_type_new(cttype, verct, error); \ if (!ctype) \ goto error; \ - if (!sml_dev_inf_data_store_set_rx_pref(ds, ctype, &gerror)) \ + if (!sml_dev_inf_data_store_set_rx_pref(ds, ctype, error)) \ goto error; \ g_object_unref(ctype); \ ctype = NULL; #define _SET_DATASTORE_TX_PREF(cttype,verct) \ - ctype = sml_dev_inf_content_type_new(cttype, verct, &gerror); \ + ctype = sml_dev_inf_content_type_new(cttype, verct, error); \ if (!ctype) \ goto error; \ - if (!sml_dev_inf_data_store_set_tx_pref(ds, ctype, &gerror)) \ + if (!sml_dev_inf_data_store_set_tx_pref(ds, ctype, error)) \ goto error; \ g_object_unref(ctype); \ ctype = NULL; -SmlBool smlDataSyncDevInfAddDatastore( - SmlDevInf *devinf, - SmlDataSyncDatastore *datastore, - SmlError **error) +gboolean +smlDataSyncDevInfAddDatastore (SmlDevInf *devinf, + SmlDataSyncDatastore *datastore, + GError **error) { smlTrace(TRACE_ENTRY, "%s (%p, %p)", __func__, devinf, datastore); CHECK_ERROR_REF smlAssert(datastore); smlAssert(datastore->contentType); smlAssert(datastore->sourceUri); - GError *gerror = NULL; - SmlDevInfDataStore *ds = sml_dev_inf_data_store_new(datastore->sourceUri, &gerror); + SmlDevInfDataStore *ds = sml_dev_inf_data_store_new(datastore->sourceUri, error); if (!ds) goto error; @@ -631,23 +612,19 @@ sml_dev_inf_data_store_set_sync_cap(ds, SML_DEVINF_SYNCTYPE_SERVER_ALERTED_SYNC, TRUE); } - if (!sml_dev_inf_add_data_store(devinf, ds, &gerror)) + if (!sml_dev_inf_add_data_store(devinf, ds, error)) goto error; smlTrace(TRAC... [truncated message content] |
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_ |
From: <svn...@op...> - 2009-07-03 14:55:22
|
Author: bellmich Date: Fri Jul 3 16:55:04 2009 New Revision: 1152 URL: http://libsyncml.opensync.org/changeset/1152 Log: - session IDs are always unsigned integer - message and command IDs are always unsigned integer - gsize is the maximum unsigned integer type which can be used for IDs Modified: trunk/libsyncml/sml_elements.c trunk/libsyncml/sml_elements_internals.h trunk/libsyncml/sml_manager.c trunk/libsyncml/sml_manager.h trunk/libsyncml/sml_notification.c trunk/libsyncml/sml_session.c trunk/libsyncml/sml_session.h trunk/libsyncml/sml_session_internals.h Modified: trunk/libsyncml/sml_elements.c ============================================================================== --- trunk/libsyncml/sml_elements.c Fri Jul 3 16:29:48 2009 (r1151) +++ trunk/libsyncml/sml_elements.c Fri Jul 3 16:55:04 2009 (r1152) @@ -71,9 +71,6 @@ { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, header); - if (header->sessionID) - smlSafeCFree(&(header->sessionID)); - if (header->emi) smlSafeCFree(&(header->emi)); Modified: trunk/libsyncml/sml_elements_internals.h ============================================================================== --- trunk/libsyncml/sml_elements_internals.h Fri Jul 3 16:29:48 2009 (r1151) +++ trunk/libsyncml/sml_elements_internals.h Fri Jul 3 16:55:04 2009 (r1152) @@ -63,7 +63,7 @@ }; struct SmlHeader { - gchar *sessionID; + gsize sessionID; SmlProtocolVersion version; SmlProtocolType protocol; SmlLocation *source; Modified: trunk/libsyncml/sml_manager.c ============================================================================== --- trunk/libsyncml/sml_manager.c Fri Jul 3 16:29:48 2009 (r1151) +++ trunk/libsyncml/sml_manager.c Fri Jul 3 16:55:04 2009 (r1152) @@ -661,13 +661,13 @@ SmlSession* smlManagerSessionFind (SmlManager *manager, - const gchar *sessionID) + gsize sessionID) { - smlTrace(TRACE_ENTRY, "%s(%p, %s)", __func__, manager, VA_STRING(sessionID)); + smlTrace(TRACE_ENTRY, "%s(%p, %uld)", __func__, manager, sessionID); GList *s = NULL; for (s = manager->sessions; s; s = s->next) { managerSession *session = s->data; - if (!strcmp(smlSessionGetSessionID(session->session), sessionID)) { + if (smlSessionGetSessionID(session->session) == sessionID) { smlTrace(TRACE_EXIT, "%s: FOUND %p", __func__, session); return session->session; } @@ -825,9 +825,7 @@ goto error; } } else { - char *lastid = smlManagerGetNewSessionID(manager); - smlSessionSetSessionID(session, lastid); - smlSafeCFree(&lastid); + smlSessionSetSessionID(session, smlManagerGetNewSessionID(manager)); } managerSession *sess = smlTryMalloc0(sizeof(managerSession), error); @@ -1425,25 +1423,24 @@ manager->localMaxObjSize = size; } -gchar* +gsize smlManagerGetNewSessionID (SmlManager *manager) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, manager); smlAssertMsg(manager, "The manager is required to avoid duplicated session IDs."); - char *sessionString = NULL; - while (sessionString == NULL) + gsize sessionID = 0; + while (sessionID == 0) { - /* WARNING: only 4 byte session IDs are theoretically allowed !!! */ + /* WARNING: only 4 digit session IDs are theoretically allowed !!! */ /* create random session ID - glib only supports 32 bit random numbers */ - unsigned int sessionID = (unsigned int) g_random_int_range (0, 0xFFFF); - sessionString = g_strdup_printf("%u", sessionID); - smlTrace(TRACE_INTERNAL, "%s: new potential session ID is %lu.", __func__, sessionID); - if (smlManagerSessionFind(manager, sessionString)) - smlSafeCFree(&sessionString); + sessionID = (gsize) g_random_int_range (0, 9999); + smlTrace(TRACE_INTERNAL, "%s: new potential session ID is %ud.", __func__, sessionID); + if (smlManagerSessionFind(manager, sessionID)) + sessionID = 0; } - smlTrace(TRACE_EXIT, "%s - %s", __func__, VA_STRING(sessionString)); - return sessionString; + smlTrace(TRACE_EXIT, "%s - %ud", __func__, sessionID); + return sessionID; } SmlLink* @@ -1458,7 +1455,7 @@ if (!_msession) { g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, - "The session %s is not registered at the manager.", + "The session %ulld is not registered at the manager.", smlSessionGetSessionID(session)); goto error; } Modified: trunk/libsyncml/sml_manager.h ============================================================================== --- trunk/libsyncml/sml_manager.h Fri Jul 3 16:29:48 2009 (r1151) +++ trunk/libsyncml/sml_manager.h Fri Jul 3 16:55:04 2009 (r1152) @@ -53,7 +53,7 @@ gboolean smlManagerReceive (SmlManager *manager, GError **error); void smlManagerSetEventCallback (SmlManager *manager, SmlManagerEventCb callback, void *userdata); -SmlSession* smlManagerSessionFind (SmlManager *manager, const gchar *sessionID); +SmlSession* smlManagerSessionFind (SmlManager *manager, gsize sessionID); gboolean smlManagerSessionAdd (SmlManager *manager, SmlSession *session, SmlLink *link, GError **error); void smlManagerSessionRemove (SmlManager *manager, SmlSession *session); @@ -77,7 +77,7 @@ void smlManagerSetLocalMaxMsgSize (SmlManager *manager, gsize size); void smlManagerSetLocalMaxObjSize (SmlManager *manager, gsize size); -gchar* smlManagerGetNewSessionID (SmlManager *manager); +gsize smlManagerGetNewSessionID (SmlManager *manager); #endif //_SML_MANAGER_H Modified: trunk/libsyncml/sml_notification.c ============================================================================== --- trunk/libsyncml/sml_notification.c Fri Jul 3 16:29:48 2009 (r1151) +++ trunk/libsyncml/sml_notification.c Fri Jul 3 16:55:04 2009 (r1152) @@ -376,14 +376,11 @@ if (!source) goto error; - char *sessionString = smlManagerGetNewSessionID(san->manager); - session = smlSessionNew(san->sessionType, san->type, version, SML_PROTOCOL_SYNCML, san->target, source, sessionString, 0, error); + session = smlSessionNew(san->sessionType, san->type, version, SML_PROTOCOL_SYNCML, san->target, source, smlManagerGetNewSessionID(san->manager), 0, error); if (!session) { - smlSafeCFree(&sessionString); g_object_unref(source); goto error; } - smlSafeCFree(&sessionString); smlManagerSessionAdd(san->manager, session, NULL, error); assm = smlAssemblerNew(san->type, 0, error); Modified: trunk/libsyncml/sml_session.c ============================================================================== --- trunk/libsyncml/sml_session.c Fri Jul 3 16:29:48 2009 (r1151) +++ trunk/libsyncml/sml_session.c Fri Jul 3 16:55:04 2009 (r1152) @@ -1803,7 +1803,7 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -const gchar* +gsize smlSessionGetSessionID (SmlSession *session) { smlAssert(session); @@ -1813,13 +1813,10 @@ void smlSessionSetSessionID (SmlSession *session, - const gchar *sessionID) + gsize sessionID) { smlAssert(session); - - if (session->sessionID) - smlSafeCFree(&(session->sessionID)); - session->sessionID = g_strdup(sessionID); + session->sessionID = sessionID; } SmlProtocolVersion @@ -1906,11 +1903,11 @@ SmlProtocolType protocol, SmlLocation *target, SmlLocation *source, - const gchar *sessionID, - guint messageID, + gsize sessionID, + gsize 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); + smlTrace(TRACE_ENTRY, "%s(%i, %i, %i, %i, %p, %p, %u, %i, %p)", __func__, sessionType, mimetype, version, protocol, target, source, sessionID, messageID, error); CHECK_ERROR_REF /* Initialize GLib thread system. */ @@ -1927,7 +1924,7 @@ session->version = version; session->protocol = protocol; session->type = mimetype; - session->sessionID = g_strdup(sessionID); + session->sessionID = sessionID; if (messageID) session->lastMessageID = messageID; else @@ -2021,9 +2018,6 @@ if (session->chal) smlChalUnref(session->chal); - if (session->sessionID) - smlSafeCFree(&(session->sessionID)); - if (session->command_queue) { SmlSessionCommand *sesscmd = NULL; while ((sesscmd = smlQueueTryPop(session->command_queue))) @@ -2240,7 +2234,7 @@ CHECK_ERROR_REF if (session->responseURI) { - g_warning("The response URI (%s) of a session (%s) should never be overwritten (%s).", + g_warning("The response URI (%s) of a session (%u) should never be overwritten (%s).", session->responseURI, session->sessionID, responseURI); smlSafeCFree(&(session->responseURI)); } Modified: trunk/libsyncml/sml_session.h ============================================================================== --- trunk/libsyncml/sml_session.h Fri Jul 3 16:29:48 2009 (r1151) +++ trunk/libsyncml/sml_session.h Fri Jul 3 16:55:04 2009 (r1152) @@ -44,7 +44,7 @@ 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 gchar *sessionID, guint messageID, GError **error); +SmlSession* smlSessionNew (SmlSessionType sessionType, SmlMimeType mimetype, SmlProtocolVersion version, SmlProtocolType protocol, SmlLocation *target, SmlLocation *source, const gsize sessionID, gsize messageID, GError **error); SmlSession* smlSessionRef (SmlSession *session); void smlSessionUnref (SmlSession *session); void smlSessionSetEventCallback (SmlSession *session, SmlSessionEventCallback callback, void *userdata); @@ -68,8 +68,8 @@ gsize smlSessionGetLocalMaxObjSize (SmlSession *session); gsize smlSessionGetRemoteMaxObjSize (SmlSession *session); -const gchar* smlSessionGetSessionID (SmlSession *session); -void smlSessionSetSessionID (SmlSession *session, const gchar *sessionID); +gsize smlSessionGetSessionID (SmlSession *session); +void smlSessionSetSessionID (SmlSession *session, gsize sessionID); SmlProtocolVersion smlSessionGetVersion (SmlSession *session); void smlSessionDispatchEvent (SmlSession *session, SmlSessionEventType type, SmlCommand *cmd, SmlCommand *parent, SmlStatus *headerreply, const GError *error); SmlLocation* smlSessionGetSource (SmlSession *session); Modified: trunk/libsyncml/sml_session_internals.h ============================================================================== --- trunk/libsyncml/sml_session_internals.h Fri Jul 3 16:29:48 2009 (r1151) +++ trunk/libsyncml/sml_session_internals.h Fri Jul 3 16:55:04 2009 (r1152) @@ -38,7 +38,7 @@ SmlSessionDataCallback dataCallback; void *dataCallbackUserdata; - gchar *sessionID; + gsize sessionID; SmlLocation *target; SmlLocation *orgTarget; @@ -56,9 +56,9 @@ GList *pendingReplies; - guint lastMessageID; - guint lastReceivedMessageID; - guint lastCommandID; + gsize lastMessageID; + gsize lastReceivedMessageID; + gsize lastCommandID; GList *commands; gboolean final; @@ -97,8 +97,8 @@ }; struct SmlPendingStatus { - guint cmdID; - guint msgID; + gsize cmdID; + gsize msgID; SmlStatusReplyCb callback; void *userdata; }; |
From: <svn...@op...> - 2009-07-03 14:29:53
|
Author: bellmich Date: Fri Jul 3 16:29:48 2009 New Revision: 1151 URL: http://libsyncml.opensync.org/changeset/1151 Log: migrated sml_support from SmlError to GError Modified: trunk/libsyncml/sml_support.c trunk/libsyncml/sml_support.h Modified: trunk/libsyncml/sml_support.c ============================================================================== --- trunk/libsyncml/sml_support.c Fri Jul 3 16:16:21 2009 (r1150) +++ trunk/libsyncml/sml_support.c Fri Jul 3 16:29:48 2009 (r1151) @@ -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 @@ -40,7 +40,8 @@ #define G_ERRORCHECK_MUTEXES -static const char* smlCheckDebugDirectory(const char *env) +static const gchar* +smlCheckDebugDirectory (const gchar *env) { const char *dirname = g_getenv(env); if (!dirname) @@ -70,7 +71,10 @@ /*@{*/ -void smlLog(const char *logname, const char *data, unsigned int size) +void +smlLog (const gchar *logname, + const gchar *data, + gsize size) { #if defined ENABLE_TRACE @@ -117,7 +121,9 @@ * @param message The message to save * */ -void smlTrace(SmlTraceType type, const char *message, ...) +void +smlTrace (SmlTraceType type, + const gchar *message, ...) { #if defined ENABLE_TRACE @@ -165,7 +171,7 @@ { gchar** filters = g_strsplit(filter, ",", 0); gint i; - SmlBool matched = FALSE; + gboolean matched = FALSE; for (i=0; filters[i] != NULL && !matched ; i++) { if (strstr(buffer, filters[i])) @@ -249,7 +255,9 @@ * @param len The length to print * */ -char *smlPrintBinary(const char *data, int len) +gchar* +smlPrintBinary (const gchar *data, + gsize len) { int t; GString *str = g_string_new(""); @@ -268,7 +276,9 @@ * @param len The length to print * */ -char *smlPrintHex(const char *data, int len) +gchar* +smlPrintHex (const gchar *data, + gsize len) { int t; GString *str = g_string_new(""); @@ -299,7 +309,9 @@ * @returns The random string * */ -char *smlRandStr(int maxlength, SmlBool exact) +gchar* +smlRandStr (gsize maxlength, + gboolean exact) { const char *randchars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIKLMNOPQRSTUVWXYZ1234567890"; @@ -332,7 +344,9 @@ * @returns The newly allocated memory or NULL in case of error * */ -void *smlTryMalloc0(long n_bytes, SmlError **error) +void* +smlTryMalloc0 (gsize n_bytes, + GError **error) { CHECK_ERROR_REF @@ -341,7 +355,7 @@ /* set error */ char *msg = NULL; if (n_bytes > 0) - msg = g_strdup_printf("No memory left (needed %ld).", n_bytes); + msg = g_strdup_printf("No memory left (needed %ulld).", n_bytes); else msg = g_strdup_printf("Malloc of zero bytes requested."); @@ -349,7 +363,7 @@ if (error == NULL) g_error("%s", msg); else - smlErrorSet(error, SML_ERROR_INTERNAL_NO_MEMORY, "%s", msg); + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_NO_MEMORY, "%s", msg); return NULL; } memset(result, 0, n_bytes); @@ -361,7 +375,8 @@ * @returns The version as const string * */ -const char *smlGetVersion(void) +const gchar* +smlGetVersion (void) { /** * @version $Id$ @@ -369,7 +384,9 @@ return "$Id$"; } -SmlThread *smlThreadNew(GMainContext *context, SmlError **error) +SmlThread* +smlThreadNew (GMainContext *context, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, context, error); CHECK_ERROR_REF @@ -391,7 +408,7 @@ if (!g_thread_supported ()) g_thread_init (NULL); if (!g_thread_supported ()) { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "Threads are not supported."); goto error; } @@ -405,13 +422,13 @@ smlTrace(TRACE_EXIT, "%s: %p", __func__, thread); return thread; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -void smlThreadFree(SmlThread *thread) +void +smlThreadFree (SmlThread *thread) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, thread); smlAssert(thread); @@ -432,7 +449,8 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -static gpointer smlThreadStartCallback(gpointer data) +static gpointer +smlThreadStartCallback (gpointer data) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, data); SmlThread *thread = data; @@ -462,7 +480,8 @@ return FALSE; } -static gboolean smlThreadStopCallback(gpointer data) +static gboolean +smlThreadStopCallback (gpointer data) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, data); SmlThread *thread = data; @@ -474,7 +493,8 @@ return FALSE; } -void smlThreadStart(SmlThread *thread) +void +smlThreadStart (SmlThread *thread) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, thread); smlAssert(thread); @@ -496,7 +516,8 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -void smlThreadStop(SmlThread *thread) +void +smlThreadStop (SmlThread *thread) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, thread); smlAssert(thread); @@ -523,15 +544,16 @@ GCond *cond; SmlThreadCallFunctionType func; gpointer data; - SmlBool result; - SmlError **error; + gboolean result; + GError **error; } SmlThreadFunctionContext; /** * This callback is used to call a function within a special thread. * Please see smlThreadCallFunction for more details. */ -gboolean smlThreadCallFunctionCallback(gpointer data) +gboolean +smlThreadCallFunctionCallback (gpointer data) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, data); smlAssert(data); @@ -558,11 +580,11 @@ * Please note: This function is blocking. * Please note: The glib source priority is IDLE. */ -SmlBool smlThreadCallFunction( - SmlThread *thread, - SmlThreadCallFunctionType func, - gpointer data, - SmlError **error) +gboolean +smlThreadCallFunction(SmlThread *thread, + SmlThreadCallFunctionType func, + gpointer data, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p => %p, %p, %p, %p)", __func__, thread, thread?thread->context:NULL, func, data, error); CHECK_ERROR_REF @@ -576,12 +598,12 @@ goto error; ctx->mutex = g_mutex_new(); if (!ctx->mutex) { - smlErrorSet(error, SML_ERROR_GENERIC, "Cannot create new mutex."); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Cannot create new mutex."); goto error; } ctx->cond = g_cond_new(); if (!ctx->cond) { - smlErrorSet(error, SML_ERROR_GENERIC, "Cannot create new condition."); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Cannot create new condition."); goto error; } ctx->func = func; @@ -604,7 +626,7 @@ /* cleanup */ smlTrace(TRACE_INTERNAL, "%s: cleanup", __func__); - SmlBool result = ctx->result; + gboolean result = ctx->result; g_source_unref(source); g_mutex_free(ctx->mutex); g_cond_free(ctx->cond); @@ -620,11 +642,12 @@ g_mutex_free(ctx->mutex); if (ctx) smlSafeFree((gpointer *) &ctx); - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } -void smlSafeFree(gpointer *address) +void +smlSafeFree (gpointer *address) { smlAssert(address); smlAssert(*address); @@ -632,17 +655,20 @@ *address = NULL; } -void smlSafeCFree(char **address) +void +smlSafeCFree (gchar **address) { smlSafeFree((gpointer *)address); } -const char *smlGetLibraryVersion() +const gchar* +smlGetLibraryVersion() { return PACKAGE_VERSION; } -const char *smlGetLibrarySoName() +const gchar* +smlGetLibrarySoName() { return PACKAGE_SONAME; } Modified: trunk/libsyncml/sml_support.h ============================================================================== --- trunk/libsyncml/sml_support.h Fri Jul 3 16:16:21 2009 (r1150) +++ trunk/libsyncml/sml_support.h Fri Jul 3 16:29:48 2009 (r1151) @@ -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 @@ -63,17 +63,17 @@ void smlThreadStart (SmlThread *thread); void smlThreadStop (SmlThread *thread); -typedef SmlBool (* SmlThreadCallFunctionType) ( +typedef gboolean (* SmlThreadCallFunctionType) ( gpointer data, GError **error); -SmlBool smlThreadCallFunction( +gboolean smlThreadCallFunction( SmlThread *thread, SmlThreadCallFunctionType func, gpointer data, GError **error); void smlSafeFree (gpointer *address); -void smlSafeCFree (char **address); +void smlSafeCFree (gchar **address); #endif //_SML_SUPPORT_H_ |
From: <svn...@op...> - 2009-07-03 14:16:28
|
Author: bellmich Date: Fri Jul 3 16:16:21 2009 New Revision: 1150 URL: http://libsyncml.opensync.org/changeset/1150 Log: replaced SmlBool with GError Modified: trunk/libsyncml/sml_command.c trunk/libsyncml/sml_command_internals.h trunk/libsyncml/sml_elements_internals.h trunk/libsyncml/sml_notification_internals.h trunk/libsyncml/sml_parse.c trunk/libsyncml/sml_parse.h trunk/libsyncml/sml_session_internals.h Modified: trunk/libsyncml/sml_command.c ============================================================================== --- trunk/libsyncml/sml_command.c Fri Jul 3 16:13:03 2009 (r1149) +++ trunk/libsyncml/sml_command.c Fri Jul 3 16:16:21 2009 (r1150) @@ -201,7 +201,7 @@ return NULL; } -SmlBool +gboolean smlStatusIsResult (SmlStatus *status) { return status->type == SML_COMMAND_TYPE_RESULTS ? TRUE : FALSE; @@ -883,7 +883,7 @@ return NULL; } -SmlBool +gboolean smlCommandAddMapItem (SmlCommand *map, SmlMapItem *item, GError **error) Modified: trunk/libsyncml/sml_command_internals.h ============================================================================== --- trunk/libsyncml/sml_command_internals.h Fri Jul 3 16:13:03 2009 (r1149) +++ trunk/libsyncml/sml_command_internals.h Fri Jul 3 16:16:21 2009 (r1150) @@ -40,7 +40,7 @@ typedef struct SmlCommandSyncPrivate { gsize numChanged; gsize maxObjSize; - SmlBool hasNumChanged; + gboolean hasNumChanged; } SmlCommandSyncPrivate; typedef struct SmlCommandAccessPrivate { @@ -81,14 +81,14 @@ SmlPendingStatus *pendingReply; GList *children; SmlCommand *parent; - SmlBool noResp; + gboolean noResp; gsize size; /** True if the command has already seen a mismatch * in size. If a second mismatch happens, the command is * simply too large */ - SmlBool pushedBack; + gboolean pushedBack; }; struct SmlStatus { Modified: trunk/libsyncml/sml_elements_internals.h ============================================================================== --- trunk/libsyncml/sml_elements_internals.h Fri Jul 3 16:13:03 2009 (r1149) +++ trunk/libsyncml/sml_elements_internals.h Fri Jul 3 16:16:21 2009 (r1150) @@ -49,11 +49,11 @@ gsize size; gchar *contenttype; - SmlBool moreData; + gboolean moreData; - SmlBool disabled; + gboolean disabled; /** If set to true, libsyncml will omit the cdata tags */ - SmlBool raw; + gboolean raw; }; struct SmlMapItem { @@ -69,7 +69,7 @@ SmlLocation *source; SmlLocation *target; gchar *responseURI; - SmlBool noResponse; + gboolean noResponse; guint messageID; guint maxmsgsize; guint maxobjsize; Modified: trunk/libsyncml/sml_notification_internals.h ============================================================================== --- trunk/libsyncml/sml_notification_internals.h Fri Jul 3 16:13:03 2009 (r1149) +++ trunk/libsyncml/sml_notification_internals.h Fri Jul 3 16:16:21 2009 (r1150) @@ -53,7 +53,7 @@ gchar *serverURI; }; -SmlBool smlNotificationAssemble11( +gboolean smlNotificationAssemble11( SmlNotification *san, gchar **data, gsize *size, Modified: trunk/libsyncml/sml_parse.c ============================================================================== --- trunk/libsyncml/sml_parse.c Fri Jul 3 16:13:03 2009 (r1149) +++ trunk/libsyncml/sml_parse.c Fri Jul 3 16:16:21 2009 (r1150) @@ -619,7 +619,7 @@ } } - SmlBool noCmdID = FALSE; + gboolean noCmdID = FALSE; if (!cmd->cmdID) { noCmdID = TRUE; /* FIXME: This code does not support more @@ -1062,7 +1062,7 @@ smlTrace(TRACE_ENTRY, "%s(%p)", __func__, assm); smlAssert(assm); - SmlBool ret = assm->empty; + gboolean ret = assm->empty; smlTrace(TRACE_EXIT, "%s: %i", __func__, ret); return ret; @@ -1079,7 +1079,7 @@ smlAssert(assm); smlAssert(assm->functions.missing_status); - SmlBool ret = assm->functions.missing_status(assm->assm_userdata); + gboolean ret = assm->functions.missing_status(assm->assm_userdata); return ret; } Modified: trunk/libsyncml/sml_parse.h ============================================================================== --- trunk/libsyncml/sml_parse.h Fri Jul 3 16:13:03 2009 (r1149) +++ trunk/libsyncml/sml_parse.h Fri Jul 3 16:16:21 2009 (r1150) @@ -120,9 +120,9 @@ gsize smlAssemblerGetRemoteMaxObjSize (SmlAssembler *assm); gsize smlAssemblerSetRemoteMaxObjSize (SmlAssembler *assm, gsize limit); -SmlBool smlAssemblerIsEmpty (SmlAssembler *assm); -SmlBool smlAssemblerIsStatusMissing (SmlAssembler *assm); -SmlBool smlAssemblerGetNextCmdRef (SmlAssembler *assm, guint *cmdRef, guint *msgRef); +gboolean smlAssemblerIsEmpty (SmlAssembler *assm); +gboolean smlAssemblerIsStatusMissing (SmlAssembler *assm); +gboolean smlAssemblerGetNextCmdRef (SmlAssembler *assm, guint *cmdRef, guint *msgRef); /* If you want to parse OMA DS 1.2 SANs then the manager is required. */ void smlParserSetManager (SmlParser *parser, SmlManager *manager); Modified: trunk/libsyncml/sml_session_internals.h ============================================================================== --- trunk/libsyncml/sml_session_internals.h Fri Jul 3 16:13:03 2009 (r1149) +++ trunk/libsyncml/sml_session_internals.h Fri Jul 3 16:16:21 2009 (r1150) @@ -30,7 +30,7 @@ SmlProtocolType protocol; SmlSessionType sessionType; SmlAssembler *assembler; - SmlBool onlyReplace; + gboolean onlyReplace; SmlSessionEventCallback eventCallback; void *eventCallbackUserdata; |
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_ |
From: <svn...@op...> - 2009-07-03 13:11:02
|
Author: bellmich Date: Fri Jul 3 15:10:54 2009 New Revision: 1148 URL: http://libsyncml.opensync.org/changeset/1148 Log: migrate sml_queue from SmlError to GError Modified: trunk/libsyncml/sml_queue.c trunk/libsyncml/sml_queue_internals.h Modified: trunk/libsyncml/sml_queue.c ============================================================================== --- trunk/libsyncml/sml_queue.c Fri Jul 3 15:03:14 2009 (r1147) +++ trunk/libsyncml/sml_queue.c Fri Jul 3 15:10:54 2009 (r1148) @@ -27,7 +27,9 @@ #ifndef DOXYGEN_SHOULD_SKIP_THIS -static gboolean _queue_prepare(GSource *source, gint *timeout_) +static gboolean +_queue_prepare (GSource *source, + gint *timeout_) { smlTrace(TRACE_INTERNAL, "%s(%p, %p)", __func__, source, timeout_); *timeout_ = 1; @@ -35,7 +37,8 @@ } /* TODO only use me for debugging */ -void smlQueueAssert(SmlQueue *queue) +void +smlQueueAssert (SmlQueue *queue) { if (queue->tail) { smlAssert(queue->head); @@ -54,13 +57,17 @@ smlAssert(g_list_last(queue->head) == queue->tail); } -static gboolean _queue_check(GSource *source) +static gboolean +_queue_check (GSource *source) { SmlQueue *queue = *((SmlQueue **)(source + 1)); return smlQueueCheck(queue); } -static gboolean _queue_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) +static gboolean +_queue_dispatch (GSource *source, + GSourceFunc callback, + gpointer user_data) { smlTrace(TRACE_INTERNAL, "%s(%p, %p, %p)", __func__, source, callback, user_data); SmlQueue *queue = user_data; @@ -78,7 +85,8 @@ * This function return the pointer to a newly created SmlQueue * */ -SmlQueue *smlQueueNew(SmlError **error) +SmlQueue* +smlQueueNew (GError **error) { CHECK_ERROR_REF SmlQueue *queue = smlTryMalloc0(sizeof(SmlQueue), error); @@ -92,7 +100,8 @@ return queue; } -void smlQueueFree(SmlQueue *queue) +void +smlQueueFree (SmlQueue *queue) { if (queue->source) smlQueueDetach(queue); @@ -105,7 +114,8 @@ smlSafeFree((gpointer *)&queue); } -void smlQueueFlush(SmlQueue *queue) +void +smlQueueFlush (SmlQueue *queue) { g_mutex_lock(queue->mutex); @@ -121,7 +131,8 @@ g_mutex_unlock(queue->mutex); } -SmlBool smlQueueCheckPrio(SmlQueue *queue) +gboolean +smlQueueCheckPrio (SmlQueue *queue) { g_mutex_lock(queue->mutex); SmlBool ret = (queue->prio == NULL) ? FALSE : TRUE; @@ -130,7 +141,8 @@ return ret; } -SmlBool smlQueueCheck(SmlQueue *queue) +gboolean +smlQueueCheck (SmlQueue *queue) { g_mutex_lock(queue->mutex); SmlBool ret = (queue->head == NULL) ? FALSE : TRUE; @@ -139,7 +151,8 @@ return ret; } -unsigned int smlQueueLength(SmlQueue *queue) +gsize +smlQueueLength (SmlQueue *queue) { g_mutex_lock(queue->mutex); unsigned int ret = g_list_length(queue->head); @@ -148,7 +161,8 @@ return ret; } -unsigned int smlQueueLengthPrio(SmlQueue *queue) +gsize +smlQueueLengthPrio (SmlQueue *queue) { g_mutex_lock(queue->mutex); unsigned int ret = g_list_length(queue->prio); @@ -157,7 +171,8 @@ return ret; } -void *smlQueueTryPop(SmlQueue *queue) +void* +smlQueueTryPop (SmlQueue *queue) { smlAssert(queue); void *message = NULL; @@ -182,7 +197,8 @@ return message; } -void *smlQueueTryPopPrio(SmlQueue *queue) +void* +smlQueueTryPopPrio (SmlQueue *queue) { smlAssert(queue); void *message = NULL; @@ -206,25 +222,29 @@ return message; } -void smlQueueLock(SmlQueue *queue) +void +smlQueueLock (SmlQueue *queue) { smlAssert(queue); g_mutex_lock(queue->mutex); } -void smlQueueUnlock(SmlQueue *queue) +void +smlQueueUnlock (SmlQueue *queue) { smlAssert(queue); g_mutex_unlock(queue->mutex); } -void *smlQueuePeek(SmlQueue *queue) +void* +smlQueuePeek (SmlQueue *queue) { smlAssert(queue); return queue->head ? queue->head->data : NULL; } -void *smlQueuePeekPrio(SmlQueue *queue) +void* +smlQueuePeekPrio (SmlQueue *queue) { smlAssert(queue); void *message = NULL; @@ -240,7 +260,8 @@ return message; } -void smlQueuePrint(SmlQueue *queue) +void +smlQueuePrint (SmlQueue *queue) { smlAssert(queue); @@ -267,7 +288,9 @@ g_mutex_unlock(queue->mutex); } -GList *smlQueuePeekNext(SmlQueue *queue, GList *prev) +GList* +smlQueuePeekNext (SmlQueue *queue, + GList *prev) { smlAssert(queue); @@ -277,7 +300,9 @@ return prev->next; } -void smlQueuePushHeadPrio(SmlQueue *queue, void *data) +void +smlQueuePushHeadPrio (SmlQueue *queue, + void *data) { smlAssert(queue); smlAssert(data); @@ -296,7 +321,9 @@ g_mutex_unlock(queue->mutex); } -void smlQueuePushHead(SmlQueue *queue, void *data) +void +smlQueuePushHead (SmlQueue *queue, + void *data) { smlAssert(queue); smlAssert(data); @@ -320,7 +347,9 @@ * @param message The message to send * */ -void smlQueueSendPrio(SmlQueue *queue, void *data) +void +smlQueueSendPrio (SmlQueue *queue, + void *data) { smlAssert(queue); smlAssert(data); @@ -350,7 +379,9 @@ * @param message The message to send * */ -void smlQueueSend(SmlQueue *queue, void *data) +void +smlQueueSend (SmlQueue *queue, + void *data) { smlAssert(queue); smlAssert(data); @@ -381,7 +412,10 @@ * @param user_data The userdata that the message handler should receive * */ -void smlQueueSetHandler(SmlQueue *queue, SmlQueueHandler handler, void *userdata) +void +smlQueueSetHandler (SmlQueue *queue, + SmlQueueHandler handler, + void *userdata) { queue->handler = handler; queue->userdata = userdata; @@ -397,7 +431,9 @@ * @param context The context to use. NULL for default loop * */ -void smlQueueAttach(SmlQueue *queue, GMainContext *context) +void +smlQueueAttach (SmlQueue *queue, + GMainContext *context) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, queue, context); @@ -424,7 +460,8 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -void smlQueueDetach(SmlQueue *queue) +void +smlQueueDetach (SmlQueue *queue) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, queue); @@ -446,19 +483,22 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -SmlBool smlQueueIsAttached(SmlQueue *queue) +gboolean +smlQueueIsAttached (SmlQueue *queue) { return queue->source ? TRUE : FALSE; } -void smlQueueDispatch(SmlQueue *queue) +void +smlQueueDispatch (SmlQueue *queue) { void *message = smlQueueTryPop(queue); if (message) queue->handler(message, queue->userdata); } -void smlQueueDispatchPrio(SmlQueue *queue) +void +smlQueueDispatchPrio (SmlQueue *queue) { void *message = smlQueueTryPopPrio(queue); Modified: trunk/libsyncml/sml_queue_internals.h ============================================================================== --- trunk/libsyncml/sml_queue_internals.h Fri Jul 3 15:03:14 2009 (r1147) +++ trunk/libsyncml/sml_queue_internals.h Fri Jul 3 15:10:54 2009 (r1148) @@ -1,6 +1,7 @@ /* * libsyncml - A syncml protocol implementation * Copyright (C) 2005 Armin Bauer <arm...@op...> + * Copyright (C) 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 @@ -51,31 +52,31 @@ GMutex *mutex; } SmlQueue; -SmlQueue *smlQueueNew(GError **error); -void smlQueueFree(SmlQueue *queue); -void smlQueueFlush(SmlQueue *queue); -void smlQueueSetHandler(SmlQueue *queue, SmlQueueHandler handler, void *userdata); -void smlQueueSend(SmlQueue *queue, void *data); -void smlQueueAttach(SmlQueue *queue, GMainContext *context); -void smlQueueDetach(SmlQueue *queue); -void smlQueueDispatch(SmlQueue *queue); -void *smlQueueTryPop(SmlQueue *queue); -SmlBool smlQueueCheck(SmlQueue *queue); -void smlQueuePushHead(SmlQueue *queue, void *data); -SmlBool smlQueueIsAttached(SmlQueue *queue); -void smlQueueLock(SmlQueue *queue); -void smlQueueUnlock(SmlQueue *queue); -void *smlQueuePeek(SmlQueue *queue); -GList *smlQueuePeekNext(SmlQueue *queue, GList *prev); -void *smlQueueTryPopPrio(SmlQueue *queue); -void smlQueuePushHeadPrio(SmlQueue *queue, void *data); -void smlQueueSendPrio(SmlQueue *queue, void *data); -SmlBool smlQueueCheckPrio(SmlQueue *queue); -void smlQueueDispatchPrio(SmlQueue *queue); -void *smlQueuePeekPrio(SmlQueue *queue); -void smlQueuePrint(SmlQueue *queue); -unsigned int smlQueueLength(SmlQueue *queue); -unsigned int smlQueueLengthPrio(SmlQueue *queue); +SmlQueue* smlQueueNew (GError **error); +void smlQueueFree (SmlQueue *queue); +void smlQueueFlush (SmlQueue *queue); +void smlQueueSetHandler (SmlQueue *queue, SmlQueueHandler handler, void *userdata); +void smlQueueSend (SmlQueue *queue, void *data); +void smlQueueAttach (SmlQueue *queue, GMainContext *context); +void smlQueueDetach (SmlQueue *queue); +void smlQueueDispatch (SmlQueue *queue); +void* smlQueueTryPop (SmlQueue *queue); +gboolean smlQueueCheck (SmlQueue *queue); +void smlQueuePushHead (SmlQueue *queue, void *data); +gboolean smlQueueIsAttached (SmlQueue *queue); +void smlQueueLock (SmlQueue *queue); +void smlQueueUnlock (SmlQueue *queue); +void* smlQueuePeek (SmlQueue *queue); +GList* smlQueuePeekNext (SmlQueue *queue, GList *prev); +void* smlQueueTryPopPrio (SmlQueue *queue); +void smlQueuePushHeadPrio (SmlQueue *queue, void *data); +void smlQueueSendPrio (SmlQueue *queue, void *data); +gboolean smlQueueCheckPrio (SmlQueue *queue); +void smlQueueDispatchPrio (SmlQueue *queue); +void* smlQueuePeekPrio (SmlQueue *queue); +void smlQueuePrint (SmlQueue *queue); +gsize smlQueueLength (SmlQueue *queue); +gsize smlQueueLengthPrio (SmlQueue *queue); #endif //_SML_QUEUE_INTERNALS_H_ |
From: <svn...@op...> - 2009-07-03 13:03:40
|
Author: bellmich Date: Fri Jul 3 15:03:14 2009 New Revision: 1147 URL: http://libsyncml.opensync.org/changeset/1147 Log: migrated sml_parse from SmlError to GError Modified: trunk/libsyncml/parser/sml_wbxml.h trunk/libsyncml/parser/sml_xml_assm.h trunk/libsyncml/parser/sml_xml_parse.h trunk/libsyncml/sml_parse.c trunk/libsyncml/sml_parse.h trunk/libsyncml/sml_parse_internals.h Modified: trunk/libsyncml/parser/sml_wbxml.h ============================================================================== --- trunk/libsyncml/parser/sml_wbxml.h Fri Jul 3 11:31:01 2009 (r1146) +++ trunk/libsyncml/parser/sml_wbxml.h Fri Jul 3 15:03:14 2009 (r1147) @@ -29,8 +29,8 @@ #ifndef _SML_WBXML_H_ #define _SML_WBXML_H_ -SmlXmlParser *smlWbxmlParserNew(SmlParserFunctions *functions, SmlError **error); -SmlXmlAssembler *smlWbxmlAssemblerNew(SmlAssembler *assembler, SmlAssemblerFunctions *functions, SmlError **error); +SmlXmlParser *smlWbxmlParserNew(SmlParserFunctions *functions, GError **error); +SmlXmlAssembler *smlWbxmlAssemblerNew(SmlAssembler *assembler, SmlAssemblerFunctions *functions, GError **error); #endif //_SML_WBXML_H_ /*@}*/ Modified: trunk/libsyncml/parser/sml_xml_assm.h ============================================================================== --- trunk/libsyncml/parser/sml_xml_assm.h Fri Jul 3 11:31:01 2009 (r1146) +++ trunk/libsyncml/parser/sml_xml_assm.h Fri Jul 3 15:03:14 2009 (r1147) @@ -32,7 +32,7 @@ typedef struct SmlXmlAssembler SmlXmlAssembler; -SmlXmlAssembler *smlXmlAssemblerNew(SmlAssembler *assembler, SmlAssemblerFunctions *functions, SmlError **error); +SmlXmlAssembler *smlXmlAssemblerNew(SmlAssembler *assembler, SmlAssemblerFunctions *functions, GError **error); SmlBool smlXmlAssemblerAddHeader(SmlXmlAssembler *assembler, SmlSession *session, SmlError **error); // FIXME: not yet implemented Modified: trunk/libsyncml/parser/sml_xml_parse.h ============================================================================== --- trunk/libsyncml/parser/sml_xml_parse.h Fri Jul 3 11:31:01 2009 (r1146) +++ trunk/libsyncml/parser/sml_xml_parse.h Fri Jul 3 15:03:14 2009 (r1147) @@ -43,14 +43,14 @@ typedef struct SmlXmlParser SmlXmlParser; -SmlXmlParser *smlXmlParserNew(SmlParserFunctions *functions, SmlError **error); +SmlXmlParser *smlXmlParserNew(SmlParserFunctions *functions, GError **error); -SmlBool smlXmlParserStart(SmlXmlParser *parser, const char *data, unsigned int size, SmlError **error); -SmlBool smlXmlParserEnd(SmlXmlParser *parser, SmlBool *final, SmlBool *end, SmlError **error); +SmlBool smlXmlParserStart(SmlXmlParser *parser, const char *data, unsigned int size, GError **error); +SmlBool smlXmlParserEnd(SmlXmlParser *parser, SmlBool *final, SmlBool *end, GError **error); void smlXmlParserFree(SmlXmlParser *parser); -SmlBool smlXmlParserGetHeader(SmlXmlParser *parser, SmlHeader **header, SmlCred **cred, SmlError **error); -SmlBool smlXmlParserGetStatus(SmlXmlParser *parser, SmlStatus **status, SmlError **error); -SmlParserResult smlXmlParserGetCommand(SmlXmlParser *parser, SmlCommand **cmd, SmlError **error); +SmlBool smlXmlParserGetHeader(SmlXmlParser *parser, SmlHeader **header, SmlCred **cred, GError **error); +SmlBool smlXmlParserGetStatus(SmlXmlParser *parser, SmlStatus **status, GError **error); +SmlParserResult smlXmlParserGetCommand(SmlXmlParser *parser, SmlCommand **cmd, GError **error); SmlDevInf *smlXmlDevInfParse(const char *data, unsigned int size, GError **error); Modified: trunk/libsyncml/sml_parse.c ============================================================================== --- trunk/libsyncml/sml_parse.c Fri Jul 3 11:31:01 2009 (r1146) +++ trunk/libsyncml/sml_parse.c Fri Jul 3 15:03:14 2009 (r1147) @@ -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 @@ -48,7 +48,10 @@ * @return The new parser or NULL in the case of an error * */ -SmlParser *smlParserNew(SmlMimeType type, unsigned int limit, SmlError **error) +SmlParser* +smlParserNew (SmlMimeType type, + gsize limit, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%i, %i, %p)", __func__, type, limit, error); CHECK_ERROR_REF @@ -63,38 +66,39 @@ switch (type) { case SML_MIMETYPE_XML: if (!(parser->parser_userdata = smlXmlParserNew(&(parser->functions), error))) - goto error_free_parser; + goto error; break; case SML_MIMETYPE_SAN: /* SANs will be converted to normal SyncML 1.1 notifications */ if (!(parser->parser_userdata = smlXmlParserNew(&(parser->functions), error))) - goto error_free_parser; + goto error; break; case SML_MIMETYPE_WBXML: #ifdef ENABLE_WBXML if (!(parser->parser_userdata = smlWbxmlParserNew(&(parser->functions), error))) - goto error_free_parser; + goto error; break; #else - smlErrorSet(error, SML_ERROR_GENERIC, "Wbxml not enabled in this build"); - goto error_free_parser; + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Wbxml not enabled in this build"); + goto error; #endif default: - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown parser type"); - goto error_free_parser; + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown parser type"); + goto error; } smlTrace(TRACE_EXIT, "%s: %p", __func__, parser); return parser; - -error_free_parser: - smlSafeFree((gpointer *)&parser); error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + if (parser) + smlSafeFree((gpointer *)&parser); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -void smlParserSetManager(SmlParser *parser, SmlManager *manager) +void +smlParserSetManager (SmlParser *parser, + SmlManager *manager) { smlAssert(parser); smlAssert(manager); @@ -106,7 +110,8 @@ * @param parser The parser to free * */ -void smlParserFree(SmlParser *parser) +void +smlParserFree (SmlParser *parser) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, parser); smlAssert(parser); @@ -130,11 +135,14 @@ * @returns TRUE if the parser started successfully, FALSE otherwise * */ -SmlBool smlParserStart(SmlParser *parser, const char *data, unsigned int size, SmlError **error) +gboolean +smlParserStart (SmlParser *parser, + const gchar *data, + gsize size, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %i, %p)", __func__, parser, data, size, error); CHECK_ERROR_REF - GError *gerror = NULL; smlAssert(parser); smlAssert(data); smlAssert(size); @@ -143,7 +151,7 @@ "If an OMA DS 1.2 SAN must be parsed then the manager must be present."); if (parser->limit && size > parser->limit) { - smlErrorSet(error, SML_ERROR_GENERIC, "Input data too large"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Input data too large"); goto error; } @@ -160,7 +168,7 @@ smlNotificationSetManager(san, parser->manager); san->type = SML_MIMETYPE_XML; san->sessionType = SML_SESSION_TYPE_CLIENT; - san->target = sml_location_new_with_options("/", NULL, &gerror); + san->target = sml_location_new_with_options("/", NULL, error); if (!san->target) goto error; @@ -194,10 +202,8 @@ 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; } @@ -216,7 +222,11 @@ * @returns TRUE if the parser retrieved the header successfully, FALSE otherwise * */ -SmlBool smlParserGetHeader(SmlParser *parser, SmlHeader **header, SmlCred **cred, SmlError **error) +gboolean +smlParserGetHeader (SmlParser *parser, + SmlHeader **header, + SmlCred **cred, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, parser, header, cred, error); CHECK_ERROR_REF @@ -230,9 +240,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; } @@ -250,7 +259,10 @@ * commands available (in which case *cmd is NULL). FALSE in the case of an error * */ -SmlParserResult smlParserGetCommand(SmlParser *parser, SmlCommand **cmd, SmlError **error) +SmlParserResult +smlParserGetCommand (SmlParser *parser, + SmlCommand **cmd, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, parser, cmd, error); CHECK_ERROR_REF @@ -264,9 +276,8 @@ smlTrace(TRACE_EXIT, "%s: %i", __func__, result); return result; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return SML_PARSER_RESULT_ERROR; } @@ -284,7 +295,10 @@ * statuses available (in which case *status is NULL). FALSE in the case of an error * */ -SmlBool smlParserGetStatus(SmlParser *parser, SmlStatus **status, SmlError **error) +gboolean +smlParserGetStatus (SmlParser *parser, + SmlStatus **status, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, parser, status, error); CHECK_ERROR_REF @@ -297,9 +311,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; } @@ -314,7 +327,11 @@ * @returns TRUE if the parser ended successfully, FALSE otherwise * */ -SmlBool smlParserEnd(SmlParser *parser, SmlBool *final, SmlBool *end, SmlError **error) +gboolean +smlParserEnd (SmlParser *parser, + gboolean *final, + gboolean *end, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, parser, final, end, error); CHECK_ERROR_REF @@ -328,9 +345,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; } @@ -352,7 +368,10 @@ * @return The new assembler or NULL in the case of an error * */ -SmlAssembler *smlAssemblerNew(SmlMimeType type, unsigned int limit, SmlError **error) +SmlAssembler* +smlAssemblerNew (SmlMimeType type, + gsize limit, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%i, %i, %p)", __func__, type, limit, error); CHECK_ERROR_REF @@ -369,31 +388,30 @@ switch (type) { case SML_MIMETYPE_XML: if (!(assm->assm_userdata = smlXmlAssemblerNew(assm, &(assm->functions), error))) - goto error_free_assm; + goto error; break; case SML_MIMETYPE_WBXML: #ifdef ENABLE_WBXML if (!(assm->assm_userdata = smlWbxmlAssemblerNew(assm, &(assm->functions), error))) - goto error_free_assm; + goto error; break; #else - smlErrorSet(error, SML_ERROR_GENERIC, "Wbxml not enabled in this build"); - goto error_free_assm; + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Wbxml not enabled in this build"); + goto error; #endif default: - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown assembler type"); - goto error_free_assm; + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown assembler type"); + goto error; } assm->options = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); smlTrace(TRACE_EXIT, "%s: %p", __func__, assm); return assm; - -error_free_assm: - smlSafeFree((gpointer *)&assm); error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + if (assm) + smlSafeFree((gpointer *)&assm); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } @@ -402,7 +420,8 @@ * @param assm The assembler to free * */ -void smlAssemblerFree(SmlAssembler *assm) +void +smlAssemblerFree (SmlAssembler *assm) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, assm); smlAssert(assm); @@ -428,7 +447,10 @@ * @returns TRUE if the package container was assembled successfully, FALSE otherwise * */ -SmlBool smlAssemblerStart(SmlAssembler *assm, SmlSession *session, SmlError **error) +gboolean +smlAssemblerStart (SmlAssembler *assm, + SmlSession *session, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, assm, session, error); CHECK_ERROR_REF @@ -441,9 +463,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; } @@ -456,7 +477,13 @@ * @returns TRUE if the package container was assembled successfully, FALSE otherwise * */ -SmlBool smlAssemblerRun(SmlAssembler *assm, char **data, unsigned int *size, SmlBool *end, SmlBool final, SmlError **error) +gboolean +smlAssemblerRun (SmlAssembler *assm, + gchar **data, + gsize *size, + gboolean *end, + gboolean final, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %i, %p)", __func__, assm, data, size, end, final, error); CHECK_ERROR_REF @@ -470,9 +497,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; } @@ -485,22 +511,24 @@ * @returns TRUE if the package container was assembled successfully, FALSE otherwise * */ -unsigned int smlAssemblerCheckSize(SmlAssembler *assm, SmlBool headeronly, SmlError **error) +gsize +smlAssemblerCheckSize (SmlAssembler *assm, + gboolean headeronly, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, assm, headeronly, error); CHECK_ERROR_REF smlAssert(assm); smlAssert(assm->functions.check_size); - unsigned int size = 0; + gsize size = 0; if (!(size = assm->functions.check_size(assm->assm_userdata, headeronly, error))) goto error; smlTrace(TRACE_EXIT, "%s: %i", __func__, size); return size; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return 0; } @@ -514,7 +542,8 @@ * @returns TRUE if the flushing was successful, FALSE otherwise * */ -unsigned int smlAssemblerFlush(SmlAssembler *assm) +gsize +smlAssemblerFlush (SmlAssembler *assm) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, assm); smlAssert(assm); @@ -527,7 +556,8 @@ return ret; } -void smlAssemblerRestoreCommands(SmlAssembler *assm) +void +smlAssemblerRestoreCommands (SmlAssembler *assm) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, assm); smlAssert(assm); @@ -545,7 +575,12 @@ * item data. Then it returns how big the item data could be without violating * the limits. If there is not limit set, -1 is returned. This command only * makes sense for change commands */ -SmlBool smlAssemblerGetSpace(SmlAssembler *assm, int *space, SmlCommand *parent, SmlCommand *cmd, SmlError **error) +gboolean +smlAssemblerGetSpace (SmlAssembler *assm, + gsize *space, + SmlCommand *parent, + SmlCommand *cmd, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %p)", __func__, assm, space, parent, cmd, error); CHECK_ERROR_REF @@ -567,7 +602,7 @@ /* Add the command */ if (parent) { if (!parent->cmdID) { - smlErrorSet(error, SML_ERROR_GENERIC, "Parent has to be added before"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Parent has to be added before"); goto error; } parentID = parent->cmdID; @@ -641,7 +676,7 @@ if (noCmdID) cmd->cmdID = 0; error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } @@ -659,7 +694,11 @@ * if the parent command did not fit, SML_ASSEMBLER_RESULT_ERROR if some error occured. * */ -SmlAssemblerResult smlAssemblerStartCommand(SmlAssembler *assm, SmlCommand *parent, SmlCommand *cmd, SmlError **error) +SmlAssemblerResult +smlAssemblerStartCommand (SmlAssembler *assm, + SmlCommand *parent, + SmlCommand *cmd, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, assm, parent, cmd, error); CHECK_ERROR_REF @@ -672,7 +711,7 @@ /* Add the command */ if (parent) { if (!parent->cmdID) { - smlErrorSet(error, SML_ERROR_GENERIC, "Parent has to be added before"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Parent has to be added before"); goto error; } parentID = parent->cmdID; @@ -705,9 +744,8 @@ 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; } @@ -722,7 +760,10 @@ * @returns TRUE if the command was added successfully, FALSE otherwise * */ -SmlBool smlAssemblerEndCommand(SmlAssembler *assm, SmlCommand *parent, SmlError **error) +gboolean +smlAssemblerEndCommand (SmlAssembler *assm, + SmlCommand *parent, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, assm, parent, error); CHECK_ERROR_REF @@ -734,7 +775,7 @@ /* Add the command */ if (parent) { if (!parent->cmdID) { - smlErrorSet(error, SML_ERROR_GENERIC, "Parent has to be added before"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Parent has to be added before"); goto error; } parentID = parent->cmdID; @@ -746,9 +787,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; } @@ -762,7 +802,10 @@ * @returns TRUE if the header was added ok, FALSE if some error occured. * */ -SmlBool smlAssemblerAddHeader(SmlAssembler *assm, SmlSession *session, SmlError **error) +gboolean +smlAssemblerAddHeader (SmlAssembler *assm, + SmlSession *session, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, assm, session, error); CHECK_ERROR_REF @@ -781,15 +824,14 @@ /* Lets see if the new buffer is small enough */ if (smlAssemblerGetRemoteMaxMsgSize(assm) && size > smlAssemblerGetRemoteMaxMsgSize(assm)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Limit to small. Unable to fit a the header"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Limit to small. Unable to fit a the header"); 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; } @@ -806,7 +848,12 @@ * @returns TRUE if successful, FALSE otherwise * */ -SmlAssemblerResult smlAssemblerReserveStatus(SmlAssembler *assm, unsigned int cmdRef, unsigned int msgRef, unsigned int cmdID, SmlError **error) +SmlAssemblerResult +smlAssemblerReserveStatus (SmlAssembler *assm, + guint cmdRef, + guint msgRef, + guint cmdID, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %i, %i, %p)", __func__, assm, cmdRef, msgRef, cmdID, error); CHECK_ERROR_REF @@ -819,9 +866,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; } @@ -839,7 +885,11 @@ * if the status did not fit, SML_ASSEMBLER_RESULT_ERROR if some error occured. * */ -SmlAssemblerResult smlAssemblerAddStatusFull(SmlAssembler *assm, SmlStatus *status, SmlBool force, SmlError **error) +SmlAssemblerResult +smlAssemblerAddStatusFull (SmlAssembler *assm, + SmlStatus *status, + gboolean force, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %i, %p)", __func__, assm, status, force, error); CHECK_ERROR_REF @@ -877,13 +927,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; } -SmlAssemblerResult smlAssemblerAddStatus(SmlAssembler *assm, SmlStatus *status, SmlError **error) +SmlAssemblerResult +smlAssemblerAddStatus (SmlAssembler *assm, + SmlStatus *status, + GError **error) { CHECK_ERROR_REF return smlAssemblerAddStatusFull(assm, status, FALSE, error); @@ -896,7 +948,10 @@ * @param value The new value * */ -void smlAssemblerSetOption(SmlAssembler *assm, const char *optionname, const char *value) +void +smlAssemblerSetOption (SmlAssembler *assm, + const gchar *optionname, + const gchar *value) { smlTrace(TRACE_ENTRY, "%s(%p, %s, %s)", __func__, assm, VA_STRING(optionname), VA_STRING(value)); smlAssert(assm); @@ -914,7 +969,9 @@ * @returns The value * */ -const char *smlAssemblerGetOption(SmlAssembler *assm, const char *optionname) +const gchar* +smlAssemblerGetOption (SmlAssembler *assm, + const gchar *optionname) { smlTrace(TRACE_ENTRY, "%s(%p, %s)", __func__, assm, VA_STRING(optionname)); smlAssert(assm); @@ -926,13 +983,8 @@ return ret; } -/* FIXME: DEPRECATED */ -unsigned int smlAssemblerGetLimit(SmlAssembler *assm) -{ - return smlAssemblerGetRemoteMaxMsgSize(assm); -} - -unsigned int smlAssemblerGetRemoteMaxMsgSize(SmlAssembler *assm) +gsize +smlAssemblerGetRemoteMaxMsgSize (SmlAssembler *assm) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, assm); smlAssert(assm); @@ -941,19 +993,8 @@ return assm->remoteMaxMsgSize; } -/* FIXME: DEPRECATED */ -void smlAssemblerSetRequestedLimit(SmlAssembler *assm, unsigned int limit) -{ - smlAssemblerSetRemoteMaxMsgSize(assm, limit); -} - -/* FIXME: DEPRECATED */ -void smlAssemblerSetLimit(SmlAssembler *assm, unsigned int limit) -{ - smlAssemblerSetRemoteMaxMsgSize(assm, limit); -} - -unsigned int smlAssemblerSetRemoteMaxMsgSize(SmlAssembler *assm, unsigned int limit) +gsize smlAssemblerSetRemoteMaxMsgSize (SmlAssembler *assm, + gsize limit) { smlTrace(TRACE_ENTRY, "%s(%p, %i)", __func__, assm, limit); smlAssert(assm); @@ -978,20 +1019,8 @@ return assm->remoteMaxMsgSize; } -/* FIXME: DEPRECATED */ -int smlAssemblerGetSendingMaxObjSize(SmlAssembler *assm) -{ - return smlAssemblerGetRemoteMaxObjSize(assm); -} - -/* FIXME: DEPRECATED */ -int smlAssemblerGetRequestedMaxObjSize(SmlAssembler *assm) -{ - return smlAssemblerGetRemoteMaxObjSize(assm); -} - - -unsigned int smlAssemblerGetRemoteMaxObjSize(SmlAssembler *assm) +gsize +smlAssemblerGetRemoteMaxObjSize (SmlAssembler *assm) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, assm); smlAssert(assm); @@ -1000,19 +1029,9 @@ return assm->remoteMaxObjSize; } -/* FIXME: DEPRECATED */ -void smlAssemblerSetRequestedMaxObjSize(SmlAssembler *assm, int limit) -{ - smlAssemblerSetRemoteMaxObjSize(assm, limit); -} - -/* FIXME: DEPRECATED */ -void smlAssemblerSetSendingMaxObjSize(SmlAssembler *assm, int limit) -{ - smlAssemblerSetRemoteMaxObjSize(assm, limit); -} - -unsigned int smlAssemblerSetRemoteMaxObjSize(SmlAssembler *assm, unsigned int limit) +gsize +smlAssemblerSetRemoteMaxObjSize (SmlAssembler *assm, + gsize limit) { smlTrace(TRACE_ENTRY, "%s(%p, %i)", __func__, assm, limit); smlAssert(assm); @@ -1037,7 +1056,8 @@ return assm->remoteMaxObjSize; } -SmlBool smlAssemblerIsEmpty(SmlAssembler *assm) +gboolean +smlAssemblerIsEmpty (SmlAssembler *assm) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, assm); smlAssert(assm); @@ -1053,7 +1073,8 @@ * @param assm The assembler to check * @returns TRUE if statuses are missing, FALSE if all statuses had been added */ -SmlBool smlAssemblerIsStatusMissing(SmlAssembler *assm) +gboolean +smlAssemblerIsStatusMissing (SmlAssembler *assm) { smlAssert(assm); smlAssert(assm->functions.missing_status); @@ -1063,7 +1084,10 @@ return ret; } -SmlBool smlAssemblerGetNextCmdRef(SmlAssembler *assm, unsigned int *cmdRef, unsigned int *msgRef) +gboolean +smlAssemblerGetNextCmdRef (SmlAssembler *assm, + guint *cmdRef, + guint *msgRef) { smlAssert(assm); smlAssert(cmdRef); Modified: trunk/libsyncml/sml_parse.h ============================================================================== --- trunk/libsyncml/sml_parse.h Fri Jul 3 11:31:01 2009 (r1146) +++ trunk/libsyncml/sml_parse.h Fri Jul 3 15:03:14 2009 (r1147) @@ -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 @@ -31,11 +31,11 @@ SML_PARSER_RESULT_OTHER = 5 } SmlParserResult; -typedef void (* SmlParserFreeFunction) (void *userdata); -typedef SmlBool (* SmlParserStartFunction) (void *userdata, const char *data, unsigned int size, GError **error); -typedef SmlBool (* SmlParserEndFunction) (void *userdata, SmlBool *final, SmlBool *end, GError **error); -typedef SmlBool (* SmlParserHeaderFunction) (void *userdata, SmlHeader **header, SmlCred **cred, GError **error); -typedef SmlBool (* SmlParserStatusFunction) (void *userdata, SmlStatus **status, GError **error); +typedef void (* SmlParserFreeFunction) (void *userdata); +typedef gboolean (* SmlParserStartFunction) (void *userdata, const gchar *data, gsize size, GError **error); +typedef gboolean (* SmlParserEndFunction) (void *userdata, gboolean *final, gboolean *end, GError **error); +typedef gboolean (* SmlParserHeaderFunction) (void *userdata, SmlHeader **header, SmlCred **cred, GError **error); +typedef gboolean (* SmlParserStatusFunction) (void *userdata, SmlStatus **status, GError **error); typedef SmlParserResult (* SmlParserCommandFunction) (void *userdata, SmlCommand **cmd, GError **error); typedef struct SmlParserFunctions { @@ -47,22 +47,22 @@ SmlParserCommandFunction get_cmd; } SmlParserFunctions; -typedef void (* SmlAssemblerFreeFunction) (void *userdata); -typedef SmlBool (* SmlAssemblerStartFunction) (void *userdata, SmlSession *session, GError **error); -typedef SmlBool (* SmlAssemblerEndFunction) (void *userdata, GError **error); -typedef SmlBool (* SmlAssemblerRunFunction) (void *userdata, char **data, unsigned int *size, SmlBool *end, SmlBool final, unsigned int maxsize, GError **error); -typedef unsigned int (* SmlAssemblerFlushFunction) (void *userdata); -typedef SmlBool (* SmlAssemblerStatusFunction) (void *userdata, SmlStatus *status, GError **error); -typedef SmlBool (* SmlAssemblerRemStatusFunction) (void *userdata, GError **error); -typedef SmlBool (* SmlAssemblerReserveStatusFunction) (void *userdata, unsigned int cmdRef, unsigned int msgRef, unsigned int cmdID, GError **error); -typedef SmlBool (* SmlAssemblerStatusMissingFunction) (void *userdata); -typedef SmlBool (* SmlAssemblerStartCommandFunction) (void *userdata, unsigned int parentID, SmlCommand *cmd, GError **error); -typedef SmlBool (* SmlAssemblerEndCommandFunction) (void *userdata, unsigned int parentID, GError **error); -typedef SmlBool (* SmlAssemblerRemCommandFunction) (void *userdata, unsigned int parentID, GError **error); -typedef SmlBool (* SmlAssemblerHeaderFunction) (void *userdata, SmlSession *session, GError **error); -typedef unsigned int (* SmlAssemblerCheckFunction) (void *userdata, SmlBool headeronly, GError **error); -typedef SmlBool (* SmlAssemblerNextCmdRefFunction) (void *userdata, unsigned int *cmdRef, unsigned int *msgRef); -typedef void (* SmlAssemblerRestoreCommandsFunction) (void *userdata); +typedef void (* SmlAssemblerFreeFunction) (void *userdata); +typedef gboolean (* SmlAssemblerStartFunction) (void *userdata, SmlSession *session, GError **error); +typedef gboolean (* SmlAssemblerEndFunction) (void *userdata, GError **error); +typedef gboolean (* SmlAssemblerRunFunction) (void *userdata, gchar **data, gsize *size, gboolean *end, gboolean final, gsize maxsize, GError **error); +typedef gsize (* SmlAssemblerFlushFunction) (void *userdata); +typedef gboolean (* SmlAssemblerStatusFunction) (void *userdata, SmlStatus *status, GError **error); +typedef gboolean (* SmlAssemblerRemStatusFunction) (void *userdata, GError **error); +typedef gboolean (* SmlAssemblerReserveStatusFunction) (void *userdata, guint cmdRef, guint msgRef, guint cmdID, GError **error); +typedef gboolean (* SmlAssemblerStatusMissingFunction) (void *userdata); +typedef gboolean (* SmlAssemblerStartCommandFunction) (void *userdata, guint parentID, SmlCommand *cmd, GError **error); +typedef gboolean (* SmlAssemblerEndCommandFunction) (void *userdata, guint parentID, GError **error); +typedef gboolean (* SmlAssemblerRemCommandFunction) (void *userdata, guint parentID, GError **error); +typedef gboolean (* SmlAssemblerHeaderFunction) (void *userdata, SmlSession *session, GError **error); +typedef gsize (* SmlAssemblerCheckFunction) (void *userdata, gboolean headeronly, GError **error); +typedef gboolean (* SmlAssemblerNextCmdRefFunction) (void *userdata, guint *cmdRef, guint *msgRef); +typedef void (* SmlAssemblerRestoreCommandsFunction) (void *userdata); typedef struct SmlAssemblerFunctions { SmlAssemblerFreeFunction free; @@ -89,51 +89,42 @@ SML_ASSEMBLER_RESULT_MISMATCH =2 } SmlAssemblerResult; -SmlParser *smlParserNew(SmlMimeType type, unsigned int limit, GError **error); -void smlParserFree(SmlParser *parser); -SmlBool smlParserStart(SmlParser *parser, const char *data, unsigned int size, GError **error); -SmlBool smlParserGetHeader(SmlParser *parser, SmlHeader **header, SmlCred **cred, GError **error); -SmlParserResult smlParserGetCommand(SmlParser *parser, SmlCommand **cmd, SmlError **error); -SmlBool smlParserGetStatus(SmlParser *parser, SmlStatus **status, SmlError **error); -SmlBool smlParserEnd(SmlParser *parser, SmlBool *final, SmlBool *end, SmlError **error); - -SmlAssembler *smlAssemblerNew(SmlMimeType type, unsigned int limit, GError **error); -void smlAssemblerFree(SmlAssembler *assm); -SmlBool smlAssemblerStart(SmlAssembler *assm, SmlSession *session, GError **error); -unsigned int smlAssemblerFlush(SmlAssembler *assm); -void smlAssemblerRestoreCommands(SmlAssembler *assm); -SmlBool smlAssemblerRun(SmlAssembler *assm, char **data, unsigned int *size, SmlBool *end, SmlBool final, GError **error); -SmlAssemblerResult smlAssemblerAddStatus(SmlAssembler *assm, SmlStatus *status, GError **error); -SmlAssemblerResult smlAssemblerAddStatusFull(SmlAssembler *assm, SmlStatus *status, SmlBool force, GError **error); -SmlAssemblerResult smlAssemblerReserveStatus(SmlAssembler *assm, unsigned int cmdRef, unsigned int msgRef, unsigned int cmdID, GError **error); -SmlBool smlAssemblerAddHeader(SmlAssembler *assm, SmlSession *session, GError **error); -SmlAssemblerResult smlAssemblerStartCommand(SmlAssembler *assm, SmlCommand *parent, SmlCommand *cmd, GError **error); -SmlBool smlAssemblerEndCommand(SmlAssembler *assm, SmlCommand *parent, GError **error); -unsigned int smlAssemblerCheckSize(SmlAssembler *assm, SmlBool headeronly, GError **error); -void smlAssemblerSetOption(SmlAssembler *assm, const char *optionname, const char *value); -const char *smlAssemblerGetOption(SmlAssembler *assm, const char *optionname); - -unsigned int smlAssemblerSetRemoteMaxMsgSize(SmlAssembler *assm, unsigned int limit); -unsigned int smlAssemblerGetRemoteMaxMsgSize(SmlAssembler *assm); -SmlBool smlAssemblerGetSpace(SmlAssembler *assm, int *space, SmlCommand *parent, SmlCommand *cmd, GError **error); - -unsigned int smlAssemblerGetRemoteMaxObjSize(SmlAssembler *assm); -unsigned int smlAssemblerSetRemoteMaxObjSize(SmlAssembler *assm, unsigned int limit); - -SmlBool smlAssemblerIsEmpty(SmlAssembler *assm); -SmlBool smlAssemblerIsStatusMissing(SmlAssembler *assm); -SmlBool smlAssemblerGetNextCmdRef(SmlAssembler *assm, unsigned int *cmdRef, unsigned int *msgRef); - -/* expire date: 20090626 */ -void smlAssemblerSetRequestedLimit(SmlAssembler *assm, unsigned int limit) LIBSYNCML_DEPRECATED; -void smlAssemblerSetLimit(SmlAssembler *assm, unsigned int limit) LIBSYNCML_DEPRECATED; -unsigned int smlAssemblerGetLimit(SmlAssembler *assm) LIBSYNCML_DEPRECATED; -void smlAssemblerSetRequestedMaxObjSize(SmlAssembler *assm, int limit) LIBSYNCML_DEPRECATED; -void smlAssemblerSetSendingMaxObjSize(SmlAssembler *assm, int limit) LIBSYNCML_DEPRECATED; -int smlAssemblerGetSendingMaxObjSize(SmlAssembler *assm) LIBSYNCML_DEPRECATED; -int smlAssemblerGetRequestedMaxObjSize(SmlAssembler *assm) LIBSYNCML_DEPRECATED; +SmlParser* smlParserNew (SmlMimeType type, gsize limit, GError **error); +void smlParserFree (SmlParser *parser); +gboolean smlParserStart (SmlParser *parser, const gchar *data, gsize size, GError **error); +gboolean smlParserGetHeader (SmlParser *parser, SmlHeader **header, SmlCred **cred, GError **error); +SmlParserResult smlParserGetCommand (SmlParser *parser, SmlCommand **cmd, GError **error); +gboolean smlParserGetStatus (SmlParser *parser, SmlStatus **status, GError **error); +gboolean smlParserEnd (SmlParser *parser, gboolean *final, gboolean *end, GError **error); + +SmlAssembler* smlAssemblerNew (SmlMimeType type, gsize limit, GError **error); +void smlAssemblerFree (SmlAssembler *assm); +gboolean smlAssemblerStart (SmlAssembler *assm, SmlSession *session, GError **error); +gsize smlAssemblerFlush (SmlAssembler *assm); +void smlAssemblerRestoreCommands (SmlAssembler *assm); +gboolean smlAssemblerRun (SmlAssembler *assm, gchar **data, gsize *size, gboolean *end, gboolean final, GError **error); +SmlAssemblerResult smlAssemblerAddStatus (SmlAssembler *assm, SmlStatus *status, GError **error); +SmlAssemblerResult smlAssemblerAddStatusFull (SmlAssembler *assm, SmlStatus *status, gboolean force, GError **error); +SmlAssemblerResult smlAssemblerReserveStatus (SmlAssembler *assm, guint cmdRef, guint msgRef, guint cmdID, GError **error); +gboolean smlAssemblerAddHeader (SmlAssembler *assm, SmlSession *session, GError **error); +SmlAssemblerResult smlAssemblerStartCommand (SmlAssembler *assm, SmlCommand *parent, SmlCommand *cmd, GError **error); +gboolean smlAssemblerEndCommand (SmlAssembler *assm, SmlCommand *parent, GError **error); +gsize smlAssemblerCheckSize (SmlAssembler *assm, gboolean headeronly, GError **error); +void smlAssemblerSetOption (SmlAssembler *assm, const gchar *optionname, const gchar *value); +const gchar* smlAssemblerGetOption (SmlAssembler *assm, const gchar *optionname); + +gsize smlAssemblerSetRemoteMaxMsgSize (SmlAssembler *assm, gsize limit); +gsize smlAssemblerGetRemoteMaxMsgSize (SmlAssembler *assm); +gboolean smlAssemblerGetSpace (SmlAssembler *assm, gsize *space, SmlCommand *parent, SmlCommand *cmd, GError **error); + +gsize smlAssemblerGetRemoteMaxObjSize (SmlAssembler *assm); +gsize smlAssemblerSetRemoteMaxObjSize (SmlAssembler *assm, gsize limit); + +SmlBool smlAssemblerIsEmpty (SmlAssembler *assm); +SmlBool smlAssemblerIsStatusMissing (SmlAssembler *assm); +SmlBool smlAssemblerGetNextCmdRef (SmlAssembler *assm, guint *cmdRef, guint *msgRef); /* If you want to parse OMA DS 1.2 SANs then the manager is required. */ -void smlParserSetManager(SmlParser *parser, SmlManager *manager); +void smlParserSetManager (SmlParser *parser, SmlManager *manager); #endif //_SML_PARSE_H_ Modified: trunk/libsyncml/sml_parse_internals.h ============================================================================== --- trunk/libsyncml/sml_parse_internals.h Fri Jul 3 11:31:01 2009 (r1146) +++ trunk/libsyncml/sml_parse_internals.h Fri Jul 3 15:03:14 2009 (r1147) @@ -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 @@ -26,7 +26,7 @@ SmlParserFunctions functions; void *parser_userdata; SmlMimeType type; - unsigned int limit; + gsize limit; SmlManager *manager; }; @@ -35,10 +35,10 @@ void *assm_userdata; SmlMimeType type; GHashTable *options; - SmlBool empty; + gboolean empty; - unsigned int remoteMaxMsgSize; - unsigned int remoteMaxObjSize; + gsize remoteMaxMsgSize; + gsize remoteMaxObjSize; }; #endif //_SML_PARSE_INTERNALS_H_ |
From: <svn...@op...> - 2009-07-03 09:31:07
|
Author: bellmich Date: Fri Jul 3 11:31:01 2009 New Revision: 1146 URL: http://libsyncml.opensync.org/changeset/1146 Log: migrated sml_notification from SmlError to GError Modified: trunk/libsyncml/sml_notification.c trunk/libsyncml/sml_notification.h trunk/libsyncml/sml_notification_internals.h trunk/libsyncml/sml_parse.h trunk/libsyncml/sml_transport.h Modified: trunk/libsyncml/sml_notification.c ============================================================================== --- trunk/libsyncml/sml_notification.c Fri Jul 3 10:26:52 2009 (r1145) +++ trunk/libsyncml/sml_notification.c Fri Jul 3 11:31:01 2009 (r1146) @@ -31,11 +31,18 @@ #include "sml_elements_internals.h" #include "data_sync_api/sml_location_internals.h" -SmlNotification *smlNotificationNew(SmlNotificationVersion version, SmlNotificationUIMode mode, SmlNotificationInitiator init, unsigned int sessionID, const char *identifier, const char *target, SmlMimeType type, SmlError **error) +SmlNotification* +smlNotificationNew (SmlNotificationVersion version, + SmlNotificationUIMode mode, + SmlNotificationInitiator init, + guint sessionID, + const gchar *identifier, + const gchar *target, + SmlMimeType type, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%i, %i, %i, %i, %s, %s, %i, %p)", __func__, version, mode, init, sessionID, VA_STRING(identifier), VA_STRING(target), type, error); CHECK_ERROR_REF - GError *gerror = NULL; SmlNotification *san = smlTryMalloc0(sizeof(SmlNotification), error); if (!san) @@ -51,25 +58,25 @@ san->sessionType = SML_SESSION_TYPE_SERVER; san->manager = NULL; - san->target = sml_location_new_with_options(target, NULL, &gerror); + san->target = sml_location_new_with_options(target, NULL, error); if (!san->target) goto error; smlTrace(TRACE_EXIT, "%s: %p", __func__, san); return san; - error: if (san) { if (san->identifier) g_free(san->identifier); smlSafeFree((gpointer *)&san); } - 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 NULL; } -void smlNotificationSetCred(SmlNotification *san, SmlCred *cred) +void +smlNotificationSetCred (SmlNotification *san, + SmlCred *cred) { smlTrace(TRACE_ENTRY, "%s", __func__); smlAssert(san); @@ -87,7 +94,9 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -void smlNotificationSetManager(SmlNotification *san, SmlManager *manager) +void +smlNotificationSetManager (SmlNotification *san, + SmlManager *manager) { smlTrace(TRACE_ENTRY, "%s", __func__); smlAssert(san); @@ -96,7 +105,8 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -void smlNotificationFree(SmlNotification *san) +void +smlNotificationFree (SmlNotification *san) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, san); smlAssert(san); @@ -124,7 +134,12 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -SmlBool smlNotificationNewAlert(SmlNotification *san, SmlAlertType type, const char *contenttype, const char *serverURI, SmlError **error) +gboolean +smlNotificationNewAlert (SmlNotification *san, + SmlAlertType type, + const gchar *contenttype, + const gchar *serverURI, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, error); CHECK_ERROR_REF @@ -142,13 +157,13 @@ smlTrace(TRACE_EXIT, "%s: %p", __func__, alert); return TRUE; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -void smlNotificationFreeAlert(SmlSanAlert *alert) +void +smlNotificationFreeAlert (SmlSanAlert *alert) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, alert); smlAssert(alert); @@ -160,25 +175,30 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -SmlNotification *smlNotificationParse(const char *data, unsigned int size, SmlError **error) +SmlNotification* +smlNotificationParse (const gchar *data, + gsize size, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, data, size, error); CHECK_ERROR_REF smlAssert(data); smlAssert(size); + + SmlNotification *san = NULL; if (size < 25) { - smlErrorSet(error, SML_ERROR_GENERIC, "Size too small"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Size too small"); goto error; } unsigned int idLength = (uint8_t)data[23]; if (size < (25 + idLength)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Size too small2"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Size too small2"); goto error; } - SmlNotification *san = smlTryMalloc0(sizeof(SmlNotification), error); + san = smlTryMalloc0(sizeof(SmlNotification), error); if (!san) goto error; san->type = SML_MIMETYPE_SAN; @@ -191,8 +211,8 @@ san->version = SML_SAN_VERSION_12; break; default: - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown version"); - goto error_free_san; + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown version"); + goto error; } /* ui mode */ @@ -210,7 +230,7 @@ /* the trailing NULL byte is usually not present in the SAN */ san->identifier = smlTryMalloc0(idLength + 1, error); if (!san->identifier) - goto error_free_san; + goto error; memcpy(san->identifier, data + 24, idLength); } @@ -222,22 +242,22 @@ unsigned int i = 0; for (i = 0; i < numSync; i++) { if (size < alertLength + 5) { - smlErrorSet(error, SML_ERROR_GENERIC, "Size too small3"); - goto error_free_san; + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Size too small3"); + goto error; } idLength = (uint8_t)data[4]; if (size < (alertLength + 5 + idLength)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Size too small4"); - goto error_free_san; + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Size too small4"); + goto error; } alertLength = alertLength + 5 + idLength; /* Alert type + future */ SmlAlertType alert_type = (((uint8_t)data[0]) >> 4) + 200; if (alert_type < 206 || alert_type > 210) { - smlErrorSet(error, SML_ERROR_GENERIC, "Wrong alert type"); - goto error_free_san; + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Wrong alert type"); + goto error; } unsigned int contenttype = ((uint8_t)data[1]) << 16; @@ -280,8 +300,8 @@ break; default: /* http://www.openmobilealliance.org/Tech/omna/omna-wsp-content-type.aspx */ - smlErrorSet(error, SML_ERROR_GENERIC, "The OMNA WSP Content Type Number 0x%xd is not supported.", contenttype); - goto error_free_san; + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The OMNA WSP Content Type Number 0x%xd is not supported.", contenttype); + goto error; } /* The server uri */ @@ -290,7 +310,7 @@ /* the trailing NULL byte is usually not present in the SAN */ alert_uri = smlTryMalloc0(idLength + 1, error); if (!alert_uri) - goto error_free_san; + goto error; memcpy(alert_uri, data + 5, idLength); } @@ -298,7 +318,7 @@ /* Create new alert */ if (!smlNotificationNewAlert(san, alert_type, alert_ct, alert_uri, error)) - goto error_free_san; + goto error; /* Cleanup */ if (idLength) @@ -306,27 +326,32 @@ } if (size > alertLength) { - smlErrorSet(error, SML_ERROR_GENERIC, "Extra chunk at the end of the buffer"); - goto error_free_san; + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Extra chunk at the end of the buffer"); + goto error; } smlTrace(TRACE_EXIT, "%s: %p", __func__, san); return san; - -error_free_san: - while (san->alerts) { - smlNotificationFreeAlert(san->alerts->data); - san->alerts = g_list_delete_link(san->alerts, san->alerts); - } - if (san->identifier) - smlSafeCFree(&(san->identifier)); - smlSafeFree((gpointer *)&san); error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + if (san) { + while (san->alerts) { + smlNotificationFreeAlert(san->alerts->data); + san->alerts = g_list_delete_link(san->alerts, san->alerts); + } + if (san->identifier) + smlSafeCFree(&(san->identifier)); + smlSafeFree((gpointer *)&san); + } + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -SmlBool smlNotificationAssemble11(SmlNotification *san, char **data, unsigned int *size, SmlProtocolVersion version, SmlError **error) +gboolean +smlNotificationAssemble11 (SmlNotification *san, + gchar **data, + gsize *size, + SmlProtocolVersion version, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %i, %p)", __func__, san, data, size, version, error); CHECK_ERROR_REF @@ -418,9 +443,7 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: - GERROR_TO_SML_ERROR(gerror,error) if (cmd) smlCommandUnref(cmd); if (session) @@ -429,11 +452,15 @@ smlAssemblerFree(assm); *data = NULL; *size = 0; - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -static SmlBool _smlNotificationAssemble12(SmlNotification *san, char **data, unsigned int *size, SmlError **error) +static gboolean +_smlNotificationAssemble12 (SmlNotification *san, + gchar **data, + gsize *size, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, san, data, size, error); CHECK_ERROR_REF @@ -574,16 +601,19 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: if (*data) smlSafeCFree(data); *size = 0; - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -SmlBool smlNotificationAssemble(SmlNotification *san, char **data, unsigned int *size, SmlError **error) +gboolean +smlNotificationAssemble (SmlNotification *san, + gchar **data, + gsize *size, + GError **error) { CHECK_ERROR_REF switch (san->version) { @@ -594,33 +624,37 @@ case SML_SAN_VERSION_11: return smlNotificationAssemble11(san, data, size, SML_VERSION_11, error); case SML_SAN_VERSION_UNKNOWN: - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown SAN version."); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown SAN version."); break; } return FALSE; } -SmlBool smlNotificationSend(SmlNotification *san, SmlTransport *tsp, SmlError **error) +gboolean +smlNotificationSend (SmlNotification *san, + SmlTransport *tsp, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, san, tsp, error); CHECK_ERROR_REF smlAssert(san); smlAssert(tsp); + SmlTransportData *tspdata = NULL; char *data = NULL; unsigned int size = 0; + if (!smlNotificationAssemble(san, &data, &size, error)) goto error; - SmlTransportData *tspdata = NULL; if (san->version == SML_SAN_VERSION_12) tspdata = smlTransportDataNew(data, size, SML_MIMETYPE_SAN, TRUE, error); else tspdata = smlTransportDataNew(data, size, san->type, TRUE, error); if (!tspdata) - goto error_free_data; + goto error; /* Do not free data because smlTransportDateNew does copy by reference. */ data = NULL; @@ -631,76 +665,87 @@ tspdata->type_get = san->type; if (!smlTransportSend(tsp, NULL, tspdata, error)) - goto error_free_tspdata; + goto error; smlTransportDataDeref(tspdata); smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; -error_free_tspdata: - smlTransportDataDeref(tspdata); -error_free_data: - smlSafeCFree(&data); error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + if (tspdata) + smlTransportDataDeref(tspdata); + if (data) + smlSafeCFree(&data); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -SmlNotificationVersion smlNotificationGetVersion(SmlNotification *san) +SmlNotificationVersion +smlNotificationGetVersion (SmlNotification *san) { smlAssert(san); return san->version; } -SmlNotificationUIMode smlNotificationGetMode(SmlNotification *san) +SmlNotificationUIMode +smlNotificationGetMode (SmlNotification *san) { smlAssert(san); return san->mode; } -SmlNotificationInitiator smlNotificationGetInitiator(SmlNotification *san) +SmlNotificationInitiator +smlNotificationGetInitiator (SmlNotification *san) { smlAssert(san); return san->init; } -unsigned int smlNotificationGetSessionID(SmlNotification *san) +guint +smlNotificationGetSessionID (SmlNotification *san) { smlAssert(san); return san->sessionID; } -const char *smlNotificationGetIdentifier(SmlNotification *san) +const gchar* +smlNotificationGetIdentifier (SmlNotification *san) { smlAssert(san); return san->identifier; } -unsigned int smlNotificationNumAlerts(SmlNotification *san) +gsize +smlNotificationNumAlerts (SmlNotification *san) { smlAssert(san); return g_list_length(san->alerts); } -SmlSanAlert *smlNotificationNthAlert(SmlNotification *san, unsigned int nth) +SmlSanAlert* +smlNotificationNthAlert (SmlNotification *san, + gsize nth) { smlAssert(san); return g_list_nth_data(san->alerts, nth); } -SmlAlertType smlSanAlertGetType(SmlSanAlert *alert) +SmlAlertType +smlSanAlertGetType (SmlSanAlert *alert) { smlAssert(alert); return alert->type; } -const char *smlSanAlertGetContentType(SmlSanAlert *alert) +const gchar* +smlSanAlertGetContentType (SmlSanAlert *alert) { smlAssert(alert); return alert->contenttype; } -const char *smlSanAlertGetServerURI(SmlSanAlert *alert) +const gchar* +smlSanAlertGetServerURI (SmlSanAlert *alert) { smlAssert(alert); return alert->serverURI; Modified: trunk/libsyncml/sml_notification.h ============================================================================== --- trunk/libsyncml/sml_notification.h Fri Jul 3 10:26:52 2009 (r1145) +++ trunk/libsyncml/sml_notification.h Fri Jul 3 11:31:01 2009 (r1146) @@ -1,7 +1,7 @@ /* * libsyncml - A syncml protocol implementation * Copyright (C) 2005 Armin Bauer <arm...@op...> - * Copyright (C) 2007 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 @@ -49,28 +49,28 @@ SML_SAN_INITIATOR_SERVER = 1 } SmlNotificationInitiator; -SmlNotification *smlNotificationNew(SmlNotificationVersion version, SmlNotificationUIMode mode, SmlNotificationInitiator init, unsigned int sessionID, const char *identifier, const char *target, SmlMimeType type, SmlError **error); -void smlNotificationSetCred(SmlNotification *san, SmlCred *cred); -void smlNotificationSetManager(SmlNotification *san, SmlManager *manager); -void smlNotificationFree(SmlNotification *san); -SmlNotification *smlNotificationParse(const char *data, unsigned int size, SmlError **error); -SmlBool smlNotificationAssemble(SmlNotification *san, char **data, unsigned int *size, SmlError **error); -SmlBool smlNotificationSend(SmlNotification *san, SmlTransport *tsp, SmlError **error); - -SmlBool smlNotificationNewAlert(SmlNotification *san, SmlAlertType type, const char *contenttype, const char *serverURI, SmlError **error); -void smlNotificationFreeAlert(SmlSanAlert *alert); - -SmlNotificationVersion smlNotificationGetVersion(SmlNotification *san); -SmlNotificationUIMode smlNotificationGetMode(SmlNotification *san); -SmlNotificationInitiator smlNotificationGetInitiator(SmlNotification *san); -unsigned int smlNotificationGetSessionID(SmlNotification *san); -const char *smlNotificationGetIdentifier(SmlNotification *san); -unsigned int smlNotificationNumAlerts(SmlNotification *san); -SmlSanAlert *smlNotificationNthAlert(SmlNotification *san, unsigned int nth); - -SmlAlertType smlSanAlertGetType(SmlSanAlert *alert); -const char *smlSanAlertGetContentType(SmlSanAlert *alert); -const char *smlSanAlertGetServerURI(SmlSanAlert *alert); +SmlNotification* smlNotificationNew (SmlNotificationVersion version, SmlNotificationUIMode mode, SmlNotificationInitiator init, guint sessionID, const gchar *identifier, const gchar *target, SmlMimeType type, GError **error); +void smlNotificationSetCred (SmlNotification *san, SmlCred *cred); +void smlNotificationSetManager (SmlNotification *san, SmlManager *manager); +void smlNotificationFree (SmlNotification *san); +SmlNotification* smlNotificationParse (const gchar *data, gsize size, GError **error); +gboolean smlNotificationAssemble (SmlNotification *san, gchar **data, gsize *size, GError **error); +gboolean smlNotificationSend (SmlNotification *san, SmlTransport *tsp, GError **error); + +gboolean smlNotificationNewAlert (SmlNotification *san, SmlAlertType type, const gchar *contenttype, const gchar *serverURI, GError **error); +void smlNotificationFreeAlert (SmlSanAlert *alert); + +SmlNotificationVersion smlNotificationGetVersion (SmlNotification *san); +SmlNotificationUIMode smlNotificationGetMode (SmlNotification *san); +SmlNotificationInitiator smlNotificationGetInitiator (SmlNotification *san); +guint smlNotificationGetSessionID (SmlNotification *san); +const gchar * smlNotificationGetIdentifier (SmlNotification *san); +gsize smlNotificationNumAlerts (SmlNotification *san); +SmlSanAlert * smlNotificationNthAlert (SmlNotification *san, gsize nth); + +SmlAlertType smlSanAlertGetType (SmlSanAlert *alert); +const gchar* smlSanAlertGetContentType (SmlSanAlert *alert); +const gchar* smlSanAlertGetServerURI (SmlSanAlert *alert); #endif //_SML_NOTIFICATION_H_ Modified: trunk/libsyncml/sml_notification_internals.h ============================================================================== --- trunk/libsyncml/sml_notification_internals.h Fri Jul 3 10:26:52 2009 (r1145) +++ trunk/libsyncml/sml_notification_internals.h Fri Jul 3 11:31:01 2009 (r1146) @@ -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 @@ -34,8 +34,8 @@ SmlNotificationVersion version; SmlNotificationUIMode mode; SmlNotificationInitiator init; - unsigned int sessionID; - char *identifier; + guint sessionID; + gchar *identifier; SmlLocation *target; GList *alerts; SmlMimeType type; @@ -43,22 +43,22 @@ SmlSessionType sessionType; SmlManager *manager; - unsigned int localMaxMsgSize; - unsigned int localMaxObjSize; + gsize localMaxMsgSize; + gsize localMaxObjSize; }; struct SmlSanAlert { SmlAlertType type; - char *contenttype; - char *serverURI; + gchar *contenttype; + gchar *serverURI; }; SmlBool smlNotificationAssemble11( SmlNotification *san, - char **data, - unsigned int *size, + gchar **data, + gsize *size, SmlProtocolVersion version, - SmlError **error); + GError **error); #endif //_SML_NOTIFICATION_INTERNALS_H_ Modified: trunk/libsyncml/sml_parse.h ============================================================================== --- trunk/libsyncml/sml_parse.h Fri Jul 3 10:26:52 2009 (r1145) +++ trunk/libsyncml/sml_parse.h Fri Jul 3 11:31:01 2009 (r1146) @@ -32,11 +32,11 @@ } SmlParserResult; typedef void (* SmlParserFreeFunction) (void *userdata); -typedef SmlBool (* SmlParserStartFunction) (void *userdata, const char *data, unsigned int size, SmlError **error); -typedef SmlBool (* SmlParserEndFunction) (void *userdata, SmlBool *final, SmlBool *end, SmlError **error); -typedef SmlBool (* SmlParserHeaderFunction) (void *userdata, SmlHeader **header, SmlCred **cred, SmlError **error); -typedef SmlBool (* SmlParserStatusFunction) (void *userdata, SmlStatus **status, SmlError **error); -typedef SmlParserResult (* SmlParserCommandFunction) (void *userdata, SmlCommand **cmd, SmlError **error); +typedef SmlBool (* SmlParserStartFunction) (void *userdata, const char *data, unsigned int size, GError **error); +typedef SmlBool (* SmlParserEndFunction) (void *userdata, SmlBool *final, SmlBool *end, GError **error); +typedef SmlBool (* SmlParserHeaderFunction) (void *userdata, SmlHeader **header, SmlCred **cred, GError **error); +typedef SmlBool (* SmlParserStatusFunction) (void *userdata, SmlStatus **status, GError **error); +typedef SmlParserResult (* SmlParserCommandFunction) (void *userdata, SmlCommand **cmd, GError **error); typedef struct SmlParserFunctions { SmlParserFreeFunction free; @@ -48,19 +48,19 @@ } SmlParserFunctions; typedef void (* SmlAssemblerFreeFunction) (void *userdata); -typedef SmlBool (* SmlAssemblerStartFunction) (void *userdata, SmlSession *session, SmlError **error); -typedef SmlBool (* SmlAssemblerEndFunction) (void *userdata, SmlError **error); -typedef SmlBool (* SmlAssemblerRunFunction) (void *userdata, char **data, unsigned int *size, SmlBool *end, SmlBool final, unsigned int maxsize, SmlError **error); +typedef SmlBool (* SmlAssemblerStartFunction) (void *userdata, SmlSession *session, GError **error); +typedef SmlBool (* SmlAssemblerEndFunction) (void *userdata, GError **error); +typedef SmlBool (* SmlAssemblerRunFunction) (void *userdata, char **data, unsigned int *size, SmlBool *end, SmlBool final, unsigned int maxsize, GError **error); typedef unsigned int (* SmlAssemblerFlushFunction) (void *userdata); -typedef SmlBool (* SmlAssemblerStatusFunction) (void *userdata, SmlStatus *status, SmlError **error); -typedef SmlBool (* SmlAssemblerRemStatusFunction) (void *userdata, SmlError **error); -typedef SmlBool (* SmlAssemblerReserveStatusFunction) (void *userdata, unsigned int cmdRef, unsigned int msgRef, unsigned int cmdID, SmlError **error); +typedef SmlBool (* SmlAssemblerStatusFunction) (void *userdata, SmlStatus *status, GError **error); +typedef SmlBool (* SmlAssemblerRemStatusFunction) (void *userdata, GError **error); +typedef SmlBool (* SmlAssemblerReserveStatusFunction) (void *userdata, unsigned int cmdRef, unsigned int msgRef, unsigned int cmdID, GError **error); typedef SmlBool (* SmlAssemblerStatusMissingFunction) (void *userdata); -typedef SmlBool (* SmlAssemblerStartCommandFunction) (void *userdata, unsigned int parentID, SmlCommand *cmd, SmlError **error); -typedef SmlBool (* SmlAssemblerEndCommandFunction) (void *userdata, unsigned int parentID, SmlError **error); -typedef SmlBool (* SmlAssemblerRemCommandFunction) (void *userdata, unsigned int parentID, SmlError **error); -typedef SmlBool (* SmlAssemblerHeaderFunction) (void *userdata, SmlSession *session, SmlError **error); -typedef unsigned int (* SmlAssemblerCheckFunction) (void *userdata, SmlBool headeronly, SmlError **error); +typedef SmlBool (* SmlAssemblerStartCommandFunction) (void *userdata, unsigned int parentID, SmlCommand *cmd, GError **error); +typedef SmlBool (* SmlAssemblerEndCommandFunction) (void *userdata, unsigned int parentID, GError **error); +typedef SmlBool (* SmlAssemblerRemCommandFunction) (void *userdata, unsigned int parentID, GError **error); +typedef SmlBool (* SmlAssemblerHeaderFunction) (void *userdata, SmlSession *session, GError **error); +typedef unsigned int (* SmlAssemblerCheckFunction) (void *userdata, SmlBool headeronly, GError **error); typedef SmlBool (* SmlAssemblerNextCmdRefFunction) (void *userdata, unsigned int *cmdRef, unsigned int *msgRef); typedef void (* SmlAssemblerRestoreCommandsFunction) (void *userdata); @@ -97,25 +97,25 @@ SmlBool smlParserGetStatus(SmlParser *parser, SmlStatus **status, SmlError **error); SmlBool smlParserEnd(SmlParser *parser, SmlBool *final, SmlBool *end, SmlError **error); -SmlAssembler *smlAssemblerNew(SmlMimeType type, unsigned int limit, SmlError **error); +SmlAssembler *smlAssemblerNew(SmlMimeType type, unsigned int limit, GError **error); void smlAssemblerFree(SmlAssembler *assm); -SmlBool smlAssemblerStart(SmlAssembler *assm, SmlSession *session, SmlError **error); +SmlBool smlAssemblerStart(SmlAssembler *assm, SmlSession *session, GError **error); unsigned int smlAssemblerFlush(SmlAssembler *assm); void smlAssemblerRestoreCommands(SmlAssembler *assm); -SmlBool smlAssemblerRun(SmlAssembler *assm, char **data, unsigned int *size, SmlBool *end, SmlBool final, SmlError **error); -SmlAssemblerResult smlAssemblerAddStatus(SmlAssembler *assm, SmlStatus *status, SmlError **error); -SmlAssemblerResult smlAssemblerAddStatusFull(SmlAssembler *assm, SmlStatus *status, SmlBool force, SmlError **error); -SmlAssemblerResult smlAssemblerReserveStatus(SmlAssembler *assm, unsigned int cmdRef, unsigned int msgRef, unsigned int cmdID, SmlError **error); -SmlBool smlAssemblerAddHeader(SmlAssembler *assm, SmlSession *session, SmlError **error); -SmlAssemblerResult smlAssemblerStartCommand(SmlAssembler *assm, SmlCommand *parent, SmlCommand *cmd, SmlError **error); -SmlBool smlAssemblerEndCommand(SmlAssembler *assm, SmlCommand *parent, SmlError **error); -unsigned int smlAssemblerCheckSize(SmlAssembler *assm, SmlBool headeronly, SmlError **error); +SmlBool smlAssemblerRun(SmlAssembler *assm, char **data, unsigned int *size, SmlBool *end, SmlBool final, GError **error); +SmlAssemblerResult smlAssemblerAddStatus(SmlAssembler *assm, SmlStatus *status, GError **error); +SmlAssemblerResult smlAssemblerAddStatusFull(SmlAssembler *assm, SmlStatus *status, SmlBool force, GError **error); +SmlAssemblerResult smlAssemblerReserveStatus(SmlAssembler *assm, unsigned int cmdRef, unsigned int msgRef, unsigned int cmdID, GError **error); +SmlBool smlAssemblerAddHeader(SmlAssembler *assm, SmlSession *session, GError **error); +SmlAssemblerResult smlAssemblerStartCommand(SmlAssembler *assm, SmlCommand *parent, SmlCommand *cmd, GError **error); +SmlBool smlAssemblerEndCommand(SmlAssembler *assm, SmlCommand *parent, GError **error); +unsigned int smlAssemblerCheckSize(SmlAssembler *assm, SmlBool headeronly, GError **error); void smlAssemblerSetOption(SmlAssembler *assm, const char *optionname, const char *value); const char *smlAssemblerGetOption(SmlAssembler *assm, const char *optionname); unsigned int smlAssemblerSetRemoteMaxMsgSize(SmlAssembler *assm, unsigned int limit); unsigned int smlAssemblerGetRemoteMaxMsgSize(SmlAssembler *assm); -SmlBool smlAssemblerGetSpace(SmlAssembler *assm, int *space, SmlCommand *parent, SmlCommand *cmd, SmlError **error); +SmlBool smlAssemblerGetSpace(SmlAssembler *assm, int *space, SmlCommand *parent, SmlCommand *cmd, GError **error); unsigned int smlAssemblerGetRemoteMaxObjSize(SmlAssembler *assm); unsigned int smlAssemblerSetRemoteMaxObjSize(SmlAssembler *assm, unsigned int limit); Modified: trunk/libsyncml/sml_transport.h ============================================================================== --- trunk/libsyncml/sml_transport.h Fri Jul 3 10:26:52 2009 (r1145) +++ trunk/libsyncml/sml_transport.h Fri Jul 3 11:31:01 2009 (r1146) @@ -52,7 +52,7 @@ 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, SmlError **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); |
From: <svn...@op...> - 2009-07-03 08:26:59
|
Author: bellmich Date: Fri Jul 3 10:26:52 2009 New Revision: 1145 URL: http://libsyncml.opensync.org/changeset/1145 Log: migrated sml_md5 from SmlError to GError Modified: trunk/libsyncml/sml_md5.c trunk/libsyncml/sml_md5.h Modified: trunk/libsyncml/sml_md5.c ============================================================================== --- trunk/libsyncml/sml_md5.c Thu Jul 2 17:00:38 2009 (r1144) +++ trunk/libsyncml/sml_md5.c Fri Jul 3 10:26:52 2009 (r1145) @@ -3,6 +3,7 @@ * Modified June 1993 by Colin Plumb for altered md5.c. * Modified October 1995 by Erik Troan for RPM * Modified again 2005 by Armin Bauer + * Modified again 2009 by Michael Bell * This code is in the public domain * */ @@ -247,7 +248,7 @@ buf[3] += d; } -void smlMD5GetDigest (const char *buffer, int buffer_size, unsigned char digest[16]) +void smlMD5GetDigest (const gchar *buffer, gsize buffer_size, guchar digest[16]) { SmlMD5Context ctx; @@ -257,7 +258,7 @@ } -char *smlMD5ToString(unsigned char digest[16], SmlError **error) +gchar *smlMD5ToString(guchar digest[16], GError **error) { CHECK_ERROR_REF char *string = smlTryMalloc0(33, error); Modified: trunk/libsyncml/sml_md5.h ============================================================================== --- trunk/libsyncml/sml_md5.h Thu Jul 2 17:00:38 2009 (r1144) +++ trunk/libsyncml/sml_md5.h Fri Jul 3 10:26:52 2009 (r1145) @@ -1,6 +1,7 @@ /* * libsyncml - A syncml protocol implementation * Copyright (C) 2005 Armin Bauer <arm...@op...> + * Copyright (C) 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 @@ -29,8 +30,8 @@ #ifndef _SML_MD5_H_ #define _SML_MD5_H_ -void smlMD5GetDigest (const char *buffer, int buffer_size, unsigned char digest[16]); -char *smlMD5ToString(unsigned char digest[16], SmlError **error); +void smlMD5GetDigest (const gchar *buffer, gsize buffer_size, guchar digest[16]); +gchar* smlMD5ToString (guchar digest[16], GError **error); #endif //_SML_BASE64_H_ |
From: <svn...@op...> - 2009-07-02 15:00:44
|
Author: bellmich Date: Thu Jul 2 17:00:38 2009 New Revision: 1144 URL: http://libsyncml.opensync.org/changeset/1144 Log: migrated sml_manager from SmlError to GError Modified: trunk/libsyncml/sml_manager.c trunk/libsyncml/sml_manager.h trunk/libsyncml/sml_manager_internals.h trunk/libsyncml/sml_parse.h trunk/libsyncml/sml_queue_internals.h trunk/libsyncml/sml_session.h trunk/libsyncml/sml_session_internals.h trunk/libsyncml/sml_transport.h trunk/libsyncml/sml_transport_internals.h Modified: trunk/libsyncml/sml_manager.c ============================================================================== --- trunk/libsyncml/sml_manager.c Thu Jul 2 16:06:31 2009 (r1143) +++ trunk/libsyncml/sml_manager.c Thu Jul 2 17:00:38 2009 (r1144) @@ -32,22 +32,17 @@ typedef struct managerSession { SmlLink *link; SmlSession *session; - unsigned int finalLock; + guint finalLock; SmlTransport *transport; GList *objects; } managerSession; -managerSession *_smlManagerGetManagerSession(SmlManager *manager, SmlSession *session); +managerSession* _smlManagerGetManagerSession (SmlManager *manager, SmlSession *session); +SmlObject* smlManagerObjectFindInternal (SmlManager *manager, SmlSession *session, SmlCommandType type, SmlLocation *target, SmlLocation *source, const gchar* contentType); -SmlObject *smlManagerObjectFindInternal( - SmlManager *manager, - SmlSession *session, - SmlCommandType type, - SmlLocation *target, - SmlLocation *source, - const char* contentType); - -static managerSession *_manager_session_find(SmlManager *manager, SmlSession *session) +static managerSession* +_manager_session_find (SmlManager *manager, + SmlSession *session) { smlAssert(session); smlAssert(manager); @@ -61,7 +56,8 @@ return NULL; } -static void _manager_session_free(managerSession *sess) +static void +_manager_session_free (managerSession *sess) { smlAssert(sess); @@ -79,14 +75,16 @@ smlSafeFree((gpointer *)&sess); } -static gboolean _manager_prepare_internal(GSource *source, gint *timeout_) +static gboolean +_manager_prepare_internal (GSource *source, gint *timeout_) { smlTrace(TRACE_INTERNAL, "%s(%p, %p)", __func__, source, timeout_); *timeout_ = 1; return FALSE; } -static gboolean _manager_check_internal(GSource *source) +static gboolean +_manager_check_internal (GSource *source) { SmlManager *manager = *((SmlManager **)(source + 1)); GList *s = NULL; @@ -98,7 +96,10 @@ return FALSE; } -static gboolean _manager_dispatch_internal(GSource *source, GSourceFunc callback, gpointer user_data) +static gboolean +_manager_dispatch_internal (GSource *source, + GSourceFunc callback, + gpointer user_data) { smlTrace(TRACE_INTERNAL, "%s(%p, %p, %p)", __func__, source, callback, user_data); int max = 100; @@ -126,52 +127,58 @@ return TRUE; } -static void _smlManagerSendEvent(SmlManager *manager, SmlManagerEventType type, SmlSession *session, SmlCommand *command, SmlCommand *parent, SmlError *error) +static void +_smlManagerSendEvent (SmlManager *manager, + SmlManagerEventType type, + SmlSession *session, + SmlCommand *command, + SmlCommand *parent, + const GError *error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p, %p)", __func__, manager, type, session, command, parent, error); - SmlError *lerr = NULL; + GError *lerr = NULL; SmlManagerEvent *event = smlTryMalloc0(sizeof(SmlManagerEvent), &lerr); - if (event) { - event->type = type; - - if (session) { - event->session = session; - smlSessionRef(session); - } else { - event->session = NULL; - } - - if (command) { - event->command = command; - smlCommandRef(command); - } else { - event->command = NULL; - } - - if (parent) { - event->parent = parent; - smlCommandRef(parent); - } else { - event->parent = NULL; - } - - if (error) { - event->error = error; - smlErrorRef(&error); - } + if (!event) { + g_error("%s", lerr->message); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, lerr->message); + g_error_free(lerr); + return; + } + + event->type = type; - smlQueueSend(manager->userEventQueue, event); + if (session) { + event->session = session; + smlSessionRef(session); } else { - /* error handling is not possible here :( */ - g_error("%s", smlErrorPrint(&lerr)); - smlErrorDeref(&lerr); + event->session = NULL; } + if (command) { + event->command = command; + smlCommandRef(command); + } else { + event->command = NULL; + } + + if (parent) { + event->parent = parent; + smlCommandRef(parent); + } else { + event->parent = NULL; + } + + if (error) + event->error = g_error_copy(error); + + smlQueueSend(manager->userEventQueue, event); + smlTrace(TRACE_EXIT, "%s", __func__); } -void _smlManagerEventFree(SmlManagerEvent *event) +void +_smlManagerEventFree (SmlManagerEvent *event) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, event); smlAssert(event); @@ -186,7 +193,7 @@ smlCommandUnref(event->parent); if (event->error) - smlErrorDeref(&(event->error)); + g_error_free(event->error); smlSafeFree((gpointer *)&event); @@ -195,7 +202,13 @@ /* If we return FALSE in this function, the current request will get * aborted */ -static SmlBool _smlManagerDataHandler(SmlTransport *tsp, SmlLink *link_, SmlTransportEventType type, SmlTransportData *data, SmlError *error, void *userdata) +static gboolean +_smlManagerDataHandler (SmlTransport *tsp, + SmlLink *link_, + SmlTransportEventType type, + SmlTransportData *data, + const GError *error, + void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %i, %p, %p, %p)", __func__, tsp, link_, type, data, error, userdata); smlAssert(userdata); @@ -204,7 +217,7 @@ SmlHeader *header = NULL; SmlCred *cred = NULL; SmlSession *session = NULL; - SmlError *locerror = NULL; + GError *locerror = NULL; switch (type) { case SML_TRANSPORT_EVENT_CONNECT_DONE: @@ -219,19 +232,19 @@ parser = smlParserNew(data->type, 0, &locerror); if (!parser) - goto session_error; + goto error; /* add manager to parser for OMA DS 1.2 SAN handling */ smlParserSetManager(parser, manager); /* start to parse the data */ if (!smlParserStart(parser, data->data, data->size, &locerror)) - goto error_free_parser; + goto error; /* Get the header of the message*/ header = NULL; cred = NULL; if (!smlParserGetHeader(parser, &header, &cred, &locerror)) - goto error_free_parser; + goto error; /* Find the session if available otherwise register it as new */ session = smlManagerSessionFind(manager, header->sessionID); @@ -254,11 +267,11 @@ sessionType = SML_SESSION_TYPE_SERVER; break; default: - smlErrorSet(&locerror, + g_set_error(&locerror, SML_ERROR, SML_ERROR_NOT_IMPLEMENTED, "New session was unexpectedly received for transport %d.", smlTransportGetType(tsp)); - goto error_free_header; + goto error; break; } if (!(session = smlSessionNew( @@ -266,24 +279,24 @@ header->version, header->protocol, header->source, header->target, header->sessionID, 1, &locerror))) - goto error_free_header; + goto error; if (link_) { char *responseURI = smlTransportGetResponseURI(link_, session, &locerror); if (!responseURI && locerror) - goto error_free_header; + goto error; if (responseURI) { if (!smlSessionSetResponseURI(session, responseURI, &locerror)) { smlSafeCFree(&responseURI); - goto error_free_header; + goto error; } smlSafeCFree(&responseURI); } } if (!smlManagerSessionAdd(manager, session, link_, &locerror)) - goto error_free_header; + goto error; smlSessionUnref(session); } else { /* SECURITY: let's check ResponseURI if supported @@ -292,7 +305,7 @@ if (link_) { char *responseUri = smlTransportGetResponseURI(link_, session, &locerror); if (!responseUri && locerror) { - goto error_free_header; + goto error; } if (responseUri) smlSafeCFree(&responseUri); @@ -327,11 +340,11 @@ /* Now check if the header is valid etc */ if (!smlSessionReceiveHeader(session, header, &locerror)) - goto error_free_header; + goto error; /* Then check if we are allowed to authenticate */ if (!smlManagerDispatchHeader(manager, session, header, cred, &locerror)) - goto error_free_header; + goto error; smlHeaderFree(header); if (cred) @@ -339,7 +352,7 @@ /* Now let the session handle the commands etc */ if (!smlSessionReceiveBody(session, parser, &locerror)) - goto error_free_parser; + goto error; /* Free the parser */ smlParserFree(parser); @@ -350,24 +363,23 @@ break; case SML_TRANSPORT_EVENT_ERROR: /* Pass the error through */ - smlErrorDuplicate(&locerror, &error); - goto transport_error; + _smlManagerSendEvent(manager, SML_MANAGER_TRANSPORT_ERROR, NULL, NULL, NULL, error); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, error->message); + return FALSE; break; } smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - -error_free_header: +error: if (header) smlHeaderFree(header); if (cred) smlCredUnref(cred); -error_free_parser: - smlParserFree(parser); + if (parser) + smlParserFree(parser); if (session) smlSessionUnlock(session); -session_error: if (session == NULL && link_ && type == SML_TRANSPORT_EVENT_DATA) { /* If there is no session and a link then this means * that there is a failing server connection. @@ -375,26 +387,22 @@ * the session has no chance to signal a clean * disconnect to the link. */ - SmlError *herror = NULL; + GError *herror = NULL; if (!smlTransportDisconnect(manager->transport, link_, &herror)) { smlTrace(TRACE_ERROR, "%s: Disconnect on error failed. %s", - smlErrorPrint(&herror)); - smlErrorDeref(&herror); + herror->message); + g_error_free(herror); } } _smlManagerSendEvent(manager, SML_MANAGER_SESSION_ERROR, session, NULL, NULL, locerror); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&locerror)); - smlErrorDeref(&locerror); - return FALSE; - -transport_error: - _smlManagerSendEvent(manager, SML_MANAGER_TRANSPORT_ERROR, NULL, NULL, NULL, locerror); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&locerror)); - smlErrorDeref(&locerror); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, locerror->message); + g_error_free(locerror); return FALSE; } -SmlManager *smlManagerNew(SmlTransport *tsp, SmlError **error) +SmlManager* +smlManagerNew (SmlTransport *tsp, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, tsp, error); smlAssert(tsp); @@ -412,19 +420,20 @@ manager->userEventQueue = smlQueueNew(error); if (!manager->userEventQueue) - goto error_free_manager; + goto error; smlTrace(TRACE_EXIT, "%s", __func__); return manager; -error_free_manager: - smlSafeFree((gpointer *)&manager); error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + if (manager) + smlSafeFree((gpointer *)&manager); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -void smlManagerFree(SmlManager *manager) +void +smlManagerFree (SmlManager *manager) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, manager); smlAssert(manager); @@ -472,7 +481,10 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -void smlManagerSetEventCallback(SmlManager *manager, SmlManagerEventCb callback, void *userdata) +void +smlManagerSetEventCallback (SmlManager *manager, + SmlManagerEventCb callback, + void *userdata) { smlAssert(manager); smlAssert(callback); @@ -481,7 +493,9 @@ manager->eventCallbackUserdata = userdata; } -SmlBool smlManagerStart(SmlManager *manager, SmlError **error) +gboolean +smlManagerStart (SmlManager *manager, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, manager, error); smlAssert(manager); @@ -489,7 +503,7 @@ manager->context = g_main_context_new(); if (!manager->context) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Cannot create new main context."); goto error; } @@ -524,7 +538,7 @@ } if (manager->functions) smlSafeFree((gpointer *)&(manager->functions)); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } @@ -562,7 +576,8 @@ * @param manager The manager * */ -void smlManagerStop(SmlManager *manager) +void +smlManagerStop (SmlManager *manager) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, manager); smlAssert(manager); @@ -601,14 +616,14 @@ * or * 2.2. this is an active server connection */ - SmlError *error = NULL; + GError *error = NULL; if (manager->transport->connected && (!sess->link || sess->link->link_data) && !smlTransportDisconnect(manager->transport, sess->link, &error)) { g_warning("Errors from the transport layer " \ "cannot be handled while freeing the manager. %s", - smlErrorPrint(&error)); - smlErrorDeref(&error); + error->message); + g_error_free(error); } sessionItem = g_list_next(sessionItem); @@ -618,7 +633,8 @@ } -void smlManagerRun(SmlManager *manager) +void +smlManagerRun (SmlManager *manager) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, manager); smlAssert(manager); @@ -630,7 +646,8 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -void smlManagerQuit(SmlManager *manager) +void +smlManagerQuit (SmlManager *manager) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, manager); smlAssert(manager); @@ -642,7 +659,9 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -SmlSession *smlManagerSessionFind(SmlManager *manager, const char *sessionID) +SmlSession* +smlManagerSessionFind (SmlManager *manager, + const gchar *sessionID) { smlTrace(TRACE_ENTRY, "%s(%p, %s)", __func__, manager, VA_STRING(sessionID)); GList *s = NULL; @@ -658,7 +677,8 @@ return NULL; } -void smlManagerDispatch(SmlManager *manager) +void +smlManagerDispatch (SmlManager *manager) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, manager); smlAssert(manager); @@ -692,16 +712,24 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -SmlBool smlManagerCheck(SmlManager *manager) +gboolean +smlManagerCheck (SmlManager *manager) { return smlQueueCheck(manager->userEventQueue); } -static void _event_callback(SmlSession *session, SmlSessionEventType type, SmlCommand *command, SmlCommand *parent, SmlStatus *reply, SmlError *error, void *userdata) +static void +_event_callback (SmlSession *session, + SmlSessionEventType type, + SmlCommand *command, + SmlCommand *parent, + SmlStatus *reply, + const GError *error, + void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p, %p, %p)", __func__, session, type, command, parent, reply, error, userdata); SmlManager *manager = userdata; - SmlError *locerror = NULL; + GError *locerror = NULL; switch (type) { case SML_SESSION_EVENT_ESTABLISHED: @@ -747,37 +775,41 @@ break; case SML_SESSION_EVENT_ERROR: /* Pass the error through */ - smlErrorDuplicate(&locerror, &error); - _smlManagerSendEvent(manager, SML_MANAGER_SESSION_ERROR, session, NULL, NULL, locerror); - goto error; + _smlManagerSendEvent(manager, SML_MANAGER_SESSION_ERROR, session, NULL, NULL, error); break; } smlTrace(TRACE_EXIT, "%s", __func__); return; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&locerror)); - smlErrorDeref(&locerror); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, locerror->message); + g_error_free(locerror); } -static void _data_send_callback(SmlSession *session, SmlTransportData *data, void *userdata) +static void +_data_send_callback (SmlSession *session, + SmlTransportData *data, + void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, data, userdata); managerSession *sess = userdata; /* The transport layer is able to signal the error via an event. */ - SmlError *error = NULL; + GError *error = NULL; if (!smlTransportSend(sess->transport, sess->link, data, &error)) { - smlTrace(TRACE_ERROR, "%s - %s", __func__, smlErrorPrint(&error)); - smlErrorDeref(&error); + smlTrace(TRACE_ERROR, "%s - %s", __func__, error->message); + g_error_free(error); } smlTrace(TRACE_EXIT, "%s", __func__); } -SmlBool smlManagerSessionAdd(SmlManager *manager, SmlSession *session, SmlLink *link_, SmlError **error) +gboolean +smlManagerSessionAdd (SmlManager *manager, + SmlSession *session, + SmlLink *link_, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, manager, session, link_, error); CHECK_ERROR_REF @@ -789,7 +821,7 @@ smlTrace(TRACE_INTERNAL, "Checking if session ID %s already exists", smlSessionGetSessionID(session)); if (smlManagerSessionFind(manager, smlSessionGetSessionID(session))) { - smlErrorSet(error, SML_ERROR_GENERIC, "Session ID already exists"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Session ID already exists"); goto error; } } else { @@ -840,14 +872,15 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: smlSessionUnref(session); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -managerSession *_smlManagerGetManagerSession(SmlManager *manager, SmlSession *session) +managerSession* +_smlManagerGetManagerSession (SmlManager *manager, + SmlSession *session) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, manager, session); @@ -864,7 +897,9 @@ return NULL; } -void smlManagerSessionRemove(SmlManager *manager, SmlSession *session) +void +smlManagerSessionRemove (SmlManager *manager, + SmlSession *session) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, manager, session); @@ -878,7 +913,9 @@ } } -void smlManagerSessionFinalLockRef(SmlManager *manager, SmlSession *session) +void +smlManagerSessionFinalLockRef (SmlManager *manager, + SmlSession *session) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, manager, session); @@ -891,7 +928,9 @@ } } -void smlManagerSessionFinalLockUnref(SmlManager *manager, SmlSession *session) +void +smlManagerSessionFinalLockUnref (SmlManager *manager, + SmlSession *session) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, manager, session); @@ -923,7 +962,16 @@ * @return TRUE if successful, FALSE otherwise * */ -SmlBool smlManagerObjectRegister(SmlManager *manager, SmlCommandType type, SmlSession *session, SmlLocation *location, SmlLocation *source, const char *contentType, SmlCommandCb callback, SmlCommandCb childCallback, void *userdata, SmlError **error) +gboolean +smlManagerObjectRegister (SmlManager *manager, + SmlCommandType type, + SmlSession *session, + SmlLocation *location, + SmlLocation *source, + const gchar *contentType, + SmlCommandCb callback, + SmlCommandCb childCallback, + void *userdata, GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p, %s, %p, %p, %p, %p)", __func__, manager, type, session, location, source, VA_STRING(contentType), callback, childCallback, userdata, error); smlAssert(manager); @@ -973,8 +1021,8 @@ if (session) { managerSession *sess = _manager_session_find(manager, session); if (!sess) { - smlErrorSet(error, SML_ERROR_GENERIC, "Session not found"); - goto error_free_object; + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Session not found"); + goto error; } sess->objects = g_list_append(sess->objects, object); @@ -1007,15 +1055,18 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - -error_free_object: - smlManagerObjectFree(object); error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + if (object) + smlManagerObjectFree(object); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -void smlManagerObjectDeregister(SmlManager *manager, SmlCommandType type, SmlLocation *location, SmlLocation *source) +void +smlManagerObjectDeregister (SmlManager *manager, + SmlCommandType type, + SmlLocation *location, + SmlLocation *source) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p, %p)", __func__, manager, type, location, source); smlAssert(manager); @@ -1043,7 +1094,8 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -void smlManagerObjectFree(SmlObject *object) +void +smlManagerObjectFree (SmlObject *object) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, object); smlAssert(object); @@ -1062,7 +1114,10 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -SmlObject *smlManagerObjectFind(SmlManager *manager, SmlSession *session, SmlCommand *cmd) +SmlObject* +smlManagerObjectFind (SmlManager *manager, + SmlSession *session, + SmlCommand *cmd) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, manager, session, cmd); smlAssert(manager); @@ -1078,13 +1133,13 @@ return object; } -SmlObject *smlManagerObjectFindInternal( - SmlManager *manager, - SmlSession *session, - SmlCommandType type, - SmlLocation *target, - SmlLocation *source, - const char* contentType) +SmlObject* +smlManagerObjectFindInternal(SmlManager *manager, + SmlSession *session, + SmlCommandType type, + SmlLocation *target, + SmlLocation *source, + const gchar* contentType) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %d, %p, %p)", __func__, manager, session, type, target, source); @@ -1150,7 +1205,8 @@ return NULL; } -SmlTransport *smlManagerGetTransport(SmlManager *manager) +SmlTransport* +smlManagerGetTransport (SmlManager *manager) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, manager); smlAssert(manager); @@ -1161,7 +1217,12 @@ return tsp; } -SmlBool smlManagerDispatchHeader(SmlManager *manager, SmlSession *session, SmlHeader *header, SmlCred *cred, SmlError **error) +gboolean +smlManagerDispatchHeader (SmlManager *manager, + SmlSession *session, + SmlHeader *header, + SmlCred *cred, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %p)", __func__, manager, session, header, cred, error); smlAssert(manager); @@ -1209,13 +1270,17 @@ 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 smlManagerDispatchChildCommand(SmlManager *manager, SmlSession *session, SmlCommand *parent, SmlCommand *cmd, SmlError **error) +gboolean +smlManagerDispatchChildCommand (SmlManager *manager, + SmlSession *session, + SmlCommand *parent, + SmlCommand *cmd, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %p)", __func__, manager, session, parent, cmd, error); smlAssert(manager); @@ -1228,7 +1293,7 @@ if (object) { //Check if a handler for this object at this path has been installed. if (!object->childCallback) { - smlErrorSet(error, SML_ERROR_GENERIC, "No handler for the child was installed"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No handler for the child was installed"); goto error; } @@ -1245,20 +1310,23 @@ smlStatusUnref(reply); - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to find child command handler"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to find child command handler"); 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; } -SmlBool smlManagerDispatchCommand(SmlManager *manager, SmlSession *session, SmlCommand *cmd, SmlError **error) +gboolean +smlManagerDispatchCommand (SmlManager *manager, + SmlSession *session, + SmlCommand *cmd, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, manager, session, cmd, error); smlAssert(manager); @@ -1271,7 +1339,7 @@ if (object) { //Check if a handler for this object at this path has been installed. if (!object->commandCallback) { - smlErrorSet(error, SML_ERROR_GENERIC, "No handler for the child was installed"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No handler for the child was installed"); goto error; } @@ -1279,29 +1347,40 @@ } else { const char *type = smlCommandTypeToString(cmd->type, error); /* If the type is unknown then this can be part of the error. */ - smlErrorDeref(error); + if (*error) { + g_error_free(*error); + *error = NULL; + } const char *srcuri = NULL; if (cmd->source) srcuri = sml_location_get_uri(cmd->source); const char *dsturi = NULL; if (cmd->target) dsturi = sml_location_get_uri(cmd->target); - smlErrorSet(error, SML_ERROR_NOT_FOUND, "Unable to find command handler (%s: %s -> %s)", (type) ? type : "UNKNOWN", VA_STRING(srcuri), VA_STRING(dsturi)); + g_set_error(error, SML_ERROR, SML_ERROR_NOT_FOUND, "Unable to find command handler (%s: %s -> %s)", (type) ? type : "UNKNOWN", VA_STRING(srcuri), VA_STRING(dsturi)); - SmlError *locerror = NULL; + GError *locerror = NULL; SmlStatus *reply = smlCommandNewReply(cmd, SML_ERROR_NOT_FOUND, &locerror); if (!reply) { - smlErrorSet(error, SML_ERROR_NOT_FOUND, "%s %s", - smlErrorPrint(error), - smlErrorPrint(&locerror)); + GError *herr = *error; + *error = NULL; + g_set_error(error, SML_ERROR, SML_ERROR_NOT_FOUND, "%s %s", + herr->message, + locerror->message); + g_error_free(herr); + g_error_free(locerror); goto error; } if (!smlSessionSendReply(session, reply, &locerror)) { + GError *herr = *error; + *error = NULL; smlStatusUnref(reply); - smlErrorSet(error, SML_ERROR_NOT_FOUND, "%s %s", - smlErrorPrint(error), - smlErrorPrint(&locerror)); + g_set_error(error, SML_ERROR, SML_ERROR_NOT_FOUND, "%s %s", + herr->message, + locerror->message); + g_error_free(herr); + g_error_free(locerror); goto error; } @@ -1312,13 +1391,16 @@ 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 smlManagerRegisterHeaderHandler(SmlManager *manager, SmlHeaderCb callback, SmlStatusReplyCb statuscb, void *userdata) +void +smlManagerRegisterHeaderHandler (SmlManager *manager, + SmlHeaderCb callback, + SmlStatusReplyCb statuscb, + void *userdata) { smlAssert(manager); @@ -1327,19 +1409,24 @@ manager->headerCallbackUserdata = userdata; } -void smlManagerSetLocalMaxMsgSize(SmlManager *manager, unsigned int size) +void +smlManagerSetLocalMaxMsgSize (SmlManager *manager, + gsize size) { smlAssert(manager); manager->localMaxMsgSize = size; } -void smlManagerSetLocalMaxObjSize(SmlManager *manager, unsigned int size) +void +smlManagerSetLocalMaxObjSize (SmlManager *manager, + gsize size) { smlAssert(manager); manager->localMaxObjSize = size; } -char *smlManagerGetNewSessionID(SmlManager *manager) +gchar* +smlManagerGetNewSessionID (SmlManager *manager) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, manager); smlAssertMsg(manager, "The manager is required to avoid duplicated session IDs."); @@ -1359,10 +1446,10 @@ return sessionString; } -SmlLink *smlManagerSessionGetLink( - SmlManager *manager, - SmlSession *session, - SmlError **error) +SmlLink* +smlManagerSessionGetLink(SmlManager *manager, + SmlSession *session, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, manager, session, error); CHECK_ERROR_REF @@ -1370,8 +1457,8 @@ managerSession *_msession = _manager_session_find(manager, session); if (!_msession) { - smlErrorSet(error, SML_ERROR_GENERIC, - "The session %d is not registered at the manager.", + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "The session %s is not registered at the manager.", smlSessionGetSessionID(session)); goto error; } @@ -1382,7 +1469,7 @@ smlTrace(TRACE_EXIT, "%s - %p", __func__, _msession->link); return _msession->link; error: - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return NULL; } Modified: trunk/libsyncml/sml_manager.h ============================================================================== --- trunk/libsyncml/sml_manager.h Thu Jul 2 16:06:31 2009 (r1143) +++ trunk/libsyncml/sml_manager.h Thu Jul 2 17:00:38 2009 (r1144) @@ -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 @@ -43,41 +43,41 @@ SML_MANAGER_SESSION_ESTABLISHED } SmlManagerEventType; -typedef void (* SmlManagerEventCb) (SmlManager *manager, SmlManagerEventType type, SmlSession *session, SmlError *error, void *userdata); -typedef void (* SmlCommandCb) (SmlSession *session, SmlCommand *cmd, void *userdata); -typedef void (* SmlHeaderCb) (SmlSession *session, SmlHeader *header, SmlCred *cred, void *userdata); -typedef void (* SmlStatusReplyCb) (SmlSession *session, SmlStatus *status, void *userdata); - -SmlManager *smlManagerNew(SmlTransport *tsp, SmlError **error); -void smlManagerFree(SmlManager *manager); -SmlBool smlManagerReceive(SmlManager *manager, SmlError **error); - -void smlManagerSetEventCallback(SmlManager *manager, SmlManagerEventCb callback, void *userdata); -SmlSession *smlManagerSessionFind(SmlManager *manager, const char *sessionID); -SmlBool smlManagerSessionAdd(SmlManager *manager, SmlSession *session, SmlLink *link, SmlError **error); -void smlManagerSessionRemove(SmlManager *manager, SmlSession *session); - -SmlBool smlManagerObjectRegister(SmlManager *manager, SmlCommandType type, SmlSession *session, SmlLocation *location, SmlLocation *source, const char *contentType, SmlCommandCb callback, SmlCommandCb childCallback, void *userdata, SmlError **error); -void smlManagerRegisterHeaderHandler(SmlManager *manager, SmlHeaderCb callback, SmlStatusReplyCb statuscb, void *userdata); - -void smlManagerObjectFree(SmlObject *object); -SmlObject *smlManagerObjectFind(SmlManager *manager, SmlSession *session, SmlCommand *cmd); -SmlBool smlManagerDispatchChildCommand(SmlManager *manager, SmlSession *session, SmlCommand *parent, SmlCommand *cmd, SmlError **error); -SmlBool smlManagerDispatchHeader(SmlManager *manager, SmlSession *session, SmlHeader *header, SmlCred *cred, SmlError **error); -SmlBool smlManagerDispatchCommand(SmlManager *manager, SmlSession *session, SmlCommand *cmd, SmlError **error); - -SmlBool smlManagerStart(SmlManager *manager, SmlError **error); -void smlManagerStop(SmlManager *manager); -void smlManagerRun(SmlManager *manager); -void smlManagerQuit(SmlManager *manager); +typedef void (* SmlManagerEventCb) (SmlManager *manager, SmlManagerEventType type, SmlSession *session, GError *error, void *userdata); +typedef void (* SmlCommandCb) (SmlSession *session, SmlCommand *cmd, void *userdata); +typedef void (* SmlHeaderCb) (SmlSession *session, SmlHeader *header, SmlCred *cred, void *userdata); +typedef void (* SmlStatusReplyCb) (SmlSession *session, SmlStatus *status, void *userdata); + +SmlManager* smlManagerNew (SmlTransport *tsp, GError **error); +void smlManagerFree (SmlManager *manager); +gboolean smlManagerReceive (SmlManager *manager, GError **error); + +void smlManagerSetEventCallback (SmlManager *manager, SmlManagerEventCb callback, void *userdata); +SmlSession* smlManagerSessionFind (SmlManager *manager, const gchar *sessionID); +gboolean smlManagerSessionAdd (SmlManager *manager, SmlSession *session, SmlLink *link, GError **error); +void smlManagerSessionRemove (SmlManager *manager, SmlSession *session); + +gboolean smlManagerObjectRegister (SmlManager *manager, SmlCommandType type, SmlSession *session, SmlLocation *location, SmlLocation *source, const gchar *contentType, SmlCommandCb callback, SmlCommandCb childCallback, void *userdata, GError **error); +void smlManagerRegisterHeaderHandler (SmlManager *manager, SmlHeaderCb callback, SmlStatusReplyCb statuscb, void *userdata); + +void smlManagerObjectFree (SmlObject *object); +SmlObject* smlManagerObjectFind (SmlManager *manager, SmlSession *session, SmlCommand *cmd); +gboolean smlManagerDispatchChildCommand (SmlManager *manager, SmlSession *session, SmlCommand *parent, SmlCommand *cmd, GError **error); +gboolean smlManagerDispatchHeader (SmlManager *manager, SmlSession *session, SmlHeader *header, SmlCred *cred, GError **error); +gboolean smlManagerDispatchCommand (SmlManager *manager, SmlSession *session, SmlCommand *cmd, GError **error); + +gboolean smlManagerStart (SmlManager *manager, GError **error); +void smlManagerStop (SmlManager *manager); +void smlManagerRun (SmlManager *manager); +void smlManagerQuit (SmlManager *manager); -void smlManagerDispatch(SmlManager *manager); -SmlBool smlManagerCheck(SmlManager *manager); +void smlManagerDispatch (SmlManager *manager); +gboolean smlManagerCheck (SmlManager *manager); -void smlManagerSetLocalMaxMsgSize(SmlManager *manager, unsigned int size); -void smlManagerSetLocalMaxObjSize(SmlManager *manager, unsigned int size); +void smlManagerSetLocalMaxMsgSize (SmlManager *manager, gsize size); +void smlManagerSetLocalMaxObjSize (SmlManager *manager, gsize size); -char *smlManagerGetNewSessionID(SmlManager *manager); +gchar* smlManagerGetNewSessionID (SmlManager *manager); #endif //_SML_MANAGER_H Modified: trunk/libsyncml/sml_manager_internals.h ============================================================================== --- trunk/libsyncml/sml_manager_internals.h Thu Jul 2 16:06:31 2009 (r1143) +++ trunk/libsyncml/sml_manager_internals.h Thu Jul 2 17:00:38 2009 (r1144) @@ -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,8 +56,8 @@ SmlQueue *userEventQueue; - unsigned int localMaxMsgSize; - unsigned int localMaxObjSize; + gsize localMaxMsgSize; + gsize localMaxObjSize; }; typedef struct SmlManagerEvent { @@ -65,7 +65,7 @@ SmlSession *session; SmlCommand *command; SmlCommand *parent; - SmlError *error; + GError *error; } SmlManagerEvent; struct SmlObject { @@ -75,16 +75,13 @@ SmlCommandCb commandCallback; SmlCommandCb childCallback; void *commandCallbackUserdata; - char *contentType; + gchar *contentType; }; -void smlManagerSessionFinalLockRef(SmlManager *manager, SmlSession *session); -void smlManagerSessionFinalLockUnref(SmlManager *manager, SmlSession *session); +void smlManagerSessionFinalLockRef (SmlManager *manager, SmlSession *session); +void smlManagerSessionFinalLockUnref (SmlManager *manager, SmlSession *session); -SmlLink *smlManagerSessionGetLink( - SmlManager *manager, - SmlSession *session, - SmlError **error); +SmlLink* smlManagerSessionGetLink (SmlManager *manager, SmlSession *session, GError **error); #endif //_SML_MANAGER_INTERNALS_H Modified: trunk/libsyncml/sml_parse.h ============================================================================== --- trunk/libsyncml/sml_parse.h Thu Jul 2 16:06:31 2009 (r1143) +++ trunk/libsyncml/sml_parse.h Thu Jul 2 17:00:38 2009 (r1144) @@ -89,10 +89,10 @@ SML_ASSEMBLER_RESULT_MISMATCH =2 } SmlAssemblerResult; -SmlParser *smlParserNew(SmlMimeType type, unsigned int limit, SmlError **error); +SmlParser *smlParserNew(SmlMimeType type, unsigned int limit, GError **error); void smlParserFree(SmlParser *parser); -SmlBool smlParserStart(SmlParser *parser, const char *data, unsigned int size, SmlError **error); -SmlBool smlParserGetHeader(SmlParser *parser, SmlHeader **header, SmlCred **cred, SmlError **error); +SmlBool smlParserStart(SmlParser *parser, const char *data, unsigned int size, GError **error); +SmlBool smlParserGetHeader(SmlParser *parser, SmlHeader **header, SmlCred **cred, GError **error); SmlParserResult smlParserGetCommand(SmlParser *parser, SmlCommand **cmd, SmlError **error); SmlBool smlParserGetStatus(SmlParser *parser, SmlStatus **status, SmlError **error); SmlBool smlParserEnd(SmlParser *parser, SmlBool *final, SmlBool *end, SmlError **error); Modified: trunk/libsyncml/sml_queue_internals.h ============================================================================== --- trunk/libsyncml/sml_queue_internals.h Thu Jul 2 16:06:31 2009 (r1143) +++ trunk/libsyncml/sml_queue_internals.h Thu Jul 2 17:00:38 2009 (r1144) @@ -51,7 +51,7 @@ GMutex *mutex; } SmlQueue; -SmlQueue *smlQueueNew(SmlError **error); +SmlQueue *smlQueueNew(GError **error); void smlQueueFree(SmlQueue *queue); void smlQueueFlush(SmlQueue *queue); void smlQueueSetHandler(SmlQueue *queue, SmlQueueHandler handler, void *userdata); Modified: trunk/libsyncml/sml_session.h ============================================================================== --- trunk/libsyncml/sml_session.h Thu Jul 2 16:06:31 2009 (r1143) +++ trunk/libsyncml/sml_session.h Thu Jul 2 17:00:38 2009 (r1144) @@ -40,11 +40,11 @@ SML_SESSION_EVENT_ESTABLISHED } SmlSessionEventType; -typedef void (* SmlSessionEventCallback) (SmlSession *session, SmlSessionEventType type, SmlCommand *command, SmlCommand *parent, SmlStatus *reply, SmlError *error, void *userdata); +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); /* Session Management */ -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 char *sessionID, unsigned int messageID, GError **error); SmlSession *smlSessionRef(SmlSession *session); void smlSessionUnref(SmlSession *session); void smlSessionSetEventCallback(SmlSession *session, SmlSessionEventCallback callback, void *userdata); @@ -80,14 +80,14 @@ void smlSessionRegisterCred(SmlSession *session, SmlCred *cred); /* Session Data input */ -SmlBool smlSessionReceiveHeader(SmlSession *session, SmlHeader *header, SmlError **error); -SmlBool smlSessionReceiveBody(SmlSession *session, SmlParser *parser, SmlError **error); +SmlBool smlSessionReceiveHeader(SmlSession *session, SmlHeader *header, GError **error); +SmlBool 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, SmlError **error); +SmlBool smlSessionSendReply(SmlSession *session, SmlStatus *status, GError **error); SmlBool smlSessionCheck(SmlSession *session); void smlSessionDispatch(SmlSession *session); Modified: trunk/libsyncml/sml_session_internals.h ============================================================================== --- trunk/libsyncml/sml_session_internals.h Thu Jul 2 16:06:31 2009 (r1143) +++ trunk/libsyncml/sml_session_internals.h Thu Jul 2 17:00:38 2009 (r1144) @@ -111,6 +111,6 @@ SmlBool smlSessionSetResponseURI( SmlSession *session, const char *responseURI, - SmlError **error); + GError **error); #endif //_SML_SESSION_INTERNALS_H_ Modified: trunk/libsyncml/sml_transport.h ============================================================================== --- trunk/libsyncml/sml_transport.h Thu Jul 2 16:06:31 2009 (r1143) +++ trunk/libsyncml/sml_transport.h Thu Jul 2 17:00:38 2009 (r1144) @@ -38,7 +38,7 @@ SML_TRANSPORT_CONNECTION_TYPE_USB = 5 } SmlTransportConnectionType; -typedef SmlBool (* SmlTransportEventCb) (SmlTransport *tsp, SmlLink *link, SmlTransportEventType type, SmlTransportData *data, SmlError *error, void *userdata); +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); @@ -50,8 +50,8 @@ 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, SmlError **error); -SmlBool smlTransportSend(SmlTransport *tsp, SmlLink *link, SmlTransportData *data, 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, SmlError **error); SmlTransportData *smlTransportDataRef(SmlTransportData *data); void smlTransportDataDeref(SmlTransportData *data); Modified: trunk/libsyncml/sml_transport_internals.h ============================================================================== --- trunk/libsyncml/sml_transport_internals.h Thu Jul 2 16:06:31 2009 (r1143) +++ trunk/libsyncml/sml_transport_internals.h Thu Jul 2 17:00:38 2009 (r1144) @@ -135,7 +135,7 @@ void smlTransportWorkerHandler(void *message, void *userdata); SmlBool smlTransportReceiveEvent(SmlTransport *tsp, SmlLink *link, SmlTransportEventType type, SmlTransportData *data, SmlError *error); -SmlBool smlTransportSetResponseURI(SmlTransport *tsp, const char *uri, SmlError **error); -char *smlTransportGetResponseURI(SmlLink *link, SmlSession *session, SmlError **error); +SmlBool smlTransportSetResponseURI(SmlTransport *tsp, const char *uri, GError **error); +char *smlTransportGetResponseURI(SmlLink *link, SmlSession *session, GError **error); #endif //_SML_TRANSPORT_INTERNALS_H_ |
From: <svn...@op...> - 2009-07-02 14:15:48
|
Author: bellmich Date: Thu Jul 2 16:06:31 2009 New Revision: 1143 URL: http://libsyncml.opensync.org/changeset/1143 Log: - migrated sml_elements and sml_error from SmlError to GError - fixed some minor issues in sml_command Modified: trunk/libsyncml/CMakeLists.txt trunk/libsyncml/sml_command.c trunk/libsyncml/sml_command.h trunk/libsyncml/sml_command_internals.h trunk/libsyncml/sml_elements.c trunk/libsyncml/sml_elements.h trunk/libsyncml/sml_elements_internals.h trunk/libsyncml/sml_error.h trunk/libsyncml/sml_error_internals.h trunk/libsyncml/sml_parse.c trunk/libsyncml/sml_support.h Modified: trunk/libsyncml/CMakeLists.txt ============================================================================== --- trunk/libsyncml/CMakeLists.txt Thu Jul 2 10:11:46 2009 (r1142) +++ trunk/libsyncml/CMakeLists.txt Thu Jul 2 16:06:31 2009 (r1143) @@ -5,7 +5,6 @@ SET( libsyncml_LIB_SRCS sml_command.c sml_elements.c - sml_error.c sml_manager.c sml_md5.c sml_notification.c @@ -71,10 +70,7 @@ objects/sml_devinf_obj.h objects/sml_ds_server.h objects/sml_auth.h - sml_command.h sml_defines.h - sml_elements.h - sml_error.h sml_manager.h sml_md5.h sml_notification.h Modified: trunk/libsyncml/sml_command.c ============================================================================== --- trunk/libsyncml/sml_command.c Thu Jul 2 10:11:46 2009 (r1142) +++ trunk/libsyncml/sml_command.c Thu Jul 2 16:06:31 2009 (r1143) @@ -30,7 +30,7 @@ #include "parser/sml_xml_assm.h" SmlCommandType -smlCommandTypeFromString (const char *name, +smlCommandTypeFromString (const gchar *name, GError **error) { CHECK_ERROR_REF @@ -98,8 +98,8 @@ SmlStatus* smlStatusNew (SmlErrorType data, - guint cmdref, - guint msgref, + gsize cmdref, + gsize msgref, SmlLocation *sourceref, SmlLocation *targetref, SmlCommandType type, @@ -266,7 +266,7 @@ smlCommandNewResult (SmlCommand *cmd, SmlLocation *source, gchar *data, - guint size, + gsize size, const gchar *contenttype, GError **error) { @@ -396,7 +396,7 @@ smlCommandNewChange (SmlChangeType type, const gchar *uid, const gchar *data, - guint size, + gsize size, const gchar *contenttype, GError **error) { @@ -474,8 +474,8 @@ smlCommandNewPartialChange (SmlChangeType type, const gchar *uid, const gchar *data, - guint complete_size, - guint partial_size, + gsize complete_size, + gsize partial_size, const gchar *contenttype, GError **error) { @@ -597,7 +597,7 @@ SmlCommand* smlCommandNewSync (SmlLocation *target, SmlLocation *source, - guint num_changes, + gsize num_changes, GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %i, %p)", __func__, target, source, num_changes, error); @@ -625,7 +625,7 @@ smlCommandNewPut (SmlLocation *target, SmlLocation *source, const gchar *data, - guint size, + gsize size, const gchar *contenttype, GError **error) { Modified: trunk/libsyncml/sml_command.h ============================================================================== --- trunk/libsyncml/sml_command.h Thu Jul 2 10:11:46 2009 (r1142) +++ trunk/libsyncml/sml_command.h Thu Jul 2 16:06:31 2009 (r1143) @@ -33,33 +33,33 @@ #include <libsyncml/syncml.h> #include <libsyncml/dev_inf_api/sml_dev_inf.h> -SmlStatus *smlStatusNew(SmlErrorType data, unsigned int cmdref, unsigned int msgref, SmlLocation *sourceref, SmlLocation *targeref, SmlCommandType type, GError **error); -SmlStatus *smlStatusRef(SmlStatus *status); -void smlStatusUnref(SmlStatus *status); -SmlErrorType smlStatusGetCode(SmlStatus *status); -SmlErrorClass smlStatusGetClass(SmlStatus *status); -SmlCommand *smlStatusGetResult(SmlStatus *status); -SmlBool smlStatusIsResult(SmlStatus *status); - -SmlCommand *smlCommandNew(SmlCommandType type, GError **error); -SmlStatus *smlCommandNewReply(const SmlCommand *cmd, SmlErrorType code, GError **error); -SmlCommand *smlCommandRef(SmlCommand *cmd); -void smlCommandUnref(SmlCommand *cmd); - -SmlCommand *smlCommandNewAlert(SmlAlertType type, SmlLocation *target, SmlLocation *source, const char *next, const char *last, const char *contenttype, GError **error); -SmlCommand *smlCommandNewSync(SmlLocation *target, SmlLocation *source, unsigned int num_changes, GError **error); -SmlCommand *smlCommandNewChange(SmlChangeType type, const char *uid, const char *data, unsigned int size, const char *contenttype, GError **error); -SmlCommand *smlCommandNewPartialChange(SmlChangeType type, const char *uid, const char *data, unsigned int complete_size, unsigned int partial_size, const char *contenttype, GError **error); -SmlCommand *smlCommandNewResult(SmlCommand *cmd, SmlLocation *source, char *data, unsigned int size, const char *contenttype, GError **error); -SmlCommand *smlCommandNewPut(SmlLocation *target, SmlLocation *source, const char *data, unsigned int size, const char *contenttype, GError **error); -SmlCommand *smlCommandNewGet(SmlLocation *target, const char *contenttype, GError **error); - -SmlCommand *smlCommandNewDevInfResult(SmlCommand *cmd, SmlDevInf *devinf, SmlDevInfVersion version, GError **error); -SmlCommand *smlCommandNewDevInfPut(SmlDevInf *devinf, SmlDevInfVersion version, GError **error); -SmlCommand *smlCommandNewDevInfGet(SmlDevInfVersion version, GError **error); +SmlStatus* smlStatusNew (SmlErrorType data, gsize cmdref, gsize msgref, SmlLocation *sourceref, SmlLocation *targeref, SmlCommandType type, GError **error); +SmlStatus* smlStatusRef (SmlStatus *status); +void smlStatusUnref (SmlStatus *status); +SmlErrorType smlStatusGetCode (SmlStatus *status); +SmlErrorClass smlStatusGetClass (SmlStatus *status); +SmlCommand* smlStatusGetResult (SmlStatus *status); +gboolean smlStatusIsResult (SmlStatus *status); + +SmlCommand* smlCommandNew (SmlCommandType type, GError **error); +SmlStatus* smlCommandNewReply (const SmlCommand *cmd, SmlErrorType code, GError **error); +SmlCommand* smlCommandRef (SmlCommand *cmd); +void smlCommandUnref (SmlCommand *cmd); + +SmlCommand* smlCommandNewAlert (SmlAlertType type, SmlLocation *target, SmlLocation *source, const gchar *next, const gchar *last, const gchar *contenttype, GError **error); +SmlCommand* smlCommandNewSync (SmlLocation *target, SmlLocation *source, gsize num_changes, GError **error); +SmlCommand* smlCommandNewChange (SmlChangeType type, const gchar *uid, const gchar *data, gsize size, const gchar *contenttype, GError **error); +SmlCommand* smlCommandNewPartialChange (SmlChangeType type, const gchar *uid, const gchar *data, gsize complete_size, gsize partial_size, const gchar *contenttype, GError **error); +SmlCommand* smlCommandNewResult (SmlCommand *cmd, SmlLocation *source, gchar *data, gsize size, const gchar *contenttype, GError **error); +SmlCommand* smlCommandNewPut (SmlLocation *target, SmlLocation *source, const gchar *data, gsize size, const gchar *contenttype, GError **error); +SmlCommand* smlCommandNewGet (SmlLocation *target, const gchar *contenttype, GError **error); + +SmlCommand* smlCommandNewDevInfResult (SmlCommand *cmd, SmlDevInf *devinf, SmlDevInfVersion version, GError **error); +SmlCommand* smlCommandNewDevInfPut (SmlDevInf *devinf, SmlDevInfVersion version, GError **error); +SmlCommand* smlCommandNewDevInfGet (SmlDevInfVersion version, GError **error); -SmlCommand *smlCommandNewMap(SmlLocation *target, SmlLocation *source, GError **error); -SmlBool smlCommandAddMapItem(SmlCommand *map, SmlMapItem *item, GError **error); +SmlCommand* smlCommandNewMap (SmlLocation *target, SmlLocation *source, GError **error); +gboolean smlCommandAddMapItem (SmlCommand *map, SmlMapItem *item, GError **error); #endif //_SML_COMMAND_H_ Modified: trunk/libsyncml/sml_command_internals.h ============================================================================== --- trunk/libsyncml/sml_command_internals.h Thu Jul 2 10:11:46 2009 (r1142) +++ trunk/libsyncml/sml_command_internals.h Thu Jul 2 16:06:31 2009 (r1143) @@ -33,18 +33,18 @@ typedef struct SmlCommandAlertPrivate { SmlAlertType type; SmlAnchor *anchor; - char *contentType; - int maxObjSize; + gchar *contentType; + gsize maxObjSize; } SmlCommandAlertPrivate; typedef struct SmlCommandSyncPrivate { - unsigned int numChanged; - int maxObjSize; + gsize numChanged; + gsize maxObjSize; SmlBool hasNumChanged; } SmlCommandSyncPrivate; typedef struct SmlCommandAccessPrivate { - char *type; + gchar *type; SmlItem *item; } SmlCommandAccessPrivate; @@ -73,8 +73,8 @@ struct SmlCommand { gint refCount; SmlCommandType type; - unsigned int cmdID; - unsigned int msgID; + gsize cmdID; + gsize msgID; SmlCommandPrivate private; SmlLocation *source; SmlLocation *target; @@ -83,7 +83,7 @@ SmlCommand *parent; SmlBool noResp; - unsigned int size; + gsize size; /** True if the command has already seen a mismatch * in size. If a second mismatch happens, the command is @@ -93,10 +93,10 @@ struct SmlStatus { gint refCount; - unsigned int msgRef; - unsigned int cmdRef; + gsize msgRef; + gsize cmdRef; SmlCommandType type; - char *data; + gchar *data; SmlAnchor *anchor; SmlLocation *sourceRef; SmlLocation *targetRef; @@ -107,10 +107,10 @@ SmlCommand *result; }; -SmlCommandType smlCommandTypeFromString(const char *name, GError **error); -const char *smlCommandTypeToString(SmlCommandType type, GError **error); +SmlCommandType smlCommandTypeFromString(const gchar *name, GError **error); +G_CONST_RETURN gchar *smlCommandTypeToString(SmlCommandType type, GError **error); -SmlAlertType smlAlertTypeConvert(unsigned int id, GError **error); +SmlAlertType smlAlertTypeConvert(guint id, GError **error); #endif //_SML_COMMAND_INTERNALS_H_ Modified: trunk/libsyncml/sml_elements.c ============================================================================== --- trunk/libsyncml/sml_elements.c Thu Jul 2 10:11:46 2009 (r1142) +++ trunk/libsyncml/sml_elements.c Thu Jul 2 16:06:31 2009 (r1143) @@ -28,7 +28,10 @@ #include "sml_error_internals.h" #include "data_sync_api/sml_location_internals.h" -SmlAnchor *smlAnchorNew(const char *last, const char *next, SmlError **error) +SmlAnchor* +smlAnchorNew (const gchar *last, + const gchar *next, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%s, %s, %p)", __func__, VA_STRING(last), VA_STRING(next), error); CHECK_ERROR_REF @@ -42,13 +45,13 @@ smlTrace(TRACE_EXIT, "%s: %p", __func__, anchor); return anchor; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -void smlAnchorFree(SmlAnchor *anchor) +void +smlAnchorFree (SmlAnchor *anchor) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, anchor); smlAssert(anchor); @@ -63,7 +66,8 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -void smlHeaderFree(SmlHeader *header) +void +smlHeaderFree (SmlHeader *header) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, header); @@ -87,7 +91,9 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -SmlItem *smlItemNew(unsigned int size, SmlError **error) +SmlItem* +smlItemNew (gsize size, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%i, %p)", __func__, size, error); CHECK_ERROR_REF @@ -101,14 +107,16 @@ smlTrace(TRACE_EXIT, "%s: %p", __func__, item); return item; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } /* If data is NULL, this call is the same if smlItemNew */ -SmlItem *smlItemNewForData(const char *data, unsigned int size, SmlError **error) +SmlItem* +smlItemNewForData (const gchar *data, + gsize size, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, data, size, error); CHECK_ERROR_REF @@ -119,20 +127,20 @@ if (data) { if (!smlItemAddData(item, data, size, error)) - goto error_free_item; + goto error; } smlTrace(TRACE_EXIT, "%s: %p", __func__, item); return item; - -error_free_item: - smlItemUnref(item); error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + if (item) + smlItemUnref(item); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -SmlItem *smlItemRef(SmlItem *item) +SmlItem* +smlItemRef (SmlItem *item) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, item); smlAssert(item); @@ -143,7 +151,8 @@ return item; } -void smlItemUnref(SmlItem *item) +void +smlItemUnref(SmlItem *item) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, item); smlAssert(item); @@ -172,13 +181,17 @@ smlTrace(TRACE_EXIT, "%s: %i", __func__, item ? item->refCount : 0); } -SmlBool smlItemAddData(SmlItem *item, const char *data, unsigned int size, SmlError **error) +gboolean +smlItemAddData (SmlItem *item, + const gchar *data, + gsize size, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %i, %p)", __func__, item, data, size, error); CHECK_ERROR_REF if (item->size && xmlBufferLength(item->buffer) + size > item->size) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to add data. size limit reached"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to add data. size limit reached"); goto error; } @@ -191,22 +204,22 @@ } if (xmlBufferAdd(item->buffer, (xmlChar *)data, size) != 0) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to add data."); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to add data."); 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; } /** Checks if the item is complete */ -SmlBool smlItemCheck(SmlItem *item) +gboolean +smlItemCheck (SmlItem *item) { smlAssert(xmlBufferLength(item->buffer) >= 0); smlAssert(item); @@ -224,7 +237,8 @@ return TRUE; } -SmlBool smlItemHasData(SmlItem *item) +gboolean +smlItemHasData (SmlItem *item) { smlAssert(item); return item->buffer ? TRUE : FALSE; @@ -232,14 +246,18 @@ /** Returns the data of the item. The data will not be freed when the item is unrefd. After * this call, smlItemHasData will report FALSE */ -SmlBool smlItemStealData(SmlItem *item, char **data, unsigned int *size, SmlError **error) +gboolean +smlItemStealData (SmlItem *item, + gchar **data, + gsize *size, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, item, data, size, error); CHECK_ERROR_REF smlAssert(size); if (!smlItemCheck(item)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Item check failed"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Item check failed"); goto error; } @@ -250,20 +268,23 @@ 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; } /** Returns a const pointer to the data of the item. the data will disappear when the data is derefd */ -SmlBool smlItemGetData(SmlItem *item, char **data, unsigned int *size, SmlError **error) +gboolean +smlItemGetData (SmlItem *item, + gchar **data, + gsize *size, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, item, data, size, error); CHECK_ERROR_REF if (!smlItemCheck(item)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Item check failed"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Item check failed"); goto error; } @@ -272,13 +293,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 smlItemSetSource(SmlItem *item, SmlLocation *source) +void +smlItemSetSource (SmlItem *item, + SmlLocation *source) { smlAssert(item); smlAssert(source); @@ -287,14 +309,17 @@ g_object_ref(source); } -SmlLocation *smlItemGetSource(SmlItem *item) +SmlLocation* +smlItemGetSource (SmlItem *item) { smlAssert(item); return item->source; } -void smlItemSetTarget(SmlItem *item, SmlLocation *target) +void +smlItemSetTarget (SmlItem *item, + SmlLocation *target) { smlAssert(item); smlAssert(target); @@ -303,24 +328,28 @@ g_object_ref(target); } -SmlLocation *smlItemGetTarget(SmlItem *item) +SmlLocation* +smlItemGetTarget (SmlItem *item) { smlAssert(item); return item->target; } -void smlItemSetRaw(SmlItem *item, SmlBool raw) +void +smlItemSetRaw (SmlItem *item, + gboolean raw) { smlAssert(item); item->raw = raw; } -SmlCred *smlCredNewFromString(const char *type, - const char *format, - const char *data, - SmlError **error) +SmlCred* +smlCredNewFromString (const gchar *type, + const gchar *format, + const gchar *data, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%s, %s, %s, %p)", __func__, VA_STRING(data), VA_STRING(type), VA_STRING(format), error); CHECK_ERROR_REF @@ -333,33 +362,34 @@ } else if (!strcmp(type, SML_AUTH_MD5)) { smlType = SML_AUTH_TYPE_MD5; } else { - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown type - %s.", type); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown type - %s.", type); goto error; } if (!format || !strcmp(format, SML_BASE64)) { smlFormat = SML_FORMAT_TYPE_BASE64; } else { - smlErrorSet(error, SML_ERROR_GENERIC, "SyncML credential: Unknown format - %s.", format); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "SyncML credential: Unknown format - %s.", format); goto error; } if (!data) { - smlErrorSet(error, SML_ERROR_GENERIC, "Data is missing in %s.", __func__); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Data is missing in %s.", __func__); goto error; } smlTrace(TRACE_EXIT, "%s", __func__); return smlCredNew(smlType, smlFormat, data, NULL, error); error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -SmlCred *smlCredNewAuth(SmlAuthType type, - const char *username, - const char *password, - SmlError **error) +SmlCred* +smlCredNewAuth (SmlAuthType type, + const gchar *username, + const gchar *password, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%d, %s, %p)", __func__, type, VA_STRING(username), error); CHECK_ERROR_REF @@ -367,12 +397,12 @@ SmlCred *cred = NULL; if (username == NULL || !strlen(username)) { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "If authentication should be used then the username must be set."); goto error; } if (password == NULL || !strlen(password)) { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "If authentication should be used then the password must be set."); goto error; } @@ -392,15 +422,16 @@ error: if (cred) smlSafeFree((gpointer *)&cred); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -SmlCred *smlCredNew(SmlAuthType type, - SmlFormatType format, - const char *data, - const char *username, - SmlError **error) +SmlCred* +smlCredNew (SmlAuthType type, + SmlFormatType format, + const gchar *data, + const gchar *username, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%s, %d, %d, %p)", __func__, VA_STRING(data), type, format, error); CHECK_ERROR_REF @@ -427,11 +458,12 @@ smlSafeCFree(&(cred->username)); if (cred) smlSafeFree((gpointer *)&cred); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -void smlCredRef(SmlCred *cred) +void +smlCredRef (SmlCred *cred) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, cred); smlAssert(cred); @@ -441,7 +473,8 @@ smlTrace(TRACE_EXIT, "%s: New refcount: %i", __func__, cred->refCount); } -void smlCredUnref(SmlCred *cred) +void +smlCredUnref (SmlCred *cred) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, cred); smlAssert(cred); @@ -462,13 +495,9 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -/* FIXME: DEPRECATED */ -void smlCredFree(SmlCred *cred) -{ - smlCredUnref(cred); -} - -SmlChal *smlChalNew(SmlAuthType type, SmlError **error) +SmlChal* +smlChalNew (SmlAuthType type, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%u, %p)", __func__, type, error); CHECK_ERROR_REF @@ -496,7 +525,7 @@ (const unsigned char *) chal->nonce_plain, chal->nonce_length); if (!chal->nonce_b64) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The nonce of the challenge cannot be base64 encoded."); goto error; } @@ -511,15 +540,15 @@ smlSafeCFree(&(chal->nonce_b64)); if (chal) smlSafeFree((gpointer *)&chal); - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return NULL; } -SmlChal *smlChalNewFromBinary( - SmlAuthType type, - const char *nonce, - size_t length, - SmlError **error) +SmlChal* +smlChalNewFromBinary(SmlAuthType type, + const gchar *nonce, + gsize length, + GError **error) { smlTrace(TRACE_ENTRY, "%s", __func__); CHECK_ERROR_REF @@ -543,7 +572,7 @@ /* create base64 nonce */ chal->nonce_b64 = g_base64_encode((const unsigned char *) nonce, length); if (!chal->nonce_b64) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The base64 encoding of the nonce failed."); goto error; } @@ -551,14 +580,14 @@ smlTrace(TRACE_EXIT, "%s", __func__); return chal; error: - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return NULL; } -SmlChal *smlChalNewFromBase64( - SmlAuthType type, - const char *nonce, - SmlError **error) +SmlChal* +smlChalNewFromBase64 (SmlAuthType type, + const gchar *nonce, + GError **error) { smlTrace(TRACE_ENTRY, "%s", __func__); CHECK_ERROR_REF @@ -582,7 +611,7 @@ size_t length = 0; chal->nonce_plain = (char *) g_base64_decode(nonce, &length); if (!chal->nonce_plain || length < 1) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The base64 encoded nonce cannot be decoded."); goto error; } @@ -591,11 +620,12 @@ smlTrace(TRACE_EXIT, "%s", __func__); return chal; error: - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return NULL; } -void smlChalRef(SmlChal *chal) +void +smlChalRef (SmlChal *chal) { smlTrace(TRACE_ENTRY, "%s", __func__); smlAssert(chal); @@ -605,7 +635,8 @@ smlTrace(TRACE_EXIT, "%s: New refcount: %i", __func__, chal->refCount); } -void smlChalUnref(SmlChal *chal) +void +smlChalUnref (SmlChal *chal) { smlTrace(TRACE_ENTRY, "%s", __func__); smlAssert(chal); @@ -625,30 +656,26 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -/* FIXME: DEPRECATED */ -void smlChalFree(SmlChal *chal) -{ - smlChalUnref(chal); -} - -SmlMapItem *smlMapItemNew(const char *uid, const char *newuid, SmlError **error) +SmlMapItem* +smlMapItemNew (const gchar *uid, + const gchar *newuid, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%s, %s, %p)", __func__, VA_STRING(uid), VA_STRING(newuid), error); CHECK_ERROR_REF smlAssert(uid); smlAssert(newuid); - GError *gerror = NULL; SmlMapItem *item = smlTryMalloc0(sizeof(SmlMapItem), error); if (!item) goto error; item->refCount = 1; - item->source = sml_location_new_with_options(newuid, NULL, &gerror); + item->source = sml_location_new_with_options(newuid, NULL, error); if (!item->source) goto error; - item->target = sml_location_new_with_options(uid, NULL, &gerror); + item->target = sml_location_new_with_options(uid, NULL, error); if (!item->target) goto error; @@ -661,15 +688,12 @@ g_object_unref(item->source); smlSafeFree((gpointer *)&item); } - if (gerror) { - smlErrorSet(error, gerror->code, "%s", gerror->message); - g_error_free(gerror); - } - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -SmlMapItem *smlMapItemRef(SmlMapItem *item) +SmlMapItem* +smlMapItemRef (SmlMapItem *item) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, item); smlAssert(item); @@ -680,7 +704,8 @@ return item; } -void smlMapItemUnref(SmlMapItem *item) +void +smlMapItemUnref (SmlMapItem *item) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, item); smlAssert(item); Modified: trunk/libsyncml/sml_elements.h ============================================================================== --- trunk/libsyncml/sml_elements.h Thu Jul 2 10:11:46 2009 (r1142) +++ trunk/libsyncml/sml_elements.h Thu Jul 2 16:06:31 2009 (r1143) @@ -30,42 +30,42 @@ #ifndef _SML_ELEMENTS_H_ #define _SML_ELEMENTS_H_ -SmlCred *smlCredNewFromString(const char *type, const char *format, const char *data, GError **error); -SmlCred *smlCredNewAuth(SmlAuthType type, const char *username, const char *password, GError **error); -SmlCred *smlCredNew(SmlAuthType type, SmlFormatType format, const char *data, const char*username, GError **error); -void smlCredRef(SmlCred *cred); -void smlCredUnref(SmlCred *cred); - -SmlAnchor *smlAnchorNew(const char *last, const char *next, GError **error); -void smlAnchorFree(SmlAnchor *anchor); - -SmlItem *smlItemNew(unsigned int size, GError **error); -SmlItem *smlItemNewForData(const char *data, unsigned int size, GError **error); -SmlItem *smlItemRef(SmlItem *item); -void smlItemUnref(SmlItem *item); -SmlBool smlItemAddData(SmlItem *item, const char *data, unsigned int size, GError **error); -SmlBool smlItemCheck(SmlItem *item); -SmlBool smlItemHasData(SmlItem *item); -SmlBool smlItemGetData(SmlItem *item, char **data, unsigned int *size, GError **error); -SmlBool smlItemStealData(SmlItem *item, char **data, unsigned int *size, GError **error); - -void smlItemSetSource(SmlItem *item, SmlLocation *source); -SmlLocation *smlItemGetSource(SmlItem *item); -void smlItemSetTarget(SmlItem *item, SmlLocation *target); -SmlLocation *smlItemGetTarget(SmlItem *item); -void smlItemSetRaw(SmlItem *item, SmlBool raw); +SmlCred* smlCredNewFromString (const gchar *type, const gchar *format, const gchar *data, GError **error); +SmlCred* smlCredNewAuth (SmlAuthType type, const gchar *username, const gchar *password, GError **error); +SmlCred* smlCredNew (SmlAuthType type, SmlFormatType format, const gchar *data, const gchar *username, GError **error); +void smlCredRef (SmlCred *cred); +void smlCredUnref (SmlCred *cred); + +SmlAnchor* smlAnchorNew (const gchar *last, const gchar *next, GError **error); +void smlAnchorFree (SmlAnchor *anchor); + +SmlItem* smlItemNew (gsize size, GError **error); +SmlItem* smlItemNewForData (const gchar *data, gsize size, GError **error); +SmlItem* smlItemRef (SmlItem *item); +void smlItemUnref (SmlItem *item); +gboolean smlItemAddData (SmlItem *item, const gchar *data, gsize size, GError **error); +gboolean smlItemCheck (SmlItem *item); +gboolean smlItemHasData (SmlItem *item); +gboolean smlItemGetData (SmlItem *item, gchar **data, gsize *size, GError **error); +gboolean smlItemStealData (SmlItem *item, gchar **data, gsize *size, GError **error); + +void smlItemSetSource (SmlItem *item, SmlLocation *source); +SmlLocation* smlItemGetSource (SmlItem *item); +void smlItemSetTarget (SmlItem *item, SmlLocation *target); +SmlLocation* smlItemGetTarget (SmlItem *item); +void smlItemSetRaw (SmlItem *item, gboolean raw); void smlHeaderFree(SmlHeader *header); -SmlChal *smlChalNew(SmlAuthType type, GError **error); -SmlChal *smlChalNewFromBinary(SmlAuthType type, const char *nonce, size_t length, GError **error); -SmlChal *smlChalNewFromBase64(SmlAuthType type, const char *nonce, GError **error); -void smlChalRef(SmlChal *chal); -void smlChalUnref(SmlChal *chal); - -SmlMapItem *smlMapItemNew(const char *uid, const char *newuid, GError **error); -SmlMapItem *smlMapItemRef(SmlMapItem *item); -void smlMapItemUnref(SmlMapItem *item); +SmlChal* smlChalNew (SmlAuthType type, GError **error); +SmlChal* smlChalNewFromBinary (SmlAuthType type, const gchar *nonce, gsize length, GError **error); +SmlChal* smlChalNewFromBase64 (SmlAuthType type, const gchar *nonce, GError **error); +void smlChalRef (SmlChal *chal); +void smlChalUnref (SmlChal *chal); + +SmlMapItem* smlMapItemNew (const gchar *uid, const gchar *newuid, GError **error); +SmlMapItem* smlMapItemRef (SmlMapItem *item); +void smlMapItemUnref (SmlMapItem *item); #endif //_SML_ELEMENTS_H_ Modified: trunk/libsyncml/sml_elements_internals.h ============================================================================== --- trunk/libsyncml/sml_elements_internals.h Thu Jul 2 10:11:46 2009 (r1142) +++ trunk/libsyncml/sml_elements_internals.h Thu Jul 2 16:06:31 2009 (r1143) @@ -33,8 +33,8 @@ #include <libxml/xmlreader.h> struct SmlAnchor { - char *next; - char *last; + gchar *next; + gchar *last; }; struct SmlItem { @@ -46,9 +46,9 @@ xmlBuffer *buffer; - unsigned int size; + gsize size; - char *contenttype; + gchar *contenttype; SmlBool moreData; SmlBool disabled; @@ -63,34 +63,34 @@ }; struct SmlHeader { - char *sessionID; + gchar *sessionID; SmlProtocolVersion version; SmlProtocolType protocol; SmlLocation *source; SmlLocation *target; - char *responseURI; + gchar *responseURI; SmlBool noResponse; - unsigned int messageID; - unsigned int maxmsgsize; - unsigned int maxobjsize; - char *emi; + guint messageID; + guint maxmsgsize; + guint maxobjsize; + gchar *emi; }; struct SmlCred { SmlFormatType format; SmlAuthType type; - char *data; + gchar *data; gint refCount; - char *username; - char *password; + gchar *username; + gchar *password; }; struct SmlChal { SmlFormatType format; SmlAuthType type; - char *nonce_plain; - unsigned int nonce_length; - char *nonce_b64; + gchar *nonce_plain; + guint nonce_length; + gchar *nonce_b64; gint refCount; }; Modified: trunk/libsyncml/sml_error.h ============================================================================== --- trunk/libsyncml/sml_error.h Thu Jul 2 10:11:46 2009 (r1142) +++ trunk/libsyncml/sml_error.h Thu Jul 2 16:06:31 2009 (r1143) @@ -113,15 +113,4 @@ } SmlErrorType; -SmlError **smlErrorRef(SmlError **error); -void smlErrorDeref(SmlError **error); -SmlBool smlErrorIsSet(SmlError **error); -void smlErrorSet(SmlError **error, SmlErrorType type, const char *format, ...); -void smlErrorUpdate(SmlError **error, const char *format, ...); -void smlErrorDuplicate(SmlError **target, SmlError **source); -const char *smlErrorPrint(SmlError **error); -SmlErrorType smlErrorGetType(SmlError **error); -void smlErrorSetType(SmlError **error, SmlErrorType type); -SmlErrorClass smlErrorGetClass(SmlError **error); - #endif //_SML_ERROR_H_ Modified: trunk/libsyncml/sml_error_internals.h ============================================================================== --- trunk/libsyncml/sml_error_internals.h Thu Jul 2 10:11:46 2009 (r1142) +++ trunk/libsyncml/sml_error_internals.h Thu Jul 2 16:06:31 2009 (r1143) @@ -24,24 +24,9 @@ #include "syncml_internals.h" -/*! @brief Represent an error - */ -struct SmlError { - /** The type of the error that occured */ - SmlErrorType type; - /** The message */ - char *message; - /** The printed message */ - char *printMessage; - /** The reference counter */ - gint32 refCount; -}; - -void smlErrorSetVargs(SmlError **error, SmlErrorType type, const char *format, va_list args); - #define CHECK_ERROR_REF \ - smlAssertMsg(error, SML_ASSERT_MSG_ERROR_MUST_NOT_BE_NULL); \ - smlAssertMsg(*error == NULL, SML_ASSERT_MSG_ERROR_MUST_BE_EMPTY); + smlAssertMsg(error, "The error handling of the function must be used."); \ + smlAssertMsg(*error == NULL, "The error parameter is already filled (ignored error)."); #define SML_ERROR g_quark_from_static_string("Sml") @@ -53,20 +38,6 @@ *d_error = NULL; \ } -#define GERROR_TO_SML_ERROR(gerror, error) \ - if (gerror) { \ - smlErrorSet(error, gerror->code, "%s", gerror->message); \ - g_error_free(gerror); \ - gerror = NULL; \ - } - -/* Error messages for assertions */ -#define SML_ASSERT_MSG_ERROR_MUST_NOT_BE_NULL "The error handling of the function must be used." -#define SML_ASSERT_MSG_ERROR_MUST_BE_EMPTY "The error parameter is already filled (ignored error)." -#define SML_ASSERT_MSG_ERROR_MUST_BE_AVAILABLE "If this function is used then there must be an error." -#define SML_ASSERT_MSG_ERROR_MUST_BE_FILLED "If this function is used then the error message must be present." -#define SML_ASSERT_MSG_SAN_PARSE_REQUIRES_MANAGER "If an OMA DS 1.2 SAN must be parsed then the manager must be present." - #endif //_SML_ERROR_INTERNALS_H_ /*@}*/ Modified: trunk/libsyncml/sml_parse.c ============================================================================== --- trunk/libsyncml/sml_parse.c Thu Jul 2 10:11:46 2009 (r1142) +++ trunk/libsyncml/sml_parse.c Thu Jul 2 16:06:31 2009 (r1143) @@ -140,7 +140,7 @@ smlAssert(size); smlAssert(parser->functions.start); smlAssertMsg(parser->type != SML_MIMETYPE_SAN || parser->manager, - SML_ASSERT_MSG_SAN_PARSE_REQUIRES_MANAGER); + "If an OMA DS 1.2 SAN must be parsed then the manager must be present."); if (parser->limit && size > parser->limit) { smlErrorSet(error, SML_ERROR_GENERIC, "Input data too large"); Modified: trunk/libsyncml/sml_support.h ============================================================================== --- trunk/libsyncml/sml_support.h Thu Jul 2 10:11:46 2009 (r1142) +++ trunk/libsyncml/sml_support.h Thu Jul 2 16:06:31 2009 (r1143) @@ -42,12 +42,12 @@ */ #define VA_STRING(param) param?param:"NULL" -void smlLog(const char *logname, const char *data, unsigned int size); -void smlTrace(SmlTraceType type, const char *message, ...); -char *smlPrintBinary(const char *data, int len); -char *smlPrintHex(const char *data, int len); -char *smlRandStr(int maxlength, SmlBool exact); -void *smlTryMalloc0(long n_bytes, GError **error); +void smlLog (const gchar *logname, const gchar *data, gsize size); +void smlTrace (SmlTraceType type, const gchar *message, ...); +gchar* smlPrintBinary (const gchar *data, gsize len); +gchar* smlPrintHex (const gchar *data, gsize len); +gchar* smlRandStr (gsize maxlength, gboolean exact); +void* smlTryMalloc0 (gsize n_bytes, GError **error); typedef struct SmlThread { GThread *thread; @@ -58,22 +58,22 @@ GMainLoop *loop; } SmlThread; -SmlThread *smlThreadNew(GMainContext *context, SmlError **error); -void smlThreadFree(SmlThread *thread); -void smlThreadStart(SmlThread *thread); -void smlThreadStop(SmlThread *thread); +SmlThread* smlThreadNew (GMainContext *context, GError **error); +void smlThreadFree (SmlThread *thread); +void smlThreadStart (SmlThread *thread); +void smlThreadStop (SmlThread *thread); typedef SmlBool (* SmlThreadCallFunctionType) ( gpointer data, - SmlError **error); + GError **error); SmlBool smlThreadCallFunction( SmlThread *thread, SmlThreadCallFunctionType func, gpointer data, - SmlError **error); + GError **error); -void smlSafeFree(gpointer *address); -void smlSafeCFree(char **address); +void smlSafeFree (gpointer *address); +void smlSafeCFree (char **address); #endif //_SML_SUPPORT_H_ |
From: <svn...@op...> - 2009-07-02 08:12:35
|
Author: bellmich Date: Thu Jul 2 10:11:46 2009 New Revision: 1142 URL: http://libsyncml.opensync.org/changeset/1142 Log: migrated sml_command.c from SmlError to GError Modified: trunk/libsyncml/parser/sml_xml_assm.h trunk/libsyncml/parser/sml_xml_parse.h trunk/libsyncml/sml_command.c trunk/libsyncml/sml_command.h trunk/libsyncml/sml_command_internals.h trunk/libsyncml/sml_elements.h trunk/libsyncml/sml_support.h Modified: trunk/libsyncml/parser/sml_xml_assm.h ============================================================================== --- trunk/libsyncml/parser/sml_xml_assm.h Wed Jul 1 17:17:17 2009 (r1141) +++ trunk/libsyncml/parser/sml_xml_assm.h Thu Jul 2 10:11:46 2009 (r1142) @@ -46,7 +46,7 @@ SmlBool smlXmlAssemblerRun(SmlXmlAssembler *assm, char **data, unsigned int *size, SmlBool *end, SmlBool final, unsigned int maxsize, SmlError **error); SmlBool smlXmlAssemblerRunFull(SmlXmlAssembler *assm, char **data, unsigned int *size, SmlBool *end, SmlBool final, SmlBool check, unsigned int maxsize, SmlError **error); -SmlBool smlXmlDevInfAssemble(SmlDevInf *devinf, SmlDevInfVersion version, char **data, unsigned int *size, SmlError **error); +SmlBool smlXmlDevInfAssemble(SmlDevInf *devinf, SmlDevInfVersion version, char **data, unsigned int *size, GError **error); /* This is necessary if the first message results in an error 407. * This error means authentication required. Modified: trunk/libsyncml/parser/sml_xml_parse.h ============================================================================== --- trunk/libsyncml/parser/sml_xml_parse.h Wed Jul 1 17:17:17 2009 (r1141) +++ trunk/libsyncml/parser/sml_xml_parse.h Thu Jul 2 10:11:46 2009 (r1142) @@ -52,7 +52,7 @@ SmlBool smlXmlParserGetStatus(SmlXmlParser *parser, SmlStatus **status, SmlError **error); SmlParserResult smlXmlParserGetCommand(SmlXmlParser *parser, SmlCommand **cmd, SmlError **error); -SmlDevInf *smlXmlDevInfParse(const char *data, unsigned int size, SmlError **error); +SmlDevInf *smlXmlDevInfParse(const char *data, unsigned int size, GError **error); #endif //_SML_XML_PARSE_H_ /*@}*/ Modified: trunk/libsyncml/sml_command.c ============================================================================== --- trunk/libsyncml/sml_command.c Wed Jul 1 17:17:17 2009 (r1141) +++ trunk/libsyncml/sml_command.c Thu Jul 2 10:11:46 2009 (r1142) @@ -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 @@ -29,7 +29,9 @@ #include "sml_error_internals.h" #include "parser/sml_xml_assm.h" -SmlCommandType smlCommandTypeFromString(const char *name, SmlError **error) +SmlCommandType +smlCommandTypeFromString (const char *name, + GError **error) { CHECK_ERROR_REF if (!name) @@ -57,11 +59,13 @@ return SML_COMMAND_TYPE_GET; } - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown command name \"%s\"", name); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown command name \"%s\"", name); return SML_COMMAND_TYPE_UNKNOWN; } -const char *smlCommandTypeToString(SmlCommandType type, SmlError **error) +G_CONST_RETURN gchar* +smlCommandTypeToString (SmlCommandType type, + GError **error) { CHECK_ERROR_REF switch (type) { @@ -86,14 +90,20 @@ case SML_COMMAND_TYPE_RESULTS: return SML_ELEMENT_RESULTS; default: - ; + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown command type \"%i\"", type); + return NULL; } - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown command type \"%i\"", type); - return NULL; } -SmlStatus *smlStatusNew(SmlErrorType data, unsigned int cmdref, unsigned int msgref, SmlLocation *sourceref, SmlLocation *targetref, SmlCommandType type, SmlError **error) +SmlStatus* +smlStatusNew (SmlErrorType data, + guint cmdref, + guint msgref, + SmlLocation *sourceref, + SmlLocation *targetref, + SmlCommandType type, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%i, %i, %i, %p, %p, %i, %p)", __func__, data, cmdref, msgref, sourceref, targetref, type, error); CHECK_ERROR_REF @@ -120,13 +130,13 @@ smlTrace(TRACE_EXIT, "%s: %p", __func__, status); return status; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -SmlStatus *smlStatusRef(SmlStatus *status) +SmlStatus* +smlStatusRef (SmlStatus *status) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, status); smlAssert(status); @@ -137,7 +147,8 @@ return status; } -void smlStatusUnref(SmlStatus *status) +void +smlStatusUnref (SmlStatus *status) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, status); smlAssert(status); @@ -166,33 +177,39 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -SmlErrorType smlStatusGetCode(SmlStatus *status) +SmlErrorType +smlStatusGetCode (SmlStatus *status) { smlAssert(status); smlAssert(status->data); return atoi(status->data); } -SmlErrorClass smlStatusGetClass(SmlStatus *status) +SmlErrorClass +smlStatusGetClass (SmlStatus *status) { smlAssert(status); smlAssert(status->data); return (atoi(status->data) / 100); } -SmlCommand *smlStatusGetResult(SmlStatus *status) +SmlCommand* +smlStatusGetResult (SmlStatus *status) { if (status->type == SML_COMMAND_TYPE_RESULTS) return status->result; return NULL; } -SmlBool smlStatusIsResult(SmlStatus *status) +SmlBool +smlStatusIsResult (SmlStatus *status) { return status->type == SML_COMMAND_TYPE_RESULTS ? TRUE : FALSE; } -SmlCommand *smlCommandNew(SmlCommandType type, SmlError **error) +SmlCommand* +smlCommandNew (SmlCommandType type, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%i, %p)", __func__, type, error); CHECK_ERROR_REF @@ -208,11 +225,14 @@ return cmd; error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -SmlStatus *smlCommandNewReply(const SmlCommand *cmd, SmlErrorType code, SmlError **error) +SmlStatus* +smlCommandNewReply (const SmlCommand *cmd, + SmlErrorType code, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, cmd, code, error); CHECK_ERROR_REF @@ -238,16 +258,21 @@ return reply; error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -SmlCommand *smlCommandNewResult(SmlCommand *cmd, SmlLocation *source, char *data, unsigned int size, const char *contenttype, SmlError **error) +SmlCommand* +smlCommandNewResult (SmlCommand *cmd, + SmlLocation *source, + gchar *data, + guint size, + const gchar *contenttype, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %i, %s, %p)", __func__, cmd, source, data, size, VA_STRING(contenttype), error); CHECK_ERROR_REF smlAssert(cmd); - GError *gerror = NULL; SmlCommand *result = smlCommandNew(SML_COMMAND_TYPE_RESULTS, error); if (!result) @@ -263,7 +288,7 @@ goto error; result->private.results.status->item->contenttype = g_strdup(contenttype); - result->private.results.status->item->source = sml_location_clone(source, &gerror); + result->private.results.status->item->source = sml_location_clone(source, error); if (!result->private.results.status->item->source) goto error; @@ -272,21 +297,17 @@ smlTrace(TRACE_EXIT, "%s: %p", __func__, result); return result; - error: - if (gerror) { - smlErrorSet(error, gerror->code, "%s", gerror->message); - g_error_free(gerror); - } if (cmd) smlCommandUnref(result); if (data) smlSafeCFree(&data); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -SmlCommand *smlCommandRef(SmlCommand *cmd) +SmlCommand* +smlCommandRef (SmlCommand *cmd) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, cmd); smlAssert(cmd); @@ -297,7 +318,8 @@ return cmd; } -void smlCommandUnref(SmlCommand *cmd) +void +smlCommandUnref (SmlCommand *cmd) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, cmd); smlAssert(cmd); @@ -370,11 +392,16 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -SmlCommand *smlCommandNewChange(SmlChangeType type, const char *uid, const char *data, unsigned int size, const char *contenttype, SmlError **error) +SmlCommand* +smlCommandNewChange (SmlChangeType type, + const gchar *uid, + const gchar *data, + guint size, + const gchar *contenttype, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%i, %s, %p, %i, %s, %p)", __func__, type, VA_STRING(uid), data, size, VA_STRING(contenttype), error); CHECK_ERROR_REF - GError *gerror = NULL; SmlCommand *cmd = NULL; switch (type) { @@ -388,7 +415,7 @@ cmd = smlCommandNew(SML_COMMAND_TYPE_DELETE, error); break; default: - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown changetype"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown changetype"); } if (!cmd) goto error; @@ -405,10 +432,10 @@ SmlLocation *loc = sml_location_new(); if (!loc) { - g_set_error(&gerror, SML_ERROR, SML_ERROR_GENERIC, "Cannot create new SmlLocation object - out of memory."); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Cannot create new SmlLocation object - out of memory."); goto error; } - if (!sml_location_set_uri(loc, uid, &gerror)) + if (!sml_location_set_uri(loc, uid, error)) goto error; /* The usage of target and source depends on the role of the @@ -432,13 +459,9 @@ return cmd; error: - if (gerror) { - smlErrorSet(error, gerror->code, "%s", gerror->message); - g_error_free(gerror); - } if (cmd) smlCommandUnref(cmd); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } @@ -447,11 +470,17 @@ * @param complete_size The overall size of the object. must be the sum over all partial_sizes * @param partial_size The size of this part. */ -SmlCommand *smlCommandNewPartialChange(SmlChangeType type, const char *uid, const char *data, unsigned int complete_size, unsigned int partial_size, const char *contenttype, SmlError **error) +SmlCommand* +smlCommandNewPartialChange (SmlChangeType type, + const gchar *uid, + const gchar *data, + guint complete_size, + guint partial_size, + const gchar *contenttype, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%i, %s, %p, %i, %i, %s, %p)", __func__, type, VA_STRING(uid), data, complete_size, partial_size, VA_STRING(contenttype), error); CHECK_ERROR_REF - GError *gerror = NULL; SmlCommand *cmd = NULL; switch (type) { @@ -465,7 +494,7 @@ cmd = smlCommandNew(SML_COMMAND_TYPE_DELETE, error); break; default: - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown changetype"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown changetype"); } if (!cmd) goto error; @@ -483,10 +512,10 @@ SmlLocation *loc = sml_location_new(); if (!loc) { - g_set_error(&gerror, SML_ERROR, SML_ERROR_GENERIC, "Cannot create new SmlLocation object - out of memory."); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Cannot create new SmlLocation object - out of memory."); goto error; } - if (!sml_location_set_uri(loc, uid, &gerror)) + if (!sml_location_set_uri(loc, uid, error)) goto error; if (type != SML_CHANGE_ADD) @@ -501,17 +530,20 @@ return cmd; error: - if (gerror) { - smlErrorSet(error, gerror->code, "%s", gerror->message); - g_error_free(gerror); - } if (cmd) smlCommandUnref(cmd); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -SmlCommand *smlCommandNewAlert(SmlAlertType type, SmlLocation *target, SmlLocation *source, const char *next, const char *last, const char *contenttype, SmlError **error) +SmlCommand* +smlCommandNewAlert (SmlAlertType type, + SmlLocation *target, + SmlLocation *source, + const gchar *next, + const gchar *last, + const gchar *contenttype, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%i, %p, %p, %s, %s, %s, %p)", __func__, type, target, source, VA_STRING(next), VA_STRING(last), VA_STRING(contenttype), error); CHECK_ERROR_REF @@ -557,13 +589,16 @@ 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; } -SmlCommand *smlCommandNewSync(SmlLocation *target, SmlLocation *source, unsigned int num_changes, SmlError **error) +SmlCommand* +smlCommandNewSync (SmlLocation *target, + SmlLocation *source, + guint num_changes, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %i, %p)", __func__, target, source, num_changes, error); CHECK_ERROR_REF @@ -581,13 +616,18 @@ 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; } -SmlCommand *smlCommandNewPut(SmlLocation *target, SmlLocation *source, const char *data, unsigned int size, const char *contenttype, SmlError **error) +SmlCommand* +smlCommandNewPut (SmlLocation *target, + SmlLocation *source, + const gchar *data, + guint size, + const gchar *contenttype, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %i, %s, %p)", __func__, target, source, data, size, VA_STRING(contenttype), error); CHECK_ERROR_REF @@ -598,7 +638,7 @@ cmd->private.access.item = smlItemNewForData(data, size, error); if (!cmd->private.access.item) - goto error_free_cmd; + goto error; if (target) { cmd->target = target; @@ -616,15 +656,17 @@ smlTrace(TRACE_EXIT, "%s: %p", __func__, cmd); return cmd; - -error_free_cmd: - smlCommandUnref(cmd); error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + if (cmd) + smlCommandUnref(cmd); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -SmlCommand *smlCommandNewGet(SmlLocation *target, const char *contenttype, SmlError **error) +SmlCommand* +smlCommandNewGet (SmlLocation *target, + const gchar *contenttype, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %s, %p)", __func__, target, VA_STRING(contenttype), error); CHECK_ERROR_REF @@ -636,7 +678,7 @@ cmd->private.access.item = smlItemNew(0, error); if (!cmd->private.access.item) - goto error_free_cmd; + goto error; cmd->target = target; g_object_ref(target); @@ -646,20 +688,22 @@ smlTrace(TRACE_EXIT, "%s: %p", __func__, cmd); return cmd; - -error_free_cmd: - smlCommandUnref(cmd); error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + if (cmd) + smlCommandUnref(cmd); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -SmlCommand *smlCommandNewDevInfResult(SmlCommand *cmd, SmlDevInf *devinf, SmlDevInfVersion version, SmlError **error) +SmlCommand* +smlCommandNewDevInfResult (SmlCommand *cmd, + SmlDevInf *devinf, + SmlDevInfVersion version, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p, %p)", __func__, cmd, devinf, version, error); CHECK_ERROR_REF smlAssert(cmd); - GError *gerror = NULL; SmlLocation *source = NULL; char *data = NULL; @@ -669,18 +713,18 @@ source = sml_location_new(); if (!source) { - g_set_error(&gerror, SML_ERROR, SML_ERROR_GENERIC, "Cannot create new SmlLocation object - out of memory."); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Cannot create new SmlLocation object - out of memory."); goto error; } if (version == SML_DEVINF_VERSION_10) { - if (!sml_location_set_uri(source, "./devinf10", &gerror)) + if (!sml_location_set_uri(source, "./devinf10", error)) goto error; } else if (version == SML_DEVINF_VERSION_12) { - if (!sml_location_set_uri(source, "./devinf12", &gerror)) + if (!sml_location_set_uri(source, "./devinf12", error)) goto error; } else { - if (!sml_location_set_uri(source, "./devinf11", &gerror)) + if (!sml_location_set_uri(source, "./devinf11", error)) goto error; } @@ -696,24 +740,22 @@ smlTrace(TRACE_EXIT, "%s: %p", __func__, result); return result; error: - if (gerror) { - smlErrorSet(error, gerror->code, "%s", gerror->message); - g_error_free(gerror); - } if (data) smlSafeCFree(&data); if (source) g_object_unref(source); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -SmlCommand *smlCommandNewDevInfPut(SmlDevInf *devinf, SmlDevInfVersion version, SmlError **error) +SmlCommand* +smlCommandNewDevInfPut (SmlDevInf *devinf, + SmlDevInfVersion version, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, devinf, version, error); CHECK_ERROR_REF smlAssert(devinf); - GError *gerror = NULL; SmlLocation *source = NULL; SmlCommand *cmd = NULL; @@ -723,18 +765,18 @@ source = sml_location_new(); if (!source) { - g_set_error(&gerror, SML_ERROR, SML_ERROR_GENERIC, "Cannot create new SmlLocation object - out of memory."); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Cannot create new SmlLocation object - out of memory."); goto error; } if (version == SML_DEVINF_VERSION_10) { - if (!sml_location_set_uri(source, "./devinf10", &gerror)) + if (!sml_location_set_uri(source, "./devinf10", error)) goto error; } else if (version == SML_DEVINF_VERSION_12) { - if (!sml_location_set_uri(source, "./devinf12", &gerror)) + if (!sml_location_set_uri(source, "./devinf12", error)) goto error; } else { - if (!sml_location_set_uri(source, "./devinf11", &gerror)) + if (!sml_location_set_uri(source, "./devinf11", error)) goto error; } @@ -761,42 +803,38 @@ smlTrace(TRACE_EXIT, "%s: %p", __func__, cmd); return cmd; - error: - if (gerror) { - smlErrorSet(error, gerror->code, "%s", gerror->message); - g_error_free(gerror); - } if (cmd) smlCommandUnref(cmd); if (source) g_object_unref(source); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -SmlCommand *smlCommandNewDevInfGet(SmlDevInfVersion version, SmlError **error) +SmlCommand* +smlCommandNewDevInfGet (SmlDevInfVersion version, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%i, %p)", __func__, version, error); CHECK_ERROR_REF - GError *gerror = NULL; SmlLocation *target = NULL; SmlCommand *cmd = NULL; target = sml_location_new(); if (!target) { - g_set_error(&gerror, SML_ERROR, SML_ERROR_GENERIC, "Cannot create new SmlLocation object - out of memory."); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Cannot create new SmlLocation object - out of memory."); goto error; } if (version == SML_DEVINF_VERSION_10) { - if (!sml_location_set_uri(target, "./devinf10", &gerror)) + if (!sml_location_set_uri(target, "./devinf10", error)) goto error; } else if (version == SML_DEVINF_VERSION_12) { - if (!sml_location_set_uri(target, "./devinf12", &gerror)) + if (!sml_location_set_uri(target, "./devinf12", error)) goto error; } else { - if (!sml_location_set_uri(target, "./devinf11", &gerror)) + if (!sml_location_set_uri(target, "./devinf11", error)) goto error; } @@ -811,21 +849,19 @@ smlTrace(TRACE_EXIT, "%s: %p", __func__, cmd); return cmd; - error: - if (gerror) { - smlErrorSet(error, gerror->code, "%s", gerror->message); - g_error_free(gerror); - } if (cmd) smlCommandUnref(cmd); if (target) g_object_unref(target); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -SmlCommand *smlCommandNewMap(SmlLocation *target, SmlLocation *source, SmlError **error) +SmlCommand* +smlCommandNewMap (SmlLocation *target, + SmlLocation *source, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, target, source, error); CHECK_ERROR_REF @@ -842,13 +878,15 @@ 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; } -SmlBool smlCommandAddMapItem(SmlCommand *map, SmlMapItem *item, SmlError **error) +SmlBool +smlCommandAddMapItem (SmlCommand *map, + SmlMapItem *item, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, map, item, error); CHECK_ERROR_REF @@ -863,7 +901,9 @@ return TRUE; } -SmlAlertType smlAlertTypeConvert(unsigned int id, SmlError **error) +SmlAlertType +smlAlertTypeConvert (guint id, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%u, %p)", __func__, id, error); CHECK_ERROR_REF @@ -877,9 +917,9 @@ smlTrace(TRACE_EXIT, "%s - %u", __func__, result); return result; } else { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The unknown alert code %u was detected.", id); - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return SML_ALERT_UNKNOWN; } } Modified: trunk/libsyncml/sml_command.h ============================================================================== --- trunk/libsyncml/sml_command.h Wed Jul 1 17:17:17 2009 (r1141) +++ trunk/libsyncml/sml_command.h Thu Jul 2 10:11:46 2009 (r1142) @@ -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 @@ -33,7 +33,7 @@ #include <libsyncml/syncml.h> #include <libsyncml/dev_inf_api/sml_dev_inf.h> -SmlStatus *smlStatusNew(SmlErrorType data, unsigned int cmdref, unsigned int msgref, SmlLocation *sourceref, SmlLocation *targeref, SmlCommandType type, SmlError **error); +SmlStatus *smlStatusNew(SmlErrorType data, unsigned int cmdref, unsigned int msgref, SmlLocation *sourceref, SmlLocation *targeref, SmlCommandType type, GError **error); SmlStatus *smlStatusRef(SmlStatus *status); void smlStatusUnref(SmlStatus *status); SmlErrorType smlStatusGetCode(SmlStatus *status); @@ -41,25 +41,25 @@ SmlCommand *smlStatusGetResult(SmlStatus *status); SmlBool smlStatusIsResult(SmlStatus *status); -SmlCommand *smlCommandNew(SmlCommandType type, SmlError **error); -SmlStatus *smlCommandNewReply(const SmlCommand *cmd, SmlErrorType code, SmlError **error); +SmlCommand *smlCommandNew(SmlCommandType type, GError **error); +SmlStatus *smlCommandNewReply(const SmlCommand *cmd, SmlErrorType code, GError **error); SmlCommand *smlCommandRef(SmlCommand *cmd); void smlCommandUnref(SmlCommand *cmd); -SmlCommand *smlCommandNewAlert(SmlAlertType type, SmlLocation *target, SmlLocation *source, const char *next, const char *last, const char *contenttype, SmlError **error); -SmlCommand *smlCommandNewSync(SmlLocation *target, SmlLocation *source, unsigned int num_changes, SmlError **error); -SmlCommand *smlCommandNewChange(SmlChangeType type, const char *uid, const char *data, unsigned int size, const char *contenttype, SmlError **error); -SmlCommand *smlCommandNewPartialChange(SmlChangeType type, const char *uid, const char *data, unsigned int complete_size, unsigned int partial_size, const char *contenttype, SmlError **error); -SmlCommand *smlCommandNewResult(SmlCommand *cmd, SmlLocation *source, char *data, unsigned int size, const char *contenttype, SmlError **error); -SmlCommand *smlCommandNewPut(SmlLocation *target, SmlLocation *source, const char *data, unsigned int size, const char *contenttype, SmlError **error); -SmlCommand *smlCommandNewGet(SmlLocation *target, const char *contenttype, SmlError **error); - -SmlCommand *smlCommandNewDevInfResult(SmlCommand *cmd, SmlDevInf *devinf, SmlDevInfVersion version, SmlError **error); -SmlCommand *smlCommandNewDevInfPut(SmlDevInf *devinf, SmlDevInfVersion version, SmlError **error); -SmlCommand *smlCommandNewDevInfGet(SmlDevInfVersion version, SmlError **error); +SmlCommand *smlCommandNewAlert(SmlAlertType type, SmlLocation *target, SmlLocation *source, const char *next, const char *last, const char *contenttype, GError **error); +SmlCommand *smlCommandNewSync(SmlLocation *target, SmlLocation *source, unsigned int num_changes, GError **error); +SmlCommand *smlCommandNewChange(SmlChangeType type, const char *uid, const char *data, unsigned int size, const char *contenttype, GError **error); +SmlCommand *smlCommandNewPartialChange(SmlChangeType type, const char *uid, const char *data, unsigned int complete_size, unsigned int partial_size, const char *contenttype, GError **error); +SmlCommand *smlCommandNewResult(SmlCommand *cmd, SmlLocation *source, char *data, unsigned int size, const char *contenttype, GError **error); +SmlCommand *smlCommandNewPut(SmlLocation *target, SmlLocation *source, const char *data, unsigned int size, const char *contenttype, GError **error); +SmlCommand *smlCommandNewGet(SmlLocation *target, const char *contenttype, GError **error); + +SmlCommand *smlCommandNewDevInfResult(SmlCommand *cmd, SmlDevInf *devinf, SmlDevInfVersion version, GError **error); +SmlCommand *smlCommandNewDevInfPut(SmlDevInf *devinf, SmlDevInfVersion version, GError **error); +SmlCommand *smlCommandNewDevInfGet(SmlDevInfVersion version, GError **error); -SmlCommand *smlCommandNewMap(SmlLocation *target, SmlLocation *source, SmlError **error); -SmlBool smlCommandAddMapItem(SmlCommand *map, SmlMapItem *item, SmlError **error); +SmlCommand *smlCommandNewMap(SmlLocation *target, SmlLocation *source, GError **error); +SmlBool smlCommandAddMapItem(SmlCommand *map, SmlMapItem *item, GError **error); #endif //_SML_COMMAND_H_ Modified: trunk/libsyncml/sml_command_internals.h ============================================================================== --- trunk/libsyncml/sml_command_internals.h Wed Jul 1 17:17:17 2009 (r1141) +++ trunk/libsyncml/sml_command_internals.h Thu Jul 2 10:11:46 2009 (r1142) @@ -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 @@ -107,10 +107,10 @@ SmlCommand *result; }; -SmlCommandType smlCommandTypeFromString(const char *name, SmlError **error); -const char *smlCommandTypeToString(SmlCommandType type, SmlError **error); +SmlCommandType smlCommandTypeFromString(const char *name, GError **error); +const char *smlCommandTypeToString(SmlCommandType type, GError **error); -SmlAlertType smlAlertTypeConvert(unsigned int id, SmlError **error); +SmlAlertType smlAlertTypeConvert(unsigned int id, GError **error); #endif //_SML_COMMAND_INTERNALS_H_ Modified: trunk/libsyncml/sml_elements.h ============================================================================== --- trunk/libsyncml/sml_elements.h Wed Jul 1 17:17:17 2009 (r1141) +++ trunk/libsyncml/sml_elements.h Thu Jul 2 10:11:46 2009 (r1142) @@ -30,25 +30,24 @@ #ifndef _SML_ELEMENTS_H_ #define _SML_ELEMENTS_H_ -SmlCred *smlCredNewFromString(const char *type, const char *format, const char *data, SmlError **error); -SmlCred *smlCredNewAuth(SmlAuthType type, const char *username, const char *password, SmlError **error); -SmlCred *smlCredNew(SmlAuthType type, SmlFormatType format, const char *data, const char*username, SmlError **error); +SmlCred *smlCredNewFromString(const char *type, const char *format, const char *data, GError **error); +SmlCred *smlCredNewAuth(SmlAuthType type, const char *username, const char *password, GError **error); +SmlCred *smlCredNew(SmlAuthType type, SmlFormatType format, const char *data, const char*username, GError **error); void smlCredRef(SmlCred *cred); void smlCredUnref(SmlCred *cred); -void smlCredFree(SmlCred *cred) LIBSYNCML_DEPRECATED; /* expire date: 20090120 */ -SmlAnchor *smlAnchorNew(const char *last, const char *next, SmlError **error); +SmlAnchor *smlAnchorNew(const char *last, const char *next, GError **error); void smlAnchorFree(SmlAnchor *anchor); -SmlItem *smlItemNew(unsigned int size, SmlError **error); -SmlItem *smlItemNewForData(const char *data, unsigned int size, SmlError **error); +SmlItem *smlItemNew(unsigned int size, GError **error); +SmlItem *smlItemNewForData(const char *data, unsigned int size, GError **error); SmlItem *smlItemRef(SmlItem *item); void smlItemUnref(SmlItem *item); -SmlBool smlItemAddData(SmlItem *item, const char *data, unsigned int size, SmlError **error); +SmlBool smlItemAddData(SmlItem *item, const char *data, unsigned int size, GError **error); SmlBool smlItemCheck(SmlItem *item); SmlBool smlItemHasData(SmlItem *item); -SmlBool smlItemGetData(SmlItem *item, char **data, unsigned int *size, SmlError **error); -SmlBool smlItemStealData(SmlItem *item, char **data, unsigned int *size, SmlError **error); +SmlBool smlItemGetData(SmlItem *item, char **data, unsigned int *size, GError **error); +SmlBool smlItemStealData(SmlItem *item, char **data, unsigned int *size, GError **error); void smlItemSetSource(SmlItem *item, SmlLocation *source); SmlLocation *smlItemGetSource(SmlItem *item); @@ -58,14 +57,13 @@ void smlHeaderFree(SmlHeader *header); -SmlChal *smlChalNew(SmlAuthType type, SmlError **error); -SmlChal *smlChalNewFromBinary(SmlAuthType type, const char *nonce, size_t length, SmlError **error); -SmlChal *smlChalNewFromBase64(SmlAuthType type, const char *nonce, SmlError **error); +SmlChal *smlChalNew(SmlAuthType type, GError **error); +SmlChal *smlChalNewFromBinary(SmlAuthType type, const char *nonce, size_t length, GError **error); +SmlChal *smlChalNewFromBase64(SmlAuthType type, const char *nonce, GError **error); void smlChalRef(SmlChal *chal); void smlChalUnref(SmlChal *chal); -void smlChalFree(SmlChal *chal) LIBSYNCML_DEPRECATED; /* expire date: 20090417 */ -SmlMapItem *smlMapItemNew(const char *uid, const char *newuid, SmlError **error); +SmlMapItem *smlMapItemNew(const char *uid, const char *newuid, GError **error); SmlMapItem *smlMapItemRef(SmlMapItem *item); void smlMapItemUnref(SmlMapItem *item); Modified: trunk/libsyncml/sml_support.h ============================================================================== --- trunk/libsyncml/sml_support.h Wed Jul 1 17:17:17 2009 (r1141) +++ trunk/libsyncml/sml_support.h Thu Jul 2 10:11:46 2009 (r1142) @@ -47,7 +47,7 @@ char *smlPrintBinary(const char *data, int len); char *smlPrintHex(const char *data, int len); char *smlRandStr(int maxlength, SmlBool exact); -void *smlTryMalloc0(long n_bytes, SmlError **error); +void *smlTryMalloc0(long n_bytes, GError **error); typedef struct SmlThread { GThread *thread; |
From: <svn...@op...> - 2009-07-01 15:17:21
|
Author: bellmich Date: Wed Jul 1 17:17:17 2009 New Revision: 1141 URL: http://libsyncml.opensync.org/changeset/1141 Log: removed deprecated base64 implementation Deleted: trunk/libsyncml/sml_base64.c trunk/libsyncml/sml_base64.h trunk/tests/check_base64.c Modified: trunk/CMakeLists.txt trunk/libsyncml/CMakeLists.txt trunk/libsyncml/syncml.h trunk/tests/CMakeLists.txt Modified: trunk/CMakeLists.txt ============================================================================== --- trunk/CMakeLists.txt Wed Jul 1 16:40:35 2009 (r1140) +++ trunk/CMakeLists.txt Wed Jul 1 17:17:17 2009 (r1141) @@ -197,7 +197,6 @@ OPTION( ENABLE_TOOLS "enable building tools" ON ) OPTION( ENABLE_TRACE "enable tracing" ON ) -OPTION( ENABLE_BASE64_TEST "enable deprecated base64 tests" OFF ) SET( PACKAGE "libsyncml" ) SET( PACKAGE_BUGREPORT " " ) @@ -269,7 +268,6 @@ SHOW_STATUS( ENABLE_BLUETOOTH "obex over bluetooth transports" BLUEZ_VERSION ) SHOW_STATUS( ENABLE_BLUETOOTH_SDPLIB "bluetooth channel discovery\t" ) SHOW_STATUS( ENABLE_OPENOBEX_TCP "obex over tcp transports\t" ) -SHOW_STATUS( ENABLE_BASE64_TEST "deprecated base64 tests\t" ) SHOW_STATUS( ENABLE_GLIB2_GREGEX "glib2 GRegex support\t\t" GLIB2_VERSION ) SHOW_STATUS( BUILD_DOCUMENTATION "documentation\t\t" ) Modified: trunk/libsyncml/CMakeLists.txt ============================================================================== --- trunk/libsyncml/CMakeLists.txt Wed Jul 1 16:40:35 2009 (r1140) +++ trunk/libsyncml/CMakeLists.txt Wed Jul 1 17:17:17 2009 (r1141) @@ -3,7 +3,6 @@ INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${GLIB2_INCLUDE_DIRS} ${GTHREAD2_INCLUDE_DIRS} ${GOBJECT2_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIRS} ${OPENOBEX_INCLUDE_DIRS} ${LIBWBXML2_INCLUDE_DIRS} ${LIBSOUP2_INCLUDE_DIRS} ${BLUEZ_INCLUDE_DIRS} ) SET( libsyncml_LIB_SRCS - sml_base64.c sml_command.c sml_elements.c sml_error.c @@ -72,7 +71,6 @@ objects/sml_devinf_obj.h objects/sml_ds_server.h objects/sml_auth.h - sml_base64.h sml_command.h sml_defines.h sml_elements.h Modified: trunk/libsyncml/syncml.h ============================================================================== --- trunk/libsyncml/syncml.h Wed Jul 1 16:40:35 2009 (r1140) +++ trunk/libsyncml/syncml.h Wed Jul 1 17:17:17 2009 (r1141) @@ -96,7 +96,6 @@ #include <libsyncml/sml_elements.h> #include <libsyncml/sml_command.h> #include <libsyncml/sml_notification.h> -#include <libsyncml/sml_base64.h> #include <libsyncml/sml_md5.h> const char *smlGetLibraryVersion(); Modified: trunk/tests/CMakeLists.txt ============================================================================== --- trunk/tests/CMakeLists.txt Wed Jul 1 16:40:35 2009 (r1140) +++ trunk/tests/CMakeLists.txt Wed Jul 1 17:17:17 2009 (r1141) @@ -474,29 +474,6 @@ SML_END_TEST() ENDIF ( ENABLE_OPENOBEX_TCP OR ENABLE_HTTP ) - # tests of deprecated stuff - # such tests produce compiler warnings - - IF ( ENABLE_BASE64_TEST ) - SML_START_TEST( "base64" base64 check_base64.c ${TEST_TARGET_LIBRARIES} ) - SML_ADD_TESTCASE( base64_decode_null ) - SML_ADD_TESTCASE( base64_decode_null2 ) - SML_ADD_TESTCASE( base64_decode_test ) - SML_ADD_TESTCASE( base64_decode_size ) - SML_ADD_TESTCASE( base64_decode2 ) - SML_ADD_TESTCASE( base64_decode3 ) - SML_ADD_TESTCASE( base64_decode4 ) - SML_ADD_TESTCASE( base64_invalid1 ) - SML_ADD_TESTCASE( base64_empty ) - # SML_ADD_TESTCASE( base64_invalid2 ) - SML_ADD_TESTCASE( base64_encode_null ) - SML_ADD_TESTCASE( base64_encode_null2 ) - SML_ADD_TESTCASE( base64_encode_test ) - SML_ADD_TESTCASE( base64_encode_test2 ) - SML_ADD_TESTCASE( base64_encode_test3 ) - SML_END_TEST() - ENDIF ( ENABLE_BASE64_TEST ) - ENDIF( ENABLE_UNIT_TEST ) CONFIGURE_FILE( "coverage.sh.cmake" "${CMAKE_BINARY_DIR}/coverage.sh") |
From: <svn...@op...> - 2009-07-01 14:40:42
|
Author: bellmich Date: Wed Jul 1 16:40:35 2009 New Revision: 1140 URL: http://libsyncml.opensync.org/changeset/1140 Log: The complete location information is managed in one object. Even TargetParent and SourceParent are not managed by separate location objects. Modified: trunk/libsyncml/parser/sml_xml_assm.c trunk/libsyncml/parser/sml_xml_parse.c trunk/libsyncml/sml_elements.c trunk/libsyncml/sml_elements.h trunk/libsyncml/sml_elements_internals.h Modified: trunk/libsyncml/parser/sml_xml_assm.c ============================================================================== --- trunk/libsyncml/parser/sml_xml_assm.c Wed Jul 1 15:48:22 2009 (r1139) +++ trunk/libsyncml/parser/sml_xml_assm.c Wed Jul 1 16:40:35 2009 (r1140) @@ -245,17 +245,30 @@ goto error; } - if (!sml_location_get_uri(location)) { - smlErrorSet(error, SML_ERROR_GENERIC, "No locURI set"); - goto error; - } + if (name && + (strcmp(SML_ELEMENT_SOURCE_PARENT, name) == 0 || + strcmp(SML_ELEMENT_TARGET_PARENT, name) == 0)) { + if (!sml_location_get_parent_uri(location)) { + smlErrorSet(error, SML_ERROR_GENERIC, "No parent URI set"); + goto error; + } - if (!_smlXmlAssemblerAddString(assm, SML_ELEMENT_LOCURI, sml_location_get_uri(location), error)) - goto error; + if (!_smlXmlAssemblerAddString(assm, SML_ELEMENT_LOCURI, sml_location_get_parent_uri(location), error)) + goto error; + + } else { + if (!sml_location_get_uri(location)) { + smlErrorSet(error, SML_ERROR_GENERIC, "No location URI set"); + goto error; + } - if (sml_location_get_name(location)) { - if (!_smlXmlAssemblerAddString(assm, SML_ELEMENT_LOCNAME, sml_location_get_name(location), error)) + if (!_smlXmlAssemblerAddString(assm, SML_ELEMENT_LOCURI, sml_location_get_uri(location), error)) goto error; + + if (sml_location_get_name(location)) { + if (!_smlXmlAssemblerAddString(assm, SML_ELEMENT_LOCNAME, sml_location_get_name(location), error)) + goto error; + } } if (name) { @@ -348,14 +361,14 @@ } /* SourceParent */ - if (smlItemGetSourceParent(item)) { - if (!smlLocationAssemble(smlItemGetSourceParent(item), assm, SML_ELEMENT_SOURCE_PARENT, error)) + if (sml_location_get_parent_uri(smlItemGetSource(item))) { + if (!smlLocationAssemble(smlItemGetSource(item), assm, SML_ELEMENT_SOURCE_PARENT, error)) goto error; } /* TargetParent */ - if (smlItemGetTargetParent(item)) { - if (!smlLocationAssemble(smlItemGetTargetParent(item), assm, SML_ELEMENT_TARGET_PARENT, error)) + if (sml_location_get_parent_uri(smlItemGetTarget(item))) { + if (!smlLocationAssemble(smlItemGetTarget(item), assm, SML_ELEMENT_TARGET_PARENT, error)) goto error; } @@ -777,8 +790,17 @@ } /* SourceParent */ + if (sml_location_get_parent_uri(cmd->source)) { + if (!smlLocationAssemble(cmd->source, assm, SML_ELEMENT_SOURCE_PARENT, error)) + goto error; + } /* TargetParent */ + if (sml_location_get_parent_uri(cmd->target)) { + if (!smlLocationAssemble(cmd->target, assm, SML_ELEMENT_TARGET_PARENT, error)) + goto error; + } + /* Begin of META */ Modified: trunk/libsyncml/parser/sml_xml_parse.c ============================================================================== --- trunk/libsyncml/parser/sml_xml_parse.c Wed Jul 1 15:48:22 2009 (r1139) +++ trunk/libsyncml/parser/sml_xml_parse.c Wed Jul 1 16:40:35 2009 (r1140) @@ -664,12 +664,15 @@ CHECK_ERROR_REF smlAssert(parser); + GError *gerror = NULL; + SmlItem *item = NULL; + if (parser->gotMoreData) { smlErrorSet(error, SML_ERROR_GENERIC, "Last item already had more data set"); goto error; } - SmlItem *item = smlItemNew(0, error); + item = smlItemNew(0, error); if (!item) goto error; @@ -682,7 +685,7 @@ if (!_smlXmlParserStep(parser)) { smlErrorSet(error, SML_ERROR_GENERIC, "The first element inside of an Item structure cannot be parsed."); - goto error_free_item; + goto error; } while (1) { @@ -693,36 +696,76 @@ smlErrorSet(error, SML_ERROR_GENERIC, "The element %s is not a start node in Item.", xmlTextReaderConstName(parser->reader)); - goto error_free_item; + goto error; } if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_SOURCE)) { SmlLocation *source = NULL; if (!_smlLocationParse(&source, parser, error)) - goto error_free_item; + goto error; + + if (smlItemGetSource(item)) { + /* SourceParent already parsed */ + if (!sml_location_set_parent_uri(source, sml_location_get_parent_uri(smlItemGetSource(item)), &gerror)) + goto error; + } smlItemSetSource(item, source); g_object_unref(source); } else if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_TARGET)) { SmlLocation *target = NULL; if (!_smlLocationParse(&target, parser, error)) - goto error_free_item; + goto error; + + if (smlItemGetTarget(item)) { + /* TargetParent already parsed */ + if (!sml_location_set_parent_uri(target, sml_location_get_parent_uri(smlItemGetTarget(item)), &gerror)) + goto error; + } smlItemSetTarget(item, target); g_object_unref(target); } else if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_SOURCE_PARENT)) { SmlLocation *source = NULL; if (!_smlLocationParse(&source, parser, error)) - goto error_free_item; + goto error; - smlItemSetSourceParent(item, source); + if (smlItemGetSource(item)) { + /* Source already parsed */ + if (!sml_location_set_parent_uri(smlItemGetSource(item), sml_location_get_uri(source), &gerror)) + goto error; + } else { + /* there is no source object until now */ + smlItemSetSource(item, source); + /* copy uri to parent_uri property */ + if (!sml_location_set_parent_uri(source, sml_location_get_uri(source), &gerror)) + goto error; + /* delete uri property */ + if (!sml_location_set_uri(source, NULL, &gerror)) + goto error; + } + g_object_unref(source); } else if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_TARGET_PARENT)) { SmlLocation *target = NULL; if (!_smlLocationParse(&target, parser, error)) - goto error_free_item; + goto error; - smlItemSetTargetParent(item, target); + if (smlItemGetTarget(item)) { + /* Target already parsed */ + if (!sml_location_set_parent_uri(smlItemGetTarget(item), sml_location_get_uri(target), &gerror)) + goto error; + } else { + /* there is no target object until now */ + smlItemSetTarget(item, target); + /* copy uri to parent_uri property */ + if (!sml_location_set_parent_uri(target, sml_location_get_uri(target), &gerror)) + goto error; + /* delete uri property */ + if (!sml_location_set_uri(target, NULL, &gerror)) + goto error; + } + g_object_unref(target); } else if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_META)) { switch (type) { @@ -734,32 +777,32 @@ * FIXME: Can we ignore the content? */ if (!_smlCommandMetaParse(parser, NULL, NULL, NULL, NULL, NULL, error)) - goto error_free_item; + goto error; } else { /* Some phones send the maxobjsize in the alert */ if (!_smlCommandMetaParse(parser, NULL, &(cmd->private.alert.contentType), &cmd->private.alert.anchor, NULL, &(cmd->private.alert.maxObjSize), error)) - goto error_free_item; + goto error; } break; case SML_COMMAND_TYPE_ADD: case SML_COMMAND_TYPE_DELETE: case SML_COMMAND_TYPE_REPLACE: if (!_smlCommandMetaParse(parser, NULL, &(item->contenttype), NULL, &cmd->size, NULL, error)) - goto error_free_item; + goto error; break; case SML_COMMAND_TYPE_RESULTS: case SML_COMMAND_TYPE_PUT:; /* Some phones send the type information for the devinf put * not in the put itself but in the item */ if (!_smlCommandMetaParse(parser, NULL, &(item->contenttype), NULL, NULL, NULL, error)) - goto error_free_item; + goto error; if (!item->contenttype) - goto error_free_item; + goto error; break; default: smlErrorSet(error, SML_ERROR_GENERIC, "Unknown command type"); - goto error_free_item; + goto error; } } else if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_DATA)) { /* Do nothing if the Data element is empty. @@ -772,7 +815,7 @@ case SML_COMMAND_TYPE_ALERT: if (!_smlXmlParserStep(parser)) { smlErrorSet(error, SML_ERROR_GENERIC, "The next element after the starting Data element in an Item is missing."); - goto error_free_item; + goto error; } if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_DATA) && @@ -793,29 +836,29 @@ */ anchor = smlTryMalloc0(sizeof(SmlAnchor), error); if (!anchor) - goto error_free_item; + goto error; anchor->next = g_strdup((char *)xmlTextReaderConstValue(parser->reader)); } else { /* normal behaviour with anchor copy */ if (!_smlAnchorParse(&anchor, parser, error)) - goto error_free_item; + goto error; } item->anchor = anchor; if (!_smlXmlParserStep(parser)) { smlErrorSet(error, SML_ERROR_GENERIC, "The closing Data element in an Item is missing."); - goto error_free_item; + goto error; } break; default:; char *data = NULL; unsigned int size = 0; if (!_smlXmlParserGetData(parser, &data, &size, SML_ELEMENT_DATA, error)) - goto error_free_item; + goto error; if (!smlItemAddData(item, data, size, error)) { smlSafeCFree(&data); - goto error_free_item; + goto error; } smlSafeCFree(&data); @@ -824,41 +867,42 @@ } else if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_MOREDATA)) { if (parser->version == SML_VERSION_10) { smlErrorSet(error, SML_ERROR_GENERIC, "SyncML 1.0 does not allow MoreData"); - goto error_free_item; + goto error; } item->moreData = TRUE; parser->gotMoreData = TRUE; if (!_smlXmlParserStep(parser)) { smlErrorSet(error, SML_ERROR_GENERIC, "Missing nodes2"); - goto error_free_item; + goto error; } if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_MOREDATA) && \ xmlTextReaderNodeType(parser->reader) == XML_NODE_CLOSE) { if (!_smlXmlParserStep(parser)) { smlErrorSet(error, SML_ERROR_GENERIC, "Missing nodes3"); - goto error_free_item; + goto error; } } continue; } else { smlErrorSet(error, SML_ERROR_GENERIC, "The element Item does not support the child element %s.", xmlTextReaderConstName(parser->reader)); - goto error_free_item; + goto error; } if (!_smlXmlParserStep(parser)) { smlErrorSet(error, SML_ERROR_GENERIC, "The next element in an Item structure is missing."); - goto error_free_item; + goto error; } } smlTrace(TRACE_EXIT, "%s", __func__); return item; -error_free_item: - smlItemUnref(item); error: + if (item) + smlItemUnref(item); + GERROR_TO_SML_ERROR(gerror,error) smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); return NULL; } Modified: trunk/libsyncml/sml_elements.c ============================================================================== --- trunk/libsyncml/sml_elements.c Wed Jul 1 15:48:22 2009 (r1139) +++ trunk/libsyncml/sml_elements.c Wed Jul 1 16:40:35 2009 (r1140) @@ -157,12 +157,6 @@ if (item->target) g_object_unref(item->target); - if (item->sourceParent) - g_object_unref(item->sourceParent); - - if (item->targetParent) - g_object_unref(item->targetParent); - if (item->anchor) smlAnchorFree(item->anchor); @@ -316,38 +310,6 @@ return item->target; } -void smlItemSetSourceParent(SmlItem *item, SmlLocation *sourceParent) -{ - smlAssert(item); - smlAssert(sourceParent); - - item->sourceParent = sourceParent; - g_object_ref(sourceParent); -} - -SmlLocation *smlItemGetSourceParent(SmlItem *item) -{ - smlAssert(item); - - return item->sourceParent; -} - -void smlItemSetTargetParent(SmlItem *item, SmlLocation *targetParent) -{ - smlAssert(item); - smlAssert(targetParent); - - item->targetParent = targetParent; - g_object_ref(targetParent); -} - -SmlLocation *smlItemGetTargetParent(SmlItem *item) -{ - smlAssert(item); - - return item->targetParent; -} - void smlItemSetRaw(SmlItem *item, SmlBool raw) { smlAssert(item); Modified: trunk/libsyncml/sml_elements.h ============================================================================== --- trunk/libsyncml/sml_elements.h Wed Jul 1 15:48:22 2009 (r1139) +++ trunk/libsyncml/sml_elements.h Wed Jul 1 16:40:35 2009 (r1140) @@ -54,10 +54,6 @@ SmlLocation *smlItemGetSource(SmlItem *item); void smlItemSetTarget(SmlItem *item, SmlLocation *target); SmlLocation *smlItemGetTarget(SmlItem *item); -void smlItemSetSourceParent(SmlItem *item, SmlLocation *sourceParent); -SmlLocation *smlItemGetSourceParent(SmlItem *item); -void smlItemSetTargetParent(SmlItem *item, SmlLocation *targeParent); -SmlLocation *smlItemGetTargetParent(SmlItem *item); void smlItemSetRaw(SmlItem *item, SmlBool raw); void smlHeaderFree(SmlHeader *header); Modified: trunk/libsyncml/sml_elements_internals.h ============================================================================== --- trunk/libsyncml/sml_elements_internals.h Wed Jul 1 15:48:22 2009 (r1139) +++ trunk/libsyncml/sml_elements_internals.h Wed Jul 1 16:40:35 2009 (r1140) @@ -42,8 +42,6 @@ SmlLocation *source; SmlLocation *target; - SmlLocation *sourceParent; - SmlLocation *targetParent; SmlAnchor *anchor; xmlBuffer *buffer; |