Fixed initialization when running callback is not given to
authorPekka Riikonen <priikone@silcnet.org>
Sun, 13 May 2007 15:28:39 +0000 (15:28 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sun, 13 May 2007 15:28:39 +0000 (15:28 +0000)
silc_client_init.

lib/silcclient/client.c
lib/silcclient/client_ops_example.c
lib/silcclient/silcclient.h

index af9954973c2fe549e5d468e73e561bd7f58aba03..ab13fd6d9fea4963b88eeeaeebb528f46c18fa38 100644 (file)
@@ -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);
index 6b6a5b889bfe2f8f8e24b7e4f4e511e2f195a947..a14ebfb00ddbf84a951af5701f170624118e1cb3 100644 (file)
@@ -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);
index 94f78481b27f0621b021ed035f66cb8bd611a880..fedeea7489abcf93b8001db5786a846fa489a5a1 100644 (file)
@@ -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,