/soc/2015/koosha/main: cc6d6c1ffe6b: XEP-0280: do not auto reply...

Koosha Khajehmoogahi koosha at posteo.de
Tue Aug 4 13:11:09 EDT 2015


Changeset: cc6d6c1ffe6be77151224b3cd9cdd8652e94670d
Author:	 Koosha Khajehmoogahi <koosha at posteo.de>
Date:	 2015-08-04 19:09 +0200
Branch:	 default
URL: https://hg.pidgin.im/soc/2015/koosha/main/rev/cc6d6c1ffe6b

Description:

XEP-0280: do not auto reply on receiving forwarded messages

diffstat:

 libpurple/conversation.h             |  2 +-
 libpurple/protocols/jabber/message.c |  7 ++++++-
 libpurple/protocols/jabber/message.h |  3 ++-
 libpurple/server.c                   |  2 ++
 4 files changed, 11 insertions(+), 3 deletions(-)

diffs (85 lines):

diff --git a/libpurple/conversation.h b/libpurple/conversation.h
--- a/libpurple/conversation.h
+++ b/libpurple/conversation.h
@@ -130,7 +130,7 @@ typedef enum /*< flags >*/
 	PURPLE_MESSAGE_NICK         = 1 << 5,
 	PURPLE_MESSAGE_NO_LOG       = 1 << 6,
 	PURPLE_MESSAGE_REPLACE_LAST = 1 << 7,
-	/* The gap here is for backward compatibility with the old code */
+	PURPLE_MESSAGE_FORWARDED    = 1 << 8,
 	PURPLE_MESSAGE_ERROR        = 1 << 9,
 	PURPLE_MESSAGE_DELAYED      = 1 << 10,
 	PURPLE_MESSAGE_RAW          = 1 << 11,
diff --git a/libpurple/protocols/jabber/message.c b/libpurple/protocols/jabber/message.c
--- a/libpurple/protocols/jabber/message.c
+++ b/libpurple/protocols/jabber/message.c
@@ -231,6 +231,9 @@ static void handle_chat(JabberMessage *j
 			g_free(tmp);
 		}
 
+		if (jm->forwarded)
+			flags |= PURPLE_MESSAGE_FORWARDED;
+
 		flags |= jm->outgoing ? PURPLE_MESSAGE_SEND : PURPLE_MESSAGE_RECV;
 		purple_serv_got_im(gc, contact, jm->xhtml ? jm->xhtml : jm->body, flags, jm->sent);
 	}
@@ -628,7 +631,7 @@ void jabber_message_parse(JabberStream *
 	JabberMessage *jm;
 	const char *id, *from, *to, *type;
 	PurpleXmlNode *child;
-	gboolean signal_return, is_outgoing = FALSE;
+	gboolean signal_return, is_outgoing = FALSE, is_forwarded = FALSE;
 	time_t message_timestamp = time(NULL);
 	gboolean delayed = FALSE;
 
@@ -650,6 +653,7 @@ void jabber_message_parse(JabberStream *
 					received : sent, "forwarded", NS_FORWARD);
 
 			if (forwarded) {
+				is_forwarded = TRUE;
 				PurpleXmlNode *message = purple_xmlnode_get_child_with_namespace(forwarded, "message", NS_XMPP_CLIENT);
 				PurpleXmlNode *delay = purple_xmlnode_get_child_with_namespace(forwarded, "delay", NS_DELAYED_DELIVERY);
 
@@ -686,6 +690,7 @@ void jabber_message_parse(JabberStream *
 	jm->delayed = delayed;
 	jm->receipt = FALSE;
 	jm->chat_state = JM_STATE_NONE;
+	jm->forwarded = is_forwarded;
 	jm->outgoing = is_outgoing;
 
 	if(type) {
diff --git a/libpurple/protocols/jabber/message.h b/libpurple/protocols/jabber/message.h
--- a/libpurple/protocols/jabber/message.h
+++ b/libpurple/protocols/jabber/message.h
@@ -42,10 +42,11 @@ typedef struct _JabberMessage {
 	} type;
 	time_t sent;
 	gboolean delayed;
+	gboolean forwarded;
 	gboolean hasBuzz;
+	gboolean outgoing;
 	gboolean receipt;
 	gboolean replace_last;
-	gboolean outgoing;
 	char *id;
 	char *from;
 	char *to;
diff --git a/libpurple/server.c b/libpurple/server.c
--- a/libpurple/server.c
+++ b/libpurple/server.c
@@ -545,6 +545,7 @@ void purple_serv_got_im(PurpleConnection
 	 *  - it's not supported on this connection
 	 *  - we are available
 	 *  - or it's disabled
+	 *  - or the received message is a forwarded one that was originally sent to another client
 	 *  - or we're not idle and the 'only auto respond if idle' pref
 	 *    is set
 	 */
@@ -569,6 +570,7 @@ void purple_serv_got_im(PurpleConnection
 			(primitive == PURPLE_STATUS_INVISIBLE) ||
 			mobile ||
 		    purple_strequal(auto_reply_pref, "never") ||
+		    (flags & PURPLE_MESSAGE_FORWARDED) ||
 		    (!purple_presence_is_idle(presence) && purple_strequal(auto_reply_pref, "awayidle")))
 		{
 			g_free(name);



More information about the Commits mailing list