mirror of
https://github.com/irssi/irssi.git
synced 2026-08-23 18:42:53 +02:00
commit
4e74fa7284
83 changed files with 1080 additions and 394 deletions
|
|
@ -326,8 +326,11 @@ static void autoconnect_servers(void)
|
|||
|
||||
if (autocon_server != NULL) {
|
||||
/* connect to specified server */
|
||||
str = g_strdup_printf(autocon_password == NULL ? "%s %d" : "%s %d %s",
|
||||
autocon_server, autocon_port, autocon_password);
|
||||
if (autocon_password == NULL)
|
||||
str = g_strdup_printf("%s %d", autocon_server, autocon_port);
|
||||
else
|
||||
str = g_strdup_printf("%s %d %s", autocon_server, autocon_port, autocon_password);
|
||||
|
||||
signal_emit("command connect", 1, str);
|
||||
g_free(str);
|
||||
return;
|
||||
|
|
@ -447,18 +450,7 @@ void fe_common_core_finish_init(void)
|
|||
signal_add_first("setup changed", (SIGNAL_FUNC) sig_setup_changed);
|
||||
|
||||
/* _after_ windows are created.. */
|
||||
#if GLIB_CHECK_VERSION(2,6,0)
|
||||
g_log_set_default_handler((GLogFunc) glog_func, NULL);
|
||||
#else
|
||||
g_log_set_handler(G_LOG_DOMAIN,
|
||||
(GLogLevelFlags) (G_LOG_LEVEL_CRITICAL |
|
||||
G_LOG_LEVEL_WARNING),
|
||||
(GLogFunc) glog_func, NULL);
|
||||
g_log_set_handler("GLib",
|
||||
(GLogLevelFlags) (G_LOG_LEVEL_CRITICAL |
|
||||
G_LOG_LEVEL_WARNING),
|
||||
(GLogFunc) glog_func, NULL); /* send glib errors to the same place */
|
||||
#endif
|
||||
|
||||
if (setup_changed)
|
||||
signal_emit("setup changed", 0);
|
||||
|
|
|
|||
|
|
@ -183,7 +183,9 @@ static void sig_message_public(SERVER_REC *server, const char *msg,
|
|||
nickrec = nicklist_find(chanrec, nick);
|
||||
|
||||
for_me = !settings_get_bool("hilight_nick_matches") ? FALSE :
|
||||
nick_match_msg(chanrec, msg, server->nick);
|
||||
!settings_get_bool("hilight_nick_matches_everywhere") ?
|
||||
nick_match_msg(chanrec, msg, server->nick) :
|
||||
nick_match_msg_everywhere(chanrec, msg, server->nick);
|
||||
hilight = for_me ? NULL :
|
||||
hilight_match_nick(server, target, nick, address, MSGLEVEL_PUBLIC, msg);
|
||||
color = (hilight == NULL) ? NULL : hilight_get_color(hilight);
|
||||
|
|
@ -694,6 +696,7 @@ void fe_messages_init(void)
|
|||
(GCompareFunc) g_direct_equal);
|
||||
|
||||
settings_add_bool("lookandfeel", "hilight_nick_matches", TRUE);
|
||||
settings_add_bool("lookandfeel", "hilight_nick_matches_everywhere", FALSE);
|
||||
settings_add_bool("lookandfeel", "emphasis", TRUE);
|
||||
settings_add_bool("lookandfeel", "emphasis_replace", FALSE);
|
||||
settings_add_bool("lookandfeel", "emphasis_multiword", FALSE);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
#include "fe-windows.h"
|
||||
#include "printtext.h"
|
||||
|
||||
#define MAX_EXPAND_RECURSION 100
|
||||
|
||||
GSList *keyinfos;
|
||||
static GHashTable *keys, *default_keys;
|
||||
|
||||
|
|
@ -171,7 +173,7 @@ KEYINFO_REC *key_info_find(const char *id)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static int expand_key(const char *key, GSList **out);
|
||||
static int expand_key(const char *key, GSList **out, int *limit);
|
||||
|
||||
#define expand_out_char(out, c) \
|
||||
{ \
|
||||
|
|
@ -188,13 +190,17 @@ static int expand_key(const char *key, GSList **out);
|
|||
g_slist_free(out); out = NULL; \
|
||||
}
|
||||
|
||||
static int expand_combo(const char *start, const char *end, GSList **out)
|
||||
static int expand_combo(const char *start, const char *end, GSList **out, int *limit)
|
||||
{
|
||||
KEY_REC *rec;
|
||||
KEYINFO_REC *info;
|
||||
GSList *tmp, *tmp2, *list, *copy, *newout;
|
||||
char *str, *p;
|
||||
|
||||
if ((*limit)-- < 0) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (start == end) {
|
||||
/* single key */
|
||||
expand_out_char(*out, *start);
|
||||
|
|
@ -229,7 +235,7 @@ static int expand_combo(const char *start, const char *end, GSList **out)
|
|||
/* only one way to generate the combo, good */
|
||||
rec = list->data;
|
||||
g_slist_free(list);
|
||||
return expand_key(rec->key, out);
|
||||
return expand_key(rec->key, out, limit);
|
||||
}
|
||||
|
||||
/* multiple ways to generate the combo -
|
||||
|
|
@ -244,7 +250,11 @@ static int expand_combo(const char *start, const char *end, GSList **out)
|
|||
copy = g_slist_append(copy, g_string_new(str->str));
|
||||
}
|
||||
|
||||
if (!expand_key(rec->key, ©)) {
|
||||
if (!expand_key(rec->key, ©, limit)) {
|
||||
if (*limit < 0) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* illegal key combo, remove from list */
|
||||
expand_out_free(copy);
|
||||
} else {
|
||||
|
|
@ -254,7 +264,11 @@ static int expand_combo(const char *start, const char *end, GSList **out)
|
|||
|
||||
rec = list->data;
|
||||
g_slist_free(list);
|
||||
if (!expand_key(rec->key, out)) {
|
||||
if (!expand_key(rec->key, out, limit)) {
|
||||
if (*limit < 0) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* illegal key combo, remove from list */
|
||||
expand_out_free(*out);
|
||||
}
|
||||
|
|
@ -264,12 +278,16 @@ static int expand_combo(const char *start, const char *end, GSList **out)
|
|||
}
|
||||
|
||||
/* Expand key code - returns TRUE if successful. */
|
||||
static int expand_key(const char *key, GSList **out)
|
||||
static int expand_key(const char *key, GSList **out, int *limit)
|
||||
{
|
||||
GSList *tmp;
|
||||
const char *start;
|
||||
int last_hyphen;
|
||||
|
||||
if ((*limit)-- < 0) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* meta-^W^Gf -> ^[-^W-^G-f */
|
||||
start = NULL; last_hyphen = TRUE;
|
||||
for (; *key != '\0'; key++) {
|
||||
|
|
@ -279,7 +297,7 @@ static int expand_key(const char *key, GSList **out)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!expand_combo(start, key-1, out))
|
||||
if (!expand_combo(start, key-1, out, limit))
|
||||
return FALSE;
|
||||
expand_out_char(*out, '-');
|
||||
start = NULL;
|
||||
|
|
@ -332,7 +350,7 @@ static int expand_key(const char *key, GSList **out)
|
|||
}
|
||||
|
||||
if (start != NULL)
|
||||
return expand_combo(start, key-1, out);
|
||||
return expand_combo(start, key-1, out, limit);
|
||||
|
||||
for (tmp = *out; tmp != NULL; tmp = tmp->next) {
|
||||
GString *str = tmp->data;
|
||||
|
|
@ -346,12 +364,13 @@ static int expand_key(const char *key, GSList **out)
|
|||
static void key_states_scan_key(const char *key, KEY_REC *rec)
|
||||
{
|
||||
GSList *tmp, *out;
|
||||
int limit = MAX_EXPAND_RECURSION;
|
||||
|
||||
if (g_strcmp0(rec->info->id, "key") == 0)
|
||||
return;
|
||||
|
||||
out = g_slist_append(NULL, g_string_new(NULL));
|
||||
if (expand_key(key, &out)) {
|
||||
if (expand_key(key, &out, &limit)) {
|
||||
for (tmp = out; tmp != NULL; tmp = tmp->next) {
|
||||
GString *str = tmp->data;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ real_sources = \
|
|||
fe-netsplit.c \
|
||||
fe-common-irc.c \
|
||||
fe-whois.c \
|
||||
fe-sasl.c \
|
||||
irc-completion.c \
|
||||
module-formats.c
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ static void dcc_request(CHAT_DCC_REC *dcc)
|
|||
if (!IS_DCC_CHAT(dcc)) return;
|
||||
|
||||
printformat(dcc->server, NULL, MSGLEVEL_DCC,
|
||||
ischannel(*dcc->target) ? IRCTXT_DCC_CHAT_CHANNEL :
|
||||
server_ischannel(SERVER(dcc->server), dcc->target) ? IRCTXT_DCC_CHAT_CHANNEL :
|
||||
IRCTXT_DCC_CHAT, dcc->id, dcc->addrstr,
|
||||
dcc->port, dcc->target);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include "module.h"
|
||||
#include "signals.h"
|
||||
#include "levels.h"
|
||||
#include "servers.h"
|
||||
|
||||
#include "irc.h"
|
||||
#include "dcc-file.h"
|
||||
|
|
@ -35,12 +36,12 @@ static void dcc_request(GET_DCC_REC *dcc)
|
|||
{
|
||||
char *sizestr;
|
||||
|
||||
if (!IS_DCC_GET(dcc)) return;
|
||||
if (!IS_DCC_GET(dcc)) return;
|
||||
|
||||
sizestr = dcc_get_size_str(dcc->size);
|
||||
|
||||
printformat(dcc->server, NULL, MSGLEVEL_DCC,
|
||||
ischannel(*dcc->target) ? IRCTXT_DCC_SEND_CHANNEL :
|
||||
server_ischannel(SERVER(dcc->server), dcc->target) ? IRCTXT_DCC_SEND_CHANNEL :
|
||||
IRCTXT_DCC_SEND, dcc->nick, dcc->addrstr,
|
||||
dcc->port, dcc->arg, sizestr, dcc->target);
|
||||
|
||||
|
|
|
|||
|
|
@ -28,13 +28,11 @@
|
|||
|
||||
#include "themes.h"
|
||||
#include "fe-irc-server.h"
|
||||
#include "fe-irc-channels.h"
|
||||
|
||||
void fe_irc_modules_init(void);
|
||||
void fe_irc_modules_deinit(void);
|
||||
|
||||
void fe_irc_channels_init(void);
|
||||
void fe_irc_channels_deinit(void);
|
||||
|
||||
void fe_irc_queries_init(void);
|
||||
void fe_irc_queries_deinit(void);
|
||||
|
||||
|
|
@ -71,6 +69,9 @@ void fe_netjoin_deinit(void);
|
|||
void fe_whois_init(void);
|
||||
void fe_whois_deinit(void);
|
||||
|
||||
void fe_sasl_init(void);
|
||||
void fe_sasl_deinit(void);
|
||||
|
||||
void irc_completion_init(void);
|
||||
void irc_completion_deinit(void);
|
||||
|
||||
|
|
@ -93,6 +94,7 @@ void fe_common_irc_init(void)
|
|||
fe_netsplit_init();
|
||||
fe_netjoin_init();
|
||||
fe_whois_init();
|
||||
fe_sasl_init();
|
||||
irc_completion_init();
|
||||
|
||||
settings_check();
|
||||
|
|
@ -118,6 +120,7 @@ void fe_common_irc_deinit(void)
|
|||
fe_netsplit_deinit();
|
||||
fe_netjoin_deinit();
|
||||
fe_whois_deinit();
|
||||
fe_sasl_deinit();
|
||||
irc_completion_deinit();
|
||||
|
||||
theme_unregister();
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ static void ctcp_default_msg(IRC_SERVER_REC *server, const char *data,
|
|||
data = p+1;
|
||||
}
|
||||
|
||||
printformat(server, ischannel(*target) ? target : nick, MSGLEVEL_CTCPS,
|
||||
printformat(server, server_ischannel(SERVER(server), target) ? target : nick, MSGLEVEL_CTCPS,
|
||||
IRCTXT_CTCP_REQUESTED_UNKNOWN,
|
||||
nick, addr, cmd, data, target);
|
||||
g_free(cmd);
|
||||
|
|
@ -113,8 +113,8 @@ static void ctcp_default_reply(IRC_SERVER_REC *server, const char *data,
|
|||
ctcpdata = ptr+1;
|
||||
}
|
||||
|
||||
printformat(server, ischannel(*target) ? target : nick, MSGLEVEL_CTCPS,
|
||||
ischannel(*target) ? IRCTXT_CTCP_REPLY_CHANNEL :
|
||||
printformat(server, server_ischannel(SERVER(server), target) ? target : nick, MSGLEVEL_CTCPS,
|
||||
server_ischannel(SERVER(server), target) ? IRCTXT_CTCP_REPLY_CHANNEL :
|
||||
IRCTXT_CTCP_REPLY, ctcp, nick, ctcpdata, target);
|
||||
g_free(ctcp);
|
||||
}
|
||||
|
|
@ -137,7 +137,7 @@ static void ctcp_ping_reply(IRC_SERVER_REC *server, const char *data,
|
|||
|
||||
g_get_current_time(&tv);
|
||||
usecs = get_timeval_diff(&tv, &tv2);
|
||||
printformat(server, ischannel(*target) ? target : nick, MSGLEVEL_CTCPS,
|
||||
printformat(server, server_ischannel(SERVER(server), target) ? target : nick, MSGLEVEL_CTCPS,
|
||||
IRCTXT_CTCP_PING_REPLY, nick, usecs/1000, usecs%1000);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -400,7 +400,7 @@ static void event_target_unavailable(IRC_SERVER_REC *server, const char *data,
|
|||
g_return_if_fail(data != NULL);
|
||||
|
||||
params = event_get_params(data, 2, NULL, &target);
|
||||
if (!ischannel(*target)) {
|
||||
if (!server_ischannel(SERVER(server), target)) {
|
||||
/* nick unavailable */
|
||||
printformat(server, NULL, MSGLEVEL_CRAP,
|
||||
IRCTXT_NICK_UNAVAILABLE, target);
|
||||
|
|
@ -583,7 +583,7 @@ static void print_event_received(IRC_SERVER_REC *server, const char *data,
|
|||
return;
|
||||
ptr++;
|
||||
|
||||
if (ischannel(*data)) /* directed at channel */
|
||||
if (server_ischannel(SERVER(server), data)) /* directed at channel */
|
||||
target = g_strndup(data, (int)(ptr - data - 1));
|
||||
else if (!target_param || *ptr == ':' || (ptr2 = strchr(ptr, ' ')) == NULL)
|
||||
target = NULL;
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@
|
|||
#include "fe-queries.h"
|
||||
#include "fe-windows.h"
|
||||
#include "fe-irc-server.h"
|
||||
#include "fe-irc-channels.h"
|
||||
|
||||
static void event_privmsg(IRC_SERVER_REC *server, const char *data,
|
||||
const char *nick, const char *addr)
|
||||
|
|
@ -52,15 +53,19 @@ static void event_privmsg(IRC_SERVER_REC *server, const char *data,
|
|||
params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
|
||||
if (nick == NULL) nick = server->real_address;
|
||||
if (addr == NULL) addr = "";
|
||||
if (*target == '@' && ischannel(target[1])) {
|
||||
|
||||
if (fe_channel_is_opchannel(server, target)) {
|
||||
/* Hybrid 6 feature, send msg to all ops in channel */
|
||||
recoded = recode_in(SERVER(server), msg, target+1);
|
||||
const char *cleantarget = fe_channel_skip_prefix(server, target);
|
||||
recoded = recode_in(SERVER(server), msg, cleantarget);
|
||||
|
||||
/* pass the original target to the signal, with the @+ here
|
||||
* the other one is only needed for recode_in*/
|
||||
signal_emit("message irc op_public", 5,
|
||||
server, recoded, nick, addr,
|
||||
get_visible_target(server, target+1));
|
||||
server, recoded, nick, addr, target);
|
||||
} else {
|
||||
recoded = recode_in(SERVER(server), msg, ischannel(*target) ? target : nick);
|
||||
signal_emit(ischannel(*target) ?
|
||||
recoded = recode_in(SERVER(server), msg, server_ischannel(SERVER(server), target) ? target : nick);
|
||||
signal_emit(server_ischannel(SERVER(server), target) ?
|
||||
"message public" : "message private", 5,
|
||||
server, recoded, nick, addr,
|
||||
get_visible_target(server, target));
|
||||
|
|
|
|||
|
|
@ -31,6 +31,51 @@
|
|||
#include "fe-windows.h"
|
||||
#include "window-items.h"
|
||||
|
||||
int fe_channel_is_opchannel(IRC_SERVER_REC *server, const char *target)
|
||||
{
|
||||
const char *statusmsg;
|
||||
|
||||
/* Quick check */
|
||||
if (server == NULL || server->prefix[(int)(unsigned char)*target] == 0)
|
||||
return FALSE;
|
||||
|
||||
statusmsg = g_hash_table_lookup(server->isupport, "statusmsg");
|
||||
if (statusmsg == NULL)
|
||||
statusmsg = "@+";
|
||||
|
||||
return strchr(statusmsg, *target) != NULL;
|
||||
}
|
||||
|
||||
const char *fe_channel_skip_prefix(IRC_SERVER_REC *server, const char *target)
|
||||
{
|
||||
const char *statusmsg;
|
||||
|
||||
/* Quick check */
|
||||
if (server == NULL || server->prefix[(int)(unsigned char)*target] == 0)
|
||||
return target;
|
||||
|
||||
/* Exit early if target doesn't name a channel */
|
||||
if (server_ischannel(SERVER(server), target) == FALSE)
|
||||
return target;
|
||||
|
||||
statusmsg = g_hash_table_lookup(server->isupport, "statusmsg");
|
||||
|
||||
/* Hack: for bahamut 1.4 which sends neither STATUSMSG nor
|
||||
* WALLCHOPS in 005, accept @#chan and @+#chan (but not +#chan) */
|
||||
if (statusmsg == NULL && *target != '@')
|
||||
return target;
|
||||
|
||||
if (statusmsg == NULL)
|
||||
statusmsg = "@+";
|
||||
|
||||
/* Strip the leading statusmsg prefixes */
|
||||
while (strchr(statusmsg, *target) != NULL) {
|
||||
target++;
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
static void sig_channel_rejoin(SERVER_REC *server, REJOIN_REC *rec)
|
||||
{
|
||||
g_return_if_fail(rec != NULL);
|
||||
|
|
@ -46,7 +91,7 @@ static void sig_event_forward(SERVER_REC *server, const char *data,
|
|||
char *params, *from, *to;
|
||||
|
||||
params = event_get_params(data, 3, NULL, &from, &to);
|
||||
if (from != NULL && to != NULL && ischannel(*from) && ischannel(*to)) {
|
||||
if (from != NULL && to != NULL && server_ischannel(server, from) && server_ischannel(server, to)) {
|
||||
channel = irc_channel_find(server, from);
|
||||
if (channel != NULL && irc_channel_find(server, to) == NULL) {
|
||||
window_bind_add(window_item_window(channel),
|
||||
|
|
|
|||
10
src/fe-common/irc/fe-irc-channels.h
Normal file
10
src/fe-common/irc/fe-irc-channels.h
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef __FE_IRC_CHANNELS_H
|
||||
#define __FE_IRC_CHANNELS_H
|
||||
|
||||
int fe_channel_is_opchannel(IRC_SERVER_REC *server, const char *target);
|
||||
const char *fe_channel_skip_prefix(IRC_SERVER_REC *server, const char *target);
|
||||
|
||||
void fe_irc_channels_init(void);
|
||||
void fe_irc_channels_deinit(void);
|
||||
|
||||
#endif
|
||||
|
|
@ -36,32 +36,8 @@
|
|||
|
||||
#include "fe-queries.h"
|
||||
#include "window-items.h"
|
||||
|
||||
static const char *skip_target(IRC_SERVER_REC *server, const char *target)
|
||||
{
|
||||
int i = 0;
|
||||
const char *val, *chars;
|
||||
|
||||
/* Quick check */
|
||||
if (server == NULL || server->prefix[(int)(unsigned char)*target] == 0)
|
||||
return target;
|
||||
|
||||
/* Hack: for bahamut 1.4 which sends neither STATUSMSG nor
|
||||
* WALLCHOPS in 005, accept @#chan and @+#chan (but not +#chan) */
|
||||
val = g_hash_table_lookup(server->isupport, "STATUSMSG");
|
||||
if (val == NULL && *target != '@')
|
||||
return target;
|
||||
chars = val ? val : "@+";
|
||||
for(i = 0; target[i] != '\0'; i++) {
|
||||
if (strchr(chars, target[i]) == NULL)
|
||||
break;
|
||||
};
|
||||
|
||||
if(ischannel(target[i]))
|
||||
target += i;
|
||||
|
||||
return target;
|
||||
}
|
||||
#include "fe-irc-channels.h"
|
||||
#include "fe-irc-server.h"
|
||||
|
||||
static void sig_message_own_public(SERVER_REC *server, const char *msg,
|
||||
const char *target, const char *origtarget)
|
||||
|
|
@ -72,7 +48,7 @@ static void sig_message_own_public(SERVER_REC *server, const char *msg,
|
|||
if (!IS_IRC_SERVER(server))
|
||||
return;
|
||||
oldtarget = target;
|
||||
target = skip_target(IRC_SERVER(server), target);
|
||||
target = fe_channel_skip_prefix(IRC_SERVER(server), target);
|
||||
if (target != oldtarget) {
|
||||
/* Hybrid 6 / Bahamut feature, send msg to all
|
||||
ops / ops+voices in channel */
|
||||
|
|
@ -95,18 +71,28 @@ static void sig_message_irc_op_public(SERVER_REC *server, const char *msg,
|
|||
const char *nick, const char *address,
|
||||
const char *target)
|
||||
{
|
||||
char *nickmode, *optarget;
|
||||
char *nickmode, *optarget, *prefix;
|
||||
const char *cleantarget;
|
||||
|
||||
nickmode = channel_get_nickmode(channel_find(server, target),
|
||||
/* only skip here so the difference can be stored in prefix */
|
||||
cleantarget = fe_channel_skip_prefix(IRC_SERVER(server), target);
|
||||
prefix = g_strndup(target, cleantarget - target);
|
||||
|
||||
/* and clean the rest here */
|
||||
cleantarget = get_visible_target(IRC_SERVER(server), cleantarget);
|
||||
|
||||
nickmode = channel_get_nickmode(channel_find(server, cleantarget),
|
||||
nick);
|
||||
|
||||
optarget = g_strconcat("@", target, NULL);
|
||||
printformat_module("fe-common/core", server, target,
|
||||
optarget = g_strconcat(prefix, cleantarget, NULL);
|
||||
|
||||
printformat_module("fe-common/core", server, cleantarget,
|
||||
MSGLEVEL_PUBLIC,
|
||||
TXT_PUBMSG_CHANNEL,
|
||||
nick, optarget, msg, nickmode);
|
||||
g_free(nickmode);
|
||||
g_free(optarget);
|
||||
g_free(optarget);
|
||||
g_free(prefix);
|
||||
}
|
||||
|
||||
static void sig_message_own_wall(SERVER_REC *server, const char *msg,
|
||||
|
|
@ -117,7 +103,8 @@ static void sig_message_own_wall(SERVER_REC *server, const char *msg,
|
|||
nickmode = channel_get_nickmode(channel_find(server, target),
|
||||
server->nick);
|
||||
|
||||
optarget = g_strconcat("@", target, NULL);
|
||||
/* this is always @, skip_prefix is not needed here */
|
||||
optarget = g_strconcat("@", target, NULL);
|
||||
printformat_module("fe-common/core", server, target,
|
||||
MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT |
|
||||
MSGLEVEL_NO_ACT,
|
||||
|
|
@ -135,8 +122,8 @@ static void sig_message_own_action(IRC_SERVER_REC *server, const char *msg,
|
|||
char *freemsg = NULL;
|
||||
|
||||
oldtarget = target;
|
||||
target = skip_target(IRC_SERVER(server), target);
|
||||
if (ischannel(*target))
|
||||
target = fe_channel_skip_prefix(IRC_SERVER(server), target);
|
||||
if (server_ischannel(SERVER(server), target))
|
||||
item = irc_channel_find(server, target);
|
||||
else
|
||||
item = irc_query_find(server, target);
|
||||
|
|
@ -146,7 +133,7 @@ static void sig_message_own_action(IRC_SERVER_REC *server, const char *msg,
|
|||
|
||||
printformat(server, target,
|
||||
MSGLEVEL_ACTIONS | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT |
|
||||
(ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS),
|
||||
(server_ischannel(SERVER(server), target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS),
|
||||
item != NULL && oldtarget == target ? IRCTXT_OWN_ACTION : IRCTXT_OWN_ACTION_TARGET,
|
||||
server->nick, msg, oldtarget);
|
||||
g_free_not_null(freemsg);
|
||||
|
|
@ -163,10 +150,10 @@ static void sig_message_irc_action(IRC_SERVER_REC *server, const char *msg,
|
|||
int own = FALSE;
|
||||
|
||||
oldtarget = target;
|
||||
target = skip_target(IRC_SERVER(server), target);
|
||||
target = fe_channel_skip_prefix(IRC_SERVER(server), target);
|
||||
|
||||
level = MSGLEVEL_ACTIONS |
|
||||
(ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS);
|
||||
(server_ischannel(SERVER(server), target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS);
|
||||
|
||||
if (ignore_check(SERVER(server), nick, address, target, msg, level))
|
||||
return;
|
||||
|
|
@ -175,7 +162,7 @@ static void sig_message_irc_action(IRC_SERVER_REC *server, const char *msg,
|
|||
level | MSGLEVEL_NO_ACT))
|
||||
level |= MSGLEVEL_NO_ACT;
|
||||
|
||||
if (ischannel(*target)) {
|
||||
if (server_ischannel(SERVER(server), target)) {
|
||||
item = irc_channel_find(server, target);
|
||||
} else {
|
||||
own = (!g_strcmp0(nick, server->nick));
|
||||
|
|
@ -185,7 +172,7 @@ static void sig_message_irc_action(IRC_SERVER_REC *server, const char *msg,
|
|||
if (settings_get_bool("emphasis"))
|
||||
msg = freemsg = expand_emphasis(item, msg);
|
||||
|
||||
if (ischannel(*target)) {
|
||||
if (server_ischannel(SERVER(server), target)) {
|
||||
/* channel action */
|
||||
if (window_item_is_active(item) && target == oldtarget) {
|
||||
/* message to active channel in window */
|
||||
|
|
@ -219,7 +206,7 @@ static void sig_message_irc_action(IRC_SERVER_REC *server, const char *msg,
|
|||
static void sig_message_own_notice(IRC_SERVER_REC *server, const char *msg,
|
||||
const char *target)
|
||||
{
|
||||
printformat(server, skip_target(server, target), MSGLEVEL_NOTICES |
|
||||
printformat(server, fe_channel_skip_prefix(server, target), MSGLEVEL_NOTICES |
|
||||
MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
|
||||
IRCTXT_OWN_NOTICE, target, msg);
|
||||
}
|
||||
|
|
@ -232,7 +219,7 @@ static void sig_message_irc_notice(SERVER_REC *server, const char *msg,
|
|||
int level = MSGLEVEL_NOTICES;
|
||||
|
||||
oldtarget = target;
|
||||
target = skip_target(IRC_SERVER(server), target);
|
||||
target = fe_channel_skip_prefix(IRC_SERVER(server), target);
|
||||
|
||||
if (address == NULL || *address == '\0') {
|
||||
/* notice from server */
|
||||
|
|
@ -245,16 +232,16 @@ static void sig_message_irc_notice(SERVER_REC *server, const char *msg,
|
|||
}
|
||||
|
||||
if (ignore_check(server, nick, address,
|
||||
ischannel(*target) ? target : NULL,
|
||||
server_ischannel(SERVER(server), target) ? target : NULL,
|
||||
msg, level))
|
||||
return;
|
||||
|
||||
if (ignore_check(server, nick, address,
|
||||
ischannel(*target) ? target : NULL,
|
||||
server_ischannel(SERVER(server), target) ? target : NULL,
|
||||
msg, level | MSGLEVEL_NO_ACT))
|
||||
level |= MSGLEVEL_NO_ACT;
|
||||
|
||||
if (ischannel(*target)) {
|
||||
if (server_ischannel(SERVER(server), target)) {
|
||||
/* notice in some channel */
|
||||
printformat(server, target, level,
|
||||
IRCTXT_NOTICE_PUBLIC, nick, oldtarget, msg);
|
||||
|
|
@ -270,7 +257,7 @@ static void sig_message_irc_notice(SERVER_REC *server, const char *msg,
|
|||
static void sig_message_own_ctcp(IRC_SERVER_REC *server, const char *cmd,
|
||||
const char *data, const char *target)
|
||||
{
|
||||
printformat(server, skip_target(server, target), MSGLEVEL_CTCPS |
|
||||
printformat(server, fe_channel_skip_prefix(server, target), MSGLEVEL_CTCPS |
|
||||
MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
|
||||
IRCTXT_OWN_CTCP, target, cmd, data);
|
||||
}
|
||||
|
|
@ -282,8 +269,8 @@ static void sig_message_irc_ctcp(IRC_SERVER_REC *server, const char *cmd,
|
|||
const char *oldtarget;
|
||||
|
||||
oldtarget = target;
|
||||
target = skip_target(server, target);
|
||||
printformat(server, ischannel(*target) ? target : nick, MSGLEVEL_CTCPS,
|
||||
target = fe_channel_skip_prefix(server, target);
|
||||
printformat(server, server_ischannel(SERVER(server), target) ? target : nick, MSGLEVEL_CTCPS,
|
||||
IRCTXT_CTCP_REQUESTED, nick, addr, cmd, data, oldtarget);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ static void event_privmsg(SERVER_REC *server, const char *data,
|
|||
|
||||
g_return_if_fail(data != NULL);
|
||||
|
||||
if (nick == NULL || address == NULL || ischannel(*data) ||
|
||||
if (nick == NULL || address == NULL || server_ischannel(server, data) ||
|
||||
!settings_get_bool("query_track_nick_changes"))
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,12 @@ static void cmd_network_list(void)
|
|||
g_string_append_printf(str, "autosendcmd: %s, ", rec->autosendcmd);
|
||||
if (rec->usermode != NULL)
|
||||
g_string_append_printf(str, "usermode: %s, ", rec->usermode);
|
||||
|
||||
if (rec->sasl_mechanism != NULL)
|
||||
g_string_append_printf(str, "sasl_mechanism: %s, ", rec->sasl_mechanism);
|
||||
if (rec->sasl_username != NULL)
|
||||
g_string_append_printf(str, "sasl_username: %s, ", rec->sasl_username);
|
||||
if (rec->sasl_password != NULL)
|
||||
g_string_append_printf(str, "sasl_password: (pass), ");
|
||||
if (rec->cmd_queue_speed > 0)
|
||||
g_string_append_printf(str, "cmdspeed: %d, ", rec->cmd_queue_speed);
|
||||
if (rec->max_cmds_at_once > 0)
|
||||
|
|
@ -82,10 +87,12 @@ static void cmd_network_list(void)
|
|||
}
|
||||
|
||||
/* SYNTAX: NETWORK ADD [-nick <nick>] [-user <user>] [-realname <name>]
|
||||
[-host <host>] [-usermode <mode>] [-autosendcmd <cmd>]
|
||||
[-querychans <count>] [-whois <count>] [-msgs <count>]
|
||||
[-kicks <count>] [-modes <count>]
|
||||
[-cmdspeed <ms>] [-cmdmax <count>] <name> */
|
||||
[-host <host>] [-usermode <mode>] [-autosendcmd <cmd>]
|
||||
[-querychans <count>] [-whois <count>] [-msgs <count>]
|
||||
[-kicks <count>] [-modes <count>] [-cmdspeed <ms>]
|
||||
[-cmdmax <count>] [-sasl_mechanism <mechanism>]
|
||||
[-sasl_username <username>] [-sasl_password <password>]
|
||||
<name> */
|
||||
static void cmd_network_add(const char *data)
|
||||
{
|
||||
GHashTable *optlist;
|
||||
|
|
@ -112,6 +119,9 @@ static void cmd_network_add(const char *data)
|
|||
}
|
||||
if (g_hash_table_lookup(optlist, "usermode")) g_free_and_null(rec->usermode);
|
||||
if (g_hash_table_lookup(optlist, "autosendcmd")) g_free_and_null(rec->autosendcmd);
|
||||
if (g_hash_table_lookup(optlist, "sasl_mechanism")) g_free_and_null(rec->sasl_mechanism);
|
||||
if (g_hash_table_lookup(optlist, "sasl_username")) g_free_and_null(rec->sasl_username);
|
||||
if (g_hash_table_lookup(optlist, "sasl_password")) g_free_and_null(rec->sasl_password);
|
||||
}
|
||||
|
||||
value = g_hash_table_lookup(optlist, "kicks");
|
||||
|
|
@ -148,6 +158,14 @@ static void cmd_network_add(const char *data)
|
|||
value = g_hash_table_lookup(optlist, "autosendcmd");
|
||||
if (value != NULL && *value != '\0') rec->autosendcmd = g_strdup(value);
|
||||
|
||||
/* the validity of the parameters is checked in sig_server_setup_fill_chatnet */
|
||||
value = g_hash_table_lookup(optlist, "sasl_mechanism");
|
||||
if (value != NULL && *value != '\0') rec->sasl_mechanism = g_strdup(value);
|
||||
value = g_hash_table_lookup(optlist, "sasl_username");
|
||||
if (value != NULL && *value != '\0') rec->sasl_username = g_strdup(value);
|
||||
value = g_hash_table_lookup(optlist, "sasl_password");
|
||||
if (value != NULL && *value != '\0') rec->sasl_password = g_strdup(value);
|
||||
|
||||
ircnet_create(rec);
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_NETWORK_ADDED, name);
|
||||
|
||||
|
|
@ -186,7 +204,8 @@ void fe_ircnet_init(void)
|
|||
command_bind("network add", NULL, (SIGNAL_FUNC) cmd_network_add);
|
||||
command_bind("network remove", NULL, (SIGNAL_FUNC) cmd_network_remove);
|
||||
|
||||
command_set_options("network add", "-kicks -msgs -modes -whois -cmdspeed -cmdmax -nick -user -realname -host -autosendcmd -querychans -usermode");
|
||||
command_set_options("network add", "-kicks -msgs -modes -whois -cmdspeed "
|
||||
"-cmdmax -nick -user -realname -host -autosendcmd -querychans -usermode -sasl_mechanism -sasl_username -sasl_password");
|
||||
}
|
||||
|
||||
void fe_ircnet_deinit(void)
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ static void sig_message_mode(IRC_SERVER_REC *server, const char *channel,
|
|||
mode, MSGLEVEL_MODES))
|
||||
return;
|
||||
|
||||
if (!ischannel(*channel)) {
|
||||
if (!server_ischannel(SERVER(server), channel)) {
|
||||
/* user mode change */
|
||||
printformat(server, NULL, MSGLEVEL_MODES,
|
||||
IRCTXT_USERMODE_CHANGE, mode, channel);
|
||||
|
|
|
|||
|
|
@ -400,7 +400,7 @@ static void msg_mode(IRC_SERVER_REC *server, const char *channel,
|
|||
int show;
|
||||
|
||||
g_return_if_fail(data != NULL);
|
||||
if (!ischannel(*channel) || addr != NULL)
|
||||
if (!server_ischannel(SERVER(server), channel) || addr != NULL)
|
||||
return;
|
||||
|
||||
params = event_get_params(data, 2 | PARAM_FLAG_GETREST,
|
||||
|
|
|
|||
48
src/fe-common/irc/fe-sasl.c
Normal file
48
src/fe-common/irc/fe-sasl.c
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
fe-sasl.c : irssi
|
||||
|
||||
Copyright (C) 2015 The Lemon Man
|
||||
|
||||
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.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "module.h"
|
||||
#include "module-formats.h"
|
||||
#include "signals.h"
|
||||
#include "levels.h"
|
||||
|
||||
#include "printtext.h"
|
||||
|
||||
static void sig_sasl_success(IRC_SERVER_REC *server)
|
||||
{
|
||||
printformat(server, NULL, MSGLEVEL_CRAP, IRCTXT_SASL_SUCCESS);
|
||||
}
|
||||
|
||||
static void sig_sasl_failure(IRC_SERVER_REC *server, const char *reason)
|
||||
{
|
||||
printformat(server, NULL, MSGLEVEL_CRAP, IRCTXT_SASL_ERROR, reason);
|
||||
}
|
||||
|
||||
void fe_sasl_init(void)
|
||||
{
|
||||
signal_add("server sasl success", (SIGNAL_FUNC) sig_sasl_success);
|
||||
signal_add("server sasl failure", (SIGNAL_FUNC) sig_sasl_failure);
|
||||
}
|
||||
|
||||
void fe_sasl_deinit(void)
|
||||
{
|
||||
signal_remove("server sasl success", (SIGNAL_FUNC) sig_sasl_success);
|
||||
signal_remove("server sasl failure", (SIGNAL_FUNC) sig_sasl_failure);
|
||||
}
|
||||
|
|
@ -44,6 +44,8 @@ FORMAT_REC fecommon_irc_formats[] = {
|
|||
{ "setupserver_header", "%#Server Port Network Settings", 0 },
|
||||
{ "setupserver_line", "%#%|$[!20]0 $[5]1 $[10]2 $3", 4, { 0, 1, 0, 0 } },
|
||||
{ "setupserver_footer", "", 0 },
|
||||
{ "sasl_success", "SASL authentication succeeded", 0 },
|
||||
{ "sasl_error", "Cannot authenticate via SASL ($0)", 1, { 0 } },
|
||||
|
||||
/* ---- */
|
||||
{ NULL, "Channels", 0 },
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ enum {
|
|||
IRCTXT_SETUPSERVER_HEADER,
|
||||
IRCTXT_SETUPSERVER_LINE,
|
||||
IRCTXT_SETUPSERVER_FOOTER,
|
||||
IRCTXT_SASL_SUCCESS,
|
||||
IRCTXT_SASL_ERROR,
|
||||
|
||||
IRCTXT_FILL_2,
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue