Hello community, here is the log from the commit of package purple-carbons for openSUSE:Factory checked in at 2018-09-25 15:43:00 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/purple-carbons (Old) and /work/SRC/openSUSE:Factory/.purple-carbons.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "purple-carbons" Tue Sep 25 15:43:00 2018 rev:2 rq:637716 version:0.1.6 Changes: -------- --- /work/SRC/openSUSE:Factory/purple-carbons/purple-carbons.changes 2018-05-15 10:33:45.971385582 +0200 +++ /work/SRC/openSUSE:Factory/.purple-carbons.new/purple-carbons.changes 2018-09-25 15:43:02.065251324 +0200 @@ -1,0 +2,6 @@ +Mon Sep 24 14:27:32 UTC 2018 - sor.ale...@meowr.ru + +- Update to version 0.1.6: + * Clean up the code a bit. + +------------------------------------------------------------------- Old: ---- carbons-0.1.5.tar.gz New: ---- carbons-0.1.6.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ purple-carbons.spec ++++++ --- /var/tmp/diff_new_pack.B6PjqE/_old 2018-09-25 15:43:02.901250430 +0200 +++ /var/tmp/diff_new_pack.B6PjqE/_new 2018-09-25 15:43:02.905250426 +0200 @@ -12,14 +12,14 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # %define _name carbons %define _purple_plugindir %(pkg-config --variable plugindir purple) Name: purple-carbons -Version: 0.1.5 +Version: 0.1.6 Release: 0 Summary: Experimental XEP-0280: Message Carbons plugin for libpurple License: GPL-2.0-or-later ++++++ carbons-0.1.5.tar.gz -> carbons-0.1.6.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/carbons-0.1.5/Makefile new/carbons-0.1.6/Makefile --- old/carbons-0.1.5/Makefile 2018-04-29 00:05:14.000000000 +0200 +++ new/carbons-0.1.6/Makefile 2018-09-23 16:24:13.000000000 +0200 @@ -32,7 +32,7 @@ $(LIBPURPLE_LDFLAGS) \ $(XML2_LDFLAGS) -CFLAGS=-std=c11 -Wall -g -Wstrict-overflow -fPIC -shared -D_XOPEN_SOURCE=700 -D_BSD_SOURCE $(PKGCFG_C) $(HEADERS) +CFLAGS=-std=c11 -Wall -g -Wstrict-overflow -fPIC -shared -D_XOPEN_SOURCE=700 -D_BSD_SOURCE -D_DEFAULT_SOURCE $(PKGCFG_C) $(HEADERS) PLUGIN_CPPFLAGS=-DPURPLE_PLUGINS ifneq ("$(wildcard /etc/redhat-release)","") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/carbons-0.1.5/README.md new/carbons-0.1.6/README.md --- old/carbons-0.1.5/README.md 2018-04-29 00:05:14.000000000 +0200 +++ new/carbons-0.1.6/README.md 2018-09-23 16:24:13.000000000 +0200 @@ -1,4 +1,4 @@ -# carbons 0.1.5 +# carbons 0.1.6 Experimental XEP-0280: Message Carbons plugin for libpurple (Pidgin, Finch, etc.) ## Installation diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/carbons-0.1.5/src/carbons.c new/carbons-0.1.6/src/carbons.c --- old/carbons-0.1.5/src/carbons.c 2018-04-29 00:05:14.000000000 +0200 +++ new/carbons-0.1.6/src/carbons.c 2018-09-23 16:24:13.000000000 +0200 @@ -22,11 +22,7 @@ #include <stdlib.h> #include <string.h> -#include "cmds.h" -#include "debug.h" -#include "notify.h" -#include "plugin.h" -#include "version.h" +#include <purple.h> #include "iq.h" @@ -35,11 +31,12 @@ #define JABBER_PROTOCOL_ID "prpl-jabber" #define CARBONS_SETTING_NAME "carbons-enabled" +#define CARBONS_LOG_CATEGORY "carbons" -#define CARBONS_XMLNS "urn:xmpp:carbons:2" +#define CARBONS_XMLNS "urn:xmpp:carbons:2" #define XMLNS_ATTR_NAME "xmlns" -#define CARBONS_ENABLE 1 +#define CARBONS_ENABLE 1 #define CARBONS_DISABLE 0 int carbons_cmd_id; @@ -51,7 +48,7 @@ split = g_strsplit(purple_account_get_username(acc_p), "/", 2); if (g_strcmp0(split[0], xmlnode_get_attrib(outer_msg_stanza_p, "from"))) { - purple_debug_warning("carbons", "Invalid sender: %s (should be: %s)\n", xmlnode_get_attrib(outer_msg_stanza_p, "from"), split[0]); + purple_debug_warning(CARBONS_LOG_CATEGORY, "Invalid sender: %s (should be: %s)\n", xmlnode_get_attrib(outer_msg_stanza_p, "from"), split[0]); g_strfreev(split); return 0; } else { @@ -64,32 +61,25 @@ xmlnode * carbons_node_p = (void *) 0; xmlnode * forwarded_node_p = (void *) 0; xmlnode * msg_node_p = (void *) 0; - xmlnode * body_node_p = (void *) 0; - xmlnode * encrypted_node_p = (void *) 0; - - int passthrough = 0; - - char * buddy_name_bare = (void *) 0; - PurpleConversation * conv_p = (void *) 0; carbons_node_p = xmlnode_get_child_with_namespace(*stanza_pp, "received", CARBONS_XMLNS); if (carbons_node_p) { - purple_debug_info("carbons", "Received carbon copy of a received message.\n"); + purple_debug_info(CARBONS_LOG_CATEGORY, "Received carbon copy of a received message.\n"); if (!carbons_is_valid(purple_connection_get_account(gc_p), *stanza_pp)) { - purple_debug_warning("carbons", "Ignoring carbon copy of received message with invalid sender.\n"); + purple_debug_warning(CARBONS_LOG_CATEGORY, "Ignoring carbon copy of received message with invalid sender.\n"); return; } forwarded_node_p = xmlnode_get_child(carbons_node_p, "forwarded"); if (!forwarded_node_p) { - purple_debug_error("carbons", "Ignoring carbon copy of received message that does not contain a 'forwarded' node.\n"); + purple_debug_error(CARBONS_LOG_CATEGORY, "Ignoring carbon copy of received message that does not contain a 'forwarded' node.\n"); return; } msg_node_p = xmlnode_get_child(forwarded_node_p, "message"); if (!msg_node_p) { - purple_debug_error("carbons", "Ignoring carbon copy of received message that does not contain a 'message' node.\n"); + purple_debug_error(CARBONS_LOG_CATEGORY, "Ignoring carbon copy of received message that does not contain a 'message' node.\n"); return; } @@ -101,54 +91,66 @@ carbons_node_p = xmlnode_get_child_with_namespace(*stanza_pp, "sent", CARBONS_XMLNS); if (carbons_node_p) { - purple_debug_info("carbons", "Received carbon copy of a sent message.\n"); + purple_debug_info(CARBONS_LOG_CATEGORY, "Received carbon copy of a sent message.\n"); if (!carbons_is_valid(purple_connection_get_account(gc_p), *stanza_pp)) { - purple_debug_warning("carbons", "Ignoring carbon copy of sent message with invalid sender.\n"); + purple_debug_warning(CARBONS_LOG_CATEGORY, "Ignoring carbon copy of sent message with invalid sender.\n"); return; } forwarded_node_p = xmlnode_get_child(carbons_node_p, "forwarded"); if (!forwarded_node_p) { - purple_debug_error("carbons", "Ignoring carbon copy of sent message that does not contain a 'forwarded' node.\n"); + purple_debug_error(CARBONS_LOG_CATEGORY, "Ignoring carbon copy of sent message that does not contain a 'forwarded' node.\n"); return; } msg_node_p = xmlnode_get_child(forwarded_node_p, "message"); if (!msg_node_p) { - purple_debug_error("carbons", "Ignoring carbon copy of sent message that does not contain a 'message' node.\n"); + purple_debug_error(CARBONS_LOG_CATEGORY, "Ignoring carbon copy of sent message that does not contain a 'message' node.\n"); return; } - body_node_p = xmlnode_get_child(msg_node_p, "body"); - if (!body_node_p) { - purple_debug_info("carbons", "Carbon copy of sent message does not contain a body - stripping and passing it through.\n"); - passthrough = 1; - } + // add an empty node inside the message node for detection in later callback + carbons_node_p = xmlnode_new_child(msg_node_p, "sent"); + xmlnode_set_namespace(carbons_node_p, CARBONS_XMLNS); - encrypted_node_p = xmlnode_get_child(msg_node_p, "encrypted"); - if (encrypted_node_p) { - purple_debug_info("carbons", "Carbon copy of sent message contains a body, but also an additional encrypted element - stripping and passing it through.\n"); - passthrough = 1; - } + purple_debug_info(CARBONS_LOG_CATEGORY, "Stripped carbons envelope of a sent message and passing through the message stanza.\n"); + msg_node_p = xmlnode_copy(msg_node_p); + xmlnode_free(*stanza_pp); + *stanza_pp = msg_node_p; + } +} - if (passthrough) { - msg_node_p = xmlnode_copy(msg_node_p); - xmlnode_free(*stanza_pp); - *stanza_pp = msg_node_p; +// libpurple doesn't know what to do with incoming messages addressed to someone else, so they need to be written to the conversation manually +// checks for presence of a <sent /> node that was inserted in the initial handler +static void carbons_xml_stripped_cb(PurpleConnection * gc_p, xmlnode ** stanza_pp) { + xmlnode * carbons_node_p = (void *) 0; + xmlnode * body_node_p = (void *) 0; + char * buddy_name_bare = (void *) 0; + PurpleConversation * conv_p = (void *) 0; - return; - } + if (g_strcmp0((*stanza_pp)->name, "message")) { + return; + } + + carbons_node_p = xmlnode_get_child_with_namespace(*stanza_pp, "sent", CARBONS_XMLNS); + if (!carbons_node_p) { + return; + } - buddy_name_bare = jabber_get_bare_jid(xmlnode_get_attrib(msg_node_p, "to")); + body_node_p = xmlnode_get_child(*stanza_pp, "body"); + if (body_node_p) { + buddy_name_bare = jabber_get_bare_jid(xmlnode_get_attrib(*stanza_pp, "to")); conv_p = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, buddy_name_bare, purple_connection_get_account(gc_p)); if (!conv_p) { conv_p = purple_conversation_new(PURPLE_CONV_TYPE_IM, purple_connection_get_account(gc_p), buddy_name_bare); } - purple_debug_info("carbons", "Writing body of the carbon copy of a sent message to the conversation window with %s.\n", buddy_name_bare); - purple_conversation_write(conv_p, xmlnode_get_attrib(msg_node_p, "from"), xmlnode_get_data(body_node_p), PURPLE_MESSAGE_SEND, time((void *) 0)); + purple_debug_info(CARBONS_LOG_CATEGORY, "Writing body of the carbon copy of a sent message to the conversation window with %s.\n", buddy_name_bare); + purple_conversation_write(conv_p, xmlnode_get_attrib(*stanza_pp, "from"), xmlnode_get_data(body_node_p), PURPLE_MESSAGE_SEND, time((void *) 0)); + xmlnode_free(*stanza_pp); + *stanza_pp = (void *) 0; g_free(buddy_name_bare); } } @@ -160,10 +162,10 @@ const char * accname = purple_account_get_username(purple_connection_get_account(js_p->gc)); if (type == JABBER_IQ_ERROR) { - purple_debug_error("carbons", "Server returned an error when trying to automatically activate carbons for %s.\n", accname); + purple_debug_error(CARBONS_LOG_CATEGORY, "Server returned an error when trying to automatically activate carbons for %s.\n", accname); purple_account_set_bool(purple_connection_get_account(js_p->gc), CARBONS_SETTING_NAME, FALSE); } else { - purple_debug_info("carbons", "Successfully automatically activated carbons for %s.\n", accname); + purple_debug_info(CARBONS_LOG_CATEGORY, "Successfully automatically activated carbons for %s.\n", accname); purple_account_set_bool(purple_connection_get_account(js_p->gc), CARBONS_SETTING_NAME, TRUE); } } @@ -180,7 +182,7 @@ jabber_iq_set_callback(jiq_p, carbons_autoenable_cb, (void *) 0); jabber_iq_send(jiq_p); - purple_debug_info("carbons", "Sent startup enable request for %s\n", purple_account_get_username(acc_p)); + purple_debug_info(CARBONS_LOG_CATEGORY, "Sent startup enable request for %s\n", purple_account_get_username(acc_p)); } static void carbons_account_connect_cb(PurpleAccount * acc_p) { @@ -201,7 +203,7 @@ PurpleConversation * conv_p = (PurpleConversation *) data_p; if (type == JABBER_IQ_ERROR) { - purple_conversation_write(conv_p, "carbons", "Server returned an error. See the debug log for more info.", PURPLE_MESSAGE_ERROR | PURPLE_MESSAGE_NO_LOG, time((void *) 0)); + purple_conversation_write(conv_p, CARBONS_LOG_CATEGORY, "Server returned an error. See the debug log for more info.", PURPLE_MESSAGE_ERROR | PURPLE_MESSAGE_NO_LOG, time((void *) 0)); if (mode_global) { purple_account_set_bool(purple_conversation_get_account(conv_p), CARBONS_SETTING_NAME, FALSE); @@ -209,7 +211,7 @@ purple_account_set_bool(purple_conversation_get_account(conv_p), CARBONS_SETTING_NAME, TRUE); } } else { - purple_conversation_write(conv_p, "carbons", "Success!", PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time((void *) 0)); + purple_conversation_write(conv_p, CARBONS_LOG_CATEGORY, "Success!", PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time((void *) 0)); if (mode_global) { purple_account_set_bool(purple_conversation_get_account(conv_p), CARBONS_SETTING_NAME, TRUE); @@ -234,7 +236,7 @@ jabber_iq_set_callback(jiq_p, carbons_switch_cb, conv_p); jabber_iq_send(jiq_p); - purple_debug_info("carbons", "Sent %s request for %s\n", mode_str, purple_account_get_username(purple_connection_get_account(js_p->gc))); + purple_debug_info(CARBONS_LOG_CATEGORY, "Sent %s request for %s\n", mode_str, purple_account_get_username(purple_connection_get_account(js_p->gc))); } static PurpleCmdRet carbons_cmd_func(PurpleConversation * conv_p, @@ -257,7 +259,7 @@ } if (msg) { - purple_conversation_write(conv_p, "carbons", msg, PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time((void *) 0)); + purple_conversation_write(conv_p, CARBONS_LOG_CATEGORY, msg, PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time((void *) 0)); } g_free(msg); @@ -286,6 +288,7 @@ (void) purple_signal_connect(purple_accounts_get_handle(), "account-signed-on", plugin_p, PURPLE_CALLBACK(carbons_account_connect_cb), NULL); (void) purple_signal_connect_priority(purple_plugins_find_with_id("prpl-jabber"), "jabber-receiving-xmlnode", plugin_p, PURPLE_CALLBACK(carbons_xml_received_cb), NULL, PURPLE_PRIORITY_LOWEST + 100); + (void) purple_signal_connect_priority(purple_plugins_find_with_id("prpl-jabber"), "jabber-receiving-xmlnode", plugin_p, PURPLE_CALLBACK(carbons_xml_stripped_cb), NULL, PURPLE_PRIORITY_HIGHEST - 50); // manually call init code if there are already accounts connected, e.g. when plugin is loaded manually accs_l_p = purple_accounts_get_all_active(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/carbons-0.1.5/src/carbons.h new/carbons-0.1.6/src/carbons.h --- old/carbons-0.1.5/src/carbons.h 2018-04-29 00:05:14.000000000 +0200 +++ new/carbons-0.1.6/src/carbons.h 2018-09-23 16:24:13.000000000 +0200 @@ -1,7 +1,7 @@ #ifndef __CARBONS_H # define __CARBONS_H -# define CARBONS_VERSION "0.1.5" +# define CARBONS_VERSION "0.1.6" # define CARBONS_AUTHOR "Richard Bayerle <r...@firemail.cc>" #endif /* __CARBONS_H */