TingPing 2015-01-30 22:08:15 -05:00
parent c5d8f59c73
commit d8759a7982
6 changed files with 75 additions and 22 deletions

View File

@ -93,6 +93,7 @@ ctcp_handle (session *sess, char *to, char *nick, char *ip,
server *serv = sess->server; server *serv = sess->server;
char outbuf[1024]; char outbuf[1024];
int ctcp_offset = 2; int ctcp_offset = 2;
gboolean fromme = FALSE;
if (serv->have_idmsg && (word[4][1] == '+' || word[4][1] == '-') ) if (serv->have_idmsg && (word[4][1] == '+' || word[4][1] == '-') )
ctcp_offset = 3; ctcp_offset = 3;
@ -129,7 +130,10 @@ ctcp_handle (session *sess, char *to, char *nick, char *ip,
if (ctcp_check (sess, nick, word, word_eol, word[4] + ctcp_offset)) if (ctcp_check (sess, nick, word, word_eol, word[4] + ctcp_offset))
goto generic; goto generic;
inbound_action (sess, to, nick, ip, msg + 7, FALSE, id, tags_data); if (!serv->p_cmp (nick, serv->nick))
fromme = TRUE;
inbound_action (sess, to, nick, ip, msg + 7, fromme, FALSE, id, tags_data);
return; return;
} }

View File

@ -549,10 +549,10 @@ dcc_chat_line (struct DCC *dcc, char *line)
if (po) if (po)
po[0] = 0; po[0] = 0;
inbound_action (sess, dcc->serv->nick, dcc->nick, "", line + 8, FALSE, inbound_action (sess, dcc->serv->nick, dcc->nick, "", line + 8, FALSE,
FALSE, &no_tags); TRUE, FALSE, &no_tags);
} else } else
{ {
inbound_privmsg (dcc->serv, dcc->nick, "", line, FALSE, &no_tags); inbound_privmsg (dcc->serv, dcc->nick, NULL, "", line, FALSE, &no_tags);
} }
g_free (line); g_free (line);
return 0; return 0;

View File

@ -154,17 +154,24 @@ inbound_make_idtext (server *serv, char *idtext, int max, int id)
} }
void void
inbound_privmsg (server *serv, char *from, char *ip, char *text, int id, inbound_privmsg (server *serv, char *from, char *to, char *ip, char *text, int id,
const message_tags_data *tags_data) const message_tags_data *tags_data)
{ {
session *sess; session *sess;
struct User *user; struct User *user;
char idtext[64]; char idtext[64];
gboolean nodiag = FALSE; char *destsess = from;
gboolean nodiag = FALSE, fromme = FALSE;
if (to && !serv->p_cmp (from, serv->nick))
{
fromme = TRUE;
destsess = to;
}
sess = find_dialog (serv, from); sess = find_dialog (serv, from);
if (sess || prefs.hex_gui_autoopen_dialog) if (!fromme && (sess || prefs.hex_gui_autoopen_dialog))
{ {
/*0=ctcp 1=priv will set hex_gui_autoopen_dialog=0 here is flud detected */ /*0=ctcp 1=priv will set hex_gui_autoopen_dialog=0 here is flud detected */
if (!sess) if (!sess)
@ -196,8 +203,15 @@ inbound_privmsg (server *serv, char *from, char *ip, char *text, int id,
sess = find_dialog (serv, destsess); sess = find_dialog (serv, destsess);
if (!sess) if (!sess)
{ {
sess = serv->front_session; if (fromme && prefs.hex_gui_autoopen_dialog)
nodiag = TRUE; /* We don't want it to look like a normal message in front sess */ {
sess = inbound_open_dialog (serv, destsess, tags_data);
}
else
{
sess = serv->front_session;
nodiag = TRUE; /* We don't want it to look like a normal message in front sess */
}
} }
user = userlist_find (sess, from); user = userlist_find (sess, from);
@ -210,7 +224,16 @@ inbound_privmsg (server *serv, char *from, char *ip, char *text, int id,
inbound_make_idtext (serv, idtext, sizeof (idtext), id); inbound_make_idtext (serv, idtext, sizeof (idtext), id);
if (sess->type == SESS_DIALOG && !nodiag) if (fromme)
{
if (sess->type == SESS_DIALOG)
EMIT_SIGNAL_TIMESTAMP (XP_TE_UCHANMSG, sess, from, text, NULL, idtext, 0,
tags_data->timestamp);
else
EMIT_SIGNAL_TIMESTAMP (XP_TE_MSGSEND, sess, to, text, NULL, NULL, 0,
tags_data->timestamp);
}
else if (sess->type == SESS_DIALOG && !nodiag)
EMIT_SIGNAL_TIMESTAMP (XP_TE_DPRIVMSG, sess, from, text, idtext, NULL, 0, EMIT_SIGNAL_TIMESTAMP (XP_TE_DPRIVMSG, sess, from, text, idtext, NULL, 0,
tags_data->timestamp); tags_data->timestamp);
else else
@ -329,15 +352,19 @@ is_hilight (char *from, char *text, session *sess, server *serv)
void void
inbound_action (session *sess, char *chan, char *from, char *ip, char *text, inbound_action (session *sess, char *chan, char *from, char *ip, char *text,
int fromme, int id, const message_tags_data *tags_data) int fromme, gboolean fake, int id, const message_tags_data *tags_data)
{ {
server *serv = sess->server; server *serv = sess->server;
struct User *user; struct User *user;
char nickchar[2] = "\000"; char nickchar[2] = "\000";
char idtext[64]; char idtext[64];
int privaction = FALSE; int privaction = FALSE;
char *destsess = from;
if (!fromme) if (fromme)
destsess = chan;
if (!fake) /* Fake events start in the correct sess. */
{ {
if (is_channel (serv, chan)) if (is_channel (serv, chan))
{ {
@ -352,13 +379,13 @@ inbound_action (session *sess, char *chan, char *from, char *ip, char *text,
/* it's a private action! */ /* it's a private action! */
privaction = TRUE; privaction = TRUE;
/* find a dialog tab for it */ /* find a dialog tab for it */
sess = find_dialog (serv, from); sess = find_dialog (serv, destsess);
/* if non found, open a new one */ /* if non found, open a new one */
if (!sess && prefs.hex_gui_autoopen_dialog) if (!sess && prefs.hex_gui_autoopen_dialog)
{ {
/* but only if it wouldn't flood */ /* but only if it wouldn't flood */
if (flood_check (from, ip, serv, current_sess, 1)) if (flood_check (destsess, ip, serv, current_sess, 1))
sess = inbound_open_dialog (serv, from, tags_data); sess = inbound_open_dialog (serv, destsess, tags_data);
else else
sess = serv->server_session; sess = serv->server_session;
} }
@ -383,7 +410,7 @@ inbound_action (session *sess, char *chan, char *from, char *ip, char *text,
lastact_update (sess); lastact_update (sess);
} }
user = userlist_find (sess, from); user = userlist_find (sess, destsess);
if (user) if (user)
{ {
nickchar[0] = user->prefix[0]; nickchar[0] = user->prefix[0];
@ -407,8 +434,19 @@ inbound_action (session *sess, char *chan, char *from, char *ip, char *text,
} }
if (fromme) if (fromme)
EMIT_SIGNAL_TIMESTAMP (XP_TE_UACTION, sess, from, text, nickchar, idtext, {
if (fake || sess->type == SESS_DIALOG ||
!serv->p_cmp (sess->channel, destsess)) /* Show normally if in correct sess */
EMIT_SIGNAL_TIMESTAMP (XP_TE_UACTION, sess, from, text, nickchar, idtext,
0, tags_data->timestamp); 0, tags_data->timestamp);
else /* There is no Action Send event, so we will just show it as CTCP.. */
{
char *new_text = g_strconcat ("ACTION ", text, NULL);
EMIT_SIGNAL_TIMESTAMP (XP_TE_CTCPSEND, sess, destsess, new_text, NULL, NULL,
0, tags_data->timestamp);
g_free (new_text);
}
}
else if (!privaction) else if (!privaction)
EMIT_SIGNAL_TIMESTAMP (XP_TE_CHANACTION, sess, from, text, nickchar, EMIT_SIGNAL_TIMESTAMP (XP_TE_CHANACTION, sess, from, text, nickchar,
idtext, 0, tags_data->timestamp); idtext, 0, tags_data->timestamp);
@ -1780,6 +1818,17 @@ inbound_cap_ls (server *serv, char *nick, char *extensions_str,
strcat (buffer, "server-time "); strcat (buffer, "server-time ");
want_cap = 1; want_cap = 1;
} }
if (!strcmp (extension, "znc.in/self-message"))
{
strcat (buffer, "znc.in/self-message ");
want_cap = 1;
}
if (!strcmp (extension, "self-message"))
{
strcat (buffer, "self-message ");
want_cap = 1;
}
/* if the SASL password is set AND auth mode is set to SASL, request SASL auth */ /* if the SASL password is set AND auth mode is set to SASL, request SASL auth */
if (!strcmp (extension, "sasl") if (!strcmp (extension, "sasl")

View File

@ -80,10 +80,10 @@ void inbound_chanmsg (server *serv, session *sess, char *chan, char *from,
const message_tags_data *tags_data); const message_tags_data *tags_data);
void clear_channel (session *sess); void clear_channel (session *sess);
void set_topic (session *sess, char *topic, char *stripped_topic); void set_topic (session *sess, char *topic, char *stripped_topic);
void inbound_privmsg (server *serv, char *from, char *ip, char *text, int id, void inbound_privmsg (server *serv, char *from, char *to, char *ip, char *text, int id,
const message_tags_data *tags_data); const message_tags_data *tags_data);
void inbound_action (session *sess, char *chan, char *from, char *ip, void inbound_action (session *sess, char *chan, char *from, char *ip,
char *text, int fromme, int id, char *text, int fromme, gboolean fake, int id,
const message_tags_data *tags_data); const message_tags_data *tags_data);
void inbound_newnick (server *serv, char *nick, char *newnick, int quiet, void inbound_newnick (server *serv, char *nick, char *newnick, int quiet,
const message_tags_data *tags_data); const message_tags_data *tags_data);

View File

@ -2642,7 +2642,7 @@ cmd_me (struct session *sess, char *tbuf, char *word[], char *word_eol[])
if (dcc_write_chat (sess->channel, tbuf)) if (dcc_write_chat (sess->channel, tbuf))
{ {
/* print it to screen */ /* print it to screen */
inbound_action (sess, sess->channel, sess->server->nick, "", act, TRUE, FALSE, inbound_action (sess, sess->channel, sess->server->nick, "", act, TRUE, TRUE, FALSE,
&no_tags); &no_tags);
} else } else
{ {
@ -2654,7 +2654,7 @@ cmd_me (struct session *sess, char *tbuf, char *word[], char *word_eol[])
sess->server->p_action (sess->server, sess->channel, split_text); sess->server->p_action (sess->server, sess->channel, split_text);
/* print it to screen */ /* print it to screen */
inbound_action (sess, sess->channel, sess->server->nick, "", inbound_action (sess, sess->channel, sess->server->nick, "",
split_text, TRUE, FALSE, split_text, TRUE, TRUE, FALSE,
&no_tags); &no_tags);
if (*split_text) if (*split_text)
@ -2666,7 +2666,7 @@ cmd_me (struct session *sess, char *tbuf, char *word[], char *word_eol[])
sess->server->p_action (sess->server, sess->channel, act + offset); sess->server->p_action (sess->server, sess->channel, act + offset);
/* print it to screen */ /* print it to screen */
inbound_action (sess, sess->channel, sess->server->nick, "", inbound_action (sess, sess->channel, sess->server->nick, "",
act + offset, TRUE, FALSE, &no_tags); act + offset, TRUE, TRUE, FALSE, &no_tags);
} else } else
{ {
notc_msg (sess); notc_msg (sess);

View File

@ -1244,7 +1244,7 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[],
{ {
if (ignore_check (word[1], IG_PRIV)) if (ignore_check (word[1], IG_PRIV))
return; return;
inbound_privmsg (serv, nick, ip, text, id, tags_data); inbound_privmsg (serv, nick, to, ip, text, id, tags_data);
} }
} }
} }