From: Pekka Riikonen Date: Sun, 13 May 2007 15:28:39 +0000 (+0000) Subject: Fixed initialization when running callback is not given to X-Git-Tag: silc.client.1.1.beta3~14 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=a941ec8ead786afebe3b15796330bbba3386887f Fixed initialization when running callback is not given to silc_client_init. --- diff --git a/lib/silcclient/client.c b/lib/silcclient/client.c index af995497..ab13fd6d 100644 --- a/lib/silcclient/client.c +++ b/lib/silcclient/client.c @@ -515,11 +515,13 @@ SILC_FSM_STATE(silc_client_st_run) /* Process events */ - if (client->internal->run_callback && client->internal->running) { + if (client->internal->run_callback) { /* Call running callbcak back to application */ - SILC_LOG_DEBUG(("We are up, call running callback")); client->internal->run_callback = FALSE; - client->internal->running(client, client->internal->running_context); + if (client->internal->running) { + SILC_LOG_DEBUG(("We are up, call running callback")); + client->internal->running(client, client->internal->running_context); + } return SILC_FSM_CONTINUE; } @@ -770,6 +772,12 @@ silc_client_connect_to_server(SilcClient client, if (!client || !remote_host) return NULL; + if (client->internal->run_callback) { + SILC_LOG_ERROR(("Client library is not started yet. SilcClientRunning " + "callback has not been called yet.")); + return NULL; + } + /* Add new connection */ conn = silc_client_add_connection(client, SILC_CONN_SERVER, TRUE, params, public_key, private_key, remote_host, @@ -807,6 +815,12 @@ silc_client_connect_to_client(SilcClient client, if (!client || !remote_host) return NULL; + if (client->internal->run_callback) { + SILC_LOG_ERROR(("Client library is not started yet. SilcClientRunning " + "callback has not been called yet.")); + return NULL; + } + if (params) params->no_authentication = TRUE; @@ -846,6 +860,12 @@ silc_client_key_exchange(SilcClient client, if (!client || !stream) return NULL; + if (client->internal->run_callback) { + SILC_LOG_ERROR(("Client library is not started yet. SilcClientRunning " + "callback has not been called yet.")); + return NULL; + } + if (!silc_socket_stream_get_info(stream, NULL, &host, NULL, &port)) { SILC_LOG_ERROR(("Socket stream does not have remote host name set")); callback(client, NULL, SILC_CLIENT_CONN_ERROR, 0, NULL, context); diff --git a/lib/silcclient/client_ops_example.c b/lib/silcclient/client_ops_example.c index 6b6a5b88..a14ebfb0 100644 --- a/lib/silcclient/client_ops_example.c +++ b/lib/silcclient/client_ops_example.c @@ -86,7 +86,9 @@ void silc_command(SilcClient client, SilcClientConnection conn, arguments are same as received from the server except for ID's. If ID is received application receives the corresponding entry to the ID. For example, if Client ID is receives application receives - SilcClientEntry. */ + SilcClientEntry. + + See: http://silcnet.org/docs/toolkit/command_reply_args.html */ void silc_command_reply(SilcClient client, SilcClientConnection conn, SilcCommand command, SilcStatus status, SilcStatus error, va_list ap); diff --git a/lib/silcclient/silcclient.h b/lib/silcclient/silcclient.h index 94f78481..fedeea74 100644 --- a/lib/silcclient/silcclient.h +++ b/lib/silcclient/silcclient.h @@ -757,7 +757,7 @@ void silc_client_free(SilcClient client); * The `running' callback with `context' is called after the client is * running after silc_client_run or silc_client_run_one has been called. * Application may start using the Client library API after that. Setting - * the callback is optional, but recommended. + * the callback is optional, but highly recommended. * ***/ SilcBool silc_client_init(SilcClient client, const char *username,