Replace 'hook' and 'noisy' flags in functions downstream of send_text() with !(stxt_flags & STXT_QUIET)

This is in preparation for consolidating the various send_text() options into one set of consistent flags.
This commit is contained in:
Kevin Easton
2017-07-07 15:16:12 +10:00
parent 2c8671f3dd
commit 2d0b3e728f
5 changed files with 25 additions and 21 deletions

View File

@@ -141,7 +141,7 @@ struct dcc_offer {
int dcc_activechat(char *); /* identify all active chat dcc's */
int dcc_activebot(char *); /* identify all active bot's */
int dcc_activeraw(char *); /* identify all active raw connects */
void dcc_chat_transmit(char *, char *, char *, char *, int);
void dcc_chat_transmit(char *, char *, char *, char *, unsigned);
void dcc_bot_transmit(char *, char *, char *);
void dcc_raw_transmit(char *, char *, char *);

View File

@@ -165,6 +165,10 @@ extern char thing_star[4];
#define MAX(a,b) ((a > b) ? (a) : (b))
#endif
/* send_text flag values */
#define STXT_NOTICE 0x0001U
#define STXT_QUIET 0x0002U
/* This section is for keeping track internally
* the CVS revision info of the running client.
* Since so many people are using CVS versions

View File

@@ -3752,7 +3752,7 @@ static int recursion = 0;
from_server = old_from_server;
}
static int try_send_special_target(char *target, const char *text, char *command, int hook)
static int try_send_special_target(char *target, const char *text, char *command, unsigned stxt_flags)
{
/*
* It is legal to send an empty line to a process, but not legal
@@ -3816,8 +3816,8 @@ static int try_send_special_target(char *target, const char *text, char *command
from_server = -1;
if (dcc_activechat(target+1))
{
dcc_chat_transmit(target + 1, line, line, command, hook);
if (hook)
dcc_chat_transmit(target + 1, line, line, command, stxt_flags);
if (!(stxt_flags & STXT_QUIET))
addtabkey(target, "msg", 0);
}
else if (dcc_activebot(target + 1))
@@ -3871,6 +3871,7 @@ int current_target = 0;
void BX_send_text(const char *nick_list, const char *text, char *command, int hook, int log)
{
static int sent_text_recursion = 0;
unsigned flags = hook ? 0 : STXT_QUIET;
int i,
done_forward = 0,
@@ -3901,9 +3902,10 @@ void BX_send_text(const char *nick_list, const char *text, char *command, int h
target[3].format_encrypted = fget_string_var(FORMAT_SEND_ENCRYPTED_NOTICE_FSET);
if (sent_text_recursion)
hook = 0;
window_display = hook;
flags |= STXT_QUIET;
sent_text_recursion++;
window_display = !(flags & STXT_QUIET);
free_nick = next_nick = m_strdup(nick_list);
while ((current_nick = next_nick))
@@ -3916,7 +3918,7 @@ void BX_send_text(const char *nick_list, const char *text, char *command, int h
if (!*current_nick)
continue;
if (try_send_special_target(current_nick, text, command, hook))
if (try_send_special_target(current_nick, text, command, flags))
continue;
/*
@@ -3933,7 +3935,7 @@ void BX_send_text(const char *nick_list, const char *text, char *command, int h
continue;
}
if (!(i = is_channel(current_nick)) && hook)
if (!(i = is_channel(current_nick)) && !(flags & STXT_QUIET))
addtabkey(current_nick, "msg", 0);
if (command && !strcmp(command, "NOTICE"))
@@ -3944,7 +3946,7 @@ void BX_send_text(const char *nick_list, const char *text, char *command, int h
set_display_target(current_nick, target[i].level);
line = sed_encrypt_msg(text, key);
if (hook && do_hook(target[i].hook_type, "%s %s", current_nick, text))
if (!(flags & STXT_QUIET) && do_hook(target[i].hook_type, "%s %s", current_nick, text))
put_it("%s", convert_output_format(target[i].format_encrypted,
"%s %s %s %s", update_clock(GET_TIME), current_nick, get_server_nickname(from_server), text));
@@ -4004,7 +4006,7 @@ void BX_send_text(const char *nick_list, const char *text, char *command, int h
else
is_current = 1;
if (hook && (blah_hook = do_hook(target[i].hook_type, "%s %s", target[i].nick_list, text)))
if (!(flags & STXT_QUIET) && (blah_hook = do_hook(target[i].hook_type, "%s %s", target[i].nick_list, text)))
;
/* supposedly if this is called before the do_hook
* it can cause a problem with scripts.
@@ -4033,7 +4035,7 @@ void BX_send_text(const char *nick_list, const char *text, char *command, int h
restore_display_target(old_mf, old_ml);
}
if (hook && get_server_away(from_server) && get_int_var(AUTO_UNMARK_AWAY_VAR))
if (!(flags & STXT_QUIET) && get_server_away(from_server) && get_int_var(AUTO_UNMARK_AWAY_VAR))
parse_line(NULL, "AWAY", empty_string, 0, 0, 1);
new_free(&free_nick);

View File

@@ -955,9 +955,7 @@ SocketList *sl;
}
#endif
/* flag == 1 means show it. flag == 0 used by redirect (and /ctcp) */
static void new_dcc_message_transmit (char *user, char *text, char *text_display, int type, int flag, char *cmd, int check_host)
static void new_dcc_message_transmit (char *user, char *text, char *text_display, int type, unsigned stxt_flags, char *cmd, int check_host)
{
SocketList *s = NULL;
DCC_int *n = NULL;
@@ -1023,14 +1021,14 @@ char thing = 0;
write(s->is_read, tmp, len);
n->bytes_sent += len;
if (flag && type != DCC_RAW)
if (!(stxt_flags & STXT_QUIET) && type != DCC_RAW)
{
if (do_hook(list, "%s %s", user, text_display ? text_display : text))
put_it("%s", convert_output_format(fget_string_var(FORMAT_SEND_DCC_CHAT_FSET), "%c %s %s", thing, user, text_display?text_display:text));
}
}
extern void dcc_chat_transmit (char *user, char *text, char *orig, char *type, int noisy)
extern void dcc_chat_transmit (char *user, char *text, char *orig, char *type, unsigned stxt_flags)
{
int fd;
@@ -1058,23 +1056,23 @@ extern void dcc_chat_transmit (char *user, char *text, char *orig, char *type, i
strcat(bogus, space);
strcat(bogus, text);
new_dcc_message_transmit(user, bogus, orig, DCC_RAW, noisy, type, 0);
new_dcc_message_transmit(user, bogus, orig, DCC_RAW, stxt_flags, type, 0);
}
else
new_dcc_message_transmit(user, text, orig, DCC_CHAT, noisy, type, 0);
new_dcc_message_transmit(user, text, orig, DCC_CHAT, stxt_flags, type, 0);
reset_display_target();
}
extern void dcc_bot_transmit (char *user, char *text, char *type)
{
set_display_target(user, LOG_DCC);
new_dcc_message_transmit(user, text, NULL, DCC_BOTMODE, 0, type, 1);
new_dcc_message_transmit(user, text, NULL, DCC_BOTMODE, STXT_QUIET, type, 1);
reset_display_target();
}
extern void dcc_chat_transmit_quiet (char *user, char *text, char *type)
{
new_dcc_message_transmit(user, text, NULL, DCC_CHAT, 0, type, 0);
new_dcc_message_transmit(user, text, NULL, DCC_CHAT, STXT_QUIET, type, 0);
}
int dcc_activechat(char *user)

View File

@@ -1250,7 +1250,7 @@ char *new_str;
else
put_it("%s", convert_output_format(fget_string_var(FORMAT_SEND_MSG_FSET), "%s %s %s %s", update_clock(GET_TIME), to, get_server_nickname(from_server), new_str));
if ((*to == '=') && dcc_activechat(to+1))
dcc_chat_transmit(to+1, new_str, new_str, "PRIVMSG", 1);
dcc_chat_transmit(to+2, new_str, new_str, "PRIVMSG", 0);
else
send_to_server("PRIVMSG %s :%s", to, new_str);
break;