Example #1
0
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);
}
Example #2
0
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);
}
Example #3
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);
}
Example #4
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;
}
Example #5
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);
}