Changeset 512

Show
Ignore:
Timestamp:
07/25/08 15:43:24 (4 months ago)
Author:
bellmich
Message:

no transport should call smlTransportRunAsync by itself

- fixed http client transport (by removing init function)
- a transport implementation can have an init function

(it is no longer a requirement)

- added more explicit error messages to the test code
- added a warning to smlManager because I think that context

duplication is a bug (introduced by myself)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libsyncml/sml_manager.c

    r500 r512  
    342342                // if the context is already set 
    343343                // then the transport is already running in asynchronous mode 
     344                g_warning("Manager context is used by transport context."); 
    344345                tsp->context = manager->context; 
    345346                g_main_context_ref(tsp->context); 
  • trunk/libsyncml/sml_transport.c

    r491 r512  
    188188                goto error; 
    189189        } 
     190        if (tsp->context != NULL) { 
     191                smlErrorSet(error, SML_ERROR_GENERIC, "Transport is already in asynchronous mode!"); 
     192                goto error; 
     193        } 
     194 
     195        g_type_init(); 
    190196 
    191197        tsp->context = g_main_context_new(); 
     
    552558        if (tsp->context) 
    553559                g_main_context_unref(tsp->context); 
     560        tsp->context = NULL; 
    554561         
    555562        smlSafeFree((gpointer *)&tsp); 
     
    661668        smlAssertMsg(*error == NULL, SML_ASSERT_MSG_ERROR_MUST_BE_EMPTY); 
    662669        smlAssert(tsp); 
    663         smlAssert(tsp->functions.initialize); 
    664670        smlAssert(tsp->state == SML_TRANSPORT_UNINITIALIZED); 
    665671         
     
    668674        smlQueueAttach(tsp->command_queue, tsp->context); 
    669675         
    670         if (!tsp->functions.initialize(tsp, error)) 
     676        if (tsp->functions.initialize && !tsp->functions.initialize(tsp, error)) 
    671677                goto error_detach; 
    672678         
  • trunk/libsyncml/transports/http_client.c

    r509 r512  
    296296} 
    297297 
    298 /** 
    299  * @defgroup GroupID Group Description 
    300  * @ingroup ParentGroupID 
    301  * @brief What does this group do? 
    302  *  
    303  */ 
    304 /*@{*/ 
    305  
    306 static SmlBool smlTransportHttpClientInit(SmlTransport *tsp, SmlError **error) 
    307 { 
    308         smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, tsp, error); 
    309         smlAssertMsg(error, SML_ASSERT_MSG_ERROR_MUST_NOT_BE_NULL); 
    310         smlAssertMsg(*error == NULL, SML_ASSERT_MSG_ERROR_MUST_BE_EMPTY); 
    311         smlAssert(tsp); 
    312         smlAssert(tsp->transport_data); 
    313         SmlTransportHttpClientEnv *env = tsp->transport_data;    
    314          
    315         g_type_init(); 
    316  
    317         smlTransportRunAsync(tsp, error); 
    318  
    319         smlTrace(TRACE_EXIT, "%s: %p", __func__, env); 
    320         return TRUE; 
    321 } 
    322  
    323298static SmlBool smlTransportHttpClientSetResponseURI( 
    324299                SmlTransport *tsp, 
     
    497472 
    498473        tsp->functions.set_config_option = smlTransportHttpClientSetConfigOption; 
    499         tsp->functions.initialize = smlTransportHttpClientInit; 
    500474        tsp->functions.set_response_uri = smlTransportHttpClientSetResponseURI; 
    501475        tsp->functions.disconnect = smlTransportHttpClientDisconnect; 
  • trunk/tests/check_http.c

    r511 r512  
    5151        fail_unless(smlTransportSetConfigOption(tsp, "URL", "http://libsyncml.opensyncml.org", &error), NULL); 
    5252 
    53         fail_unless(smlTransportInitialize(tsp, &error), NULL); 
    54         fail_unless(error == NULL, NULL); 
     53        fail_unless(smlTransportInitialize(tsp, &error), smlErrorPrint(&error)); 
     54        fail_unless(error == NULL, smlErrorPrint(&error)); 
    5555         
    5656        fail_unless(smlTransportFinalize(tsp, &error), NULL); 
     
    101101 
    102102        /* The transport is not configured but libsoup can initialize a default client */ 
    103         fail_unless(smlTransportInitialize(tsp, &error), NULL); 
    104         fail_unless(error == NULL, NULL); 
     103        fail_unless(smlTransportInitialize(tsp, &error), smlErrorPrint(&error)); 
     104        fail_unless(error == NULL, smlErrorPrint(&error)); 
    105105 
    106106        smlTransportFree(tsp); 
     
    136136        fail_unless(error == NULL, NULL); 
    137137 
    138         fail_unless(smlTransportInitialize(tsp, &error), NULL); 
    139         fail_unless(error == NULL, NULL); 
     138        fail_unless(smlTransportInitialize(tsp, &error), smlErrorPrint(&error)); 
     139        fail_unless(error == NULL, smlErrorPrint(&error)); 
    140140         
    141141        fail_unless(smlTransportFinalize(tsp, &error), NULL); 
     
    164164 
    165165        /* The default config of libsoup can be used to setup a valid transport. */ 
    166         fail_unless(smlTransportInitialize(tsp, &error), NULL); 
    167         fail_unless(error == NULL, NULL); 
     166        fail_unless(smlTransportInitialize(tsp, &error), smlErrorPrint(&error)); 
     167        fail_unless(error == NULL, smlErrorPrint(&error)); 
    168168         
    169169        smlTransportFree(tsp); 
     
    286286        smlTransportSetEventCallback(client, _recv_client_event, GINT_TO_POINTER(1)); 
    287287 
    288         fail_unless(smlTransportInitialize(client, &error), NULL); 
    289         fail_unless(smlTransportInitialize(server, &error), NULL); 
     288        fail_unless(smlTransportInitialize(client, &error), smlErrorPrint(&error)); 
     289        fail_unless(smlTransportInitialize(server, &error), smlErrorPrint(&error)); 
    290290 
    291291        fail_unless(smlTransportConnect(client, &error), NULL); 
     
    336336        smlTransportSetEventCallback(client, _recv_client_event, GINT_TO_POINTER(1)); 
    337337         
    338         fail_unless(smlTransportInitialize(client, &error), NULL); 
    339         fail_unless(smlTransportInitialize(server, &error), NULL); 
     338        fail_unless(smlTransportInitialize(client, &error), smlErrorPrint(&error)); 
     339        fail_unless(smlTransportInitialize(server, &error), smlErrorPrint(&error)); 
    340340 
    341341        SmlTransportData *data = smlTransportDataNew("test", 5, SML_MIMETYPE_XML, FALSE, &error); 
     
    389389        smlTransportSetEventCallback(client, _recv_client_event, GINT_TO_POINTER(1)); 
    390390 
    391         fail_unless(smlTransportInitialize(client, &error), NULL); 
    392         fail_unless(smlTransportInitialize(server, &error), NULL); 
     391        fail_unless(smlTransportInitialize(client, &error), smlErrorPrint(&error)); 
     392        fail_unless(smlTransportInitialize(server, &error), smlErrorPrint(&error)); 
    393393 
    394394        SmlTransportData *data = smlTransportDataNew("test", 5, SML_MIMETYPE_XML, FALSE, &error); 
     
    445445        smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(1)); 
    446446 
    447         fail_unless(smlTransportInitialize(client, &error), NULL); 
    448         fail_unless(smlTransportInitialize(server, &error), NULL); 
     447        fail_unless(smlTransportInitialize(client, &error), smlErrorPrint(&error)); 
     448        fail_unless(smlTransportInitialize(server, &error), smlErrorPrint(&error)); 
    449449 
    450450        SmlTransportData *data = smlTransportDataNew("test", 5, SML_MIMETYPE_XML, FALSE, &error); 
     
    504504        smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(1)); 
    505505 
    506         fail_unless(smlTransportInitialize(client, &error), NULL); 
    507         fail_unless(smlTransportInitialize(server, &error), NULL); 
     506        fail_unless(smlTransportInitialize(client, &error), smlErrorPrint(&error)); 
     507        fail_unless(smlTransportInitialize(server, &error), smlErrorPrint(&error)); 
    508508 
    509509        SmlTransportData *data = NULL; 
     
    562562        smlTransportSetEventCallback(client, _recv_client_event, GINT_TO_POINTER(1)); 
    563563 
    564         fail_unless(smlTransportInitialize(client, &error), NULL); 
     564        fail_unless(smlTransportInitialize(client, &error), smlErrorPrint(&error)); 
    565565 
    566566        SmlTransportData *data = smlTransportDataNew("test", 5, SML_MIMETYPE_XML, FALSE, &error); 
     
    615615        smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(2)); 
    616616 
    617         fail_unless(smlTransportInitialize(client, &error), NULL); 
    618         fail_unless(smlTransportInitialize(server, &error), NULL); 
     617        fail_unless(smlTransportInitialize(client, &error), smlErrorPrint(&error)); 
     618        fail_unless(smlTransportInitialize(server, &error), smlErrorPrint(&error)); 
    619619 
    620620        SmlTransportData *data = smlTransportDataNew("test", 5, SML_MIMETYPE_XML, FALSE, &error); 
     
    864864        smlTransportSetEventCallback(server, _recv_server_event, GINT_TO_POINTER(1)); 
    865865 
    866         fail_unless(smlTransportInitialize(client1, &error), NULL); 
    867         fail_unless(smlTransportInitialize(client2, &error), NULL); 
    868         fail_unless(smlTransportInitialize(client3, &error), NULL); 
    869         fail_unless(smlTransportInitialize(server, &error), NULL); 
     866        fail_unless(smlTransportInitialize(client1, &error), smlErrorPrint(&error)); 
     867        fail_unless(smlTransportInitialize(client2, &error), smlErrorPrint(&error)); 
     868        fail_unless(smlTransportInitialize(client3, &error), smlErrorPrint(&error)); 
     869        fail_unless(smlTransportInitialize(server, &error), smlErrorPrint(&error)); 
    870870 
    871871        SmlTransportData *data = NULL;