The _CLOSED flag is called when calling silc_client_file_close.
authorPekka Riikonen <priikone@silcnet.org>
Sat, 21 Feb 2004 08:05:05 +0000 (08:05 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sat, 21 Feb 2004 08:05:05 +0000 (08:05 +0000)
Added silc_client_get_clients_whois using WHOIS command and
supporting requested attributes.

CHANGES
apps/irssi/src/silc/core/silc-servers.c
lib/silcclient/client_ftp.c
lib/silcclient/idlist.c
lib/silcclient/silcclient.h

diff --git a/CHANGES b/CHANGES
index fa7f18d328fe4e0ae4628b67e019e4b09ffd43ab..e48d7389cbd07763e536ee7c9b9cb3e025dee006 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,13 @@
+Fri Feb 20 20:37:38 EET 2004  Pekka Riikonen <priikone@silcnet.org>
+
+       * Call the monitor callback with _CLOSED status from the
+         silc_client_file_close.  Affected files are
+         lib/silcclient/client_fpt.c, silcclient.h
+
+       * Added silc_client_get_clients_whois which resolves using
+         WHOIS, and supports requested attributes as well.
+         Affected files are lib/silcclient/silcclient.h, idlist.c.
+
 Fri Feb 19 21:09:22 EET 2004  Pekka Riikonen <priikone@silcnet.org>
 
        * Added support for asking the destination filename where
index 37a0b9eb6b40ac66be6ebc251c896a74afb865d5..9d5d661b877278f1507f89524656fb9aa9c2f760 100644 (file)
@@ -597,6 +597,9 @@ static void silc_client_file_monitor(SilcClient client,
   FtpSession ftp;
   char fsize[32];
 
+  if (status == SILC_CLIENT_FILE_MONITOR_CLOSED)
+    return;
+
   snprintf(fsize, sizeof(fsize) - 1, "%llu", ((filesize + 1023) / 1024));
 
   silc_dlist_start(server->ftp_sessions);
index 4806cf622c068468214a919708623256d18d6e0f..42b987ca9a6798934960c7ebe63f964051f0e643 100644 (file)
@@ -1060,9 +1060,8 @@ SilcClientFileError silc_client_file_close(SilcClient client,
   silc_dlist_start(conn->internal->ftp_sessions);
   while ((session = silc_dlist_get(conn->internal->ftp_sessions))
         != SILC_LIST_END) {
-    if (session->session_id == session_id) {
+    if (session->session_id == session_id)
       break;
-    }
   }
 
   if (session == SILC_LIST_END) {
@@ -1070,6 +1069,13 @@ SilcClientFileError silc_client_file_close(SilcClient client,
     return SILC_CLIENT_FILE_UNKNOWN_SESSION;
   }
 
+  if (session->monitor)
+    (*session->monitor)(session->client, session->conn,
+                       SILC_CLIENT_FILE_MONITOR_CLOSED,
+                       SILC_CLIENT_FILE_OK, 0, 0,
+                       session->client_entry, session->session_id,
+                       session->filepath, session->monitor_context);
+
   silc_client_ftp_session_free(session);
 
   return SILC_CLIENT_FILE_OK;
index 00a24a2e5c443fb3871fa3972227876a0a33832c..38864297a5ab08ded2a0c9fc5dc27a1b481dcd71 100644 (file)
@@ -132,7 +132,7 @@ SILC_CLIENT_CMD_FUNC(get_client_callback)
 
   /* Get the clients */
   clients = silc_client_get_clients_local(i->client, i->conn,
-                                         i->nickname, i->server,
+                                         i->nickname, NULL,
                                          &clients_count);
   if (clients) {
     i->completion(i->client, i->conn, clients, clients_count, i->context);
@@ -155,12 +155,14 @@ SILC_CLIENT_CMD_FUNC(get_client_callback)
    get the client entry since this function may be very slow and should
    be used only to initially get the client entries. */
 
-void silc_client_get_clients(SilcClient client,
-                            SilcClientConnection conn,
-                            const char *nickname,
-                            const char *server,
-                            SilcGetClientCallback completion,
-                            void *context)
+void silc_client_get_clients_i(SilcClient client,
+                              SilcClientConnection conn,
+                              SilcCommand command,
+                              const char *nickname,
+                              const char *server,
+                              SilcBuffer attributes,
+                              SilcGetClientCallback completion,
+                              void *context)
 {
   GetClientInternal i;
   int len;
@@ -190,23 +192,57 @@ void silc_client_get_clients(SilcClient client,
   }
 
   /* Register our own command reply for this command */
-  silc_client_command_register(client, SILC_COMMAND_IDENTIFY, NULL, NULL,
-                              silc_client_command_reply_identify_i, 0,
-                              ++conn->cmd_ident);
-
-  /* Send the command */
-  silc_client_command_send(client, conn, SILC_COMMAND_IDENTIFY,
-                          conn->cmd_ident, 1, 1, userhost,
-                          strlen(userhost));
+  if (command == SILC_COMMAND_IDENTIFY) {
+    silc_client_command_register(client, command, NULL, NULL,
+                                silc_client_command_reply_identify_i, 0,
+                                ++conn->cmd_ident);
+    /* Send the command */
+    silc_client_command_send(client, conn, SILC_COMMAND_IDENTIFY,
+                            conn->cmd_ident, 1, 1, userhost,
+                            strlen(userhost));
+  } else {
+    silc_client_command_register(client, command, NULL, NULL,
+                                silc_client_command_reply_whois_i, 0,
+                                ++conn->cmd_ident);
+    /* Send the command */
+    silc_client_command_send(client, conn, command, conn->cmd_ident, 2,
+                            1, userhost, strlen(userhost),
+                            3, attributes ? attributes->data : NULL,
+                            attributes ? attributes->len : 0);
+  }
 
   /* Add pending callback */
-  silc_client_command_pending(conn, SILC_COMMAND_IDENTIFY, conn->cmd_ident,
+  silc_client_command_pending(conn, command, conn->cmd_ident,
                              silc_client_command_get_client_callback,
                              (void *)i);
-
   silc_free(userhost);
 }
 
+void silc_client_get_clients(SilcClient client,
+                            SilcClientConnection conn,
+                            const char *nickname,
+                            const char *server,
+                            SilcGetClientCallback completion,
+                            void *context)
+{
+  silc_client_get_clients_i(client, conn, SILC_COMMAND_IDENTIFY,
+                           nickname, server, NULL,
+                           completion, context);
+}
+
+void silc_client_get_clients_whois(SilcClient client,
+                                  SilcClientConnection conn,
+                                  const char *nickname,
+                                  const char *server,
+                                  SilcBuffer attributes,
+                                  SilcGetClientCallback completion,
+                                  void *context)
+{
+  silc_client_get_clients_i(client, conn, SILC_COMMAND_WHOIS,
+                           nickname, server, attributes,
+                           completion, context);
+}
+
 /* The old style function to find client entry. This is used by the
    library internally. If `query' is TRUE then the client information is
    requested by the server. The pending command callback must be set
index b02b60f93fbee4f4d612baa74ec7a96de4e3c8b5..3f337ec99c6dfd7d938e3527c3f9a6a6e62f9d92 100644 (file)
@@ -1300,6 +1300,48 @@ void silc_client_get_clients(SilcClient client,
                             SilcGetClientCallback completion,
                             void *context);
 
+/****f* silcclient/SilcClientAPI/silc_client_get_clients
+ *
+ * SYNOPSIS
+ *
+ *    void silc_client_get_clients_whois(SilcClient client,
+ *                                       SilcClientConnection conn,
+ *                                       const char *nickname,
+ *                                       const char *server,
+ *                                       SilcBuffer attributes,
+ *                                       SilcGetClientCallback completion,
+ *                                       void *context);
+ *
+ * DESCRIPTION
+ *
+ *    Finds client entry or entries by the `nickname' and `server'. The
+ *    completion callback will be called when the client entries has been
+ *    found.  After the server returns the client information it is cached
+ *    and can be accesses locally at a later time.  The resolving is done
+ *    with WHOIS command.  The `server' may be NULL.
+ *
+ *    If the `attributes' is non-NULL then the buffer includes Requested
+ *    Attributes which can be used to fetch very detailed information
+ *    about the user. If it is NULL then only normal WHOIS query is
+ *    made (for more information about attributes see SilcAttribute).
+ *    Caller may create the `attributes' with silc_client_attributes_request
+ *    function.
+ *
+ * NOTES
+ *
+ *    The resolving is done with WHOIS command. For this reason this
+ *    command may take a long time because it resolves detailed user
+ *    information.
+ *
+ ***/
+void silc_client_get_clients_whois(SilcClient client,
+                                  SilcClientConnection conn,
+                                  const char *nickname,
+                                  const char *server,
+                                  SilcBuffer attributes,
+                                  SilcGetClientCallback completion,
+                                  void *context);
+
 /****f* silcclient/SilcClientAPI/silc_client_get_clients_local
  *
  * SYNOPSIS
@@ -2618,7 +2660,10 @@ silc_client_file_receive(SilcClient client,
  *    If file transmission is being conducted it will be aborted
  *    automatically. This function is also used to close the session
  *    after successful file transmission. This function can be used
- *    also to reject incoming file transmission request.
+ *    also to reject incoming file transmission request.  If the
+ *    session was already started and the monitor callback was set
+ *    the monitor callback will be called with the monitor status
+ *    SILC_CLIENT_FILE_MONITOR_CLOSED.
  *
  ***/
 SilcClientFileError silc_client_file_close(SilcClient client,