void inbound_away (server *serv, char *nick, char *msg) { struct away_msg *away = find_away_message (serv, nick); session *sess = NULL; GSList *list; if (away && !strcmp (msg, away->message)) /* Seen the msg before? */ { if (prefs.show_away_once && !serv->inside_whois) return; } else { save_away_message (serv, nick, msg); } if (!serv->inside_whois) sess = find_session_from_nick (nick, serv); if (!sess) sess = serv->server_session; EMIT_SIGNAL (XP_TE_WHOIS5, sess, nick, msg, NULL, NULL, 0); list = sess_list; while (list) { sess = list->data; if (sess->server == serv) userlist_set_away (sess, nick, TRUE); list = list->next; } }
void inbound_privmsg (server *serv, char *from, char *ip, char *text, int id, const message_tags_data *tags_data) { session *sess; struct User *user; char idtext[64]; gboolean nodiag = FALSE; sess = find_dialog (serv, from); if (sess || prefs.hex_gui_autoopen_dialog) { /*0=ctcp 1=priv will set hex_gui_autoopen_dialog=0 here is flud detected */ if (!sess) { if (flood_check (from, ip, serv, current_sess, 1)) /* Create a dialog session */ sess = inbound_open_dialog (serv, from, tags_data); else sess = serv->server_session; if (!sess) return; /* ?? */ } if (ip && ip[0]) set_topic (sess, ip, ip); inbound_chanmsg (serv, NULL, NULL, from, text, FALSE, id, tags_data); return; } sess = find_session_from_nick (from, serv); if (!sess) { 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); if (user) { user->lasttalk = time (0); if (user->account) id = TRUE; } inbound_make_idtext (serv, idtext, sizeof (idtext), id); if (sess->type == SESS_DIALOG && !nodiag) EMIT_SIGNAL_TIMESTAMP (XP_TE_DPRIVMSG, sess, from, text, idtext, NULL, 0, tags_data->timestamp); else EMIT_SIGNAL_TIMESTAMP (XP_TE_PRIVMSG, sess, from, text, idtext, NULL, 0, tags_data->timestamp); }
void inbound_privmsg (server * serv, char *from, char *ip, char *text, int id) { session *sess; char idtext[64]; sess = find_dialog (serv, from); if (sess || prefs.autodialog) { /*0=ctcp 1=priv will set autodialog=0 here is flud detected */ if (!sess) { if (flood_check (from, ip, serv, current_sess, 1)) /* Create a dialog session */ sess = inbound_open_dialog (serv, from); else sess = serv->server_session; if (!sess) return; /* ?? */ } if (ip && ip[0]) { if (prefs.logging && sess->logfd != -1 && (!sess->topic || strcmp (sess->topic, ip))) { char tbuf[1024]; snprintf (tbuf, sizeof (tbuf), "[%s has address %s]\n", from, ip); write (sess->logfd, tbuf, strlen (tbuf)); } set_topic (sess, ip, ip); } inbound_chanmsg (serv, NULL, NULL, from, text, FALSE, id); return; } inbound_make_idtext (serv, idtext, sizeof (idtext), id); sess = find_session_from_nick (from, serv); if (!sess) { sess = serv->front_session; EMIT_SIGNAL (XP_TE_PRIVMSG, sess, from, text, idtext, NULL, 0); return; } if (sess->type == SESS_DIALOG) EMIT_SIGNAL (XP_TE_DPRIVMSG, sess, from, text, idtext, NULL, 0); else EMIT_SIGNAL (XP_TE_PRIVMSG, sess, from, text, idtext, NULL, 0); }
void inbound_away (server *serv, char *nick, char *msg, const message_tags_data *tags_data) { struct away_msg *away = server_away_find_message (serv, nick); session *sess = NULL; GSList *list; if (away && !strcmp (msg, away->message)) /* Seen the msg before? */ { if (prefs.hex_away_show_once && !serv->inside_whois) return; } else { server_away_save_message (serv, nick, msg); } if (prefs.hex_irc_whois_front) sess = serv->front_session; else { if (!serv->inside_whois) sess = find_session_from_nick (nick, serv); if (!sess) sess = serv->server_session; } /* possibly hide the output */ if (!serv->inside_whois || !serv->skip_next_whois) EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS5, sess, nick, msg, NULL, NULL, 0, tags_data->timestamp); list = sess_list; while (list) { sess = list->data; if (sess->server == serv) userlist_set_away (sess, nick, TRUE); list = list->next; } }
void inbound_notice (server *serv, char *to, char *nick, char *msg, char *ip, int id) { char *po,*ptr=to; session *sess = 0; int server_notice = FALSE; if (is_channel (serv, ptr)) sess = find_channel (serv, ptr); if (!sess && ptr[0] == '@') { ptr++; sess = find_channel (serv, ptr); } if (!sess && ptr[0] == '%') { ptr++; sess = find_channel (serv, ptr); } if (!sess && ptr[0] == '+') { ptr++; sess = find_channel (serv, ptr); } if (strcmp (nick, ip) == 0) server_notice = TRUE; if (!sess) { ptr = 0; if (prefs.hex_gui_tab_notices) { int stype = server_notice ? SESS_SNOTICES : SESS_NOTICES; sess = find_session_from_type (stype, serv); if (!sess) { if (stype == SESS_NOTICES) sess = new_ircwindow (serv, "(notices)", SESS_NOTICES, 0); else sess = new_ircwindow (serv, "(snotices)", SESS_SNOTICES, 0); fe_set_channel (sess); fe_set_title (sess); fe_set_nonchannel (sess, FALSE); userlist_clear (sess); log_open_or_close (sess); } /* Avoid redundancy with some Undernet notices */ if (!strncmp (msg, "*** Notice -- ", 14)) msg += 14; } else { /* paranoia check */ if (msg[0] == '[' && (!serv->have_idmsg || id)) { /* guess where chanserv meant to post this -sigh- */ if (!g_ascii_strcasecmp (nick, "ChanServ") && !find_dialog (serv, nick)) { char *dest = strdup (msg + 1); char *end = strchr (dest, ']'); if (end) { *end = 0; sess = find_channel (serv, dest); } free (dest); } } if (!sess) sess = find_session_from_nick (nick, serv); } if (!sess) { if (server_notice) sess = serv->server_session; else sess = serv->front_session; } } if (msg[0] == 1) { msg++; if (!strncmp (msg, "PING", 4)) { inbound_ping_reply (sess, msg + 5, nick); return; } } po = strchr (msg, '\001'); if (po) po[0] = 0; if (server_notice) EMIT_SIGNAL (XP_TE_SERVNOTICE, sess, msg, nick, NULL, NULL, 0); else if (ptr) EMIT_SIGNAL (XP_TE_CHANNOTICE, sess, nick, to, msg, NULL, 0); else EMIT_SIGNAL (XP_TE_NOTICE, sess, nick, msg, NULL, NULL, 0); }
void inbound_action (session *sess, char *chan, char *from, char *ip, char *text, int fromme, int id) { session *def = sess; server *serv = sess->server; struct User *user; char nickchar[2] = "\000"; char idtext[64]; int privaction = FALSE; if (!fromme) { if (is_channel (serv, chan)) { sess = find_channel (serv, chan); } else { /* it's a private action! */ privaction = TRUE; /* find a dialog tab for it */ sess = find_dialog (serv, from); /* if non found, open a new one */ if (!sess && prefs.hex_gui_autoopen_dialog) { /* but only if it wouldn't flood */ if (flood_check (from, ip, serv, current_sess, 1)) sess = inbound_open_dialog (serv, from); else sess = serv->server_session; } if (!sess) { sess = find_session_from_nick (from, serv); /* still not good? */ if (!sess) sess = serv->front_session; } } } if (!sess) sess = def; if (sess != current_tab) { if (fromme) { sess->msg_said = FALSE; sess->new_data = TRUE; } else { sess->msg_said = TRUE; sess->new_data = FALSE; } } user = userlist_find (sess, from); if (user) { nickchar[0] = user->prefix[0]; user->lasttalk = time (0); } inbound_make_idtext (serv, idtext, sizeof (idtext), id); if (!fromme && !privaction) { if (is_hilight (from, text, sess, serv)) { EMIT_SIGNAL (XP_TE_HCHANACTION, sess, from, text, nickchar, idtext, 0); return; } } if (fromme) EMIT_SIGNAL (XP_TE_UACTION, sess, from, text, nickchar, idtext, 0); else if (!privaction) EMIT_SIGNAL (XP_TE_CHANACTION, sess, from, text, nickchar, idtext, 0); else if (sess->type == SESS_DIALOG) EMIT_SIGNAL (XP_TE_DPRIVACTION, sess, from, text, idtext, NULL, 0); else EMIT_SIGNAL (XP_TE_PRIVACTION, sess, from, text, idtext, NULL, 0); }
void inbound_privmsg (server *serv, char *from, char *ip, char *text, int id) { session *sess; struct User *user; char idtext[64]; gboolean nodiag = FALSE; sess = find_dialog (serv, from); if (sess || prefs.hex_gui_autoopen_dialog) { /*0=ctcp 1=priv will set hex_gui_autoopen_dialog=0 here is flud detected */ if (!sess) { if (flood_check (from, ip, serv, current_sess, 1)) /* Create a dialog session */ sess = inbound_open_dialog (serv, from); else sess = serv->server_session; if (!sess) return; /* ?? */ } if (ip && ip[0]) { if (prefs.hex_irc_logging && sess->logfd != -1 && (!sess->topic || strcmp(sess->topic, ip))) { char tbuf[1024]; snprintf (tbuf, sizeof (tbuf), "[%s has address %s]\n", from, ip); write (sess->logfd, tbuf, strlen (tbuf)); } set_topic (sess, ip, ip); } inbound_chanmsg (serv, NULL, NULL, from, text, FALSE, id); return; } sess = find_session_from_nick (from, serv); if (!sess) { 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); if (user) { user->lasttalk = time (0); if (user->account) id = TRUE; } inbound_make_idtext (serv, idtext, sizeof (idtext), id); if (sess->type == SESS_DIALOG && !nodiag) EMIT_SIGNAL (XP_TE_DPRIVMSG, sess, from, text, idtext, NULL, 0); else EMIT_SIGNAL (XP_TE_PRIVMSG, sess, from, text, idtext, NULL, 0); }
void inbound_notice (server *serv, char *to, char *nick, char *msg, char *ip) { char *po,*ptr=to; session *sess = 0; int server_notice = FALSE; if (is_channel (serv, ptr)) sess = find_channel (serv, ptr); if (!sess && ptr[0] == '@') { ptr++; sess = find_channel (serv, ptr); } if (!sess && ptr[0] == '+') { ptr++; sess = find_channel (serv, ptr); } if (strcmp (nick, ip) == 0) server_notice = TRUE; if (!sess) { ptr = 0; if (prefs.notices_tabs) { int stype = server_notice ? SESS_SNOTICES : SESS_NOTICES; sess = find_session_from_type (stype, serv); if (!sess) { register unsigned int oldh = prefs.hideuserlist; prefs.hideuserlist = 1; if (stype == SESS_NOTICES) sess = new_ircwindow (serv, "(notices)", SESS_NOTICES); else sess = new_ircwindow (serv, "(snotices)", SESS_SNOTICES); prefs.hideuserlist = oldh; fe_set_channel (sess); fe_set_title (sess); fe_set_nonchannel (sess, FALSE); clear_user_list (sess); if (prefs.logging) log_open (sess); } /* Avoid redundancy with some Undernet notices */ if (!strncmp (msg, "*** Notice -- ", 14)) msg += 14; } else { sess = find_session_from_nick (nick, serv); } if (!sess) { if (server_notice) sess = serv->server_session; else sess = serv->front_session; } } if (msg[0] == 1) { msg++; if (!strncmp (msg, "PING", 4)) { inbound_ping_reply (sess, msg + 5, nick); return; } } po = strchr (msg, '\001'); if (po) po[0] = 0; if (server_notice) EMIT_SIGNAL (XP_TE_SERVNOTICE, sess, msg, nick, NULL, NULL, 0); else if (ptr) EMIT_SIGNAL (XP_TE_CHANNOTICE, sess, nick, to, msg, NULL, 0); else EMIT_SIGNAL (XP_TE_NOTICE, sess, nick, msg, NULL, NULL, 0); }