From bb8673d141d95f7b3f8fbd623fef0872baf32cd1 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Mon, 2 Apr 2001 17:20:37 +0000 Subject: [PATCH] updates. --- CHANGES | 5 +++ apps/silc/client_ops.c | 91 +++++++++++++++++++++++++++++++++++----- lib/silcclient/command.c | 70 +------------------------------ 3 files changed, 86 insertions(+), 80 deletions(-) diff --git a/CHANGES b/CHANGES index 8fb8dede..14b5f3fa 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +Mon Apr 2 20:02:33 EEST 2001 Pekka Riikonen + + * 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 * Updated TODO. diff --git a/apps/silc/client_ops.c b/apps/silc/client_ops.c index 3165b7d8..074cdfe2 100644 --- a/apps/silc/client_ops.c +++ b/apps/silc/client_ops.c @@ -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; diff --git a/lib/silcclient/command.c b/lib/silcclient/command.c index a97cdc0d..3a3e8d14 100644 --- a/lib/silcclient/command.c +++ b/lib/silcclient/command.c @@ -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; -- 2.24.0