that SILC specific message hilighting, colors etc is possible.
Affected file irssi/src/fe-common/silc/module-formats.[ch].
+ Added channel mode, channel user mode, actions, notices,
+ whois and whowas printing to the the module-formats.c.
+
+ * Fixed a bug in channel deletion in the server. The channel
+ is not left to the cache even if the channel founder auth mode
+ is set when there are no users anymore on the channel. Affected
+ file silcd/server.c.
+
+ * The silc_net_localhost now resolves the entire hostname including
+ the domain name. Affected file lib/silcutil/silcnet.c.
+
Sat May 26 12:13:37 EEST 2001 Pekka Riikonen <priikone@poseidon.pspt.fi>
* Changed the ask_passphrase client operation to be ascynchronous.
# reason for something is printed (part, quit, kick, ..)
reason = "{comment $0-}";
- # mode change is printed ([+o nick])
- mode = "{comment $0-}";
+ # mode change is printed
+ mode = "[$0-]";
##
## channel specific messages
# ban/ban exception/invite list mask is printed
ban = "$0-";
+ ##
+ ## Action (/ME command)
+ ##
+
+ # Generic action
+ action = "%Y* $0-";
+
+ # Own sent action
+ ownaction = "%c* $0-";
+
+ ##
+ ## Notice (/NOTICE command)
+ ##
+
+ # Generic notice
+ notice = "%C- $0-";
+
+ # Own sent notice
+ ownnotice = "%g- $0";
+
+
##
## messages
##
# private message in query
privmsgnick = "{msgnick $0-%n}";
- ##
- ## Actions (/ME stuff)
- ##
-
- # used internally by this theme
- action_core = "%Y* $0-";
-
- # generic one that's used by most actions
- action = "{action_core $0-} ";
-
- # own action, both private/public
- ownaction = "{action $0-}";
-
- # own action with target, both private/public
- ownaction_target = "{action_core $0}{msgchannel $1} ";
-
- # private action sent by others
- pvtaction = " (*) $0- ";
- pvtaction_query = "{action $0-}";
-
- # public action sent by others
- pubaction = "{action $0-}";
-
##
## other IRC events
##
- # notices
- ownnotice = "-%c$1-%n- ";
- notice = "-%C$0-%n- ";
- pubnotice_channel = "{msgchannel $0}";
- pvtnotice_host = "";
- servernotice = "{notice $0-}";
-
# CTCPs
ownctcp = "[$0$1-] ";
ctcp = "$0-";
netjoin = "%C$0-%n";
# /names list
- names_nick = "%n%_$0%_$1- | ";
- names_users = "($0-)";
+ names_nick = "[ %n%_$0%_$1- ] ";
+ names_users = "$0-";
names_channel = "{channel $0-}";
# DCC
FORMAT_REC fecommon_silc_formats[] = {
{ MODULE_NAME, "SILC", 0 },
- /* ---- */
+ /* Channel related messages */
{ NULL, "Channel", 0 },
{ "channel_founder_you", "You are channel founder on {channel $0}", 1, { 0 } },
- { "channel_founder", "Channel founder on {channel $0} is: {channick_hilight $1}", 2, { 0, 0 } },
+ { "channel_founder", "channel founder on {channel $0} is: {channick_hilight $1}", 2, { 0, 0 } },
{ "channel_topic", "Topic for {channel $0} is: $1", 2, { 0, 0 } },
+ { "cmode", "channel mode/{channel $0} {mode $1} by {nick $2}", 3, { 0, 0, 0 } },
+ { "cumode", "channel user mode/{channel $0}/{nick $1} {mode $2} by {nick $3}", 4, { 0, 0, 0, 0 } },
+ { "action", "{action $0}", 1, { 0 } },
+ { "notice", "{notice $0}", 1, { 0 } },
+ { "ownaction", "{ownaction $0}", 1, { 0 } },
+ { "ownnotice", "{ownnotice $0}", 1, { 0 } },
+
+ /* WHOIS and WHOWAS messages */
+ { NULL, "Who Queries", 0 },
+
+ { "whois", "{nick $0} {nickhost $1}%: realname : $2", 3, { 0, 0, 0 } },
+ { "whois_channels", " channels : $0", 1, { 0 } },
+ { "whois_modes", " modes : $0", 1, { 0 } },
+ { "whois_idle", " idle : $0", 1, { 0 } },
+ { "whowas", "{nick $0} was {nickhost $1} ($2)", 3, { 0, 0, 0 } },
{ NULL, NULL, 0 }
};
+
SILCTXT_CHANNEL_FOUNDER_YOU,
SILCTXT_CHANNEL_FOUNDER,
SILCTXT_CHANNEL_TOPIC,
+ SILCTXT_CHANNEL_CMODE,
+ SILCTXT_CHANNEL_CUMODE,
+ SILCTXT_CHANNEL_ACTION,
+ SILCTXT_CHANNEL_NOTICE,
+ SILCTXT_CHANNEL_OWNACTION,
+ SILCTXT_CHANNEL_OWNNOTICE,
+
+ SILCTXT_FILL_2,
+
+ SILCTXT_WHOIS_USERINFO,
+ SILCTXT_WHOIS_CHANNELS,
+ SILCTXT_WHOIS_MODES,
+ SILCTXT_WHOIS_IDLE,
+ SILCTXT_WHOWAS_USERINFO,
};
extern FORMAT_REC fecommon_silc_formats[];
#include "window-item-def.h"
#include "fe-common/core/printtext.h"
+#include "fe-common/silc/module-formats.h"
SILC_CHANNEL_REC *silc_channel_create(SILC_SERVER_REC *server,
const char *name, int automatic)
client = va_arg(va, SilcClientEntry);
modei = va_arg(va, uint32);
+ (void)va_arg(va, char *);
+ (void)va_arg(va, char *);
channel = va_arg(va, SilcChannelEntry);
+
mode = silc_client_chmode(modei, channel);
chanrec = silc_channel_find_entry(server, channel);
signal_emit("channel mode changed", 1, chanrec);
}
- printtext(server, channel->channel_name, MSGLEVEL_MODES,
- "cmode/%s [%s] by %s", channel->channel_name, mode,
- client->nickname);
+ printformat_module("fe-common/silc", server, channel->channel_name,
+ MSGLEVEL_MODES, SILCTXT_CHANNEL_CMODE,
+ channel->channel_name, mode ? mode : "removed all",
+ client->nickname);
g_free(mode);
}
chanrec->chanop =
(mode & SILC_CHANNEL_UMODE_CHANOP) != 0;
}
-
+
nick = silc_nicklist_find(chanrec, destclient);
if (nick != NULL) {
nick->op = (mode & SILC_CHANNEL_UMODE_CHANOP) != 0;
}
}
- printtext(server, channel->channel_name, MSGLEVEL_MODES,
- "cumode/%s/%s [%s] by %s", destclient->nickname,
- channel->channel_name, modestr, client->nickname);
-
+ printformat_module("fe-common/silc", server, channel->channel_name,
+ MSGLEVEL_MODES, SILCTXT_CHANNEL_CUMODE,
+ channel->channel_name, destclient->nickname,
+ modestr ? modestr : "removed all",
+ client->nickname);
+
+ if (mode & SILC_CHANNEL_UMODE_CHANFO)
+ printformat_module("fe-common/silc",
+ server, channel->channel_name, MSGLEVEL_CRAP,
+ SILCTXT_CHANNEL_FOUNDER,
+ channel->channel_name, destclient->nickname);
+
g_free(modestr);
}
SILC_MESSAGE_FLAG_ACTION,
argv[1], argv_lens[1], TRUE);
+ printformat_module("fe-common/silc", server, chanrec->entry->channel_name,
+ MSGLEVEL_ACTIONS, SILCTXT_CHANNEL_OWNACTION, argv[1]);
+
for (i = 0; i < argc; i++)
silc_free(argv[i]);
silc_free(argv_lens);
SILC_MESSAGE_FLAG_NOTICE,
argv[1], argv_lens[1], TRUE);
+ printformat_module("fe-common/silc", server, chanrec->entry->channel_name,
+ MSGLEVEL_NOTICES, SILCTXT_CHANNEL_OWNNOTICE, argv[1]);
+
for (i = 0; i < argc; i++)
silc_free(argv[i]);
silc_free(argv_lens);
silc_free(argv_types);
}
+/* AWAY local command. Sends UMODE command that sets the SILC_UMODE_GONE
+ flag. */
+
+static void command_away(const char *data, SILC_SERVER_REC *server,
+ WI_ITEM_REC *item)
+{
+ if (!IS_SILC_SERVER(server) || !server->connected)
+ cmd_return_error(CMDERR_NOT_CONNECTED);
+
+ /* XXX TODO */
+}
+
void silc_channels_init(void)
{
signal_add("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
command_bind("part", MODULE_NAME, (SIGNAL_FUNC) command_part);
command_bind("me", MODULE_NAME, (SIGNAL_FUNC) command_me);
command_bind("notice", MODULE_NAME, (SIGNAL_FUNC) command_notice);
-
+ command_bind("away", MODULE_NAME, (SIGNAL_FUNC) command_away);
+
silc_nicklist_init();
}
command_unbind("part", (SIGNAL_FUNC) command_part);
command_unbind("me", (SIGNAL_FUNC) command_me);
command_unbind("notice", (SIGNAL_FUNC) command_notice);
-
+ command_unbind("away", (SIGNAL_FUNC) command_away);
+
silc_nicklist_deinit();
}
nick = silc_nicklist_find(chanrec, sender);
if (flags & SILC_MESSAGE_FLAG_ACTION)
- ;
+ printformat_module("fe-common/silc", server, channel->channel_name,
+ MSGLEVEL_ACTIONS, SILCTXT_CHANNEL_ACTION, msg);
else if (flags & SILC_MESSAGE_FLAG_NOTICE)
- ;
+ printformat_module("fe-common/silc", server, channel->channel_name,
+ MSGLEVEL_NOTICES, SILCTXT_CHANNEL_NOTICE, msg);
else
signal_emit("message public", 6, server, msg,
nick == NULL ? "[<unknown>]" : nick->nick,
case SILC_COMMAND_WHOIS:
{
char buf[1024], *nickname, *username, *realname;
- int len;
uint32 idle, mode;
SilcBuffer channels;
- /* XXX should use irssi routines */
-
if (status == SILC_STATUS_ERR_NO_SUCH_NICK ||
status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
char *tmp;
tmp = silc_argument_get_arg_type(silc_command_get_args(cmd_payload),
3, NULL);
if (tmp)
- client->ops->say(client, conn, "%s: %s", tmp,
- silc_client_command_status_message(status));
+ silc_say_error("%s: %s", tmp,
+ silc_client_command_status_message(status));
else
- client->ops->say(client, conn, "%s",
- silc_client_command_status_message(status));
+ silc_say_error("%s", silc_client_command_status_message(status));
break;
}
mode = va_arg(vp, uint32);
idle = va_arg(vp, uint32);
- memset(buf, 0, sizeof(buf));
-
- if (nickname) {
- len = strlen(nickname);
- strncat(buf, nickname, len);
- strncat(buf, " is ", 4);
- }
-
- if (username) {
- strncat(buf, username, strlen(username));
- }
-
- if (realname) {
- strncat(buf, " (", 2);
- strncat(buf, realname, strlen(realname));
- strncat(buf, ")", 1);
- }
-
- client->ops->say(client, conn, "%s", buf);
-
+ printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP,
+ SILCTXT_WHOIS_USERINFO, nickname, username,
+ realname);
+
if (channels) {
SilcDList list = silc_channel_payload_parse_list(channels);
if (list) {
SilcChannelPayload entry;
-
memset(buf, 0, sizeof(buf));
- strcat(buf, "on channels: ");
-
silc_dlist_start(list);
while ((entry = silc_dlist_get(list)) != SILC_LIST_END) {
char *m = silc_client_chumode_char(silc_channel_get_mode(entry));
silc_free(m);
}
- client->ops->say(client, conn, "%s", buf);
+ printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP,
+ SILCTXT_WHOIS_CHANNELS, buf);
silc_channel_payload_list_free(list);
}
}
if (mode) {
+ memset(buf, 0, sizeof(buf));
+
if ((mode & SILC_UMODE_SERVER_OPERATOR) ||
- (mode & SILC_UMODE_ROUTER_OPERATOR))
- client->ops->say(client, conn, "%s is %s", nickname,
- (mode & SILC_UMODE_SERVER_OPERATOR) ?
- "Server Operator" :
- (mode & SILC_UMODE_ROUTER_OPERATOR) ?
- "SILC Operator" : "[Unknown mode]");
-
+ (mode & SILC_UMODE_ROUTER_OPERATOR)) {
+ strcat(buf, (mode & SILC_UMODE_SERVER_OPERATOR) ?
+ "Server Operator " :
+ (mode & SILC_UMODE_ROUTER_OPERATOR) ?
+ "SILC Operator " : "[Unknown mode] ");
+ }
if (mode & SILC_UMODE_GONE)
- client->ops->say(client, conn, "%s is gone", nickname);
+ strcat(buf, "away");
+
+ printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP,
+ SILCTXT_WHOIS_MODES, buf);
}
- if (idle && nickname)
- client->ops->say(client, conn, "%s has been idle %d %s",
- nickname,
- idle > 60 ? (idle / 60) : idle,
- idle > 60 ? "minutes" : "seconds");
+ if (idle && nickname) {
+ memset(buf, 0, sizeof(buf));
+ snprintf(buf, sizeof(buf) - 1, "%lu %s",
+ idle > 60 ? (idle / 60) : idle,
+ idle > 60 ? "minutes" : "seconds");
+
+ printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP,
+ SILCTXT_WHOIS_IDLE, buf);
+ }
}
break;
case SILC_COMMAND_WHOWAS:
{
- char buf[1024], *nickname, *username, *realname;
- int len;
-
- /* XXX should use irssi routines */
+ char *nickname, *username, *realname;
if (status == SILC_STATUS_ERR_NO_SUCH_NICK ||
status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
tmp = silc_argument_get_arg_type(silc_command_get_args(cmd_payload),
3, NULL);
if (tmp)
- client->ops->say(client, conn, "%s: %s", tmp,
- silc_client_command_status_message(status));
+ silc_say_error("%s: %s", tmp,
+ silc_client_command_status_message(status));
else
- client->ops->say(client, conn, "%s",
- silc_client_command_status_message(status));
+ silc_say_error("%s", silc_client_command_status_message(status));
break;
}
username = va_arg(vp, char *);
realname = va_arg(vp, char *);
- memset(buf, 0, sizeof(buf));
-
- if (nickname) {
- len = strlen(nickname);
- strncat(buf, nickname, len);
- strncat(buf, " was ", 5);
- }
-
- if (username) {
- strncat(buf, username, strlen(nickname));
- }
-
- if (realname) {
- strncat(buf, " (", 2);
- strncat(buf, realname, strlen(realname));
- strncat(buf, ")", 1);
- }
-
- client->ops->say(client, conn, "%s", buf);
+ printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP,
+ SILCTXT_WHOWAS_USERINFO, nickname, username,
+ realname ? realname : "");
}
break;
break;
case SILC_COMMAND_OPER:
-#if 0
- if (status == SILC_STATUS_OK) {
- conn->local_entry->mode |= SILC_UMODE_SERVER_OPERATOR;
- if (app->screen->bottom_line->umode)
- silc_free(app->screen->bottom_line->umode);
- app->screen->bottom_line->umode = strdup("Server Operator");;
- silc_screen_print_bottom_line(app->screen, 0);
- }
-#endif
+ silc_say(client, conn, "You are now server operator");
break;
case SILC_COMMAND_SILCOPER:
-#if 0
- if (status == SILC_STATUS_OK) {
- conn->local_entry->mode |= SILC_UMODE_ROUTER_OPERATOR;
- if (app->screen->bottom_line->umode)
- silc_free(app->screen->bottom_line->umode);
- app->screen->bottom_line->umode = strdup("SILC Operator");;
- silc_screen_print_bottom_line(app->screen, 0);
- }
-#endif
+ silc_say(client, conn, "You are now SILC operator");
break;
case SILC_COMMAND_USERS:
channel = va_arg(vp, SilcChannelEntry);
topic = va_arg(vp, char *);
- /* XXX should use irssi routines */
-
- if (topic)
- silc_say(client, conn,
- "Topic on channel %s: %s", channel->channel_name,
- topic);
+ if (topic) {
+ chanrec = silc_channel_find_entry(server, channel);
+ if (chanrec) {
+ g_free_not_null(chanrec->topic);
+ chanrec->topic = *topic == '\0' ? NULL : g_strdup(topic);
+ signal_emit("channel topic changed", 1, chanrec);
+ }
+ printformat_module("fe-common/silc", server, channel->channel_name,
+ MSGLEVEL_CRAP, SILCTXT_CHANNEL_TOPIC,
+ channel->channel_name, topic);
+ }
}
break;
}
/* Remove channel if there is no users anymore */
if (server->server_type == SILC_ROUTER &&
silc_hash_table_count(channel->user_list) < 2) {
-
if (channel->rekey)
silc_task_unregister_by_context(server->timeout_queue, channel->rekey);
-
- if (channel->founder_key) {
- /* The founder auth data exists, do not remove the channel entry */
- SilcChannelClientEntry chl2;
- SilcHashTableList htl2;
-
- channel->id = NULL;
-
- silc_hash_table_list(channel->user_list, &htl2);
- while (silc_hash_table_get(&htl2, NULL, (void *)&chl2)) {
- silc_hash_table_del(chl2->client->channels, channel);
- silc_hash_table_del(channel->user_list, chl2->client);
- silc_free(chl2);
- }
- continue;
- }
-
- /* Remove the channel entry */
if (!silc_idlist_del_channel(server->local_list, channel))
silc_idlist_del_channel(server->global_list, channel);
server->stat.my_channels--;
NULL, key, newhmac);
if (!entry) {
silc_free(channel_name);
+ silc_cipher_free(key);
+ silc_hmac_free(newhmac);
return NULL;
}
char *silc_net_localhost()
{
char hostname[256];
- if (!gethostname(hostname, sizeof(hostname)))
+ struct hostent *dest;
+
+ if (gethostname(hostname, sizeof(hostname)))
+ return NULL;
+
+ dest = gethostbyname(hostname);
+ if (!dest)
return strdup(hostname);
- return NULL;
+
+ return strdup(dest->h_name);
}