updates.
authorPekka Riikonen <priikone@silcnet.org>
Thu, 25 Oct 2001 20:12:41 +0000 (20:12 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Thu, 25 Oct 2001 20:12:41 +0000 (20:12 +0000)
CHANGES
apps/irssi/src/silc/core/client_ops.c
apps/irssi/src/silc/core/silc-channels.c
apps/irssi/src/silc/core/silc-servers.c
lib/silcclient/client_notify.c
lib/silcclient/command_reply.c
lib/silcclient/silcapi.h

diff --git a/CHANGES b/CHANGES
index f7dbcb28fcc5ad10867c42f990c921a68be276fb..5379d3f6c4c8701da1c4249ab7520abc52d90b4c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,22 @@
+Thu Oct 25 22:44:06 EDT 2001  Pekka Riikonen <priikone@silcnet.org>
+
+       * Assure that silc_client_notify_by_server_resolve does not
+         resolve the client information multiple times.  If it cannot
+         be found by the first it cannot be found at all.  Affected
+         file lib/silcclient/client_notify.c.
+
+       * Fixed WHOWAS command reply calling.  Affected file
+         lib/silcclient/command_reply.c.
+
+       * Removed all references to silc_idlist_get_client from the
+         Irssi SILC client since that call is internal call used by
+         the library.  The Irssi SILC client will use now client
+         retrieval functions found in silcapi.h.
+
+       * Fixed a bug in resolving nickname info before sending
+         private message.  It used freed memory.  Affected file
+         irssi/src/silc/core/silc-servers.c.
+
 Thu Oct 25 19:04:49 EDT 2001  Pekka Riikonen <priikone@silcnet.org>
 
        * Assure my_channels statistics cannot go negative in server.
index 9923412e9886245399afe12f7fb6fdb8e9be9bab..59ecd37246bfcd0655885d7702456c23df1aa5c5 100644 (file)
@@ -413,8 +413,6 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
        if (tmp)
          silc_say_error("%s: %s", tmp, 
                         silc_client_command_status_message(status));
-       else
-         silc_say_error("%s", silc_client_command_status_message(status));
        break;
       }
       
@@ -503,8 +501,6 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
        if (tmp)
          silc_say_error("%s: %s", tmp, 
                         silc_client_command_status_message(status));
-       else
-         silc_say_error("%s", silc_client_command_status_message(status));
        break;
       }
       
index 3bdc9cc780ce1debcab8175469cd8629f7e35fd0..499b0cfe0cd157964786328b3f99bb956aefcc25 100644 (file)
@@ -815,18 +815,35 @@ static void keyagr_completion(SilcClient client,
 typedef struct {
   SILC_SERVER_REC *server;
   char *data;
+  char *nick;
   WI_ITEM_REC *item;
 } *KeyGetClients;
 
 /* Callback to be called after client information is resolved from the
    server. */
 
-SILC_CLIENT_CMD_FUNC(key_get_clients)
+static void silc_client_command_key_get_clients(SilcClient client,
+                                               SilcClientConnection conn,
+                                               SilcClientEntry *clients,
+                                               uint32 clients_count,
+                                               void *context)
 {
   KeyGetClients internal = (KeyGetClients)context;
+
+  if (!clients) {
+    printtext(NULL, NULL, MSGLEVEL_CLIENTERROR, "Unknown nick: %s", 
+             internal->nick);
+    silc_free(internal->data);
+    silc_free(internal->nick);
+    silc_free(internal);
+    return;
+  }
+
   signal_emit("command key", 3, internal->data, internal->server,
              internal->item);
+
   silc_free(internal->data);
+  silc_free(internal->nick);
   silc_free(internal);
 }
 
@@ -834,7 +851,8 @@ static void command_key(const char *data, SILC_SERVER_REC *server,
                        WI_ITEM_REC *item)
 {
   SilcClientConnection conn;
-  SilcClientEntry client_entry = NULL;
+  SilcClientEntry *entrys, client_entry = NULL;
+  uint32 entry_count;
   SilcChannelEntry channel_entry = NULL;
   char *nickname = NULL, *tmp;
   int command = 0, port = 0, type = 0;
@@ -878,22 +896,20 @@ static void command_key(const char *data, SILC_SERVER_REC *server,
       }
       
       /* Find client entry */
-      client_entry = silc_idlist_get_client(silc_client, conn, nickname, 
-                                           argv[2], TRUE);
-      if (!client_entry) {
+      entrys = silc_client_get_clients_local(silc_client, conn, nickname,
+                                            argv[2], &entry_count);
+      if (!entrys) {
        KeyGetClients inter = silc_calloc(1, sizeof(*inter));
        inter->server = server;
        inter->data = strdup(data);
+       inter->nick = strdup(nickname);
        inter->item = item;
-
-       /* Client entry not found, it was requested thus mark this to be
-          pending command. */
-       silc_client_command_pending(conn, SILC_COMMAND_IDENTIFY, 
-                                   conn->cmd_ident, 
-                                   NULL, silc_client_command_key_get_clients, 
-                                   inter);
+       silc_client_get_clients(silc_client, conn, nickname, argv[2],
+                               silc_client_command_key_get_clients, inter);
        goto out;
       }
+      client_entry = entrys[0];
+      silc_free(entrys);
     }
   }
 
index 6fccc11b924e3643d5c154924dc3e61e3b7c9b85..e20a2d4b0ebd15765c2e33a3404fc3897f5f30b1 100644 (file)
@@ -129,8 +129,6 @@ static void silc_send_msg(SILC_SERVER_REC *server, char *nick, char *msg)
   /* Find client entry */
   clients = silc_client_get_clients_local(silc_client, server->conn, 
                                          nickname, nick, &clients_count);
-  silc_free(nickname);
-
   if (!clients) {
     rec = g_new0(PRIVMSG_REC, 1);
     rec->nick = g_strdup(nick);
@@ -140,10 +138,12 @@ static void silc_send_msg(SILC_SERVER_REC *server, char *nick, char *msg)
     /* Could not find client with that nick, resolve it from server. */
     silc_client_get_clients(silc_client, server->conn,
                            nickname, NULL, silc_send_msg_clients, rec);
+    silc_free(nickname);
     return;
   }
 
   /* Send the private message directly */
+  silc_free(nickname);
   silc_client_send_private_message(silc_client, server->conn, 
                                   clients[0], 0, msg, strlen(msg), TRUE);
 }
@@ -485,15 +485,32 @@ static void silc_client_file_monitor(SilcClient client,
 typedef struct {
   SILC_SERVER_REC *server;
   char *data;
+  char *nick;
   WI_ITEM_REC *item;
 } *FileGetClients;
 
-SILC_CLIENT_CMD_FUNC(file_get_clients)
+static void silc_client_command_file_get_clients(SilcClient client,
+                                                SilcClientConnection conn,
+                                                SilcClientEntry *clients,
+                                                uint32 clients_count,
+                                                void *context)
 {
   FileGetClients internal = (FileGetClients)context;
+
+  if (!clients) {
+    printtext(NULL, NULL, MSGLEVEL_CLIENTERROR, "Unknown nick: %s", 
+             internal->nick);
+    silc_free(internal->data);
+    silc_free(internal->nick);
+    silc_free(internal);
+    return;
+  }
+
   signal_emit("command file", 3, internal->data, internal->server,
              internal->item);
+
   silc_free(internal->data);
+  silc_free(internal->nick);
   silc_free(internal);
 }
 
@@ -501,7 +518,8 @@ static void command_file(const char *data, SILC_SERVER_REC *server,
                         WI_ITEM_REC *item)
 {
   SilcClientConnection conn;
-  SilcClientEntry client_entry;
+  SilcClientEntry *entrys, client_entry;
+  uint32 entry_count;
   char *nickname = NULL, *tmp;
   unsigned char **argv;
   uint32 argc;
@@ -548,22 +566,20 @@ static void command_file(const char *data, SILC_SERVER_REC *server,
     }
     
     /* Find client entry */
-    client_entry = silc_idlist_get_client(silc_client, conn, nickname, 
-                                         argv[3], TRUE);
-    if (!client_entry) {
+    entrys = silc_client_get_clients_local(silc_client, conn, nickname,
+                                          argv[3], &entry_count);
+    if (!entrys) {
       FileGetClients inter = silc_calloc(1, sizeof(*inter));
       inter->server = server;
       inter->data = strdup(data);
+      inter->nick = strdup(nickname);
       inter->item = item;
-      
-      /* Client entry not found, it was requested thus mark this to be
-        pending command. */
-      silc_client_command_pending(conn, SILC_COMMAND_IDENTIFY, 
-                                 conn->cmd_ident, 
-                                 NULL, silc_client_command_file_get_clients, 
-                                 inter);
+      silc_client_get_clients(silc_client, conn, nickname, argv[3],
+                             silc_client_command_file_get_clients, inter);
       goto out;
     }
+    client_entry = entrys[0];
+    silc_free(entrys);
 
     silc_client_file_send(silc_client, conn, silc_client_file_monitor, 
                          server, client_entry, argv[2]);
@@ -591,23 +607,20 @@ static void command_file(const char *data, SILC_SERVER_REC *server,
       }
     
       /* Find client entry */
-      client_entry = silc_idlist_get_client(silc_client, conn, nickname, 
-                                           argv[2], TRUE);
-      if (!client_entry) {
+      entrys = silc_client_get_clients_local(silc_client, conn, nickname,
+                                            argv[2], &entry_count);
+      if (!entrys) {
        FileGetClients inter = silc_calloc(1, sizeof(*inter));
        inter->server = server;
        inter->data = strdup(data);
+       inter->nick = strdup(nickname);
        inter->item = item;
-      
-       /* Client entry not found, it was requested thus mark this to be
-          pending command. */
-       silc_client_command_pending(conn, SILC_COMMAND_IDENTIFY, 
-                                   conn->cmd_ident, 
-                                   NULL, 
-                                   silc_client_command_file_get_clients, 
-                                   inter);
+       silc_client_get_clients(silc_client, conn, nickname, argv[2],
+                               silc_client_command_file_get_clients, inter);
        goto out;
       }
+      client_entry = entrys[0];
+      silc_free(entrys);
     } else {
       if (!server->current_session) {
        printformat_module("fe-common/silc", server, NULL,
@@ -658,30 +671,27 @@ static void command_file(const char *data, SILC_SERVER_REC *server,
       }
     
       /* Find client entry */
-      client_entry = silc_idlist_get_client(silc_client, conn, nickname, 
-                                           argv[2], TRUE);
-      if (!client_entry) {
+      entrys = silc_client_get_clients_local(silc_client, conn, nickname,
+                                            argv[2], &entry_count);
+      if (!entrys) {
        FileGetClients inter = silc_calloc(1, sizeof(*inter));
        inter->server = server;
        inter->data = strdup(data);
+       inter->nick = strdup(nickname);
        inter->item = item;
-      
-       /* Client entry not found, it was requested thus mark this to be
-          pending command. */
-       silc_client_command_pending(conn, SILC_COMMAND_IDENTIFY, 
-                                   conn->cmd_ident, 
-                                   NULL, 
-                                   silc_client_command_file_get_clients, 
-                                   inter);
+       silc_client_get_clients(silc_client, conn, nickname, argv[2],
+                               silc_client_command_file_get_clients, inter);
        goto out;
       }
+      client_entry = entrys[0];
+      silc_free(entrys);
     } else {
       if (!server->current_session) {
        printformat_module("fe-common/silc", server, NULL,
                           MSGLEVEL_CRAP, SILCTXT_FILE_NA);
        goto out;
       }
-
       if (!silc_client_file_close(silc_client, conn, 
                                  server->current_session->session_id))
        printformat_module("fe-common/silc", server, NULL,
index 85b4530de9055b15e9a866b27173924de4b26990..5b508e5c3e6938645aefbd020e5f520b9d9879a4 100644 (file)
@@ -38,6 +38,19 @@ typedef struct {
 static void silc_client_notify_by_server_pending(void *context, void *context2)
 {
   SilcClientNotifyResolve res = (SilcClientNotifyResolve)context;
+  SilcClientCommandReplyContext reply = 
+    (SilcClientCommandReplyContext)context2;
+
+  if (reply) {
+    SilcCommandStatus status;
+    unsigned char *tmp = silc_argument_get_arg_type(reply->args, 1, NULL);
+    SILC_GET16_MSB(status, tmp);
+    if (status != SILC_STATUS_OK) {
+      silc_socket_free(res->sock);
+      return;
+    }
+  }
+
   silc_client_notify_by_server(res->context, res->sock, res->packet);
   silc_socket_free(res->sock);
 }
index 01fe350cfd1a0a386b1ff6d12f676a96ed1171c2..e6a778690a7d84683012b96fcf41eb9063d49a6b 100644 (file)
@@ -389,8 +389,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(whowas)
   }
 
  out:
-  SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_WHOIS);
-  SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_WHOIS);
+  SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_WHOWAS);
+  SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_WHOWAS);
   silc_client_command_reply_free(cmd);
 }
 
index e7d7b9cc25355e491e33f5053c5d803d25df0495..7ee729e2cd218459d12f6f5bdba31581dd56e156 100644 (file)
@@ -843,7 +843,8 @@ void silc_client_get_clients(SilcClient client,
  *    is the formatted nickname to find exact match from multiple found
  *    entries. The format must be same as given in the SilcClientParams
  *    structure to the client library. If the `format' is NULL all found
- *    clients by `nickname' are returned.
+ *    clients by `nickname' are returned. The caller must return the
+ *    returned array.
  *
  ***/
 SilcClientEntry *silc_client_get_clients_local(SilcClient client,