Hello community, here is the log from the commit of package purple-carbons for openSUSE:Factory checked in at 2018-10-04 19:01:48 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/purple-carbons (Old) and /work/SRC/openSUSE:Factory/.purple-carbons.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "purple-carbons" Thu Oct 4 19:01:48 2018 rev:3 rq:639811 version:0.2.0 Changes: -------- --- /work/SRC/openSUSE:Factory/purple-carbons/purple-carbons.changes 2018-09-25 15:43:02.065251324 +0200 +++ /work/SRC/openSUSE:Factory/.purple-carbons.new/purple-carbons.changes 2018-10-04 19:01:49.207182843 +0200 @@ -1,0 +2,8 @@ +Wed Oct 3 18:13:00 UTC 2018 - Martin Herkt <9+suse@cirno.systems> + +- Update to version 0.2.0: + * Got rid of the commands, the plugin now sends a feature + discovery request to the server and activates message carbons + if they are supported by the server. + +------------------------------------------------------------------- Old: ---- carbons-0.1.6.tar.gz New: ---- carbons-0.2.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ purple-carbons.spec ++++++ --- /var/tmp/diff_new_pack.uV05Qn/_old 2018-10-04 19:01:49.595182435 +0200 +++ /var/tmp/diff_new_pack.uV05Qn/_new 2018-10-04 19:01:49.595182435 +0200 @@ -19,7 +19,7 @@ %define _name carbons %define _purple_plugindir %(pkg-config --variable plugindir purple) Name: purple-carbons -Version: 0.1.6 +Version: 0.2.0 Release: 0 Summary: Experimental XEP-0280: Message Carbons plugin for libpurple License: GPL-2.0-or-later ++++++ carbons-0.1.6.tar.gz -> carbons-0.2.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/carbons-0.1.6/README.md new/carbons-0.2.0/README.md --- old/carbons-0.1.6/README.md 2018-09-23 16:24:13.000000000 +0200 +++ new/carbons-0.2.0/README.md 2018-10-03 15:33:19.000000000 +0200 @@ -1,4 +1,4 @@ -# carbons 0.1.6 +# carbons 0.2.0 Experimental XEP-0280: Message Carbons plugin for libpurple (Pidgin, Finch, etc.) ## Installation @@ -38,9 +38,9 @@ For this, you have to set up a build environment as described in https://developer.pidgin.im/wiki/BuildingWinPidgin . ## Usage -As some servers might not support message carbons or for some reason disallow enabling them, you have to activate them individually for every account. -To do this, open any chat window from that account and type `/carbons on`. You should see the result immediately (success or error). It will then enable carbons at every startup. -If you want to deactivate the plugin again, type `/carbons off`. +Unlike in previous versions, there is no need to interact with the plugin. On startup, it sends a feature discovery request to the server and automatically enables message carbons if the server lists it among its supported features. + +If something is not working right, consult the debug window. ## Caveats -Also note that this only synchronizes messages of devices that are online at the same time - for history synchronization, MAM is needed. +Note that this only synchronizes messages of devices that are online at the same time - for history synchronization, MAM is needed. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/carbons-0.1.6/src/carbons.c new/carbons-0.2.0/src/carbons.c --- old/carbons-0.1.6/src/carbons.c 2018-09-23 16:24:13.000000000 +0200 +++ new/carbons-0.2.0/src/carbons.c 2018-10-03 15:33:19.000000000 +0200 @@ -33,8 +33,9 @@ #define CARBONS_SETTING_NAME "carbons-enabled" #define CARBONS_LOG_CATEGORY "carbons" -#define CARBONS_XMLNS "urn:xmpp:carbons:2" #define XMLNS_ATTR_NAME "xmlns" +#define CARBONS_XMLNS "urn:xmpp:carbons:2" +#define DISCO_XMLNS "http://jabber.org/protocol/disco#info" // see XEP-0030: Service Discovery (https://xmpp.org/extensions/xep-0030.html) #define CARBONS_ENABLE 1 #define CARBONS_DISABLE 0 @@ -156,17 +157,14 @@ } static void carbons_autoenable_cb(JabberStream * js_p, const char * from, - JabberIqType type, const char * id, - xmlnode * packet_p, gpointer data_p) { - + JabberIqType type, const char * id, + xmlnode * packet_p, gpointer data_p) { const char * accname = purple_account_get_username(purple_connection_get_account(js_p->gc)); if (type == JABBER_IQ_ERROR) { - 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); + purple_debug_error(CARBONS_LOG_CATEGORY, "Server returned an error when trying to activate carbons for %s.\n", accname); } else { - 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); + purple_debug_info(CARBONS_LOG_CATEGORY, "Successfully activated carbons for %s.\n", accname); } } @@ -182,89 +180,67 @@ jabber_iq_set_callback(jiq_p, carbons_autoenable_cb, (void *) 0); jabber_iq_send(jiq_p); - purple_debug_info(CARBONS_LOG_CATEGORY, "Sent startup enable request for %s\n", purple_account_get_username(acc_p)); + purple_debug_info(CARBONS_LOG_CATEGORY, "Sent enable request for %s.\n", purple_account_get_username(acc_p)); } -static void carbons_account_connect_cb(PurpleAccount * acc_p) { - if (strcmp(purple_account_get_protocol_id(acc_p), "prpl-jabber")) { +static void carbons_discover_cb(JabberStream * js_p, const char * from, + JabberIqType type, const char * id, + xmlnode * packet_p, gpointer data_p) { + xmlnode * query_node_p = (void *) 0; + xmlnode * feature_node_p = (void *) 0; + + const char * feature_name = (void *) 0; + const char * accname = purple_account_get_username(purple_connection_get_account(js_p->gc)); + + if (type == JABBER_IQ_ERROR) { + purple_debug_error(CARBONS_LOG_CATEGORY, "Server returned an error when trying to discover carbons for %s.\n", accname); return; } - if (!purple_account_get_bool(acc_p, CARBONS_SETTING_NAME, FALSE)) { + query_node_p = xmlnode_get_child_with_namespace(packet_p, "query", DISCO_XMLNS); + if (!query_node_p) { + purple_debug_error(CARBONS_LOG_CATEGORY, "No 'query' node in feature discovery reply for %s.\n", accname); return; } - carbons_autoenable(acc_p); -} - -static void carbons_switch_cb(JabberStream * js_p, const char * from, - JabberIqType type, const char * id, - xmlnode * packet_p, gpointer data_p) { - PurpleConversation * conv_p = (PurpleConversation *) data_p; - - if (type == JABBER_IQ_ERROR) { - 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); - } else { - purple_account_set_bool(purple_conversation_get_account(conv_p), CARBONS_SETTING_NAME, TRUE); - } - } else { - 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); - } else { - purple_account_set_bool(purple_conversation_get_account(conv_p), CARBONS_SETTING_NAME, FALSE); + for (feature_node_p = xmlnode_get_child(query_node_p, "feature"); feature_node_p; feature_node_p = feature_node_p->next) { + feature_name = xmlnode_get_attrib(feature_node_p, "var"); + if (!g_strcmp0(CARBONS_XMLNS, feature_name)) { + purple_debug_info(CARBONS_LOG_CATEGORY, "Found carbons in server features, sending enable request for %s.\n", accname); + carbons_autoenable(purple_connection_get_account(js_p->gc)); + return; } } -} -static void carbons_switch_do(PurpleConversation * conv_p, int mode) { - JabberIq * jiq_p = (void *) 0; - xmlnode * req_node_p = (void *) 0; + purple_debug_info(CARBONS_LOG_CATEGORY, "Server does not support message carbons, therefore doing nothing for %s.\n", accname); +} - mode_global = mode; - const char * mode_str = mode ? "enable" : "disable"; - JabberStream * js_p = purple_connection_get_protocol_data(purple_account_get_connection(purple_conversation_get_account(conv_p))); +static void carbons_discover(PurpleAccount * acc_p) { + JabberIq * jiq_p = (void *) 0; + xmlnode * query_node_p = (void *) 0; + JabberStream * js_p = purple_connection_get_protocol_data(purple_account_get_connection(acc_p)); + const char * username = purple_account_get_username(acc_p); - jiq_p = jabber_iq_new(js_p, JABBER_IQ_SET); - req_node_p = xmlnode_new_child(jiq_p->node, mode_str); - xmlnode_set_namespace(req_node_p, CARBONS_XMLNS); + jiq_p = jabber_iq_new(js_p, JABBER_IQ_GET); + xmlnode_set_attrib(jiq_p->node, "to", jabber_get_domain(username)); + query_node_p = xmlnode_new_child(jiq_p->node, "query"); + xmlnode_set_namespace(query_node_p, DISCO_XMLNS); - jabber_iq_set_callback(jiq_p, carbons_switch_cb, conv_p); + jabber_iq_set_callback(jiq_p, carbons_discover_cb, (void *) 0); jabber_iq_send(jiq_p); - 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))); + purple_debug_info(CARBONS_LOG_CATEGORY, "Sent feature discovery request for %s.\n", purple_account_get_username(acc_p)); } -static PurpleCmdRet carbons_cmd_func(PurpleConversation * conv_p, - const gchar * cmd, - gchar ** args, - gchar ** error, - void * data_p) { - - char * msg = (void *) 0; - const char * username = purple_account_get_username(purple_conversation_get_account(conv_p)); - - if (!g_strcmp0(args[0], "on")) { - msg = g_strdup_printf("Turning carbons ON for %s...", username); - carbons_switch_do(conv_p, CARBONS_ENABLE); - } else if (!g_strcmp0(args[0], "off")) { - msg = g_strdup_printf("Turning carbons OFF for %s...", username); - carbons_switch_do(conv_p, CARBONS_DISABLE); - } else { - msg = g_strdup_printf("No such command. Usage: /carbons [on|off]"); - } - - if (msg) { - purple_conversation_write(conv_p, CARBONS_LOG_CATEGORY, msg, PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time((void *) 0)); +static void carbons_account_connect_cb(PurpleAccount * acc_p) { + if (strcmp(purple_account_get_protocol_id(acc_p), "prpl-jabber")) { + return; } - g_free(msg); + // "migration code" - remove obsolete setting + purple_account_remove_setting(acc_p, CARBONS_SETTING_NAME); - return PURPLE_CMD_RET_OK; + carbons_discover(acc_p); } static gboolean @@ -276,16 +252,6 @@ (void) jabber_add_feature(CARBONS_XMLNS, (void *) 0); - carbons_cmd_id = purple_cmd_register("carbons", - "w", - PURPLE_CMD_P_PLUGIN, - PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, - "prpl-jabber", - carbons_cmd_func, - "carbons <on|off>: " - "Turns Message Carbons on or off for the calling account.", - (void *) 0); - (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); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/carbons-0.1.6/src/carbons.h new/carbons-0.2.0/src/carbons.h --- old/carbons-0.1.6/src/carbons.h 2018-09-23 16:24:13.000000000 +0200 +++ new/carbons-0.2.0/src/carbons.h 2018-10-03 15:33:19.000000000 +0200 @@ -1,7 +1,7 @@ #ifndef __CARBONS_H # define __CARBONS_H -# define CARBONS_VERSION "0.1.6" +# define CARBONS_VERSION "0.2.0" # define CARBONS_AUTHOR "Richard Bayerle <r...@firemail.cc>" #endif /* __CARBONS_H */