mirror of
https://github.com/irssi/irssi.git
synced 2026-08-10 04:13:32 +02:00
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:
parent
965def294b
commit
2b8580c8a7
46 changed files with 667 additions and 687 deletions
|
|
@ -14,6 +14,7 @@ libfe_common_core_a_SOURCES = \
|
|||
fe-common-core.c \
|
||||
fe-core-commands.c \
|
||||
fe-log.c \
|
||||
fe-messages.c \
|
||||
fe-modules.c \
|
||||
fe-queries.c \
|
||||
fe-server.c \
|
||||
|
|
|
|||
|
|
@ -49,6 +49,9 @@ void fe_core_log_deinit(void);
|
|||
void fe_log_init(void);
|
||||
void fe_log_deinit(void);
|
||||
|
||||
void fe_messages_init(void);
|
||||
void fe_messages_deinit(void);
|
||||
|
||||
void fe_modules_init(void);
|
||||
void fe_modules_deinit(void);
|
||||
|
||||
|
|
@ -76,7 +79,6 @@ void fe_common_core_init(void)
|
|||
settings_add_bool("lookandfeel", "timestamps", TRUE);
|
||||
settings_add_bool("lookandfeel", "msgs_timestamps", FALSE);
|
||||
settings_add_bool("lookandfeel", "hide_text_style", FALSE);
|
||||
settings_add_bool("lookandfeel", "show_nickmode", TRUE);
|
||||
settings_add_bool("lookandfeel", "bell_beeps", FALSE);
|
||||
settings_add_str("lookandfeel", "beep_on_msg", "");
|
||||
settings_add_bool("lookandfeel", "beep_when_away", TRUE);
|
||||
|
|
@ -99,6 +101,7 @@ void fe_common_core_init(void)
|
|||
fe_channels_init();
|
||||
fe_queries_init();
|
||||
fe_log_init();
|
||||
fe_messages_init();
|
||||
fe_modules_init();
|
||||
fe_server_init();
|
||||
fe_settings_init();
|
||||
|
|
@ -121,6 +124,7 @@ void fe_common_core_deinit(void)
|
|||
printtext_deinit();
|
||||
fe_channels_deinit();
|
||||
fe_queries_deinit();
|
||||
fe_messages_deinit();
|
||||
fe_log_deinit();
|
||||
fe_modules_deinit();
|
||||
fe_server_deinit();
|
||||
|
|
|
|||
222
src/fe-common/core/fe-messages.c
Normal file
222
src/fe-common/core/fe-messages.c
Normal file
|
|
@ -0,0 +1,222 @@
|
|||
/*
|
||||
fe-messages.c : irssi
|
||||
|
||||
Copyright (C) 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 "module-formats.h"
|
||||
#include "signals.h"
|
||||
#include "commands.h"
|
||||
#include "levels.h"
|
||||
#include "special-vars.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include "window-items.h"
|
||||
#include "fe-queries.h"
|
||||
#include "channels.h"
|
||||
#include "nicklist.h"
|
||||
#include "hilight-text.h"
|
||||
|
||||
static char *get_nickmode(CHANNEL_REC *channel, const char *nick)
|
||||
{
|
||||
NICK_REC *nickrec;
|
||||
|
||||
g_return_val_if_fail(nick != NULL, NULL);
|
||||
|
||||
nickrec = channel == NULL ? NULL :
|
||||
nicklist_find(channel, nick);
|
||||
return (nickrec == NULL || !settings_get_bool("show_nickmode")) ?
|
||||
"" : (nickrec->op ? "@" : (nickrec->voice ? "+" : " "));
|
||||
}
|
||||
|
||||
static void sig_message_public(SERVER_REC *server, const char *msg,
|
||||
const char *nick, const char *address,
|
||||
const char *target)
|
||||
{
|
||||
CHANNEL_REC *chanrec;
|
||||
const char *nickmode;
|
||||
int for_me, print_channel, level;
|
||||
char *color;
|
||||
|
||||
chanrec = channel_find(server, target);
|
||||
for_me = nick_match_msg(server, msg, server->nick);
|
||||
color = for_me ? NULL :
|
||||
hilight_find_nick(target, nick, address, MSGLEVEL_PUBLIC, msg);
|
||||
|
||||
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));
|
||||
|
||||
nickmode = get_nickmode(chanrec, nick);
|
||||
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 sig_message_private(SERVER_REC *server, const char *msg,
|
||||
const char *nick, const char *address)
|
||||
{
|
||||
QUERY_REC *query;
|
||||
|
||||
query = privmsg_get_query(server, nick, FALSE, MSGLEVEL_MSGS);
|
||||
printformat(server, nick, MSGLEVEL_MSGS,
|
||||
query == NULL ? IRCTXT_MSG_PRIVATE :
|
||||
IRCTXT_MSG_PRIVATE_QUERY, nick, address, msg);
|
||||
}
|
||||
|
||||
static void print_own_channel_message(SERVER_REC *server, CHANNEL_REC *channel,
|
||||
const char *target, const char *msg)
|
||||
{
|
||||
WINDOW_REC *window;
|
||||
const char *nickmode;
|
||||
int print_channel;
|
||||
|
||||
nickmode = get_nickmode(channel, server->nick);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
static void cmd_msg(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
|
||||
{
|
||||
GHashTable *optlist;
|
||||
CHANNEL_REC *channel;
|
||||
char *target, *msg, *freestr, *newtarget;
|
||||
void *free_arg;
|
||||
int free_ret;
|
||||
|
||||
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 = cmd_options_get_server("msg", optlist, server);
|
||||
|
||||
free_ret = FALSE;
|
||||
if (strcmp(target, ",") == 0 || strcmp(target, ".") == 0) {
|
||||
/* , and . are handled specially */
|
||||
newtarget = parse_special(&target, server, item,
|
||||
NULL, &free_ret, NULL);
|
||||
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;
|
||||
} else if (strcmp(target, "*") == 0 && item != NULL) {
|
||||
/* * means active channel */
|
||||
target = item->name;
|
||||
}
|
||||
|
||||
if (server == NULL || !server->connected)
|
||||
cmd_param_error(CMDERR_NOT_CONNECTED);
|
||||
channel = channel_find(server, target);
|
||||
|
||||
freestr = !free_ret ? NULL : target;
|
||||
if (*target == '@' && server->ischannel(target[1])) {
|
||||
/* Hybrid 6 feature, send msg to all ops in channel
|
||||
FIXME: this shouldn't really be here in core.. */
|
||||
target++;
|
||||
}
|
||||
|
||||
if (server->ischannel(*target)) {
|
||||
/* msg to channel */
|
||||
print_own_channel_message(server, channel, target, msg);
|
||||
} else {
|
||||
/* private message */
|
||||
QUERY_REC *query;
|
||||
|
||||
query = privmsg_get_query(server, target, TRUE, MSGLEVEL_MSGS);
|
||||
printformat(server, target, MSGLEVEL_MSGS |
|
||||
MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
|
||||
query == NULL ? IRCTXT_OWN_MSG_PRIVATE :
|
||||
IRCTXT_OWN_MSG_PRIVATE_QUERY,
|
||||
target, msg, server->nick);
|
||||
}
|
||||
g_free_not_null(freestr);
|
||||
|
||||
cmd_params_free(free_arg);
|
||||
}
|
||||
|
||||
void fe_messages_init(void)
|
||||
{
|
||||
settings_add_bool("lookandfeel", "show_nickmode", TRUE);
|
||||
settings_add_bool("lookandfeel", "print_active_channel", FALSE);
|
||||
|
||||
signal_add("message public", (SIGNAL_FUNC) sig_message_public);
|
||||
signal_add("message private", (SIGNAL_FUNC) sig_message_private);
|
||||
command_bind_last("msg", NULL, (SIGNAL_FUNC) cmd_msg);
|
||||
}
|
||||
|
||||
void fe_messages_deinit(void)
|
||||
{
|
||||
signal_remove("message public", (SIGNAL_FUNC) sig_message_public);
|
||||
signal_remove("message private", (SIGNAL_FUNC) sig_message_private);
|
||||
command_unbind("msg", (SIGNAL_FUNC) cmd_msg);
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ static void cmd_server_add(const char *data)
|
|||
signal_emit("server add create", 2, &rec, optlist);
|
||||
if (rec == NULL) {
|
||||
/* no chatnet option specified, use the first. */
|
||||
g_hash_table_insert(optlist, (char *) chat_protocol_get_chatnet(1), "");
|
||||
g_hash_table_insert(optlist, (char *) chat_protocol_get_rec(1)->name, "");
|
||||
signal_emit("server add create", 2, &rec, optlist);
|
||||
if (rec == NULL) {
|
||||
/* bug? */
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
(MSGLEVEL_PUBLIC | MSGLEVEL_MSGS | \
|
||||
MSGLEVEL_ACTIONS | MSGLEVEL_DCCMSGS)
|
||||
|
||||
static int hilight_next;
|
||||
static int hilight_next, last_nick_color;
|
||||
GSList *hilights;
|
||||
|
||||
static void hilight_add_config(HILIGHT_REC *rec)
|
||||
|
|
@ -281,6 +281,30 @@ static void sig_print_text_stripped(WINDOW_REC *window, SERVER_REC *server, cons
|
|||
g_free_not_null(color);
|
||||
}
|
||||
|
||||
char *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_nick_color = (color != NULL && *color == 3) ?
|
||||
atoi(color+1) : 0;
|
||||
return color;
|
||||
}
|
||||
|
||||
int hilight_last_nick_color(void)
|
||||
{
|
||||
return last_nick_color;
|
||||
}
|
||||
|
||||
static void sig_message(void)
|
||||
{
|
||||
last_nick_color = 0;
|
||||
}
|
||||
|
||||
static void read_hilight_config(void)
|
||||
{
|
||||
CONFIG_NODE *node;
|
||||
|
|
@ -448,6 +472,7 @@ static void cmd_dehilight(const char *data)
|
|||
void hilight_text_init(void)
|
||||
{
|
||||
hilight_next = FALSE;
|
||||
last_nick_color = 0;
|
||||
|
||||
read_hilight_config();
|
||||
settings_add_str("misc", "hilight_color", "8");
|
||||
|
|
@ -456,6 +481,8 @@ void hilight_text_init(void)
|
|||
signal_add_first("print text", (SIGNAL_FUNC) sig_print_text);
|
||||
signal_add_first("print text stripped", (SIGNAL_FUNC) sig_print_text_stripped);
|
||||
signal_add("setup reread", (SIGNAL_FUNC) read_hilight_config);
|
||||
signal_add_last("message public", (SIGNAL_FUNC) sig_message);
|
||||
signal_add_last("message private", (SIGNAL_FUNC) sig_message);
|
||||
command_bind("hilight", NULL, (SIGNAL_FUNC) cmd_hilight);
|
||||
command_bind("dehilight", NULL, (SIGNAL_FUNC) cmd_dehilight);
|
||||
|
||||
|
|
@ -469,6 +496,8 @@ void hilight_text_deinit(void)
|
|||
signal_remove("print text", (SIGNAL_FUNC) sig_print_text);
|
||||
signal_remove("print text stripped", (SIGNAL_FUNC) sig_print_text_stripped);
|
||||
signal_remove("setup reread", (SIGNAL_FUNC) read_hilight_config);
|
||||
signal_remove("message public", (SIGNAL_FUNC) sig_message);
|
||||
signal_remove("message private", (SIGNAL_FUNC) sig_message);
|
||||
command_unbind("hilight", (SIGNAL_FUNC) cmd_hilight);
|
||||
command_unbind("dehilight", (SIGNAL_FUNC) cmd_dehilight);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,12 @@ typedef struct {
|
|||
|
||||
extern GSList *hilights;
|
||||
|
||||
char *hilight_match(const char *channel, const char *nickmask, int level, const char *str);
|
||||
char *hilight_match(const char *channel, const char *nickmask,
|
||||
int level, const char *str);
|
||||
|
||||
char *hilight_find_nick(const char *channel, const char *nick,
|
||||
const char *address, int level, const char *msg);
|
||||
int hilight_last_nick_color(void);
|
||||
|
||||
void hilight_text_init(void);
|
||||
void hilight_text_deinit(void);
|
||||
|
|
|
|||
|
|
@ -75,6 +75,24 @@ FORMAT_REC fecommon_core_formats[] = {
|
|||
{ "chansetup_line", "$[15]0 %|$[10]1 $[10]2 $3", 4, { 0, 0, 0, 0 } },
|
||||
{ "chansetup_footer", "", 0 },
|
||||
|
||||
/* ---- */
|
||||
{ NULL, "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 } },
|
||||
{ "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 } },
|
||||
{ "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, "Queries", 0 },
|
||||
|
||||
|
|
|
|||
|
|
@ -51,13 +51,30 @@ enum {
|
|||
IRCTXT_CHANSETUP_LINE,
|
||||
IRCTXT_CHANSETUP_FOOTER,
|
||||
|
||||
IRCTXT_FILL_4,
|
||||
IRCTXT_FILL_4,
|
||||
|
||||
IRCTXT_OWN_MSG,
|
||||
IRCTXT_OWN_MSG_CHANNEL,
|
||||
IRCTXT_OWN_MSG_PRIVATE,
|
||||
IRCTXT_OWN_MSG_PRIVATE_QUERY,
|
||||
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_NO_MSGS_GOT,
|
||||
IRCTXT_NO_MSGS_SENT,
|
||||
|
||||
IRCTXT_FILL_5,
|
||||
|
||||
IRCTXT_QUERY_STARTED,
|
||||
IRCTXT_NO_QUERY,
|
||||
IRCTXT_QUERY_SERVER_CHANGED,
|
||||
|
||||
IRCTXT_FILL_5,
|
||||
IRCTXT_FILL_6,
|
||||
|
||||
IRCTXT_HILIGHT_HEADER,
|
||||
IRCTXT_HILIGHT_LINE,
|
||||
|
|
@ -65,7 +82,7 @@ enum {
|
|||
IRCTXT_HILIGHT_NOT_FOUND,
|
||||
IRCTXT_HILIGHT_REMOVED,
|
||||
|
||||
IRCTXT_FILL_6,
|
||||
IRCTXT_FILL_7,
|
||||
|
||||
IRCTXT_ALIAS_ADDED,
|
||||
IRCTXT_ALIAS_REMOVED,
|
||||
|
|
@ -74,7 +91,7 @@ enum {
|
|||
IRCTXT_ALIASLIST_LINE,
|
||||
IRCTXT_ALIASLIST_FOOTER,
|
||||
|
||||
IRCTXT_FILL_7,
|
||||
IRCTXT_FILL_8,
|
||||
|
||||
IRCTXT_LOG_OPENED,
|
||||
IRCTXT_LOG_CLOSED,
|
||||
|
|
@ -91,7 +108,7 @@ enum {
|
|||
IRCTXT_LOG_NO_AWAY_MSGS,
|
||||
IRCTXT_LOG_AWAY_MSGS,
|
||||
|
||||
IRCTXT_FILL_8,
|
||||
IRCTXT_FILL_9,
|
||||
|
||||
IRCTXT_MODULE_ALREADY_LOADED,
|
||||
IRCTXT_MODULE_LOAD_ERROR,
|
||||
|
|
@ -99,7 +116,7 @@ enum {
|
|||
IRCTXT_MODULE_LOADED,
|
||||
IRCTXT_MODULE_UNLOADED,
|
||||
|
||||
IRCTXT_FILL_9,
|
||||
IRCTXT_FILL_10,
|
||||
|
||||
IRCTXT_COMMAND_UNKNOWN,
|
||||
IRCTXT_COMMAND_AMBIGUOUS,
|
||||
|
|
@ -113,7 +130,7 @@ enum {
|
|||
IRCTXT_CHAN_NOT_SYNCED,
|
||||
IRCTXT_NOT_GOOD_IDEA,
|
||||
|
||||
IRCTXT_FILL_10,
|
||||
IRCTXT_FILL_11,
|
||||
|
||||
IRCTXT_THEME_SAVED,
|
||||
IRCTXT_THEME_SAVE_FAILED,
|
||||
|
|
@ -123,7 +140,7 @@ enum {
|
|||
IRCTXT_FORMAT_SUBTITLE,
|
||||
IRCTXT_FORMAT_ITEM,
|
||||
|
||||
IRCTXT_FILL_11,
|
||||
IRCTXT_FILL_12,
|
||||
|
||||
IRCTXT_NOT_TOGGLE,
|
||||
IRCTXT_PERL_ERROR,
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
#include "windows.h"
|
||||
#include "window-items.h"
|
||||
#include "nicklist.h"
|
||||
#include "hilight-text.h"
|
||||
|
||||
static const char *noact_channels;
|
||||
|
||||
|
|
@ -119,6 +121,58 @@ static void sig_hilight_window_item(WI_ITEM_REC *item)
|
|||
signal_emit("window activity", 2, window, GINT_TO_POINTER(oldlevel));
|
||||
}
|
||||
|
||||
static void sig_message(SERVER_REC *server, const char *msg,
|
||||
const char *nick, const char *addr,
|
||||
const char *target, int level)
|
||||
{
|
||||
WINDOW_REC *window;
|
||||
WI_ITEM_REC *item;
|
||||
|
||||
/* get window and window item */
|
||||
item = window_item_find(server, target);
|
||||
window = item == NULL ?
|
||||
window_find_closest(server, target, level) :
|
||||
window_item_window(item);
|
||||
|
||||
if (window == active_win)
|
||||
return;
|
||||
|
||||
/* hilight */
|
||||
if (item != NULL) item->last_color = hilight_last_nick_color();
|
||||
level = (item != NULL && item->last_color > 0) ||
|
||||
(level & MSGLEVEL_MSGS) ||
|
||||
nick_match_msg(SERVER(server), msg, server->nick) ?
|
||||
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 = hilight_last_nick_color();
|
||||
signal_emit("window hilight", 2, window,
|
||||
GINT_TO_POINTER(oldlevel));
|
||||
}
|
||||
signal_emit("window activity", 2, window,
|
||||
GINT_TO_POINTER(oldlevel));
|
||||
}
|
||||
}
|
||||
|
||||
static void sig_message_public(SERVER_REC *server, const char *msg,
|
||||
const char *nick, const char *addr,
|
||||
const char *target)
|
||||
{
|
||||
sig_message(server, msg, nick, addr, target, MSGLEVEL_PUBLIC);
|
||||
}
|
||||
|
||||
static void sig_message_private(SERVER_REC *server, const char *msg,
|
||||
const char *nick, const char *addr)
|
||||
{
|
||||
sig_message(server, msg, nick, addr, nick, MSGLEVEL_MSGS);
|
||||
}
|
||||
|
||||
static void read_settings(void)
|
||||
{
|
||||
noact_channels = settings_get_str("noact_channels");
|
||||
|
|
@ -134,6 +188,8 @@ void window_activity_init(void)
|
|||
signal_add("window changed", (SIGNAL_FUNC) sig_dehilight_window);
|
||||
signal_add("window dehilight", (SIGNAL_FUNC) sig_dehilight_window);
|
||||
signal_add("window item hilight", (SIGNAL_FUNC) sig_hilight_window_item);
|
||||
signal_add("message public", (SIGNAL_FUNC) sig_message_public);
|
||||
signal_add("message private", (SIGNAL_FUNC) sig_message_private);
|
||||
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
|
||||
}
|
||||
|
||||
|
|
@ -144,5 +200,7 @@ void window_activity_deinit(void)
|
|||
signal_remove("window changed", (SIGNAL_FUNC) sig_dehilight_window);
|
||||
signal_remove("window dehilight", (SIGNAL_FUNC) sig_dehilight_window);
|
||||
signal_remove("window item hilight", (SIGNAL_FUNC) sig_hilight_window_item);
|
||||
signal_remove("message public", (SIGNAL_FUNC) sig_message_public);
|
||||
signal_remove("message private", (SIGNAL_FUNC) sig_message_private);
|
||||
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,8 +130,8 @@ static void window_save_items(WINDOW_REC *window, CONFIG_NODE *node)
|
|||
subnode = config_node_section(node, NULL, NODE_TYPE_BLOCK);
|
||||
|
||||
iconfig_node_set_str(subnode, "type", type);
|
||||
iconfig_node_set_str(subnode, "chat_type",
|
||||
chat_protocol_get_name(rec->chat_type));
|
||||
type = chat_protocol_get_rec(rec->chat_type)->name;
|
||||
iconfig_node_set_str(subnode, "chat_type", type);
|
||||
iconfig_node_set_str(subnode, "name", rec->name);
|
||||
|
||||
if (server != NULL)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue