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; |