updates.
authorPekka Riikonen <priikone@silcnet.org>
Mon, 2 Apr 2001 17:20:37 +0000 (17:20 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Mon, 2 Apr 2001 17:20:37 +0000 (17:20 +0000)
CHANGES
apps/silc/client_ops.c
lib/silcclient/command.c

diff --git a/CHANGES b/CHANGES
index 8fb8dedef55806d9c36f370d435edbf597fa4621..14b5f3fadad8b703486156b77aa53e318a3a2ced 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+Mon Apr  2 20:02:33 EEST 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Moved the USERS printing from the library to the application.
+         Affected files lib/silcclient/command.c and silc/client_ops.c.
+
 Mon Apr  2 13:13:23 EEST 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
 
        * Updated TODO.
index 3165b7d86a57afcfc3c8ea2bdc39eb245f01c623..074cdfe2f296c92168ab90e2f22e062b73b00c3d 100644 (file)
@@ -764,19 +764,88 @@ void silc_command_reply(SilcClient client, SilcClientConnection conn,
       break;
 
     case SILC_COMMAND_USERS:
-      if (!success)
-       return;
+      {
+       SilcChannelEntry channel;
+       int line_len;
+       char *line;
+       
+       if (!success)
+         return;
 
-      silc_list_start(conn->current_channel->clients);
-      while ((chu = silc_list_get(conn->current_channel->clients)) 
-            != SILC_LIST_END) {
-       if (chu->client == conn->local_entry) {
-         if (app->screen->bottom_line->mode)
-           silc_free(app->screen->bottom_line->mode);
-         app->screen->bottom_line->mode = silc_client_chumode_char(chu->mode);
-         silc_screen_print_bottom_line(app->screen, 0);
-         break;
+       channel = va_arg(vp, SilcChannelEntry);
+
+       /* There are two ways to do this, either parse the list (that
+          the command_reply sends (just take it with va_arg())) or just
+          traverse the channel'c client list.  I'll do the latter.  See
+          JOIN command reply for example for the list. */
+
+       silc_say(client, conn, "Users on %s", channel->channel_name);
+       
+       line = silc_calloc(1024, sizeof(*line));
+       line_len = 1024;
+       silc_list_start(channel->clients);
+       while ((chu = silc_list_get(channel->clients)) != SILC_LIST_END) {
+         SilcClientEntry e = chu->client;
+         int i, len1;
+         char *m, tmp[80];
+
+         memset(line, 0, line_len);
+
+         if (chu->client == conn->local_entry) {
+           /* Update status line */
+           if (app->screen->bottom_line->mode)
+             silc_free(app->screen->bottom_line->mode);
+           app->screen->bottom_line->mode = 
+             silc_client_chumode_char(chu->mode);
+           silc_screen_print_bottom_line(app->screen, 0);
+         }
+
+         if (strlen(e->nickname) + strlen(e->server) + 100 > line_len) {
+           silc_free(line);
+           line_len += strlen(e->nickname) + strlen(e->server) + 100;
+           line = silc_calloc(line_len, sizeof(*line));
+         }
+
+         memset(tmp, 0, sizeof(tmp));
+         m = silc_client_chumode_char(chu->mode);
+
+         strncat(line, " ", 1);
+         strncat(line, e->nickname, strlen(e->nickname));
+         strncat(line, e->server ? "@" : "", 1);
+         
+         len1 = 0;
+         if (e->server)
+           len1 = strlen(e->server);
+         strncat(line, e->server ? e->server : "", len1 > 30 ? 30 : len1);
+         
+         len1 = strlen(line);
+         if (len1 >= 30) {
+           memset(&line[29], 0, len1 - 29);
+         } else {
+           for (i = 0; i < 30 - len1 - 1; i++)
+             strcat(line, " ");
+         }
+         
+         if (e->mode & SILC_UMODE_GONE)
+           strcat(line, "  G");
+         else
+           strcat(line, "  H");
+         strcat(tmp, m ? m : "");
+         strncat(line, tmp, strlen(tmp));
+         
+         if (strlen(tmp) < 5)
+           for (i = 0; i < 5 - strlen(tmp); i++)
+             strcat(line, " ");
+         
+         strcat(line, e->username ? e->username : "");
+         
+         silc_say(client, conn, "%s", line);
+         
+         if (m)
+           silc_free(m);
        }
+       
+       silc_free(line);
       }
       break;
 
index a97cdc0d951780c4d16f73c2c2464a6373bc59f6..3a3e8d1490de584dd6d224873d4edcd9e7bc46fa 100644 (file)
@@ -1927,8 +1927,7 @@ SILC_CLIENT_CMD_FUNC(users)
   SilcIDCacheEntry id_cache = NULL;
   SilcChannelEntry channel;
   SilcBuffer buffer, idp;
-  char *name, *line = NULL;
-  unsigned int line_len = 0;
+  char *name;
 
   if (!cmd->conn) {
     SILC_NOT_CONNECTED(cmd->client, cmd->conn);
@@ -1993,73 +1992,6 @@ SILC_CLIENT_CMD_FUNC(users)
     return;
   }
 
-  if (cmd->pending) {
-    /* Pending command. Now we've resolved the information from server and
-       we are ready to display the information on screen. */
-    int i;
-    SilcChannelUser chu;
-
-    cmd->client->ops->say(cmd->client, conn, "Users on %s", 
-                         channel->channel_name);
-
-    line = silc_calloc(4096, sizeof(*line));
-    line_len = 4096;
-    silc_list_start(channel->clients);
-    while ((chu = silc_list_get(channel->clients)) != SILC_LIST_END) {
-      SilcClientEntry e = chu->client;
-      char *m, tmp[80], len1;
-
-      memset(line, 0, sizeof(line_len));
-
-      if (strlen(e->nickname) + strlen(e->server) + 100 > line_len) {
-       silc_free(line);
-       line_len += strlen(e->nickname) + strlen(e->server) + 100;
-       line = silc_calloc(line_len, sizeof(*line));
-      }
-
-      memset(tmp, 0, sizeof(tmp));
-      m = silc_client_chumode_char(chu->mode);
-
-      strncat(line, " ", 1);
-      strncat(line, e->nickname, strlen(e->nickname));
-      strncat(line, e->server ? "@" : "", 1);
-
-      len1 = 0;
-      if (e->server)
-       len1 = strlen(e->server);
-      strncat(line, e->server ? e->server : "", len1 > 30 ? 30 : len1);
-
-      len1 = strlen(line);
-      if (len1 >= 30) {
-       memset(&line[29], 0, len1 - 29);
-      } else {
-       for (i = 0; i < 30 - len1 - 1; i++)
-         strcat(line, " ");
-      }
-
-      if (e->mode & SILC_UMODE_GONE)
-       strcat(line, "  G");
-      else
-       strcat(line, "  H");
-      strcat(tmp, m ? m : "");
-      strncat(line, tmp, strlen(tmp));
-
-      if (strlen(tmp) < 5)
-       for (i = 0; i < 5 - strlen(tmp); i++)
-         strcat(line, " ");
-
-      strcat(line, e->username ? e->username : "");
-
-      cmd->client->ops->say(cmd->client, conn, "%s", line);
-
-      if (m)
-       silc_free(m);
-    }
-  }
-
-  if (line)
-    silc_free(line);
-
   /* Notify application */
   COMMAND;