1
0
mirror of https://github.com/irssi/irssi.git synced 2025-02-02 15:08:01 -05:00

Fixed DCC stuff. Added DCCMSGS level for DCC chat messages.

Actions match now either MSGS or PUBLIC level as well as the ACTIONS
level always.

Added DCCMSGS level to default highlight levels. Highlighting works
with other than public messages now even if -nick option is used.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@463 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2000-07-15 13:04:03 +00:00 committed by cras
parent 1b736a68a7
commit 796d51afe4
10 changed files with 54 additions and 35 deletions

View File

@ -40,6 +40,7 @@ static const char *levels[] =
"INVITES",
"NICKS",
"DCC",
"DCCMSGS",
"CLIENTNOTICES",
"CLIENTCRAP",
"CLIENTERRORS",

View File

@ -24,12 +24,13 @@
#define MSGLEVEL_INVITES 0x0004000
#define MSGLEVEL_NICKS 0x0008000
#define MSGLEVEL_DCC 0x0010000
#define MSGLEVEL_CLIENTNOTICE 0x0020000
#define MSGLEVEL_CLIENTCRAP 0x0040000
#define MSGLEVEL_CLIENTERROR 0x0080000
#define MSGLEVEL_HILIGHT 0x0100000
#define MSGLEVEL_DCCMSGS 0x0020000
#define MSGLEVEL_CLIENTNOTICE 0x0040000
#define MSGLEVEL_CLIENTCRAP 0x0080000
#define MSGLEVEL_CLIENTERROR 0x0100000
#define MSGLEVEL_HILIGHT 0x0200000
#define MSGLEVEL_ALL 0x01fffff
#define MSGLEVEL_ALL 0x03fffff
#define MSGLEVEL_NOHILIGHT 0x1000000 /* Don't try to hilight words in this message */
#define MSGLEVEL_NO_ACT 0x2000000 /* Don't trigger channel activity */

View File

@ -32,7 +32,8 @@
#include "hilight-text.h"
#define DEFAULT_HILIGHT_LEVEL \
(MSGLEVEL_PUBLIC | MSGLEVEL_MSGS | MSGLEVEL_NOTICES | MSGLEVEL_ACTIONS)
(MSGLEVEL_PUBLIC | MSGLEVEL_MSGS | MSGLEVEL_NOTICES | \
MSGLEVEL_ACTIONS | MSGLEVEL_DCCMSGS)
static int hilight_next;
GSList *hilights;
@ -201,8 +202,7 @@ char *hilight_match(const char *channel, const char *nickmask, int level, const
if ((level & (rec->level > 0 ? rec->level : DEFAULT_HILIGHT_LEVEL)) == 0)
continue;
if ((rec->nick && nickmask == NULL) ||
(!rec->nick && nickmask != NULL))
if (!rec->nick && nickmask != NULL)
continue;
if (rec->channels != NULL && (channel == NULL || strarray_find(rec->channels, channel) == -1))
continue;

View File

@ -118,7 +118,7 @@ static void dcc_chat_action(const char *msg, DCC_REC *dcc)
g_return_if_fail(msg != NULL);
sender = g_strconcat("=", dcc->nick, NULL);
printformat(NULL, sender, MSGLEVEL_DCC | MSGLEVEL_MSGS,
printformat(NULL, sender, MSGLEVEL_DCCMSGS,
IRCTXT_ACTION_DCC, dcc->nick, msg);
g_free(sender);
}
@ -131,7 +131,7 @@ static void dcc_chat_ctcp(const char *msg, DCC_REC *dcc)
g_return_if_fail(msg != NULL);
sender = g_strconcat("=", dcc->nick, NULL);
printformat(NULL, sender, MSGLEVEL_DCC | MSGLEVEL_CTCPS, IRCTXT_DCC_CTCP, dcc->nick, msg);
printformat(NULL, sender, MSGLEVEL_DCC, IRCTXT_DCC_CTCP, dcc->nick, msg);
g_free(sender);
}
@ -143,7 +143,7 @@ static void dcc_chat_msg(DCC_REC *dcc, const char *msg)
g_return_if_fail(msg != NULL);
sender = g_strconcat("=", dcc->nick, NULL);
printformat(NULL, sender, MSGLEVEL_DCC | MSGLEVEL_MSGS,
printformat(NULL, sender, MSGLEVEL_DCCMSGS,
query_find(NULL, sender) ? IRCTXT_DCC_MSG_QUERY :
IRCTXT_DCC_MSG, dcc->nick, msg);
g_free(sender);
@ -310,7 +310,7 @@ static void cmd_msg(const char *data)
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
IRCTXT_DCC_CHAT_NOT_FOUND, target+1);
} else {
printformat(NULL, target, MSGLEVEL_DCC | MSGLEVEL_MSGS | MSGLEVEL_NOHILIGHT,
printformat(NULL, target, MSGLEVEL_DCCMSGS | MSGLEVEL_NOHILIGHT,
query_find(NULL, target) ? IRCTXT_OWN_DCC_QUERY :
IRCTXT_OWN_DCC, dcc->mynick, text);
}
@ -327,7 +327,7 @@ static void cmd_me(const char *data, SERVER_REC *server, WI_IRC_REC *item)
dcc = item_get_dcc(item);
if (dcc == NULL) return;
printformat(NULL, item->name, MSGLEVEL_DCC | MSGLEVEL_ACTIONS | MSGLEVEL_NOHILIGHT,
printformat(NULL, item->name, MSGLEVEL_DCCMSGS | MSGLEVEL_NOHILIGHT,
IRCTXT_OWN_DCC_ME, dcc->mynick, data);
}
@ -353,7 +353,7 @@ static void cmd_action(const char *data, SERVER_REC *server, WI_IRC_REC *item)
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
IRCTXT_DCC_CHAT_NOT_FOUND, target+1);
} else {
printformat(NULL, target, MSGLEVEL_DCC | MSGLEVEL_ACTIONS,
printformat(NULL, target, MSGLEVEL_DCCMSGS | MSGLEVEL_NOHILIGHT,
IRCTXT_OWN_DCC_ME, dcc->mynick, text);
}
cmd_params_free(free_arg);
@ -384,7 +384,7 @@ static void cmd_ctcp(const char *data, SERVER_REC *server)
IRCTXT_DCC_CHAT_NOT_FOUND, target+1);
} else {
g_strup(ctcpcmd);
printformat(server, target, MSGLEVEL_DCC | MSGLEVEL_CTCPS, IRCTXT_OWN_DCC_CTCP,
printformat(server, target, MSGLEVEL_DCC, IRCTXT_OWN_DCC_CTCP,
target, ctcpcmd, ctcpdata);
}

View File

@ -129,6 +129,7 @@ static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char *
static void ctcp_msg_check_action(gchar *data, IRC_SERVER_REC *server, gchar *nick, gchar *addr, gchar *target)
{
WI_ITEM_REC *item;
int level;
g_return_if_fail(data != NULL);
@ -136,7 +137,9 @@ static void ctcp_msg_check_action(gchar *data, IRC_SERVER_REC *server, gchar *ni
return;
data += 7;
if (ignore_check(server, nick, addr, target, data, MSGLEVEL_ACTIONS))
level = MSGLEVEL_ACTIONS |
(ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS);
if (ignore_check(server, nick, addr, target, data, level))
return;
if (ischannel(*target)) {
@ -145,17 +148,17 @@ static void ctcp_msg_check_action(gchar *data, IRC_SERVER_REC *server, gchar *ni
if (window_item_is_active(item)) {
/* message to active channel in window */
printformat(server, target, MSGLEVEL_ACTIONS,
printformat(server, target, level,
IRCTXT_ACTION_PUBLIC, nick, data);
} else {
/* message to not existing/active channel */
printformat(server, target, MSGLEVEL_ACTIONS,
printformat(server, target, level,
IRCTXT_ACTION_PUBLIC_CHANNEL, nick, target, data);
}
} else {
/* private action */
item = (WI_ITEM_REC *) privmsg_get_query(server, nick, FALSE);
printformat(server, nick, MSGLEVEL_ACTIONS,
printformat(server, nick, level,
item == NULL ? IRCTXT_ACTION_PRIVATE : IRCTXT_ACTION_PRIVATE_QUERY,
nick, addr == NULL ? "" : addr, data);
}

View File

@ -178,9 +178,11 @@ static void cmd_me(gchar *data, IRC_SERVER_REC *server, WI_IRC_REC *item)
if (!irc_item_check(item))
return;
if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED);
if (server == NULL || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
printformat(server, item->name, MSGLEVEL_ACTIONS,
printformat(server, item->name, MSGLEVEL_ACTIONS | MSGLEVEL_NOHILIGHT |
(ischannel(*item->name) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS),
IRCTXT_OWN_ME, server->nick, data);
irc_send_cmdv(server, "PRIVMSG %s :\001ACTION %s\001", item->name, data);
@ -192,13 +194,17 @@ static void cmd_action(const char *data, IRC_SERVER_REC *server)
void *free_arg;
g_return_if_fail(data != NULL);
if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED);
if (server == NULL || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, &target, &text))
return;
if (*target == '\0' || *text == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
if (*target == '\0' || *text == '\0')
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
printformat(server, target, MSGLEVEL_ACTIONS, IRCTXT_OWN_ME, server->nick, text);
printformat(server, target, MSGLEVEL_ACTIONS | MSGLEVEL_NOHILIGHT |
(ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS),
IRCTXT_OWN_ME, server->nick, text);
irc_send_cmdv(server, "PRIVMSG %s :\001ACTION %s\001", target, text);
cmd_params_free(free_arg);
}
@ -236,6 +242,12 @@ static void cmd_ctcp(const char *data, IRC_SERVER_REC *server)
return;
if (*target == '\0' || *ctcpcmd == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
if (*target == '=') {
/* don't handle DCC CTCPs */
cmd_params_free(free_arg);
return;
}
if (*target == '@' && ischannel(target[1]))
target++; /* Hybrid 6 feature, send ctcp to all ops in channel */

View File

@ -198,7 +198,7 @@ static void dcc_chat_listen(DCC_REC *dcc)
/* TODO: add paranoia check - see dcc-files.c */
g_source_remove(dcc->tagread);
g_source_remove(dcc->tagconn);
close(dcc->handle);
dcc->starttime = time(NULL);
@ -217,7 +217,6 @@ static void sig_chat_connected(DCC_REC *dcc)
{
g_return_if_fail(dcc != NULL);
g_source_remove(dcc->tagread);
if (net_geterror(dcc->handle) != 0) {
/* error connecting */
signal_emit("dcc error connect", 1, dcc);
@ -226,6 +225,7 @@ static void sig_chat_connected(DCC_REC *dcc)
}
/* connect ok. */
g_source_remove(dcc->tagconn);
dcc->starttime = time(NULL);
dcc->tagread = g_input_add(dcc->handle, G_INPUT_READ,
(GInputFunction) dcc_chat_input, dcc);
@ -245,7 +245,7 @@ static void dcc_chat_connect(DCC_REC *dcc)
dcc->handle = net_connect_ip(&dcc->addr, dcc->port,
source_host_ok ? source_host_ip : NULL);
if (dcc->handle != -1) {
dcc->tagread = g_input_add(dcc->handle, G_INPUT_WRITE|G_INPUT_READ|G_INPUT_EXCEPTION,
dcc->tagconn = g_input_add(dcc->handle, G_INPUT_WRITE|G_INPUT_READ|G_INPUT_EXCEPTION,
(GInputFunction) sig_chat_connected, dcc);
} else {
/* error connecting */
@ -290,7 +290,7 @@ static void cmd_dcc_chat(const char *data, IRC_SERVER_REC *server)
cmd_param_error(CMDERR_ERRNO);
dcc = dcc_create(DCC_TYPE_CHAT, handle, nick, "chat", server, NULL);
dcc->tagread = g_input_add(dcc->handle, G_INPUT_READ,
dcc->tagconn = g_input_add(dcc->handle, G_INPUT_READ,
(GInputFunction) dcc_chat_listen, dcc);
/* send the request */

View File

@ -61,7 +61,7 @@ void dcc_get_send_received(DCC_REC *dcc)
count_buf should be re-sent.. also, if it's 1, 2 or 3, the
last 1-3 bytes should be sent later. these happen probably
never, but I just want to do it right.. :) */
if (dcc->tagwrite != -1) {
if (dcc->tagwrite == -1) {
dcc->tagwrite = g_input_add(dcc->handle, G_INPUT_WRITE,
(GInputFunction) sig_dccget_send, dcc);
}
@ -151,7 +151,6 @@ static void sig_dccget_connected(DCC_REC *dcc)
g_return_if_fail(dcc != NULL);
g_source_remove(dcc->tagread);
if (net_geterror(dcc->handle) != 0) {
/* error connecting */
signal_emit("dcc error connect", 1, dcc);
@ -159,6 +158,8 @@ static void sig_dccget_connected(DCC_REC *dcc)
return;
}
g_source_remove(dcc->tagconn);
g_free_not_null(dcc->file);
dcc->file = dcc_get_download_path(dcc->arg);
@ -196,7 +197,7 @@ static void dcc_get_connect(DCC_REC *dcc)
dcc->handle = net_connect_ip(&dcc->addr, dcc->port,
source_host_ok ? source_host_ip : NULL);
if (dcc->handle != -1) {
dcc->tagread = g_input_add(dcc->handle, G_INPUT_WRITE|G_INPUT_READ|G_INPUT_EXCEPTION,
dcc->tagconn = g_input_add(dcc->handle, G_INPUT_WRITE|G_INPUT_READ|G_INPUT_EXCEPTION,
(GInputFunction) sig_dccget_connected, dcc);
} else {
/* error connecting */
@ -458,7 +459,7 @@ static void dcc_send_init(DCC_REC *dcc)
that the host of the nick who we sent the request matches the
address who connected us. */
g_source_remove(dcc->tagread);
g_source_remove(dcc->tagconn);
close(dcc->handle);
dcc->starttime = time(NULL);
@ -562,7 +563,7 @@ static void cmd_dcc_send(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *i
dcc->port = port;
dcc->size = fsize;
dcc->fhandle = hfile;
dcc->tagread = g_input_add(hlisten, G_INPUT_READ,
dcc->tagconn = g_input_add(hlisten, G_INPUT_READ,
(GInputFunction) dcc_send_init, dcc);
/* send DCC request */

View File

@ -68,7 +68,7 @@ DCC_REC *dcc_create(int type, int handle, const char *nick, const char *arg,
dcc->nick = g_strdup(nick);
dcc->handle = handle;
dcc->fhandle = -1;
dcc->tagread = dcc->tagwrite = -1;
dcc->tagconn = dcc->tagread = dcc->tagwrite = -1;
dcc->server = server;
dcc->mynick = g_strdup(server != NULL ? server->nick :
chat != NULL ? chat->nick : "??");
@ -110,6 +110,7 @@ void dcc_destroy(DCC_REC *dcc)
if (dcc->fhandle != -1) close(dcc->fhandle);
if (dcc->handle != -1) net_disconnect(dcc->handle);
if (dcc->tagconn != -1) g_source_remove(dcc->tagconn);
if (dcc->tagread != -1) g_source_remove(dcc->tagread);
if (dcc->tagwrite != -1) g_source_remove(dcc->tagwrite);

View File

@ -41,7 +41,7 @@ typedef struct DCC_REC {
long size, transfd, skipped; /* file size / bytes transferred / skipped at start */
int handle; /* socket handle */
int tagread, tagwrite;
int tagconn, tagread, tagwrite;
int fhandle; /* file handle */
time_t starttime; /* transfer start time */
int trans_bytes;