Package: irssi-plugin-xmpp / 0.54-3

ailin-nemui-0008-Add-support-for-messages-coming-directly-from-room.patch Patch series | download
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
From f5f403961df4ad5a739c6a83619816133d84eefb Mon Sep 17 00:00:00 2001
From: Paul Fariello <pfariello@arkoon.dev>
Date: Tue, 24 Jan 2017 17:21:31 +0100
Subject: [PATCH 08/44] Add support for messages coming directly from room

---
 src/core/xep/muc-events.c        | 37 +++++++++++++++++++++----------------
 src/fe-common/fe-xmpp-messages.c | 22 ++++++++++++++++++++++
 src/fe-common/module-formats.c   |  1 +
 src/fe-common/module-formats.h   |  1 +
 4 files changed, 45 insertions(+), 16 deletions(-)

--- a/src/core/xep/muc-events.c
+++ b/src/core/xep/muc-events.c
@@ -546,24 +546,29 @@
 			g_free(str);
 		}
 		node = lm_message_node_get_child(lmsg->node, "body");
-		if (node != NULL && node->value != NULL && nick != NULL) {
+		if (node != NULL && node->value != NULL) {
 			str = xmpp_recode_in(node->value);
-			own = strcmp(nick, channel->nick) == 0;
-			action = g_ascii_strncasecmp(str, "/me ", 4) == 0;
-			if (action && own)
-				signal_emit("message xmpp own_action", 4,
-				    server, str+4, channel->name,
-				    GINT_TO_POINTER(SEND_TARGET_CHANNEL));
-			else if (action)
-				signal_emit("message xmpp action", 5,
-				    server, str+4, nick, channel->name,
-				    GINT_TO_POINTER(SEND_TARGET_CHANNEL));
-			else if (own)
-				signal_emit("message xmpp own_public", 3,
+			if (nick != NULL) {
+				own = strcmp(nick, channel->nick) == 0;
+				action = g_ascii_strncasecmp(str, "/me ", 4) == 0;
+				if (action && own)
+					signal_emit("message xmpp own_action", 4,
+					    server, str+4, channel->name,
+					    GINT_TO_POINTER(SEND_TARGET_CHANNEL));
+				else if (action)
+					signal_emit("message xmpp action", 5,
+					    server, str+4, nick, channel->name,
+					    GINT_TO_POINTER(SEND_TARGET_CHANNEL));
+				else if (own)
+					signal_emit("message xmpp own_public", 3,
+					    server, str, channel->name);
+				else
+					signal_emit("message public", 5,
+					    server, str, nick, "", channel->name);
+			} else {
+				signal_emit("message xmpp room", 3,
 				    server, str, channel->name);
-			else
-				signal_emit("message public", 5,
-				    server, str, nick, "", channel->name);
+			}
 			g_free(str);
 		}
 		break;
--- a/src/fe-common/fe-xmpp-messages.c
+++ b/src/fe-common/fe-xmpp-messages.c
@@ -189,6 +189,26 @@
 }
 
 static void
+sig_room(SERVER_REC *server, const char *msg, const char *target)
+{
+	CHANNEL_REC *channel;
+	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);
+
+	channel = channel_find(server, target);
+	if (settings_get_bool("emphasis"))
+		msg = freemsg = expand_emphasis(item, msg);
+	printformat_module(MODULE_NAME, server, target, MSGLEVEL_PUBLIC,
+	    XMPPTXT_MESSAGE_ROOM, msg);
+	g_free(freemsg);
+}
+
+static void
 sig_error(XMPP_SERVER_REC *server, const char *full_jid,
     const char *msg)
 {
@@ -257,6 +277,7 @@
 	signal_add("message xmpp history action", sig_history_action);
 	signal_add("message xmpp action", sig_action);
 	signal_add("message xmpp own_action", sig_own_action);
+	signal_add("message xmpp room", sig_room);
 	signal_add("message xmpp error", sig_error);
 	signal_add_first("message xmpp own_public", sig_message_own_public);
 	signal_add_first("message own_public", sig_message_ignore);
@@ -269,6 +290,7 @@
 	signal_remove("message xmpp history action", sig_history_action);
 	signal_remove("message xmpp action", sig_action);
 	signal_remove("message xmpp own_action", sig_own_action);
+	signal_remove("message xmpp room", sig_room);
 	signal_remove("message xmpp error", sig_error);
 	signal_remove("message xmpp own_public", sig_message_own_public);
 	signal_remove("message own_public", sig_message_ignore);
--- a/src/fe-common/module-formats.c
+++ b/src/fe-common/module-formats.c
@@ -52,6 +52,7 @@
 	/* ---- */
 	{ NULL, "Message", 0, { 0 } },
 
+	{ "message_room", "$0", 1,  { 0 } },
 	{ "message_event", "$0: $1", 2,  { 0, 0 } },
 	{ "message_not_delivered", "$0: cannot deliver message {comment $1}", 2,  { 0, 0 } },
 	{ "message_timestamp", "[{timestamp $0}] $1", 2, { 0, 0 } },
--- a/src/fe-common/module-formats.h
+++ b/src/fe-common/module-formats.h
@@ -30,6 +30,7 @@
 
 	XMPPTXT_FILL_4,
 
+	XMPPTXT_MESSAGE_ROOM,
 	XMPPTXT_MESSAGE_EVENT,
 	XMPPTXT_MESSAGE_NOT_DELIVERED,
 	XMPPTXT_MESSAGE_TIMESTAMP,