updates
authorPekka Riikonen <priikone@silcnet.org>
Wed, 10 Apr 2002 09:28:03 +0000 (09:28 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Wed, 10 Apr 2002 09:28:03 +0000 (09:28 +0000)
apps/irssi/src/silc/core/silc-servers.c
lib/silcclient/client.c
lib/silcclient/client.h
lib/silcclient/client_ftp.c
lib/silcclient/silcclient.h

index f24ba50828474763a75479740c7b2ab8de05fe34..e92ae9ba7ded428b2c93c5f863dd2a712ce199e3 100644 (file)
@@ -197,7 +197,7 @@ static void sig_connected(SILC_SERVER_REC *server)
   if (!IS_SILC_SERVER(server))
     return;
 
-  conn = silc_client_add_connection(silc_client,
+  conn = silc_client_add_connection(silc_client, NULL,
                                    server->connrec->address,
                                    server->connrec->port,
                                    server);
index 4875e8e24d09901ece369ff18c6c3231b2e0c047..c5b13236e391a85aadde434ec493ee7d1b6e8aa6 100644 (file)
@@ -186,10 +186,10 @@ static void silc_client_entry_destructor(SilcIDCache cache,
    application performed the connecting outside the library. The library
    however may use this internally. */
 
-SilcClientConnection silc_client_add_connection(SilcClient client,
-                                               char *hostname,
-                                               int port,
-                                               void *context)
+SilcClientConnection
+silc_client_add_connection(SilcClient client,
+                           SilcClientConnectionParams *params,
+                           char *hostname, int port, void *context)
 {
   SilcClientConnection conn;
   int i;
@@ -208,6 +208,13 @@ SilcClientConnection silc_client_add_connection(SilcClient client,
   conn->pending_commands = silc_dlist_init();
   conn->ftp_sessions = silc_dlist_init();
 
+  if (params) {
+    if (params->detach_data)
+      conn->params.detach_data = silc_memdup(params->detach_data,
+                                            params->detach_data_len);
+    conn->params.detach_data_len = params->detach_data_len;
+  }
+
   /* Add the connection to connections table */
   for (i = 0; i < client->internal->conns_count; i++)
     if (client->internal->conns && !client->internal->conns[i]) {
@@ -330,8 +337,9 @@ silc_client_connect_to_server_internal(SilcClientInternalConnectContext *ctx)
    case then this function is not used at all. When the connecting is
    done the `connect' client operation is called. */
 
-int silc_client_connect_to_server(SilcClient client, int port,
-                                 char *host, void *context)
+int silc_client_connect_to_server(SilcClient client,
+                                  SilcClientConnectionParams *params,
+                                  int port, char *host, void *context)
 {
   SilcClientInternalConnectContext *ctx;
   SilcClientConnection conn;
@@ -340,7 +348,7 @@ int silc_client_connect_to_server(SilcClient client, int port,
   SILC_LOG_DEBUG(("Connecting to port %d of server %s",
                  port, host));
 
-  conn = silc_client_add_connection(client, host, port, context);
+  conn = silc_client_add_connection(client, params, host, port, context);
 
   client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_AUDIT, 
                             "Connecting to port %d of server %s", port, host);
index 7868d4602e1c91ec44a6e4c70bffcc78d17e099f..2073bc5a0db7e5d09eb8f75048b647bd63b50f95 100644 (file)
@@ -135,6 +135,9 @@ struct SilcClientConnectionStruct {
      and the actual client object is accesible through this pointer. */
   SilcClient client;
 
+  /* Connection parameters */
+  SilcClientConnectionParams params;
+
   /* User data context. Library does not touch this. */
   void *context;
 };
index 6d63544d07835427e4e471142cfd540d5456a218..87a1f4c9e51b05c0f74d78b0779d550976b23e88 100644 (file)
@@ -542,7 +542,7 @@ static void silc_client_ftp_start_key_agreement(SilcClientFtpSession session,
                        NULL, session->monitor_context);
 
   /* Add new connection for this session */
-  conn = silc_client_add_connection(client, session->hostname,
+  conn = silc_client_add_connection(client, NULL, session->hostname,
                                    session->port, session);
 
   /* Allocate new socket connection object */
@@ -640,7 +640,7 @@ SILC_TASK_CALLBACK(silc_client_ftp_process_key_agreement)
                        NULL, session->monitor_context);
 
   /* Add new connection for this session */
-  conn = silc_client_add_connection(client, newsocket->hostname,
+  conn = silc_client_add_connection(client, NULL, newsocket->hostname,
                                    newsocket->port, session);
   conn->sock = newsocket;
   conn->sock->user_data = conn;
index a1f8e48b87005a187c04321e5c385df244b60697..87c3b97c84ac77a4c1486b1d595ee64681c32d54 100644 (file)
@@ -622,12 +622,38 @@ void silc_client_stop(SilcClient client);
 
 /* Connecting functions (client.c) */
 
+/****s* silcclient/SilcClientAPI/SilcClientConnectionParams
+ *
+ * NAME
+ *
+ *    typedef struct { ... } SilcClientConnectionParams;
+ *
+ * DESCRIPTION
+ *
+ *    Client connection parameters.  This can be filled by the application
+ *    and given as argument to silc_client_connect_to_server or to
+ *    silc_client_add_connection.
+ *
+ * SOURCE
+ */
+typedef struct {
+  /* The SILC session detachment data that was returned by `detach' client
+     operation when the application detached from the network.  Application
+     is responsible of saving the data and giving it as argument here
+     for resuming the session in the SILC network. */
+  unsigned char *detach_data;
+  SilcUInt32 detach_data_len;
+
+} SilcClientConnectionParams;
+/***/
+
 /****f* silcclient/SilcClientAPI/silc_client_connect_to_server
  *
  * SYNOPSIS
  *
- *    int silc_client_connect_to_server(SilcClient client, int port,
- *                                      char *host, void *context);
+ *    int silc_client_connect_to_server(SilcClient client, 
+ *                                      SilcClientConnectionParams *params,
+ *                                      int port, char *host, void *context);
  *
  * DESCRIPTION
  *
@@ -637,20 +663,24 @@ void silc_client_stop(SilcClient client);
  *    that is created after the connection is created. Note that application
  *    may handle the connecting process outside the library. If this is the
  *    case then this function is not used at all. When the connecting is
- *    done the `connect' client operation is called.
+ *    done the `connect' client operation is called, and the `context' is
+ *    accessible with conn->context, conn being SilcClientConnection.
+ *    If the `params' is provided they are used by the routine.
  *
  ***/
-int silc_client_connect_to_server(SilcClient client, int port,
-                                 char *host, void *context);
+int silc_client_connect_to_server(SilcClient client, 
+                                 SilcClientConnectionParams *params,
+                                 int port, char *host, void *context);
 
 /****f* silcclient/SilcClientAPI/silc_client_add_connection
  *
  * SYNOPSIS
  *
- *    SilcClientConnection silc_client_add_connection(SilcClient client,
- *                                                    char *hostname,
- *                                                   int port,
- *                                                   void *context);
+ *
+ *    SilcClientConnection
+ *    silc_client_add_connection(SilcClient client,
+ *                               SilcClientConnectionParams *params,
+ *                               char *hostname, int port, void *context);
  *
  * DESCRIPTION
  *
@@ -658,15 +688,21 @@ int silc_client_connect_to_server(SilcClient client, int port,
  *    connection to the connection table and returns a pointer to it. A client
  *    can have multiple connections to multiple servers. Every connection must
  *    be added to the client using this function. User data `context' may
- *    be sent as argument. This function is normally used only if the 
- *    application performed the connecting outside the library. The library
+ *    be sent as argument.  If the `params' is provided they are used by 
+ *    the routine.
+ *
+ * NOTES
+ *
+ *    This function is normally used only if the application performed 
+ *    the connecting outside the library, and did not called the
+ *    silc_client_connect_to_server function at all. The library
  *    however may use this internally.
  *
  ***/
-SilcClientConnection silc_client_add_connection(SilcClient client,
-                                               char *hostname,
-                                               int port,
-                                               void *context);
+SilcClientConnection
+silc_client_add_connection(SilcClient client,
+                          SilcClientConnectionParams *params,
+                          char *hostname, int port, void *context);
 
 /****f* silcclient/SilcClientAPI/silc_client_del_connection
  *