Fixed the USERS & JOIN command replys, added silc-expandos.c to
authorPekka Riikonen <priikone@silcnet.org>
Fri, 8 Mar 2002 15:46:29 +0000 (15:46 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Fri, 8 Mar 2002 15:46:29 +0000 (15:46 +0000)
update stuff on statusbar.

CHANGES
TODO
apps/irssi/src/silc/core/Makefile.am
apps/irssi/src/silc/core/client_ops.c
apps/irssi/src/silc/core/silc-core.c
apps/irssi/src/silc/core/silc-expandos.c [new file with mode: 0644]
lib/silcclient/command_reply.c

diff --git a/CHANGES b/CHANGES
index 78b6134540fc6263f4ecdd88a347c05ecc72741d..d4ebaed5ab003c536903e3feff8bd314bc71db02 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,15 @@
+Fri Mar  8 17:16:41 EET 2002  Pekka Riikonen <priikone@silcnet.org>
+
+       * 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 <priikone@silcnet.org>
 
        * Changed silc_mutex_[un]lock calls in lib/silcutil/silcschedule.c
diff --git a/TODO b/TODO
index bea85c6865f60f7ecebff161ab6ee3b52e6d1dc3..a2361fbc0aa759e52b5b06b4cc1fc01895c0b57d 100644 (file)
--- 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.
index c33f948425112a28dbfacad9d526dd900017d4ad..68ce72f533e5fcf980fb1fcebeb3abfc180eb27d 100644 (file)
@@ -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 = \
index 6d8e905bb4ee7b5359bfe2af424f1e618fbff608..e3a31a5a6e8a006d1149111eea8a0f872a0c6517 100644 (file)
@@ -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;
 
index d51c943aa665fe84410bedd4e9fc4bbcda6a89b8..8ddbe364f85a2bc890293b1deb75dff5fa8e898e 100644 (file)
@@ -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 (file)
index 0000000..2f17626
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+
+  silc-expandos.c 
+
+  Author: Pekka Riikonen <priikone@silcnet.org>
+
+  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);
+}
index fba3147b535dcdaef6c34867a48a76327b90f49f..279489a05ebbe553609957fef6046143119652f3 100644 (file)
@@ -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);