Beispiel #1
0
static void
sig_presence_changed(XMPP_SERVER_REC *server, const char *full_jid,
    int show, const char *status)
{
	XMPP_QUERY_REC *rec;
	XMPP_ROSTER_USER_REC *user;
	const char *msg;
	char *name;

	g_return_if_fail(server != NULL);
	g_return_if_fail(full_jid != NULL);
	g_return_if_fail(0 <= show && show < XMPP_PRESENCE_SHOW_LEN);
	if ((rec = xmpp_query_find(server, full_jid)) == NULL)
		return;
	msg = fe_xmpp_presence_show[show];
	user = rosters_find_user(server->roster, full_jid, NULL, NULL);
	name = user != NULL && user->name != NULL ?
	    format_get_text(MODULE_NAME, NULL, server, NULL,
		XMPPTXT_FORMAT_NAME, user->name, full_jid) :
	    format_get_text(MODULE_NAME, NULL, server, NULL,
		XMPPTXT_FORMAT_JID, full_jid);
	if (status != NULL)
		printformat_module(MODULE_NAME, server, full_jid, MSGLEVEL_CRAP,
		    XMPPTXT_PRESENCE_CHANGE_REASON, name, msg, status);
	else
		printformat_module(MODULE_NAME, server, full_jid, MSGLEVEL_CRAP,
		    XMPPTXT_PRESENCE_CHANGE, name, msg);
}
Beispiel #2
0
static void
func_vcard_subvalue(const char *key, const char *value,
    struct vcard_user_data *ud)
{
	printformat_module(MODULE_NAME, ud->server, ud->jid, MSGLEVEL_CRAP,
	    XMPPTXT_VCARD_SUBVALUE, key, value);
}
Beispiel #3
0
static void
sig_roster_show(XMPP_SERVER_REC *server)
{
	GSList *gl, *ul;
	XMPP_ROSTER_GROUP_REC *group;
	XMPP_ROSTER_USER_REC *user;

	g_return_if_fail(IS_XMPP_SERVER(server));
	show_begin_of_roster(server);
	for (gl = server->roster; gl != NULL; gl = gl->next) {
		group = gl->data;
		/* don't show groups with only offline users */
		for (ul = group->users; ul != NULL
		    && !user_is_shown(ul->data); ul = ul->next);
		if (ul == NULL)
			continue;
		show_group(server, group);
		 for (ul = group->users; ul != NULL; ul = ul->next) {
			user = ul->data;
			if (user_is_shown(user))
				show_user(server, user);
		}
	}
	printformat_module(MODULE_NAME, server, NULL, MSGLEVEL_CRAP,
	    XMPPTXT_END_OF_ROSTER);
}
Beispiel #4
0
static void
show_begin_of_roster(XMPP_SERVER_REC *server)
{
	char *show, *status, *priority, *text, *resources, *pgp_keyid;

	g_return_if_fail(IS_XMPP_SERVER(server));
	show = (server->show == XMPP_PRESENCE_AVAILABLE) ? NULL :
	    format_get_text(MODULE_NAME, NULL, server, NULL,
	        XMPPTXT_FORMAT_RESOURCE_SHOW,
	    xmpp_presence_show[server->show]);
	status = (server->away_reason == NULL
	    || strcmp(server->away_reason, " ") == 0) ? NULL :
	    format_get_text(MODULE_NAME, NULL, server, NULL,
	        XMPPTXT_FORMAT_RESOURCE_STATUS, server->away_reason);
	priority = g_strdup_printf("%d", server->priority);
	pgp_keyid = !settings_get_str("xmpp_pgp") ? NULL : \
	    format_get_text(MODULE_NAME, NULL, server, NULL,
	        XMPPTXT_FORMAT_PGP_KEYID, settings_get_str("xmpp_pgp"));
	text = format_get_text(MODULE_NAME, NULL, server, NULL,
	    XMPPTXT_FORMAT_RESOURCE, show,  server->resource, priority,
	    status, pgp_keyid);
	g_free(show);
	g_free(status);
	g_free(priority);
	resources = get_resources(server, server->my_resources);
	printformat_module(MODULE_NAME, server, NULL, MSGLEVEL_CRAP,
	    XMPPTXT_BEGIN_OF_ROSTER, server->jid, text, resources);
	g_free(text);
	g_free(resources);
}
Beispiel #5
0
static void
show_user(XMPP_SERVER_REC *server, XMPP_ROSTER_USER_REC *user)
{
	const char *first_show;
	char *name, *resources, *subscription;

	g_return_if_fail(IS_SERVER(server));
	g_return_if_fail(user != NULL);
	if (user->resources == NULL)
		first_show = xmpp_presence_show[user->error ?
		    XMPP_PRESENCE_ERROR : XMPP_PRESENCE_UNAVAILABLE];
	else
		first_show = get_first_show(user->resources);
	name = user->name != NULL ?
	    format_get_text(MODULE_NAME, NULL, server, NULL,
	        XMPPTXT_FORMAT_NAME, user->name, user->jid) :
	    format_get_text(MODULE_NAME, NULL, server, NULL,
	        XMPPTXT_FORMAT_JID, user->jid);
	resources = get_resources(server, user->resources);
	subscription = user->subscription == XMPP_SUBSCRIPTION_BOTH ? NULL :
	    format_get_text(MODULE_NAME, NULL, server, NULL,
	        XMPPTXT_FORMAT_SUBSCRIPTION,
	        xmpp_subscription[user->subscription]);
	printformat_module(MODULE_NAME, server, NULL, MSGLEVEL_CRAP,
    	    XMPPTXT_ROSTER_CONTACT, first_show, name, resources,
	    subscription);
	g_free(name);
	g_free(resources);
	g_free(subscription);
}
Beispiel #6
0
static void
sig_failed(const char *username, const char *domain, gpointer error)
{
	char *reason;

	switch(GPOINTER_TO_INT(error)) {
	case REGISTRATION_ERROR_UNAUTHORIZED:
	case REGISTRATION_ERROR_UNAUTHORIZED_REG:
		reason = "Registration unauthorized";
		break;
	case REGISTRATION_ERROR_UNIMPLEMENTED:
	case REGISTRATION_ERROR_UNAVAILABLE:
		reason = "Service unavailable";
		break;
	case REGISTRATION_ERROR_CONFLICT:
		reason = "Account already exists";
		break;
	case REGISTRATION_ERROR_TIMEOUT:
	case REGISTRATION_ERROR_TIMEOUT_SERVER:
		reason = "Connection times out";
		break;
	case REGISTRATION_ERROR_CONNECTION:
		reason = "Cannot open connection";
		break;
	case REGISTRATION_ERROR_INFO:
		reason = "Cannot send registration information";
		break;
	default:
		reason = "Cannot register account";
	}
	printformat_module(MODULE_NAME, NULL, NULL,
	    MSGLEVEL_CRAP, XMPPTXT_REGISTRATION_FAILED, username, domain,
	    reason);
}
Beispiel #7
0
static void sig_message_own_public(SERVER_REC *server, const char *msg,
				   const char *target, const char *origtarget)
{
	const char *oldtarget;
	char *nickmode;

	if (!IS_IRC_SERVER(server))
		return;
	oldtarget = target;
	target = fe_channel_skip_prefix(IRC_SERVER(server), target);
	if (target != oldtarget) {
		/* Hybrid 6 / Bahamut feature, send msg to all
		   ops / ops+voices in channel */
		nickmode = channel_get_nickmode(channel_find(server, target),
						server->nick);

		printformat_module("fe-common/core", server, target,
				   MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT |
				   MSGLEVEL_NO_ACT,
				   TXT_OWN_MSG_CHANNEL,
				   server->nick, oldtarget, msg, nickmode);
		g_free(nickmode);
                signal_stop();
	}

}
Beispiel #8
0
/* received msg to all ops in channel */
static void sig_message_irc_op_public(SERVER_REC *server, const char *msg,
				      const char *nick, const char *address,
				      const char *target)
{
	char *nickmode, *optarget, *prefix;
	const char *cleantarget;

	/* only skip here so the difference can be stored in prefix */
	cleantarget = fe_channel_skip_prefix(IRC_SERVER(server), target);
	prefix = g_strndup(target, cleantarget - target);

	/* and clean the rest here */
	cleantarget = get_visible_target(IRC_SERVER(server), cleantarget);

	nickmode = channel_get_nickmode(channel_find(server, cleantarget),
					nick);

	optarget = g_strconcat(prefix, cleantarget, NULL);

	printformat_module("fe-common/core", server, cleantarget,
			   MSGLEVEL_PUBLIC,
			   TXT_PUBMSG_CHANNEL,
			   nick, optarget, msg, nickmode);
	g_free(nickmode);
	g_free(optarget);
	g_free(prefix);
}
Beispiel #9
0
static void
sig_version(XMPP_SERVER_REC *server, const char *jid, const char *client,
    const char *version, const char *os)
{
	XMPP_ROSTER_USER_REC *user;
	char *name, *str;

	g_return_if_fail(jid != NULL);
	if (client == NULL && version == NULL && os == NULL)
		return;
	str = g_strconcat("is running ",
	    client != NULL ? client : "",
	    client != NULL && version != NULL ? " " : "",
	    version != NULL ? version : "",
	    (client != NULL || version != NULL) && os != NULL ? " - " : "",
	    os != NULL ? "on " : "",
	    os != NULL ? os : "", (void *)NULL);
	user = rosters_find_user(server->roster, jid, NULL, NULL);
	name = user != NULL && user->name != NULL ?
	    format_get_text(MODULE_NAME, NULL, server, NULL,
	        XMPPTXT_FORMAT_NAME, user->name, jid) :
	    format_get_text(MODULE_NAME, NULL, server, NULL,
	        XMPPTXT_FORMAT_JID, jid);
	printformat_module(MODULE_NAME, server, jid, MSGLEVEL_CRAP,
	    XMPPTXT_MESSAGE_EVENT, name, str);
	g_free(name);
	g_free(str);
}
Beispiel #10
0
static void
sig_not_in_roster(XMPP_SERVER_REC *server, const char *jid)
{
	g_return_if_fail(IS_SERVER(server));
	g_return_if_fail(jid != NULL);
	printformat_module(MODULE_NAME, server, NULL,
	    MSGLEVEL_CLIENTERROR, XMPPTXT_NOT_IN_ROSTER, jid);
}
Beispiel #11
0
static void
show_group(XMPP_SERVER_REC *server, XMPP_ROSTER_GROUP_REC *group)
{
	g_return_if_fail(IS_SERVER(server));
	g_return_if_fail(group != NULL);
	printformat_module(MODULE_NAME, server, NULL, MSGLEVEL_CRAP,
	    XMPPTXT_ROSTER_GROUP, (group->name != NULL) ?
	    group->name : settings_get_str("xmpp_roster_default_group"));
}
Beispiel #12
0
static void
sig_error(XMPP_SERVER_REC *server, const char *full_jid,
    const char *msg)
{
	g_return_if_fail(server != NULL);
	g_return_if_fail(full_jid != NULL);

	printformat_module(MODULE_NAME, server, full_jid, MSGLEVEL_CRAP,
	    XMPPTXT_MESSAGE_NOT_DELIVERED, full_jid, msg);
}
Beispiel #13
0
static void
sig_message_own_public(SERVER_REC *server, char *msg, char *target)
{
	WINDOW_REC *window;
	CHANNEL_REC *channel;
	char *nick, *nickmode, *freemsg = NULL, *recoded;
	gboolean print_channel;

	g_return_if_fail(server != NULL);
	g_return_if_fail(msg != NULL);
	g_return_if_fail(target != NULL);
	if (!IS_XMPP_SERVER(server))
		return;
	channel = channel_find(server, target);
	if (channel == NULL || channel->ownnick == NULL)
		return;
	nick = channel->ownnick->nick;
	nickmode = channel_get_nickmode(CHANNEL(channel), nick);
	window = (channel == NULL) ?
	    NULL : window_item_window((WI_ITEM_REC *)channel);
	print_channel = (window == NULL ||
	    window->active != (WI_ITEM_REC *) channel);
	if (!print_channel && settings_get_bool("print_active_channel") &&
	    window != NULL && g_slist_length(window->items) > 1)
		print_channel = TRUE;
	if (settings_get_bool("emphasis"))
		msg = freemsg = expand_emphasis((WI_ITEM_REC *)channel, msg);
	/* ugly from irssi: recode the sent message back for printing */
	recoded = recode_in(SERVER(server), msg, target);
	if (!print_channel)
		printformat_module(CORE_MODULE_NAME, server, target,
		    MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
		    TXT_OWN_MSG, nick, recoded, nickmode);
	else
		printformat_module(CORE_MODULE_NAME, server, target,
		    MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
		    TXT_OWN_MSG_CHANNEL, nick, target, recoded, nickmode);
	g_free(recoded);
	g_free(nickmode);
	g_free_not_null(freemsg);
	signal_stop();
	/* emit signal for chat-completion */
}
Beispiel #14
0
static void
sig_vcard(XMPP_SERVER_REC *server, const char *jid, GHashTable *ht)
{
	XMPP_ROSTER_USER_REC *user;
	struct vcard_user_data ud;
	char *name;

	user = rosters_find_user(server->roster, jid, NULL, NULL);
	name = user != NULL && user->name != NULL ?
	    g_strdup(user->name) : xmpp_strip_resource(jid);
	printformat_module(MODULE_NAME, server, jid, MSGLEVEL_CRAP,
	    XMPPTXT_VCARD, name, jid);
	g_free(name);
	ud.server = server;
	ud.jid = jid;
	g_hash_table_foreach(ht,
	    (void (*)(gpointer, gpointer, gpointer))func_vcard_value, &ud);
	printformat_module(MODULE_NAME, server, jid, MSGLEVEL_CRAP,
	    XMPPTXT_END_OF_VCARD);
}
Beispiel #15
0
static void
sig_history(SERVER_REC *server, const char *msg, const char *nick,
    const char *target, const char *stamp, gpointer gpointer_type)
{
	void *item;
	char *text, *freemsg = NULL;
	int level, type;

	g_return_if_fail(server != NULL);
	g_return_if_fail(msg != NULL);
	g_return_if_fail(nick != NULL);
	g_return_if_fail(target != NULL);
	type = GPOINTER_TO_INT(gpointer_type);
	level = MSGLEVEL_NO_ACT | MSGLEVEL_NOHILIGHT
	    | (type == SEND_TARGET_CHANNEL ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS);
	item = type == SEND_TARGET_CHANNEL ?
	    (void *)channel_find(server, target) : query_find(server, nick);
	if (settings_get_bool("emphasis"))
		msg = freemsg = expand_emphasis(item, msg);
	/* MUC */
	if (type == SEND_TARGET_CHANNEL) {
		CHANNEL_REC *chanrec = item;
		int print_channel;
		char *nickmode;

		print_channel = chanrec == NULL ||
		    !window_item_is_active((WI_ITEM_REC *)chanrec);
		if (!print_channel
		    && settings_get_bool("print_active_channel")
		    && window_item_window((WI_ITEM_REC *)chanrec)->items->next
		    != NULL)
			print_channel = TRUE;
		nickmode = channel_get_nickmode(chanrec, nick);
		text = !print_channel ?
		    format_get_text(CORE_MODULE_NAME, NULL, server,
			target, TXT_PUBMSG, nick, msg, nickmode) :
		    format_get_text(CORE_MODULE_NAME, NULL, server,
			target, TXT_PUBMSG_CHANNEL, nick, target, msg,
			nickmode);
		g_free(nickmode);
	/* General */
	} else
		text = format_get_text(CORE_MODULE_NAME, NULL, server,
		    target, item == NULL ? TXT_MSG_PRIVATE :
		    TXT_MSG_PRIVATE_QUERY, nick, nick, msg);
	printformat_module(MODULE_NAME, server, target,
	    level, XMPPTXT_MESSAGE_TIMESTAMP,
	    stamp, text);
	g_free_not_null(freemsg);
	g_free(text);
}
Beispiel #16
0
static void
sig_query_created(XMPP_QUERY_REC *query, int automatic)
{
	XMPP_ROSTER_USER_REC *user;

	if (!IS_XMPP_QUERY(query))
		return;
	user = rosters_find_user(query->server->roster, query->name, NULL,
	    NULL);
	if (user == NULL || user->name == NULL)
		return;
	printformat_module(MODULE_NAME, query->server, query->name,
	    MSGLEVEL_CRAP, XMPPTXT_QUERY_AKA, user->jid, user->name);
}
Beispiel #17
0
static void
sig_action(SERVER_REC *server, const char *msg, const char *nick,
    const char *target, gpointer gpointer_type)
{
	void *item;
	char *freemsg = NULL;
	int level, type;

	g_return_if_fail(server != NULL);
	g_return_if_fail(msg != NULL);
	g_return_if_fail(nick != NULL);
	g_return_if_fail(target != NULL);
	type = GPOINTER_TO_INT(gpointer_type);
	level = MSGLEVEL_ACTIONS | (type == SEND_TARGET_CHANNEL ?
	    MSGLEVEL_PUBLIC : MSGLEVEL_MSGS);
	item = type == SEND_TARGET_CHANNEL ?
	    (void *)channel_find(server, target)
	    : privmsg_get_query(SERVER(server), nick, FALSE, level);
	if (settings_get_bool("emphasis"))
		msg = freemsg = expand_emphasis(item, msg);
	/* MUC */
	if (type == SEND_TARGET_CHANNEL) {
		if (item && window_item_is_active(item))
			printformat_module(IRC_MODULE_NAME, server, target,
			    level, IRCTXT_ACTION_PUBLIC, nick, msg);
		else
			printformat_module(IRC_MODULE_NAME, server, target,
			    level, IRCTXT_ACTION_PUBLIC_CHANNEL, nick,
			    target, msg);
	/* General */
	} else
		printformat_module(IRC_MODULE_NAME, server, nick, level,
		    (item == NULL) ?
		    IRCTXT_ACTION_PRIVATE : IRCTXT_ACTION_PRIVATE_QUERY,
		    nick, nick, msg);
	g_free(freemsg);
}
Beispiel #18
0
static void
sig_message_delay_action(SERVER_REC *server, const char *msg, const char *nick,
    const char *target, time_t *t, gpointer gpointer_type)
{
	void *item;
	char *text, *freemsg = NULL;
	char stamp[BUFSIZ];
	int level, type;

	g_return_if_fail(server != NULL);
	g_return_if_fail(msg != NULL);
	g_return_if_fail(nick != NULL);
	g_return_if_fail(target != NULL);

	type = GPOINTER_TO_INT(gpointer_type);
	level = MSGLEVEL_ACTIONS | MSGLEVEL_NO_ACT | MSGLEVEL_NOHILIGHT
	    | (type == SEND_TARGET_CHANNEL ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS);
	item = type == SEND_TARGET_CHANNEL ?
	    (void *)get_muc((XMPP_SERVER_REC *)server, target) :
	    query_find(server, nick);

	if (settings_get_bool("emphasis"))
		msg = freemsg = expand_emphasis(item, msg);

	/* MUC */
	if (type == SEND_TARGET_CHANNEL) {
		if (item && window_item_is_active(item))
			text = format_get_text(IRC_MODULE_NAME, NULL, server,
			    target, IRCTXT_ACTION_PUBLIC, nick, msg);
		else
			text = format_get_text(IRC_MODULE_NAME, NULL, server,
			    target, IRCTXT_ACTION_PUBLIC_CHANNEL, nick,
			    target, msg);

	/* General */
	} else
		text = format_get_text(IRC_MODULE_NAME, NULL, server,
		    nick, (item == NULL) ? IRCTXT_ACTION_PRIVATE : 
		    IRCTXT_ACTION_PRIVATE_QUERY, nick, nick, msg);

	if (strftime(stamp, sizeof(stamp)-1,
	    settings_get_str("xmpp_timestamp_format"), localtime(t)) == 0)
	stamp[sizeof(stamp)-1] = '\0';

	printformat_module(MODULE_NAME, server, target, level,
	    XMPPTXT_MESSAGE_TIMESTAMP, stamp, text);

	g_free(freemsg);
}
Beispiel #19
0
static void event_names_list(IRC_SERVER_REC *server, const char *data)
{
	char *params, *channel, *names;

	g_return_if_fail(data != NULL);

	params = event_get_params(data, 4, NULL, NULL, &channel, &names);
	if (irc_channel_find(server, channel) == NULL) {
		printformat_module("fe-common/core", server, channel,
				   MSGLEVEL_CRAP, TXT_NAMES,
				   channel, 0, 0, 0, 0, 0);
                printtext(server, channel, MSGLEVEL_CRAP, "%s", names);

	}
	g_free(params);
}
Beispiel #20
0
static void sig_message_own_wall(SERVER_REC *server, const char *msg,
				 const char *target)
{
        char *nickmode, *optarget;

	nickmode = channel_get_nickmode(channel_find(server, target),
					server->nick);

        optarget = g_strconcat("@", target, NULL);
	printformat_module("fe-common/core", server, target,
			   MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT |
			   MSGLEVEL_NO_ACT,
			   TXT_OWN_MSG_CHANNEL,
			   server->nick, optarget, msg, nickmode);
        g_free(optarget);
}
Beispiel #21
0
/* received msg to all ops in channel */
static void sig_message_irc_op_public(SERVER_REC *server, const char *msg,
				      const char *nick, const char *address,
				      const char *target)
{
	char *nickmode, *optarget;

	nickmode = channel_get_nickmode(channel_find(server, target),
					server->nick);

        optarget = g_strconcat("@", target, NULL);
	printformat_module("fe-common/core", server, target,
			   MSGLEVEL_PUBLIC,
			   TXT_PUBMSG_CHANNEL,
			   nick, optarget, msg, nickmode);
        g_free(optarget);
}
Beispiel #22
0
static void sig_message_own_public(SERVER_REC *server, const char *msg,
				   const char *target, const char *origtarget)
{
	char *nickmode;

	if (IS_IRC_SERVER(server) && target != NULL &&
	    *target == '@' && ischannel(target[1])) {
		/* Hybrid 6 feature, send msg to all ops in channel */
		nickmode = channel_get_nickmode(channel_find(server, target+1),
						server->nick);

		printformat_module("fe-common/core", server, target+1,
				   MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT |
				   MSGLEVEL_NO_ACT,
				   TXT_OWN_MSG_CHANNEL,
				   server->nick, target, msg, nickmode);
                signal_stop();
	}
}
Beispiel #23
0
static void
sig_unsubscribed(XMPP_SERVER_REC *server, const char *jid)
{
	XMPP_ROSTER_USER_REC *user;
	char *name;

	g_return_if_fail(IS_SERVER(server));
	g_return_if_fail(jid != NULL);
	user = rosters_find_user(server->roster, jid, NULL, NULL);
	name = user != NULL && user->name != NULL ?
	    format_get_text(MODULE_NAME, NULL, server, NULL,
	        XMPPTXT_FORMAT_NAME, user->name, jid) :
	    format_get_text(MODULE_NAME, NULL, server, NULL,
	        XMPPTXT_FORMAT_JID, jid);
	if (settings_get_bool("xmpp_status_window"))
		printformat_module_window(MODULE_NAME,
		    fe_xmpp_status_get_window(server), MSGLEVEL_CRAP,
		    XMPPTXT_UNSUBSCRIBED, name);
	else
		printformat_module(MODULE_NAME, server, NULL, MSGLEVEL_CRAP,
		    XMPPTXT_UNSUBSCRIBED, name);
	g_free(name);
}
Beispiel #24
0
static void
sig_history_action(SERVER_REC *server, const char *msg, const char *nick,
    const char *target, const char *stamp, gpointer gpointer_type)
{
	void *item;
	char *text, *freemsg = NULL;
	int level, type;

	g_return_if_fail(server != NULL);
	g_return_if_fail(msg != NULL);
	g_return_if_fail(nick != NULL);
	g_return_if_fail(target != NULL);
	type = GPOINTER_TO_INT(gpointer_type);
	level = MSGLEVEL_ACTIONS | MSGLEVEL_NO_ACT | MSGLEVEL_NOHILIGHT
	    | (type == SEND_TARGET_CHANNEL ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS);
	item = type == SEND_TARGET_CHANNEL ?
	    (void *)channel_find(server, target) : query_find(server, nick);
	if (settings_get_bool("emphasis"))
		msg = freemsg = expand_emphasis(item, msg);
	/* MUC */
	if (type == SEND_TARGET_CHANNEL) {
		if (item && window_item_is_active(item))
			text = format_get_text(IRC_MODULE_NAME, NULL, server,
			    target, IRCTXT_ACTION_PUBLIC, nick, msg);
		else
			text = format_get_text(IRC_MODULE_NAME, NULL, server,
			    target, IRCTXT_ACTION_PUBLIC_CHANNEL, nick,
			    target, msg);
	/* General */
	} else
		text = format_get_text(IRC_MODULE_NAME, NULL, server,
		    nick, (item == NULL) ? IRCTXT_ACTION_PRIVATE : 
		    IRCTXT_ACTION_PRIVATE_QUERY, nick, nick, msg);
	printformat_module(MODULE_NAME, server, target, level,
	    XMPPTXT_MESSAGE_TIMESTAMP, stamp, text);
	g_free(freemsg);
}
Beispiel #25
0
static void
sig_own_action(SERVER_REC *server, const char *msg, const char *target,
    gpointer gpointer_type)
{
	void *item;
	char *freemsg = NULL;
	int type;

	g_return_if_fail(server != NULL);
	g_return_if_fail(msg != NULL);
	g_return_if_fail(target != NULL);

	type = GPOINTER_TO_INT(gpointer_type);
	item = type == SEND_TARGET_CHANNEL ?
	    (void *)channel_find(server, target) : query_find(server, target);
	if (settings_get_bool("emphasis"))
		msg = freemsg = expand_emphasis(item, msg);
	printformat_module(IRC_MODULE_NAME, server, target,
	    MSGLEVEL_ACTIONS | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT |
	    ((type == SEND_TARGET_CHANNEL) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS),
	    (item != NULL) ? IRCTXT_OWN_ACTION : IRCTXT_OWN_ACTION_TARGET,
	    server->nick, msg, target);
	g_free(freemsg);
}
Beispiel #26
0
static void
sig_started(const char *username, const char *domain)
{
	printformat_module(MODULE_NAME, NULL, NULL,
	    MSGLEVEL_CRAP, XMPPTXT_REGISTRATION_STARTED, username, domain);
}
static void
sig_server_status(SERVER_REC *server, const char *msg)
{
	printformat_module(MODULE_NAME, server, NULL, MSGLEVEL_CLIENTNOTICE,
	    XMPPTXT_DEFAULT_EVENT, NULL, msg, NULL);
}
Beispiel #28
0
/*
 * Print a message using the public message format (to channel)
 * Can be from others or ourselves
 */
void
print_message_public(SERVER_REC* server_rec, CHANNEL_REC* channel_rec,
	char* target, char* nick, char* address, char* msg)
{
	// See fe-common/core/fe-messages.c, sig_message_public()
	// and fe-common/irc/fe-irc-messages.c, sig_message_irc_op_public()
	// for the below.

	char* nickmode = channel_get_nickmode(channel_rec, nick);

	// Check if hilight by someone referring to me
	int for_me = nick_match_msg(channel_rec, msg, server_rec->nick);

	// Also can hilight based on address?
	int hilight;
	if (address != NULL) {
		hilight = for_me
			|| hilight_match_nick(server_rec, target, nick, address,
					MSGLEVEL_PUBLIC, msg);
	} else {
		hilight = for_me;
	}

	// If channel is active, we don't need to use the format which includes
	// channel name, such as <@nick:#channel>
	int should_print_channel = channel_rec == NULL
		|| !window_item_is_active((WI_ITEM_REC*) channel_rec);

	// Check if it was us that said this
	int from_me = strcmp(nick, server_rec->nick) == 0;

	// Fix up the message level
	int msg_level = MSGLEVEL_PUBLIC;
	// We don't want to hilight ourselves
	if (!from_me && hilight) {
		msg_level |= MSGLEVEL_HILIGHT;
	}
	
	if (should_print_channel) {
		if (from_me) {
			printformat_module("fe-common/core", server_rec, target, msg_level,
				TXT_OWN_MSG_CHANNEL,
				nick, target, msg, nickmode);
		} else {
			printformat_module("fe-common/core", server_rec, target, msg_level,
				hilight ? TXT_PUBMSG_ME_CHANNEL : TXT_PUBMSG_CHANNEL,
				nick, target, msg, nickmode);
		}
	} else {
		if (from_me) {
			printformat_module("fe-common/core", server_rec, target, msg_level,
				TXT_OWN_MSG,
				nick, msg, nickmode);
		} else {
			printformat_module("fe-common/core", server_rec, target, msg_level,
				hilight ? TXT_PUBMSG_ME : TXT_PUBMSG,
				nick, msg, nickmode);
		}
	}
	g_free_not_null(nickmode);
}