File: fe-carbons.c

package info (click to toggle)
irssi-plugin-xmpp 0.54-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 1,952 kB
  • sloc: ansic: 8,831; makefile: 113; perl: 58
file content (63 lines) | stat: -rw-r--r-- 1,762 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "module.h"
#include "levels.h"
#include "module-formats.h"
#include "printtext.h"
#include "settings.h"
#include "signals.h"
#include "window-items.h"
#include "fe-messages.h"
#include "fe-queries.h"
#include "fe-common/core/module-formats.h"
#include "fe-common/core/fe-messages.h"
#include "fe-common/irc/module-formats.h"

#include "xmpp-servers.h"
#include "rosters-tools.h"
#include "xep/muc.h"

static void
sig_message_carbons_sent(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_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, target);

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

	if (type == SEND_TARGET_CHANNEL) {
		char *nickmode = channel_get_nickmode(item, nick);
		printformat_module(CORE_MODULE_NAME, server, target,
		    level, TXT_OWN_MSG_CHANNEL, nick, target, msg, nickmode);
	} else if(item) { // If no query, why do we want to see carbons?
		printformat_module(CORE_MODULE_NAME, server, target,
		    level, TXT_OWN_MSG_PRIVATE_QUERY, target, msg, nick);
	}

	g_free_not_null(freemsg);
}

void
fe_carbons_init(void)
{
	signal_add("message xmpp carbons sent", sig_message_carbons_sent);
}

void
fe_carbons_deinit(void)
{
	signal_remove("message xmpp carbons sent", sig_message_carbons_sent);
}