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-13 12:09:53
|
Author: bellmich Date: Mon Jul 13 14:09:45 2009 New Revision: 1178 URL: http://libsyncml.opensync.org/changeset/1178 Log: migrated check_sync from SmlError to GError Modified: trunk/tests/check_sync.c Modified: trunk/tests/check_sync.c ============================================================================== --- trunk/tests/check_sync.c Mon Jul 13 14:02:32 2009 (r1177) +++ trunk/tests/check_sync.c Mon Jul 13 14:09:45 2009 (r1178) @@ -66,7 +66,7 @@ #define TEST_DEFAULT_MAX_MSG_SIZE 1024000 #define TEST_DEFAULT_MAX_OBJ_SIZE 1024000 unsigned int num_changes; -SmlError *eventError; +GError *eventError; void reset_testbed() { @@ -98,7 +98,7 @@ setup_testbed(NULL); } -static void _manager_event(SmlManager *manager, SmlManagerEventType type, SmlSession *session, SmlError *error, void *userdata) +static void _manager_event(SmlManager *manager, SmlManagerEventType type, SmlSession *session, GError *error, void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p)", __func__, manager, type, session, error, userdata); managerTracker *tracker = userdata; @@ -114,9 +114,8 @@ g_atomic_int_inc(&num_disconnects); break; case SML_MANAGER_TRANSPORT_ERROR: - smlTrace(TRACE_INTERNAL, "%s - error: %s", __func__, smlErrorPrint(&error)); - eventError = error; - smlErrorRef(&eventError); + smlTrace(TRACE_INTERNAL, "%s - error: %s", __func__, error->message); + eventError = g_error_copy(error); transport_errors++; break; case SML_MANAGER_SESSION_NEW: @@ -133,11 +132,10 @@ break; case SML_MANAGER_SESSION_ERROR: case SML_MANAGER_SESSION_WARNING: - smlTrace(TRACE_INTERNAL, "%s - error: %s", __func__, smlErrorPrint(&error)); + smlTrace(TRACE_INTERNAL, "%s - error: %s", __func__, error->message); if (eventError) - smlErrorDeref(&eventError); - eventError = error; - smlErrorRef(&eventError); + SML_ERROR_FREE(eventError); + eventError = g_error_copy(error); session_errors++; break; default: @@ -167,7 +165,7 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -static SmlBool _recv_alert(SmlDsSession *dsession, SmlAlertType type, const char *last, const char *next, void *userdata) +static gboolean _recv_alert(SmlDsSession *dsession, SmlAlertType type, const char *last, const char *next, void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %s, %s, %p)", __func__, dsession, type, VA_STRING(last), VA_STRING(next), userdata); @@ -214,50 +212,42 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -static void _add_reply(SmlDsSession *session, SmlStatus *status, const char *newuid, void *userdata) +static void _add_reply(SmlDsSession *session, SmlStatus *status, void *userdata) { - smlTrace(TRACE_ENTRY, "%s(%p, %p, %s, %p)", __func__, session, status, VA_STRING(newuid), userdata); + smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, status, userdata); sml_fail_unless(status != NULL, NULL); sml_fail_unless(smlStatusGetClass(status) == SML_ERRORCLASS_SUCCESS, NULL); sml_fail_unless(GPOINTER_TO_INT(userdata) == 1 || GPOINTER_TO_INT(userdata) == 2, NULL); - if (GPOINTER_TO_INT(userdata) == 1) { - sml_fail_unless(!strcmp(newuid, "newuid"), NULL); - } else { - sml_fail_unless(newuid == NULL, NULL); - } + /* newuid is only supplied by mapping callback */ add_replies_received++; smlTrace(TRACE_EXIT, "%s", __func__); } -static void _modify_reply(SmlDsSession *session, SmlStatus *status, const char *newuid, void *userdata) +static void _modify_reply(SmlDsSession *session, SmlStatus *status, void *userdata) { - smlTrace(TRACE_ENTRY, "%s(%p, %p, %s, %p)", __func__, session, status, VA_STRING(newuid), userdata); + smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, status, userdata); sml_fail_unless(status != NULL, NULL); sml_fail_unless(smlStatusGetClass(status) == SML_ERRORCLASS_SUCCESS, NULL); sml_fail_unless(GPOINTER_TO_INT(userdata) == 1, NULL); - sml_fail_unless(newuid == NULL, NULL); - modify_replies_received++; smlTrace(TRACE_EXIT, "%s", __func__); } -static void _delete_reply(SmlDsSession *session, SmlStatus *status, const char *newuid, void *userdata) +static void _delete_reply(SmlDsSession *session, SmlStatus *status, void *userdata) { - smlTrace(TRACE_ENTRY, "%s(%p, %p, %s, %p)", __func__, session, status, VA_STRING(newuid), userdata); + smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, status, userdata); sml_fail_unless(status != NULL, NULL); sml_fail_unless(smlStatusGetClass(status) == SML_ERRORCLASS_SUCCESS, NULL); sml_fail_unless(GPOINTER_TO_INT(userdata) == 1, NULL); - sml_fail_unless(newuid == NULL, NULL); - delete_replies_received++; smlTrace(TRACE_EXIT, "%s", __func__); @@ -297,7 +287,7 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -static SmlBool _recv_changes(SmlDsSession *dsession, SmlChangeType type, const char *uid, char *data, unsigned int size, const char *contenttype, void *userdata, SmlError **error) +static gboolean _recv_changes(SmlDsSession *dsession, SmlChangeType type, const char *uid, char *data, unsigned int size, const char *contenttype, void *userdata, GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %s, %s, %i, %s, %p, %p)", __func__, dsession, type, VA_STRING(uid), VA_STRING(data), size, VA_STRING(contenttype), userdata, error); @@ -331,7 +321,7 @@ { reset_testbed(); - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlTransport *server = smlTransportNew(SML_TRANSPORT_HTTP_SERVER, &error); @@ -350,9 +340,9 @@ smlManagerSetLocalMaxMsgSize(servertracker->manager, TEST_DEFAULT_MAX_MSG_SIZE); smlManagerSetLocalMaxObjSize(servertracker->manager, TEST_DEFAULT_MAX_OBJ_SIZE); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); sml_fail_unless(smlManagerStart(clientmanager, &error), NULL); sml_fail_unless(error == NULL, NULL); @@ -407,7 +397,7 @@ smlAuthSetEnable(auth2, FALSE); smlAuthRegister(auth2, servermanager, &error); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, NULL, 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 0, 0, &error); sml_fail_unless(smlManagerSessionAdd(clientmanager, session, NULL, &error), NULL); sml_fail_unless(error == NULL, NULL); @@ -425,7 +415,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } smlDsSessionGetAlert(servertracker->dssessions[0], _recv_alert, GINT_TO_POINTER(1)); @@ -443,7 +433,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } sml_fail_unless(init_alerts_received == 3, NULL); @@ -498,7 +488,7 @@ smlAuthFree(auth2); sml_fail_unless(smlTransportFinalize(server, &error), NULL); - sml_fail_unless(smlTransportFinalize(client, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportFinalize(client, &error), "%s", error->message); smlTransportFree(server); smlTransportFree(client); @@ -517,7 +507,7 @@ unsigned int num_items = 10; num_changes = 3 * num_items; - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlTransport *server = smlTransportNew(SML_TRANSPORT_HTTP_SERVER, &error); @@ -536,9 +526,9 @@ smlManagerSetLocalMaxMsgSize(servertracker->manager, TEST_DEFAULT_MAX_MSG_SIZE); smlManagerSetLocalMaxObjSize(servertracker->manager, TEST_DEFAULT_MAX_OBJ_SIZE); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); sml_fail_unless(smlManagerStart(clientmanager, &error), NULL); sml_fail_unless(error == NULL, NULL); @@ -592,7 +582,7 @@ smlAuthSetEnable(auth2, FALSE); smlAuthRegister(auth2, servermanager, &error); - clienttracker->session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, NULL, 0, &error); + clienttracker->session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 0, 0, &error); sml_fail_unless(smlManagerSessionAdd(clientmanager, clienttracker->session, NULL, &error), NULL); sml_fail_unless(error == NULL, NULL); @@ -610,7 +600,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } smlDsSessionGetAlert(servertracker->dssessions[0], _recv_alert, GINT_TO_POINTER(1)); @@ -640,7 +630,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } const char *content_types[] = {SML_ELEMENT_TEXT_VCARD, SML_ELEMENT_TEXT_VCAL, SML_ELEMENT_TEXT_PLAIN}; @@ -683,7 +673,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } sml_fail_unless(servertracker->session != NULL, NULL); @@ -697,7 +687,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } sml_fail_unless(init_alerts_received == 3, NULL); @@ -752,7 +742,7 @@ smlManagerFree(servermanager); sml_fail_unless(smlTransportFinalize(server, &error), NULL); - sml_fail_unless(smlTransportFinalize(client, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportFinalize(client, &error), "%s", error->message); smlTransportFree(server); smlTransportFree(client); @@ -773,7 +763,7 @@ unsigned int num_items = 100; num_changes = 3 * num_items; - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlTransport *server = smlTransportNew(SML_TRANSPORT_HTTP_SERVER, &error); @@ -792,9 +782,9 @@ smlManagerSetLocalMaxMsgSize(servertracker->manager, TEST_DEFAULT_MAX_MSG_SIZE); smlManagerSetLocalMaxObjSize(servertracker->manager, TEST_DEFAULT_MAX_OBJ_SIZE); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); sml_fail_unless(smlManagerStart(clientmanager, &error), NULL); sml_fail_unless(error == NULL, NULL); @@ -848,7 +838,7 @@ smlAuthSetEnable(auth2, FALSE); smlAuthRegister(auth2, servermanager, &error); - clienttracker->session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, NULL, 0, &error); + clienttracker->session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 0, 0, &error); sml_fail_unless(smlManagerSessionAdd(clientmanager, clienttracker->session, NULL, &error), NULL); sml_fail_unless(error == NULL, NULL); @@ -866,7 +856,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } smlDsSessionGetAlert(servertracker->dssessions[0], _recv_alert, GINT_TO_POINTER(1)); @@ -896,7 +886,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } const char *content_types[] = {SML_ELEMENT_TEXT_VCARD, SML_ELEMENT_TEXT_VCAL, SML_ELEMENT_TEXT_PLAIN}; @@ -939,7 +929,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } for (k = 0; k < 3; k++) @@ -980,7 +970,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } unsigned int i = 0; @@ -1008,7 +998,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } sml_fail_unless(servertracker->session != NULL, NULL); @@ -1022,7 +1012,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } sml_fail_unless(init_alerts_received == 3, NULL); @@ -1077,7 +1067,7 @@ smlManagerFree(servermanager); sml_fail_unless(smlTransportFinalize(server, &error), NULL); - sml_fail_unless(smlTransportFinalize(client, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportFinalize(client, &error), "%s", error->message); smlTransportFree(server); smlTransportFree(client); @@ -1096,7 +1086,7 @@ unsigned int num_items = 100; num_changes = 3 * num_items; - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlTransport *server = smlTransportNew(SML_TRANSPORT_HTTP_SERVER, &error); @@ -1115,9 +1105,9 @@ smlManagerSetLocalMaxMsgSize(servertracker->manager, TEST_DEFAULT_MAX_MSG_SIZE); smlManagerSetLocalMaxObjSize(servertracker->manager, TEST_DEFAULT_MAX_OBJ_SIZE); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); sml_fail_unless(smlManagerStart(clientmanager, &error), NULL); sml_fail_unless(error == NULL, NULL); @@ -1241,7 +1231,7 @@ smlAuthSetEnable(auth2, FALSE); smlAuthRegister(auth2, servermanager, &error); - clienttracker->session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, NULL, 0, &error); + clienttracker->session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 0, 0, &error); smlSessionSetLocalMaxMsgSize(clienttracker->session, TEST_DEFAULT_MAX_MSG_SIZE); sml_fail_unless(smlSessionGetRemoteMaxObjSize(clienttracker->session) == 0, NULL); smlSessionSetLocalMaxObjSize(clienttracker->session, TEST_DEFAULT_MAX_OBJ_SIZE); @@ -1271,7 +1261,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } sml_fail_unless(smlSessionGetRemoteMaxMsgSize(servertracker->session) == TEST_DEFAULT_MAX_MSG_SIZE, NULL); @@ -1288,7 +1278,7 @@ smlDsSessionDispatch(servertracker->dssessions[1]); smlDsSessionDispatch(servertracker->dssessions[2]); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } SmlDevInf *recvClientDevInf = smlDevInfAgentGetSessionDevInf(serveragent, servertracker->session); @@ -1298,8 +1288,8 @@ sml_fail_unless(sml_dev_inf_get_support_large_objs(recvClientDevInf) == FALSE, NULL); sml_fail_unless(sml_dev_inf_get_support_utc(recvClientDevInf) == FALSE, NULL); - sml_fail_unless(smlDevInfAgentSendDevInf(serveragent, servertracker->session, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(smlDevInfAgentSendDevInf(serveragent, servertracker->session, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); smlDsSessionSendAlert(servertracker->dssessions[0], SML_ALERT_TWO_WAY, "last", "next", _alert_reply, GINT_TO_POINTER(1), &error); smlDsSessionSendAlert(servertracker->dssessions[1], SML_ALERT_TWO_WAY, "last", "next", _alert_reply, GINT_TO_POINTER(1), &error); @@ -1324,7 +1314,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } sml_fail_unless(smlSessionGetRemoteMaxMsgSize(clienttracker->session) == TEST_DEFAULT_MAX_MSG_SIZE, NULL); @@ -1377,7 +1367,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } for (k = 0; k < 3; k++) @@ -1418,7 +1408,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } unsigned int i = 0; @@ -1446,7 +1436,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } @@ -1467,7 +1457,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } sml_fail_unless(init_alerts_received == 3, NULL); @@ -1523,7 +1513,7 @@ smlManagerFree(servermanager); sml_fail_unless(smlTransportFinalize(server, &error), NULL); - sml_fail_unless(smlTransportFinalize(client, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportFinalize(client, &error), "%s", error->message); smlTransportFree(server); smlTransportFree(client); @@ -1542,19 +1532,19 @@ unsigned int num_items = 10; num_changes = 3 * num_items; - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; /* The OMA DS client is an OBEX server. */ SmlTransport *client = smlTransportNew(SML_TRANSPORT_OBEX_SERVER, &error); sml_fail_unless(smlTransportSetConnectionType(client, SML_TRANSPORT_CONNECTION_TYPE_NET, &error), NULL); - sml_fail_unless(smlTransportSetConfigOption(client, "PORT", "12010", &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportSetConfigOption(client, "PORT", "12010", &error), "%s", error->message); /* The OMA DS server is an OBEX client. */ SmlTransport *server = smlTransportNew(SML_TRANSPORT_OBEX_CLIENT, &error); - sml_fail_unless(smlTransportSetConnectionType(server, SML_TRANSPORT_CONNECTION_TYPE_NET, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportSetConfigOption(server, "PORT", "12010", &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportSetConfigOption(server, "URL", "127.0.0.1", &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportSetConnectionType(server, SML_TRANSPORT_CONNECTION_TYPE_NET, &error), "%s", error->message); + sml_fail_unless(smlTransportSetConfigOption(server, "PORT", "12010", &error), "%s", error->message); + sml_fail_unless(smlTransportSetConfigOption(server, "URL", "127.0.0.1", &error), "%s", error->message); managerTracker *clienttracker = g_malloc0(sizeof(managerTracker)); SmlManager *clientmanager = clienttracker->manager = smlManagerNew(client, &error); @@ -1570,8 +1560,8 @@ sml_fail_unless(smlManagerStart(servermanager, &error), NULL); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); SmlLocation *loc = sml_location_new_with_options("test", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); @@ -1647,7 +1637,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } sml_fail_unless(clienttracker->session != NULL, NULL); @@ -1665,7 +1655,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } smlDsSessionGetAlert(servertracker->dssessions[0], _recv_alert, GINT_TO_POINTER(1)); @@ -1695,7 +1685,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } const char *content_types[] = {SML_ELEMENT_TEXT_VCARD, SML_ELEMENT_TEXT_VCAL, SML_ELEMENT_TEXT_PLAIN}; @@ -1738,7 +1728,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } sml_fail_unless(servertracker->session != NULL, NULL); @@ -1751,7 +1741,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } sml_fail_unless(init_alerts_received == 3, NULL); @@ -1809,7 +1799,7 @@ smlManagerFree(clientmanager); smlManagerFree(servermanager); - sml_fail_unless(smlTransportFinalize(server, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportFinalize(server, &error), "%s", error->message); sml_fail_unless(smlTransportFinalize(client, &error), NULL); smlTransportFree(server); @@ -1828,7 +1818,7 @@ unsigned int num_items = 10; num_changes = 3 * num_items; - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlTransport *server = smlTransportNew(SML_TRANSPORT_OBEX_CLIENT, &error); @@ -1850,13 +1840,13 @@ smlManagerSetLocalMaxMsgSize(servertracker->manager, TEST_DEFAULT_MAX_MSG_SIZE); smlManagerSetLocalMaxObjSize(servertracker->manager, TEST_DEFAULT_MAX_OBJ_SIZE); - sml_fail_unless(smlManagerStart(clientmanager, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlManagerStart(clientmanager, &error), "%s", error->message); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(smlManagerStart(servermanager, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlManagerStart(servermanager, &error), "%s", error->message); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); SmlLocation *loc1 = sml_location_new_with_options("test1", NULL, &gerror); sml_fail_unless(loc1 != NULL, NULL); @@ -1919,8 +1909,8 @@ sml_fail_unless(smlDsServerAddSan(servertracker->ds[2], san, &error), NULL); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(smlNotificationSend(san, server, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(smlNotificationSend(san, server, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); smlNotificationFree(san); @@ -1928,7 +1918,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } sml_fail_unless(clienttracker->session != NULL, NULL); @@ -1944,7 +1934,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } smlDsSessionGetAlert(servertracker->dssessions[0], _recv_alert, GINT_TO_POINTER(1)); @@ -1974,7 +1964,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } const char *content_types[] = {SML_ELEMENT_TEXT_VCARD, SML_ELEMENT_TEXT_VCAL, SML_ELEMENT_TEXT_PLAIN}; @@ -1996,7 +1986,7 @@ smlDsSessionCloseSync(clienttracker->dssessions[k], &error); } - sml_fail_unless(smlSessionFlush(clienttracker->session, TRUE, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlSessionFlush(clienttracker->session, TRUE, &error), "%s", error->message); smlDsSessionGetSync(servertracker->dssessions[0], _recv_sync, GINT_TO_POINTER(1)); smlDsSessionGetSync(servertracker->dssessions[1], _recv_sync, GINT_TO_POINTER(1)); @@ -2017,11 +2007,11 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } sml_fail_unless(servertracker->session != NULL, NULL); - sml_fail_unless(smlSessionEnd(servertracker->session, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlSessionEnd(servertracker->session, &error), "%s", error->message); sml_fail_unless(error == NULL, NULL); smlSessionUnref(servertracker->session); smlSessionUnref(clienttracker->session); @@ -2030,7 +2020,7 @@ smlManagerDispatch(servermanager); smlManagerDispatch(clientmanager); usleep(100); - sml_fail_unless(eventError == NULL, "%s", smlErrorPrint(&eventError)); + sml_fail_unless(eventError == NULL, "%s", eventError->message); } sml_fail_unless(init_alerts_received == 3, NULL); @@ -2088,8 +2078,8 @@ smlManagerFree(clientmanager); smlManagerFree(servermanager); - sml_fail_unless(smlTransportFinalize(server, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportFinalize(client, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportFinalize(server, &error), "%s", error->message); + sml_fail_unless(smlTransportFinalize(client, &error), "%s", error->message); smlTransportFree(server); smlTransportFree(client); |
From: <svn...@op...> - 2009-07-13 12:02:39
|
Author: bellmich Date: Mon Jul 13 14:02:32 2009 New Revision: 1177 URL: http://libsyncml.opensync.org/changeset/1177 Log: migrated check_session from SmlError to GError Modified: trunk/tests/check_session.c Modified: trunk/tests/check_session.c ============================================================================== --- trunk/tests/check_session.c Mon Jul 13 14:01:07 2009 (r1176) +++ trunk/tests/check_session.c Mon Jul 13 14:02:32 2009 (r1177) @@ -154,7 +154,7 @@ { smlTrace(TRACE_INTERNAL, "%s(%p. %p, %p)", __func__, source, callback, user_data); SmlSessionThread *check = user_data; - SmlError *error = NULL; + GError *error = NULL; smlAssert(check != NULL); smlAssert(check->data != NULL); @@ -209,7 +209,7 @@ SmlSessionThread *smlSessionRunAsync(SmlSession *session, SmlTransportData **input) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, session, input); - SmlError *error = NULL; + GError *error = NULL; SmlSessionThread *thread = g_malloc0(sizeof(SmlSessionThread)); @@ -290,14 +290,14 @@ SmlManager* _start_manager() { - SmlError *error = NULL; + GError *error = NULL; _tsp = smlTransportNew(SML_TRANSPORT_HTTP_SERVER, &error); - sml_fail_unless(_tsp != NULL, "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(_tsp != NULL, "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); SmlManager *manager = smlManagerNew(_tsp, &error); - sml_fail_unless(manager != NULL, "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(manager != NULL, "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); smlManagerSetLocalMaxMsgSize(manager, defaultMaxMsgSize); smlManagerSetLocalMaxObjSize(manager, defaultMaxObjSize); @@ -316,14 +316,14 @@ { init_testbed(); - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); sml_fail_unless(session != NULL, NULL); sml_fail_unless(error == NULL, NULL); @@ -338,14 +338,14 @@ { init_testbed(); - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlCommand *cmd = smlCommandNewAlert(SML_ALERT_TWO_WAY, loc, loc, "last", "next", NULL, &error); sml_fail_unless(cmd != NULL, NULL); @@ -362,11 +362,11 @@ } END_TEST -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: %d (%p)", __func__, type, parent); smlAssert(GPOINTER_TO_INT(userdata) <= 5); - SmlError *locerror = NULL; + GError *locerror = NULL; switch (type) { case SML_SESSION_EVENT_HEADER_REPLY: @@ -462,7 +462,7 @@ if (GPOINTER_TO_INT(userdata) == 2) g_atomic_int_inc(&errors_received); else { - sml_fail_unless(FALSE, "%s", smlErrorPrint(&error)); + sml_fail_unless(FALSE, "%s", error->message); abort(); } break; @@ -533,14 +533,14 @@ { init_testbed(); - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session, &to_session); smlSessionSetDataCallback(session, _data_send_callback, &to_session2); @@ -575,14 +575,14 @@ { init_testbed(); - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session, &to_session); smlSessionSetDataCallback(session, _data_send_callback, &to_session2); @@ -618,7 +618,7 @@ { init_testbed(); - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); @@ -637,7 +637,7 @@ sml_fail_unless(header != NULL, NULL); sml_fail_unless(cred == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); smlSessionSetLocalMaxMsgSize(session, defaultMaxMsgSize); smlSessionSetLocalMaxObjSize(session, defaultMaxObjSize); @@ -672,14 +672,14 @@ { init_testbed(); - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session, &to_session); smlSessionSetDataCallback(session, _data_send_callback, &to_session2); @@ -713,7 +713,7 @@ SmlCred *cred = NULL; sml_fail_unless(smlParserGetHeader(parser, &header, &cred, &error), NULL); - SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); smlSessionSetLocalMaxMsgSize(session2, defaultMaxMsgSize); smlSessionSetLocalMaxObjSize(session2, defaultMaxObjSize); @@ -753,16 +753,16 @@ { init_testbed(); - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session, &to_session); - SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread2 = smlSessionRunAsync(session2, &to_session2); smlSessionSetLocalMaxMsgSize(session2, defaultMaxMsgSize); smlSessionSetLocalMaxObjSize(session2, defaultMaxObjSize); @@ -832,16 +832,16 @@ { init_testbed(); - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session, &to_session); - SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread2 = smlSessionRunAsync(session2, &to_session2); smlSessionSetLocalMaxMsgSize(session2, defaultMaxMsgSize); smlSessionSetLocalMaxObjSize(session2, defaultMaxObjSize); @@ -930,16 +930,16 @@ int num_commands = 1000; - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session, &to_session); - SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread2 = smlSessionRunAsync(session2, &to_session2); /* The test is not designed for splitted packages or objects. */ @@ -998,7 +998,7 @@ sml_fail_unless(end_received == 0, NULL); sml_fail_unless(smlSessionFlush(session, TRUE, &error), NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); /*while (finals_received != 3) { usleep(100); @@ -1050,16 +1050,16 @@ mutex = g_mutex_new(); - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session, &to_session); - SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread2 = smlSessionRunAsync(session2, &to_session2); smlSessionSetLocalMaxMsgSize(session, limit); @@ -1178,16 +1178,16 @@ mutex = g_mutex_new(); - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session, &to_session); - SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread2 = smlSessionRunAsync(session2, &to_session2); smlSessionSetLocalMaxMsgSize(session, limit); @@ -1280,16 +1280,16 @@ setup_testbed(NULL); - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session, &to_session); - SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread2 = smlSessionRunAsync(session2, &to_session2); smlSessionSetLocalMaxMsgSize(session, limit); @@ -1399,7 +1399,7 @@ { init_testbed(); - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); @@ -1418,7 +1418,7 @@ sml_fail_unless(header != NULL, NULL); sml_fail_unless(cred == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_11, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_11, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); smlSessionSetLocalMaxMsgSize(session, defaultMaxMsgSize); smlSessionSetLocalMaxObjSize(session, defaultMaxObjSize); @@ -1483,7 +1483,7 @@ { init_testbed(); - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); @@ -1502,7 +1502,7 @@ sml_fail_unless(header != NULL, NULL); sml_fail_unless(cred == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_11, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_11, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); smlSessionSetLocalMaxMsgSize(session, defaultMaxMsgSize); smlSessionSetLocalMaxObjSize(session, defaultMaxObjSize); @@ -1676,7 +1676,7 @@ { init_testbed(); - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); @@ -1695,7 +1695,7 @@ sml_fail_unless(header != NULL, NULL); sml_fail_unless(cred == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_11, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_11, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); smlSessionSetLocalMaxMsgSize(session, defaultMaxMsgSize); smlSessionSetLocalMaxObjSize(session, defaultMaxObjSize); @@ -1708,7 +1708,7 @@ session->established = TRUE; sml_fail_unless(!smlSessionReceiveBody(session, parser, &error), NULL); sml_fail_unless(error != NULL, NULL); - smlErrorDeref(&error); + SML_ERROR_FREE(error); smlParserFree(parser); smlHeaderFree(header); @@ -1727,7 +1727,7 @@ { init_testbed(); - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); @@ -1746,7 +1746,7 @@ sml_fail_unless(header != NULL, NULL); sml_fail_unless(cred == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_10, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_10, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); smlSessionSetLocalMaxMsgSize(session, defaultMaxMsgSize); smlSessionSetLocalMaxObjSize(session, defaultMaxObjSize); @@ -1762,7 +1762,7 @@ sml_fail_unless(!smlSessionReceiveBody(session, parser, &error), NULL); sml_fail_unless(error != NULL, NULL); - smlErrorDeref(&error); + SML_ERROR_FREE(error); smlParserFree(parser); smlHeaderFree(header); @@ -1785,7 +1785,7 @@ sml_fail_unless(header != NULL, NULL); sml_fail_unless(cred == NULL, NULL); - session = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_11, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + session = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_11, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); smlSessionSetLocalMaxMsgSize(session, defaultMaxMsgSize); smlSessionSetLocalMaxObjSize(session, defaultMaxObjSize); @@ -1825,7 +1825,7 @@ { init_testbed(); - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); @@ -1844,7 +1844,7 @@ sml_fail_unless(header != NULL, NULL); sml_fail_unless(cred == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_10, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_10, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); smlSessionSetLocalMaxMsgSize(session, defaultMaxMsgSize); smlSessionSetLocalMaxObjSize(session, defaultMaxObjSize); @@ -1860,7 +1860,7 @@ sml_fail_unless(!smlSessionReceiveBody(session, parser, &error), NULL); sml_fail_unless(error != NULL, NULL); - smlErrorDeref(&error); + SML_ERROR_FREE(error); smlParserFree(parser); smlHeaderFree(header); @@ -1887,7 +1887,7 @@ { init_testbed(); - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); @@ -1906,7 +1906,7 @@ sml_fail_unless(header != NULL, NULL); sml_fail_unless(cred == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_11, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_11, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); smlSessionSetLocalMaxMsgSize(session, defaultMaxMsgSize); smlSessionSetLocalMaxObjSize(session, defaultMaxObjSize); @@ -1922,7 +1922,7 @@ sml_fail_unless(!smlSessionReceiveBody(session, parser, &error), NULL); sml_fail_unless(error != NULL, NULL); - smlErrorDeref(&error); + SML_ERROR_FREE(error); smlParserFree(parser); smlHeaderFree(header); @@ -1943,7 +1943,7 @@ { init_testbed(); - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); @@ -1962,7 +1962,7 @@ sml_fail_unless(header != NULL, NULL); sml_fail_unless(cred == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_11, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_11, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); smlSessionSetLocalMaxMsgSize(session, defaultMaxMsgSize); smlSessionSetLocalMaxObjSize(session, defaultMaxObjSize); @@ -2010,7 +2010,7 @@ sml_fail_unless(!smlSessionReceiveBody(session, parser, &error), NULL); sml_fail_unless(error != NULL, NULL); - smlErrorDeref(&error); + SML_ERROR_FREE(error); smlParserFree(parser); smlHeaderFree(header); @@ -2029,7 +2029,7 @@ { init_testbed(); - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); @@ -2048,7 +2048,7 @@ sml_fail_unless(header != NULL, NULL); sml_fail_unless(cred == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_11, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_11, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); smlSessionSetLocalMaxMsgSize(session, defaultMaxMsgSize); smlSessionSetLocalMaxObjSize(session, defaultMaxObjSize); @@ -2096,7 +2096,7 @@ sml_fail_unless(!smlSessionReceiveBody(session, parser, &error), NULL); sml_fail_unless(error != NULL, NULL); - smlErrorDeref(&error); + SML_ERROR_FREE(error); smlParserFree(parser); smlHeaderFree(header); @@ -2115,7 +2115,7 @@ { init_testbed(); - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); @@ -2134,7 +2134,7 @@ sml_fail_unless(header != NULL, NULL); sml_fail_unless(cred == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_11, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_11, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); smlSessionSetLocalMaxMsgSize(session, defaultMaxMsgSize); smlSessionSetLocalMaxObjSize(session, defaultMaxObjSize); @@ -2182,7 +2182,7 @@ sml_fail_unless(!smlSessionReceiveBody(session, parser, &error), NULL); sml_fail_unless(error != NULL, NULL); - smlErrorDeref(&error); + SML_ERROR_FREE(error); smlParserFree(parser); smlHeaderFree(header); @@ -2204,16 +2204,16 @@ int limit = 1000; int objlength = 600; - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session, &to_session); - SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread2 = smlSessionRunAsync(session2, &to_session2); smlSessionSetEventCallback(session2, _event_callback, GINT_TO_POINTER(5)); @@ -2289,16 +2289,16 @@ int limit = 1000; int objlength = 4000; - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session, &to_session); - SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread2 = smlSessionRunAsync(session2, &to_session2); smlSessionSetEventCallback(session2, _event_callback, GINT_TO_POINTER(5)); @@ -2366,16 +2366,16 @@ int objlength = 1500; int num_obj = 10; - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session, &to_session); - SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread2 = smlSessionRunAsync(session2, &to_session2); smlSessionSetEventCallback(session2, _event_callback, GINT_TO_POINTER(5)); @@ -2446,16 +2446,16 @@ int objlength = 1500; int num_obj = 5; - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session, &to_session); - SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread2 = smlSessionRunAsync(session2, &to_session2); smlSessionSetEventCallback(session2, _event_callback, GINT_TO_POINTER(5)); @@ -2530,16 +2530,16 @@ { init_testbed(); - SmlError *error = NULL; + GError *error = NULL; GError *gerror = NULL; SmlLocation *loc = sml_location_new_with_options("/test", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session, &to_session); - SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread2 = smlSessionRunAsync(session2, &to_session2); smlSessionSetLocalMaxMsgSize(session2, defaultMaxMsgSize); @@ -2551,8 +2551,8 @@ smlSessionSetDataCallback(session, _data_send_callback, &to_session2); SmlNotification *san = smlNotificationNew(SML_SAN_VERSION_11, SML_SAN_UIMODE_USER, SML_SAN_INITIATOR_SERVER, 65535, "test", "/", SML_MIMETYPE_XML, &error); - sml_fail_unless(san != NULL, "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(san != NULL, "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); SmlManager *manager = _start_manager(); smlNotificationSetManager(san, manager); |
From: <svn...@op...> - 2009-07-13 12:01:16
|
Author: bellmich Date: Mon Jul 13 14:01:07 2009 New Revision: 1176 URL: http://libsyncml.opensync.org/changeset/1176 Log: migrated check_san from SmlError to GError Modified: trunk/tests/check_san.c Modified: trunk/tests/check_san.c ============================================================================== --- trunk/tests/check_san.c Mon Jul 13 14:00:10 2009 (r1175) +++ trunk/tests/check_san.c Mon Jul 13 14:01:07 2009 (r1176) @@ -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 @@ -20,6 +20,7 @@ */ #include "tests/support.h" +#include "libsyncml/sml_error_internals.h" /* If the notification is a normal SyncML message then a manager is * required. The easiest way are two function which create and destroy @@ -33,14 +34,14 @@ unsigned int defaultMaxMsgSize = 10240; unsigned int defaultMaxObjSize = 1024000; - SmlError *error = NULL; + GError *error = NULL; _tsp = smlTransportNew(SML_TRANSPORT_HTTP_SERVER, &error); - sml_fail_unless(_tsp != NULL, "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(_tsp != NULL, "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); SmlManager *manager = smlManagerNew(_tsp, &error); - sml_fail_unless(manager != NULL, "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(manager != NULL, "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); smlManagerSetLocalMaxMsgSize(manager, defaultMaxMsgSize); smlManagerSetLocalMaxObjSize(manager, defaultMaxObjSize); @@ -58,7 +59,7 @@ { setup_testbed(NULL); - SmlError *error = NULL; + GError *error = NULL; SmlNotification *san = smlNotificationNew(SML_SAN_VERSION_12, SML_SAN_UIMODE_USER, SML_SAN_INITIATOR_USER, 0, "test", "/", SML_MIMETYPE_UNKNOWN, &error); sml_fail_unless(san != NULL, NULL); sml_fail_unless(error == NULL, NULL); @@ -71,7 +72,7 @@ { setup_testbed(NULL); - SmlError *error = NULL; + GError *error = NULL; SmlNotification *san = smlNotificationNew(SML_SAN_VERSION_12, SML_SAN_UIMODE_UNSPECIFIED, SML_SAN_INITIATOR_USER, 0, "tttt", "/", SML_MIMETYPE_UNKNOWN, &error); sml_fail_unless(san != NULL, NULL); sml_fail_unless(error == NULL, NULL); @@ -104,7 +105,7 @@ { setup_testbed(NULL); - SmlError *error = NULL; + GError *error = NULL; SmlNotification *san = smlNotificationNew(SML_SAN_VERSION_12, SML_SAN_UIMODE_USER, SML_SAN_INITIATOR_SERVER, 65535, "ttttt", "/", SML_MIMETYPE_UNKNOWN, &error); sml_fail_unless(san != NULL, NULL); sml_fail_unless(error == NULL, NULL); @@ -137,7 +138,7 @@ { setup_testbed(NULL); - SmlError *error = NULL; + GError *error = NULL; SmlNotification *san = smlNotificationNew(SML_SAN_VERSION_12, SML_SAN_UIMODE_USER, SML_SAN_INITIATOR_SERVER, 65535, "ttttt", "/", SML_MIMETYPE_UNKNOWN, &error); sml_fail_unless(san != NULL, NULL); sml_fail_unless(error == NULL, NULL); @@ -176,7 +177,7 @@ { setup_testbed(NULL); - SmlError *error = NULL; + GError *error = NULL; SmlNotification *san = smlNotificationNew(SML_SAN_VERSION_12, SML_SAN_UIMODE_USER, SML_SAN_INITIATOR_SERVER, 65535, "ttttt", "/", SML_MIMETYPE_UNKNOWN, &error); sml_fail_unless(san != NULL, NULL); sml_fail_unless(error == NULL, NULL); @@ -221,7 +222,7 @@ { setup_testbed(NULL); - SmlError *error = NULL; + GError *error = NULL; SmlNotification *san = smlNotificationNew(SML_SAN_VERSION_12, SML_SAN_UIMODE_USER, SML_SAN_INITIATOR_SERVER, 65535, "OpenSync", "/", SML_MIMETYPE_UNKNOWN, &error); sml_fail_unless(san != NULL, NULL); sml_fail_unless(error == NULL, NULL); @@ -265,7 +266,7 @@ { setup_testbed(NULL); - SmlError *error = NULL; + GError *error = NULL; SmlNotification *san = smlNotificationNew(SML_SAN_VERSION_11, SML_SAN_UIMODE_USER, SML_SAN_INITIATOR_SERVER, 65535, "ttttt", "/", SML_MIMETYPE_XML, &error); sml_fail_unless(san != NULL, NULL); sml_fail_unless(error == NULL, NULL); @@ -330,7 +331,7 @@ 0x00, 0x00, 0x07, //Content type 0x05, 0x74, 0x74, 0x74, 0x74, 0x00 }; //Server URI; - SmlError *error = NULL; + GError *error = NULL; SmlNotification *san = smlNotificationParse((char *) target, sizeof(target), &error); sml_fail_unless(san != NULL, NULL); sml_fail_unless(error == NULL, NULL); @@ -369,7 +370,7 @@ 0x00, //server identifier 0x00}; //num syncs - SmlError *error = NULL; + GError *error = NULL; SmlNotification *san = smlNotificationParse((char *) target, sizeof(target), &error); sml_fail_unless(san != NULL, NULL); sml_fail_unless(error == NULL, NULL); @@ -396,11 +397,11 @@ 0x00, 0x00, //Session id 0x00}; //num syncs - SmlError *error = NULL; + GError *error = NULL; SmlNotification *san = smlNotificationParse((char *) target, sizeof(target), &error); sml_fail_unless(san == NULL, NULL); sml_fail_unless(error != NULL, NULL); - smlErrorDeref(&error); + SML_ERROR_FREE(error); } END_TEST @@ -415,11 +416,11 @@ 0x01, //server identifier 0x00}; //num syncs - SmlError *error = NULL; + GError *error = NULL; SmlNotification *san = smlNotificationParse((char *) target, sizeof(target), &error); sml_fail_unless(san == NULL, NULL); sml_fail_unless(error != NULL, NULL); - smlErrorDeref(&error); + SML_ERROR_FREE(error); } END_TEST @@ -434,11 +435,11 @@ 0x01, 0x00,//server identifier 0x10}; //num syncs - SmlError *error = NULL; + GError *error = NULL; SmlNotification *san = smlNotificationParse((char *) target, sizeof(target), &error); sml_fail_unless(san == NULL, NULL); sml_fail_unless(error != NULL, NULL); - smlErrorDeref(&error); + SML_ERROR_FREE(error); } END_TEST @@ -453,11 +454,11 @@ 0x01, 0x00,//server identifier 0x00}; //num syncs - SmlError *error = NULL; + GError *error = NULL; SmlNotification *san = smlNotificationParse(target, sizeof(target), &error); sml_fail_unless(san == NULL, NULL); sml_fail_unless(error != NULL, NULL); - smlErrorDeref(&error); + SML_ERROR_FREE(error); } END_TEST @@ -475,11 +476,11 @@ 0x00, 0x00, 0x07, //Content type 0x05, 0x74, 0x74, 0x74, 0x74, 0x00}; //Server URI; - SmlError *error = NULL; + GError *error = NULL; SmlNotification *san = smlNotificationParse((char *) target, sizeof(target), &error); sml_fail_unless(san == NULL, NULL); sml_fail_unless(error != NULL, NULL); - smlErrorDeref(&error); + SML_ERROR_FREE(error); } END_TEST @@ -497,11 +498,11 @@ 0x00, 0x00, 0x07, //Content type 0x01}; //Server URI; - SmlError *error = NULL; + GError *error = NULL; SmlNotification *san = smlNotificationParse((char *) target, sizeof(target), &error); sml_fail_unless(san == NULL, NULL); sml_fail_unless(error != NULL, NULL); - smlErrorDeref(&error); + SML_ERROR_FREE(error); } END_TEST @@ -519,11 +520,11 @@ 0x00, 0x00, 0x07, //Content type 0x01, 0x00, 0x00}; //Server URI; - SmlError *error = NULL; + GError *error = NULL; SmlNotification *san = smlNotificationParse((char *) target, sizeof(target), &error); sml_fail_unless(san == NULL, NULL); sml_fail_unless(error != NULL, NULL); - smlErrorDeref(&error); + SML_ERROR_FREE(error); } END_TEST @@ -531,7 +532,7 @@ { setup_testbed(NULL); - SmlError *error = NULL; + GError *error = NULL; SmlNotification *san = smlNotificationNew(SML_SAN_VERSION_12, SML_SAN_UIMODE_USER, SML_SAN_INITIATOR_SERVER, 65535, "ttttt", "/", &error); sml_fail_unless(san != NULL, NULL); sml_fail_unless(error == NULL, NULL); @@ -547,7 +548,7 @@ sml_fail_unless(smlNotificationAssemble(san, &buffer, &size, &error), NULL); sml_fail_unless(error == NULL, NULL); - SmlBool smlNotificationSend(SmlNotification *san, SmlTransport *tsp, SmlTransportSendCb callback, void *userdata, SmlError **error) + gboolean smlNotificationSend(SmlNotification *san, SmlTransport *tsp, SmlTransportSendCb callback, void *userdata, GError **error) sml_fail_unless(size == sizeof(target), NULL); |
From: <svn...@op...> - 2009-07-13 12:00:18
|
Author: bellmich Date: Mon Jul 13 14:00:10 2009 New Revision: 1175 URL: http://libsyncml.opensync.org/changeset/1175 Log: migrated check_obex from SmlError to GError Modified: trunk/tests/check_obex.c Modified: trunk/tests/check_obex.c ============================================================================== --- trunk/tests/check_obex.c Mon Jul 13 13:57:22 2009 (r1174) +++ trunk/tests/check_obex.c Mon Jul 13 14:00:10 2009 (r1175) @@ -23,6 +23,7 @@ #include <libsyncml/sml_transport_internals.h> #include <libsyncml/transports/obex_internals.h> +#include <libsyncml/sml_error_internals.h> START_TEST (obex_get_result_macro) { @@ -55,10 +56,10 @@ { setup_testbed(NULL); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *tsp = smlTransportNew(SML_TRANSPORT_OBEX_CLIENT, &error); sml_fail_unless(tsp != NULL, NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); smlTransportFree(tsp); } @@ -68,19 +69,19 @@ { setup_testbed(NULL); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *tsp = smlTransportNew(SML_TRANSPORT_OBEX_CLIENT, &error); sml_fail_unless(tsp != NULL, NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); sml_fail_unless(smlTransportSetConfigOption(tsp, "URL", "127.0.0.1", &error), NULL); sml_fail_unless(smlTransportSetConnectionType(tsp, SML_TRANSPORT_CONNECTION_TYPE_NET, &error), NULL); - sml_fail_unless(smlTransportInitialize(tsp, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(tsp, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); sml_fail_unless(smlTransportFinalize(tsp, &error), NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); smlTransportFree(tsp); } @@ -90,10 +91,10 @@ { setup_testbed(NULL); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *tsp = smlTransportNew(SML_TRANSPORT_OBEX_SERVER, &error); sml_fail_unless(tsp != NULL, NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); smlTransportFree(tsp); } @@ -104,7 +105,7 @@ int client_receives = 0; int client_errors = 0; -SmlBool _recv_client_event(SmlTransport *tsp, SmlLink *link_, SmlTransportEventType type, SmlTransportData *data, SmlError *error, void *userdata) +gboolean _recv_client_event(SmlTransport *tsp, SmlLink *link_, SmlTransportEventType type, SmlTransportData *data, const GError *error, void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %d)", __func__, tsp, link_, type); @@ -140,10 +141,12 @@ int server_disconnect_done = 0; int server_receives = 0; -SmlBool _recv_server_event(SmlTransport *tsp, SmlLink *link_, SmlTransportEventType type, SmlTransportData *data, SmlError *error, void *userdata) +gboolean _recv_server_event(SmlTransport *tsp, SmlLink *link_, SmlTransportEventType type, SmlTransportData *data, const GError *error, void *userdata) { smlTrace(TRACE_ENTRY, "%s(%d, %p)", __func__, type, error); - + + GError *locerror = NULL; + switch (type) { case SML_TRANSPORT_EVENT_DATA: g_atomic_int_inc(&server_receives); @@ -154,20 +157,20 @@ sml_fail_unless(link_ != NULL, NULL); if (GPOINTER_TO_INT(userdata) == 1) { - data = smlTransportDataNew((char *)"answer", 7, SML_MIMETYPE_XML, FALSE, &error); + data = smlTransportDataNew((char *)"answer", 7, SML_MIMETYPE_XML, FALSE, &locerror); sml_fail_unless(data != NULL, NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(locerror == NULL, "%s", locerror->message); - sml_fail_unless(smlTransportSend(tsp, link_, data, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportSend(tsp, link_, data, &locerror), "%s", locerror->message); smlTransportDataDeref(data); } else if (GPOINTER_TO_INT(userdata) == 2) { - SmlError *newerror = NULL; - smlErrorSet(&newerror, SML_ERROR_GENERIC, "test"); - smlTransportSetError(tsp, link_, &newerror); - smlErrorDeref(&newerror); + GError *newerror = NULL; + SML_SET_ERROR(&newerror, SML_ERROR_GENERIC, "test"); + smlTransportSendError(tsp, link_, newerror); + SML_ERROR_FREE(newerror); } else if (GPOINTER_TO_INT(userdata) == 3) { - sml_fail_unless(smlTransportDisconnect(tsp, link_, &error), NULL); + sml_fail_unless(smlTransportDisconnect(tsp, link_, &locerror), NULL); } else { sml_fail_unless(FALSE, "The userdata %d was not expected.", GPOINTER_TO_INT(userdata)); } @@ -176,10 +179,10 @@ sml_fail_unless(data->type == SML_MIMETYPE_XML, NULL); sml_fail_unless(link_ != NULL, NULL); - SmlError *newerror = NULL; - smlErrorSet(&newerror, SML_ERROR_GENERIC, "test2"); - smlTransportSetError(tsp, link_, &newerror); - smlErrorDeref(&newerror); + GError *newerror = NULL; + SML_SET_ERROR(&newerror, SML_ERROR_GENERIC, "test2"); + smlTransportSendError(tsp, link_, newerror); + SML_ERROR_FREE(newerror); } else { sml_fail_unless(FALSE, "The received data was not expected (%s).", data->data); } @@ -195,7 +198,7 @@ g_atomic_int_inc(&server_disconnect_done); break; case SML_TRANSPORT_EVENT_ERROR: - sml_fail_unless(FALSE, "%s", smlErrorPrint(&error)); + sml_fail_unless(FALSE, "%s", error->message); break; default: sml_fail_unless(FALSE, "An unexpected transport event %d was received.", type); @@ -225,13 +228,13 @@ { setup_testbed(NULL); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *tsp = smlTransportNew(SML_TRANSPORT_OBEX_SERVER, &error); sml_fail_unless(tsp != NULL, NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); sml_fail_unless(smlTransportSetConnectionType(tsp, SML_TRANSPORT_CONNECTION_TYPE_NET, &error), NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); /* Don't use the default port 650 here because this is a reserved port in Unix. * Therefore the port is usually only allowed for the root user. @@ -240,11 +243,11 @@ smlTransportSetEventCallback(tsp, _recv_server_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(tsp, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(tsp, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); - sml_fail_unless(smlTransportFinalize(tsp, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportFinalize(tsp, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); smlTransportFree(tsp); } @@ -254,7 +257,7 @@ { reset_testbed(); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *server = smlTransportNew(SML_TRANSPORT_OBEX_SERVER, &error); SmlTransport *client = smlTransportNew(SML_TRANSPORT_OBEX_CLIENT, &error); @@ -268,17 +271,17 @@ smlTransportSetEventCallback(client, _recv_client_event, GINT_TO_POINTER(1)); smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); sml_fail_unless(smlTransportConnect(client, &error), NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); while (client_connect_done < 1 || server_connect_done < 1) { usleep(50); }; sml_fail_unless(smlTransportDisconnect(client, NULL, &error), NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); while (client_disconnect_done < 1 || server_disconnect_done < 1) { usleep(50); }; @@ -301,7 +304,7 @@ { reset_testbed(); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *server = smlTransportNew(SML_TRANSPORT_OBEX_SERVER, &error); SmlTransport *client = smlTransportNew(SML_TRANSPORT_OBEX_CLIENT, &error); @@ -315,28 +318,28 @@ smlTransportSetEventCallback(client, _recv_client_event, GINT_TO_POINTER(1)); smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(3)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); sml_fail_unless(smlTransportConnect(client, &error), NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); while (client_connect_done < 1 || server_connect_done < 1) { usleep(50); }; SmlTransportData *data = smlTransportDataNew((char *)"test", 5, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); - sml_fail_unless(smlTransportSend(client, NULL, data, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportSend(client, NULL, data, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); smlTransportDataDeref(data); while (server_receives < 1) { usleep(50); }; sml_fail_unless(smlTransportDisconnect(client, NULL, &error), NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); while ((client_disconnect_done < 1 || server_disconnect_done < 1 @@ -379,7 +382,7 @@ { reset_testbed(); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *server = smlTransportNew(SML_TRANSPORT_OBEX_SERVER, &error); SmlTransport *client = smlTransportNew(SML_TRANSPORT_OBEX_CLIENT, &error); @@ -393,26 +396,26 @@ smlTransportSetEventCallback(client, _recv_client_event, GINT_TO_POINTER(1)); smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); sml_fail_unless(smlTransportConnect(client, &error), NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); while (client_connect_done < 1 || server_connect_done < 1) { usleep(50); }; SmlTransportData *data = smlTransportDataNew((char *)"test", 5, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); - sml_fail_unless(smlTransportSend(client, NULL, data, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportSend(client, NULL, data, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); smlTransportDataDeref(data); sml_fail_unless(smlTransportDisconnect(client, NULL, &error), NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); while (client_disconnect_done < 1 || server_disconnect_done < 1) { usleep(50); }; @@ -438,7 +441,7 @@ int num = 10; - SmlError *error = NULL; + GError *error = NULL; SmlTransport *server = smlTransportNew(SML_TRANSPORT_OBEX_SERVER, &error); SmlTransport *client = smlTransportNew(SML_TRANSPORT_OBEX_CLIENT, &error); @@ -452,12 +455,12 @@ smlTransportSetEventCallback(client, _recv_client_event, GINT_TO_POINTER(1)); smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); sml_fail_unless(smlTransportConnect(client, &error), NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); while (client_connect_done < 1 || server_connect_done < 1) { usleep(50); }; @@ -467,10 +470,10 @@ for (i = 0; i < num; i++) { data = smlTransportDataNew((char *)"test", 5, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); - sml_fail_unless(smlTransportSend(client, NULL, data, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportSend(client, NULL, data, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); smlTransportDataDeref(data); @@ -482,7 +485,7 @@ } sml_fail_unless(smlTransportDisconnect(client, NULL, &error), NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); while (client_disconnect_done < 1 || server_disconnect_done < 1) { usleep(50); }; @@ -506,7 +509,7 @@ { reset_testbed(); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *server = smlTransportNew(SML_TRANSPORT_OBEX_SERVER, &error); SmlTransport *client1 = smlTransportNew(SML_TRANSPORT_OBEX_CLIENT, &error); SmlTransport *client2 = smlTransportNew(SML_TRANSPORT_OBEX_CLIENT, &error); @@ -532,44 +535,44 @@ smlTransportSetEventCallback(client3, _recv_client_event, GINT_TO_POINTER(1)); smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client1, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(client2, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(client3, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(client1, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(client2, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(client3, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); sml_fail_unless(smlTransportConnect(client1, &error), NULL); sml_fail_unless(smlTransportConnect(client2, &error), NULL); sml_fail_unless(smlTransportConnect(client3, &error), NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); while (client_connect_done < 3 || server_connect_done < 3) { usleep(50); }; SmlTransportData *data = smlTransportDataNew((char *)"test", 5, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportSend(client1, NULL, data, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); + sml_fail_unless(smlTransportSend(client1, NULL, data, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); smlTransportDataDeref(data); data = smlTransportDataNew((char *)"test", 5, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportSend(client2, NULL, data, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); + sml_fail_unless(smlTransportSend(client2, NULL, data, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); smlTransportDataDeref(data); data = smlTransportDataNew((char *)"test", 5, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportSend(client3, NULL, data, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); + sml_fail_unless(smlTransportSend(client3, NULL, data, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); smlTransportDataDeref(data); sml_fail_unless(smlTransportDisconnect(client1, NULL, &error), NULL); sml_fail_unless(smlTransportDisconnect(client2, NULL, &error), NULL); sml_fail_unless(smlTransportDisconnect(client3, NULL, &error), NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); while (client_disconnect_done < 3 || server_disconnect_done < 3) { usleep(50); }; @@ -599,7 +602,7 @@ int num = 1000; - SmlError *error = NULL; + GError *error = NULL; SmlTransport *server = smlTransportNew(SML_TRANSPORT_OBEX_SERVER, &error); SmlTransport *client1 = smlTransportNew(SML_TRANSPORT_OBEX_CLIENT, &error); SmlTransport *client2 = smlTransportNew(SML_TRANSPORT_OBEX_CLIENT, &error); @@ -626,20 +629,20 @@ smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(1)); /* Always start the server first. */ - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(client1, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(client2, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(client3, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); + sml_fail_unless(smlTransportInitialize(client1, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); + sml_fail_unless(smlTransportInitialize(client2, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); + sml_fail_unless(smlTransportInitialize(client3, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); sml_fail_unless(smlTransportConnect(client1, &error), NULL); sml_fail_unless(smlTransportConnect(client2, &error), NULL); sml_fail_unless(smlTransportConnect(client3, &error), NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); while (client_connect_done < 3 || server_connect_done < 3) { usleep(50); }; @@ -649,23 +652,23 @@ for (i = 0; i < num; i++) { data = smlTransportDataNew((char *)"test", 5, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportSend(client1, NULL, data, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); + sml_fail_unless(smlTransportSend(client1, NULL, data, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); smlTransportDataDeref(data); data = smlTransportDataNew((char *)"test", 5, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportSend(client2, NULL, data, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); + sml_fail_unless(smlTransportSend(client2, NULL, data, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); smlTransportDataDeref(data); data = smlTransportDataNew((char *)"test", 5, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportSend(client3, NULL, data, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); + sml_fail_unless(smlTransportSend(client3, NULL, data, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); smlTransportDataDeref(data); while (1) { @@ -678,7 +681,7 @@ sml_fail_unless(smlTransportDisconnect(client1, NULL, &error), NULL); sml_fail_unless(smlTransportDisconnect(client2, NULL, &error), NULL); sml_fail_unless(smlTransportDisconnect(client3, NULL, &error), NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); while (client_disconnect_done < 3 || server_disconnect_done < 3) { usleep(50); }; @@ -706,7 +709,7 @@ { reset_testbed(); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *client = smlTransportNew(SML_TRANSPORT_OBEX_CLIENT, &error); sml_fail_unless(smlTransportSetConfigOption(client, "URL", "127.0.0.1", &error), NULL); @@ -715,18 +718,18 @@ smlTransportSetEventCallback(client, _recv_client_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); sml_fail_unless(smlTransportConnect(client, &error), NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); sleep(1); while (client_errors < 1) { usleep(50); }; sml_fail_unless(!smlTransportDisconnect(client, NULL, &error), NULL); sml_fail_unless(error != NULL, NULL); - smlErrorDeref(&error); + SML_ERROR_FREE(error); /* The client is stateful and so disconnect is false * because the client was never connected. @@ -747,7 +750,7 @@ { reset_testbed(); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *server = smlTransportNew(SML_TRANSPORT_OBEX_SERVER, &error); SmlTransport *client = smlTransportNew(SML_TRANSPORT_OBEX_CLIENT, &error); @@ -761,18 +764,18 @@ smlTransportSetEventCallback(client, _recv_client_event, GINT_TO_POINTER(1)); smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(4)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); sml_fail_unless(smlTransportConnect(client, &error), NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); while (client_errors < 1 || server_connect_done < 1) { usleep(50); }; sml_fail_unless(!smlTransportDisconnect(client, NULL, &error), NULL); sml_fail_unless(error != NULL, NULL); - smlErrorDeref(&error); + SML_ERROR_FREE(error); while (server_disconnect_done < 1) { usleep(50); }; @@ -796,7 +799,7 @@ { reset_testbed(); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *server = smlTransportNew(SML_TRANSPORT_OBEX_SERVER, &error); SmlTransport *client1 = smlTransportNew(SML_TRANSPORT_OBEX_CLIENT, &error); SmlTransport *client2 = smlTransportNew(SML_TRANSPORT_OBEX_CLIENT, &error); @@ -822,44 +825,44 @@ smlTransportSetEventCallback(client3, _recv_client_event, GINT_TO_POINTER(1)); smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client1, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(client2, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(client3, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(client1, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(client2, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(client3, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); sml_fail_unless(smlTransportConnect(client1, &error), NULL); sml_fail_unless(smlTransportConnect(client2, &error), NULL); sml_fail_unless(smlTransportConnect(client3, &error), NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); while (client_connect_done < 3 || server_connect_done < 3) { usleep(50); }; SmlTransportData *data = smlTransportDataNew((char *)"test", 5, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportSend(client1, NULL, data, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); + sml_fail_unless(smlTransportSend(client1, NULL, data, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); smlTransportDataDeref(data); data = smlTransportDataNew((char *)"error", 6, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportSend(client2, NULL, data, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); + sml_fail_unless(smlTransportSend(client2, NULL, data, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); smlTransportDataDeref(data); data = smlTransportDataNew((char *)"error", 6, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportSend(client3, NULL, data, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); + sml_fail_unless(smlTransportSend(client3, NULL, data, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); smlTransportDataDeref(data); sml_fail_unless(smlTransportDisconnect(client1, NULL, &error), NULL); sml_fail_unless(smlTransportDisconnect(client2, NULL, &error), NULL); sml_fail_unless(smlTransportDisconnect(client3, NULL, &error), NULL); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(error == NULL, "%s", error->message); while (client_disconnect_done < 3 || server_disconnect_done < 3) { usleep(50); }; |
From: <svn...@op...> - 2009-07-13 11:57:28
|
Author: bellmich Date: Mon Jul 13 13:57:22 2009 New Revision: 1174 URL: http://libsyncml.opensync.org/changeset/1174 Log: migrated mobile tests from SmlError to GError Modified: trunk/tests/mobiles/libsyncml_ds_server.c trunk/tests/mobiles/obex_mobile_ds_client.c Modified: trunk/tests/mobiles/libsyncml_ds_server.c ============================================================================== --- trunk/tests/mobiles/libsyncml_ds_server.c Mon Jul 13 13:53:42 2009 (r1173) +++ trunk/tests/mobiles/libsyncml_ds_server.c Mon Jul 13 13:57:22 2009 (r1174) @@ -44,13 +44,15 @@ SmlDataSyncObject *dsObject, SmlDataSyncEventType type, void *userdata, - SmlError *error) + const GError *error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p, %p)", __func__, dsObject, type, userdata, error); + + GError *locerror = NULL; switch (type) { case SML_DATA_SYNC_EVENT_ERROR: - sml_fail_unless(FALSE, "%s", smlErrorPrint(&error)); + sml_fail_unless(FALSE, "%s", error->message); smlAssert(FALSE); break; case SML_DATA_SYNC_EVENT_CONNECT: @@ -63,8 +65,8 @@ break; case SML_DATA_SYNC_EVENT_GOT_ALL_CHANGES: sml_fail_unless( - smlDataSyncSendChanges(dsObject, &error), - "%s", smlErrorPrint(&error)); + smlDataSyncSendChanges(dsObject, &locerror), + "%s", locerror->message); break; default: sml_fail_unless(FALSE, "The unexpected data sync event %d was received.", type); @@ -73,7 +75,7 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -static SmlBool _recv_change( +static gboolean _recv_change( SmlDataSyncObject *dsObject, const char *source, SmlChangeType type, @@ -81,7 +83,7 @@ char *data, unsigned int size, void *userdata, - SmlError **error) + GError **error) { smlTrace(TRACE_INTERNAL, "%s: %s ==> %s (%p, %d, %p, %d, %p, %p)", __func__, VA_STRING(source), VA_STRING(uid), dsObject, type, data, size, userdata, error); smlSafeCFree(&data); @@ -92,13 +94,13 @@ void libsyncml_connect() { - SmlError *error = NULL; + GError *error = NULL; dsObject = smlDataSyncNew( SML_SESSION_TYPE_SERVER, tspType, &error); - sml_fail_unless(dsObject != NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(dsObject != NULL, "%s", error->message); switch(tspType) { @@ -109,13 +111,13 @@ SML_DATA_SYNC_CONFIG_CONNECTION_TYPE, SML_DATA_SYNC_CONFIG_CONNECTION_NET, &error), - "%s", smlErrorPrint(&error)); + "%s", error->message); sml_fail_unless( smlDataSyncSetOption( dsObject, SML_TRANSPORT_CONFIG_PORT, obex_port, &error), - "%s", smlErrorPrint(&error)); + "%s", error->message); break; default: sml_fail_unless(FALSE, "The unsupported transport type %d was used for testing.", tspType); @@ -126,43 +128,43 @@ dsObject, SML_TRANSPORT_CONFIG_URL, "127.0.0.1", &error), - "%s", smlErrorPrint(&error)); + "%s", error->message); sml_fail_unless( smlDataSyncSetOption( dsObject, SML_DATA_SYNC_CONFIG_MAX_MSG_SIZE, maxMsgSize, &error), - "%s", smlErrorPrint(&error)); + "%s", error->message); sml_fail_unless( smlDataSyncSetOption( dsObject, SML_DATA_SYNC_CONFIG_MAX_OBJ_SIZE, maxObjSize, &error), - "%s", smlErrorPrint(&error)); + "%s", error->message); sml_fail_unless( smlDataSyncSetOption( dsObject, SML_DATA_SYNC_CONFIG_USE_WBXML, enableWbxml, &error), - "%s", smlErrorPrint(&error)); + "%s", error->message); sml_fail_unless( smlDataSyncSetOption( dsObject, SML_DATA_SYNC_CONFIG_IDENTIFIER, identifier, &error), - "%s", smlErrorPrint(&error)); + "%s", error->message); sml_fail_unless( smlDataSyncSetOption( dsObject, SML_DATA_SYNC_CONFIG_USE_TIMESTAMP_ANCHOR, useTimestamp, &error), - "%s", smlErrorPrint(&error)); + "%s", error->message); sml_fail_unless( smlDataSyncSetOption( dsObject, SML_DATA_SYNC_CONFIG_VERSION, "1.1", &error), - "%s", smlErrorPrint(&error)); + "%s", error->message); smlDataSyncRegisterEventCallback(dsObject, _libsyncml_event_callback, NULL); smlDataSyncRegisterChangeCallback(dsObject, _recv_change, NULL); @@ -177,14 +179,14 @@ NULL, locList[2*i], /* source */ &error), - "%s", smlErrorPrint(&error)); + "%s", error->message); sml_fail_unless(error == NULL, NULL); } - sml_fail_unless(smlDataSyncInit(dsObject, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); - sml_fail_unless(smlDataSyncRun(dsObject, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(smlDataSyncInit(dsObject, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); + sml_fail_unless(smlDataSyncRun(dsObject, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); } void libsyncml_disconnect() Modified: trunk/tests/mobiles/obex_mobile_ds_client.c ============================================================================== --- trunk/tests/mobiles/obex_mobile_ds_client.c Mon Jul 13 13:53:42 2009 (r1173) +++ trunk/tests/mobiles/obex_mobile_ds_client.c Mon Jul 13 13:57:22 2009 (r1174) @@ -73,21 +73,21 @@ void obex_mobile_send(SmlLink *link_, const char *data, unsigned int size) { - SmlError *error = NULL; + GError *error = NULL; SmlMimeType mimetype = SML_MIMETYPE_XML; if (enableWbxml) mimetype = SML_MIMETYPE_WBXML; char *msg = smlTryMalloc0(size, &error); - sml_fail_unless(msg != NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(msg != NULL, "%s", error->message); memcpy(msg, data, size); SmlTransportData *tsp_data = smlTransportDataNew(msg, size, mimetype, TRUE, &error); sml_fail_unless(tsp_data != NULL, NULL); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(smlTransportSend(mobile_tsp, link_, tsp_data, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportSend(mobile_tsp, link_, tsp_data, &error), "%s", error->message); sml_fail_unless(error == NULL, NULL); smlTransportDataDeref(tsp_data); @@ -133,7 +133,7 @@ return result; } -static SmlBool equal_messages( +static gboolean equal_messages( const char *recv_data, size_t recv_size, const char *orig_data, size_t orig_size) { @@ -242,7 +242,7 @@ /* compare strings */ - SmlBool notEqual = strcmp(recv, orig); + gboolean notEqual = strcmp(recv, orig); if (notEqual) { smlLog("original-%d.xml", orig, strlen(orig)); @@ -255,7 +255,7 @@ return (!notEqual); } -SmlBool _recv_server_event(SmlTransport *tsp, SmlLink *link_, SmlTransportEventType type, SmlTransportData *data, SmlError *error, void *userdata) +gboolean _recv_server_event(SmlTransport *tsp, SmlLink *link_, SmlTransportEventType type, SmlTransportData *data, const GError *error, void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, tsp, userdata); @@ -317,7 +317,7 @@ mobile_state = TEST_MOBILE_STATE_DISCONNECTED; break; case SML_TRANSPORT_EVENT_ERROR: - sml_fail_unless(FALSE, "%s", smlErrorPrint(&error)); + sml_fail_unless(FALSE, "%s", error->message); break; default: sml_fail_unless(FALSE, "The unexpected transport event %d was received.", type); @@ -405,7 +405,7 @@ /* init the mobiles SyncML stack */ - SmlError *error = NULL; + GError *error = NULL; mobile_tsp = smlTransportNew(SML_TRANSPORT_OBEX_SERVER, &error); sml_fail_unless(smlTransportSetConnectionType(mobile_tsp, SML_TRANSPORT_CONNECTION_TYPE_NET, &error), NULL); @@ -419,7 +419,7 @@ void obex_mobile_disconnect() { smlTrace(TRACE_ENTRY, "%s", __func__); - SmlError *error = NULL; + GError *error = NULL; while (mobile_state != TEST_MOBILE_STATE_DISCONNECTED) { usleep(100); |
From: <svn...@op...> - 2009-07-13 11:53:48
|
Author: bellmich Date: Mon Jul 13 13:53:42 2009 New Revision: 1173 URL: http://libsyncml.opensync.org/changeset/1173 Log: migrated check_libsoup from SmlError to GError Modified: trunk/tests/check_libsoup.c Modified: trunk/tests/check_libsoup.c ============================================================================== --- trunk/tests/check_libsoup.c Mon Jul 13 13:50:53 2009 (r1172) +++ trunk/tests/check_libsoup.c Mon Jul 13 13:53:42 2009 (r1173) @@ -141,19 +141,19 @@ static void init_server(unsigned int port) { smlTrace(TRACE_ENTRY, "%s", __func__); - SmlError *error = NULL; + GError *error = NULL; /* prepare asynchronous runtime environment */ server_ctx = g_main_context_new(); sml_fail_unless(server_ctx != NULL, NULL); server_thread = smlThreadNew(server_ctx, &error); - sml_fail_unless(server_thread != NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(server_thread != NULL, "%s", error->message); /* simulate the transport layer behaviour */ queue = smlQueueNew(&error); - sml_fail_unless(queue != NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(queue != NULL, "%s", error->message); smlQueueSetHandler(queue, (SmlQueueHandler)transport_dummy_callback, NULL); smlQueueAttach(queue, server_ctx); @@ -213,12 +213,12 @@ } -SmlBool _recv_event( +gboolean _recv_event( SmlTransport *tsp, SmlLink *link_, SmlTransportEventType type, SmlTransportData *data, - SmlError *error, + const GError *error, void *userdata) { smlTrace(TRACE_ENTRY, "%s(%d)", __func__, type); @@ -256,15 +256,16 @@ sml_fail_unless(data->type == SML_MIMETYPE_XML, NULL); g_atomic_int_inc(&server_messages); + GError *terror = NULL; data = smlTransportDataNew( (char *)"answer", 6, SML_MIMETYPE_XML, FALSE, - &error); + &terror); sml_fail_unless(data != NULL, NULL); - sml_fail_unless(error == NULL, NULL); + sml_fail_unless(terror == NULL, NULL); - sml_fail_unless(smlTransportSend(tsp, server_link, data, &error), NULL); - sml_fail_unless(error == NULL, NULL); + sml_fail_unless(smlTransportSend(tsp, server_link, data, &terror), NULL); + sml_fail_unless(terror == NULL, NULL); smlTransportDataDeref(data); } @@ -288,14 +289,14 @@ static void run_transport_client(const char *url) { smlTrace(TRACE_ENTRY, "%s", __func__); - SmlError *error = NULL; + GError *error = NULL; /* init client */ SmlTransport *client = smlTransportNew(SML_TRANSPORT_HTTP_CLIENT, &error); sml_fail_unless(smlTransportSetConfigOption(client, "URL", url, &error), NULL); smlTransportSetEventCallback(client, _recv_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); /* send test message */ @@ -322,7 +323,7 @@ /* cleanup client */ - sml_fail_unless(smlTransportDisconnect(client, NULL, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportDisconnect(client, NULL, &error), "%s", error->message); sleep_total = 0; while (client_disconnects < 1 && client_errors < 1 && sleep_total < sleep_max) { @@ -345,7 +346,7 @@ GMainContext *client_ctx; SoupSession *client_session; -SmlBool init_soup_session(gpointer data, SmlError **error) +gboolean init_soup_session(gpointer data, GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, data, error); sml_fail_unless(data != NULL, NULL); @@ -359,7 +360,7 @@ return TRUE; } -SmlBool cleanup_soup_session(gpointer data, SmlError **error) +gboolean cleanup_soup_session(gpointer data, GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, data, error); @@ -376,7 +377,7 @@ { smlTrace(TRACE_ENTRY, "%s", __func__); init_testbed(); - SmlError *error = NULL; + GError *error = NULL; init_server(13001); @@ -404,10 +405,10 @@ client_ctx = g_main_context_new(); sml_fail_unless(client_ctx != NULL, NULL); SmlThread *client_thread = smlThreadNew(client_ctx, &error); - sml_fail_unless(client_thread != NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(client_thread != NULL, "%s", error->message); smlThreadStart(client_thread); - sml_fail_unless(smlThreadCallFunction(client_thread, init_soup_session, msg, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlThreadCallFunction(client_thread, init_soup_session, msg, &error), "%s", error->message); #endif /* test and cleanup server */ @@ -431,7 +432,7 @@ #else /* cleanup session */ - sml_fail_unless(smlThreadCallFunction(client_thread, cleanup_soup_session, NULL, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlThreadCallFunction(client_thread, cleanup_soup_session, NULL, &error), "%s", error->message); /* The client thread must be stopped first * because libsoup is not thread safe. @@ -465,15 +466,15 @@ { smlTrace(TRACE_ENTRY, "%s", __func__); init_testbed(); - SmlError *error = NULL; + GError *error = NULL; /* init server transport */ SmlTransport *serverTsp = smlTransportNew(SML_TRANSPORT_HTTP_SERVER, &error); - sml_fail_unless(serverTsp != NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(serverTsp != NULL, "%s", error->message); sml_fail_unless(smlTransportSetConfigOption(serverTsp, "PORT", "13003", &error), NULL); smlTransportSetEventCallback(serverTsp, _recv_event, GINT_TO_POINTER(2)); - sml_fail_unless(smlTransportInitialize(serverTsp, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(serverTsp, &error), "%s", error->message); /* client stuff */ |
From: <svn...@op...> - 2009-07-13 11:50:59
|
Author: bellmich Date: Mon Jul 13 13:50:53 2009 New Revision: 1172 URL: http://libsyncml.opensync.org/changeset/1172 Log: migrated check_http from SmlError to GError Modified: trunk/tests/check_http.c Modified: trunk/tests/check_http.c ============================================================================== --- trunk/tests/check_http.c Mon Jul 13 13:44:15 2009 (r1171) +++ trunk/tests/check_http.c Mon Jul 13 13:50:53 2009 (r1172) @@ -22,6 +22,7 @@ #include "tests/support.h" #include <libsyncml/sml_transport_internals.h> +#include <libsyncml/sml_error_internals.h> int client_connects; int client_disconnects; @@ -54,7 +55,7 @@ { reset_testbed(); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *tsp = smlTransportNew(SML_TRANSPORT_HTTP_CLIENT, &error); sml_fail_unless(tsp != NULL, NULL); sml_fail_unless(error == NULL, NULL); @@ -67,15 +68,15 @@ { reset_testbed(); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *tsp = smlTransportNew(SML_TRANSPORT_HTTP_CLIENT, &error); sml_fail_unless(tsp != NULL, NULL); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(smlTransportSetConfigOption(tsp, "URL", "http://libsyncml.opensyncml.org", &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportSetConfigOption(tsp, "URL", "http://libsyncml.opensyncml.org", &error), "%s", error->message); - sml_fail_unless(smlTransportInitialize(tsp, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(tsp, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); sml_fail_unless(smlTransportFinalize(tsp, &error), NULL); sml_fail_unless(error == NULL, NULL); @@ -89,7 +90,7 @@ { reset_testbed(); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *tsp = smlTransportNew(SML_TRANSPORT_HTTP_CLIENT, &error); sml_fail_unless(tsp != NULL, NULL); sml_fail_unless(error == NULL, NULL); @@ -101,7 +102,7 @@ sml_fail_unless(!smlTransportInitialize(tsp, &config, &error), NULL); sml_fail_unless(error != NULL, NULL); - smlErrorDeref(&error); + SML_ERROR_FREE(error); smlTransportFree(tsp); } @@ -114,7 +115,7 @@ reset_testbed(); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *tsp = smlTransportNew(SML_TRANSPORT_HTTP_CLIENT, &error); sml_fail_unless(tsp != NULL, NULL); sml_fail_unless(error == NULL, NULL); @@ -124,11 +125,11 @@ sml_fail_unless(error == NULL, NULL); /* The transport is not configured but libsoup can initialize a default client */ - sml_fail_unless(smlTransportInitialize(tsp, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(tsp, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); - sml_fail_unless(smlTransportFinalize(tsp, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportFinalize(tsp, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); smlTransportFree(tsp); } @@ -138,7 +139,7 @@ { reset_testbed(); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *tsp = smlTransportNew(SML_TRANSPORT_HTTP_SERVER, &error); sml_fail_unless(tsp != NULL, NULL); sml_fail_unless(error == NULL, NULL); @@ -147,7 +148,7 @@ } END_TEST -SmlBool _recv_client_event(SmlTransport *tsp, SmlLink *link_, SmlTransportEventType type, SmlTransportData *data, SmlError *error, void *userdata) +gboolean _recv_client_event(SmlTransport *tsp, SmlLink *link_, SmlTransportEventType type, SmlTransportData *data, const GError *error, void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %d)", __func__, tsp, link_, type); @@ -179,10 +180,10 @@ return TRUE; } -SmlBool _recv_server_event(SmlTransport *tsp, SmlLink *link_, SmlTransportEventType type, SmlTransportData *data, SmlError *error, void *userdata) +gboolean _recv_server_event(SmlTransport *tsp, SmlLink *link_, SmlTransportEventType type, SmlTransportData *data, const GError *error, void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %d, %p)", __func__, link_, type, error); - SmlError *locerror = NULL; + GError *locerror = NULL; SmlLink *last = NULL; switch (type) { @@ -210,18 +211,18 @@ if (GPOINTER_TO_INT(userdata) == 1) { data = smlTransportDataNew((char *)"answer", 7, SML_MIMETYPE_WBXML, FALSE, &locerror); sml_fail_unless(data != NULL, NULL); - sml_fail_unless(locerror == NULL, "%s", smlErrorPrint(&locerror)); + sml_fail_unless(locerror == NULL, "%s", locerror->message); - sml_fail_unless(smlTransportSend(tsp, link_, data, &locerror), "%s", smlErrorPrint(&locerror)); + sml_fail_unless(smlTransportSend(tsp, link_, data, &locerror), "%s", locerror->message); smlTransportDataDeref(data); } else if (GPOINTER_TO_INT(userdata) == 2) { - SmlError *newerror = NULL; - smlErrorSet(&newerror, SML_ERROR_GENERIC, "test"); - smlTransportSetError(tsp, link_, &newerror); - smlErrorDeref(&newerror); + GError *newerror = NULL; + SML_SET_ERROR(&newerror, SML_ERROR_GENERIC, "test"); + smlTransportSendError(tsp, link_, newerror); + SML_ERROR_FREE(newerror); } else if (GPOINTER_TO_INT(userdata) == 3) { - sml_fail_unless(smlTransportDisconnect(tsp, link_, &locerror), "%s", smlErrorPrint(&locerror)); + sml_fail_unless(smlTransportDisconnect(tsp, link_, &locerror), "%s", locerror->message); } else { sml_fail_unless(FALSE, "Some unexpected userdata %i was detected.", GPOINTER_TO_INT(userdata)); } @@ -230,10 +231,10 @@ sml_fail_unless(data->type == SML_MIMETYPE_XML, NULL); sml_fail_unless(link_ != NULL, NULL); - SmlError *newerror = NULL; - smlErrorSet(&newerror, SML_ERROR_GENERIC, "test2"); - smlTransportSetError(tsp, link_, &newerror); - smlErrorDeref(&newerror); + GError *newerror = NULL; + SML_SET_ERROR(&newerror, SML_ERROR_GENERIC, "test2"); + smlTransportSendError(tsp, link_, newerror); + SML_ERROR_FREE(newerror); } else { sml_fail_unless(FALSE, "The received data was not expected (%s).", data->data); } @@ -251,7 +252,7 @@ { reset_testbed(); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *tsp = smlTransportNew(SML_TRANSPORT_HTTP_SERVER, &error); sml_fail_unless(tsp != NULL, NULL); sml_fail_unless(error == NULL, NULL); @@ -261,8 +262,8 @@ smlTransportSetEventCallback(tsp, _recv_server_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(tsp, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(tsp, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); sml_fail_unless(smlTransportFinalize(tsp, &error), NULL); sml_fail_unless(error == NULL, NULL); @@ -275,7 +276,7 @@ { reset_testbed(); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *tsp = smlTransportNew(SML_TRANSPORT_HTTP_SERVER, &error); sml_fail_unless(tsp != NULL, NULL); sml_fail_unless(error == NULL, NULL); @@ -283,11 +284,11 @@ /* -1 is an illegal port. */ sml_fail_unless(smlTransportSetConfigOption(tsp, "PORT", "-1", &error) == FALSE, NULL); sml_fail_unless(error != NULL, NULL); - smlErrorDeref(&error); + SML_ERROR_FREE(error); /* The default config of libsoup can be used to setup a valid transport. */ - sml_fail_unless(smlTransportInitialize(tsp, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(error == NULL, "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(tsp, &error), "%s", error->message); + sml_fail_unless(error == NULL, "%s", error->message); sml_fail_unless(smlTransportFinalize(tsp, &error), NULL); sml_fail_unless(error == NULL, NULL); @@ -300,7 +301,7 @@ { reset_testbed(); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *server = smlTransportNew(SML_TRANSPORT_HTTP_SERVER, &error); SmlTransport *client = smlTransportNew(SML_TRANSPORT_HTTP_CLIENT, &error); @@ -311,8 +312,8 @@ smlTransportSetEventCallback(client, _recv_client_event, GINT_TO_POINTER(1)); smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); sml_fail_unless(smlTransportConnect(client, &error), NULL); sml_fail_unless(error == NULL, NULL); @@ -324,7 +325,7 @@ /* disconnect the client */ - sml_fail_unless(smlTransportDisconnect(client, NULL, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportDisconnect(client, NULL, &error), "%s", error->message); sml_fail_unless(error == NULL, NULL); while (client_disconnects == 0) { usleep(50); }; @@ -346,7 +347,7 @@ { reset_testbed(); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *server = smlTransportNew(SML_TRANSPORT_HTTP_SERVER, &error); SmlTransport *client = smlTransportNew(SML_TRANSPORT_HTTP_CLIENT, &error); @@ -357,8 +358,8 @@ smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(1)); smlTransportSetEventCallback(client, _recv_client_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); SmlTransportData *data = smlTransportDataNew((char *)"test", 5, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); @@ -372,7 +373,7 @@ /* disconnect client */ - sml_fail_unless(smlTransportDisconnect(client, NULL, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportDisconnect(client, NULL, &error), "%s", error->message); while(client_disconnects < 1) { usleep(50); } /* disconnect server */ @@ -394,7 +395,7 @@ { reset_testbed(); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *server = smlTransportNew(SML_TRANSPORT_HTTP_SERVER, &error); SmlTransport *client = smlTransportNew(SML_TRANSPORT_HTTP_CLIENT, &error); @@ -406,8 +407,8 @@ smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(3)); smlTransportSetEventCallback(client, _recv_client_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); SmlTransportData *data = smlTransportDataNew((char *)"test", 5, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); @@ -445,7 +446,7 @@ { reset_testbed(); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *server = smlTransportNew(SML_TRANSPORT_HTTP_SERVER, &error); SmlTransport *client = smlTransportNew(SML_TRANSPORT_HTTP_CLIENT, &error); @@ -456,8 +457,8 @@ smlTransportSetEventCallback(client, _recv_client_event, GINT_TO_POINTER(1)); smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); SmlTransportData *data = smlTransportDataNew((char *)"test", 5, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); @@ -477,7 +478,7 @@ /* disconnect client */ - sml_fail_unless(smlTransportDisconnect(client, NULL, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportDisconnect(client, NULL, &error), "%s", error->message); while(client_disconnects < 1) { usleep(50); } /* disconnect server */ @@ -499,7 +500,7 @@ { reset_testbed(); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *server = smlTransportNew(SML_TRANSPORT_HTTP_SERVER, &error); SmlTransport *client = smlTransportNew(SML_TRANSPORT_HTTP_CLIENT, &error); @@ -510,8 +511,8 @@ smlTransportSetEventCallback(client, _recv_client_event, GINT_TO_POINTER(1)); smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); SmlTransportData *data = NULL; @@ -538,7 +539,7 @@ /* disconnect client */ - sml_fail_unless(smlTransportDisconnect(client, NULL, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportDisconnect(client, NULL, &error), "%s", error->message); while(client_disconnects < 1) { usleep(50); } /* disconnect server */ @@ -571,14 +572,14 @@ { reset_testbed(); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *client = smlTransportNew(SML_TRANSPORT_HTTP_CLIENT, &error); sml_fail_unless(smlTransportSetConfigOption(client, "URL", "http://127.0.0.1:10013", &error), NULL); smlTransportSetEventCallback(client, _recv_client_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); SmlTransportData *data = smlTransportDataNew((char *)"test", 5, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); @@ -606,7 +607,7 @@ { reset_testbed(); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *server = smlTransportNew(SML_TRANSPORT_HTTP_SERVER, &error); SmlTransport *client = smlTransportNew(SML_TRANSPORT_HTTP_CLIENT, &error); @@ -617,8 +618,8 @@ smlTransportSetEventCallback(client, _recv_client_event, GINT_TO_POINTER(1)); smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(2)); - sml_fail_unless(smlTransportInitialize(client, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(client, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); SmlTransportData *data = smlTransportDataNew((char *)"test", 5, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); @@ -646,7 +647,7 @@ sml_fail_unless(server_disconnects == 1, NULL); sml_fail_unless(smlTransportFinalize(client, &error), NULL); - sml_fail_unless(smlTransportFinalize(server, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportFinalize(server, &error), "%s", error->message); smlTransportFree(client); smlTransportFree(server); @@ -657,7 +658,7 @@ { reset_testbed(); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *server = smlTransportNew(SML_TRANSPORT_HTTP_SERVER, &error); SmlTransport *client1 = smlTransportNew(SML_TRANSPORT_HTTP_CLIENT, &error); SmlTransport *client2 = smlTransportNew(SML_TRANSPORT_HTTP_CLIENT, &error); @@ -674,10 +675,10 @@ smlTransportSetEventCallback(client3, _recv_client_event, GINT_TO_POINTER(1)); smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client1, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(client2, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(client3, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(client1, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(client2, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(client3, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); SmlTransportData *data = smlTransportDataNew((char *)"test", 5, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); @@ -715,9 +716,9 @@ sml_fail_unless(client_receives == 3, NULL); sml_fail_unless(server_receives == 3, NULL); - sml_fail_unless(smlTransportDisconnect(client1, NULL, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportDisconnect(client2, NULL, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportDisconnect(client3, NULL, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportDisconnect(client1, NULL, &error), "%s", error->message); + sml_fail_unless(smlTransportDisconnect(client2, NULL, &error), "%s", error->message); + sml_fail_unless(smlTransportDisconnect(client3, NULL, &error), "%s", error->message); while (client_disconnects < 3) { usleep(100); }; @@ -730,7 +731,7 @@ * that the list will be cleaned up before * this for-loop ends */ - sml_fail_unless(smlTransportDisconnect(server, g_list_nth_data(links, i-1), &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportDisconnect(server, g_list_nth_data(links, i-1), &error), "%s", error->message); while (server_disconnects < 3 - i + 1) { usleep(100); } @@ -757,7 +758,7 @@ { reset_testbed(); - SmlError *error = NULL; + GError *error = NULL; SmlTransport *server = smlTransportNew(SML_TRANSPORT_HTTP_SERVER, &error); SmlTransport *client1 = smlTransportNew(SML_TRANSPORT_HTTP_CLIENT, &error); SmlTransport *client2 = smlTransportNew(SML_TRANSPORT_HTTP_CLIENT, &error); @@ -774,10 +775,10 @@ smlTransportSetEventCallback(client3, _recv_client_event, GINT_TO_POINTER(1)); smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client1, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(client2, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(client3, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(client1, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(client2, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(client3, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); SmlTransportData *data = smlTransportDataNew((char *)"test", 5, SML_MIMETYPE_XML, FALSE, &error); sml_fail_unless(data != NULL, NULL); @@ -817,7 +818,7 @@ sml_fail_unless(client_errors == 2, NULL); sml_fail_unless(server_receives == 3, NULL); - sml_fail_unless(smlTransportDisconnect(client1, NULL, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportDisconnect(client1, NULL, &error), "%s", error->message); while (client_disconnects < 1) { usleep(100); } @@ -830,7 +831,7 @@ * that the list will be cleaned up before * this for-loop ends */ - sml_fail_unless(smlTransportDisconnect(server, g_list_nth_data(links, i-1), &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportDisconnect(server, g_list_nth_data(links, i-1), &error), "%s", error->message); while (server_disconnects < 3 - i + 1) { usleep(100); } @@ -858,7 +859,7 @@ reset_testbed(); int num = 1000; - SmlError *error = NULL; + GError *error = NULL; SmlTransport *server = smlTransportNew(SML_TRANSPORT_HTTP_SERVER, &error); SmlTransport *client1 = smlTransportNew(SML_TRANSPORT_HTTP_CLIENT, &error); SmlTransport *client2 = smlTransportNew(SML_TRANSPORT_HTTP_CLIENT, &error); @@ -875,10 +876,10 @@ smlTransportSetEventCallback(client3, _recv_client_event, GINT_TO_POINTER(1)); smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(1)); - sml_fail_unless(smlTransportInitialize(client1, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(client2, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(client3, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportInitialize(server, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportInitialize(client1, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(client2, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(client3, &error), "%s", error->message); + sml_fail_unless(smlTransportInitialize(server, &error), "%s", error->message); SmlTransportData *data = NULL; @@ -923,9 +924,9 @@ sml_fail_unless(client_receives == 3 * num, NULL); sml_fail_unless(server_receives == 3 * num, NULL); - sml_fail_unless(smlTransportDisconnect(client1, NULL, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportDisconnect(client2, NULL, &error), "%s", smlErrorPrint(&error)); - sml_fail_unless(smlTransportDisconnect(client3, NULL, &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportDisconnect(client1, NULL, &error), "%s", error->message); + sml_fail_unless(smlTransportDisconnect(client2, NULL, &error), "%s", error->message); + sml_fail_unless(smlTransportDisconnect(client3, NULL, &error), "%s", error->message); for (i = g_list_length(links); i > 0; i--) { /* start to disconnect from the end * to avoid conflicts with very fast SMP machines @@ -933,7 +934,7 @@ * that the list will be cleaned up before * this for-loop ends */ - sml_fail_unless(smlTransportDisconnect(server, g_list_nth_data(links, i-1), &error), "%s", smlErrorPrint(&error)); + sml_fail_unless(smlTransportDisconnect(server, g_list_nth_data(links, i-1), &error), "%s", error->message); while (server_disconnects < (3 * num - i + 1)) { usleep(100); } |
From: <svn...@op...> - 2009-07-13 11:44:23
|
Author: bellmich Date: Mon Jul 13 13:44:15 2009 New Revision: 1171 URL: http://libsyncml.opensync.org/changeset/1171 Log: migrated syncml-ds-tool from SmlError to GError Modified: trunk/tools/syncml-ds-tool.c Modified: trunk/tools/syncml-ds-tool.c ============================================================================== --- trunk/tools/syncml-ds-tool.c Mon Jul 13 13:43:57 2009 (r1170) +++ trunk/tools/syncml-ds-tool.c Mon Jul 13 13:44:15 2009 (r1171) @@ -449,7 +449,7 @@ SmlDataSyncObject *dsObject, SmlDataSyncEventType type, void *userdata, - GError *error) + const GError *error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p, %p)", __func__, dsObject, type, userdata, error); GError *locerror = NULL; @@ -458,7 +458,7 @@ case SML_DATA_SYNC_EVENT_ERROR: writeSyncStatus(FALSE); g_message("ERROR: %s\n", error->message); - g_error_free(error); + // g_error_free(error); exit(2); break; case SML_DATA_SYNC_EVENT_CONNECT: |
From: <svn...@op...> - 2009-07-13 11:44:04
|
Author: bellmich Date: Mon Jul 13 13:43:57 2009 New Revision: 1170 URL: http://libsyncml.opensync.org/changeset/1170 Log: migrated check_error from SmlError to GError Modified: trunk/libsyncml/sml_error.c trunk/libsyncml/sml_error_internals.h trunk/tests/CMakeLists.txt trunk/tests/check_error.c Modified: trunk/libsyncml/sml_error.c ============================================================================== --- trunk/libsyncml/sml_error.c Mon Jul 13 13:18:52 2009 (r1169) +++ trunk/libsyncml/sml_error.c Mon Jul 13 13:43:57 2009 (r1170) @@ -398,7 +398,7 @@ */ SmlErrorClass smlErrorGetClass(GError **error) { - if (!smlErrorIsSet(error)) + if (!error || *error == NULL) return SML_ERRORCLASS_SUCCESS; if ((*error)->code == SML_NO_ERROR) Modified: trunk/libsyncml/sml_error_internals.h ============================================================================== --- trunk/libsyncml/sml_error_internals.h Mon Jul 13 13:18:52 2009 (r1169) +++ trunk/libsyncml/sml_error_internals.h Mon Jul 13 13:43:57 2009 (r1170) @@ -29,6 +29,17 @@ smlAssertMsg(*error == NULL, "The error parameter is already filled (ignored error)."); #define SML_ERROR g_quark_from_static_string("Sml") +#define SML_SET_ERROR(error,type,...) \ + {\ + gchar *__sml_error_string = g_strdup_printf(__VA_ARGS__); \ + if (__sml_error_string && strlen(__sml_error_string)) \ + g_set_error(error, SML_ERROR, type, "%s %s", smlErrorTypeGetMessage(type), __sml_error_string); \ + else \ + g_set_error(error, SML_ERROR, type, "Error %d: %s", type, smlErrorTypeGetMessage(type)); \ + g_free(__sml_error_string);\ + } + +#define SML_ERROR_FREE(error) g_error_free(error); error = NULL; #define sml_return_val_error_if_fail(d_expr,d_value,d_error,d_error_code, d_error_msg) \ g_set_error(d_error, SML_ERROR, d_error_code, d_error_msg); \ Modified: trunk/tests/CMakeLists.txt ============================================================================== --- trunk/tests/CMakeLists.txt Mon Jul 13 13:18:52 2009 (r1169) +++ trunk/tests/CMakeLists.txt Mon Jul 13 13:43:57 2009 (r1170) @@ -62,16 +62,7 @@ SML_ADD_TESTCASE( error_free_null ) SML_ADD_TESTCASE( error_free_null2 ) SML_ADD_TESTCASE( error_free ) - SML_ADD_TESTCASE( error_check_null ) - SML_ADD_TESTCASE( error_check_null2 ) - SML_ADD_TESTCASE( error_check ) - SML_ADD_TESTCASE( error_check2 ) - SML_ADD_TESTCASE( error_update_null ) - SML_ADD_TESTCASE( error_update_null2 ) - SML_ADD_TESTCASE( error_update ) - SML_ADD_TESTCASE( error_update2 ) SML_ADD_TESTCASE( error_set_null ) - SML_ADD_TESTCASE( error_set_null2 ) SML_ADD_TESTCASE( error_duplicate_null ) SML_ADD_TESTCASE( error_class ) SML_END_TEST() Modified: trunk/tests/check_error.c ============================================================================== --- trunk/tests/check_error.c Mon Jul 13 13:18:52 2009 (r1169) +++ trunk/tests/check_error.c Mon Jul 13 13:43:57 2009 (r1170) @@ -27,14 +27,13 @@ { setup_testbed(NULL); - SmlError *error = NULL; - smlErrorSet(&error, SML_ERROR_GENERIC, "test%i", 1); + GError *error = NULL; + SML_SET_ERROR(&error, SML_ERROR_GENERIC, "test%i", 1); sml_fail_unless(error != NULL, NULL); - sml_fail_unless(error->type == SML_ERROR_GENERIC, NULL); + sml_fail_unless(error->code == SML_ERROR_GENERIC, NULL); sml_fail_unless(!strcmp(error->message, "test1"), NULL); - sml_fail_unless(smlErrorIsSet(&error), NULL); - smlErrorDeref(&error); + SML_ERROR_FREE(error); sml_fail_unless(error == NULL, NULL); } END_TEST @@ -43,15 +42,16 @@ { setup_testbed(NULL); - smlErrorSet(NULL, SML_ERROR_GENERIC, "test%i", 1); + SML_SET_ERROR(NULL, SML_ERROR_GENERIC, "test%i", 1); } END_TEST START_TEST (error_free_null) { setup_testbed(NULL); - - smlErrorDeref(NULL); + + GError *error = NULL; + SML_ERROR_FREE(error); } END_TEST @@ -59,8 +59,8 @@ { setup_testbed(NULL); - SmlError *error = NULL; - smlErrorDeref(&error); + GError *error = NULL; + SML_ERROR_FREE(error); } END_TEST @@ -68,120 +68,29 @@ { setup_testbed(NULL); - SmlError *error = NULL; - smlErrorSet(&error, SML_ERROR_GENERIC, "test"); + GError *error = NULL; + SML_SET_ERROR(&error, SML_ERROR_GENERIC, "test"); sml_fail_unless(error != NULL, NULL); - smlErrorDeref(&error); + SML_ERROR_FREE(error); sml_fail_unless(error == NULL, NULL); } END_TEST -START_TEST (error_check_null) -{ - setup_testbed(NULL); - - sml_fail_unless(smlErrorIsSet(NULL) == FALSE, NULL); -} -END_TEST - -START_TEST (error_check_null2) -{ - setup_testbed(NULL); - - SmlError *error = NULL; - sml_fail_unless(smlErrorIsSet(&error) == FALSE, NULL); -} -END_TEST - -START_TEST (error_check) -{ - setup_testbed(NULL); - - SmlError *error = NULL; - smlErrorSet(&error, SML_ERROR_GENERIC, "test"); - sml_fail_unless(smlErrorIsSet(&error) == TRUE, NULL); - smlErrorDeref(&error); -} -END_TEST - -START_TEST (error_check2) -{ - setup_testbed(NULL); - - SmlError *error = NULL; - smlErrorSet(&error, SML_NO_ERROR, NULL); - sml_fail_unless(smlErrorIsSet(&error) == FALSE, NULL); -} -END_TEST - -START_TEST (error_update_null) -{ - setup_testbed(NULL); - - smlErrorUpdate(NULL, NULL); -} -END_TEST - -START_TEST (error_update_null2) -{ - setup_testbed(NULL); - - SmlError *error = NULL; - smlErrorUpdate(&error, NULL); -} -END_TEST - -START_TEST (error_update) -{ - setup_testbed(NULL); - - SmlError *error = NULL; - smlErrorSet(&error, SML_ERROR_GENERIC, "test"); - smlErrorUpdate(&error, "test2%i", 1); - sml_fail_unless(!strcmp(error->message, "test21"), NULL); - smlErrorDeref(&error); -} -END_TEST - -START_TEST (error_update2) -{ - setup_testbed(NULL); - - SmlError *error = NULL; - smlErrorSet(&error, SML_ERROR_GENERIC, "test"); - smlErrorUpdate(&error, "test2%s", error->message); - sml_fail_unless(!strcmp(error->message, "test2test"), "%s != test2test", error->message); - smlErrorDeref(&error); -} -END_TEST - START_TEST (error_set_null) { setup_testbed(NULL); - smlErrorSet(NULL, SML_NO_ERROR, NULL); + SML_SET_ERROR(NULL, SML_NO_ERROR, NULL); } END_TEST -START_TEST (error_set_null2) -{ - - setup_testbed(NULL); - - SmlError *error = NULL; - smlErrorUpdate(&error, NULL); -} -END_TEST - START_TEST (error_duplicate_null) { setup_testbed(NULL); - SmlError *error = NULL; - smlErrorSet(&error, SML_ERROR_GENERIC, "asd"); - smlErrorDuplicate(NULL, &error); - smlErrorDeref(&error); + GError *duplicate = g_error_copy(NULL); + sml_fail_unless(duplicate == NULL, NULL); } END_TEST @@ -191,20 +100,20 @@ sml_fail_unless(smlErrorGetClass(NULL) == SML_ERRORCLASS_SUCCESS, NULL); - SmlError *error = NULL; + GError *error = NULL; sml_fail_unless(smlErrorGetClass(&error) == SML_ERRORCLASS_SUCCESS, NULL); - smlErrorSet(&error, SML_NO_ERROR, "test%i", 1); + SML_SET_ERROR(&error, SML_NO_ERROR, "test%i", 1); sml_fail_unless(smlErrorGetClass(&error) == SML_ERRORCLASS_SUCCESS, NULL); - smlErrorDeref(&error); + SML_ERROR_FREE(error); - smlErrorSet(&error, SML_ERROR_SEE_OTHER_RETRY, "test%i", 1); + SML_SET_ERROR(&error, SML_ERROR_SEE_OTHER_RETRY, "test%i", 1); sml_fail_unless(smlErrorGetClass(&error) == SML_ERRORCLASS_RETRY, NULL); - smlErrorDeref(&error); + SML_ERROR_FREE(error); - smlErrorSet(&error, SML_ERROR_GENERIC, "test%i", 1); + SML_SET_ERROR(&error, SML_ERROR_GENERIC, "test%i", 1); sml_fail_unless(smlErrorGetClass(&error) == SML_ERRORCLASS_FATAL, NULL); - smlErrorDeref(&error); + SML_ERROR_FREE(error); sml_fail_unless(error == NULL, NULL); } |
From: <svn...@op...> - 2009-07-13 11:18:59
|
Author: bellmich Date: Mon Jul 13 13:18:52 2009 New Revision: 1169 URL: http://libsyncml.opensync.org/changeset/1169 Log: migrated check_data_sync_api from SmlError to GError Modified: trunk/tests/check_data_sync_api.c Modified: trunk/tests/check_data_sync_api.c ============================================================================== --- trunk/tests/check_data_sync_api.c Mon Jul 13 13:15:37 2009 (r1168) +++ trunk/tests/check_data_sync_api.c Mon Jul 13 13:18:52 2009 (r1169) @@ -49,7 +49,7 @@ SmlBool sendAllChanges( SmlDataSyncObject *dsObject, - SmlError **error) + GError **error) { smlTrace(TRACE_ENTRY, "%s", __func__); @@ -64,7 +64,7 @@ char *name = g_strdup_printf("%d", count); if (!smlDataSyncAddChange(client, client_source, SML_CHANGE_ADD, name , test_data, strlen(test_data), NULL, error)) { - sml_fail_unless(FALSE, "%s", smlErrorPrint(error)); + sml_fail_unless(FALSE, "%s", (*error)->message); } smlSafeCFree(&name); } @@ -78,17 +78,17 @@ SmlDataSyncObject *dsObject, SmlDataSyncEventType type, void *userdata, - SmlError *error) + const GError *error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p, %p)", __func__, dsObject, type, userdata, error); - SmlError *locerror = NULL; + GError *locerror = NULL; switch (type) { case SML_DATA_SYNC_EVENT_ERROR: if (dsObject == client) { - sml_fail_unless(FALSE, "OMA DS client failed: %s", smlErrorPrint(&error)); + sml_fail_unless(FALSE, "OMA DS client failed: %s", error->message); } else { - sml_fail_unless(FALSE, "OMA DS server failed: %s", smlErrorPrint(&error)); + sml_fail_unless(FALSE, "OMA DS server failed: %s", error->message); } break; case SML_DATA_SYNC_EVENT_CONNECT: @@ -136,9 +136,9 @@ return; error: - fprintf(stderr, "An error occured while handling events: %s\n", smlErrorPrint(&locerror)); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&locerror)); - smlErrorDeref(&locerror); + fprintf(stderr, "An error occured while handling events: %s\n", locerror->message); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, locerror->message); + g_error_free(locerror); exit(3); } @@ -150,7 +150,7 @@ char *data, unsigned int size, void *userdata, - SmlError **error) + GError **error) { smlTrace(TRACE_ENTRY, "%s: %s ==> %s(%p, %d, %p, %d, %p, %p)", __func__, VA_STRING(source), VA_STRING(uid), dsObject, type, data, size, userdata, error); @@ -196,7 +196,7 @@ // const char *source, // SmlAlertType type, // void *userdata, -// SmlError **error) +// GError **error) //{ // smlTrace(TRACE_ENTRY, "%s - %s: %d", __func__, VA_STRING(source), type); // /* find the appropriate datasoure */ @@ -229,7 +229,7 @@ // smlTrace(TRACE_EXIT, "%s - slow == %d", __func__, datastore->slow); // return type; //error: -// smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); +// smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); // return SML_ALERT_UNKNOWN; //} @@ -237,7 +237,7 @@ { /* general init */ setup_testbed(NULL); - SmlError *error = NULL; + GError *error = NULL; client_items = NULL; #ifdef ENABLE_OPENOBEX_TCP @@ -326,12 +326,12 @@ return; error: - sml_fail_unless(FALSE, "%s", smlErrorPrint(&error)); + sml_fail_unless(FALSE, "%s", error->message); } void run_testbed() { - SmlError *error = NULL; + GError *error = NULL; locks = 2; /* init the sync */ @@ -375,12 +375,12 @@ return; error: - sml_fail_unless(FALSE, "%s", smlErrorPrint(&error)); + sml_fail_unless(FALSE, "%s", error->message); } START_TEST (ds_api_text_vcard_21) { - SmlError *error = NULL; + GError *error = NULL; init_testbed("HTTP", "17001"); /* register datastore @@ -410,13 +410,13 @@ return; error: - sml_fail_unless(FALSE, "%s", smlErrorPrint(&error)); + sml_fail_unless(FALSE, "%s", error->message); } END_TEST START_TEST (ds_api_image_jpeg) { - SmlError *error = NULL; + GError *error = NULL; init_testbed("OBEX", "17002"); /* register datastore @@ -449,13 +449,13 @@ return; error: - sml_fail_unless(FALSE, "%s", smlErrorPrint(&error)); + sml_fail_unless(FALSE, "%s", error->message); } END_TEST START_TEST (ds_api_unknown_ct) { - SmlError *error = NULL; + GError *error = NULL; init_testbed("HTTP", "17003"); /* register datastore @@ -485,13 +485,13 @@ return; error: - sml_fail_unless(FALSE, "%s", smlErrorPrint(&error)); + sml_fail_unless(FALSE, "%s", error->message); } END_TEST START_TEST (ds_api_multi_text_vcard_21) { - SmlError *error = NULL; + GError *error = NULL; init_testbed("HTTP", "17004"); /* register datastore @@ -525,7 +525,7 @@ return; error: - sml_fail_unless(FALSE, "%s", smlErrorPrint(&error)); + sml_fail_unless(FALSE, "%s", error->message); } END_TEST |
From: <svn...@op...> - 2009-07-13 11:15:54
|
Author: bellmich Date: Mon Jul 13 13:15:37 2009 New Revision: 1168 URL: http://libsyncml.opensync.org/changeset/1168 Log: migrated check_ds from SmlError to GError Modified: trunk/tests/check_ds.c Modified: trunk/tests/check_ds.c ============================================================================== --- trunk/tests/check_ds.c Mon Jul 13 12:23:54 2009 (r1167) +++ trunk/tests/check_ds.c Mon Jul 13 13:15:37 2009 (r1168) @@ -116,7 +116,7 @@ { smlTrace(TRACE_INTERNAL, "%s(%p, %p)", __func__, source, callback); SmlSessionThread *check = user_data; - SmlError *error = NULL; + GError *error = NULL; smlAssert(check != NULL); smlAssert(check->data != NULL); @@ -160,7 +160,7 @@ SmlSessionThread *smlSessionRunAsync(SmlSession *session, SmlTransportData **input) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, session, input); - SmlError *error = NULL; + GError *error = NULL; SmlSessionThread *thread = g_malloc0(sizeof(SmlSessionThread)); @@ -267,7 +267,7 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -static SmlBool _recv_changes(SmlDsSession *dsession, SmlChangeType type, const char *uid, char *data, unsigned int size, const char *contenttype, void *userdata, SmlError **error) +static SmlBool _recv_changes(SmlDsSession *dsession, SmlChangeType type, const char *uid, char *data, unsigned int size, const char *contenttype, void *userdata, GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %s, %s, %i, %s, %p, %p)", __func__, dsession, type, VA_STRING(uid), VA_STRING(data), size, VA_STRING(contenttype), userdata, error); @@ -331,51 +331,42 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -static void _add_reply(SmlDsSession *session, SmlStatus *status, const char *newuid, void *userdata) +static void _add_reply(SmlDsSession *session, SmlStatus *status, void *userdata) { - smlTrace(TRACE_ENTRY, "%s(%p, %p, %s, %p)", __func__, session, status, VA_STRING(newuid), userdata); + smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, status, userdata); sml_fail_unless(status != NULL, NULL); sml_fail_unless(smlStatusGetClass(status) == SML_ERRORCLASS_SUCCESS, NULL); sml_fail_unless(GPOINTER_TO_INT(userdata) == 1 || GPOINTER_TO_INT(userdata) == 2, NULL); - if (GPOINTER_TO_INT(userdata) == 1) { - sml_fail_unless(newuid != NULL, NULL); - sml_fail_unless(!strcmp(newuid, "newuid"), NULL); - } else { - sml_fail_unless(newuid == NULL, NULL); - } - + /* the newuid will only be received by the mapping callback */ + g_atomic_int_add(&add_replies_received, 1); smlTrace(TRACE_EXIT, "%s", __func__); } -static void _modify_reply(SmlDsSession *session, SmlStatus *status, const char *newuid, void *userdata) +static void _modify_reply(SmlDsSession *session, SmlStatus *status, void *userdata) { - smlTrace(TRACE_ENTRY, "%s(%p, %p, %s, %p)", __func__, session, status, VA_STRING(newuid), userdata); + smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, status, userdata); sml_fail_unless(status != NULL, NULL); sml_fail_unless(smlStatusGetClass(status) == SML_ERRORCLASS_SUCCESS, NULL); sml_fail_unless(GPOINTER_TO_INT(userdata) == 1, NULL); - sml_fail_unless(newuid == NULL, NULL); - g_atomic_int_add(&modify_replies_received, 1); smlTrace(TRACE_EXIT, "%s", __func__); } -static void _delete_reply(SmlDsSession *session, SmlStatus *status, const char *newuid, void *userdata) +static void _delete_reply(SmlDsSession *session, SmlStatus *status, void *userdata) { - smlTrace(TRACE_ENTRY, "%s(%p, %p, %s, %p)", __func__, session, status, VA_STRING(newuid), userdata); + smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, status, userdata); sml_fail_unless(status != NULL, NULL); sml_fail_unless(smlStatusGetClass(status) == SML_ERRORCLASS_SUCCESS, NULL); sml_fail_unless(GPOINTER_TO_INT(userdata) == 1, NULL); - sml_fail_unless(newuid == NULL, NULL); - g_atomic_int_add(&delete_replies_received, 1); smlTrace(TRACE_EXIT, "%s", __func__); @@ -398,7 +389,7 @@ setup_testbed(NULL); GError *gerror = NULL; - SmlError *error = NULL; + GError *error = NULL; SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); @@ -417,7 +408,7 @@ setup_testbed(NULL); GError *gerror = NULL; - SmlError *error = NULL; + GError *error = NULL; SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); @@ -431,7 +422,7 @@ } END_TEST -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, %p)", __func__, parent, reply); @@ -488,7 +479,7 @@ g_atomic_int_add(&session_ends, 1); break; case SML_SESSION_EVENT_ERROR: - sml_fail_unless(FALSE, "%s", smlErrorPrint(&error)); + sml_fail_unless(FALSE, "%s", error->message); break; default: sml_fail_unless(FALSE, "An unexpected session event %d was received.", type); @@ -521,7 +512,7 @@ setup_testbed(NULL); GError *gerror = NULL; - SmlError *error = NULL; + GError *error = NULL; SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); @@ -536,9 +527,9 @@ smlDsServerSetConnectCallback(server, _recv_init_alert, server_corr); /* Start a new session from the client */ - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); client_corr->thread = smlSessionRunAsync(session, &to_session); - SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); server_corr->thread = smlSessionRunAsync(session2, &to_session2); smlSessionSetLocalMaxMsgSize(session2, defaultMaxMsgSize); smlSessionSetLocalMaxObjSize(session2, defaultMaxObjSize); @@ -633,7 +624,7 @@ setup_testbed(NULL); GError *gerror = NULL; - SmlError *error = NULL; + GError *error = NULL; SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); @@ -650,9 +641,9 @@ /* Start a new session from the client */ - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); client_corr->thread = smlSessionRunAsync(session, &to_session); - SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); server_corr->thread = smlSessionRunAsync(session2, &to_session2); smlSessionSetLocalMaxMsgSize(session2, defaultMaxMsgSize); smlSessionSetLocalMaxObjSize(session2, defaultMaxObjSize); @@ -759,7 +750,7 @@ setup_testbed(NULL); GError *gerror = NULL; - SmlError *error = NULL; + GError *error = NULL; SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); @@ -777,9 +768,9 @@ /* Start a new session from the client */ - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); client_corr->thread = smlSessionRunAsync(session, &to_session); - SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); server_corr->thread = smlSessionRunAsync(session2, &to_session2); smlSessionSetLocalMaxMsgSize(session2, defaultMaxMsgSize); smlSessionSetLocalMaxObjSize(session2, defaultMaxObjSize); @@ -908,7 +899,7 @@ setup_testbed(NULL); GError *gerror = NULL; - SmlError *error = NULL; + GError *error = NULL; SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); @@ -926,9 +917,9 @@ /* Start a new session from the client */ - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); client_corr->thread = smlSessionRunAsync(session, &to_session); - SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); server_corr->thread = smlSessionRunAsync(session2, &to_session2); smlSessionSetLocalMaxMsgSize(session2, defaultMaxMsgSize); smlSessionSetLocalMaxObjSize(session2, defaultMaxObjSize); @@ -1076,7 +1067,7 @@ setup_testbed(NULL); GError *gerror = NULL; - SmlError *error = NULL; + GError *error = NULL; SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); @@ -1094,9 +1085,9 @@ /* Start a new session from the client */ - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); client_corr->thread = smlSessionRunAsync(session, &to_session); - SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); server_corr->thread = smlSessionRunAsync(session2, &to_session2); smlSessionSetLocalMaxMsgSize(session2, defaultMaxMsgSize); smlSessionSetLocalMaxObjSize(session2, defaultMaxObjSize); @@ -1255,7 +1246,7 @@ setup_testbed(NULL); GError *gerror = NULL; - SmlError *error = NULL; + GError *error = NULL; SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); @@ -1273,9 +1264,9 @@ /* Start a new session from the client */ - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); client_corr->thread = smlSessionRunAsync(session, &to_session); - SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); server_corr->thread = smlSessionRunAsync(session2, &to_session2); smlSessionSetLocalMaxMsgSize(session2, defaultMaxMsgSize); smlSessionSetLocalMaxObjSize(session2, defaultMaxObjSize); @@ -1449,7 +1440,7 @@ setup_testbed(NULL); GError *gerror = NULL; - SmlError *error = NULL; + GError *error = NULL; SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); @@ -1467,9 +1458,9 @@ /* Start a new session from the client */ - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); client_corr->thread = smlSessionRunAsync(session, &to_session); - SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); server_corr->thread = smlSessionRunAsync(session2, &to_session2); smlSessionSetLocalMaxMsgSize(session2, defaultMaxMsgSize); smlSessionSetLocalMaxObjSize(session2, defaultMaxObjSize); @@ -1634,7 +1625,7 @@ setup_testbed(NULL); GError *gerror = NULL; - SmlError *error = NULL; + GError *error = NULL; SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); @@ -1652,9 +1643,9 @@ /* Start a new session from the client */ - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); client_corr->thread = smlSessionRunAsync(session, &to_session); - SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); server_corr->thread = smlSessionRunAsync(session2, &to_session2); smlSessionSetLocalMaxMsgSize(session2, defaultMaxMsgSize); smlSessionSetLocalMaxObjSize(session2, defaultMaxObjSize); @@ -1842,7 +1833,7 @@ setup_testbed(NULL); GError *gerror = NULL; - SmlError *error = NULL; + GError *error = NULL; SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); @@ -1860,9 +1851,9 @@ /* Start a new session from the client */ - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); client_corr->thread = smlSessionRunAsync(session, &to_session); - SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); server_corr->thread = smlSessionRunAsync(session2, &to_session2); /* All stuff must be sent at once. */ smlSessionSetLocalMaxMsgSize(session2, defaultMaxObjSize); @@ -2043,7 +2034,7 @@ setup_testbed(NULL); GError *gerror = NULL; - SmlError *error = NULL; + GError *error = NULL; SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); @@ -2061,10 +2052,10 @@ /* Start a new session from the client */ - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); client_corr->thread = smlSessionRunAsync(session, &to_session); smlSessionSetRemoteMaxMsgSize(session, limit); - SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); server_corr->thread = smlSessionRunAsync(session2, &to_session2); smlSessionSetRemoteMaxMsgSize(session2, limit); smlSessionSetLocalMaxMsgSize(session2, defaultMaxMsgSize); @@ -2239,7 +2230,7 @@ setup_testbed(NULL); GError *gerror = NULL; - SmlError *error = NULL; + GError *error = NULL; SmlLocation *loc = sml_location_new_with_options("test", NULL, &gerror); sml_fail_unless(loc != NULL, NULL); sml_fail_unless(gerror == NULL, NULL); @@ -2285,10 +2276,10 @@ /* Start a new session from the client */ - SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); client_corr1->thread = smlSessionRunAsync(session, &to_session); smlSessionSetSendingMaxMsgSize(session, limit); - SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, "1", 0, &error); + SmlSession *session2 = smlSessionNew(SML_SESSION_TYPE_SERVER, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); server_corr->thread = smlSessionRunAsync(session2, &to_session2); smlSessionSetSendingMaxMsgSize(session2, limit); |
From: <svn...@op...> - 2009-07-13 10:24:04
|
Author: bellmich Date: Mon Jul 13 12:23:54 2009 New Revision: 1167 URL: http://libsyncml.opensync.org/changeset/1167 Log: enabled still required parts of sml_error.c Modified: trunk/libsyncml/CMakeLists.txt trunk/libsyncml/sml_error.c trunk/libsyncml/sml_error_internals.h Modified: trunk/libsyncml/CMakeLists.txt ============================================================================== --- trunk/libsyncml/CMakeLists.txt Mon Jul 13 12:23:31 2009 (r1166) +++ trunk/libsyncml/CMakeLists.txt Mon Jul 13 12:23:54 2009 (r1167) @@ -5,6 +5,7 @@ SET( libsyncml_LIB_SRCS sml_command.c sml_elements.c + sml_error.c sml_manager.c sml_md5.c sml_notification.c @@ -67,16 +68,8 @@ INSTALL( TARGETS syncml DESTINATION ${LIBSYNCML_LIBRARIES_DIR} ) INSTALL( FILES - objects/sml_devinf_obj.h - objects/sml_ds_server.h - objects/sml_auth.h sml_defines.h - sml_manager.h - sml_md5.h - sml_notification.h - sml_parse.h - sml_session.h - sml_transport.h + sml_error.h syncml.h DESTINATION ${LIBSYNCML_INCLUDE_DIR}/libsyncml ) Modified: trunk/libsyncml/sml_error.c ============================================================================== --- trunk/libsyncml/sml_error.c Mon Jul 13 12:23:31 2009 (r1166) +++ trunk/libsyncml/sml_error.c Mon Jul 13 12:23:54 2009 (r1167) @@ -191,6 +191,7 @@ * @param args The arguments to the message * */ +/* void smlErrorSetVargs(SmlError **error, SmlErrorType type, const char *format, va_list args) { return_if_fail(error); @@ -219,6 +220,7 @@ return; } +*/ /*@}*/ @@ -229,7 +231,7 @@ * */ /*@{*/ - +/* SmlError **smlErrorRef(SmlError **error) { if (!smlErrorIsSet(error)) @@ -239,7 +241,9 @@ return error; } +*/ +/* void smlErrorDeref(SmlError **error) { if (!smlErrorIsSet(error)) @@ -258,6 +262,7 @@ smlSafeFree((gpointer *)error); } +*/ /*! @brief Checks if the error is set * @@ -282,6 +287,7 @@ * @returns The type of the error * */ +/* SmlErrorType smlErrorGetType(SmlError **error) { if (!smlErrorIsSet(error)) @@ -289,6 +295,7 @@ return (*error)->type; } +*/ /*! @brief Returns the message of the error * @@ -296,6 +303,7 @@ * @returns The message of the error or NULL if no error * */ +/* const char *smlErrorPrint(SmlError **error) { if (!smlErrorIsSet(error)) @@ -303,6 +311,7 @@ return (*error)->printMessage; } +*/ /*! @brief Updates the error message * @@ -314,6 +323,7 @@ * @param format The new message * */ +/* void smlErrorUpdate(SmlError **error, const char *format, ...) { return_if_fail(smlErrorIsSet(error)); @@ -326,6 +336,7 @@ smlSafeCFree(&old); } +*/ /*! @brief Duplicates the error into the target * @@ -334,6 +345,7 @@ * @param source The source error which to duplicate * */ +/* void smlErrorDuplicate(SmlError **target, SmlError **source) { return_if_fail(target != NULL); @@ -342,6 +354,7 @@ smlErrorSet(target, (*source)->type, (*source)->message); } +*/ /*! @brief Sets the error * @@ -352,6 +365,7 @@ * @param format The message * */ +/* void smlErrorSet(SmlError **error, SmlErrorType type, const char *format, ...) { va_list args; @@ -359,6 +373,7 @@ smlErrorSetVargs(error, type, format, args); va_end (args); } +*/ /*! @brief Sets the type of an error * @@ -366,12 +381,14 @@ * @param type The Error type to set * */ +/* void smlErrorSetType(SmlError **error, SmlErrorType type) { return_if_fail(error != NULL); (*error)->type = type; } +*/ /*! @brief Gets the error class * Modified: trunk/libsyncml/sml_error_internals.h ============================================================================== --- trunk/libsyncml/sml_error_internals.h Mon Jul 13 12:23:31 2009 (r1166) +++ trunk/libsyncml/sml_error_internals.h Mon Jul 13 12:23:54 2009 (r1167) @@ -38,6 +38,8 @@ *d_error = NULL; \ } +const char *smlErrorTypeGetMessage(SmlErrorType type); + #endif //_SML_ERROR_INTERNALS_H_ /*@}*/ |
From: <svn...@op...> - 2009-07-13 10:23:43
|
Author: bellmich Date: Mon Jul 13 12:23:31 2009 New Revision: 1166 URL: http://libsyncml.opensync.org/changeset/1166 Log: migrated syncml-ds-tool from SmlError to GError Modified: trunk/tools/syncml-ds-tool.c Modified: trunk/tools/syncml-ds-tool.c ============================================================================== --- trunk/tools/syncml-ds-tool.c Thu Jul 9 13:57:42 2009 (r1165) +++ trunk/tools/syncml-ds-tool.c Mon Jul 13 12:23:31 2009 (r1166) @@ -230,9 +230,11 @@ /* *********** CONFIG ***************** */ /* ************************************ */ +#define TOOL_ERROR g_quark_from_static_string("syncml-ds-tool") + typedef struct SmlDsToolLocationType { char *source; - SmlBool slow; + gboolean slow; char *contentType; char *directory; GHashTable *remoteHash; @@ -253,22 +255,22 @@ char *maxObjSize = NULL; GMutex *runMutex = NULL; -SmlBool dumpinfo = FALSE; -SmlBool useNumberOfChanges = TRUE; -SmlBool useStringTable = FALSE; +gboolean dumpinfo = FALSE; +gboolean useNumberOfChanges = TRUE; +gboolean useStringTable = FALSE; SmlDevInf *remoteDevinf = NULL; -SmlBool localWinsConflicts = TRUE; +gboolean localWinsConflicts = TRUE; time_t checkpoint; -SmlBool readOnly = FALSE; +gboolean readOnly = FALSE; /* ************************************ */ /* *********** CALLBACKS ************** */ /* ************************************ */ -static void writeSyncStatus(SmlBool success) +static void writeSyncStatus(gboolean success) { SmlDsToolLocationType *datastore = NULL; GList *o = datastores; @@ -277,11 +279,11 @@ if (datastore->directory) { char *absolute = g_strdup_printf("%s/%s", datastore->directory, STATUS_FILENAME); if (success) { - GError *gerror = NULL; - if (!g_file_set_contents(absolute, "DONE", 4, &gerror)) { + GError *error = NULL; + if (!g_file_set_contents(absolute, "DONE", 4, &error)) { g_warning("Cannot write data to %s. %s", - absolute, gerror->message); - g_error_free(gerror); + absolute, error->message); + g_error_free(error); } } else { g_unlink(STATUS_FILENAME); @@ -294,7 +296,7 @@ SmlChangeType getChangeType( SmlDsToolLocationType *datastore, const char *filename, - SmlError **error) + GError **error) { smlTrace(TRACE_ENTRY, "%s(%s, %s, %p)", __func__, VA_STRING(datastore->source), VA_STRING(filename), error); struct stat fdata; @@ -303,7 +305,7 @@ /* does the file exist */ if (g_stat(filename, &fdata) != 0) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, TOOL_ERROR, SML_ERROR_GENERIC, "Cannot stat file %s (%d).", filename, errno); goto error; @@ -312,7 +314,7 @@ /* was the file touched after the checkpoint */ if (fdata.st_mtime >= checkpoint) { if (sessionType == SML_SESSION_TYPE_CLIENT) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, TOOL_ERROR, SML_ERROR_GENERIC, "Someone accessed the file absolute after the synchronization started.", filename); goto error; @@ -328,7 +330,7 @@ absolute_status = g_strdup_printf("%s/%s", datastore->directory, STATUS_FILENAME); if (!g_file_test(absolute_status, G_FILE_TEST_EXISTS)) { if (!datastore->slow) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, TOOL_ERROR, SML_ERROR_GENERIC, "Status file %s is missing but it is no SLOW-SYNC.", absolute_status); goto error; @@ -342,7 +344,7 @@ /* read the stat from the status file */ if (g_stat(absolute_status, &fstatus) != 0) { /* this is a general error */ - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, TOOL_ERROR, SML_ERROR_GENERIC, "Cannot stat file %s (%d).", absolute_status, errno); goto error; @@ -384,26 +386,25 @@ error: if (absolute_status) smlSafeCFree(&absolute_status); - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return SML_CHANGE_UNKNOWN; } -SmlBool sendAllChanges( +gboolean sendAllChanges( SmlDataSyncObject *dsObject, - SmlError **error) + GError **error) { smlTrace(TRACE_ENTRY, "%s", __func__); GList *o = datastores; - GError *gerror = NULL; /* If readOnly then data MUST NOT be send. */ for (;!readOnly && o;o=o->next) { SmlDsToolLocationType *datastore = o->data; if (!datastore->directory) continue; smlTrace(TRACE_INTERNAL, "%s: checking %s", __func__, VA_STRING(datastore->source)); - GDir *dir = g_dir_open(datastore->directory, 0, &gerror); + GDir *dir = g_dir_open(datastore->directory, 0, error); if (!dir) - goto gerror; + goto error; const gchar *filename = g_dir_read_name(dir); for (;filename; filename = g_dir_read_name(dir)) { smlTrace(TRACE_INTERNAL, "%s: checking %s", __func__, VA_STRING(filename)); @@ -424,9 +425,9 @@ smlTrace(TRACE_INTERNAL, "%s: sending %s", __func__, VA_STRING(absolute)); gsize length; char *data = NULL; - if (!g_file_get_contents(absolute, &data, &length, &gerror)) { + if (!g_file_get_contents(absolute, &data, &length, error)) { smlSafeCFree(&absolute); - goto gerror; + goto error; } smlSafeCFree(&absolute); if (!smlDataSyncAddChange(dsObject, datastore->source, changeType, @@ -439,11 +440,8 @@ } smlTrace(TRACE_EXIT, "%s", __func__); return smlDataSyncSendChanges(dsObject, error); -gerror: - smlErrorSet(error, SML_ERROR_GENERIC, gerror->message); - g_error_free(gerror); error: - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } @@ -451,16 +449,16 @@ SmlDataSyncObject *dsObject, SmlDataSyncEventType type, void *userdata, - SmlError *error) + GError *error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p, %p)", __func__, dsObject, type, userdata, error); - SmlError *locerror = NULL; + GError *locerror = NULL; switch (type) { case SML_DATA_SYNC_EVENT_ERROR: writeSyncStatus(FALSE); - g_message("ERROR: %s\n", smlErrorPrint(&error)); - smlErrorDeref(&error); + g_message("ERROR: %s\n", error->message); + g_error_free(error); exit(2); break; case SML_DATA_SYNC_EVENT_CONNECT: @@ -508,15 +506,15 @@ return; error: - fprintf(stderr, "An error occured while handling events: %s\n", smlErrorPrint(&locerror)); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&locerror)); - smlErrorDeref(&locerror); + fprintf(stderr, "An error occured while handling events: %s\n", locerror->message); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, locerror->message); + g_error_free(locerror); exit(3); } static char * getSafeFilename(const char *filename) { - SmlBool clean = TRUE; + gboolean clean = TRUE; size_t i; for (i=0; i < strlen(filename); i++) { @@ -532,7 +530,7 @@ } } -static SmlBool recvChangeCallback( +static gboolean recvChangeCallback( SmlDataSyncObject *dsObject, const char *source, SmlChangeType type, @@ -540,7 +538,7 @@ char *data, unsigned int size, void *userdata, - SmlError **error) + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %s, %d, %s, %p, %d, %p, %p)", __func__, dsObject, VA_STRING(source), type, VA_STRING(uid), data, size, userdata, error); char *absolute_uid = NULL; @@ -572,7 +570,7 @@ /* sanity check for uid */ if (!strcmp(safeUID, STATUS_FILENAME)) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, TOOL_ERROR, SML_ERROR_GENERIC, "The filename %s cannot be used as UID. This is a potential attack.", STATUS_FILENAME); printf("\tIllegal filename %s detected.\n", STATUS_FILENAME); @@ -587,7 +585,7 @@ g_hash_table_insert(datastore->remoteHash, g_strdup(absolute_uid), (char *)"1"); } /* the directory is checked by scanArguments */ - SmlBool doWrite = FALSE; + gboolean doWrite = FALSE; if (!doWrite && !g_file_test(absolute_uid, G_FILE_TEST_EXISTS)) doWrite = TRUE; if (!doWrite && sessionType == SML_SESSION_TYPE_CLIENT) @@ -617,13 +615,13 @@ struct stat fdata; struct stat status; if (g_stat(absolute_uid, &fdata) != 0) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, TOOL_ERROR, SML_ERROR_GENERIC, "Cannot stat uid file %s (%d).", absolute_uid, errno); goto error; } if (g_stat(absolute_status, &status) != 0) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, TOOL_ERROR, SML_ERROR_GENERIC, "Cannot stat status file %s (%d).", absolute_status, errno); goto error; @@ -640,14 +638,8 @@ g_unlink(absolute_uid); printf("\tThe item was successfully deleted.\n"); } else { - GError *gerror = NULL; - if (!g_file_set_contents(absolute_uid, data, size, &gerror)) { - smlErrorSet(error, SML_ERROR_GENERIC, - "Cannot write data to %s. %s", - absolute_uid, gerror->message); - g_error_free(gerror); + if (!g_file_set_contents(absolute_uid, data, size, error)) goto error; - } printf("\tThe item was successfully written.\n"); } } else { @@ -674,15 +666,15 @@ smlSafeCFree(&absolute_uid); if (absolute_status) smlSafeCFree(&absolute_status); - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } -static SmlBool recvDevInfCallback( +static gboolean recvDevInfCallback( SmlDataSyncObject *dsObject, SmlDevInf *devinf, void *userdata, - SmlError **error) + GError **error) { smlTrace(TRACE_INTERNAL, "%s(%p, %p, %p, %p)", dsObject, devinf, userdata, error); printf("Received device information.\n"); @@ -696,7 +688,7 @@ const char *source, SmlAlertType type, void *userdata, - SmlError **error) + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %s, %d, %p, %p)", __func__, dsObject, VA_STRING(source), type, userdata, error); /* find the appropriate datasoure */ @@ -713,7 +705,7 @@ if (o) o = o->next; } if (!datastore) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, TOOL_ERROR, SML_ERROR_GENERIC, "Cannot found datastore %s.", source); goto error; @@ -729,7 +721,7 @@ smlTrace(TRACE_EXIT, "%s - slow == %d", __func__, datastore->slow); return type; error: - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return SML_ALERT_UNKNOWN; } @@ -907,10 +899,10 @@ return type; } -SmlBool scanArguments( +gboolean scanArguments( SmlDataSyncObject *dsObject, int argc, char *argv[], - SmlError **error) + GError **error) { smlTrace(TRACE_ENTRY, "%s", __func__); if (argc == 1) @@ -967,7 +959,7 @@ /* check the directory */ if (g_mkdir_with_parents(datastore->directory, 0700) != 0) { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, + g_set_error(error, TOOL_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "There is a problem with the directory %s (%d).", datastore->directory, errno); goto error; @@ -1353,7 +1345,7 @@ if (g_list_length(datastores) == 0) { if (syncmlVersion == NULL || strcmp(syncmlVersion, "1.2")) { - smlErrorSet(error, SML_ERROR_GENERIC, "You have to configure at least one database"); + g_set_error(error, TOOL_ERROR, SML_ERROR_GENERIC, "You have to configure at least one database"); goto error; } else { printf("All datastores will be requested because no datastore is configured.\n"); @@ -1366,7 +1358,7 @@ error: smlTrace(TRACE_EXIT_ERROR, "Failed to start the client: %s\n", - smlErrorPrint(error)); + (*error)->message); return FALSE; } @@ -1376,7 +1368,7 @@ int main(int argc, char *argv[]) { - SmlError *error = NULL; + GError *error = NULL; if (!g_thread_supported ()) g_thread_init (NULL); /* init DS object */ @@ -1475,8 +1467,8 @@ return 0; error: if (error != NULL) { - fprintf(stderr, "ERROR: %s\n", smlErrorPrint(&error)); - smlErrorDeref(&error); + fprintf(stderr, "ERROR: %s\n", error->message); + g_error_free(error); } return 1; } |
From: <svn...@op...> - 2009-07-10 09:08:42
|
Author: bricks Date: Fri Jul 10 11:08:34 2009 New Revision: 5700 URL: http://www.opensync.org/changeset/5700 Log: implemented first parts of merger api refs #1084 Added: branches/opensync-ticket1084/opensync/format/opensync_merger.c Modified: branches/opensync-ticket1084/opensync/CMakeLists.txt branches/opensync-ticket1084/opensync/format/opensync_merger.h branches/opensync-ticket1084/opensync/format/opensync_merger_private.h Modified: branches/opensync-ticket1084/opensync/CMakeLists.txt ============================================================================== --- branches/opensync-ticket1084/opensync/CMakeLists.txt Fri Jul 10 10:41:55 2009 (r5699) +++ branches/opensync-ticket1084/opensync/CMakeLists.txt Fri Jul 10 11:08:34 2009 (r5700) @@ -35,6 +35,7 @@ format/opensync_objformat.c format/opensync_objformat_sink.c format/opensync_time.c + format/opensync_merger.c group/opensync_group.c group/opensync_group_env.c group/opensync_member.c Added: branches/opensync-ticket1084/opensync/format/opensync_merger.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/opensync-ticket1084/opensync/format/opensync_merger.c Fri Jul 10 11:08:34 2009 (r5700) @@ -0,0 +1,81 @@ +/* + * libopensync - A synchronization framework + * Copyright (C) 2009 Bjoern Ricks <bjo...@go...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "opensync.h" +#include "opensync_internals.h" + +#include "opensync_merger.h" +#include "opensync_merger_private.h" + +OSyncMerger *osync_merger_new(const char *objformat, const char *capsformat, OSyncError **error) +{ + OSyncMerger *merger = NULL; + osync_trace(TRACE_ENTRY, "%s(%s, %s, %p)", __func__, objformat, capsformat, error); + + merger = osync_try_malloc0(sizeof(OSyncMerger), error); + if (!merger) { + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return NULL; + } + merger->ref_count = 1; + merger->objformat = osync_strdup(objformat); + merger->capsformat = osync_strdup(capsformat); + + osync_trace(TRACE_EXIT, "%s: %p", __func__, merger); + return merger; +} + +OSyncMerger *osync_merger_ref(OSyncMerger *merger) +{ + osync_return_val_if_fail(merger, NULL); + + g_atomic_int_inc(&(merger->ref_count)); + + return merger; +} + +void osync_merger_unref(OSyncMerger *merger) +{ + osync_return_if_fail(merger); + + if (g_atomic_int_dec_and_test(&(merger->ref_count))) { + if (merger->objformat) { + osync_free(merger->objformat); + } + + if (merger->capsformat) { + osync_free(merger->capsformat); + } + + osync_free(merger); + } +} + +void osync_merger_set_initialize_func(OSyncMerger *merger, OSyncMergerInitializeFunc initialize_func) +{ + osync_return_if_fail(merger); + merger->initialize_func = initialize_func; +} + +void osync_merger_set_finalize_func(OSyncMerger *merger, OSyncMergerFinalizeFunc finalize_func) +{ + osync_return_if_fail(merger); + merger->finalize_func = finalize_func; +} Modified: branches/opensync-ticket1084/opensync/format/opensync_merger.h ============================================================================== --- branches/opensync-ticket1084/opensync/format/opensync_merger.h Fri Jul 10 10:41:55 2009 (r5699) +++ branches/opensync-ticket1084/opensync/format/opensync_merger.h Fri Jul 10 11:08:34 2009 (r5700) @@ -32,11 +32,15 @@ typedef void * (* OSyncMergerInitializeFunc) (OSyncError **error); typedef void (* OSyncMergerFinalizeFunc) (void *user_data); -OSYNC_EXPORT OSyncMerger *osync_merger_new(const char *objformat, const char *capsformat, OSyncError **error) ; +OSYNC_EXPORT OSyncMerger *osync_merger_new(const char *objformat, const char *capsformat, OSyncError **error); + +OSYNC_EXPORT OSyncMerger *osync_merger_ref(OSyncMerger *merger); + +OSYNC_EXPORT void osync_merger_unref(OSyncMerger *merger); OSYNC_EXPORT void osync_merger_set_initialize_func(OSyncMerger *merger, OSyncMergerInitializeFunc initialize_func); -OSYNC_EXPORT void osync_merger_set_finalize_func(OSyncMerger *merger, OSyncMergerInitializeFunc finalize_func); +OSYNC_EXPORT void osync_merger_set_finalize_func(OSyncMerger *merger, OSyncMergerFinalizeFunc finalize_func); /*@}*/ Modified: branches/opensync-ticket1084/opensync/format/opensync_merger_private.h ============================================================================== --- branches/opensync-ticket1084/opensync/format/opensync_merger_private.h Fri Jul 10 10:41:55 2009 (r5699) +++ branches/opensync-ticket1084/opensync/format/opensync_merger_private.h Fri Jul 10 11:08:34 2009 (r5700) @@ -30,11 +30,11 @@ /*@{*/ struct OSyncMerger { - const char *objformat; - const char *capsformat; + char *objformat; + char *capsformat; int ref_count; OSyncMergerInitializeFunc initialize_func; - OSyncFormatFinalizeFunc finalize_func; + OSyncMergerFinalizeFunc finalize_func; void *user_data; }; |
From: <svn...@op...> - 2009-07-10 08:42:03
|
Author: bricks Date: Fri Jul 10 10:41:55 2009 New Revision: 5699 URL: http://www.opensync.org/changeset/5699 Log: added new merger api refs #1084 Added: branches/opensync-ticket1084/opensync/format/opensync_merger.h branches/opensync-ticket1084/opensync/format/opensync_merger_private.h Added: branches/opensync-ticket1084/opensync/format/opensync_merger.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/opensync-ticket1084/opensync/format/opensync_merger.h Fri Jul 10 10:41:55 2009 (r5699) @@ -0,0 +1,43 @@ +/* + * libopensync - A synchronization framework + * Copyright (C) 2009 Bjoern Ricks <bjo...@go...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef OPENSYNC_MERGER_H_ +#define OPENSYNC_MERGER_H_ + +/** + * @defgroup OSyncMergerAPI OpenSync Merger + * @ingroup OSyncFormat + * @brief Functions for merging formats + * + */ +/*@{*/ + +typedef void * (* OSyncMergerInitializeFunc) (OSyncError **error); +typedef void (* OSyncMergerFinalizeFunc) (void *user_data); + +OSYNC_EXPORT OSyncMerger *osync_merger_new(const char *objformat, const char *capsformat, OSyncError **error) ; + +OSYNC_EXPORT void osync_merger_set_initialize_func(OSyncMerger *merger, OSyncMergerInitializeFunc initialize_func); + +OSYNC_EXPORT void osync_merger_set_finalize_func(OSyncMerger *merger, OSyncMergerInitializeFunc finalize_func); + +/*@}*/ + +#endif /* OPENSYNC_MERGER_H_ */ Added: branches/opensync-ticket1084/opensync/format/opensync_merger_private.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/opensync-ticket1084/opensync/format/opensync_merger_private.h Fri Jul 10 10:41:55 2009 (r5699) @@ -0,0 +1,43 @@ +/* + * libopensync - A synchronization framework + * Copyright (C) 2009 Bjoern Ricks <bjo...@go...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef OPENSYNC_MERGER_PRIVATE_H_ +#define OPENSYNC_MERGER_PRIVATE_H_ + +/** + * @defgroup OSyncMergerrPrivateAPI OpenSync Merger Private + * @ingroup OSyncFormatPrivate + * @brief Private part for merging formats + * + */ +/*@{*/ + +struct OSyncMerger { + const char *objformat; + const char *capsformat; + int ref_count; + OSyncMergerInitializeFunc initialize_func; + OSyncFormatFinalizeFunc finalize_func; + void *user_data; +}; + +/*@}*/ + +#endif /* OPENSYNC_MERGER_PRIVATE_H_ */ |
From: <svn...@op...> - 2009-07-10 07:20:57
|
Author: bricks Date: Fri Jul 10 09:20:47 2009 New Revision: 5698 URL: http://www.opensync.org/changeset/5698 Log: Introduced API changes from Linuxtag discussion about Mergers Currently the new API is only defined and not implemented refs #1084 Modified: branches/opensync-ticket1084/opensync/engine/opensync_engine.c branches/opensync-ticket1084/opensync/engine/opensync_mapping_entry_engine.c branches/opensync-ticket1084/opensync/engine/opensync_sink_engine.c branches/opensync-ticket1084/opensync/format/opensync_format_env.h branches/opensync-ticket1084/opensync/format/opensync_objformat.c branches/opensync-ticket1084/opensync/format/opensync_objformat.h branches/opensync-ticket1084/opensync/format/opensync_objformat_internals.h branches/opensync-ticket1084/opensync/format/opensync_objformat_private.h branches/opensync-ticket1084/opensync/opensync.h Modified: branches/opensync-ticket1084/opensync/engine/opensync_engine.c ============================================================================== --- branches/opensync-ticket1084/opensync/engine/opensync_engine.c Wed Jul 8 11:13:11 2009 (r5697) +++ branches/opensync-ticket1084/opensync/engine/opensync_engine.c Fri Jul 10 09:20:47 2009 (r5698) @@ -258,9 +258,11 @@ /* Merger - Merge lost information to the change (don't merger anything when changetype is DELETED.) */ if( osync_group_get_merger_enabled(engine->group) && osync_group_get_converter_enabled(engine->group) && - (osync_change_get_changetype(change) != OSYNC_CHANGE_TYPE_DELETED) && - /* only use the merger if the objformat has merger registered. */ - osync_objformat_has_merger(osync_change_get_objformat(change)) ) + (osync_change_get_changetype(change) != OSYNC_CHANGE_TYPE_DELETED) + /* FIXME && + only use the merger if the objformat has merger registered. + osync_objformat_has_merger(osync_change_get_objformat(change)) */ + ) { OSyncCapabilities *caps; @@ -299,12 +301,13 @@ osync_data_get_data(osync_change_get_data(change), &buffer, &size); + /* FIXME ret = osync_objformat_merge(objformat, &buffer, &size, entirebuf, entsize, caps, &error); - osync_free(entirebuf); + osync_free(entirebuf); if (ret != TRUE) goto error; - + */ osync_trace(TRACE_SENSITIVE, "Merge result:\n%s\n", osync_objformat_print(objformat, buffer, size)); } Modified: branches/opensync-ticket1084/opensync/engine/opensync_mapping_entry_engine.c ============================================================================== --- branches/opensync-ticket1084/opensync/engine/opensync_mapping_entry_engine.c Wed Jul 8 11:13:11 2009 (r5697) +++ branches/opensync-ticket1084/opensync/engine/opensync_mapping_entry_engine.c Fri Jul 10 09:20:47 2009 (r5698) @@ -187,8 +187,9 @@ goto error_free_marshal; } + /* FIXME if (!osync_objformat_demerge(objformat, &buffer, &size, caps, error)) - goto error_free_marshal; + goto error_free_marshal; */ osync_trace(TRACE_SENSITIVE, "Post Demerge:\n%s\n", osync_objformat_print(objformat, buffer, size)); Modified: branches/opensync-ticket1084/opensync/engine/opensync_sink_engine.c ============================================================================== --- branches/opensync-ticket1084/opensync/engine/opensync_sink_engine.c Wed Jul 8 11:13:11 2009 (r5697) +++ branches/opensync-ticket1084/opensync/engine/opensync_sink_engine.c Fri Jul 10 09:20:47 2009 (r5698) @@ -150,8 +150,10 @@ if (osync_change_get_changetype(entry_engine->change) == OSYNC_CHANGE_TYPE_DELETED) continue; + /* if (!osync_objformat_has_merger(osync_change_get_objformat(entry_engine->change))) continue; + */ if (!osync_entry_engine_demerge(entry_engine, archive, caps, error)) goto error; Modified: branches/opensync-ticket1084/opensync/format/opensync_format_env.h ============================================================================== --- branches/opensync-ticket1084/opensync/format/opensync_format_env.h Wed Jul 8 11:13:11 2009 (r5697) +++ branches/opensync-ticket1084/opensync/format/opensync_format_env.h Fri Jul 10 09:20:47 2009 (r5698) @@ -245,6 +245,13 @@ */ OSYNC_EXPORT OSyncFormatConverterPath *osync_format_env_find_path_formats_with_detectors(OSyncFormatEnv *env, OSyncData *sourcedata, OSyncList *targets, const char *preferred_format, OSyncError **error); +/** @brief Registers Merger to Format Environment + * + * @param env The format environment + * @param merger Pointer of the merger + */ +OSYNC_EXPORT void osync_format_env_register_merger(OSyncFormatEnv *env, OSyncMerger *merger); + /*@}*/ #endif /* _OPENSYNC_FORMAT_ENV_H_ */ Modified: branches/opensync-ticket1084/opensync/format/opensync_objformat.c ============================================================================== --- branches/opensync-ticket1084/opensync/format/opensync_objformat.c Wed Jul 8 11:13:11 2009 (r5697) +++ branches/opensync-ticket1084/opensync/format/opensync_objformat.c Fri Jul 10 09:20:47 2009 (r5698) @@ -300,42 +300,3 @@ osync_assert(format); return format->validate_func ? TRUE : FALSE; } - -void osync_objformat_set_merge_func(OSyncObjFormat *format, OSyncFormatMergeFunc merge_func) -{ - osync_return_if_fail(format); - format->merge_func = merge_func; -} - -osync_bool osync_objformat_merge(OSyncObjFormat *format, - char **data, unsigned int *size, - const char *entire, unsigned int entsize, - OSyncCapabilities *caps, OSyncError **error) -{ - osync_assert(format); - osync_return_val_if_fail(format->merge_func, TRUE); - return format->merge_func(data, size, entire, entsize, caps, format->user_data, error); -} - -void osync_objformat_set_demerge_func(OSyncObjFormat *format, OSyncFormatDemergeFunc demerge_func) -{ - osync_return_if_fail(format); - format->demerge_func = demerge_func; -} - -osync_bool osync_objformat_demerge(OSyncObjFormat *format, - char **data, unsigned int *size, - OSyncCapabilities *caps, OSyncError **error) -{ - osync_assert(format); - osync_return_val_if_fail(format->demerge_func, TRUE); - return format->demerge_func(data, size, caps, format->user_data, error); -} - - -osync_bool osync_objformat_has_merger(OSyncObjFormat *format) -{ - osync_return_val_if_fail(format, FALSE); - return (format->demerge_func && format->merge_func) ? TRUE : FALSE; -} - Modified: branches/opensync-ticket1084/opensync/format/opensync_objformat.h ============================================================================== --- branches/opensync-ticket1084/opensync/format/opensync_objformat.h Wed Jul 8 11:13:11 2009 (r5697) +++ branches/opensync-ticket1084/opensync/format/opensync_objformat.h Fri Jul 10 09:20:47 2009 (r5698) @@ -44,8 +44,7 @@ typedef osync_bool (* OSyncFormatDemarshalFunc) (OSyncMarshal *marshal, char **output, unsigned int *outpsize, void *user_data, OSyncError **error); typedef osync_bool (* OSyncFormatValidateFunc) (const char *data, unsigned int size, void *user_data, OSyncError **error); -typedef osync_bool (* OSyncFormatMergeFunc) (char **data, unsigned int *size, const char *entire, unsigned int entsize, OSyncCapabilities *caps, void *user_data, OSyncError **error); -typedef osync_bool (* OSyncFormatDemergeFunc) (char **data, unsigned int *size, OSyncCapabilities *caps, void *user_data, OSyncError **error); +typedef osync_bool (* OSyncFormatCapsConverterFunc) (OSyncCapabilities *oldcaps, OSyncCapabilities **newcaps, OSyncError **error); /** * @brief Creates a new object format @@ -225,26 +224,10 @@ OSYNC_EXPORT void osync_objformat_set_validate_func(OSyncObjFormat *format, OSyncFormatValidateFunc validate_func); /** - * @brief Sets the optional merge function for an object format - * - * The merge function can be used to merge data for the specific - * format. This is optional. - * - * @param format Pointer to the object format - * @param merge_func The merge function to use - */ -OSYNC_EXPORT void osync_objformat_set_merge_func(OSyncObjFormat *format, OSyncFormatMergeFunc merge_func); - -/** - * @brief Sets the optional demerge function for an object format - * - * The demerge function can be used to demerge data for the specific - * format. This is optional. - * * @param format Pointer to the object format - * @param demerge_func The demerge function to use + * @param capsconverter_func The function to convert capabilities */ -OSYNC_EXPORT void osync_objformat_set_demerge_func(OSyncObjFormat *format, OSyncFormatDemergeFunc demerge_func); +OSYNC_EXPORT void osync_objformat_set_capsconverter_func(OSyncObjFormat *format, OSyncFormatCapsConverterFunc capsconverter_func); /** * @brief Prints the specified object Modified: branches/opensync-ticket1084/opensync/format/opensync_objformat_internals.h ============================================================================== --- branches/opensync-ticket1084/opensync/format/opensync_objformat_internals.h Wed Jul 8 11:13:11 2009 (r5697) +++ branches/opensync-ticket1084/opensync/format/opensync_objformat_internals.h Fri Jul 10 09:20:47 2009 (r5698) @@ -178,50 +178,6 @@ */ osync_bool osync_objformat_must_validate(OSyncObjFormat *format); -/** - * @brief Merge supplied data in format specific way - * - * @param format Pointer to the object format - * @param data Reference of buffer which stores data to merge - * @param size Reference of size in bytes of the buffer specified by the data paramter - * @param entire - * @param entsize Size in bytes of the base data buffer specified by the entire parameter - * @param caps The capabilities list which describes what must get merged: entire -> input - * @param error Pointer to an error struct - * @returns TRUE if data got merged successfully, otherwise FALSE - */ -OSYNC_TEST_EXPORT osync_bool osync_objformat_merge(OSyncObjFormat *format, - char **data, unsigned int *size, - const char *entire, unsigned int entsize, - OSyncCapabilities *caps, OSyncError **error); - -/** - * @brief Demerge supplied data in format specific way - * - * @param format Pointer to the object format - * @param data Pointer to the buffer which should get demerged - * @param size Reference of size in bytes of the buffer specified by the data parameter - * @param caps The capabilities list which describes what must get demerged - * @param error Pointer to an error struct - * @returns TRUE if data got demerged successfully, otherwise FALSE - */ -OSYNC_TEST_EXPORT osync_bool osync_objformat_demerge(OSyncObjFormat *format, - char **data, unsigned int *size, - OSyncCapabilities *caps, OSyncError **error); - -/** - * @brief Check if specific format is able to merge/demerge - * - * If merge and demerge function are set for the specific format then merger - * and demerger get invoked. Merger/Demerge still can be disabled in group - * configuration, by disabling the merger, or not providing capabilities for - * the member. - * - * @param format Pointer to the object format - * @returns TRUE if merge and demerge is support for this format, otherwise FALSE - */ -osync_bool osync_objformat_has_merger(OSyncObjFormat *format); - /*@}*/ #endif /* _OPENSYNC_OBJFORMAT_INTERNALS_H_ */ Modified: branches/opensync-ticket1084/opensync/format/opensync_objformat_private.h ============================================================================== --- branches/opensync-ticket1084/opensync/format/opensync_objformat_private.h Wed Jul 8 11:13:11 2009 (r5697) +++ branches/opensync-ticket1084/opensync/format/opensync_objformat_private.h Fri Jul 10 09:20:47 2009 (r5698) @@ -61,8 +61,7 @@ OSyncFormatMarshalFunc marshal_func; OSyncFormatDemarshalFunc demarshal_func; OSyncFormatValidateFunc validate_func; - OSyncFormatMergeFunc merge_func; - OSyncFormatDemergeFunc demerge_func; + OSyncFormatCapsConverterFunc capsconverter_func; }; /*@}*/ Modified: branches/opensync-ticket1084/opensync/opensync.h ============================================================================== --- branches/opensync-ticket1084/opensync/opensync.h Wed Jul 8 11:13:11 2009 (r5697) +++ branches/opensync-ticket1084/opensync/opensync.h Fri Jul 10 09:20:47 2009 (r5698) @@ -197,6 +197,7 @@ typedef struct OSyncFormatConverterPath OSyncFormatConverterPath; typedef struct OSyncFormatConverter OSyncFormatConverter; typedef struct OSyncObjFormatSink OSyncObjFormatSink; +typedef struct OSyncMerger OSyncMerger; /* Plugin component */ typedef struct OSyncContext OSyncContext; @@ -249,7 +250,7 @@ typedef struct OSyncGroupEnv OSyncGroupEnv; typedef struct OSyncMember OSyncMember; -/* Merger component */ +/* Capabilities component */ typedef struct OSyncCapabilities OSyncCapabilities; typedef struct OSyncCapability OSyncCapability; typedef struct OSyncCapabilityParameter OSyncCapabilityParameter; |
From: <svn...@op...> - 2009-07-09 11:57:53
|
Author: bellmich Date: Thu Jul 9 13:57:42 2009 New Revision: 1165 URL: http://libsyncml.opensync.org/changeset/1165 Log: migrated transports/http_server from SmlError to GError Modified: trunk/libsyncml/transports/http_server.c Modified: trunk/libsyncml/transports/http_server.c ============================================================================== --- trunk/libsyncml/transports/http_server.c Thu Jul 9 13:57:21 2009 (r1164) +++ trunk/libsyncml/transports/http_server.c Thu Jul 9 13:57:42 2009 (r1165) @@ -40,7 +40,7 @@ SmlTransportHttpServerEnv *env = data; SmlLinkHttpServerEnv *linkenv = NULL; SmlLink *link_ = NULL; - SmlError *error = NULL; + GError *error = NULL; char *path = soup_uri_to_string (soup_message_get_uri(msg), TRUE); smlTrace(TRACE_INTERNAL, "%s: %s %s HTTP/1.%d", @@ -59,7 +59,7 @@ * SECURITY: This is a potential attack. * FALSE POSITIVE: Session with a timeout. */ - smlErrorSet(&error, SML_ERROR_INTERNAL_FILE_NOT_FOUND, + g_set_error(&error, SML_ERROR, SML_ERROR_INTERNAL_FILE_NOT_FOUND, "Not Found (%s).", path); soup_message_set_status(msg, SOUP_STATUS_NOT_FOUND); smlSafeCFree(&path); @@ -70,13 +70,13 @@ smlSafeCFree(&path); if (soup_message_get_http_version(msg) != 1) { - smlErrorSet(&error, SML_ERROR_NOT_IMPLEMENTED, "Wrong http version"); + g_set_error(&error, SML_ERROR, SML_ERROR_NOT_IMPLEMENTED, "Wrong http version"); soup_message_set_status(msg, SOUP_STATUS_NOT_IMPLEMENTED); goto error; } if (soup_method_get_id(msg->method) != SOUP_METHOD_ID_POST) { - smlErrorSet(&error, SML_ERROR_NOT_IMPLEMENTED, "Wrong method"); + g_set_error(&error, SML_ERROR, SML_ERROR_NOT_IMPLEMENTED, "Wrong method"); soup_message_set_status(msg, SOUP_STATUS_NOT_IMPLEMENTED); goto error; } @@ -89,11 +89,11 @@ else if(header && !g_strncasecmp(header, SML_ELEMENT_SAN, strlen(SML_ELEMENT_SAN))) mimetype = SML_MIMETYPE_SAN; else if (header) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unknown mimetype"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unknown mimetype"); soup_message_set_status (msg, SOUP_STATUS_BAD_REQUEST); goto error; } else { - smlErrorSet(&error, SML_ERROR_GENERIC, "Faulty mimetype"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Faulty mimetype"); soup_message_set_status (msg, SOUP_STATUS_BAD_REQUEST); goto error; } @@ -169,8 +169,8 @@ error: soup_server_message_set_encoding (SOUP_SERVER_MESSAGE (msg), SOUP_TRANSFER_CONTENT_LENGTH); soup_message_io_unpause(msg); - 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 /* !HAVE_LIBSOUP22 == libsoup 2.4 */ @@ -189,13 +189,13 @@ SmlTransportHttpServerEnv *env = data; SmlLinkHttpServerEnv *linkenv = NULL; SmlLink *link_ = NULL; - SmlError *error = NULL; + GError *error = NULL; smlTrace(TRACE_INTERNAL, "%s: %s %s HTTP/1.%d", __func__, VA_STRING(msg->method), VA_STRING(path), soup_message_get_http_version(msg)); if (msg->method != SOUP_METHOD_POST) { - smlErrorSet(&error, SML_ERROR_NOT_IMPLEMENTED, "Wrong method"); + g_set_error(&error, SML_ERROR, SML_ERROR_NOT_IMPLEMENTED, "Wrong method"); soup_message_set_status(msg, SOUP_STATUS_NOT_IMPLEMENTED); goto error; } @@ -212,7 +212,7 @@ * SECURITY: This is a potential attack. * FALSE POSITIVE: Session with a timeout. */ - smlErrorSet(&error, SML_ERROR_INTERNAL_FILE_NOT_FOUND, + g_set_error(&error, SML_ERROR, SML_ERROR_INTERNAL_FILE_NOT_FOUND, "Not Found (%s).", fullpath); soup_message_set_status(msg, SOUP_STATUS_NOT_FOUND); smlSafeCFree(&fullpath); @@ -230,11 +230,11 @@ else if(header && !g_strncasecmp(header, SML_ELEMENT_SAN, strlen(SML_ELEMENT_SAN))) mimetype = SML_MIMETYPE_SAN; else if (header) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unknown mimetype"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unknown mimetype"); soup_message_set_status (msg, SOUP_STATUS_BAD_REQUEST); goto error; } else { - smlErrorSet(&error, SML_ERROR_GENERIC, "Faulty mimetype"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Faulty mimetype"); soup_message_set_status (msg, SOUP_STATUS_BAD_REQUEST); goto error; } @@ -311,17 +311,17 @@ error_unref_msg: smlLinkDeref(link_); 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); } #endif /* HAVE_LIBSOUP22 */ -static SmlBool smlTransportHttpServerSetConfigOption( - SmlTransport *tsp, - const char *name, - const char *value, - SmlError **error) +static gboolean +smlTransportHttpServerSetConfigOption (SmlTransport *tsp, + const gchar *name, + const gchar *value, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %s, %s, %p)", __func__, tsp, VA_STRING(name), VA_STRING(value), error); CHECK_ERROR_REF @@ -332,8 +332,8 @@ if (!strcmp(name, SML_TRANSPORT_CONFIG_PORT)) { env->port = atoi(value); if (!(env->port > 0 && env->port < 65535)) { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, "specified port was wrong"); - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "specified port was wrong"); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } smlTrace(TRACE_INTERNAL, "%s: Port %i detected", __func__, env->port); @@ -347,8 +347,8 @@ env->ssl_cert = g_strdup(value); smlTrace(TRACE_INTERNAL, "%s: SSL server certificate %s detected", __func__, VA_STRING(env->ssl_cert)); } else { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, "Unknown parameter %s found.", name); - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "Unknown parameter %s found.", name); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } @@ -356,7 +356,9 @@ return TRUE; } -static SmlBool smlTransportHttpServerInit(SmlTransport *tsp, SmlError **error) +static gboolean +smlTransportHttpServerInit (SmlTransport *tsp, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, tsp, error); CHECK_ERROR_REF @@ -367,9 +369,9 @@ if (!env->port) { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "The HTTP server needs a port where it has to run."); - goto error_free_env; + goto error; } if (!env->url) @@ -395,8 +397,8 @@ NULL); } if (!env->server) { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, "Unable to spawn server"); - goto error_free_env; + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "Unable to spawn server"); + goto error; } #ifdef HAVE_LIBSOUP22 @@ -409,14 +411,11 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - -error_free_env: +error: if (env->url) smlSafeCFree(&(env->url)); - smlSafeFree((gpointer *)&env); -// error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } @@ -526,9 +525,9 @@ return TRUE; } -static SmlBool smlTransportHttpServerCleanupSocket( - gpointer data, - SmlError **error) +static gboolean +smlTransportHttpServerCleanupSocket (gpointer data, + GError **error) { smlTrace(TRACE_ENTRY, "%s", __func__); CHECK_ERROR_REF @@ -543,7 +542,9 @@ return TRUE; } -static SmlBool smlTransportHttpServerFinalize(void *data, SmlError **error) +static gboolean +smlTransportHttpServerFinalize (void *data, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, data, error); CHECK_ERROR_REF @@ -581,7 +582,7 @@ env); if (count != removed) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The glib function g_hash_table_foreach_steal could " \ "not remove all key/value pairs from uriToLink (%u of %u).", removed, count); @@ -600,7 +601,7 @@ env); if (count != removed) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The glib function g_hash_table_foreach_steal could not " \ "remove all key/value pairs from sessionToUri. (%u of %u)", removed, count); @@ -615,11 +616,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; } -static void smlTransportHttpServerSend(void *userdata, void *linkdata, SmlTransportData *data, SmlError *error) +static void +smlTransportHttpServerSend (void *userdata, + void *linkdata, + SmlTransportData *data, + GError *error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, userdata, linkdata, data, error); // smlAssert(userdata); @@ -652,7 +657,7 @@ content_type = SML_ELEMENT_SAN; break; default: - smlErrorSet(&error, SML_ERROR_GENERIC, "Unknown Mimetype"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unknown Mimetype"); goto error_free_message; } @@ -676,9 +681,9 @@ error_free_message: if (smlErrorGetClass(&error) <= SML_ERRORCLASS_RETRY) - soup_message_set_status_full(msg, SOUP_STATUS_BAD_REQUEST, smlErrorPrint(&error)); + soup_message_set_status_full(msg, SOUP_STATUS_BAD_REQUEST, error->message); else - soup_message_set_status_full(msg, SOUP_STATUS_INTERNAL_SERVER_ERROR, smlErrorPrint(&error)); + soup_message_set_status_full(msg, SOUP_STATUS_INTERNAL_SERVER_ERROR, error->message); #ifdef HAVE_LIBSOUP22 soup_server_message_set_encoding (SOUP_SERVER_MESSAGE (msg), SOUP_TRANSFER_CONTENT_LENGTH); @@ -687,12 +692,15 @@ soup_server_unpause_message(linkenv->env->server, msg); #endif - smlErrorDeref(&error); + g_error_free(error); smlTrace(TRACE_EXIT, "%s: Sent Error", __func__); return; } -char * smlTransportHttpServerGetResponseURI(SmlLink *link_, SmlSession *session, SmlError **error) +gchar* +smlTransportHttpServerGetResponseURI (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 @@ -729,7 +737,7 @@ if (strcmp(env->url, soupURI)) { /* SECURITY: This can be an attack. */ - smlErrorSet(error, SML_ERROR_RETRY_LATER, + g_set_error(error, SML_ERROR, SML_ERROR_RETRY_LATER, "A new session with a configured HTTP session was detected."); smlSafeCFree(&soupURI); goto error; @@ -761,7 +769,7 @@ if (g_hash_table_lookup(env->uriToLink, responseURI)) { /* SECURITY: This can be an insecure random number generator. */ - smlErrorSet(error, SML_ERROR_RETRY_LATER, + g_set_error(error, SML_ERROR, SML_ERROR_RETRY_LATER, "A fresh random session ID is already in use."); goto error; } @@ -790,7 +798,7 @@ if (strcmp(soupURI, sessionURI)) { /* SECURITY: This is a potential attack. */ - smlErrorSet(error, SML_ERROR_RETRY_LATER, + g_set_error(error, SML_ERROR, SML_ERROR_RETRY_LATER, "Another session (%s) re-used an already existing HTTP session (%s).", soupURI, sessionURI); smlSafeCFree(&soupURI); @@ -801,7 +809,7 @@ if (!cachedLink) { /* SECURITY: This is an internal bug. */ - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Cannot find link for used URL."); smlSafeCFree(&soupURI); goto error; @@ -809,7 +817,7 @@ if (cachedLink != link_) { /* SECURITY: This is an internal bug. */ - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The link objects mismatch."); smlSafeCFree(&soupURI); goto error; @@ -817,7 +825,7 @@ if (strcmp(linkenv->url, soupURI)) { /* SECURITY: This can be an attack. */ - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The URL of the link object is wrong."); smlSafeCFree(&soupURI); goto error; @@ -828,11 +836,13 @@ smlTrace(TRACE_EXIT, "%s - %s", __func__, VA_STRING(responseURI)); return responseURI; error: - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return NULL; } -SmlBool smlTransportHttpServerNew(SmlTransport *tsp, SmlError **error) +gboolean +smlTransportHttpServerNew (SmlTransport *tsp, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, tsp, error); CHECK_ERROR_REF |
From: <svn...@op...> - 2009-07-09 11:57:30
|
Author: bellmich Date: Thu Jul 9 13:57:21 2009 New Revision: 1164 URL: http://libsyncml.opensync.org/changeset/1164 Log: migrated transports/http_client from SmlError to GError Modified: trunk/libsyncml/transports/http_client.c trunk/libsyncml/transports/http_client_internals.h Modified: trunk/libsyncml/transports/http_client.c ============================================================================== --- trunk/libsyncml/transports/http_client.c Thu Jul 9 13:57:04 2009 (r1163) +++ trunk/libsyncml/transports/http_client.c Thu Jul 9 13:57:21 2009 (r1164) @@ -27,9 +27,9 @@ #include "http_client_internals.h" -static void smlTransportHttpClientSend(void *userdata, void *link, SmlTransportData *data, SmlError *error); -static void smlTransportHttpClientDisconnect(void *data, void *linkdata); -static SmlBool smlTransportHttpClientFinalize(void *data, SmlError **error); +static void smlTransportHttpClientSend (void *userdata, void *link, SmlTransportData *data, GError *error); +static void smlTransportHttpClientDisconnect (void *data, void *linkdata); +static gboolean smlTransportHttpClientFinalize (void *data, GError **error); #ifdef HAVE_LIBSOUP22 #define soup_message_headers_get soup_message_get_header @@ -47,7 +47,7 @@ smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, msg, userdata); #endif SmlTransportHttpClientEnv *env = userdata; - SmlError *error = NULL; + GError *error = NULL; /* handle potential session shutdown */ if (env->connectDone && msg->status_code == SOUP_STATUS_CANCELLED) @@ -68,8 +68,8 @@ */ if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) { - smlErrorSet(&error, - SML_ERROR_GENERIC, + g_set_error(&error, + SML_ERROR, SML_ERROR_GENERIC, "Connection failed (%d) - %s", msg->status_code, msg->reason_phrase); goto error; } @@ -100,7 +100,7 @@ /* check the library status for errors */ if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Call not successfull: %d %s", + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Call not successfull: %d %s", msg->status_code, msg->reason_phrase); goto error; } @@ -118,10 +118,10 @@ else if(header && !g_strncasecmp(header, SML_ELEMENT_SAN, strlen(SML_ELEMENT_SAN))) mimetype = SML_MIMETYPE_SAN; else if (header) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unknown mimetype"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unknown mimetype"); goto error; } else { - smlErrorSet(&error, SML_ERROR_GENERIC, "Faulty mimetype"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Faulty mimetype"); goto error; } @@ -173,8 +173,8 @@ smlSafeCFree(&data); error: smlTransportReceiveEvent(env->tsp, NULL, SML_TRANSPORT_EVENT_ERROR, NULL, error); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&error)); - smlErrorDeref(&error); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, error->message); + g_error_free(error); } /* This is the authentication callback for libsoup. @@ -210,11 +210,11 @@ } #endif -static SmlBool smlTransportHttpClientSetConfigOption( - SmlTransport *tsp, - const char *name, - const char *value, - SmlError **error) +static gboolean +smlTransportHttpClientSetConfigOption (SmlTransport *tsp, + const gchar *name, + const gchar *value, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %s, %s, %p)", __func__, tsp, VA_STRING(name), VA_STRING(value), error); CHECK_ERROR_REF @@ -230,9 +230,9 @@ env->url = g_strdup(value); env->uri = soup_uri_new(env->url); if (env->uri == NULL) { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "The configured url %s is wrong.", env->url); - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } smlTrace(TRACE_INTERNAL, "%s: URL %s detected", __func__, VA_STRING(env->url)); @@ -249,8 +249,8 @@ env->cafile = g_strdup(value); smlTrace(TRACE_INTERNAL, "%s: SSL_CA_FILE %s detected", __func__, VA_STRING(env->cafile)); } else { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, "Unknown parameter %s found.", name); - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "Unknown parameter %s found.", name); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } @@ -266,11 +266,11 @@ smlTrace(TRACE_ENTRY, "%s(%p)", __func__, data); smlAssert(data); SmlTransportHttpClientEnv *env = data; - SmlError *error = NULL; + GError *error = NULL; if (!env->tsp->context) { - smlErrorSet(&error, SML_ERROR_INTERNAL_MISCONFIGURATION, + g_set_error(&error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "HTTP client runs only in asynchronous mode. So the context must be set."); goto error; } @@ -327,7 +327,7 @@ } } if (!env->session) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unable to create new session"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unable to create new session"); goto error; } @@ -345,14 +345,15 @@ smlTrace(TRACE_EXIT, "%s: %p", __func__, env); return; error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&error)); smlTransportReceiveEvent(env->tsp, NULL, SML_TRANSPORT_EVENT_ERROR, NULL, error); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, error->message); + g_error_free(error); } -static SmlBool smlTransportHttpClientSetResponseURI( - SmlTransport *tsp, - const char *uri, - SmlError **error) +static gboolean +smlTransportHttpClientSetResponseURI (SmlTransport *tsp, + const gchar *uri, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %s, %p)", __func__, tsp, VA_STRING(uri), error); CHECK_ERROR_REF @@ -369,9 +370,9 @@ env->url = g_strdup(uri); env->uri = soup_uri_new(env->url); if (env->uri == NULL) { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "The specified url \"%s\" is wrong.", env->url); - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } @@ -379,9 +380,9 @@ return TRUE; } -static SmlBool smlTransportHttpClientCleanupSession( - gpointer data, - SmlError **error) +static gboolean +smlTransportHttpClientCleanupSession (gpointer data, + GError **error) { smlTrace(TRACE_ENTRY, "%s", __func__); CHECK_ERROR_REF @@ -396,7 +397,9 @@ return TRUE; } -static SmlBool smlTransportHttpClientFinalize(void *data, SmlError **error) +static gboolean +smlTransportHttpClientFinalize (void *data, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, data, error); CHECK_ERROR_REF @@ -426,11 +429,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; } -static void smlTransportHttpClientSend(void *userdata, void *link_, SmlTransportData *data, SmlError *error) +static void +smlTransportHttpClientSend (void *userdata, + void *link_, + SmlTransportData *data, + GError *error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, userdata, link_, data, error); smlAssert(error || data); @@ -447,7 +454,7 @@ SoupMessage *msg = soup_message_new_from_uri(SOUP_METHOD_POST, env->uri); if (!msg) { - smlErrorSet(&error, SML_ERROR_GENERIC, "unknown libsoup error during message_new"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "unknown libsoup error during message_new"); goto error; } @@ -463,7 +470,7 @@ content_type = SML_ELEMENT_SAN; break; default: - smlErrorSet(&error, SML_ERROR_GENERIC, "Unknown Mimetype %d", data->type); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unknown Mimetype %d", data->type); goto error_free_message; } @@ -499,8 +506,8 @@ g_object_unref(msg); error: smlTransportReceiveEvent(env->tsp, NULL, SML_TRANSPORT_EVENT_ERROR, NULL, error); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&error)); - smlErrorDeref(&error); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, error->message); + g_error_free(error); } static void smlTransportHttpClientDisconnect(void *data, void *linkdata) @@ -540,7 +547,9 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -SmlBool smlTransportHttpClientNew(SmlTransport *tsp, SmlError **error) +gboolean +smlTransportHttpClientNew (SmlTransport *tsp, + GError **error) { CHECK_ERROR_REF smlAssert(tsp); Modified: trunk/libsyncml/transports/http_client_internals.h ============================================================================== --- trunk/libsyncml/transports/http_client_internals.h Thu Jul 9 13:57:04 2009 (r1163) +++ trunk/libsyncml/transports/http_client_internals.h Thu Jul 9 13:57:21 2009 (r1164) @@ -48,8 +48,8 @@ char *password; char *cafile; - SmlBool connectDone; - SmlBool disconnectDone; + gboolean connectDone; + gboolean disconnectDone; } SmlTransportHttpClientEnv; gboolean smlTransportHttpClientNew (SmlTransport *tsp, GError **error); |
From: <svn...@op...> - 2009-07-09 11:57:13
|
Author: bellmich Date: Thu Jul 9 13:57:04 2009 New Revision: 1163 URL: http://libsyncml.opensync.org/changeset/1163 Log: migrated transports/obex_server from SmlError to GError Modified: trunk/libsyncml/CMakeLists.txt trunk/libsyncml/sml_error.c trunk/libsyncml/sml_error.h trunk/libsyncml/transports/obex_server.c trunk/libsyncml/transports/obex_server_internals.h Modified: trunk/libsyncml/CMakeLists.txt ============================================================================== --- trunk/libsyncml/CMakeLists.txt Thu Jul 9 12:34:31 2009 (r1162) +++ trunk/libsyncml/CMakeLists.txt Thu Jul 9 13:57:04 2009 (r1163) @@ -44,8 +44,8 @@ SET( libsyncml_LIB_SRCS ${libsyncml_LIB_SRCS} transports/obex_client.c - transports/obex_server.c transports/obex_client_samsung.c + transports/obex_server.c transports/obex.c ) ENDIF ( ENABLE_OBEX ) Modified: trunk/libsyncml/sml_error.c ============================================================================== --- trunk/libsyncml/sml_error.c Thu Jul 9 12:34:31 2009 (r1162) +++ trunk/libsyncml/sml_error.c Thu Jul 9 13:57:04 2009 (r1163) @@ -265,7 +265,7 @@ * @returns TRUE if the error is set, FALSE otherwise * */ -SmlBool smlErrorIsSet(SmlError **error) +static gboolean smlErrorIsSet(GError **error) { if (!error) return FALSE; @@ -379,15 +379,15 @@ * @returns The error class * */ -SmlErrorClass smlErrorGetClass(SmlError **error) +SmlErrorClass smlErrorGetClass(GError **error) { if (!smlErrorIsSet(error)) return SML_ERRORCLASS_SUCCESS; - if ((*error)->type == SML_NO_ERROR) + if ((*error)->code == SML_NO_ERROR) return SML_ERRORCLASS_SUCCESS; - return (int)((*error)->type / 100); + return (int)((*error)->code / 100); } /*@}*/ Modified: trunk/libsyncml/sml_error.h ============================================================================== --- trunk/libsyncml/sml_error.h Thu Jul 9 12:34:31 2009 (r1162) +++ trunk/libsyncml/sml_error.h Thu Jul 9 13:57:04 2009 (r1163) @@ -22,7 +22,7 @@ #ifndef _SML_ERROR_H_ #define _SML_ERROR_H_ -#include <libsyncml/syncml.h> +#include <glib.h> typedef enum { SML_ERRORCLASS_UNKNOWN = 0, @@ -113,4 +113,6 @@ } SmlErrorType; +SmlErrorClass smlErrorGetClass(GError **error); + #endif //_SML_ERROR_H_ Modified: trunk/libsyncml/transports/obex_server.c ============================================================================== --- trunk/libsyncml/transports/obex_server.c Thu Jul 9 12:34:31 2009 (r1162) +++ trunk/libsyncml/transports/obex_server.c Thu Jul 9 13:57:04 2009 (r1163) @@ -45,13 +45,13 @@ int result = OBEX_HandleInput(linkenv->handle, 0); if (result < 0) { - SmlError *error = NULL; - smlErrorSet(&error, SML_ERROR_GENERIC, + GError *error = NULL; + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The handling of the obex input failed (%i).", result); smlTransportReceiveEvent(linkenv->env->tsp, linkenv->link, SML_TRANSPORT_EVENT_ERROR, NULL, error); - smlTrace(TRACE_ERROR, "%s: %s", __func__, smlErrorPrint(&error)); - smlErrorDeref(&error); + smlTrace(TRACE_ERROR, "%s: %s", __func__, error->message); + g_error_free(error); return FALSE; } @@ -93,7 +93,7 @@ { smlTrace(TRACE_ENTRY, "%s(%p, %p, %i, %i, %i, %i)", __func__, handle, object, mode, event, obex_cmd, obex_rsp); SmlLinkObexServerEnv *linkenv = OBEX_GetUserData(handle); - SmlError *error = NULL; + GError *error = NULL; obex_headerdata_t header; uint8_t headertype = 0; uint32_t len = 0; @@ -171,7 +171,7 @@ /*char *mimetypestr = g_malloc0(len);// / 2 + 1); if (OBEX_UnicodeToChar((unsigned char *)mimetypestr, header.bs, len / 2 + 1) == -1) { smlSafeCFree(&mimetypestr); - smlErrorSet(&error, SML_ERROR_GENERIC, "unable to convert from unicode"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "unable to convert from unicode"); goto error; }*/ @@ -185,7 +185,7 @@ mimetype = SML_MIMETYPE_SAN; } else { smlSafeCFree(&mimetypestr); - smlErrorSet(&error, SML_ERROR_GENERIC, "Unknown mime type"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unknown mime type"); goto error; } @@ -197,7 +197,7 @@ break; case OBEX_HDR_BODY: if (!length) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Length must come before the body"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Length must come before the body"); goto error; } @@ -221,27 +221,27 @@ } if (!conid) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Missing connection id"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Missing connection id"); goto error; } if (conid != linkenv->conid) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Wrong connection id"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Wrong connection id"); goto error; } if (mimetype == SML_MIMETYPE_UNKNOWN) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Missing mime type"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Missing mime type"); goto error; } if (!length) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Missing length"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Missing length"); goto error; } if (!body) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Missing body"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Missing body"); goto error; } @@ -271,7 +271,7 @@ /*char *mimetypestr = g_malloc0(len / 2 + 1); if (OBEX_UnicodeToChar((unsigned char *)mimetypestr, header.bs, len / 2 + 1) == -1) { smlSafeCFree(&mimetypestr); - smlErrorSet(&error, SML_ERROR_GENERIC, "unable to convert from unicode"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "unable to convert from unicode"); goto error; }*/ @@ -285,7 +285,7 @@ mimetype = SML_MIMETYPE_SAN; } else { smlSafeCFree(&mimetypestr); - smlErrorSet(&error, SML_ERROR_GENERIC, "Unknown mime type"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unknown mime type"); goto error; } @@ -297,17 +297,17 @@ } if (!conid) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Missing connection id"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Missing connection id"); goto error; } if (conid != linkenv->conid) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Wrong connection id"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Wrong connection id"); goto error; } if (mimetype == SML_MIMETYPE_UNKNOWN) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Missing mime type"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Missing mime type"); goto error; } @@ -317,19 +317,19 @@ else OBEX_ObjectSetRsp(object, OBEX_RSP_FORBIDDEN, OBEX_RSP_FORBIDDEN); - smlErrorDeref(&(linkenv->error)); + g_error_free(linkenv->error); linkenv->error = NULL; smlTrace(TRACE_INTERNAL, "%s: Sent error in response to get", __func__); break; } if (!linkenv->send_data) { - smlErrorSet(&error, SML_ERROR_GENERIC, "No data to send"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "No data to send"); goto error; } if (mimetype != linkenv->send_data->type) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Wrong mimetype %d requested. %d was expected.", mimetype, linkenv->send_data->type); goto error; @@ -365,7 +365,7 @@ if (!target || strcmp(target, "SYNCML-SYNC")) { smlSafeCFree(&target); - smlErrorSet(&error, SML_ERROR_GENERIC, "Missing target"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Missing target"); goto error; } smlSafeCFree(&target); @@ -412,10 +412,9 @@ error: OBEX_ObjectSetRsp(object, OBEX_RSP_BAD_REQUEST, OBEX_RSP_BAD_REQUEST); - smlErrorRef(&error); smlTransportReceiveEvent(linkenv->env->tsp, linkenv->link, SML_TRANSPORT_EVENT_ERROR, NULL, error); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&error)); - smlErrorDeref(&error); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, error->message); + g_error_free(error); } static void _smlTransportObexServerMainEvent(obex_t *handle, obex_object_t *object, int mode, int event, int obex_cmd, int obex_rsp) @@ -423,7 +422,7 @@ smlTrace(TRACE_ENTRY, "%s(%p, %p, %i, %i, %i, %i)", __func__, handle, object, mode, event, obex_cmd, obex_rsp); SmlTransportObexServerEnv *env = OBEX_GetUserData(handle); - SmlError *error = NULL; + GError *error = NULL; SmlLinkObexServerEnv *linkenv = NULL; switch (event) { @@ -438,7 +437,7 @@ linkenv->handle = OBEX_ServerAccept(env->handle, _smlTransportObexServerLinkEvent, linkenv); if (!linkenv->handle) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "OBEX_ServerAccept failed."); smlSafeFree((gpointer *)&linkenv); goto error; @@ -461,7 +460,7 @@ break; default: - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unknown OBEX event %d.", event); goto error; break; @@ -472,10 +471,9 @@ error: OBEX_ObjectSetRsp(object, OBEX_RSP_BAD_REQUEST, OBEX_RSP_BAD_REQUEST); - smlErrorRef(&error); smlTransportReceiveEvent(env->tsp, NULL, SML_TRANSPORT_EVENT_ERROR, NULL, error); - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(&error)); - smlErrorDeref(&error); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, error->message); + g_error_free(error); } /* These function supervise the file descriptor where we are listening for incoming @@ -517,18 +515,18 @@ { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, source, callback, user_data); SmlTransportObexServerEnv *env = user_data; - SmlError *error = NULL; + GError *error = NULL; /* this is a non-locking function */ int result = OBEX_HandleInput(env->handle, 0); if (result < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "OBEX_HandleInput on main handle returned %d.", result); goto error; } if (result == 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "OBEX_HandleInput on main handle get a timeout."); goto error; } @@ -537,15 +535,16 @@ return TRUE; error: smlTransportReceiveEvent(env->tsp, NULL, SML_TRANSPORT_EVENT_ERROR, NULL, error); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, error->message); + g_error_free(error); return FALSE; } -static SmlBool smlTransportObexServerSetConfigOption( - SmlTransport *tsp, - const char *name, - const char *value, - SmlError **error) +static gboolean +smlTransportObexServerSetConfigOption (SmlTransport *tsp, + const gchar *name, + const gchar *value, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %s, %s, %p)", __func__, tsp, VA_STRING(name), VA_STRING(value), error); CHECK_ERROR_REF @@ -560,14 +559,14 @@ #ifdef ENABLE_BLUETOOTH int code = str2ba(value, env->bdaddr); if (code != 0) { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "Bluetooth MAC cannot be interpreted (%d).", code); goto error; } smlTrace(TRACE_INTERNAL, "%s: Bluetooth MAC %s detected", __func__, VA_STRING(value)); #else - smlErrorSet(error, SML_ERROR_GENERIC, "Bluetooth not enabled"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Bluetooth not enabled"); goto error; #endif } else if (!strcmp(name, SML_TRANSPORT_CONFIG_BLUETOOTH_CHANNEL)) { @@ -579,7 +578,7 @@ smlTrace(TRACE_INTERNAL, "%s: IRDA service %s detected", __func__, VA_STRING(env->irda_service)); } else { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "Unknown parameter %s found.", name); goto error; } @@ -587,14 +586,14 @@ smlTrace(TRACE_EXIT, "%s - TRUE", __func__); return TRUE; error: - smlTrace(TRACE_EXIT, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT, "%s - %s", __func__, (*error)->message); return FALSE; } -static SmlBool smlTransportObexServerSetConnectionType( - SmlTransport *tsp, - SmlTransportConnectionType type, - SmlError **error) +static gboolean +smlTransportObexServerSetConnectionType (SmlTransport *tsp, + SmlTransportConnectionType type, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, tsp, type, error); CHECK_ERROR_REF @@ -608,7 +607,9 @@ return TRUE; } -static SmlBool smlTransportObexServerInit(SmlTransport *tsp, SmlError **error) +static gboolean +smlTransportObexServerInit (SmlTransport *tsp, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, tsp, error); CHECK_ERROR_REF @@ -625,7 +626,7 @@ _smlTransportObexServerMainEvent, OBEX_FL_KEEPSERVER); if (!env->handle) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to create OBEX IRDA transport."); goto error; } @@ -643,7 +644,7 @@ /* register server */ if (GET_OBEX_RESULT(TcpOBEX_ServerRegister(env->handle, (struct sockaddr *) addr, size)) < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to register INET OBEX server. %s (%i).", strerror(errno), errno); smlSafeFree((gpointer *)&addr); @@ -658,7 +659,7 @@ _smlTransportObexServerMainEvent, OBEX_FL_KEEPSERVER); if (!env->handle) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to create OBEX IRDA transport."); goto error; } @@ -666,7 +667,7 @@ /* register server */ if (GET_OBEX_RESULT(IrOBEX_ServerRegister(env->handle, env->irda_service))) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to register IRDA OBEX server. %s (%i).", strerror(errno), errno); goto error; @@ -679,7 +680,7 @@ _smlTransportObexServerMainEvent, OBEX_FL_KEEPSERVER); if (!env->handle) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to create OBEX Bluetooth transport."); goto error; } @@ -687,18 +688,18 @@ /* register server */ if (GET_OBEX_RESULT(BtOBEX_ServerRegister(env->handle, env->bdaddr, env->port)) < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to register Bluetooth OBEX server. %s (%i).", strerror(errno), errno); goto error; } #else - smlErrorSet(error, SML_ERROR_GENERIC, "Bluetooth not enabled"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Bluetooth not enabled"); goto error; #endif break; default: - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown obex type"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown obex type"); goto error; } smlTrace(TRACE_INTERNAL, "%s: server registered successfully", __func__); @@ -730,11 +731,13 @@ } if (env) smlSafeFree((gpointer *)&env); - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } -static SmlBool smlTransportObexServerFinalize(void *data, SmlError **error) +static gboolean +smlTransportObexServerFinalize (void *data, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, data, error); CHECK_ERROR_REF @@ -770,7 +773,11 @@ return TRUE; } -static void smlTransportObexServerSend(void *userdata, void *linkdata, SmlTransportData *data, SmlError *error) +static void +smlTransportObexServerSend (void *userdata, + void *linkdata, + SmlTransportData *data, + GError *error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, userdata, linkdata, data, error); smlAssert(data || error); @@ -778,13 +785,13 @@ // Unused: SmlTransportObexServerEnv *env = userdata; SmlLinkObexServerEnv *linkenv = linkdata; smlAssert(linkenv); - SmlError *local_error = NULL; + GError *local_error = NULL; if (linkdata == NULL) { /* send is called before connect succeeded or * the user of the library ignored the link */ - smlErrorSet(&local_error, SML_ERROR_GENERIC, + g_set_error(&local_error, SML_ERROR, SML_ERROR_GENERIC, "The OBEX server tries to send before a connection with a client was established or the link was ignored."); goto error; } @@ -798,7 +805,7 @@ } if (linkenv->send_data) { - smlErrorSet(&local_error, SML_ERROR_GENERIC, "We already have waiting data"); + g_set_error(&local_error, SML_ERROR, SML_ERROR_GENERIC, "We already have waiting data"); goto error; } @@ -807,15 +814,15 @@ smlTrace(TRACE_EXIT, "%s", __func__); return; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&local_error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, local_error->message); smlTransportReceiveEvent(linkenv->env->tsp, linkenv->link, SML_TRANSPORT_EVENT_ERROR, NULL, local_error); - smlErrorDeref(&local_error); + g_error_free(local_error); return; } -static void smlTransportObexServerDisconnect(void *data, void *linkdata) +static void +smlTransportObexServerDisconnect(void *data, void *linkdata) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, data, linkdata); smlAssert(data); @@ -835,7 +842,9 @@ return; } -SmlBool smlTransportObexServerNew(SmlTransport *tsp, SmlError **error) +gboolean +smlTransportObexServerNew (SmlTransport *tsp, + GError **error) { CHECK_ERROR_REF smlAssert(tsp); Modified: trunk/libsyncml/transports/obex_server_internals.h ============================================================================== --- trunk/libsyncml/transports/obex_server_internals.h Thu Jul 9 12:34:31 2009 (r1162) +++ trunk/libsyncml/transports/obex_server_internals.h Thu Jul 9 13:57:04 2009 (r1163) @@ -30,12 +30,12 @@ typedef struct SmlTransportObexServerEnv { SmlTransportConnectionType type; SmlTransport *tsp; - char *path; + gchar *path; uint16_t port; #ifdef ENABLE_BLUETOOTH bdaddr_t *bdaddr; #endif - char *irda_service; + gchar *irda_service; obex_t *handle; @@ -51,10 +51,10 @@ uint32_t conid; obex_t *handle; uint8_t *stream_chunk; - SmlBool destroy; - SmlBool disconnect; + gboolean destroy; + gboolean disconnect; GSource *source; - SmlError *error; + GError *error; SmlTransportData *send_data; } SmlLinkObexServerEnv; |
From: <svn...@op...> - 2009-07-09 10:34:42
|
Author: bellmich Date: Thu Jul 9 12:34:31 2009 New Revision: 1162 URL: http://libsyncml.opensync.org/changeset/1162 Log: migrated transports/obex_client from SmlError to GError Modified: trunk/libsyncml/transports/obex_client.c trunk/libsyncml/transports/obex_client_internals.h trunk/libsyncml/transports/obex_client_samsung.c trunk/libsyncml/transports/obex_client_vendor_internals.h Modified: trunk/libsyncml/transports/obex_client.c ============================================================================== --- trunk/libsyncml/transports/obex_client.c Thu Jul 9 12:33:42 2009 (r1161) +++ trunk/libsyncml/transports/obex_client.c Thu Jul 9 12:34:31 2009 (r1162) @@ -58,13 +58,13 @@ #ifndef WIN32 -static SmlBool obex_cable_at( - SmlTransportObexClientEnv *userdata, - const char *cmd, - char *rspbuf, - int rspbuflen, - int timeout, - SmlError **error) +static gboolean +obex_cable_at (SmlTransportObexClientEnv *userdata, + const gchar *cmd, + gchar *rspbuf, + gint rspbuflen, + gint timeout, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %s, %p, %i, %i, %p)", __func__, userdata, VA_STRING(cmd), rspbuf, rspbuflen, timeout, error); CHECK_ERROR_REF @@ -73,7 +73,7 @@ struct timeval tv; gint fd; - SmlBool statusOnly = FALSE; + gboolean statusOnly = FALSE; char *answer = NULL; char *answer_end = NULL; @@ -97,7 +97,7 @@ fd = userdata->fd; rspbuf[0] = 0; if(fd < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The file descriptor for the cable AT command is not legal (%d).", fd); goto error; @@ -108,7 +108,7 @@ cmdlen = strlen(cmd); if(write(fd, cmd, cmdlen) < cmdlen) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The command cannot be written (completely) to the file descriptor."); goto error; } @@ -125,7 +125,7 @@ if(select(fd+1, &ttyset, NULL, NULL, &tv)) { actual = read(fd, &tmpbuf[total], sizeof(tmpbuf) - total); if(actual < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "read failed with return code %i.", actual); goto error; @@ -134,7 +134,7 @@ /* Answer didn't come within the length of the buffer. Cancel! */ if(total == sizeof(tmpbuf)) { - smlErrorSet(error, SML_ERROR_NOT_IMPLEMENTED, + g_set_error(error, SML_ERROR, SML_ERROR_NOT_IMPLEMENTED, "The size of the answer to the AT command %s was too large for the internal buffer.", VA_STRING(cmd)); goto error; @@ -145,7 +145,7 @@ ) { /* check for an error */ if (!strncasecmp("ERROR", answer+1, 5)) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The AT command %s failed.", VA_STRING(cmd)); goto error; @@ -168,7 +168,7 @@ } } else { /* Anser didn't come in time. Cancel */ - smlErrorSet(error, SML_ERROR_INTERNAL_IO_ERROR, + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_IO_ERROR, "The read operation for the answer of the AT command was timed out."); goto error; } @@ -189,7 +189,7 @@ smlTrace(TRACE_INTERNAL, "%s: answer size=%d", __func__, answer_size); if( (answer_size) >= rspbuflen ) { - smlErrorSet(error, SML_ERROR_NOT_IMPLEMENTED, + g_set_error(error, SML_ERROR, SML_ERROR_NOT_IMPLEMENTED, "The size of the answer to the AT command %s was too large.", VA_STRING(cmd)); goto error; @@ -200,7 +200,7 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; error: - smlTrace(TRACE_EXIT, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT, "%s - %s", __func__, (*error)->message); return FALSE; } @@ -228,7 +228,7 @@ return 0; } -SmlTransportObexVendorType smlTransportObexClientGetVendor(const char *manufacturer) +SmlTransportObexVendorType smlTransportObexClientGetVendor(const gchar *manufacturer) { smlTrace(TRACE_ENTRY, "%s(%s)", __func__, VA_STRING(manufacturer)); smlAssert(manufacturer); @@ -247,11 +247,11 @@ return vendor; } -static int smlTransportObexClientCableConnect(obex_t *handle, gpointer ud) +static gint smlTransportObexClientCableConnect(obex_t *handle, gpointer ud) { smlTrace(TRACE_ENTRY, "%s", __func__); - SmlError *error = NULL; + GError *error = NULL; SmlTransportObexClientEnv *userdata = (SmlTransportObexClientEnv *) ud; struct termios newtio; char rspbuf[201]; @@ -259,7 +259,7 @@ userdata->fd = open(userdata->path, O_RDWR|O_NONBLOCK|O_NOCTTY); if (userdata->fd < 0) { - smlErrorSet(&error, SML_ERROR_INTERNAL_IO_ERROR, + g_set_error(&error, SML_ERROR, SML_ERROR_INTERNAL_IO_ERROR, "A valid file descriptor must be non-negative."); goto error; } @@ -279,7 +279,7 @@ goto error; if (strcasecmp("OK", rspbuf)) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The ATZ command was answered with %s.", rspbuf); goto error; @@ -318,7 +318,7 @@ case SML_OBEX_VENDOR_SAMSUNG: smlTrace(TRACE_INTERNAL, "%s: Samsung detected", __func__); if (!smlTransportObexVendorSamsungInit(userdata)) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The intialization for Samsung failed."); goto error; } @@ -340,7 +340,7 @@ goto error; if (strcasecmp("CONNECT", rspbuf)) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The command AT+CPROT=0 failed with answer %s.", rspbuf); goto error; @@ -348,14 +348,14 @@ // fcntl(userdata->fd, F_SETFL, O_NONBLOCK); return 0; error: - perror(smlErrorPrint(&error)); + perror(error->message); smlTransportObexClientCableDisconnect(handle, userdata); - smlTrace(TRACE_ERROR, "%s - %s", __func__, smlErrorPrint(&error)); - smlErrorDeref(&error); + smlTrace(TRACE_ERROR, "%s - %s", __func__, error->message); + g_error_free(error); return -1; } -static int smlTransportObexClientCableWrite(obex_t *handle, gpointer ud, guint8 *buf, int buflen) { +static gint smlTransportObexClientCableWrite(obex_t *handle, gpointer ud, guint8 *buf, gint buflen) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %i)", __func__, handle, ud, buf, buflen); SmlTransportObexClientEnv *userdata = (SmlTransportObexClientEnv *) ud; @@ -414,11 +414,11 @@ #endif -static void smlTransportObexClientEvent(obex_t *handle, obex_object_t *object, int mode, int event, int obex_cmd, int obex_rsp) +static void smlTransportObexClientEvent(obex_t *handle, obex_object_t *object, gint mode, gint event, gint obex_cmd, gint obex_rsp) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %i, %i, %i, %i)", __func__, handle, object, mode, event, obex_cmd, obex_rsp); SmlTransportObexClientEnv *env = OBEX_GetUserData(handle); - SmlError *error = NULL; + GError *error = NULL; switch (event) { case OBEX_EV_PROGRESS: @@ -431,13 +431,13 @@ if (obex_rsp != OBEX_RSP_SUCCESS) { switch(obex_cmd) { case OBEX_CMD_CONNECT: - smlErrorSet(&error, SML_ERROR_INTERNAL_MISCONFIGURATION, + g_set_error(&error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "The OBEX client cannot connect to the configured device or resource (%s - 0x%x).", OBEX_ResponseToString(obex_rsp), obex_rsp); break; default: - smlErrorSet(&error, SML_ERROR_INTERNAL_IO_ERROR, + g_set_error(&error, SML_ERROR, SML_ERROR_INTERNAL_IO_ERROR, "%s (0x%x)", OBEX_ResponseToString(obex_rsp), obex_rsp); @@ -471,14 +471,14 @@ } if (!env->connection_id) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Missing connection id"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Missing connection id"); smlSafeCFree(&who); goto error; } smlTrace(TRACE_INTERNAL, "%s: Got who: %s", __func__, VA_STRING(who)); if (!who || strcmp(who, "SYNCML-SYNC")) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Missing or wrong who response"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Missing or wrong who response"); smlSafeCFree(&who); goto error; } @@ -514,7 +514,7 @@ } if (!length) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Got zero length!"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Got zero length!"); goto error; } @@ -538,12 +538,12 @@ } if (!length) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Missing length"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Missing length"); goto error; } if (!body) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Missing body"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Missing body"); goto error; } @@ -569,11 +569,11 @@ } } else { /* This is a normal error. */ - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Link Error: %s - 0x%x", OBEX_ResponseToString(obex_rsp), obex_rsp); smlTrace(TRACE_INTERNAL, "%s - %s", - __func__, smlErrorPrint(&error)); + __func__, error->message); goto error; } break; @@ -587,18 +587,18 @@ error: smlTransportReceiveEvent(env->tsp, NULL, SML_TRANSPORT_EVENT_ERROR, NULL, error); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&error)); - smlErrorDeref(&error); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, error->message); + g_error_free(error); env->busy = FALSE; env->error = TRUE; return; } -static SmlBool smlTransportObexClientSetConfigOption( - SmlTransport *tsp, - const char *name, - const char *value, - SmlError **error) +static gboolean +smlTransportObexClientSetConfigOption (SmlTransport *tsp, + const gchar *name, + const gchar *value, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %s, %s, %p)", __func__, tsp, VA_STRING(name), VA_STRING(value), error); CHECK_ERROR_REF @@ -610,7 +610,7 @@ /* This transport does not accept NULL as value. */ if (!value) { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "The configuration option %s requires a value.", name); goto error; } @@ -670,7 +670,8 @@ if (!strcasecmp(SML_TRANSPORT_CONFIG_DATASTORE_NOTE, value)) datastore = SML_TRANSPORT_OBEX_DATASTORE_NOTE; if (!datastore) { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, "Unknown datastore %s found.", value); + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, + "Unknown datastore %s found.", value); goto error; } SmlTransportObexDatastoreType *type = smlTryMalloc0(sizeof(SmlTransportObexDatastoreType), error); @@ -680,22 +681,23 @@ env->datastores = g_list_append(env->datastores, type); smlTrace(TRACE_INTERNAL, "%s: Datastore %i detected", __func__, datastore); } else { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, "Unknown parameter %s found.", name); + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, + "Unknown parameter %s found.", name); goto error; } smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; error: - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } -static SmlBool smlTransportObexClientSetConnectionType( - SmlTransport *tsp, - SmlTransportConnectionType type, - SmlError **error) +static gboolean +smlTransportObexClientSetConnectionType (SmlTransport *tsp, + SmlTransportConnectionType type, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, tsp, type, error); CHECK_ERROR_REF @@ -722,14 +724,14 @@ env->obexhandle = OBEX_Init(OBEX_TRANS_USB, smlTransportObexClientEvent, 0); break; default: - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown obex type"); - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown obex type"); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } if (!env->obexhandle) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to open connection"); - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to open connection"); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } @@ -750,7 +752,9 @@ return TRUE; } -static SmlBool smlTransportObexClientInit(SmlTransport *tsp, SmlError **error) +static gboolean +smlTransportObexClientInit (SmlTransport *tsp, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, tsp, error); CHECK_ERROR_REF @@ -763,20 +767,20 @@ switch (env->type) { case SML_TRANSPORT_CONNECTION_TYPE_NET: if (!env->path) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The hostname or address is missing."); goto error; } break; case SML_TRANSPORT_CONNECTION_TYPE_BLUETOOTH: if (!env->path) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The bluetooth address is missing."); goto error; } #ifndef ENABLE_BLUETOOTH_SDPLIB if (!env->port) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The bluetooth channel is missing."); goto error; } @@ -800,11 +804,13 @@ if (env->model) smlSafeCFree(&(env->model)); smlSafeFree((gpointer *)&env); - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } -static SmlBool smlTransportObexClientFinalize(void *data, SmlError **error) +static gboolean +smlTransportObexClientFinalize (void *data, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, data, error); CHECK_ERROR_REF @@ -842,7 +848,7 @@ smlAssert(data); SmlTransportObexClientEnv *env = data; int fd = 0; - SmlError *error = NULL; + GError *error = NULL; unsigned int obex_intf_cnt; obex_interface_t *obex_intf; env->isDisconnected = FALSE; @@ -857,14 +863,14 @@ struct hostent *hostinfo = gethostbyname (env->path); if (!hostinfo) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unknown host %s", env->path); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unknown host %s", env->path); goto error; } addr.sin_addr = *(struct in_addr *) hostinfo->h_addr_list[0]; fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Cannot create socket: %s", strerror(errno)); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Cannot create socket: %s", strerror(errno)); goto error; } @@ -874,7 +880,7 @@ smlTrace(TRACE_INTERNAL, "%s: peer addr = %d %s %i", __func__, hostinfo->h_addr_list[0], VA_STRING(addrstr), env->port); if (connect(fd, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Cannot connect socket: %s", strerror(errno)); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Cannot connect socket: %s", strerror(errno)); goto error_close; } smlTrace(TRACE_INTERNAL, "%s: connect done", __func__); @@ -886,14 +892,14 @@ smlTrace(TRACE_INTERNAL, "%s: found %i interfaces", __func__, obex_intf_cnt); if (obex_intf_cnt <= 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, "There are no valid USB interfaces."); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "There are no valid USB interfaces."); goto error; } else if (env->port >= obex_intf_cnt) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unable to find the USB interface number %i", env->port); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unable to find the USB interface number %i", env->port); goto error; } else { if (GET_OBEX_RESULT(OBEX_InterfaceConnect(env->obexhandle, &obex_intf[env->port])) < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The interface cannot be connected. %s (%i).", strerror(errno), errno); goto error; @@ -914,7 +920,7 @@ sdp_session_t *sdp_session = sdp_connect(BDADDR_ANY, &bdaddr, SDP_RETRY_IF_BUSY); if (!sdp_session) { - smlErrorSet(&error, SML_ERROR_GENERIC, "The Bluetooth connect to search for the channel failed."); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The Bluetooth connect to search for the channel failed."); goto error; } unsigned char syncml_client_uuid[] = { @@ -932,8 +938,8 @@ sdp_list_free(attribute, 0); sdp_list_free(class, 0); - smlErrorSet( - &error, SML_ERROR_GENERIC, + g_set_error( + &error, SML_ERROR, SML_ERROR_GENERIC, "The service search on the Bluetooth device failed."); goto error; } @@ -962,7 +968,7 @@ #endif if (GET_OBEX_RESULT(BtOBEX_TransportConnect(env->obexhandle, BDADDR_ANY, &bdaddr, channel)) < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The Bluetooth connect failed. %s (%i).", strerror(errno), errno); goto error; @@ -970,14 +976,14 @@ smlTrace(TRACE_INTERNAL, "%s: bluetooth connect done", __func__); #else - smlErrorSet(&error, SML_ERROR_GENERIC, "Bluetooth not enabled"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Bluetooth not enabled"); goto error; #endif } else if (env->type == SML_TRANSPORT_CONNECTION_TYPE_IRDA) { smlTrace(TRACE_INTERNAL, "%s: connecting to IrDA service %s", __func__, env->irda_service ? env->irda_service : "OBEX"); if (GET_OBEX_RESULT(IrOBEX_TransportConnect(env->obexhandle, env->irda_service)) < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The IrDA connect failed. %s (%i).", strerror(errno), errno); goto error; @@ -992,18 +998,18 @@ /* Open the file descriptor */ fd = open(env->path, O_RDWR | O_NOCTTY); if (fd == -1) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unable to open %s: %s", env->path, strerror(errno)); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unable to open %s: %s", env->path, strerror(errno)); goto error; } /* Lock it*/ if (lockf(fd, F_TLOCK, 0)) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unable to lock %s: %s", env->path, strerror(errno)); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unable to lock %s: %s", env->path, strerror(errno)); goto error_close; } if (tcgetattr(fd, &tio)) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unable to get attr from %s", env->path); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unable to get attr from %s", env->path); goto error_unlock; } @@ -1024,7 +1030,7 @@ cfsetospeed(&tio, B115200); if (tcsetattr(fd, TCSANOW, &tio)) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unable to set attr from %s", env->path); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unable to set attr from %s", env->path); goto error_unlock; } tcflush(fd, TCIFLUSH); @@ -1036,7 +1042,7 @@ && env->type != SML_TRANSPORT_CONNECTION_TYPE_IRDA) { /* Start the obex transport */ if (GET_OBEX_RESULT(FdOBEX_TransportSetup(env->obexhandle, fd, fd, 4096)) < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The OBEX transport setup failed. %s (%i).", strerror(errno), errno); goto error_unlock; @@ -1046,7 +1052,7 @@ /* Make a new connect object */ obex_object_t *obj = OBEX_ObjectNew(env->obexhandle, OBEX_CMD_CONNECT); if (!obj) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unable to create new connect object"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unable to create new connect object"); goto error_transport_close; } @@ -1058,7 +1064,7 @@ env->busy = TRUE; /* Now we need to send the request */ if (GET_OBEX_RESULT(OBEX_Request(env->obexhandle, obj)) < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The OBEX request failed. %s (%i).", strerror(errno), errno); goto error_free_obj; @@ -1073,12 +1079,12 @@ while (env->busy) { int result = OBEX_HandleInput(env->obexhandle, 20); if (result < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The connect request was not successful (%i).", result); goto error; } else if (result == 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The connect request was timed out."); goto error; } @@ -1100,8 +1106,8 @@ close(fd); error: smlTransportReceiveEvent(env->tsp, NULL, SML_TRANSPORT_EVENT_ERROR, NULL, error); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&error)); - smlErrorDeref(&error); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, error->message); + g_error_free(error); } static void smlTransportObexClientDisconnect(void *data, void *linkdata) @@ -1109,7 +1115,7 @@ smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, data, linkdata); smlAssert(data); SmlTransportObexClientEnv *env = data; - SmlError *error = NULL; + GError *error = NULL; if (env->isDisconnected) { /* This is a bug. If the transport is disconnected @@ -1128,7 +1134,7 @@ /* Make a new disconnect object */ obex_object_t *obj = OBEX_ObjectNew(env->obexhandle, OBEX_CMD_DISCONNECT); if (!obj) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unable to create new disconnect object"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unable to create new disconnect object"); goto error; } @@ -1140,14 +1146,14 @@ env->busy = TRUE; /* Now we need to send the request */ if (GET_OBEX_RESULT(OBEX_Request(env->obexhandle, obj)) < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The OBEX request cannot be sent. %s (%i).", strerror(errno), errno); goto error_free_obj; } if (env->error) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unable to send disconnect request. Bailing out"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unable to send disconnect request. Bailing out"); goto error; } @@ -1163,12 +1169,12 @@ int result = OBEX_HandleInput(env->obexhandle, 1); /* timeout and success are not relevant */ if (result < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The disconnect request was not accepted (%i).", result); goto error; } else if (result == 0 && !env->busy && !env->isDisconnected) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The disconnect request was timed out."); goto error; } @@ -1197,11 +1203,15 @@ OBEX_ObjectDelete(env->obexhandle, obj); error: smlTransportReceiveEvent(env->tsp, NULL, SML_TRANSPORT_EVENT_ERROR, NULL, error); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&error)); - smlErrorDeref(&error); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, error->message); + g_error_free(error); } -static void smlTransportObexClientSend(void *userdata, void *link_, SmlTransportData *data, SmlError *error) +static void +smlTransportObexClientSend (void *userdata, + void *link_, + SmlTransportData *data, + GError *error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, userdata, link_, data, error); smlAssert(error || data); @@ -1218,7 +1228,7 @@ /* Make a new put command */ obex_object_t *obj = OBEX_ObjectNew(env->obexhandle, OBEX_CMD_PUT); if (!obj) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unable to create new put object"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unable to create new put object"); goto error; } @@ -1243,7 +1253,7 @@ target = SML_ELEMENT_SAN; break; default: - smlErrorSet(&error, SML_ERROR_GENERIC, "Unknown mime type"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unknown mime type"); goto error_free_obj; } smlTrace(TRACE_INTERNAL, "%s: Target %s", __func__, VA_STRING(target)); @@ -1253,7 +1263,7 @@ unsigned int unicodesize = OBEX_CharToUnicode(unicode, (const unsigned char *)target, 2 * strlen(target) + 2); if (unicodesize == -1) { - smlErrorSet(&error, SML_ERROR_GENERIC, "unable to convert to unicode"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "unable to convert to unicode"); goto error_free_obj; }*/ @@ -1273,7 +1283,7 @@ env->busy = TRUE; /* Now we need to send the request */ if (GET_OBEX_RESULT(OBEX_Request(env->obexhandle, obj)) < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The OBEX request cannot be sent. %s (%i).", strerror(errno), errno); goto error_free_obj; @@ -1283,19 +1293,19 @@ while (env->busy) { int result = OBEX_HandleInput(env->obexhandle, 20); if (result < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The request was not successful (%d).", result); goto error; } else if (result == 0 && !env->busy) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The request was timed out."); goto error; } } if (env->error) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unable to send put request. Bailing out"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unable to send put request. Bailing out"); goto error; } @@ -1309,7 +1319,7 @@ /* Make a new get command */ obj = OBEX_ObjectNew(env->obexhandle, OBEX_CMD_GET); if (!obj) { - smlErrorSet(&error, SML_ERROR_GENERIC, "Unable to create new get object"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unable to create new get object"); goto error; } @@ -1340,7 +1350,7 @@ target = SML_ELEMENT_SAN; break; default: - smlErrorSet(&error, SML_ERROR_GENERIC, "Unknown mime type"); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Unknown mime type"); goto error_free_obj; } @@ -1360,7 +1370,7 @@ env->busy = TRUE; /* Now we need to send the request */ if (GET_OBEX_RESULT(OBEX_Request(env->obexhandle, obj)) < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The OBEX request cannot be sent. %s (%i).", strerror(errno), errno); goto error_free_obj; @@ -1371,12 +1381,12 @@ while (env->busy) { int result = OBEX_HandleInput(env->obexhandle, 20); if (result < 0) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The answer was not received successfully (%i).", result); goto error; } else if (result == 0 && !env->busy) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "The answer was timed out."); goto error; } @@ -1389,11 +1399,14 @@ OBEX_ObjectDelete(env->obexhandle, obj); error: smlTransportReceiveEvent(env->tsp, NULL, SML_TRANSPORT_EVENT_ERROR, NULL, error); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, error->message); + g_error_free(error); return; } -SmlBool smlTransportObexClientNew(SmlTransport *tsp, SmlError **error) +gboolean +smlTransportObexClientNew (SmlTransport *tsp, + GError **error) { CHECK_ERROR_REF smlAssert(tsp); Modified: trunk/libsyncml/transports/obex_client_internals.h ============================================================================== --- trunk/libsyncml/transports/obex_client_internals.h Thu Jul 9 12:33:42 2009 (r1161) +++ trunk/libsyncml/transports/obex_client_internals.h Thu Jul 9 12:34:31 2009 (r1162) @@ -49,27 +49,27 @@ SmlTransportConnectionType type; SmlTransport *tsp; obex_t *obexhandle; - uint32_t connection_id; - char *path; - unsigned int port; - char *irda_service; - char *at_command; - char *manufacturer; - char *model; + guint32 connection_id; + gchar *path; + guint port; + gchar *irda_service; + gchar *at_command; + gchar *manufacturer; + gchar *model; GList *datastores; - int fd; - int state; - char *databuf; - int *databuflen; - int connected; + gint fd; + gint state; + gchar *databuf; + gint *databuflen; + gint connected; #ifndef WIN32 struct termios oldtio; #endif - SmlBool busy; - SmlBool error; + gboolean busy; + gboolean error; SmlMimeType mimetype; - SmlBool isDisconnected; + gboolean isDisconnected; } SmlTransportObexClientEnv; gboolean smlTransportObexClientNew (SmlTransport *tsp, GError **error); Modified: trunk/libsyncml/transports/obex_client_samsung.c ============================================================================== --- trunk/libsyncml/transports/obex_client_samsung.c Thu Jul 9 12:33:42 2009 (r1161) +++ trunk/libsyncml/transports/obex_client_samsung.c Thu Jul 9 12:34:31 2009 (r1162) @@ -1,6 +1,6 @@ /* * libsyncml - A syncml protocol implementation - * Copyright (C) 2008 Michael Bell <mic...@op...> + * Copyright (C) 2008-2009 Michael Bell <mic...@op...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -24,7 +24,7 @@ #include <libsyncml/sml_transport_internals.h> #include "obex_client_internals.h" -SmlBool smlTransportObexVendorSamsungInit(SmlTransportObexClientEnv *env) +gboolean smlTransportObexVendorSamsungInit(SmlTransportObexClientEnv *env) { smlTrace(TRACE_EXIT, "%s(%p, %s)", __func__, VA_STRING(env->model)); Modified: trunk/libsyncml/transports/obex_client_vendor_internals.h ============================================================================== --- trunk/libsyncml/transports/obex_client_vendor_internals.h Thu Jul 9 12:33:42 2009 (r1161) +++ trunk/libsyncml/transports/obex_client_vendor_internals.h Thu Jul 9 12:34:31 2009 (r1162) @@ -1,6 +1,6 @@ /* * libsyncml - A syncml protocol implementation - * Copyright (C) 2008 Michael Bell <mic...@op...> + * Copyright (C) 2008-2009 Michael Bell <mic...@op...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -21,6 +21,6 @@ #ifndef _OBEX_CLIENT_SAMSUNG_INTERNALS_H_ #define _OBEX_CLIENT_SAMSUNG_INTERNALS_H_ -SmlBool smlTransportObexVendorSamsungInit(SmlTransportObexClientEnv *env); +gboolean smlTransportObexVendorSamsungInit(SmlTransportObexClientEnv *env); #endif //_OBEX_CLIENT_SAMSUNG_INTERNALS_H_ |
From: <svn...@op...> - 2009-07-09 10:33:53
|
Author: bellmich Date: Thu Jul 9 12:33:42 2009 New Revision: 1161 URL: http://libsyncml.opensync.org/changeset/1161 Log: migrated parser/sml_xml_parser from SmlError to GError Modified: trunk/libsyncml/parser/sml_xml_parse.c trunk/libsyncml/parser/sml_xml_parse.h trunk/libsyncml/parser/sml_xml_parse_internals.h Modified: trunk/libsyncml/parser/sml_xml_parse.c ============================================================================== --- trunk/libsyncml/parser/sml_xml_parse.c Wed Jul 8 17:23:22 2009 (r1160) +++ trunk/libsyncml/parser/sml_xml_parse.c Thu Jul 9 12:33:42 2009 (r1161) @@ -33,9 +33,9 @@ #define BUFFER_SIZE 500 -static SmlBool _smlXmlParserStep(SmlXmlParser *parser) +static gboolean _smlXmlParserStep(SmlXmlParser *parser) { - SmlBool ret = FALSE; + gboolean ret = FALSE; do { ret = (xmlTextReaderRead(parser->reader) == 1) ? TRUE : FALSE; } while (ret && (xmlTextReaderNodeType(parser->reader) == XML_READER_TYPE_DOCUMENT_TYPE || \ @@ -45,9 +45,9 @@ return ret; } -static SmlBool _smlXmlParserStepData(SmlXmlParser *parser) +static gboolean _smlXmlParserStepData(SmlXmlParser *parser) { - SmlBool ret = FALSE; + gboolean ret = FALSE; do { ret = (xmlTextReaderRead(parser->reader) == 1) ? TRUE : FALSE; } while (ret && (xmlTextReaderNodeType(parser->reader) == XML_READER_TYPE_DOCUMENT_TYPE || \ @@ -56,7 +56,7 @@ return ret; } -static SmlBool _smlXmlSkipNode(SmlXmlParser *parser) +static gboolean _smlXmlSkipNode(SmlXmlParser *parser) { int node_type; @@ -75,16 +75,21 @@ return TRUE; } -static SmlBool _smlXmlParserExpectNode(SmlXmlParser *parser, int type, SmlBool empty, const char *name, SmlError **error) +static gboolean +_smlXmlParserExpectNode (SmlXmlParser *parser, + int type, + gboolean empty, + const gchar *name, + GError **error) { CHECK_ERROR_REF if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "No node at all"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No node at all"); return FALSE; } if (xmlTextReaderNodeType(parser->reader) != type) { - smlErrorSet(error, SML_ERROR_GENERIC, "wrong node type"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "wrong node type"); return FALSE; } @@ -94,38 +99,42 @@ case XML_NODE_CLOSE: if (name) { if (!xmlTextReaderConstName(parser->reader)) { - smlErrorSet(error, SML_ERROR_GENERIC, "no name"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "no name"); return FALSE; } if (strcmp((char *)xmlTextReaderConstName(parser->reader), name)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Wrong name"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Wrong name"); return FALSE; } } break; case XML_NODE_TEXT: if (!empty && !xmlTextReaderConstName(parser->reader)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Empty."); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Empty."); return FALSE; } break; default: - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown node type"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown node type"); return FALSE; } return TRUE; } -static SmlBool _smlXmlParserGetID(SmlXmlParser *parser, unsigned int *id, const char *name, SmlError **error) +static gboolean +_smlXmlParserGetID (SmlXmlParser *parser, + guint64 *id, + const gchar *name, + GError **error) { CHECK_ERROR_REF smlAssert(parser); smlAssert(id); if (*id) { - smlErrorSet(error, SML_ERROR_GENERIC, "Id already set"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Id already set"); goto error; } @@ -138,19 +147,22 @@ goto error; return TRUE; - error: return FALSE; } -static SmlBool _smlXmlParserGetString(SmlXmlParser *parser, char **string, const char *name, SmlError **error) +static gboolean +_smlXmlParserGetString (SmlXmlParser *parser, + gchar **string, + const gchar *name, + GError **error) { CHECK_ERROR_REF smlAssert(parser); smlAssert(string); if (*string) { - smlErrorSet(error, SML_ERROR_GENERIC, "string already set"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "string already set"); goto error; } @@ -161,7 +173,7 @@ } if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "No node at all"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No node at all"); goto error_clear; } @@ -173,7 +185,7 @@ } else if (xmlTextReaderNodeType(parser->reader) == XML_NODE_CLOSE) { *string = g_strdup(""); } else { - smlErrorSet(error, SML_ERROR_GENERIC, "wrong node type"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "wrong node type"); goto error_clear; } @@ -185,7 +197,12 @@ return FALSE; } -static SmlBool _smlXmlParserGetData(SmlXmlParser *parser, char **string, unsigned int *size, const char *name, SmlError **error) +static gboolean +_smlXmlParserGetData (SmlXmlParser *parser, + gchar **string, + gsize *size, + const gchar *name, + GError **error) { CHECK_ERROR_REF smlAssert(parser); @@ -193,20 +210,20 @@ int rc = 0; if (*string) { - smlErrorSet(error, SML_ERROR_GENERIC, "string already set"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "string already set"); return FALSE; } xmlBuffer *buffer = xmlBufferCreateSize(BUFFER_SIZE); if (!buffer) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to create new buffer"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to create new buffer"); goto error; } xmlTextWriter *writer = xmlNewTextWriterMemory(buffer, 0); if (!writer) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to create new writer"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to create new writer"); goto error_free_buffer; } @@ -216,7 +233,8 @@ while (1) { if (!_smlXmlParserStepData(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "There is a missing node during the data parsing of %s.", name); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "There is a missing node during the data parsing of %s.", name); goto error_free_writer; } @@ -229,7 +247,8 @@ rc = xmlTextWriterEndElement(writer); if (rc < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to end node"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Unable to end node"); goto error_free_writer; } break; @@ -240,7 +259,7 @@ rc = xmlTextWriterWriteElementNS(writer, NULL, xmlTextReaderConstName(parser->reader), NULL, (const xmlChar*)""); if (rc < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to start node"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to start node"); goto error_free_writer; } break; @@ -248,19 +267,19 @@ case XML_NODE_TEXT: rc = xmlTextWriterWriteRaw(writer, xmlTextReaderConstValue(parser->reader)); if (rc < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to add string"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to add string"); goto error_free_writer; } break; case XML_READER_TYPE_SIGNIFICANT_WHITESPACE: rc = xmlTextWriterWriteRaw(writer, xmlTextReaderConstValue(parser->reader)); if (rc < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to add string"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to add string"); goto error_free_writer; } break; default: - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown node type"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown node type"); goto error_free_writer; } } @@ -292,7 +311,10 @@ return FALSE; } -static SmlBool _smlSyncHeaderParseDTD(SmlProtocolVersion *version, SmlXmlParser *parser, SmlError **error) +static gboolean +_smlSyncHeaderParseDTD (SmlProtocolVersion *version, + SmlXmlParser *parser, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, version, parser, error); CHECK_ERROR_REF @@ -300,8 +322,8 @@ smlAssert(version); if (*version) { - smlErrorSet(error, SML_ERROR_GENERIC, "dtd already set"); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "dtd already set"); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } @@ -317,21 +339,23 @@ *version = SML_VERSION_12; else { smlSafeCFree(&dtd); - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown VerDTD"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown VerDTD"); goto error; } smlSafeCFree(&dtd); smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: *version = SML_VERSION_UNKNOWN; - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -static SmlBool _smlSyncHeaderParseProto(SmlProtocolType *type, SmlXmlParser *parser, SmlError **error) +static gboolean +_smlSyncHeaderParseProto (SmlProtocolType *type, + SmlXmlParser *parser, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, type, parser, error); CHECK_ERROR_REF @@ -339,8 +363,8 @@ smlAssert(type); if (*type) { - smlErrorSet(error, SML_ERROR_GENERIC, "protocol already set"); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "protocol already set"); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } @@ -352,44 +376,45 @@ *type = SML_PROTOCOL_SYNCML; else { smlSafeCFree(&proto); - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown VerProto"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown VerProto"); goto error; } smlSafeCFree(&proto); smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: *type = SML_PROTOCOL_UNKNOWN; - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -static SmlBool _smlLocationParse(SmlLocation **location, SmlXmlParser *parser, SmlError **error) +static gboolean +_smlLocationParse (SmlLocation **location, + SmlXmlParser *parser, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, location, parser, error); CHECK_ERROR_REF smlAssert(parser); smlAssert(location); - GError *gerror = NULL; if (*location) { - smlErrorSet(error, SML_ERROR_GENERIC, "Location already set"); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Location already set"); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } *location = sml_location_new(); if (!location) { - smlErrorSet(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; } while (1) { if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing nodes"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing nodes"); goto error; } @@ -406,7 +431,7 @@ xmlTextReaderNodeType(parser->reader) == XML_NODE_CLOSE) { break; } else if (xmlTextReaderNodeType(parser->reader) != XML_NODE_START) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The element %s is not a start node in locations (Target, Source, SourceParent or TargetParent).", xmlTextReaderConstName(parser->reader)); goto error; @@ -416,7 +441,7 @@ gchar *uri = NULL; if (!_smlXmlParserGetString(parser, &uri, SML_ELEMENT_LOCURI, error)) goto error; - if (!sml_location_set_uri(*location, uri, &gerror)) { + if (!sml_location_set_uri(*location, uri, error)) { g_free(uri); goto error; } @@ -425,35 +450,36 @@ gchar *name = NULL; if (!_smlXmlParserGetString(parser, &name, SML_ELEMENT_LOCNAME, error)) goto error; - if (!sml_location_set_name(*location, name, &gerror)) { + if (!sml_location_set_name(*location, name, error)) { g_free(name); goto error; } g_free(name); } else { - smlErrorSet(error, SML_ERROR_GENERIC, "wrong initial node. expected SyncHdr"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "wrong initial node. expected SyncHdr"); goto error; } } if (!sml_location_get_uri(*location)) { - smlErrorSet(error, SML_ERROR_GENERIC, "No locURI set"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No locURI set"); goto error; } smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: if (*location) g_object_unref(*location); *location = NULL; - 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; } -static SmlBool _smlAnchorParse(SmlAnchor **anchor, SmlXmlParser *parser, SmlError **error) +static gboolean +_smlAnchorParse (SmlAnchor **anchor, + SmlXmlParser *parser, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, anchor, parser, error); CHECK_ERROR_REF @@ -461,8 +487,8 @@ smlAssert(anchor); if (*anchor) { - smlErrorSet(error, SML_ERROR_GENERIC, "anchor already set"); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "anchor already set"); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } @@ -472,7 +498,7 @@ while (1) { if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing nodes"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing nodes"); goto error_free_anchor; } @@ -480,7 +506,7 @@ xmlTextReaderNodeType(parser->reader) == XML_NODE_CLOSE) { break; } else if (xmlTextReaderNodeType(parser->reader) != XML_NODE_START) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The element %s is not a start node in Anchor.", xmlTextReaderConstName(parser->reader)); goto error_free_anchor; @@ -493,13 +519,13 @@ if (!_smlXmlParserGetString(parser, &((*anchor)->last), SML_ELEMENT_LAST, error)) goto error_free_anchor; } else { - smlErrorSet(error, SML_ERROR_GENERIC, "wrong initial node"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "wrong initial node"); goto error_free_anchor; } } if (!(*anchor)->next) { - smlErrorSet(error, SML_ERROR_GENERIC, "No next set"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No next set"); goto error_free_anchor; } @@ -510,11 +536,16 @@ smlAnchorFree(*anchor); error: *anchor = NULL; - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -static SmlBool _smlChalMetaParse(SmlXmlParser *parser, char **format, char **type, char **nonce, SmlError **error) +static gboolean +_smlChalMetaParse (SmlXmlParser *parser, + gchar **format, + gchar **type, + gchar **nonce, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %p, %p, %p)", __func__, parser, format, type, nonce, error); CHECK_ERROR_REF @@ -522,7 +553,7 @@ while (1) { if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing nodes"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing nodes"); goto error; } @@ -530,7 +561,7 @@ xmlTextReaderNodeType(parser->reader) == XML_NODE_CLOSE) { break; } else if (xmlTextReaderNodeType(parser->reader) != XML_NODE_START) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The element %s is not a start node in Chal/Meta.", xmlTextReaderConstName(parser->reader)); goto error; @@ -546,7 +577,7 @@ if (!_smlXmlParserGetString(parser, nonce, SML_ELEMENT_NEXTNONCE, error)) goto error; } else { - smlErrorSet(error, SML_ERROR_GENERIC, "wrong initial node: %s", xmlTextReaderConstName(parser->reader)); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "wrong initial node: %s", xmlTextReaderConstName(parser->reader)); goto error; } } @@ -562,18 +593,25 @@ if (type) *type = NULL; - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -static SmlBool _smlCommandMetaParse(SmlXmlParser *parser, char **format, char **type, SmlAnchor **anchor, unsigned int *size, int *maxobjsize, SmlError **error) +static gboolean +_smlCommandMetaParse (SmlXmlParser *parser, + gchar **format, + gchar **type, + SmlAnchor **anchor, + gsize *size, + gsize *maxobjsize, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %p, %p, %p)", __func__, parser, format, type, anchor, size, maxobjsize, error); CHECK_ERROR_REF smlAssert(parser); if (maxobjsize) - *maxobjsize = -1; + *maxobjsize = 0; if (xmlTextReaderIsEmptyElement(parser->reader)) { @@ -584,7 +622,7 @@ while (1) { if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing nodes"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing nodes"); goto error; } @@ -592,7 +630,7 @@ /* Ignored for now */ smlTrace(TRACE_INTERNAL, "%s: Skipping mem node"); if (!_smlXmlSkipNode(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to skip mem node"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to skip mem node"); goto error; } } @@ -601,7 +639,7 @@ xmlTextReaderNodeType(parser->reader) == XML_NODE_CLOSE) { break; } else if (xmlTextReaderNodeType(parser->reader) != XML_NODE_START) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The element %s is not a start node in Command/Meta.", xmlTextReaderConstName(parser->reader)); goto error; @@ -623,15 +661,17 @@ goto error; smlSafeCFree(&mark); } else if (size && !strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_SIZE)) { - if (!_smlXmlParserGetID(parser, size, SML_ELEMENT_SIZE, error)) + guint64 id = 0; + if (!_smlXmlParserGetID(parser, &id, SML_ELEMENT_SIZE, error)) goto error; + *size = id; } else if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_MAXOBJSIZE)) { /* MaxObjSize must be parsed even if there is no maxobjsize pointer */ - unsigned int loc_maxobjsize = 0; - if (!_smlXmlParserGetID(parser, &loc_maxobjsize, SML_ELEMENT_MAXOBJSIZE, error)) + guint64 id = 0; + if (!_smlXmlParserGetID(parser, &id, SML_ELEMENT_MAXOBJSIZE, error)) goto error; if (maxobjsize) - *maxobjsize = loc_maxobjsize; + *maxobjsize = id; } else if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_VERSION)) { /* Ignore the version for now */ char *version = NULL; @@ -639,7 +679,7 @@ goto error; smlSafeCFree(&version); } else { - smlErrorSet(error, SML_ERROR_GENERIC, "wrong initial node for meta information: %s", xmlTextReaderConstName(parser->reader)); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "wrong initial node for meta information: %s", xmlTextReaderConstName(parser->reader)); goto error; } } @@ -654,21 +694,24 @@ *anchor = NULL; if (type) *type = NULL; - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -static SmlItem *_smlItemParse(SmlXmlParser *parser, SmlCommand *cmd, SmlCommandType type, SmlError **error) +static SmlItem* +_smlItemParse (SmlXmlParser *parser, + SmlCommand *cmd, + SmlCommandType type, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %i, %p)", __func__, parser, cmd, type, error); 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"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Last item already had more data set"); goto error; } @@ -684,7 +727,7 @@ } if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "The first element inside of an Item structure cannot be parsed."); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The first element inside of an Item structure cannot be parsed."); goto error; } @@ -693,7 +736,7 @@ xmlTextReaderNodeType(parser->reader) == XML_NODE_CLOSE) { break; } else if (xmlTextReaderNodeType(parser->reader) != XML_NODE_START) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The element %s is not a start node in Item.", xmlTextReaderConstName(parser->reader)); goto error; @@ -706,7 +749,7 @@ if (smlItemGetSource(item)) { /* SourceParent already parsed */ - if (!sml_location_set_parent_uri(source, sml_location_get_parent_uri(smlItemGetSource(item)), &gerror)) + if (!sml_location_set_parent_uri(source, sml_location_get_parent_uri(smlItemGetSource(item)), error)) goto error; } @@ -719,7 +762,7 @@ if (smlItemGetTarget(item)) { /* TargetParent already parsed */ - if (!sml_location_set_parent_uri(target, sml_location_get_parent_uri(smlItemGetTarget(item)), &gerror)) + if (!sml_location_set_parent_uri(target, sml_location_get_parent_uri(smlItemGetTarget(item)), error)) goto error; } @@ -732,16 +775,16 @@ if (smlItemGetSource(item)) { /* Source already parsed */ - if (!sml_location_set_parent_uri(smlItemGetSource(item), sml_location_get_uri(source), &gerror)) + if (!sml_location_set_parent_uri(smlItemGetSource(item), sml_location_get_uri(source), error)) 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)) + if (!sml_location_set_parent_uri(source, sml_location_get_uri(source), error)) goto error; /* delete uri property */ - if (!sml_location_set_uri(source, NULL, &gerror)) + if (!sml_location_set_uri(source, NULL, error)) goto error; } @@ -753,16 +796,16 @@ if (smlItemGetTarget(item)) { /* Target already parsed */ - if (!sml_location_set_parent_uri(smlItemGetTarget(item), sml_location_get_uri(target), &gerror)) + if (!sml_location_set_parent_uri(smlItemGetTarget(item), sml_location_get_uri(target), error)) 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)) + if (!sml_location_set_parent_uri(target, sml_location_get_uri(target), error)) goto error; /* delete uri property */ - if (!sml_location_set_uri(target, NULL, &gerror)) + if (!sml_location_set_uri(target, NULL, error)) goto error; } @@ -801,7 +844,7 @@ goto error; break; default: - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown command type"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown command type"); goto error; } } else if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_DATA)) { @@ -814,7 +857,7 @@ switch (type) { 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."); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The next element after the starting Data element in an Item is missing."); goto error; } @@ -846,7 +889,7 @@ item->anchor = anchor; if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "The closing Data element in an Item is missing."); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The closing Data element in an Item is missing."); goto error; } break; @@ -866,32 +909,32 @@ } } 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"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "SyncML 1.0 does not allow MoreData"); goto error; } item->moreData = TRUE; parser->gotMoreData = TRUE; if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing nodes2"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing nodes2"); 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"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing nodes3"); goto error; } } continue; } else { - smlErrorSet(error, SML_ERROR_GENERIC, "The element Item does not support the child element %s.", xmlTextReaderConstName(parser->reader)); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The element Item does not support the child element %s.", xmlTextReaderConstName(parser->reader)); goto error; } if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "The next element in an Item structure is missing."); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The next element in an Item structure is missing."); goto error; } } @@ -902,12 +945,13 @@ error: if (item) smlItemUnref(item); - 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; } -static SmlCred *_smlCredParse(SmlXmlParser *parser, SmlError **error) +static SmlCred* +_smlCredParse (SmlXmlParser *parser, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, parser, error); CHECK_ERROR_REF @@ -919,7 +963,7 @@ while (1) { if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing nodes"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing nodes"); goto error; } @@ -927,7 +971,7 @@ xmlTextReaderNodeType(parser->reader) == XML_NODE_CLOSE) { break; } else if (xmlTextReaderNodeType(parser->reader) != XML_NODE_START) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The element %s is not a start node in Cred.", xmlTextReaderConstName(parser->reader)); goto error; @@ -940,7 +984,7 @@ if (!_smlXmlParserGetString(parser, &data, SML_ELEMENT_DATA, error)) goto error; } else { - smlErrorSet(error, SML_ERROR_GENERIC, "wrong initial node %s", xmlTextReaderConstName(parser->reader)); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "wrong initial node %s", xmlTextReaderConstName(parser->reader)); goto error; } } @@ -957,19 +1001,21 @@ if (type) smlSafeCFree(&type); - if (!smlErrorIsSet(error)) + if (!(*error)) { smlTrace(TRACE_EXIT, "%s: %p", __func__, cred); return cred; } else { if (cred) smlCredUnref(cred); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } } -static SmlChal *_smlChalParse(SmlXmlParser *parser, SmlError **error) +static SmlChal* +_smlChalParse (SmlXmlParser *parser, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, parser, error); CHECK_ERROR_REF @@ -980,7 +1026,7 @@ while (1) { if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing nodes"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing nodes"); goto error; } @@ -988,7 +1034,7 @@ xmlTextReaderNodeType(parser->reader) == XML_NODE_CLOSE) { break; } else if (xmlTextReaderNodeType(parser->reader) != XML_NODE_START) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The element %s is not a start node in Chal.", xmlTextReaderConstName(parser->reader)); goto error; @@ -998,13 +1044,13 @@ if (!_smlChalMetaParse(parser, &format, &type, &nonce, error)) goto error; } else { - smlErrorSet(error, SML_ERROR_GENERIC, "wrong initial node %s", xmlTextReaderConstName(parser->reader)); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "wrong initial node %s", xmlTextReaderConstName(parser->reader)); goto error; } } if (format && strcmp(format, SML_BASE64)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown format"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown format"); goto error; } @@ -1014,7 +1060,7 @@ } else if (!strcmp(type, SML_AUTH_MD5)) { auth = SML_AUTH_TYPE_MD5; } else { - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown type"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown type"); goto error; } @@ -1036,7 +1082,6 @@ smlTrace(TRACE_EXIT, "%s: %p", __func__, chal); return chal; - error: if (format) smlSafeCFree(&format); @@ -1044,17 +1089,21 @@ smlSafeCFree(&type); if (nonce) smlSafeCFree(&nonce); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -static SmlBool _smlChangeParse(SmlXmlParser *parser, SmlCommand **cmd, SmlCommandType type, const char *name, SmlError **error) +static gboolean +_smlChangeParse (SmlXmlParser *parser, + SmlCommand **cmd, + SmlCommandType type, + const gchar *name, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %s, %p)", __func__, parser, type, VA_STRING(name), error); CHECK_ERROR_REF smlAssert(parser); smlAssert(name); - GError *gerror = NULL; char *contenttype = NULL; *cmd = smlCommandNew(type, error); @@ -1064,7 +1113,7 @@ while (1) { if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing nodes"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing nodes"); goto error; } @@ -1072,15 +1121,17 @@ xmlTextReaderNodeType(parser->reader) == XML_NODE_CLOSE) { break; } else if (xmlTextReaderNodeType(parser->reader) != XML_NODE_START) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The element %s is not a start node in %s.", xmlTextReaderConstName(parser->reader), name); goto error; } if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_CMDID)) { - if (!_smlXmlParserGetID(parser, &((*cmd)->cmdID), SML_ELEMENT_CMDID, error)) + guint64 id = 0; + if (!_smlXmlParserGetID(parser, &id, SML_ELEMENT_CMDID, error)) goto error; + (*cmd)->cmdID = id; } else if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_ITEM)) { SmlItem *item = _smlItemParse(parser, *cmd, type, error); if (!item) @@ -1089,26 +1140,26 @@ if (!(*cmd)->private.change.items) { smlItemUnref(item); - smlErrorSet(error, SML_ERROR_GENERIC, "g_list_append for item list of change command failed."); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "g_list_append for item list of change command failed."); goto error; } } else if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_META)) { if (!_smlCommandMetaParse(parser, NULL, &contenttype, NULL, &(*cmd)->size, NULL, error)) goto error; } else { - smlErrorSet(error, SML_ERROR_GENERIC, "wrong initial node"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "wrong initial node"); goto error; } } if (!(*cmd)->cmdID) { - smlErrorSet(error, SML_ERROR_GENERIC, "No cmdid set"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No cmdid set"); goto error; } if (!(*cmd)->private.change.items || !g_list_length((*cmd)->private.change.items)) { - smlErrorSet(error, SML_ERROR_GENERIC, "No items set"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No items set"); goto error; } @@ -1142,7 +1193,7 @@ (*cmd)->private.change.type = SML_CHANGE_DELETE; break; default: - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown change type set"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown change type set"); goto error; } @@ -1150,7 +1201,7 @@ { SmlItem *item = g_list_nth_data((*cmd)->private.change.items, 0); if (item->source) { - (*cmd)->source = sml_location_clone(item->source, &gerror); + (*cmd)->source = sml_location_clone(item->source, error); if (!(*cmd)->source) goto error; } @@ -1160,7 +1211,7 @@ { SmlItem *item = g_list_nth_data((*cmd)->private.change.items, 0); if (item->target) { - (*cmd)->target = sml_location_clone(item->target, &gerror); + (*cmd)->target = sml_location_clone(item->target, error); if (!(*cmd)->target) goto error; } @@ -1168,25 +1219,28 @@ /* Step once more */ if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing nodes"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing nodes"); goto error; } smlTrace(TRACE_EXIT, "%s: %p", __func__, *cmd); return TRUE; - error: if (*cmd) smlCommandUnref(*cmd); *cmd = NULL; if (contenttype) smlSafeCFree(&contenttype); - 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; } -static SmlBool _smlMessageParseSynchdrMeta(SmlXmlParser *parser, unsigned int *maxmsgsize, unsigned int *maxobjsize, char **emi, SmlError **error) +static gboolean +_smlMessageParseSynchdrMeta (SmlXmlParser *parser, + gsize *maxmsgsize, + gsize *maxobjsize, + gchar **emi, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, parser, maxmsgsize, maxobjsize, error); CHECK_ERROR_REF @@ -1195,10 +1249,9 @@ smlAssert(maxobjsize); smlAssert(emi); - while (1) { if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing nodes"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing nodes"); goto error; } @@ -1206,49 +1259,55 @@ xmlTextReaderNodeType(parser->reader) == XML_NODE_CLOSE) { break; } else if (xmlTextReaderNodeType(parser->reader) != XML_NODE_START) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The element %s is not a start node in SyncHdr/Meta.", xmlTextReaderConstName(parser->reader)); goto error; } if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_MAXMSGSIZE)) { - if (!_smlXmlParserGetID(parser, maxmsgsize, SML_ELEMENT_MAXMSGSIZE, error)) + guint64 id = 0; + if (!_smlXmlParserGetID(parser, &id, SML_ELEMENT_MAXMSGSIZE, error)) goto error; + *maxmsgsize = id; } else if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_MAXOBJSIZE)) { - if (!_smlXmlParserGetID(parser, maxobjsize, SML_ELEMENT_MAXOBJSIZE, error)) + guint64 id = 0; + if (!_smlXmlParserGetID(parser, &id, SML_ELEMENT_MAXOBJSIZE, error)) goto error; + *maxobjsize = id; } else if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_EMI)) { if (!_smlXmlParserGetString(parser, emi, SML_ELEMENT_EMI, error)) goto error; } else { - smlErrorSet(error, SML_ERROR_GENERIC, "wrong initial node. expected MaxMsgSize, MaxObjSize or EMI. Instead of that: %s", xmlTextReaderConstName(parser->reader)); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "wrong initial node. expected MaxMsgSize, MaxObjSize or EMI. Instead of that: %s", xmlTextReaderConstName(parser->reader)); goto error; } } if (!(*maxmsgsize) && !(*maxobjsize)) { - smlErrorSet(error, SML_ERROR_GENERIC, "No maxmsgsize set"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No maxmsgsize set"); goto error; } smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: *maxmsgsize = 0; *maxobjsize = 0; - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -static SmlBool _smlAlertParse(SmlXmlParser *parser, SmlCommand **cmd, SmlError **error) +static gboolean +_smlAlertParse (SmlXmlParser *parser, + SmlCommand **cmd, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, parser, cmd, error); CHECK_ERROR_REF smlAssert(parser); smlAssert(cmd); - + *cmd = smlCommandNew(SML_COMMAND_TYPE_ALERT, error); if (!*cmd) goto error; @@ -1257,7 +1316,7 @@ while (1) { if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing nodes"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing nodes"); goto error_free_cmd; } @@ -1265,15 +1324,17 @@ xmlTextReaderNodeType(parser->reader) == XML_NODE_CLOSE) { break; } else if (xmlTextReaderNodeType(parser->reader) != XML_NODE_START) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The element %s is not a start node in Alert.", xmlTextReaderConstName(parser->reader)); goto error_free_cmd; } if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_CMDID)) { - if (!_smlXmlParserGetID(parser, &((*cmd)->cmdID), SML_ELEMENT_CMDID, error)) + guint64 id = 0; + if (!_smlXmlParserGetID(parser, &id, SML_ELEMENT_CMDID, error)) goto error_free_cmd; + (*cmd)->cmdID = id; } else if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_ITEM)) { SmlItem *item = _smlItemParse(parser, (*cmd), SML_COMMAND_TYPE_ALERT, error); if (!item) @@ -1286,7 +1347,7 @@ smlItemUnref(item); } else if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_DATA)) { - unsigned int id = 0; + guint64 id = 0; if (!_smlXmlParserGetID(parser, &id, SML_ELEMENT_DATA, error)) goto error_free_cmd; (*cmd)->private.alert.type = smlAlertTypeConvert(id, error); @@ -1294,19 +1355,19 @@ *error != NULL) goto error_free_cmd; } else { - smlErrorSet(error, SML_ERROR_GENERIC, "wrong initial node %s", xmlTextReaderConstName(parser->reader)); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "wrong initial node %s", xmlTextReaderConstName(parser->reader)); goto error_free_cmd; } } if (!(*cmd)->private.alert.type) { - smlErrorSet(error, SML_ERROR_GENERIC, "No alert type set"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No alert type set"); goto error_free_cmd; } /* Step once more */ if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing nodes"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing nodes"); goto error_free_cmd; } @@ -1317,11 +1378,14 @@ smlCommandUnref(*cmd); error: *cmd = NULL; - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -static SmlParserResult _smlCommandSyncParse(SmlXmlParser *parser, SmlCommand **cmd, SmlError **error) +static SmlParserResult +_smlCommandSyncParse (SmlXmlParser *parser, + SmlCommand **cmd, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, parser, cmd, error); CHECK_ERROR_REF @@ -1335,14 +1399,14 @@ while (1) { if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing nodes"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing nodes"); goto error_free_cmd; } if (xmlTextReaderNodeType(parser->reader) == XML_NODE_CLOSE && !strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_SYNC)) break; else if (xmlTextReaderNodeType(parser->reader) != XML_NODE_START) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The element %s is not a start node in Sync.", xmlTextReaderConstName(parser->reader)); goto error_free_cmd; @@ -1354,8 +1418,10 @@ break; if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_CMDID)) { - if (!_smlXmlParserGetID(parser, &((*cmd)->cmdID), SML_ELEMENT_CMDID, error)) + guint64 id = 0; + if (!_smlXmlParserGetID(parser, &id, SML_ELEMENT_CMDID, error)) goto error_free_cmd; + (*cmd)->cmdID = id; } else if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_ITEM)) { SmlItem *item = _smlItemParse(parser, (*cmd), SML_COMMAND_TYPE_SYNC, error); if (!item) @@ -1370,11 +1436,13 @@ if (!_smlLocationParse(&(*cmd)->source, parser, error)) goto error_free_cmd; } else if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_NUMBEROFCHANGES)) { + guint64 id = 0; (*cmd)->private.sync.hasNumChanged = TRUE; - if (!_smlXmlParserGetID(parser, &((*cmd)->private.sync.numChanged), SML_ELEMENT_NUMBEROFCHANGES, error)) + if (!_smlXmlParserGetID(parser, &id, SML_ELEMENT_NUMBEROFCHANGES, error)) goto error_free_cmd; + (*cmd)->private.sync.numChanged = id; } else { - smlErrorSet(error, SML_ERROR_GENERIC, "wrong initial node: %s", xmlTextReaderConstName(parser->reader)); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "wrong initial node: %s", xmlTextReaderConstName(parser->reader)); goto error_free_cmd; } } @@ -1386,11 +1454,13 @@ smlCommandUnref(*cmd); error: *cmd = NULL; - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -static SmlMapItem *_smlMapItemParse(SmlXmlParser *parser, SmlError **error) +static SmlMapItem* +_smlMapItemParse (SmlXmlParser *parser, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, parser, error); CHECK_ERROR_REF @@ -1403,7 +1473,7 @@ while (1) { if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing nodes"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing nodes"); goto error_free_item; } @@ -1411,7 +1481,7 @@ xmlTextReaderNodeType(parser->reader) == XML_NODE_CLOSE) { break; } else if (xmlTextReaderNodeType(parser->reader) != XML_NODE_START) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The element %s is not a start node in MapItem.", xmlTextReaderConstName(parser->reader)); goto error_free_item; @@ -1424,7 +1494,7 @@ if (!_smlLocationParse(&item->target, parser, error)) goto error_free_item; } else { - smlErrorSet(error, SML_ERROR_GENERIC, "wrong initial node %s", xmlTextReaderConstName(parser->reader)); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "wrong initial node %s", xmlTextReaderConstName(parser->reader)); goto error_free_item; } } @@ -1435,11 +1505,14 @@ error_free_item: smlMapItemUnref(item); error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -static SmlBool _smlCommandMapParse(SmlXmlParser *parser, SmlCommand **cmd, SmlError **error) +static gboolean +_smlCommandMapParse (SmlXmlParser *parser, + SmlCommand **cmd, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, parser, cmd, error); CHECK_ERROR_REF @@ -1453,7 +1526,7 @@ while (1) { if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing nodes"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing nodes"); goto error_free_cmd; } @@ -1461,15 +1534,17 @@ xmlTextReaderNodeType(parser->reader) == XML_NODE_CLOSE) { break; } else if (xmlTextReaderNodeType(parser->reader) != XML_NODE_START) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The element %s is not a start node in Map.", xmlTextReaderConstName(parser->reader)); goto error_free_cmd; } if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_CMDID)) { - if (!_smlXmlParserGetID(parser, &((*cmd)->cmdID), SML_ELEMENT_CMDID, error)) + guint64 id = 0; + if (!_smlXmlParserGetID(parser, &id, SML_ELEMENT_CMDID, error)) goto error_free_cmd; + (*cmd)->cmdID = id; } else if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_MAPITEM)) { SmlMapItem *item = _smlMapItemParse(parser, error); if (!item) @@ -1482,14 +1557,14 @@ if (!_smlLocationParse(&(*cmd)->source, parser, error)) goto error_free_cmd; } else { - smlErrorSet(error, SML_ERROR_GENERIC, "wrong initial node"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "wrong initial node"); goto error_free_cmd; } } /* Step once more */ if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing nodes"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing nodes"); goto error_free_cmd; } @@ -1500,11 +1575,15 @@ smlCommandUnref(*cmd); error: *cmd = NULL; - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -static SmlBool _smlCommandAccessParse(SmlXmlParser *parser, SmlCommand **cmd, SmlCommandType type, SmlError **error) +static gboolean +_smlCommandAccessParse (SmlXmlParser *parser, + SmlCommand **cmd, + SmlCommandType type, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %i, %p)", __func__, parser, cmd, type, error); CHECK_ERROR_REF @@ -1519,7 +1598,7 @@ while (1) { if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing nodes"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing nodes"); goto error_free_cmd; } @@ -1530,15 +1609,17 @@ xmlTextReaderNodeType(parser->reader) == XML_NODE_CLOSE) { break; } else if (xmlTextReaderNodeType(parser->reader) != XML_NODE_START) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The element %s is not a start node in Put or Get.", xmlTextReaderConstName(parser->reader)); goto error_free_cmd; } if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_CMDID)) { - if (!_smlXmlParserGetID(parser, &((*cmd)->cmdID), SML_ELEMENT_CMDID, error)) + guint64 id = 0; + if (!_smlXmlParserGetID(parser, &id, SML_ELEMENT_CMDID, error)) goto error_free_cmd; + (*cmd)->cmdID = id; } else if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_ITEM)) { (*cmd)->private.access.item = _smlItemParse(parser, (*cmd), (*cmd)->type, error); if (!(*cmd)->private.access.item) @@ -1554,13 +1635,13 @@ goto error_free_cmd; if (format) smlSafeCFree(&format); } else { - smlErrorSet(error, SML_ERROR_GENERIC, "wrong initial node"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "wrong initial node"); goto error_free_cmd; } } if (!(*cmd)->private.access.item) { - smlErrorSet(error, SML_ERROR_GENERIC, "Put/Get is missing item"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Put/Get is missing item"); goto error_free_cmd; } @@ -1574,7 +1655,7 @@ /* Step once more */ if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing nodes"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing nodes"); goto error_free_cmd; } @@ -1587,17 +1668,19 @@ *cmd = NULL; if (contenttype) smlSafeCFree(&contenttype); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -static SmlBool _smlResultsParse(SmlXmlParser *parser, SmlCommand **cmd, SmlError **error) +static gboolean +_smlResultsParse (SmlXmlParser *parser, + SmlCommand **cmd, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, parser, cmd, error); CHECK_ERROR_REF smlAssert(parser); smlAssert(cmd); - GError *gerror = NULL; char *contenttype = NULL; char *locURI = NULL; @@ -1615,7 +1698,7 @@ while (1) { if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing nodes"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing nodes"); goto error; } @@ -1623,7 +1706,7 @@ xmlTextReaderNodeType(parser->reader) == XML_NODE_CLOSE) { break; } else if (xmlTextReaderNodeType(parser->reader) != XML_NODE_START) { - smlErrorSet(error, SML_ERROR_GENERIC, + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "The element %s is not a start node in Results.", xmlTextReaderConstName(parser->reader)); goto error; @@ -1631,19 +1714,25 @@ if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_CMDID)) { - if (!_smlXmlParserGetID(parser, &((*cmd)->cmdID), SML_ELEMENT_CMDID, error)) + guint64 id = 0; + if (!_smlXmlParserGetID(parser, &id, SML_ELEMENT_CMDID, error)) goto error; + (*cmd)->cmdID = id; } else if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_MSGREF)) { - if (!_smlXmlParserGetID(parser, &((*cmd)->private.results.status->msgRef), SML_ELEMENT_MSGREF, error)) + guint64 id = 0; + if (!_smlXmlParserGetID(parser, &id, SML_ELEMENT_MSGREF, error)) goto error; + (*cmd)->private.results.status->msgRef = id; } else if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_CMDREF)) { - if (!_smlXmlParserGetID(parser, &((*cmd)->private.results.status->cmdRef), SML_ELEMENT_CMDREF, error)) + guint64 id = 0; + if (!_smlXmlParserGetID(parser, &id, SML_ELEMENT_CMDREF, error)) goto error; + (*cmd)->private.results.status->cmdRef = id; } else if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_SOURCEREF)) { if (!_smlXmlParserGetString(parser, &locURI, SML_ELEMENT_SOURCEREF, error)) goto error; - (*cmd)->private.results.status->sourceRef = sml_location_new_with_options(locURI, NULL, &gerror); + (*cmd)->private.results.status->sourceRef = sml_location_new_with_options(locURI, NULL, error); smlSafeCFree(&locURI); if (!(*cmd)->private.results.status->sourceRef) goto error; @@ -1651,7 +1740,7 @@ if (!_smlXmlParserGetString(parser, &locURI, SML_ELEMENT_TARGETREF, error)) goto error; - (*cmd)->private.results.status->targetRef = sml_location_new_with_options(locURI, NULL, &gerror); + (*cmd)->private.results.status->targetRef = sml_location_new_with_options(locURI, NULL, error); smlSafeCFree(&locURI); if (!(*cmd)->private.results.status->targetRef) goto error; @@ -1671,13 +1760,13 @@ goto error; if (format) smlSafeCFree(&format); } else { - smlErrorSet(error, SML_ERROR_GENERIC, "wrong initial node"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "wrong initial node"); goto error; } } if (!(*cmd)->private.results.status->item) { - smlErrorSet(error, SML_ERROR_GENERIC, "Result is missing item"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Result is missing item"); goto error; } @@ -1685,7 +1774,7 @@ * a content type set */ if (!(*cmd)->private.results.status->item->contenttype) { if (!contenttype) { - smlErrorSet(error, SML_ERROR_GENERIC, "Result is missing content type"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Result is missing content type"); goto error; } @@ -1697,7 +1786,7 @@ /* Step once more */ if (!_smlXmlParserStep(parser)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing nodes"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing nodes"); goto error; } @@ -1710,15 +1799,16 @@ *cmd = NULL; if (contenttype) smlSafeCFree(&contenttype); - 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; } -static SmlBool _smlXmlParserFixBrokenItemData( - const char *data, unsigned int size, - char **fixed_data, unsigned int *fixed_size, - SmlError **error) +static gboolean +_smlXmlParserFixBrokenItemData (const gchar *data, + gsize size, + gchar **fixed_data, + gsize *fixed_size, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %d, %p, %p, %p)", __func__, data, size, fixed_data, fixed_size, error); CHECK_ERROR_REF @@ -1742,7 +1832,7 @@ *fixed_data = smlTryMalloc0(size + 1, error); if (!*fixed_data) { - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } memcpy(*fixed_data, data, size); @@ -1774,22 +1864,22 @@ /* convert the whole strong to UTF-8 */ smlTrace(TRACE_INTERNAL, "%s: Converting %d bytes ...", __func__, last_utf16 - position + 1); - GError *gerror = NULL; size_t read_bytes = 0; size_t written_bytes = 0; gchar *conv_string = g_convert( position, (last_utf16 - position + 1), "UTF-8", "UTF-16", &read_bytes, &written_bytes, - &gerror); - if (gerror != NULL) + error); + if (error != NULL) { - smlErrorSet( - error, SML_ERROR_GENERIC, - "Character conversion from UTF-16 to UTF-8 failed. %s", - gerror->message); - g_error_free(gerror); - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + GError *ext = NULL; + g_set_error(&ext, SML_ERROR, SML_ERROR_GENERIC, + "Character conversion from UTF-16 to UTF-8 failed. %s", + (*error)->message); + g_error_free(*error); + *error = ext; + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } smlTrace(TRACE_INTERNAL, "%s: read %d --> written %d --> %d ::= %s", __func__, read_bytes, written_bytes, strlen(conv_string), conv_string); @@ -1798,7 +1888,7 @@ char *new_data = smlTryMalloc0(*fixed_size - read_bytes + written_bytes + 1, error); if (!new_data) { - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } memcpy(new_data, *fixed_data, (size_t) position - (size_t) *fixed_data); @@ -1935,7 +2025,7 @@ char *new_data = smlTryMalloc0(*fixed_size + strlen("<![CDATA[]]>") + 1, error); if (!new_data) { - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } size_t before_size = limit_data_start + strlen("<Data>") - *fixed_data; @@ -1970,7 +2060,9 @@ return TRUE; } -SmlDevInfDevTyp _smlParseDevInfDevType(const char *name, SmlError **error) +SmlDevInfDevTyp +_smlParseDevInfDevType (const gchar *name, + GError **error) { CHECK_ERROR_REF @@ -1989,12 +2081,15 @@ } else if (!strcmp(name, SML_ELEMENT_DEVTYP_WORKSTATION)) { return SML_DEVINF_DEVTYP_WORKSTATION; } else { - smlErrorSet(error, SML_ERROR_GENERIC, "The device information DevTyp \"%s\" is unknown.", name); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "The device information DevTyp \"%s\" is unknown.", name); return SML_DEVINF_DEVTYP_UNKNOWN; } } -SmlDevInfSyncCap _smlParseDevInfSyncCap(unsigned int id, SmlError **error) +SmlDevInfSyncCap +_smlParseDevInfSyncCap (guint id, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%u, %p)", __func__, id, error); CHECK_ERROR_REF @@ -2024,9 +2119,9 @@ result = SML_DEVINF_SYNCTYPE_SERVER_ALERTED_SYNC; break; default: - smlErrorSet(error, SML_ERROR_GENERIC, - "The synchronization type %u is unknwon.", id); - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "The synchronization type %u is unknwon.", id); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return SML_DEVINF_SYNCTYPE_UNKNOWN; break; } @@ -2034,7 +2129,9 @@ return result; } -SmlDevInfCTCapType _smlParseDevInfCTCapType(const char *name, SmlError **error) +SmlDevInfCTCapType +_smlParseDevInfCTCapType (const gchar *name, + GError **error) { CHECK_ERROR_REF @@ -2066,8 +2163,9 @@ return SML_DEVINF_CTCAP_MAXSIZE; } - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown ctcap type name \"%s\"", name); - smlTrace(TRACE_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Unknown ctcap type name \"%s\"", name); + smlTrace(TRACE_ERROR, "%s - %s", __func__, (*error)->message); return SML_DEVINF_CTCAP_UNKNOWN; } @@ -2077,7 +2175,11 @@ * This will set everything up and parse until the SyncHdr * */ -SmlBool smlXmlParserStart(SmlXmlParser *parser, const char *data, unsigned int size, SmlError **error) +gboolean +smlXmlParserStart (SmlXmlParser *parser, + const gchar *data, + gsize size, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %i, %p)", __func__, parser, data, size, error); CHECK_ERROR_REF @@ -2097,7 +2199,7 @@ if (! _smlXmlParserFixBrokenItemData( data, size, &(parser->data), &(parser->size), error)) { - smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s - %s", __func__, (*error)->message); return FALSE; } @@ -2111,7 +2213,8 @@ /* Create the new parser */ parser->reader = xmlReaderForMemory(parser->data, parser->size, "/", NULL, XML_PARSE_NONET | XML_PARSE_NOERROR | XML_PARSE_NOWARNING | XML_PARSE_NOCDATA); if (!parser->reader) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to create new reader"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Unable to create new reader"); goto error; } xmlSubstituteEntitiesDefault(1); @@ -2133,29 +2236,33 @@ parser->reader = NULL; if (parser->data) smlSafeCFree(&(parser->data)); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -SmlBool smlXmlParserEnd(SmlXmlParser *parser, SmlBool *final, SmlBool *end, SmlError **error) +gboolean +smlXmlParserEnd (SmlXmlParser *parser, + gboolean *final, + gboolean *end, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, parser, final, end, error); CHECK... [truncated message content] |
From: <svn...@op...> - 2009-07-08 15:23:29
|
Author: bellmich Date: Wed Jul 8 17:23:22 2009 New Revision: 1160 URL: http://libsyncml.opensync.org/changeset/1160 Log: - fixed forgotten glib type migrations - fixed wrong AddID interface Modified: trunk/libsyncml/parser/sml_xml_assm.c trunk/libsyncml/parser/sml_xml_assm.h trunk/libsyncml/parser/sml_xml_assm_internals.h Modified: trunk/libsyncml/parser/sml_xml_assm.c ============================================================================== --- trunk/libsyncml/parser/sml_xml_assm.c Wed Jul 8 17:16:46 2009 (r1159) +++ trunk/libsyncml/parser/sml_xml_assm.c Wed Jul 8 17:23:22 2009 (r1160) @@ -152,11 +152,11 @@ static gboolean _smlXmlAssemblerAddID (SmlXmlAssembler *assm, const gchar *name, - gsize id, + guint64 id, GError **error) { CHECK_ERROR_REF - int rc = xmlTextWriterWriteFormatElement(assm->writer, (xmlChar *)name, "%i", id); + int rc = xmlTextWriterWriteFormatElement(assm->writer, (xmlChar *)name, "%lli", id); if (rc < 0) { g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to add id"); Modified: trunk/libsyncml/parser/sml_xml_assm.h ============================================================================== --- trunk/libsyncml/parser/sml_xml_assm.h Wed Jul 8 17:16:46 2009 (r1159) +++ trunk/libsyncml/parser/sml_xml_assm.h Wed Jul 8 17:23:22 2009 (r1160) @@ -40,7 +40,7 @@ gboolean smlXmlAssemblerStart (SmlXmlAssembler *assm, SmlSession *session, GError **error); gboolean smlXmlAssemblerEnd (SmlXmlAssembler *assm, GError **error); gboolean smlXmlAssemblerRun (SmlXmlAssembler *assm, gchar **data, gsize *size, gboolean *end, gboolean final, gsize maxsize, GError **error); -gboolean smlXmlAssemblerRunFull (SmlXmlAssembler *assm, char **data, unsigned int *size, gboolean *end, gboolean final, gboolean check, gsize maxsize, GError **error); +gboolean smlXmlAssemblerRunFull (SmlXmlAssembler *assm, gchar **data, gsize *size, gboolean *end, gboolean final, gboolean check, gsize maxsize, GError **error); gboolean smlXmlDevInfAssemble (SmlDevInf *devinf, SmlDevInfVersion version, gchar **data, gsize *size, GError **error); Modified: trunk/libsyncml/parser/sml_xml_assm_internals.h ============================================================================== --- trunk/libsyncml/parser/sml_xml_assm_internals.h Wed Jul 8 17:16:46 2009 (r1159) +++ trunk/libsyncml/parser/sml_xml_assm_internals.h Wed Jul 8 17:23:22 2009 (r1160) @@ -88,7 +88,7 @@ gboolean smlAssemblerEndNode (SmlAssembler *assm, GError **error); gboolean smlAssemblerAddString (SmlAssembler *assm, const gchar *name, const gchar *value, GError **error); gboolean smlAssemblerAddStringNS (SmlAssembler *assm, const gchar *prefix, const gchar *name, const gchar *uri, const gchar *value, GError **error); -gboolean smlAssemblerAddID (SmlAssembler *assm, const gchar *name, gsize id, GError **error); +gboolean smlAssemblerAddID (SmlAssembler *assm, const gchar *name, guint64 id, GError **error); gboolean smlAssemblerAddData (SmlAssembler *assm, const gchar *name, const gchar *value, GError **error); #endif //_SML_XML_ASSM_INTERNALS_H_ |
From: <svn...@op...> - 2009-07-08 15:16:56
|
Author: bellmich Date: Wed Jul 8 17:16:46 2009 New Revision: 1159 URL: http://libsyncml.opensync.org/changeset/1159 Log: migrated parser/sml_xml_assm from SmlError to GError Modified: trunk/libsyncml/parser/sml_xml_assm.c trunk/libsyncml/parser/sml_xml_assm_internals.h Modified: trunk/libsyncml/parser/sml_xml_assm.c ============================================================================== --- trunk/libsyncml/parser/sml_xml_assm.c Wed Jul 8 16:18:21 2009 (r1158) +++ trunk/libsyncml/parser/sml_xml_assm.c Wed Jul 8 17:16:46 2009 (r1159) @@ -40,7 +40,11 @@ */ /*@{*/ -static SmlBool _smlXmlAssemblerStartNodeNS(SmlXmlAssembler *assm, const char *name, const char *uri, SmlError **error) +static gboolean +_smlXmlAssemblerStartNodeNS (SmlXmlAssembler *assm, + const gchar *name, + const gchar *uri, + GError **error) { CHECK_ERROR_REF smlAssert(assm); @@ -50,53 +54,78 @@ smlTrace(TRACE_INTERNAL, "%s: Starting \"%s\"", __func__, VA_STRING(name)); int rc = xmlTextWriterStartElementNS(assm->writer, NULL, (xmlChar *)name, (xmlChar *)uri); if (rc < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to start node"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to start node"); return FALSE; } return TRUE; } -static SmlBool _smlXmlAssemblerStartNode(SmlXmlAssembler *assm, const char *name, SmlError **error) +static gboolean +_smlXmlAssemblerStartNode (SmlXmlAssembler *assm, + const gchar *name, + GError **error) { CHECK_ERROR_REF return _smlXmlAssemblerStartNodeNS(assm, name, NULL, error); } -static SmlBool _smlXmlAssemblerEndNode(SmlXmlAssembler *assm, SmlError **error) +static gboolean +_smlXmlAssemblerEndNode (SmlXmlAssembler *assm, + GError **error) { CHECK_ERROR_REF smlTrace(TRACE_INTERNAL, "%s: Ending node", __func__); int rc = xmlTextWriterEndElement(assm->writer); if (rc < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to end node (%d).", rc); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Unable to end node (%d).", rc); return FALSE; } return TRUE; } -static SmlBool _smlXmlAssemblerAddStringNS(SmlXmlAssembler *assm, const char *name, const char *uri, const char *value, SmlError **error) +static gboolean +_smlXmlAssemblerAddStringNS (SmlXmlAssembler *assm, + const gchar *name, + const gchar *uri, + const gchar *value, + GError **error) { CHECK_ERROR_REF int rc = xmlTextWriterWriteElementNS(assm->writer, NULL, (xmlChar *)name, (xmlChar *)uri, (xmlChar *)value); if (rc < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to add string (%d - %s:%s -> %s).", rc, VA_STRING(uri), VA_STRING(name), VA_STRING(value)); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Unable to add string (%d - %s:%s -> %s).", + rc, VA_STRING(uri), VA_STRING(name), VA_STRING(value)); return FALSE; } return TRUE; } -static SmlBool _smlXmlAssemblerAddString(SmlXmlAssembler *assm, const char *name, const char *value, SmlError **error) +static gboolean +_smlXmlAssemblerAddString (SmlXmlAssembler *assm, + const gchar *name, + const gchar *value, + GError **error) { CHECK_ERROR_REF int rc = xmlTextWriterWriteElement(assm->writer, (xmlChar *)name, (xmlChar *)value); if (rc < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to add pure string (%d - %s -> %s).", rc, VA_STRING(name), VA_STRING(value)); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Unable to add pure string (%d - %s -> %s).", + rc, VA_STRING(name), VA_STRING(value)); return FALSE; } return TRUE; } -static SmlBool _smlXmlAssemblerAddData(SmlXmlAssembler *assm, const char *name, const char *value, unsigned int size, SmlBool raw, SmlError **error) +static gboolean +_smlXmlAssemblerAddData (SmlXmlAssembler *assm, + const gchar *name, + const gchar *value, + gsize size, + gboolean raw, + GError **error) { CHECK_ERROR_REF int rc = 0; @@ -109,7 +138,8 @@ rc = xmlTextWriterWriteFormatCDATA(assm->writer, "%*s", size, (xmlChar *)value); if (rc < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to add data (%d).", rc); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Unable to add data (%d).", rc); return FALSE; } @@ -119,35 +149,47 @@ return TRUE; } -static SmlBool _smlXmlAssemblerAddID(SmlXmlAssembler *assm, const char *name, unsigned int id, SmlError **error) +static gboolean +_smlXmlAssemblerAddID (SmlXmlAssembler *assm, + const gchar *name, + gsize id, + GError **error) { CHECK_ERROR_REF int rc = xmlTextWriterWriteFormatElement(assm->writer, (xmlChar *)name, "%i", id); if (rc < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to add id"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Unable to add id"); return FALSE; } return TRUE; } -static SmlBool _smlXmlAssemblerAddIDNS(SmlXmlAssembler *assm, const char *name, const char *uri, unsigned int id, SmlError **error) +static gboolean +_smlXmlAssemblerAddIDNS (SmlXmlAssembler *assm, + const gchar *name, + const gchar *uri, + gsize id, + GError **error) { CHECK_ERROR_REF int rc = xmlTextWriterWriteFormatElementNS(assm->writer, NULL, (xmlChar *)name, (xmlChar *)uri, "%i", id); if (rc < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to add id"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Unable to add id"); return FALSE; } return TRUE; } -static SmlBool _smlAssembleUseMaxObjSize(SmlXmlAssembler *assm) +static gboolean +_smlAssembleUseMaxObjSize (SmlXmlAssembler *assm) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, assm); /* check the configuration */ const char *opt = smlAssemblerGetOption(assm->assembler, "USE_LARGEOBJECTS"); - SmlBool supportsLargeObjects = (opt && !atoi(opt)) ? FALSE : TRUE; + gboolean supportsLargeObjects = (opt && !atoi(opt)) ? FALSE : TRUE; /* server should react only the client behavior */ if (assm->session->sessionType == SML_SESSION_TYPE_SERVER) @@ -172,7 +214,9 @@ return supportsLargeObjects; } -static SmlBool _smlAssembleMaxObjSize(SmlXmlAssembler *assm, SmlError **error) +static gboolean +_smlAssembleMaxObjSize (SmlXmlAssembler *assm, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, assm); CHECK_ERROR_REF @@ -200,13 +244,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; } -static const char *_smlAssembleDevInfDevType(SmlDevInfDevTyp type, SmlError **error) +static const gchar* +_smlAssembleDevInfDevType (SmlDevInfDevTyp type, + GError **error) { CHECK_ERROR_REF @@ -226,14 +271,20 @@ case SML_DEVINF_DEVTYP_WORKSTATION: return SML_ELEMENT_DEVTYP_WORKSTATION; default: - smlErrorSet(error, SML_ERROR_GENERIC, "The devince information DevTyp \"%i\" is unknown.", type); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "The devince information DevTyp \"%i\" is unknown.", + type); /* fall through! */ } return NULL; } -SmlBool smlLocationAssemble(SmlLocation *location, SmlXmlAssembler *assm, const char *name, SmlError **error) +gboolean +smlLocationAssemble (SmlLocation *location, + SmlXmlAssembler *assm, + const gchar *name, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %s, %p)", __func__, location, assm, VA_STRING(name), error); CHECK_ERROR_REF @@ -249,7 +300,8 @@ (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"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "No parent URI set"); goto error; } @@ -258,7 +310,8 @@ } else { if (!sml_location_get_uri(location)) { - smlErrorSet(error, SML_ERROR_GENERIC, "No location URI set"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "No location URI set"); goto error; } @@ -278,15 +331,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 smlAnchorAssemble(SmlAnchor *anchor, SmlXmlAssembler *assm, SmlError **error) +gboolean +smlAnchorAssemble (SmlAnchor *anchor, + SmlXmlAssembler *assm, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, anchor, assm, error); CHECK_ERROR_REF @@ -305,7 +360,7 @@ goto error; if (!anchor->next) { - smlErrorSet(error, SML_ERROR_GENERIC, "No next set"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No next set"); goto error; } @@ -326,13 +381,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 smlItemAssemble(SmlItem *item, SmlXmlAssembler *assm, SmlError **error) +gboolean +smlItemAssemble (SmlItem *item, + SmlXmlAssembler *assm, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, item, assm, error); CHECK_ERROR_REF @@ -340,7 +397,8 @@ smlAssert(item); if (assm->moreDataSet) { - smlErrorSet(error, SML_ERROR_GENERIC, "Trying to start a new item while last item had more data"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Trying to start a new item while last item had more data"); goto error; } @@ -402,13 +460,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 smlCredAssemble(SmlCred *cred, SmlXmlAssembler *assm, SmlError **error) +gboolean +smlCredAssemble (SmlCred *cred, + SmlXmlAssembler *assm, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, cred, assm, error); CHECK_ERROR_REF @@ -428,7 +488,8 @@ goto error; break; default: - smlErrorSet(error, SML_ERROR_GENERIC, "SyncML credential: Unknown format %d.", cred->format); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "SyncML credential: Unknown format %d.", cred->format); goto error; } @@ -442,7 +503,8 @@ goto error; break; default: - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown format"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Unknown format"); goto error; } @@ -458,13 +520,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 smlAccessAssemble(SmlXmlAssembler *assm, SmlCommand *change, SmlError **error) +gboolean +smlAccessAssemble (SmlXmlAssembler *assm, + SmlCommand *change, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, assm, change, error); CHECK_ERROR_REF @@ -472,12 +536,12 @@ smlAssert(assm); if (!change->private.access.item) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing item"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing item"); goto error; } if (!change->private.access.item->contenttype) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing contenttype"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing contenttype"); goto error; } @@ -497,13 +561,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 smlChangeAssemble(SmlXmlAssembler *assm, SmlCommand *change, SmlError **error) +gboolean +smlChangeAssemble (SmlXmlAssembler *assm, + SmlCommand *change, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, assm, change, error); CHECK_ERROR_REF @@ -512,7 +578,7 @@ if (!change->private.change.items || !g_list_length(change->private.change.items)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing items"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Missing items"); goto error; } @@ -521,11 +587,13 @@ SmlItem *item = g_list_nth_data(change->private.change.items, 0); if (!item) { - smlErrorSet(error, SML_ERROR_GENERIC, "One item of the item list is NULL."); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "One item of the item list is NULL."); goto error; } if (!item->contenttype) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing contenttype"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Missing contenttype"); goto error; } @@ -539,7 +607,7 @@ /* We will add the max obj size node, if USE_LARGEOBJECTS is true or not set at all. * And the remote side must have set a maxobjsize if we are a server */ const char *opt = smlAssemblerGetOption(assm->assembler, "USE_LARGEOBJECTS"); - SmlBool supportsLargeObjects = (opt && !atoi(opt)) ? FALSE : TRUE; + gboolean supportsLargeObjects = (opt && !atoi(opt)) ? FALSE : TRUE; smlTrace(TRACE_INTERNAL, "%s: Large object: use %i, server %i, requestedSize %i", __func__, supportsLargeObjects, assm->session->sessionType == SML_SESSION_TYPE_SERVER ? 1 : 0, smlAssemblerGetRemoteMaxObjSize(assm->assembler)); @@ -614,13 +682,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 smlSyncAssemble(SmlXmlAssembler *assm, SmlCommand *cmd, SmlError **error) +gboolean +smlSyncAssemble (SmlXmlAssembler *assm, + SmlCommand *cmd, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, assm, cmd, error); CHECK_ERROR_REF @@ -628,7 +698,7 @@ smlAssert(assm); if (!cmd->target) { - smlErrorSet(error, SML_ERROR_GENERIC, "No target set"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No target set"); goto error; } @@ -642,7 +712,7 @@ goto error; if (!cmd->source) { - smlErrorSet(error, SML_ERROR_GENERIC, "No source set"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No source set"); goto error; } @@ -662,7 +732,7 @@ } const char *opt = smlAssemblerGetOption(assm->assembler, "USE_NUMBEROFCHANGES"); - SmlBool supportsNumberOfChanges = (opt && !atoi(opt)) ? FALSE : TRUE; + gboolean supportsNumberOfChanges = (opt && !atoi(opt)) ? FALSE : TRUE; if (supportsNumberOfChanges && assm->session->version != SML_VERSION_10) { if (!_smlXmlAssemblerAddID(assm, SML_ELEMENT_NUMBEROFCHANGES, cmd->private.sync.numChanged, error)) goto error; @@ -670,13 +740,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 smlMapItemAssemble(SmlXmlAssembler *assm, SmlMapItem *item, SmlError **error) +gboolean +smlMapItemAssemble (SmlXmlAssembler *assm, + SmlMapItem *item, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, assm, item, error); CHECK_ERROR_REF @@ -702,13 +774,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 smlMapAssemble(SmlXmlAssembler *assm, SmlCommand *cmd, SmlError **error) +gboolean +smlMapAssemble (SmlXmlAssembler *assm, + SmlCommand *cmd, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, assm, cmd, error); CHECK_ERROR_REF @@ -716,7 +790,7 @@ smlAssert(assm); if (!cmd->target) { - smlErrorSet(error, SML_ERROR_GENERIC, "No target set"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No target set"); goto error; } @@ -724,7 +798,7 @@ goto error; if (!cmd->source) { - smlErrorSet(error, SML_ERROR_GENERIC, "No source set"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No source set"); goto error; } @@ -740,13 +814,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 smlAlertAssemble(SmlXmlAssembler *assm, SmlCommand *cmd, SmlError **error) +gboolean +smlAlertAssemble (SmlXmlAssembler *assm, + SmlCommand *cmd, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, assm, cmd, error); CHECK_ERROR_REF @@ -784,7 +860,7 @@ } else { // NEXT MESSAGE alerts does not need a source/target if (cmd->private.alert.type != SML_ALERT_NEXT_MESSAGE) { - smlErrorSet(error, SML_ERROR_GENERIC, "No source set"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No source set"); goto error; } } @@ -804,7 +880,7 @@ /* Begin of META */ - SmlBool meta = FALSE; + gboolean meta = FALSE; if (cmd->private.alert.contentType) meta = TRUE; if (cmd->private.alert.anchor) @@ -839,13 +915,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 smlResultsAssemble(SmlXmlAssembler *assm, SmlCommand *cmd, SmlError **error) +gboolean +smlResultsAssemble (SmlXmlAssembler *assm, + SmlCommand *cmd, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, assm, cmd, error); CHECK_ERROR_REF @@ -892,11 +970,14 @@ return TRUE; error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -SmlBool smlXmlAssemblerAddHeader(SmlXmlAssembler *assm, SmlSession *session, SmlError **error) +gboolean +smlXmlAssemblerAddHeader (SmlXmlAssembler *assm, + SmlSession *session, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, assm, session, error); CHECK_ERROR_REF @@ -913,13 +994,14 @@ /* We first start a new writer that will write our header into a buffer */ assm->header_buffer = xmlBufferCreateSize(BUFFER_SIZE); if (!assm->header_buffer) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to create new buffer"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Unable to create new buffer"); goto error; } assm->writer = xmlNewTextWriterMemory(assm->header_buffer, 0); if (!assm->writer) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to create new writer"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to create new writer"); goto error; } @@ -927,12 +1009,12 @@ goto error; if (!session->protocol) { - smlErrorSet(error, SML_ERROR_GENERIC, "No version set"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No version set"); goto error; } if (!session->version) { - smlErrorSet(error, SML_ERROR_GENERIC, "No dtd set"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No dtd set"); goto error; } @@ -961,17 +1043,19 @@ goto error; break; default: - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown version"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Unknown version"); goto error; } break; default: - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown protocol"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Unknown protocol"); goto error; } if (session->sessionID) { - if (!_smlXmlAssemblerAddString(assm, SML_ELEMENT_SESSIONID, session->sessionID, error)) + if (!_smlXmlAssemblerAddID(assm, SML_ELEMENT_SESSIONID, session->sessionID, error)) goto error; } @@ -1021,13 +1105,13 @@ /* Large object support is enabled. */ if (smlSessionGetLocalMaxMsgSize(session) < 1) { - smlErrorSet(error, SML_ERROR_INTERNAL_MISCONFIGURATION, + g_set_error(error, SML_ERROR, SML_ERROR_INTERNAL_MISCONFIGURATION, "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, "MaxObjSize must be set."); goto error; } @@ -1056,7 +1140,7 @@ /* Now close the buffer and get the content */ if (xmlTextWriterEndDocument(assm->writer) < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to end writer"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to end writer"); goto error; } @@ -1066,7 +1150,6 @@ g_mutex_unlock(assm->mutex); smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: if (assm->writer) { xmlFreeTextWriter(assm->writer); @@ -1077,33 +1160,39 @@ assm->header_buffer = NULL; } g_mutex_unlock(assm->mutex); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -SmlBool smlXmlAssemblerStartCommand(SmlXmlAssembler *assm, unsigned int parentID, SmlCommand *cmd, SmlError **error) +gboolean +smlXmlAssemblerStartCommand (SmlXmlAssembler *assm, + gsize parentID, + SmlCommand *cmd, + GError **error) { CHECK_ERROR_REF smlAssert(assm); smlAssert(cmd); + + SmlXmlAssemblerCommand *assmcmd = NULL; if (cmd->type == SML_COMMAND_TYPE_UNKNOWN) { - smlErrorSet(error, SML_ERROR_GENERIC, "No cmd set"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No cmd set"); goto error; } if (!cmd->cmdID) { - smlErrorSet(error, SML_ERROR_GENERIC, "No cmd ID set"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No cmd ID set"); goto error; } /* Lets see if there already was a header before */ if (!assm->header_buffer) { - smlErrorSet(error, SML_ERROR_GENERIC, "Header not yet added"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Header not yet added"); goto error; } - SmlXmlAssemblerCommand *assmcmd = smlTryMalloc0(sizeof(SmlXmlAssemblerCommand), error); + assmcmd = smlTryMalloc0(sizeof(SmlXmlAssemblerCommand), error); if (!assmcmd) goto error; assmcmd->nodeType = SML_ASSEMBLER_NODE_OPEN; @@ -1125,57 +1214,60 @@ /* We first start a new parent writer that will write our command into a buffer */ assmcmd->buffer = xmlBufferCreateSize(BUFFER_SIZE); if (!assmcmd->buffer) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to create new buffer"); - goto error_free_cmd; + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Unable to create new buffer"); + goto error; } assm->writer = xmlNewTextWriterMemory(assmcmd->buffer, 0); if (!assm->writer) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to create new writer"); - goto error_free_buffer; + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Unable to create new writer"); + goto error; } /* We start without the root node */ if (!_smlXmlAssemblerAddID(assm, SML_ELEMENT_CMDID, cmd->cmdID, error)) - goto error_free_writer; + goto error; switch (cmd->type) { case SML_COMMAND_TYPE_ALERT: if (!smlAlertAssemble(assm, cmd, error)) - goto error_free_writer; + goto error; break; case SML_COMMAND_TYPE_SYNC: if (!smlSyncAssemble(assm, cmd, error)) - goto error_free_writer; + goto error; break; case SML_COMMAND_TYPE_ADD: case SML_COMMAND_TYPE_REPLACE: case SML_COMMAND_TYPE_DELETE: if (!smlChangeAssemble(assm, cmd, error)) - goto error_free_writer; + goto error; break; case SML_COMMAND_TYPE_PUT: case SML_COMMAND_TYPE_GET: if (!smlAccessAssemble(assm, cmd, error)) - goto error_free_writer; + goto error; break; case SML_COMMAND_TYPE_MAP: if (!smlMapAssemble(assm, cmd, error)) - goto error_free_writer; + goto error; break; case SML_COMMAND_TYPE_RESULTS: if (!smlResultsAssemble(assm, cmd, error)) - goto error_free_writer; + goto error; break; default: - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown command type"); - goto error_free_writer; + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Unknown command type"); + goto error; } /* Now close the buffer */ if (xmlTextWriterEndDocument(assm->writer) < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to end writer"); - goto error_free_writer; + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to end writer"); + goto error; } xmlFreeTextWriter(assm->writer); @@ -1185,26 +1277,33 @@ *appendto = g_list_append(*appendto, assmcmd); return TRUE; - -error_free_writer: - xmlFreeTextWriter(assm->writer); - assm->writer = NULL; -error_free_buffer: - xmlBufferFree(assmcmd->buffer); -error_free_cmd: - smlSafeFree((gpointer *)&assmcmd); error: + if (assm->writer) { + xmlFreeTextWriter(assm->writer); + assm->writer = NULL; + } + if (assmcmd) { + if (assmcmd->buffer) { + xmlBufferFree(assmcmd->buffer); + assmcmd->buffer = NULL; + } + smlSafeFree((gpointer *)&assmcmd); + } return FALSE; } -SmlBool smlXmlAssemblerEndCommand(SmlXmlAssembler *assm, unsigned int parentID, SmlError **error) +gboolean +smlXmlAssemblerEndCommand (SmlXmlAssembler *assm, + gsize parentID, + GError **error) { CHECK_ERROR_REF smlAssert(assm); /* Lets see if there already was a header before */ if (!assm->header_buffer) { - smlErrorSet(error, SML_ERROR_GENERIC, "Header not yet added"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Header not yet added"); goto error; } @@ -1229,12 +1328,14 @@ *appendto = g_list_append(*appendto, assmcmd); return TRUE; - error: return FALSE; } -SmlBool smlXmlAssemblerRemCommand(SmlXmlAssembler *assm, unsigned int parentID, SmlError **error) +gboolean +smlXmlAssemblerRemCommand (SmlXmlAssembler *assm, + gsize parentID, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, assm, parentID, error); CHECK_ERROR_REF @@ -1253,7 +1354,7 @@ } if (!*removefrom) { - smlErrorSet(error, SML_ERROR_GENERIC, "Nothing to remove"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Nothing to remove"); goto error; } @@ -1261,7 +1362,8 @@ SmlXmlAssemblerCommand *cmd = b->data; *removefrom = g_list_delete_link(*removefrom, b); if (cmd->nodeType != SML_ASSEMBLER_NODE_OPEN) { - smlErrorSet(error, SML_ERROR_GENERIC, "Trying to remove not a starting command"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Trying to remove not a starting command"); goto error; } @@ -1272,20 +1374,22 @@ 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 smlXmlAssemblerRemStatus(SmlXmlAssembler *assm, SmlError **error) +gboolean +smlXmlAssemblerRemStatus (SmlXmlAssembler *assm, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, assm, error); CHECK_ERROR_REF smlAssert(assm); if (!assm->statuses) { - smlErrorSet(error, SML_ERROR_GENERIC, "Trying to remove status but no status available"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Trying to remove status but no status available"); goto error; } @@ -1308,13 +1412,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 smlXmlAssemblerReserveStatus(SmlXmlAssembler *assm, unsigned int cmdRef, unsigned int msgRef, unsigned int cmdID, SmlError **error) +gboolean +smlXmlAssemblerReserveStatus (SmlXmlAssembler *assm, + gsize cmdRef, + gsize msgRef, + gsize cmdID, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %i, %i, %p)", __func__, assm, cmdRef, msgRef, cmdID, error); CHECK_ERROR_REF @@ -1337,13 +1445,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 smlXmlAssemblerAddStatus(SmlXmlAssembler *assm, SmlStatus *status, SmlError **error) +gboolean +smlXmlAssemblerAddStatus (SmlXmlAssembler *assm, + SmlStatus *status, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, assm, status, error); CHECK_ERROR_REF @@ -1358,18 +1468,18 @@ goto error; if (!status->msgRef) { - smlErrorSet(error, SML_ERROR_GENERIC, "No msgref set"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No msgref set"); goto error; } if (status->type == SML_COMMAND_TYPE_UNKNOWN) { - smlErrorSet(error, SML_ERROR_GENERIC, "No cmd set"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No cmd set"); goto error; } /* Lets see if there already was a header before */ if (!assm->header_buffer) { - smlErrorSet(error, SML_ERROR_GENERIC, "Header not yet added"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Header not yet added"); goto error; } @@ -1383,30 +1493,30 @@ } if (!res) { - smlErrorSet(error, SML_ERROR_GENERIC, "Status not reserved"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Status not reserved"); goto error; } if (!res->cmdID) { - smlErrorSet(error, SML_ERROR_GENERIC, "No cmd ID set"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No cmd ID set"); goto error; } if (res->buffer) { - smlErrorSet(error, SML_ERROR_GENERIC, "Status already added"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Status already added"); goto error; } /* We first start a new writer that will write our status into a buffer */ res->buffer = xmlBufferCreateSize(BUFFER_SIZE); if (!res->buffer) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to create new buffer"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to create new buffer"); goto error; } assm->writer = xmlNewTextWriterMemory(res->buffer, 0); if (!assm->writer) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to create new writer"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to create new writer"); goto error_free_buffer; } @@ -1472,7 +1582,7 @@ goto error; break; default: - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown auth type"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown auth type"); goto error; } @@ -1518,7 +1628,7 @@ /* Now close the buffer and get the content */ if (xmlTextWriterEndDocument(assm->writer) < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to end writer"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to end writer"); goto error_free_writer; } @@ -1539,11 +1649,12 @@ res->buffer = NULL; error: g_mutex_unlock(assm->mutex); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -SmlBool smlXmlAssemblerMissingStatus(SmlXmlAssembler *assm) +gboolean +smlXmlAssemblerMissingStatus (SmlXmlAssembler *assm) { smlAssert(assm); @@ -1553,7 +1664,8 @@ return FALSE; } -static void flush_list(GList *list) +static void +flush_list(GList *list) { GList *l = NULL; for (l = list; l; l = l->next) { @@ -1569,7 +1681,8 @@ g_list_free(list); } -void smlXmlAssemblerFree(SmlXmlAssembler *assm) +void +smlXmlAssemblerFree (SmlXmlAssembler *assm) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, assm); smlAssert(assm); @@ -1600,13 +1713,14 @@ /* This function returns the highest command id that is still in the * assembler after flushing which is: number of statuses + 1 */ -unsigned int smlXmlAssemblerFlush(SmlXmlAssembler *assm) +gsize +smlXmlAssemblerFlush (SmlXmlAssembler *assm) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, assm); smlAssert(assm); unsigned int newid = 1; - SmlBool missing = FALSE; + gboolean missing = FALSE; /* Remove the statuses */ GList *s = NULL; @@ -1648,7 +1762,10 @@ return newid; } -SmlBool smlXmlAssemblerStart(SmlXmlAssembler *assm, SmlSession *session, SmlError **error) +gboolean +smlXmlAssemblerStart (SmlXmlAssembler *assm, + SmlSession *session, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, assm, session, error); CHECK_ERROR_REF @@ -1664,7 +1781,9 @@ } -SmlBool smlXmlAssemblerEnd(SmlXmlAssembler *assm, SmlError **error) +gboolean +smlXmlAssemblerEnd (SmlXmlAssembler *assm, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, assm, error); CHECK_ERROR_REF @@ -1676,27 +1795,29 @@ goto error; if (_smlXmlAssemblerEndNode(assm, NULL)) { - smlErrorSet(error, SML_ERROR_GENERIC, "Extra node open"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Extra node open"); goto error; } g_mutex_unlock(assm->mutex); smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: g_mutex_unlock(assm->mutex); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -SmlBool smlXmlAssemblerAddChildren(SmlXmlAssembler *assm, GList *b, SmlError **error) +gboolean +smlXmlAssemblerAddChildren (SmlXmlAssembler *assm, + GList *b, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, assm, b, error); CHECK_ERROR_REF smlAssert(assm); const char *opt = smlAssemblerGetOption(assm->assembler, "ONLY_REPLACE"); - SmlBool onlyReplace = (opt && atoi(opt)) ? TRUE : FALSE; + gboolean onlyReplace = (opt && atoi(opt)) ? TRUE : FALSE; SmlXmlAssemblerCommand *cmd = NULL; const char *cmdname = NULL; @@ -1721,7 +1842,8 @@ int rc = xmlTextWriterWriteRawLen(assm->writer, xmlBufferContent(cmd->buffer), xmlBufferLength(cmd->buffer)); if (rc < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to write raw node data (%d).", rc); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Unable to write raw node data (%d).", rc); goto error; } @@ -1744,13 +1866,20 @@ 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 smlXmlAssemblerRunFull(SmlXmlAssembler *assm, char **data, unsigned int *size, SmlBool *end, SmlBool final, SmlBool check, unsigned int maxsize, SmlError **error) +gboolean +smlXmlAssemblerRunFull (SmlXmlAssembler *assm, + gchar **data, + gsize *size, + gboolean *end, + gboolean final, + gboolean check, + gsize maxsize, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %i, %i, %i, %p)", __func__, assm, data, size, end, final, check, maxsize, error); CHECK_ERROR_REF @@ -1763,7 +1892,7 @@ /* Return an error if there is no header */ if (!assm->header_buffer) { - smlErrorSet(error, SML_ERROR_GENERIC, "No header available"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No header available"); goto error; } @@ -1771,14 +1900,16 @@ * statuses have been reserved, at least the first status * must be added */ if (check && !assm->statuses && !assm->commands) { - smlErrorSet(error, SML_ERROR_GENERIC, "No status/command available"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "No status/command available"); goto error; } if (check && assm->statuses && final) { SmlXmlAssemblerStatus *status = assm->statuses->data; if (!status->buffer) { - smlErrorSet(error, SML_ERROR_GENERIC, "Missing the first status with cmdRef %i", status->cmdRef); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Missing the first status with cmdRef %i", + status->cmdRef); goto error; } } @@ -1786,13 +1917,13 @@ /* Create the final buffer and writer */ xmlBuffer *buffer = xmlBufferCreateSize(BUFFER_SIZE); if (!buffer) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to create new buffer"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to create new buffer"); goto error; } assm->writer = xmlNewTextWriterMemory(buffer, 0); if (!assm->writer) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to create new writer"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to create new writer"); goto error_free_buffer; } @@ -1801,7 +1932,7 @@ * is explicitly added to support buggy XML parsers. */ if (xmlTextWriterStartDocument(assm->writer, NULL, "UTF-8", NULL) < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to create new writer"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to create new writer"); goto error_free_writer; } @@ -1823,14 +1954,15 @@ goto error_free_writer; break; default: - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown version"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unknown version"); goto error_free_writer; } /* Add the header */ int rc = xmlTextWriterWriteRawLen(assm->writer, xmlBufferContent(assm->header_buffer), xmlBufferLength(assm->header_buffer)); if (rc < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to write raw header data (%d).", rc); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Unable to write raw header data (%d).", rc); goto error_free_writer; } @@ -1844,14 +1976,15 @@ /* Add the statuses */ GList *b = NULL; - SmlBool missingstatus = FALSE; + gboolean missingstatus = FALSE; smlTrace(TRACE_INTERNAL, "%s: Now adding %i statuses", __func__, g_list_length(assm->statuses)); for (b = assm->statuses; b; b = b->next) { SmlXmlAssemblerStatus *status = b->data; if (!status->buffer || xmlBufferLength(status->buffer) == 0) { if (status->cmdRef == 0 && check) { - smlErrorSet(error, SML_ERROR_GENERIC, "Reserved status 0 has not been added"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Reserved status 0 has not been added"); goto error_free_writer; } smlTrace(TRACE_INTERNAL, "%s: Reserved status %i is missing", @@ -1865,16 +1998,18 @@ // break; rc = xmlTextWriterWriteRawLen(assm->writer, xmlBufferContent(status->buffer), xmlBufferLength(status->buffer)); if (rc < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to write raw status data (%d - %d of %d: %s).", - rc, xmlBufferLength(status->buffer), - buffersize, xmlBufferContent(status->buffer)); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Unable to write raw status data (%d - %d of %d: %s).", + rc, xmlBufferLength(status->buffer), + buffersize, xmlBufferContent(status->buffer)); goto error_free_writer; } } /* We cannot have missing statuses when its final. And we cannot add commands */ if (missingstatus && final && check) { - smlErrorSet(error, SML_ERROR_GENERIC, "Reserved status has not been added"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Reserved status has not been added"); goto error_free_writer; } @@ -1897,7 +2032,7 @@ goto error_free_writer; if (xmlTextWriterEndDocument(assm->writer) < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to end writer"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, "Unable to end writer"); goto error; } @@ -1930,13 +2065,13 @@ xmlBufferFree(buffer); error: g_mutex_unlock(assm->mutex); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -static unsigned int calc_list(GList *list) +static gsize calc_list(GList *list) { - unsigned int size = 0; + gsize size = 0; for (; list; list = list->next) { SmlXmlAssemblerCommand *cmd = list->data; @@ -1951,20 +2086,30 @@ return size; } -SmlBool smlXmlAssemblerRun(SmlXmlAssembler *assm, char **data, unsigned int *size, SmlBool *end, SmlBool final, unsigned int maxsize, SmlError **error) +gboolean +smlXmlAssemblerRun (SmlXmlAssembler *assm, + gchar **data, + gsize *size, + gboolean *end, + gboolean final, + gsize maxsize, + GError **error) { CHECK_ERROR_REF - SmlBool ans = smlXmlAssemblerRunFull(assm, data, size, end, final, TRUE, maxsize, error); + gboolean ans = smlXmlAssemblerRunFull(assm, data, size, end, final, TRUE, maxsize, error); if (ans) smlLog("sent-%i.xml", *data, *size); else - smlTrace(TRACE_ERROR, "%s - %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_ERROR, "%s - %s", __func__, (*error)->message); return ans; } -unsigned int smlXmlAssemblerCheckSize(SmlXmlAssembler *assm, SmlBool headeronly, SmlError **error) +gsize +smlXmlAssemblerCheckSize (SmlXmlAssembler *assm, + gboolean headeronly, + GError **error) { CHECK_ERROR_REF smlAssert(assm); @@ -1996,7 +2141,10 @@ return size; } -SmlBool smlXmlAssemblerNextCmdRef(SmlXmlAssembler *assm, unsigned int *cmdRef, unsigned int *msgRef) +gboolean +smlXmlAssemblerNextCmdRef (SmlXmlAssembler *assm, + gsize *cmdRef, + gsize *msgRef) { smlAssert(assm); smlAssert(cmdRef); @@ -2023,7 +2171,10 @@ * @return The new assembler or NULL in the case of an error * */ -SmlXmlAssembler *smlXmlAssemblerNew(SmlAssembler *assembler, SmlAssemblerFunctions *functions, SmlError **error) +SmlXmlAssembler* +smlXmlAssemblerNew (SmlAssembler *assembler, + SmlAssemblerFunctions *functions, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, assembler, functions, error); CHECK_ERROR_REF @@ -2058,13 +2209,19 @@ error_mutex: smlSafeFree((gpointer *)&assm); - smlErrorSet(error, SML_ERROR_GENERIC, "%s - Cannot create new mutex.", __func__); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "%s - Cannot create new mutex.", __func__); error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -static SmlBool _smlXmlDevInfDataStoreAssembleRxTx(SmlXmlAssembler *assm, const char *element, const char *cttype, const char *version, SmlError **error) +static gboolean +_smlXmlDevInfDataStoreAssembleRxTx (SmlXmlAssembler *assm, + const gchar *element, + const gchar *cttype, + const gchar *version, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %s, %s, %s, %p)", __func__, assm, VA_STRING(element), VA_STRING(cttype), VA_STRING(version), error); CHECK_ERROR_REF @@ -2086,17 +2243,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; } -static SmlBool _smlXmlDevInfDataStoreAssembleCTCap( - SmlXmlAssembler *assm, - SmlDevInfCTCap *ctcap, - SmlBool flat, - SmlError **error) +static gboolean +_smlXmlDevInfDataStoreAssembleCTCap (SmlXmlAssembler *assm, + SmlDevInfCTCap *ctcap, + gboolean flat, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, assm, ctcap, error); CHECK_ERROR_REF @@ -2270,17 +2426,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; } -static SmlBool _smlXmlDevInfDataStoreAssemble( - SmlXmlAssembler *assm, - SmlDevInfDataStore *datastore, - SmlDevInf *devinf, - SmlError **error) +static gboolean +_smlXmlDevInfDataStoreAssemble (SmlXmlAssembler *assm, + SmlDevInfDataStore *datastore, + SmlDevInf *devinf, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, assm, datastore, devinf, error); CHECK_ERROR_REF @@ -2288,14 +2443,9 @@ smlAssert(assm); GList *contentTypes = NULL; - GError *gerror = NULL; - if (!sml_dev_inf_data_store_is_compliant(datastore, &gerror)) { - smlErrorSet(error, gerror->code, "%s", gerror->message); - g_error_free(gerror); - gerror = NULL; + if (!sml_dev_inf_data_store_is_compliant(datastore, error)) goto error; - } // Datastore if (!_smlXmlAssemblerStartNode(assm, SML_ELEMENT_DATASTORE, error)) @@ -2458,13 +2608,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 smlXmlDevInfAssemble(SmlDevInf *devinf, SmlDevInfVersion version, char **data, unsigned int *size, SmlError **error) +gboolean +smlXmlDevInfAssemble (SmlDevInf *devinf, + SmlDevInfVersion version, + gchar **data, + gsize *size, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p)", __func__, devinf, version, data, size, error); CHECK_ERROR_REF @@ -2488,13 +2642,15 @@ /* We first start a new parent writer that will write our command into a buffer */ xmlBuffer *buffer = xmlBufferCreateSize(BUFFER_SIZE); if (!buffer) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to create new buffer"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Unable to create new buffer"); goto error_free_assm; } assm->writer = xmlNewTextWriterMemory(buffer, 0); if (!assm->writer) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to create new writer"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Unable to create new writer"); goto error_free_buffer; } @@ -2517,7 +2673,8 @@ goto error_free_writer; break; case SML_DEVINF_VERSION_UNKNOWN: - smlErrorSet(error, SML_ERROR_GENERIC, "Unknown devinf version"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Unknown devinf version"); goto error_free_writer; break; } @@ -2622,7 +2779,8 @@ /* Now close the buffer */ if (xmlTextWriterEndDocument(assm->writer) < 0) { - smlErrorSet(error, SML_ERROR_GENERIC, "Unable to end writer"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "Unable to end writer"); goto error_free_writer; } @@ -2649,12 +2807,13 @@ error_free_assm: smlSafeFree((gpointer *)&assm); error: - g_warning("%s: %s", __func__, smlErrorPrint(error)); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + g_warning("%s: %s", __func__, (*error)->message); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -void smlXmlAssemblerRestoreCommands(SmlXmlAssembler *assm) +void +smlXmlAssemblerRestoreCommands (SmlXmlAssembler *assm) { smlTrace(TRACE_ENTRY, "%s", __func__); smlAssert(assm->commands == NULL); Modified: trunk/libsyncml/parser/sml_xml_assm_internals.h ============================================================================== --- trunk/libsyncml/parser/sml_xml_assm_internals.h Wed Jul 8 16:18:21 2009 (r1158) +++ trunk/libsyncml/parser/sml_xml_assm_internals.h Wed Jul 8 17:16:46 2009 (r1159) @@ -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 @@ -50,19 +50,19 @@ /** The type of the node. Either a opening or a closing node */ SmlXmlAssemblerNodeType nodeType; /** The command id. Needed if you want to add children */ - unsigned int cmdID; + gsize cmdID; GList *children; } SmlXmlAssemblerCommand; typedef struct SmlXmlAssemblerStatus { /** The type of the command. Used the make the opening and closing tags */ - unsigned int cmdRef; + gsize cmdRef; - unsigned int msgRef; + gsize msgRef; /** The buffer that holds the assembled data of this status */ xmlBuffer *buffer; /** The command id.*/ - unsigned int cmdID; + gsize cmdID; } SmlXmlAssemblerStatus; struct SmlXmlAssembler { @@ -77,19 +77,19 @@ SmlAssembler *assembler; GMutex *mutex; - unsigned int reserved_statuses; - unsigned int added_statuses; + gsize reserved_statuses; + gsize added_statuses; - SmlBool moreDataSet; + gboolean moreDataSet; }; -SmlBool smlAssemblerStartNode(SmlAssembler *assm, const char *name, SmlError **error); -SmlBool smlAssemblerStartNodeNS(SmlAssembler *assm, const char *prefix, const char *name, const char *uri, SmlError **error); -SmlBool smlAssemblerEndNode(SmlAssembler *assm, SmlError **error); -SmlBool smlAssemblerAddString(SmlAssembler *assm, const char *name, const char *value, SmlError **error); -SmlBool smlAssemblerAddStringNS(SmlAssembler *assm, const char *prefix, const char *name, const char *uri, const char *value, SmlError **error); -SmlBool smlAssemblerAddID(SmlAssembler *assm, const char *name, unsigned int id, SmlError **error); -SmlBool smlAssemblerAddData(SmlAssembler *assm, const char *name, const char *value, SmlError **error); +gboolean smlAssemblerStartNode (SmlAssembler *assm, const gchar *name, GError **error); +gboolean smlAssemblerStartNodeNS (SmlAssembler *assm, const gchar *prefix, const gchar *name, const gchar *uri, GError **error); +gboolean smlAssemblerEndNode (SmlAssembler *assm, GError **error); +gboolean smlAssemblerAddString (SmlAssembler *assm, const gchar *name, const gchar *value, GError **error); +gboolean smlAssemblerAddStringNS (SmlAssembler *assm, const gchar *prefix, const gchar *name, const gchar *uri, const gchar *value, GError **error); +gboolean smlAssemblerAddID (SmlAssembler *assm, const gchar *name, gsize id, GError **error); +gboolean smlAssemblerAddData (SmlAssembler *assm, const gchar *name, const gchar *value, GError **error); #endif //_SML_XML_ASSM_INTERNALS_H_ /*@}*/ |
From: <svn...@op...> - 2009-07-08 14:35:00
|
Author: bellmich Date: Wed Jul 8 16:18:21 2009 New Revision: 1158 URL: http://libsyncml.opensync.org/changeset/1158 Log: migrated parser/sml_wbxml from SmlError to SmlBool Modified: trunk/libsyncml/parser/sml_wbxml.c trunk/libsyncml/parser/sml_wbxml.h trunk/libsyncml/parser/sml_wbxml_internals.h trunk/libsyncml/parser/sml_xml_assm.h Modified: trunk/libsyncml/parser/sml_wbxml.c ============================================================================== --- trunk/libsyncml/parser/sml_wbxml.c Wed Jul 8 12:22:14 2009 (r1157) +++ trunk/libsyncml/parser/sml_wbxml.c Wed Jul 8 16:18:21 2009 (r1158) @@ -36,7 +36,12 @@ #include "sml_wbxml.h" #include "sml_wbxml_internals.h" -SmlBool smlWbxmlConvertTo(WBXMLConvXML2WBXMLParams *params, const char *input, char **output, size_t *outputLen, SmlError** error) +gboolean +smlWbxmlConvertTo (WBXMLConvXML2WBXMLParams *params, + const gchar *input, + gchar **output, + gsize *outputLen, + GError** error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %p)", __func__, params, input, output, outputLen, error); smlAssert(input); @@ -51,14 +56,20 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: - smlErrorSet(error, SML_ERROR_GENERIC, (char *)wbxml_errors_string(wberror)); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "%s", (const char *)wbxml_errors_string(wberror)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -SmlBool smlWbxmlConvertFrom(WBXMLConvWBXML2XMLParams *params, const char *input, size_t inputLen, char **output, size_t *outputLen, SmlError** error) +gboolean +smlWbxmlConvertFrom (WBXMLConvWBXML2XMLParams *params, + const gchar *input, + gsize inputLen, + gchar **output, + gsize *outputLen, + GError** error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %i, %p, %p, %p)", __func__, params, input, inputLen, output, outputLen, error); WBXMLError wberror; @@ -70,14 +81,18 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: - smlErrorSet(error, SML_ERROR_GENERIC, (char *)wbxml_errors_string(wberror)); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "%s", (const char *)wbxml_errors_string(wberror)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -static SmlBool smlWbxmlParserStart(SmlXmlParser *parser, const char *data, unsigned int size, SmlError **error) +static gboolean +smlWbxmlParserStart (SmlXmlParser *parser, + const gchar *data, + gsize size, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, parser, data, size, error); CHECK_ERROR_REF @@ -107,15 +122,16 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: if (buffer) smlSafeCFree(&buffer); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -SmlXmlParser *smlWbxmlParserNew(SmlParserFunctions *functions, SmlError **error) +SmlXmlParser* +smlWbxmlParserNew (SmlParserFunctions *functions, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, functions, error); CHECK_ERROR_REF @@ -129,13 +145,19 @@ smlTrace(TRACE_EXIT, "%s: %p", __func__, parser); return parser; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -SmlBool smlWbxmlAssemblerRun(SmlXmlAssembler *assm, char **data, unsigned int *size, SmlBool *end, SmlBool final, unsigned int maxsize, SmlError **error) +gboolean +smlWbxmlAssemblerRun (SmlXmlAssembler *assm, + gchar **data, + gsize *size, + gboolean *end, + gboolean final, + gsize maxsize, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p, %i, %i, %p)", __func__, assm, data, size, end, final, maxsize, error); CHECK_ERROR_REF @@ -164,15 +186,17 @@ smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - error: if (buffer) smlSafeCFree(&buffer); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } -unsigned int smlWbxmlAssemblerCheckSize(SmlXmlAssembler *assm, SmlBool headeronly, SmlError **error) +gsize +smlWbxmlAssemblerCheckSize (SmlXmlAssembler *assm, + gboolean headeronly, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, assm, headeronly, error); CHECK_ERROR_REF @@ -190,18 +214,17 @@ if (opt && atoi(opt)) params.use_strtbl = TRUE; if (!smlWbxmlConvertTo(¶ms, buffer, &data, &size, error)) - goto error_free_buffer; + goto error; smlSafeCFree(&data); smlSafeCFree(&buffer); smlTrace(TRACE_EXIT, "%s: %i", __func__, size); return size; - -error_free_buffer: - smlSafeCFree(&buffer); error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + if (buffer) + smlSafeCFree(&buffer); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return 0; } @@ -212,7 +235,10 @@ * @return The new assembler or NULL in the case of an error * */ -SmlXmlAssembler *smlWbxmlAssemblerNew(SmlAssembler *assembler, SmlAssemblerFunctions *functions, SmlError **error) +SmlXmlAssembler* +smlWbxmlAssemblerNew (SmlAssembler *assembler, + SmlAssemblerFunctions *functions, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, assembler, functions, error); CHECK_ERROR_REF @@ -226,9 +252,8 @@ smlTrace(TRACE_EXIT, "%s: %p", __func__, assm); return assm; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } Modified: trunk/libsyncml/parser/sml_wbxml.h ============================================================================== --- trunk/libsyncml/parser/sml_wbxml.h Wed Jul 8 12:22:14 2009 (r1157) +++ trunk/libsyncml/parser/sml_wbxml.h Wed Jul 8 16:18:21 2009 (r1158) @@ -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_WBXML_H_ #define _SML_WBXML_H_ -SmlXmlParser *smlWbxmlParserNew(SmlParserFunctions *functions, GError **error); -SmlXmlAssembler *smlWbxmlAssemblerNew(SmlAssembler *assembler, SmlAssemblerFunctions *functions, GError **error); +SmlXmlParser* smlWbxmlParserNew (SmlParserFunctions *functions, GError **error); +SmlXmlAssembler* smlWbxmlAssemblerNew (SmlAssembler *assembler, SmlAssemblerFunctions *functions, GError **error); #endif //_SML_WBXML_H_ /*@}*/ Modified: trunk/libsyncml/parser/sml_wbxml_internals.h ============================================================================== --- trunk/libsyncml/parser/sml_wbxml_internals.h Wed Jul 8 12:22:14 2009 (r1157) +++ trunk/libsyncml/parser/sml_wbxml_internals.h Wed Jul 8 16:18:21 2009 (r1158) @@ -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 @@ #include <wbxml.h> -SmlBool smlWbxmlConvertTo(WBXMLConvXML2WBXMLParams *params, const char *input, char **output, size_t *outputLen, SmlError** error); -SmlBool smlWbxmlConvertFrom(WBXMLConvWBXML2XMLParams *params, const char *input, size_t inputLen, char **output, size_t *outputLen, SmlError** error); +gboolean smlWbxmlConvertTo (WBXMLConvXML2WBXMLParams *params, const gchar *input, gchar **output, gsize *outputLen, GError** error); +gboolean smlWbxmlConvertFrom (WBXMLConvWBXML2XMLParams *params, const gchar *input, gsize inputLen, gchar **output, gsize *outputLen, GError** error); #endif //_SML_WBXML_INTERNALS_H_ /*@}*/ Modified: trunk/libsyncml/parser/sml_xml_assm.h ============================================================================== --- trunk/libsyncml/parser/sml_xml_assm.h Wed Jul 8 12:22:14 2009 (r1157) +++ trunk/libsyncml/parser/sml_xml_assm.h Wed Jul 8 16:18:21 2009 (r1158) @@ -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 @@ -32,27 +32,23 @@ typedef struct SmlXmlAssembler SmlXmlAssembler; -SmlXmlAssembler *smlXmlAssemblerNew(SmlAssembler *assembler, SmlAssemblerFunctions *functions, GError **error); +SmlXmlAssembler* smlXmlAssemblerNew (SmlAssembler *assembler, SmlAssemblerFunctions *functions, GError **error); -SmlBool smlXmlAssemblerAddHeader(SmlXmlAssembler *assembler, SmlSession *session, SmlError **error); -// FIXME: not yet implemented -// SmlBool smlXmlAssemblerAddCommand(SmlXmlAssembler *assembler, SmlCommand *cmd, SmlError **error); -SmlBool smlXmlAssemblerAddStatus(SmlXmlAssembler *assembler, SmlStatus *status, SmlError **error); -void smlXmlAssemblerFree(SmlXmlAssembler *assm); -// FIXME: not yet implemented -// void smlXmlAssemblerClean(SmlXmlAssembler *assm); -SmlBool smlXmlAssemblerStart(SmlXmlAssembler *assm, SmlSession *session, SmlError **error); -SmlBool smlXmlAssemblerEnd(SmlXmlAssembler *assm, SmlError **error); -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); +gboolean smlXmlAssemblerAddHeader (SmlXmlAssembler *assembler, SmlSession *session, GError **error); +gboolean smlXmlAssemblerAddStatus (SmlXmlAssembler *assembler, SmlStatus *status, GError **error); +void smlXmlAssemblerFree (SmlXmlAssembler *assm); +gboolean smlXmlAssemblerStart (SmlXmlAssembler *assm, SmlSession *session, GError **error); +gboolean smlXmlAssemblerEnd (SmlXmlAssembler *assm, GError **error); +gboolean smlXmlAssemblerRun (SmlXmlAssembler *assm, gchar **data, gsize *size, gboolean *end, gboolean final, gsize maxsize, GError **error); +gboolean smlXmlAssemblerRunFull (SmlXmlAssembler *assm, char **data, unsigned int *size, gboolean *end, gboolean final, gboolean check, gsize maxsize, GError **error); -SmlBool smlXmlDevInfAssemble(SmlDevInf *devinf, SmlDevInfVersion version, char **data, unsigned int *size, GError **error); +gboolean smlXmlDevInfAssemble (SmlDevInf *devinf, SmlDevInfVersion version, gchar **data, gsize *size, GError **error); /* This is necessary if the first message results in an error 407. * This error means authentication required. * After such an error the previous commands must be sent again. */ -void smlXmlAssemblerRestoreCommands(SmlXmlAssembler *assm); +void smlXmlAssemblerRestoreCommands (SmlXmlAssembler *assm); #endif //_SML_XML_ASSM_H_ /*@}*/ |
From: <svn...@op...> - 2009-07-08 10:22:25
|
Author: bellmich Date: Wed Jul 8 12:22:14 2009 New Revision: 1157 URL: http://libsyncml.opensync.org/changeset/1157 Log: migrated sml_ds_server from SmlError to GError Modified: trunk/libsyncml/objects/sml_ds_server.c trunk/libsyncml/objects/sml_ds_server.h trunk/libsyncml/objects/sml_ds_server_internals.h Modified: trunk/libsyncml/objects/sml_ds_server.c ============================================================================== --- trunk/libsyncml/objects/sml_ds_server.c Wed Jul 8 11:19:54 2009 (r1156) +++ trunk/libsyncml/objects/sml_ds_server.c Wed Jul 8 12:22:14 2009 (r1157) @@ -30,7 +30,7 @@ #include <libsyncml/sml_command_internals.h> #include <libsyncml/sml_elements_internals.h> -static SmlWriteContext *_write_context_find(SmlDsSession *dsession, const char *uid, SmlChangeType type) +static SmlWriteContext *_write_context_find(SmlDsSession *dsession, const gchar *uid, SmlChangeType type) { smlTrace(TRACE_ENTRY, "%s(%p, %s, %i)", __func__, dsession, VA_STRING(uid), type); @@ -89,7 +89,7 @@ return; } - ctx->callback(dsession, ctx->status, ctx->newuid, ctx->userdata); + ctx->callback(dsession, ctx->status, ctx->userdata); g_mutex_lock(dsession->pendingMapsLock); dsession->pendingMaps = g_list_remove(dsession->pendingMaps, ctx); @@ -189,7 +189,10 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -SmlDsServer *smlDsServerNew(const char *type, SmlLocation *location, SmlError **error) +SmlDsServer* +smlDsServerNew (const gchar *type, + SmlLocation *location, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%s, %p, %p)", __func__, VA_STRING(type), location, error); smlAssert(location); @@ -207,13 +210,16 @@ smlTrace(TRACE_EXIT, "%s: %p", __func__, server); return server; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -SmlDsServer *smlDsClientNew(const char *type, SmlLocation *location, SmlLocation *target, SmlError **error) +SmlDsServer* +smlDsClientNew (const gchar *type, + SmlLocation *location, + SmlLocation *target, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%s, %p, %p, %p)", __func__, VA_STRING(type), location, target, error); smlAssert(location); @@ -235,9 +241,8 @@ smlTrace(TRACE_EXIT, "%s: %p", __func__, server); return server; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } @@ -287,18 +292,6 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -void smlDsServerSetSanCallback(SmlDsServer *server, SmlDsServerSanCb callback, void *userdata) -{ - smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, server, callback, userdata); - smlAssert(server); - smlAssert(server->servertype == SML_DS_CLIENT); - - server->sanCallback = callback; - server->sanCallbackUserdata = userdata; - - smlTrace(TRACE_EXIT, "%s", __func__); -} - void smlDsServerSetSanSessionCallback(SmlDsServer *server, SmlDsServerSanSessionCb callback, void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, server, callback, userdata); @@ -325,7 +318,10 @@ return server->contenttype; } -SmlBool smlDsServerAddSan(SmlDsServer *server, SmlNotification *san, SmlError **error) +gboolean +smlDsServerAddSan (SmlDsServer *server, + SmlNotification *san, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, server, san, error); smlAssert(server); @@ -337,16 +333,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; } SmlDsSession *smlDsServerRecvAlert(SmlDsServer *server, SmlSession *session, SmlCommand *cmd) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, server, session, cmd); - SmlError *error = NULL; + GError *error = NULL; SmlDsSession *dsession = smlDsSessionNew(server, session, &error); if (!dsession) @@ -361,14 +356,22 @@ smlTrace(TRACE_EXIT, "%s", __func__); return dsession; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&error)); - smlErrorDeref(&error); + smlSessionDispatchEvent(session, SML_SESSION_EVENT_ERROR, NULL, NULL, NULL, error); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, error->message); + g_error_free(error); return NULL; } -SmlDsSession *smlDsServerSendAlert(SmlDsServer *server, SmlSession *session, SmlAlertType type, const char *last, const char *next, SmlStatusReplyCb callback, void *userdata, SmlError **error) +SmlDsSession* +smlDsServerSendAlert (SmlDsServer *server, + SmlSession *session, + SmlAlertType type, + const gchar *last, + const gchar *next, + SmlStatusReplyCb callback, + void *userdata, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %i, %s, %s, %p)", __func__, server, session, type, VA_STRING(last), VA_STRING(next), error); smlAssert(server); @@ -381,29 +384,31 @@ if (server->manager) { if (!smlManagerObjectRegister(server->manager, SML_COMMAND_TYPE_SYNC, session, server->location, NULL, NULL, smlDsSessionRecvSync, smlDsSessionRecvChange, dsession, error)) - goto error_free_dsession; + goto error; if (!smlManagerObjectRegister(server->manager, SML_COMMAND_TYPE_MAP, session, server->location, NULL, NULL, smlDsSessionRecvMap, NULL, dsession, error)) - goto error_free_dsession; + goto error; if (!smlManagerObjectRegister(server->manager, SML_COMMAND_TYPE_ALERT, session, server->location, NULL, NULL, smlDsSessionRecvAlert, NULL, dsession, error)) - goto error_free_dsession; + goto error; } if (!smlDsSessionSendAlert(dsession, type, last, next, callback, userdata, error)) - goto error_free_dsession; + goto error; smlTrace(TRACE_EXIT, "%s", __func__); return dsession; - -error_free_dsession: - smlSafeFree((gpointer *)&dsession); error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + if (dsession) + smlSafeFree((gpointer *)&dsession); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } -SmlDsSession *smlDsSessionNew(SmlDsServer *server, SmlSession *session, SmlError **error) +SmlDsSession* +smlDsSessionNew (SmlDsServer *server, + SmlSession *session, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, server, session, error); smlAssert(server); @@ -432,9 +437,8 @@ smlTrace(TRACE_EXIT, "%s: %p", __func__, dsession); return dsession; - error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return NULL; } @@ -514,7 +518,7 @@ void smlDsSessionDispatch(SmlDsSession *dsession) { smlTrace(TRACE_ENTRY, "%s(%p)", __func__, dsession); - SmlError *error = NULL; + GError *error = NULL; SmlStatus *reply = NULL; /* A dispatch function should never block on a @@ -618,7 +622,8 @@ if (!cmd->private.change.items || !g_list_length(cmd->private.change.items)) { - smlErrorSet(&error, SML_ERROR_GENERIC, "No items found in command."); + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, + "No items found in command."); goto error; } @@ -634,7 +639,7 @@ SmlItem *item = g_list_nth_data(cmd->private.change.items, i); if (!item) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Item %i of the command's item list is NULL.", i); goto error; } @@ -642,7 +647,7 @@ * uid (if we are a client for example). If it is not given we use the * source uri. This has then to be translated by the sync engine of course */ if ((!item->source && !item->target)) { - smlErrorSet(&error, SML_ERROR_GENERIC, + g_set_error(&error, SML_ERROR, SML_ERROR_GENERIC, "Cannot determine UID because source an target are missing on item %i.", i); goto error; } @@ -706,16 +711,16 @@ g_mutex_unlock(dsession->lock); return; - error: if (reply) smlStatusUnref(reply); + smlSessionDispatchEvent(dsession->session, SML_SESSION_EVENT_ERROR, NULL, NULL, NULL, error); + smlTrace(TRACE_EXIT_ERROR, "%s: Unable to dispatch: %s", __func__, error->message); + g_error_free(error); g_mutex_unlock(dsession->lock); - smlTrace(TRACE_EXIT_ERROR, "%s: Unable to dispatch: %s", __func__, smlErrorPrint(&error)); - smlErrorDeref(&error); } -SmlBool smlDsSessionCheck(SmlDsSession *dsession) +gboolean smlDsSessionCheck(SmlDsSession *dsession) { if ((dsession->alertCommand && dsession->recvAlertCallback) || \ (dsession->recvSync && dsession->recvSyncCallback) || \ @@ -728,7 +733,7 @@ { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, cmd, userdata); SmlDsSession *dsession = userdata; - SmlError *error = NULL; + GError *error = NULL; smlAssert(dsession->location); g_mutex_lock(dsession->lock); @@ -794,16 +799,16 @@ error: g_mutex_unlock(dsession->lock); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&error)); - smlErrorDeref(&error); - return; + smlSessionDispatchEvent(session, SML_SESSION_EVENT_ERROR, NULL, NULL, NULL, error); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, error->message); + g_error_free(error); } void smlDsSessionRecvSync(SmlSession *session, SmlCommand *cmd, void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, cmd, userdata); SmlDsSession *dsession = userdata; - SmlError *error = NULL; + GError *error = NULL; /* Create a write lock on the complete DsSession object to avoid race * conditions. If the write lock is already present then this is the @@ -863,8 +868,9 @@ error: g_mutex_unlock(dsession->lock); g_mutex_unlock(dsession->write_lock); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&error)); - smlErrorDeref(&error); + smlSessionDispatchEvent(session, SML_SESSION_EVENT_ERROR, NULL, NULL, NULL, error); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, error->message); + g_error_free(error); } void smlDsSessionRecvChange(SmlSession *session, SmlCommand *cmd, void *userdata) @@ -888,7 +894,7 @@ { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, cmd, userdata); SmlDsSession *dsession = userdata; - SmlError *error = NULL; + GError *error = NULL; g_mutex_lock(dsession->lock); @@ -932,8 +938,9 @@ error: g_mutex_unlock(dsession->lock); - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&error)); - smlErrorDeref(&error); + smlSessionDispatchEvent(session, SML_SESSION_EVENT_ERROR, NULL, NULL, NULL, error); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, error->message); + g_error_free(error); } /** @brief Gets a already received alert @@ -974,7 +981,14 @@ * @param error A pointer to a error struct * @returns TRUE if the call was successful, FALSE otherwise */ -SmlBool smlDsSessionSendAlert(SmlDsSession *dsession, SmlAlertType type, const char *last, const char *next, SmlStatusReplyCb callback, void *userdata, SmlError **error) +gboolean +smlDsSessionSendAlert (SmlDsSession *dsession, + SmlAlertType type, + const gchar *last, + const gchar *next, + SmlStatusReplyCb callback, + void *userdata, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %s, %s, %p)", __func__, dsession, type, VA_STRING(last), VA_STRING(next), error); smlAssert(dsession); @@ -994,9 +1008,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; } @@ -1079,14 +1092,20 @@ * @param error A pointer to a error struct * @returns TRUE if the call was successful, FALSE otherwise */ -SmlBool smlDsSessionSendSync(SmlDsSession *dsession, unsigned int num_changes, SmlStatusReplyCb callback, void *userdata, SmlError **error) +gboolean +smlDsSessionSendSync (SmlDsSession *dsession, + gsize num_changes, + SmlStatusReplyCb callback, + void *userdata, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p)", __func__, dsession, num_changes, callback, userdata, error); smlAssert(dsession); CHECK_ERROR_REF if (dsession->syncCommand) { - smlErrorSet(error, SML_ERROR_GENERIC, "There already was a sync command started"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "There already was a sync command started"); goto error; } @@ -1102,31 +1121,43 @@ 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; } //Send a change to the remote side -SmlBool smlDsSessionQueueChange(SmlDsSession *dsession, SmlChangeType type, const char *uid, const char *data, unsigned int size, const char *contenttype, SmlDsSessionWriteCb callback, void *userdata, SmlError **error) +gboolean +smlDsSessionQueueChange (SmlDsSession *dsession, + SmlChangeType type, + const gchar *uid, + const gchar *data, + gsize size, + const gchar *contenttype, + SmlDsSessionWriteCb callback, + void *userdata, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %s, %p, %i, %s, %p, %p, %p)", __func__, dsession, type, VA_STRING(uid), data, size, VA_STRING(contenttype), callback, userdata, error); smlAssert(dsession); CHECK_ERROR_REF + SmlCommand *cmd = NULL; + SmlWriteContext *ctx = NULL; + if (!dsession->syncCommand) { - smlErrorSet(error, SML_ERROR_GENERIC, "You have to start a sync command first"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "You have to start a sync command first"); goto error; } - SmlCommand *cmd = smlCommandNewChange(type, uid, data, size, contenttype, error); + cmd = smlCommandNewChange(type, uid, data, size, contenttype, error); if (!cmd) goto error; - SmlWriteContext *ctx = smlTryMalloc0(sizeof(SmlWriteContext), error); + ctx = smlTryMalloc0(sizeof(SmlWriteContext), error); if (!ctx) - goto error_free_cmd; + goto error; ctx->callback = callback; ctx->userdata = userdata; @@ -1139,20 +1170,21 @@ g_mutex_unlock(dsession->pendingMapsLock); if (!smlSessionSendCommand(dsession->session, cmd, dsession->syncCommand, _change_reply, ctx, error)) - goto error_free_ctx; + goto error; + ctx = NULL; smlCommandUnref(cmd); smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - -error_free_ctx: - smlSafeCFree(&(ctx->uid)); - smlSafeFree((gpointer *)&ctx); -error_free_cmd: - smlCommandUnref(cmd); error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); + if (ctx) { + smlSafeCFree(&(ctx->uid)); + smlSafeFree((gpointer *)&ctx); + } + if (cmd) + smlCommandUnref(cmd); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, (*error)->message); return FALSE; } @@ -1162,14 +1194,17 @@ * @param error A pointer to a error struct * @returns TRUE if the call was successful, FALSE otherwise */ -SmlBool smlDsSessionCloseSync(SmlDsSession *dsession, SmlError **error) +gboolean +smlDsSessionCloseSync (SmlDsSession *dsession, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, dsession, error); smlAssert(dsession); CHECK_ERROR_REF if (!dsession->syncCommand) { - smlErrorSet(error, SML_ERROR_GENERIC, "There already was a sync command started"); + g_set_error(error, SML_ERROR, SML_ERROR_GENERIC, + "There already was a sync command started"); goto error; } @@ -1181,13 +1216,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; } -SmlBool smlDsSessionQueueMap(SmlDsSession *dsession, const char *uid, const char *newuid, SmlError **error) +gboolean +smlDsSessionQueueMap (SmlDsSession *dsession, + const gchar *uid, + const gchar *newuid, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %s, %s, %p)", __func__, dsession, VA_STRING(uid), VA_STRING(newuid), error); smlAssert(dsession); @@ -1201,9 +1239,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; } @@ -1216,7 +1253,11 @@ * @param error A pointer to a error struct * @returns TRUE if the call was successful, FALSE otherwise */ -SmlBool smlDsSessionCloseMap(SmlDsSession *dsession, SmlStatusReplyCb callback, void *userdata, SmlError **error) +gboolean +smlDsSessionCloseMap (SmlDsSession *dsession, + SmlStatusReplyCb callback, + void *userdata, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, dsession, callback, userdata, error); smlAssert(dsession); @@ -1234,28 +1275,27 @@ while (dsession->mapItems) { SmlMapItem *item = dsession->mapItems->data; if (!smlCommandAddMapItem(cmd, item, error)) - goto error_free_cmd; + goto error; smlMapItemUnref(item); dsession->mapItems = g_list_remove(dsession->mapItems, item); } if (!smlSessionSendCommand(dsession->session, cmd, NULL, callback, userdata, error)) - goto error_free_cmd; + goto error; smlCommandUnref(cmd); smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; - -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 FALSE; } -const char *smlDsSessionGetLocation(SmlDsSession *dsession) +const gchar *smlDsSessionGetLocation(SmlDsSession *dsession) { smlAssert(dsession); return smlDsServerGetLocation(dsession->server); @@ -1267,7 +1307,7 @@ return dsession->server; } -const char *smlDsSessionGetContentType(SmlDsSession *dsession) +const gchar *smlDsSessionGetContentType(SmlDsSession *dsession) { smlAssert(dsession); return smlDsServerGetContentType(dsession->server); @@ -1277,34 +1317,37 @@ { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, cmd, userdata); SmlDsServer *server = userdata; - SmlError *error = NULL; + GError *error = NULL; + /* The error is already signaled by smlDsServerRecvAlert. */ SmlDsSession *dsession = smlDsServerRecvAlert(server, session, cmd); if (!dsession) goto error; if (!smlManagerObjectRegister(server->manager, SML_COMMAND_TYPE_SYNC, session, server->location, NULL, NULL, smlDsSessionRecvSync, smlDsSessionRecvChange, dsession, &error)) - goto error_free_dsession; + goto error; if (!smlManagerObjectRegister(server->manager, SML_COMMAND_TYPE_MAP, session, server->location, NULL, NULL, smlDsSessionRecvMap, NULL, dsession, &error)) - goto error_free_dsession; + goto error; smlTrace(TRACE_EXIT, "%s", __func__); return; -error_free_dsession: - smlSafeFree((gpointer *)&dsession); error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&error)); - if (error) - smlErrorDeref(&error); + if (dsession) + smlSafeFree((gpointer *)&dsession); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, error?error->message:"NULL"); + if (error) { + smlSessionDispatchEvent(session, SML_SESSION_EVENT_ERROR, NULL, NULL, NULL, error); + g_error_free(error); + } } static void _recv_manager_san(SmlSession *session, SmlCommand *cmd, void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, session, cmd, userdata); SmlDsServer *server = userdata; - SmlError *error = NULL; + GError *error = NULL; /* ensure that the session is in client mode */ session->sessionType = SML_SESSION_TYPE_CLIENT; @@ -1330,17 +1373,6 @@ goto error; smlStatusUnref(reply); - } else if (server->sanCallback) { - SmlErrorType type = server->sanCallback(server, cmd->private.alert.type, server->sanCallbackUserdata); - - SmlStatus *reply = smlCommandNewReply(cmd, type, &error); - if (!reply) - goto error; - - if (!smlSessionSendReply(session, reply, &error)) - goto error; - - smlStatusUnref(reply); } else { smlTrace(TRACE_INTERNAL, "%s: SAN ignored", __func__); @@ -1358,12 +1390,15 @@ return; error: - smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(&error)); - if (error) - smlErrorDeref(&error); + smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, error->message); + smlSessionDispatchEvent(session, SML_SESSION_EVENT_ERROR, NULL, NULL, NULL, error); + g_error_free(error); } -SmlBool smlDsServerRegister(SmlDsServer *server, SmlManager *manager, SmlError **error) +gboolean +smlDsServerRegister (SmlDsServer *server, + SmlManager *manager, + GError **error) { smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, server, manager, error); smlAssert(server); @@ -1380,9 +1415,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/objects/sml_ds_server.h ============================================================================== --- trunk/libsyncml/objects/sml_ds_server.h Wed Jul 8 11:19:54 2009 (r1156) +++ trunk/libsyncml/objects/sml_ds_server.h Wed Jul 8 12:22:14 2009 (r1157) @@ -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 @@ -38,54 +38,49 @@ SML_DS_EVENT_COMMITEDCHANGES = 1 } SmlDsEvent; -typedef void (* SmlDsSessionConnectCb) (SmlDsSession *dsession, void *userdata); -typedef gboolean (* SmlDsSessionAlertCb) (SmlDsSession *dsession, SmlAlertType type, const char *last, const char *next, void *userdata); -typedef void (* SmlDsSessionSyncCb) (SmlDsSession *dsession, unsigned int numchanges, void *userdata); -typedef void (* SmlDsSessionEventCb) (SmlDsSession *dsession, SmlDsEvent event, void *userdata); +typedef void (* SmlDsSessionConnectCb) (SmlDsSession *dsession, void *userdata); +typedef gboolean (* SmlDsSessionAlertCb) (SmlDsSession *dsession, SmlAlertType type, const gchar *last, const gchar *next, void *userdata); +typedef void (* SmlDsSessionSyncCb) (SmlDsSession *dsession, gsize numchanges, void *userdata); +typedef void (* SmlDsSessionEventCb) (SmlDsSession *dsession, SmlDsEvent event, void *userdata); typedef gboolean (* SmlDsSessionChangesCb) (SmlDsSession *dsession, SmlChangeType type, const gchar *uid, gchar *data, gsize size, const gchar *contenttype, void *userdata, GError **error); -typedef void (* SmlDsSessionWriteCb) (SmlDsSession *dsession, SmlStatus *status, void *userdata); +typedef void (* SmlDsSessionWriteCb) (SmlDsSession *dsession, SmlStatus *status, void *userdata); -SmlDsServer *smlDsServerNew(const char *type, SmlLocation *location, GError **error); -SmlDsServer *smlDsClientNew(const char *type, SmlLocation *location, SmlLocation *target, GError **error); -SmlDsServerType smlDsServerGetServerType(SmlDsServer *server); -void smlDsServerFree(SmlDsServer *server); -gboolean smlDsServerRegister(SmlDsServer *server, SmlManager *manager, GError **error); -gboolean smlDsServerAddSan(SmlDsServer *server, SmlNotification *san, GError **error); -void smlDsServerReset(SmlDsServer *server); -void smlDsServerSetConnectCallback(SmlDsServer *server, SmlDsSessionConnectCb callback, void *userdata); -const char *smlDsServerGetLocation(SmlDsServer *server); -const char *smlDsServerGetContentType(SmlDsServer *server); -SmlDsSession *smlDsServerSendAlert(SmlDsServer *server, SmlSession *session, SmlAlertType type, const char *last, const char *next, SmlStatusReplyCb callback, void *userdata, GError **error); - -SmlDsSession *smlDsSessionNew(SmlDsServer *server, SmlSession *session, GError **error); -SmlDsSession *smlDsSessionRef(SmlDsSession *dsession); -void smlDsSessionUnref(SmlDsSession *dsession); -void smlDsSessionDispatch(SmlDsSession *dsession); -gboolean smlDsSessionCheck(SmlDsSession *dsession); -void smlDsSessionGetAlert(SmlDsSession *dsession, SmlDsSessionAlertCb callback, void *userdata); -gboolean smlDsSessionSendAlert(SmlDsSession *dsession, SmlAlertType type, const char *last, const char *next, SmlStatusReplyCb callback, void *userdata, GError **error); -void smlDsSessionGetChanges(SmlDsSession *dsession, SmlDsSessionChangesCb chgCallback, void *userdata); -void smlDsSessionGetSync(SmlDsSession *dsession, SmlDsSessionSyncCb chgCallback, void *userdata); -void smlDsSessionGetEvent(SmlDsSession *dsession, SmlDsSessionEventCb eventCallback, void *userdata); -gboolean smlDsSessionSendSync(SmlDsSession *dsession, unsigned int num_changes, SmlStatusReplyCb callback, void *userdata, GError **error); -gboolean smlDsSessionQueueChange(SmlDsSession *dsession, SmlChangeType type, const char *uid, const char *data, unsigned int size, const char *contenttype, SmlDsSessionWriteCb callback, void *userdata, GError **error); -gboolean smlDsSessionCloseSync(SmlDsSession *dsession, GError **error); -gboolean smlDsSessionQueueMap(SmlDsSession *dsession, const char *uid, const char *newuid, GError **error); -gboolean smlDsSessionCloseMap(SmlDsSession *dsession, SmlStatusReplyCb callback, void *userdata, GError **error); -const char *smlDsSessionGetLocation(SmlDsSession *dsession); -const char *smlDsSessionGetContentType(SmlDsSession *dsession); -SmlDsServer *smlDsSessionGetServer(SmlDsSession *dsession); -SmlLocation *smlDsSessionGetTarget(SmlDsSession *dsession); +SmlDsServer* smlDsServerNew (const gchar *type, SmlLocation *location, GError **error); +SmlDsServer* smlDsClientNew (const gchar *type, SmlLocation *location, SmlLocation *target, GError **error); +SmlDsServerType smlDsServerGetServerType (SmlDsServer *server); +void smlDsServerFree (SmlDsServer *server); +gboolean smlDsServerRegister (SmlDsServer *server, SmlManager *manager, GError **error); +gboolean smlDsServerAddSan (SmlDsServer *server, SmlNotification *san, GError **error); +void smlDsServerReset (SmlDsServer *server); +void smlDsServerSetConnectCallback (SmlDsServer *server, SmlDsSessionConnectCb callback, void *userdata); +const gchar* smlDsServerGetLocation (SmlDsServer *server); +const gchar* smlDsServerGetContentType (SmlDsServer *server); +SmlDsSession* smlDsServerSendAlert (SmlDsServer *server, SmlSession *session, SmlAlertType type, const gchar *last, const gchar *next, SmlStatusReplyCb callback, void *userdata, GError **error); + +SmlDsSession* smlDsSessionNew (SmlDsServer *server, SmlSession *session, GError **error); +SmlDsSession* smlDsSessionRef (SmlDsSession *dsession); +void smlDsSessionUnref (SmlDsSession *dsession); +void smlDsSessionDispatch (SmlDsSession *dsession); +gboolean smlDsSessionCheck (SmlDsSession *dsession); +void smlDsSessionGetAlert (SmlDsSession *dsession, SmlDsSessionAlertCb callback, void *userdata); +gboolean smlDsSessionSendAlert (SmlDsSession *dsession, SmlAlertType type, const gchar *last, const gchar *next, SmlStatusReplyCb callback, void *userdata, GError **error); +void smlDsSessionGetChanges (SmlDsSession *dsession, SmlDsSessionChangesCb chgCallback, void *userdata); +void smlDsSessionGetSync (SmlDsSession *dsession, SmlDsSessionSyncCb chgCallback, void *userdata); +void smlDsSessionGetEvent (SmlDsSession *dsession, SmlDsSessionEventCb eventCallback, void *userdata); +gboolean smlDsSessionSendSync (SmlDsSession *dsession, gsize num_changes, SmlStatusReplyCb callback, void *userdata, GError **error); +gboolean smlDsSessionQueueChange (SmlDsSession *dsession, SmlChangeType type, const gchar *uid, const gchar *data, gsize size, const gchar *contenttype, SmlDsSessionWriteCb callback, void *userdata, GError **error); +gboolean smlDsSessionCloseSync (SmlDsSession *dsession, GError **error); +gboolean smlDsSessionQueueMap (SmlDsSession *dsession, const gchar *uid, const gchar *newuid, GError **error); +gboolean smlDsSessionCloseMap (SmlDsSession *dsession, SmlStatusReplyCb callback, void *userdata, GError **error); +const gchar* smlDsSessionGetLocation (SmlDsSession *dsession); +const gchar* smlDsSessionGetContentType (SmlDsSession *dsession); +SmlDsServer* smlDsSessionGetServer (SmlDsSession *dsession); +SmlLocation* smlDsSessionGetTarget (SmlDsSession *dsession); /* multi session safe SAN handling */ typedef SmlErrorType (* SmlDsServerSanSessionCb) (SmlDsServer *dsserver, SmlSession *session, SmlAlertType type, void *userdata); -void smlDsServerSetSanSessionCallback(SmlDsServer *server, SmlDsServerSanSessionCb callback, void *userdata); - -/* deprecated SAN handling */ - -typedef SmlErrorType (* SmlDsServerSanCb) (SmlDsServer *dsserver, SmlAlertType type, void *userdata); -void smlDsServerSetSanCallback(SmlDsServer *server, SmlDsServerSanCb callback, void *userdata) LIBSYNCML_DEPRECATED; +void smlDsServerSetSanSessionCallback (SmlDsServer *server, SmlDsServerSanSessionCb callback, void *userdata); #endif //_SML_DS_SERVER_H_ /*@}*/ Modified: trunk/libsyncml/objects/sml_ds_server_internals.h ============================================================================== --- trunk/libsyncml/objects/sml_ds_server_internals.h Wed Jul 8 11:19:54 2009 (r1156) +++ trunk/libsyncml/objects/sml_ds_server_internals.h Wed Jul 8 12:22:14 2009 (r1157) @@ -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 @@ -34,8 +34,8 @@ typedef struct SmlWriteContext { SmlDsSessionWriteCb callback; - char *uid; - char *newuid; + gchar *uid; + gchar *newuid; SmlStatus *status; void *userdata; SmlChangeType type; @@ -72,8 +72,8 @@ GList *recvSync; GList *recvChanges; SmlErrorType syncReply; - GError finalLock; - GError emptySync; + SmlBool finalLock; + SmlBool emptySync; /** Callback that will receive the reply to the sync command */ SmlStatusReplyCb sentSyncCallback; @@ -102,7 +102,7 @@ SmlLocation *location; /** The target if the ds server is in client mode */ SmlLocation *target; - char *contenttype; + gchar *contenttype; SmlDsServerType servertype; SmlManager *manager; @@ -112,20 +112,18 @@ SmlDsServerSanSessionCb sanSessionCallback; void *sanSessionCallbackUserdata; - SmlDsServerSanCb sanCallback; - void *sanCallbackUserdata; }; -void smlDsSessionRecvAlert(SmlSession *session, SmlCommand *cmd, void *userdata); -void smlDsSessionRecvSync(SmlSession *session, SmlCommand *cmd, void *userdata); -void smlDsSessionRecvChange(SmlSession *session, SmlCommand *cmd, void *userdata); -void smlDsSessionRecvMap(SmlSession *session, SmlCommand *cmd, void *userdata); -SmlDsSession *smlDsServerRecvAlert(SmlDsServer *server, SmlSession *session, SmlCommand *cmd); +void smlDsSessionRecvAlert (SmlSession *session, SmlCommand *cmd, void *userdata); +void smlDsSessionRecvSync (SmlSession *session, SmlCommand *cmd, void *userdata); +void smlDsSessionRecvChange (SmlSession *session, SmlCommand *cmd, void *userdata); +void smlDsSessionRecvMap (SmlSession *session, SmlCommand *cmd, void *userdata); +SmlDsSession* smlDsServerRecvAlert (SmlDsServer *server, SmlSession *session, SmlCommand *cmd); -SmlDsSession *smlDsSessionNew(SmlDsServer *server, SmlSession *session, GError **error); -void smlDsSessionFree(SmlDsSession *dsession); +SmlDsSession* smlDsSessionNew (SmlDsServer *server, SmlSession *session, GError **error); +void smlDsSessionFree (SmlDsSession *dsession); -void smlDsSessionGetMapping(SmlDsSession *dsession, SmlDsSessionMapCb mapCallback, void *userdata); +void smlDsSessionGetMapping (SmlDsSession *dsession, SmlDsSessionMapCb mapCallback, void *userdata); #endif //_SML_DS_SERVER_INTERNALS_H_ /*@}*/ |