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 */ |