Esempio n. 1
0
void
inbound_chanmsg (server *serv, session *sess, char *chan, char *from, char *text, char fromme, int id)
{
	struct User *user;
	int hilight = FALSE;
	char nickchar[2] = "\000";
	char idtext[64];

	if (!sess)
	{
		if (chan)
		{
			sess = find_channel (serv, chan);
			if (!sess && !is_channel (serv, chan))
				sess = find_dialog (serv, chan);
		} else
		{
			sess = find_dialog (serv, from);
		}
		if (!sess)
			return;
	}

	if (sess != current_tab)
	{
		sess->msg_said = TRUE;
		sess->new_data = FALSE;
		lastact_update (sess);
	}

	user = userlist_find (sess, from);
	if (user)
	{
		if (user->account)
			id = TRUE;
		nickchar[0] = user->prefix[0];
		user->lasttalk = time (0);
	}

	if (fromme)
	{
  		if (prefs.hex_away_auto_unmark && serv->is_away)
			sess->server->p_set_back (sess->server);
		EMIT_SIGNAL (XP_TE_UCHANMSG, sess, from, text, nickchar, NULL, 0);
		return;
	}

	inbound_make_idtext (serv, idtext, sizeof (idtext), id);

	if (is_hilight (from, text, sess, serv))
		hilight = TRUE;

	if (sess->type == SESS_DIALOG)
		EMIT_SIGNAL (XP_TE_DPRIVMSG, sess, from, text, idtext, NULL, 0);
	else if (hilight)
		EMIT_SIGNAL (XP_TE_HCHANMSG, sess, from, text, nickchar, idtext, 0);
	else
		EMIT_SIGNAL (XP_TE_CHANMSG, sess, from, text, nickchar, idtext, 0);
}
Esempio n. 2
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);
}
Esempio n. 3
0
static void inbound_privmsg_helper(char *nickchar, char *prefixchar, char *idtext,
				   int *is_highlight, msg_destination *action_type,
				   session **initial_session, server *serv, char **chan,
				   char *from, char *ip, char *text, int *from_me, int *id,
				   const message_tags_data *tags_data)
{
	struct User *user;
	session *sess = *initial_session;

	if (*from_me && sess == NULL)
	{
		*action_type = MSGDEST_DIRECT;
		sess = serv->front_session;
	}
	else if (*chan && is_channel (serv, *chan))
	{
		*action_type = MSGDEST_CHANNEL;
		sess = find_channel (serv, *chan);
	}
	else if (*chan && strchr(serv->nick_prefixes, **chan) && is_channel (serv, *chan + 1))
	{
		*action_type = MSGDEST_PREFIX;
		prefixchar[0] = **chan;
		++*chan;
		sess = find_channel (serv, *chan);
	}
	else
	{
		char *target = *from_me ? *chan : from;
		session *userquery = find_dialog (serv, target);
		if (!userquery)
		{
			if (prefs.hex_gui_autoopen_dialog && flood_check (target, ip, serv, current_sess, 1))
			{
				*action_type = MSGDEST_PRIVATE;
				sess = inbound_open_dialog (serv, target, tags_data);
			}
			else
			{
				*action_type = MSGDEST_DIRECT;
				sess = serv->front_session;
			}
		}
		else
		{
			*action_type = MSGDEST_PRIVATE;
			sess = userquery;
		}
	}

	*is_highlight = is_hilight (from, text, sess, serv);

	if (sess != current_tab)
	{
		if (*from_me)
		{
			sess->msg_said = FALSE;
			sess->new_data = TRUE;
		} else
		{
			sess->msg_said = TRUE;
			sess->new_data = FALSE;
		}
		lastact_update (sess);
	}

	user = userlist_find (sess, from);
	if (user)
	{
		nickchar[0] = user->prefix[0];
		user->lasttalk = time (0);
		if (user->account)
			*id = TRUE;
		if (user->me)
			*from_me = TRUE;
	}

	inbound_make_idtext (serv, idtext, sizeof (idtext), *id);

	*initial_session = sess;
}
Esempio n. 4
0
void
inbound_chanmsg (server *serv, char *chan, char *from, char *text, char fromme)
{
	struct User *user;
	session *sess;
	int hilight = FALSE;
	char nickchar[2] = "\000";

	if (chan)
	{
		sess = find_channel (serv, chan);
		if (!sess && !is_channel (serv, chan))
			sess = find_dialog (serv, chan);
	} else
	{
		sess = find_dialog (serv, from);
	}
	if (!sess)
		return;

	if (sess != current_tab)
	{
		sess->msg_said = TRUE;
		sess->new_data = FALSE;
	}

	user = find_name (sess, from);
	if (user)
	{
		nickchar[0] = user->prefix[0];
		user->lasttalk = time (0);
	}

	if (fromme)
	{
  		if (prefs.auto_unmark_away && serv->is_away)
			sess->server->p_set_back (sess->server);
		EMIT_SIGNAL (XP_TE_UCHANMSG, sess, from, text, nickchar, NULL, 0);
		return;
	}

	if (sess->type != SESS_DIALOG)
		if (prefs.beepchans || sess->beep)
			fe_beep ();

	if (is_hilight (text, sess, serv))
	{
		hilight = TRUE;
		if (prefs.beephilight)
			fe_beep ();
	}
	if (sess->type == SESS_DIALOG)
		EMIT_SIGNAL (XP_TE_DPRIVMSG, sess, from, text, NULL, NULL, 0);
	else if (hilight)
		EMIT_SIGNAL (XP_TE_HCHANMSG, sess, from, text, nickchar, NULL, 0);
	else if (prefs.colorednicks)
	{
		char tbuf[NICKLEN + 4];
		snprintf (tbuf, sizeof (tbuf), "\003%d%s", color_of (from), from);
		EMIT_SIGNAL (XP_TE_CHANMSG, sess, tbuf, text, nickchar, NULL, 0);
	}
	else
		EMIT_SIGNAL (XP_TE_CHANMSG, sess, from, text, nickchar, NULL, 0);
}
Esempio n. 5
0
void
inbound_action (session *sess, char *chan, char *from, char *text, int fromme)
{
	session *def = sess;
	server *serv = sess->server;
	int beep = FALSE;
	int hilight = FALSE;

	if (!fromme)
	{
		if (is_channel (serv, chan))
		{
			sess = find_channel (serv, chan);
			beep = prefs.beepchans;
		} else
		{
			/* it's a private action! */
			beep = prefs.beepmsg;
			/* find a dialog tab for it */
			sess = find_dialog (serv, from);
			/* if non found, open a new one */
			if (!sess && prefs.autodialog)
				sess = new_ircwindow (serv, from, SESS_DIALOG);
		}
	}

	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;
		}
	}

	if (!fromme)
	{
		hilight = is_hilight (text, sess, serv);
		if (hilight && prefs.beephilight)
			beep = TRUE;

		if (beep || sess->beep)
			fe_beep ();

		if (hilight)
		{
			EMIT_SIGNAL (XP_TE_HCHANACTION, sess, from, text, NULL, NULL, 0);
			return;
		}
	}

	if (prefs.colorednicks)
	{
		char tbuf[NICKLEN + 4];
		snprintf (tbuf, sizeof (tbuf), "\003%d%s", color_of (from), from);
		EMIT_SIGNAL (XP_TE_CHANACTION, sess, tbuf, text, NULL, NULL, 0);
	} else
	{
		EMIT_SIGNAL (XP_TE_CHANACTION, sess, from, text, NULL, NULL, 0);
	}
}