multiprotocol updates. SILC prints channel and private messages now

using the same message formats as IRC.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@699 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2000-09-30 22:49:48 +00:00 committed by cras
commit 2b8580c8a7
46 changed files with 667 additions and 687 deletions

View file

@ -24,13 +24,10 @@ libfe_common_irc_a_SOURCES = \
fe-netsplit.c \
fe-common-irc.c \
irc-completion.c \
irc-window-activity.c \
irc-hilight-text.c \
irc-modules.c \
module-formats.c
noinst_HEADERS = \
fe-common-irc.h \
irc-hilight-text.h \
module.h \
module-formats.h

View file

@ -67,12 +67,6 @@ void fe_netsplit_deinit(void);
void fe_netjoin_init(void);
void fe_netjoin_deinit(void);
void irc_hilight_text_init(void);
void irc_hilight_text_deinit(void);
void irc_window_activity_init(void);
void irc_window_activity_deinit(void);
static char *autocon_server;
static char *autocon_password;
static int autocon_port;
@ -102,7 +96,6 @@ void fe_common_irc_init(void)
settings_add_bool("lookandfeel", "show_away_once", TRUE);
settings_add_bool("lookandfeel", "show_quit_once", FALSE);
settings_add_bool("lookandfeel", "print_active_channel", FALSE);
theme_register(fecommon_irc_formats);
@ -117,8 +110,6 @@ void fe_common_irc_init(void)
fe_netsplit_init();
fe_netjoin_init();
irc_completion_init();
irc_hilight_text_init();
irc_window_activity_init();
fe_irc_modules_init();
}
@ -138,8 +129,6 @@ void fe_common_irc_deinit(void)
fe_netsplit_deinit();
fe_netjoin_deinit();
irc_completion_deinit();
irc_hilight_text_deinit();
irc_window_activity_deinit();
theme_unregister();
}

View file

@ -35,7 +35,6 @@
#include "fe-queries.h"
#include "irc-channels.h"
#include "irc-nicklist.h"
#include "irc-hilight-text.h"
#include "windows.h"
#include "completion.h"
@ -43,62 +42,8 @@
#define target_level(target) \
(ischannel((target)[0]) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS)
static void print_channel_msg(IRC_SERVER_REC *server, const char *msg,
const char *nick, const char *addr,
const char *target)
{
IRC_CHANNEL_REC *chanrec;
NICK_REC *nickrec;
const char *nickmode;
int for_me, print_channel, level;
char *color;
chanrec = irc_channel_find(server, target);
for_me = irc_nick_match(server->nick, msg);
color = for_me ? NULL : irc_hilight_find_nick(target, nick, addr, MSGLEVEL_PUBLIC, msg);
nickrec = chanrec == NULL ? NULL :
nicklist_find(CHANNEL(chanrec), nick);
nickmode = (!settings_get_bool("show_nickmode") || nickrec == NULL) ? "" :
(nickrec->op ? "@" : nickrec->voice ? "+" : " ");
print_channel = !window_item_is_active((WI_ITEM_REC *) chanrec);
if (!print_channel && settings_get_bool("print_active_channel") &&
window_item_window((WI_ITEM_REC *) chanrec)->items->next != NULL)
print_channel = TRUE;
level = MSGLEVEL_PUBLIC |
(color != NULL ? MSGLEVEL_HILIGHT :
(for_me ? MSGLEVEL_HILIGHT : MSGLEVEL_NOHILIGHT));
if (!print_channel) {
/* message to active channel in window */
if (color != NULL) {
/* highlighted nick */
printformat(server, target, level, IRCTXT_PUBMSG_HILIGHT,
color, nick, msg, nickmode);
} else {
printformat(server, target, level,
for_me ? IRCTXT_PUBMSG_ME : IRCTXT_PUBMSG, nick, msg, nickmode);
}
} else {
/* message to not existing/active channel */
if (color != NULL) {
/* highlighted nick */
printformat(server, target, level, IRCTXT_PUBMSG_HILIGHT_CHANNEL,
color, nick, target, msg, nickmode);
} else {
printformat(server, target, level,
for_me ? IRCTXT_PUBMSG_ME_CHANNEL : IRCTXT_PUBMSG_CHANNEL,
nick, target, msg, nickmode);
}
}
g_free_not_null(color);
}
static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char *nick, const char *addr)
{
QUERY_REC *query;
char *params, *target, *msg;
g_return_if_fail(data != NULL);
@ -108,15 +53,9 @@ static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char *
if (addr == NULL) addr = "";
if (!ignore_check(server, nick, addr, target, msg, target_level(target))) {
if (ischannel(*target)) {
/* message to channel */
print_channel_msg(server, msg, nick, addr, target);
} else {
/* private message */
query = privmsg_get_query(SERVER(server), nick, FALSE, MSGLEVEL_MSGS);
printformat(server, nick, MSGLEVEL_MSGS,
query == NULL ? IRCTXT_MSG_PRIVATE : IRCTXT_MSG_PRIVATE_QUERY, nick, addr, msg);
}
signal_emit(ischannel(*target) ?
"message public" : "message private", 5,
server, msg, nick, addr, target);
}
g_free(params);

View file

@ -37,96 +37,6 @@
#include "windows.h"
#include "window-items.h"
static void cmd_msg(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
{
GHashTable *optlist;
WINDOW_REC *window;
IRC_CHANNEL_REC *channel;
NICK_REC *nickrec;
const char *nickmode;
char *target, *msg, *freestr, *newtarget;
void *free_arg;
int free_ret, print_channel;
g_return_if_fail(data != NULL);
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS |
PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST,
"msg", &optlist, &target, &msg))
return;
if (*target == '\0' || *msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
server = IRC_SERVER(cmd_options_get_server("msg", optlist, SERVER(server)));
if (*target == '=')
{
/* dcc msg - handled in fe-dcc.c */
cmd_params_free(free_arg);
return;
}
free_ret = FALSE;
if (strcmp(target, ",") == 0 || strcmp(target, ".") == 0)
newtarget = parse_special(&target, SERVER(server), item, NULL, &free_ret, NULL);
else if (strcmp(target, "*") == 0 &&
(IS_IRC_CHANNEL(item) || IS_IRC_QUERY(item)))
newtarget = item->name;
else newtarget = target;
if (newtarget == NULL) {
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, *target == ',' ?
IRCTXT_NO_MSGS_GOT : IRCTXT_NO_MSGS_SENT);
cmd_params_free(free_arg);
signal_stop();
return;
}
target = newtarget;
if (server == NULL || !server->connected) cmd_param_error(CMDERR_NOT_CONNECTED);
channel = irc_channel_find(server, target);
freestr = !free_ret ? NULL : target;
if (*target == '@' && ischannel(target[1]))
target++; /* Hybrid 6 feature, send msg to all ops in channel */
if (ischannel(*target))
{
/* msg to channel */
nickrec = channel == NULL ? NULL :
nicklist_find(CHANNEL(channel), server->nick);
nickmode = !settings_get_bool("show_nickmode") || nickrec == NULL ? "" :
nickrec->op ? "@" : nickrec->voice ? "+" : " ";
window = channel == NULL ? NULL : window_item_window((WI_ITEM_REC *) channel);
print_channel = window == NULL ||
window->active != (WI_ITEM_REC *) channel;
if (!print_channel && settings_get_bool("print_active_channel") &&
window != NULL && g_slist_length(window->items) > 1)
print_channel = TRUE;
if (!print_channel)
{
printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
IRCTXT_OWN_MSG, server->nick, msg, nickmode);
}
else
{
printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
IRCTXT_OWN_MSG_CHANNEL, server->nick, target, msg, nickmode);
}
}
else
{
/* private message */
item = (WI_ITEM_REC *) privmsg_get_query(SERVER(server), target, TRUE, MSGLEVEL_MSGS);
printformat(server, target, MSGLEVEL_MSGS | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
item == NULL ? IRCTXT_OWN_MSG_PRIVATE : IRCTXT_OWN_MSG_PRIVATE_QUERY, target, msg, server->nick);
}
g_free_not_null(freestr);
cmd_params_free(free_arg);
}
/* SYNTAX: ME <message> */
static void cmd_me(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
{
@ -428,7 +338,6 @@ static void cmd_ts(const char *data)
void fe_irc_commands_init(void)
{
command_bind_last("msg", NULL, (SIGNAL_FUNC) cmd_msg);
command_bind_last("me", NULL, (SIGNAL_FUNC) cmd_me);
command_bind_last("action", NULL, (SIGNAL_FUNC) cmd_action);
command_bind("notice", NULL, (SIGNAL_FUNC) cmd_notice);
@ -445,7 +354,6 @@ void fe_irc_commands_init(void)
void fe_irc_commands_deinit(void)
{
command_unbind("msg", (SIGNAL_FUNC) cmd_msg);
command_unbind("me", (SIGNAL_FUNC) cmd_me);
command_unbind("action", (SIGNAL_FUNC) cmd_action);
command_unbind("notice", (SIGNAL_FUNC) cmd_notice);

View file

@ -235,7 +235,7 @@ static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char *
}
mchannel = MODULE_DATA(channel);
list = irc_nick_match(server->nick, msg) ?
list = nick_match_msg(SERVER(server), msg, server->nick) ?
&mchannel->lastownmsgs :
&mchannel->lastmsgs;
nick_completion_create(list, time(NULL), nick);

View file

@ -1,62 +0,0 @@
/*
irc-hilight-text.c : irssi
Copyright (C) 1999-2000 Timo Sirainen
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; either version 2 of the License, or
(at your option) any later version.
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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "module.h"
#include "signals.h"
#include "settings.h"
#include "hilight-text.h"
static int last_color;
char *irc_hilight_find_nick(const char *channel, const char *nick,
const char *address, int level, const char *msg)
{
char *color, *mask;
mask = g_strdup_printf("%s!%s", nick, address);
color = hilight_match(channel, mask, level, msg);
g_free(mask);
last_color = (color != NULL && *color == 3) ?
atoi(color+1) : 0;
return color;
}
int irc_hilight_last_color(void)
{
return last_color;
}
static void event_privmsg(void)
{
last_color = 0;
}
void irc_hilight_text_init(void)
{
last_color = 0;
signal_add_last("event privmsg", (SIGNAL_FUNC) event_privmsg);
}
void irc_hilight_text_deinit(void)
{
signal_remove("event privmsg", (SIGNAL_FUNC) event_privmsg);
}

View file

@ -1,9 +0,0 @@
#ifndef __IRC_HILIGHT_TEXT_H
#define __IRC_HILIGHT_TEXT_H
char *irc_hilight_find_nick(const char *channel, const char *nick,
const char *address, int level, const char *msg);
int irc_hilight_last_color(void);
#endif

View file

@ -1,87 +0,0 @@
/*
irc-window-activity.c : irssi
Copyright (C) 1999-2000 Timo Sirainen
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; either version 2 of the License, or
(at your option) any later version.
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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "module.h"
#include "signals.h"
#include "levels.h"
#include "irc.h"
#include "ignore.h"
#include "irc-servers.h"
#include "irc-nicklist.h"
#include "completion.h"
#include "windows.h"
#include "window-items.h"
#include "irc-hilight-text.h"
static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char *nick, const char *addr)
{
WINDOW_REC *window;
WI_ITEM_REC *item;
char *params, *target, *msg;
int level;
g_return_if_fail(data != NULL);
params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
/* get window and window item */
level = ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS;
item = window_item_find(server, ischannel(*target) ? target : nick);
window = item == NULL ?
window_find_closest(server, target, GPOINTER_TO_INT(level)) :
window_item_window(item);
/* check that msg wasn't send to current window and
that it didn't get ignored */
if (window != active_win && !ignore_check(server, nick, addr, target, msg, level)) {
/* hilight */
if (item != NULL) item->last_color = irc_hilight_last_color();
level = (item != NULL && item->last_color > 0) ||
!ischannel(*target) || irc_nick_match(server->nick, msg) ?
NEWDATA_HILIGHT : NEWDATA_MSG;
if (item != NULL && item->new_data < level) {
item->new_data = level;
signal_emit("window item hilight", 1, item);
} else {
int oldlevel = window->new_data;
if (window->new_data < level) {
window->new_data = level;
window->last_color = irc_hilight_last_color();
signal_emit("window hilight", 2, window, GINT_TO_POINTER(oldlevel));
}
signal_emit("window activity", 2, window, GINT_TO_POINTER(oldlevel));
}
}
g_free(params);
}
void irc_window_activity_init(void)
{
signal_add_last("event privmsg", (SIGNAL_FUNC) event_privmsg);
}
void irc_window_activity_deinit(void)
{
signal_remove("event privmsg", (SIGNAL_FUNC) event_privmsg);
}

View file

@ -122,10 +122,6 @@ FORMAT_REC fecommon_irc_formats[] = {
/* ---- */
{ NULL, "Your messages", 0 },
{ "own_msg", "%K<%n$2%W$0%K>%n %|$1", 3, { 0, 0, 0 } },
{ "own_msg_channel", "%K<%n$3%W$0%K:%c$1%K>%n %|$2", 4, { 0, 0, 0, 0 } },
{ "own_msg_private", "%K[%rmsg%K(%R$0%K)]%n $1", 2, { 0, 0 } },
{ "own_msg_private_query", "%K<%W$2%K>%n %|$1", 3, { 0, 0, 0 } },
{ "own_notice", "%K[%rnotice%K(%R$0%K)]%n $1", 2, { 0, 0 } },
{ "own_action", "%W * $0%n $1", 2, { 0, 0 } },
{ "own_ctcp", "%K[%rctcp%K(%R$0%K)]%n $1 $2", 3, { 0, 0, 0 } },
@ -134,14 +130,6 @@ FORMAT_REC fecommon_irc_formats[] = {
/* ---- */
{ NULL, "Received messages", 0 },
{ "pubmsg_me", "%K<%n$2%Y$0%K>%n %|$1", 3, { 0, 0, 0 } },
{ "pubmsg_me_channel", "%K<%n$3%Y$0%K:%c$1%K>%n %|$2", 4, { 0, 0, 0, 0 } },
{ "pubmsg_hilight", "%K<%n$3$0$1%K>%n %|$2", 4, { 0, 0, 0, 0 } },
{ "pubmsg_hilight_channel", "%K<%n$4$0$1%K:%c$2%K>%n %|$3", 5, { 0, 0, 0, 0, 0 } },
{ "pubmsg", "%K<%n$2$0%K>%n %|$1", 3, { 0, 0, 0 } },
{ "pubmsg_channel", "%K<%n$3$0%K:%c$1%K>%n %|$2", 4, { 0, 0, 0, 0 } },
{ "msg_private", "%K[%R$0%K(%r$1%K)]%n $2", 3, { 0, 0, 0 } },
{ "msg_private_query", "%K<%R$0%K>%n %|$2", 3, { 0, 0, 0 } },
{ "notice_server", "%g!$0%n $1", 2, { 0, 0 } },
{ "notice_public", "%K-%M$0%K:%m$1%K-%n $2", 3, { 0, 0, 0 } },
{ "notice_public_ops", "%K-%M$0%K:%m@$1%K-%n $2", 3, { 0, 0, 0 } },
@ -180,8 +168,6 @@ FORMAT_REC fecommon_irc_formats[] = {
{ "ignore_header", "Ignorance List:", 0 },
{ "ignore_line", "$[-4]0 $1: $2 $3 $4", 4, { 1, 0, 0, 0 } },
{ "ignore_footer", "", 0 },
{ "no_msgs_got", "You have not received a message from anyone yet", 0 },
{ "no_msgs_sent", "You have not sent a message to anyone yet", 0 },
{ NULL, NULL, 0 }
};

View file

@ -96,10 +96,6 @@ enum {
IRCTXT_FILL_6,
IRCTXT_OWN_MSG,
IRCTXT_OWN_MSG_CHANNEL,
IRCTXT_OWN_MSG_PRIVATE,
IRCTXT_OWN_MSG_PRIVATE_QUERY,
IRCTXT_OWN_NOTICE,
IRCTXT_OWN_ME,
IRCTXT_OWN_CTCP,
@ -107,14 +103,6 @@ enum {
IRCTXT_FILL_7,
IRCTXT_PUBMSG_ME,
IRCTXT_PUBMSG_ME_CHANNEL,
IRCTXT_PUBMSG_HILIGHT,
IRCTXT_PUBMSG_HILIGHT_CHANNEL,
IRCTXT_PUBMSG,
IRCTXT_PUBMSG_CHANNEL,
IRCTXT_MSG_PRIVATE,
IRCTXT_MSG_PRIVATE_QUERY,
IRCTXT_NOTICE_SERVER,
IRCTXT_NOTICE_PUBLIC,
IRCTXT_NOTICE_PUBLIC_OPS,
@ -149,9 +137,7 @@ enum {
IRCTXT_IGNORE_NO_IGNORES,
IRCTXT_IGNORE_HEADER,
IRCTXT_IGNORE_LINE,
IRCTXT_IGNORE_FOOTER,
IRCTXT_NO_MSGS_GOT,
IRCTXT_NO_MSGS_SENT
IRCTXT_IGNORE_FOOTER
};
extern FORMAT_REC fecommon_irc_formats[];