From: Pekka Riikonen Date: Fri, 8 Mar 2002 15:46:29 +0000 (+0000) Subject: Fixed the USERS & JOIN command replys, added silc-expandos.c to X-Git-Tag: silc.client.0.8.1~9 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=adaae2377e6a015f05b3b88fc4fb04ecbb33323e Fixed the USERS & JOIN command replys, added silc-expandos.c to update stuff on statusbar. --- diff --git a/CHANGES b/CHANGES index 78b61345..d4ebaed5 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,15 @@ +Fri Mar 8 17:16:41 EET 2002 Pekka Riikonen + + * Fixed the USERS command reply to save the user's mode on the + channel as well. Fixed JOIN command reply to check whether a + client is on channel already and not join it twice. Affected + file lib/silcclient/command_reply.c. + + * Added new file silc-expandos.c into irssi/silc/core/ to return + various stuff for various signal for the statusbar etc. updating. + Now Irssi SILC client prints channel user modes etc. on the + statusbar. + Thu Mar 7 19:21:22 EET 2002 Pekka Riikonen * Changed silc_mutex_[un]lock calls in lib/silcutil/silcschedule.c diff --git a/TODO b/TODO index bea85c68..a2361fbc 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,6 @@ TODO/bugs in Irssi SILC client ============================== - o /USERS does not show the user modes on the channel correctly. - o Fix the silc_channels_join to parse the command like, with fe. silc_parse_command_line, because currently it ignores all options, including passphrase which makes autojoin impossible to +a channels. diff --git a/apps/irssi/src/silc/core/Makefile.am b/apps/irssi/src/silc/core/Makefile.am index c33f9484..68ce72f5 100644 --- a/apps/irssi/src/silc/core/Makefile.am +++ b/apps/irssi/src/silc/core/Makefile.am @@ -21,6 +21,7 @@ libsilc_core_a_SOURCES = \ silc-nicklist.c \ silc-queries.c \ silc-servers.c \ + silc-expandos.c \ silc-servers-reconnect.c noinst_HEADERS = \ diff --git a/apps/irssi/src/silc/core/client_ops.c b/apps/irssi/src/silc/core/client_ops.c index 6d8e905b..e3a31a5a 100644 --- a/apps/irssi/src/silc/core/client_ops.c +++ b/apps/irssi/src/silc/core/client_ops.c @@ -397,12 +397,12 @@ void silc_notify(SilcClient client, SilcClientConnection conn, mode = va_arg(va, SilcUInt32); client_entry2 = va_arg(va, SilcClientEntry); channel = va_arg(va, SilcChannelEntry); - + tmp = silc_client_chumode(mode); chanrec = silc_channel_find_entry(server, channel); if (chanrec != NULL) { SILC_NICK_REC *nick; - + if (client_entry2 == server->conn->local_entry) chanrec->chanop = (mode & SILC_CHANNEL_UMODE_CHANOP) != 0; @@ -413,7 +413,7 @@ void silc_notify(SilcClient client, SilcClientConnection conn, signal_emit("nick mode changed", 2, chanrec, nick); } } - + printformat_module("fe-common/silc", server, channel->channel_name, MSGLEVEL_MODES, SILCTXT_CHANNEL_CUMODE, channel->channel_name, client_entry2->nickname, @@ -425,7 +425,7 @@ void silc_notify(SilcClient client, SilcClientConnection conn, server, channel->channel_name, MSGLEVEL_CRAP, SILCTXT_CHANNEL_FOUNDER, channel->channel_name, client_entry2->nickname); - + silc_free(tmp); break; diff --git a/apps/irssi/src/silc/core/silc-core.c b/apps/irssi/src/silc/core/silc-core.c index d51c943a..8ddbe364 100644 --- a/apps/irssi/src/silc/core/silc-core.c +++ b/apps/irssi/src/silc/core/silc-core.c @@ -56,6 +56,9 @@ SilcSimContext **sims = NULL; SilcUInt32 sims_count = 0; #endif +void silc_expandos_init(void); +void silc_expandos_deinit(void); + static int my_silc_scheduler(void) { silc_client_run_one(silc_client); @@ -242,7 +245,7 @@ void silc_opt_callback(poptContext con, silc_pkcs_register_default(); silc_hash_register_default(); silc_hmac_register_default(); - silc_client_show_key(arg); + silc_client_show_key((char *)arg); exit(0); } @@ -422,6 +425,7 @@ void silc_core_init(void) silc_server_init(); silc_channels_init(); silc_queries_init(); + silc_expandos_init(); idletag = g_timeout_add(5, (GSourceFunc) my_silc_scheduler, NULL); @@ -439,6 +443,7 @@ void silc_core_deinit(void) silc_server_deinit(); silc_channels_deinit(); silc_queries_deinit(); + silc_expandos_deinit(); chat_protocol_unregister("SILC"); diff --git a/apps/irssi/src/silc/core/silc-expandos.c b/apps/irssi/src/silc/core/silc-expandos.c new file mode 100644 index 00000000..2f176266 --- /dev/null +++ b/apps/irssi/src/silc/core/silc-expandos.c @@ -0,0 +1,81 @@ +/* + + silc-expandos.c + + Author: Pekka Riikonen + + Copyright (C) 2002 Pekka Riikonen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + +*/ + +#include "module.h" +#include "misc.h" +#include "expandos.h" +#include "settings.h" + +#include "chatnets.h" +#include "servers-setup.h" +#include "channels-setup.h" +#include "silc-servers.h" +#include "silc-channels.h" +#include "silc-queries.h" +#include "silc-nicklist.h" + +/* User mode in active server */ + +static char *expando_usermode(SERVER_REC *server, void *item, int *free_ret) +{ + return ""; +} + +/* Expands to your usermode on channel */ + +static char *expando_cumode(SERVER_REC *server, void *item, int *free_ret) +{ + if (IS_CHANNEL(item) && CHANNEL(item)->ownnick) { + SILC_NICK_REC *nick = (SILC_NICK_REC *)CHANNEL(item)->ownnick; + return (nick->op && nick->founder) ? "*@" : + nick->op ? "@" : nick->founder ? "*" : ""; + } + + return ""; +} + +static char *expando_cumode_space(SERVER_REC *server, void *item, + int *free_ret) +{ + char *ret = expando_cumode(server, item, free_ret); + return *ret == '\0' ? " " : ret; +} + +void silc_expandos_init(void) +{ + expando_create("usermode", expando_usermode, + "window changed", EXPANDO_ARG_NONE, + "window server changed", EXPANDO_ARG_WINDOW, + "user mode changed", EXPANDO_ARG_SERVER, NULL); + expando_create("cumode", expando_cumode, + "window changed", EXPANDO_ARG_NONE, + "window item changed", EXPANDO_ARG_WINDOW, + "nick mode changed", EXPANDO_ARG_WINDOW_ITEM, NULL); + expando_create("cumode_space", expando_cumode_space, + "window changed", EXPANDO_ARG_NONE, + "window item changed", EXPANDO_ARG_WINDOW, + "nick mode changed", EXPANDO_ARG_WINDOW_ITEM, NULL); +} + +void silc_expandos_deinit(void) +{ + expando_destroy("usermode", expando_usermode); + expando_destroy("cumode", expando_cumode); + expando_destroy("cumode_space", expando_cumode_space); +} diff --git a/lib/silcclient/command_reply.c b/lib/silcclient/command_reply.c index fba3147b..279489a0 100644 --- a/lib/silcclient/command_reply.c +++ b/lib/silcclient/command_reply.c @@ -1061,12 +1061,14 @@ SILC_CLIENT_CMD_REPLY_FUNC(join) } /* Join client to the channel */ - chu = silc_calloc(1, sizeof(*chu)); - chu->client = client_entry; - chu->channel = channel; - chu->mode = mode; - silc_hash_table_add(channel->user_list, client_entry, chu); - silc_hash_table_add(client_entry->channels, channel, chu); + if (!silc_client_on_channel(channel, client_entry)) { + chu = silc_calloc(1, sizeof(*chu)); + chu->client = client_entry; + chu->channel = channel; + chu->mode = mode; + silc_hash_table_add(channel->user_list, client_entry, chu); + silc_hash_table_add(client_entry->channels, channel, chu); + } silc_free(client_id); silc_buffer_pull(client_id_list, idp_len); @@ -1714,6 +1716,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(users) if (!silc_client_on_channel(channel, client_entry)) { chu = silc_calloc(1, sizeof(*chu)); chu->client = client_entry; + chu->mode = mode; chu->channel = channel; silc_hash_table_add(channel->user_list, client_entry, chu); silc_hash_table_add(client_entry->channels, channel, chu);