# HG changeset patch # User franky # Date 1413577999 -7200 # Node ID db6ca1e1e082cda716af9d14b2ed104dea3bdc26 # Parent 038c4d601011d77a4718370c52c01516c2ff3776 Remove support for obsolete XEP 22 diff -r 038c4d601011 -r db6ca1e1e082 mcabber/configure.ac --- a/mcabber/configure.ac Fri Oct 17 22:31:03 2014 +0200 +++ b/mcabber/configure.ac Fri Oct 17 22:33:19 2014 +0200 @@ -254,14 +254,6 @@ # Export $libexecdir to the source tree AC_DEFINE_DIR(PKGLIB_DIR, "${libdir}/${PACKAGE}", [Modules directory]) -AC_ARG_ENABLE(xep0022, - AC_HELP_STRING([--enable-xep0022], - [enable obsolete Message Events (XEP-0022)]), - xep0022=$enableval) -if test "${xep0022}" = "yes"; then - AC_DEFINE([XEP0022], 1, [Define if you want obsolete Message Events]) -fi - AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [add development compilation options]), debug=$enableval, debug="") diff -r 038c4d601011 -r db6ca1e1e082 mcabber/mcabber/roster.c --- a/mcabber/mcabber/roster.c Fri Oct 17 22:31:03 2014 +0200 +++ b/mcabber/mcabber/roster.c Fri Oct 17 22:33:19 2014 +0200 @@ -75,9 +75,6 @@ gchar *realjid; /* for chatrooms, if buddy's real jid is known */ guint events; char *caps; -#ifdef XEP0022 - struct xep0022 xep22; -#endif #ifdef XEP0085 struct xep0085 xep85; #endif @@ -155,10 +152,6 @@ g_free((gchar*)p_res->status_msg); g_free((gchar*)p_res->name); g_free((gchar*)p_res->realjid); -#ifdef XEP0022 - g_free(p_res->xep22.last_msgid_sent); - g_free(p_res->xep22.last_msgid_rcvd); -#endif #ifdef HAVE_GPGME g_free(p_res->pgpdata.sign_keyid); #endif @@ -1357,17 +1350,6 @@ } } -struct xep0022 *buddy_resource_xep22(gpointer rosterdata, const char *resname) -{ -#ifdef XEP0022 - roster *roster_usr = rosterdata; - res *p_res = get_resource(roster_usr, resname); - if (p_res) - return &p_res->xep22; -#endif - return NULL; -} - struct xep0085 *buddy_resource_xep85(gpointer rosterdata, const char *resname) { #ifdef XEP0085 diff -r 038c4d601011 -r db6ca1e1e082 mcabber/mcabber/roster.h --- a/mcabber/mcabber/roster.h Fri Oct 17 22:31:03 2014 +0200 +++ b/mcabber/mcabber/roster.h Fri Oct 17 22:33:19 2014 +0200 @@ -121,16 +121,8 @@ #define ROSTER_FLAG_USRLOCK (1U<<3) // Node should not be removed from buddylist // ROSTER_FLAG_LOCAL (1U<<4) // Buddy not on server's roster (??) -// #define XEP0022 (Officially obsoleted by XMPP Council) #define XEP0085 -struct xep0022 { - guint support; - guint last_state_sent; - gchar *last_msgid_sent; - guint last_state_rcvd; - gchar *last_msgid_rcvd; -}; struct xep0085 { guint support; guint last_state_sent; @@ -153,17 +145,12 @@ /* Message event and chat state flags */ #define ROSTER_EVENT_NONE 0U -/* XEP-22 Message Events */ -#define ROSTER_EVENT_OFFLINE (1U<<0) -#define ROSTER_EVENT_DELIVERED (1U<<1) -#define ROSTER_EVENT_DISPLAYED (1U<<2) -/* XEP-22 & XEP-85 */ -#define ROSTER_EVENT_COMPOSING (1U<<3) /* XEP-85 Chat State Notifications */ -#define ROSTER_EVENT_ACTIVE (1U<<4) -#define ROSTER_EVENT_PAUSED (1U<<5) -#define ROSTER_EVENT_INACTIVE (1U<<6) -#define ROSTER_EVENT_GONE (1U<<7) +#define ROSTER_EVENT_COMPOSING (1U<<0) +#define ROSTER_EVENT_ACTIVE (1U<<1) +#define ROSTER_EVENT_PAUSED (1U<<2) +#define ROSTER_EVENT_INACTIVE (1U<<3) +#define ROSTER_EVENT_GONE (1U<<4) extern GList *buddylist; extern GList *current_buddy; @@ -248,7 +235,6 @@ void buddy_resource_setcaps(gpointer rosterdata, const char *resname, const char *caps); char *buddy_resource_getcaps(gpointer rosterdata, const char *resname); -struct xep0022 *buddy_resource_xep22(gpointer rosterdata, const char *resname); struct xep0085 *buddy_resource_xep85(gpointer rosterdata, const char *resname); struct pgp_data *buddy_resource_pgp(gpointer rosterdata, const char *resname); enum imrole buddy_getrole(gpointer rosterdata, const char *resname); diff -r 038c4d601011 -r db6ca1e1e082 mcabber/mcabber/screen.c --- a/mcabber/mcabber/screen.c Fri Oct 17 22:31:03 2014 +0200 +++ b/mcabber/mcabber/screen.c Fri Oct 17 22:33:19 2014 +0200 @@ -89,7 +89,7 @@ static void scr_glog_print(const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data); -#if defined XEP0022 || defined XEP0085 +#ifdef XEP0085 static gboolean scr_chatstates_timeout(); #endif @@ -2380,7 +2380,7 @@ // If the chat state has changed, call xmpp_send_chatstate() static void set_chatstate(int state) { -#if defined XEP0022 || defined XEP0085 +#ifdef XEP0085 if (chatstates_disabled) return; if (!chatmode) @@ -2409,7 +2409,7 @@ #endif } -#if defined XEP0022 || defined XEP0085 +#ifdef XEP0085 static gboolean scr_chatstates_timeout(void) { time_t now; diff -r 038c4d601011 -r db6ca1e1e082 mcabber/mcabber/xmpp.c --- a/mcabber/mcabber/xmpp.c Fri Oct 17 22:31:03 2014 +0200 +++ b/mcabber/mcabber/xmpp.c Fri Oct 17 22:33:19 2014 +0200 @@ -311,16 +311,13 @@ int otr_msg = 0; #endif char *barejid; -#if defined HAVE_GPGME || defined XEP0022 || defined XEP0085 +#if defined HAVE_GPGME || defined XEP0085 char *rname; GSList *sl_buddy; #endif -#if defined XEP0022 || defined XEP0085 +#ifdef XEP0085 LmMessageNode *event; struct xep0085 *xep85 = NULL; -#if defined XEP0022 - guint use_xep85 = 0; -#endif #endif gchar *enc = NULL; @@ -343,8 +340,7 @@ } barejid = jidtodisp(fjid); -#if defined HAVE_GPGME || defined HAVE_LIBOTR || \ - defined XEP0022 || defined XEP0085 +#if defined HAVE_GPGME || defined HAVE_LIBOTR || defined XEP0085 rname = strchr(fjid, JID_RESOURCE_SEPARATOR); sl_buddy = roster_find(barejid, jidsearch, ROSTER_TYPE_USER); @@ -399,7 +395,7 @@ } #endif // HAVE_GPGME -#endif // HAVE_GPGME || defined XEP0022 || defined XEP0085 +#endif // HAVE_GPGME || defined XEP0085 x = lm_message_new_with_sub_type(fjid, LM_MESSAGE_TYPE_MESSAGE, subtype); lm_message_node_add_child(x->node, "body", @@ -433,16 +429,14 @@ } g_free(barejid); -#if defined XEP0022 || defined XEP0085 +#ifdef XEP0085 // If typing notifications are disabled, we can skip all this stuff... if (chatstates_disabled || type == ROSTER_TYPE_ROOM) goto xmpp_send_msg_no_chatstates; if (sl_buddy) xep85 = buddy_resource_xep85(sl_buddy->data, rname); -#endif -#ifdef XEP0085 /* XEP-0085 5.1 * "Until receiving a reply to the initial content message (or a standalone * notification) from the Contact, the User MUST NOT send subsequent chat @@ -456,40 +450,9 @@ lm_message_node_set_attribute(event, "xmlns", NS_CHATSTATES); if (xep85->support == CHATSTATES_SUPPORT_UNKNOWN) xep85->support = CHATSTATES_SUPPORT_PROBED; -#ifdef XEP0022 - else - use_xep85 = 1; -#endif xep85->last_state_sent = ROSTER_EVENT_ACTIVE; } #endif -#ifdef XEP0022 - /* XEP-22 - * If the Contact supports XEP-0085, we do not use XEP-0022. - * If not, we try to fall back to XEP-0022. - */ - if (!use_xep85) { - struct xep0022 *xep22 = NULL; - event = lm_message_node_add_child(x->node, "x", NULL); - lm_message_node_set_attribute(event, "xmlns", NS_EVENT); - lm_message_node_add_child(event, "composing", NULL); - - if (sl_buddy) - xep22 = buddy_resource_xep22(sl_buddy->data, rname); - if (xep22) - xep22->last_state_sent = ROSTER_EVENT_ACTIVE; - - // An id is mandatory when using XEP-0022. - if (text || subject) { - const gchar *msgid = lm_message_get_id(x); - // Let's update last_msgid_sent - if (xep22) { - g_free(xep22->last_msgid_sent); - xep22->last_msgid_sent = g_strdup(msgid); - } - } - } -#endif xmpp_send_msg_no_chatstates: #ifdef WITH_DEPRECATED_STATUS_INVISIBLE @@ -559,93 +522,21 @@ } #endif -#ifdef XEP0022 -// xmpp_send_xep22_event() -// Send a XEP-22 message event (delivered, composing...). -static void xmpp_send_xep22_event(const char *fjid, guint type) -{ - LmMessage *x; - LmMessageNode *event; - const char *msgid; - char *rname, *barejid; - GSList *sl_buddy; - struct xep0022 *xep22 = NULL; - guint xep22_state; - - if (!xmpp_is_online()) - return; - - rname = strchr(fjid, JID_RESOURCE_SEPARATOR); - barejid = jidtodisp(fjid); - sl_buddy = roster_find(barejid, jidsearch, ROSTER_TYPE_USER); - g_free(barejid); - - // If we can get a resource name, we use it. Else we use NULL, - // which hopefully will give us the most likely resource. - if (rname) - rname++; - if (sl_buddy) - xep22 = buddy_resource_xep22(sl_buddy->data, rname); - - if (!xep22) - return; // XXX Maybe we could try harder (other resources?) - - msgid = xep22->last_msgid_rcvd; - - // For composing events (composing, active, inactive, paused...), - // XEP22 only has 2 states; we'll use composing and active. - if (type == ROSTER_EVENT_COMPOSING) - xep22_state = ROSTER_EVENT_COMPOSING; - else if (type == ROSTER_EVENT_ACTIVE || - type == ROSTER_EVENT_PAUSED) - xep22_state = ROSTER_EVENT_ACTIVE; - else - xep22_state = 0; // ROSTER_EVENT_NONE - - if (xep22_state) { - // Do not re-send a same event - if (xep22_state == xep22->last_state_sent) - return; - xep22->last_state_sent = xep22_state; - } - - x = lm_message_new_with_sub_type(fjid, LM_MESSAGE_TYPE_MESSAGE, - LM_MESSAGE_SUB_TYPE_CHAT); - - event = lm_message_node_add_child(x->node, "x", NULL); - lm_message_node_set_attribute(event, "xmlns", NS_EVENT); - if (type == ROSTER_EVENT_DELIVERED) - lm_message_node_add_child(event, "delivered", NULL); - else if (type == ROSTER_EVENT_COMPOSING) - lm_message_node_add_child(event, "composing", NULL); - lm_message_node_add_child(event, "id", msgid); - - lm_connection_send(lconnection, x, NULL); - lm_message_unref(x); -} -#endif - // xmpp_send_chatstate(buddy, state) // Send a chatstate or event (XEP-22/85) according to the buddy's capabilities. // The message is sent to one of the resources with the highest priority. -#if defined XEP0022 || defined XEP0085 +#if defined XEP0085 void xmpp_send_chatstate(gpointer buddy, guint chatstate) { const char *bjid; const char *activeres; -#ifdef XEP0085 GSList *resources, *p_res, *p_next; struct xep0085 *xep85 = NULL; -#endif -#ifdef XEP0022 - struct xep0022 *xep22; -#endif bjid = buddy_getjid(buddy); if (!bjid) return; activeres = buddy_getactiveresource(buddy); -#ifdef XEP0085 /* Send the chatstate to the last resource (which should have the highest priority). If chatstate is "active", send an "active" state to all resources @@ -671,13 +562,6 @@ // we don't want to send a XEP22 event. if (xep85 && xep85->support == CHATSTATES_SUPPORT_OK) return; -#endif -#ifdef XEP0022 - xep22 = buddy_resource_xep22(buddy, activeres); - if (xep22 && xep22->support == CHATSTATES_SUPPORT_OK) { - xmpp_send_xep22_event(bjid, chatstate); - } -#endif } #endif @@ -685,13 +569,12 @@ // chatstates_reset_probed(fulljid) // If the XEP has been probed for this contact, set it back to unknown so // that we probe it again. The parameter must be a full jid (w/ resource). -#if defined XEP0022 || defined XEP0085 +#if defined XEP0085 static void chatstates_reset_probed(const char *fulljid) { char *rname, *barejid; GSList *sl_buddy; struct xep0085 *xep85; - struct xep0022 *xep22; rname = strchr(fulljid, JID_RESOURCE_SEPARATOR); if (!rname++) @@ -705,12 +588,9 @@ return; xep85 = buddy_resource_xep85(sl_buddy->data, rname); - xep22 = buddy_resource_xep22(sl_buddy->data, rname); if (xep85 && xep85->support == CHATSTATES_SUPPORT_PROBED) xep85->support = CHATSTATES_SUPPORT_UNKNOWN; - if (xep22 && xep22->support == CHATSTATES_SUPPORT_PROBED) - xep22->support = CHATSTATES_SUPPORT_UNKNOWN; } #endif @@ -974,18 +854,11 @@ static void handle_state_events(const char *from, LmMessageNode *node) { -#if defined XEP0022 || defined XEP0085 +#if defined XEP0085 LmMessageNode *state_ns = NULL; char *rname, *bjid; GSList *sl_buddy; - guint events; - struct xep0022 *xep22 = NULL; struct xep0085 *xep85 = NULL; - enum { - XEP_none, - XEP_85, - XEP_22 - } which_xep = XEP_none; rname = strchr(from, JID_RESOURCE_SEPARATOR); if (rname) @@ -996,92 +869,34 @@ sl_buddy = roster_find(bjid, jidsearch, ROSTER_TYPE_USER); g_free(bjid); - /* XXX Actually that's wrong, since it filters out server "offline" - messages (for XEP-0022). This XEP is (almost) deprecated so - we don't really care. */ if (!sl_buddy) { return; } - /* Let's see chich XEP the contact uses. If possible, we'll use - XEP-85, if not we'll look for XEP-22 support. */ - events = buddy_resource_getevents(sl_buddy->data, rname); - + /* Let's see whether the contact supports XEP0085 */ xep85 = buddy_resource_xep85(sl_buddy->data, rname); - if (xep85) { + if (xep85) state_ns = lm_message_node_find_xmlns(node, NS_CHATSTATES); - if (state_ns) - which_xep = XEP_85; - } - if (which_xep != XEP_85) { /* Fall back to XEP-0022 */ - xep22 = buddy_resource_xep22(sl_buddy->data, rname); - if (xep22) { - state_ns = lm_message_node_find_xmlns(node, NS_EVENT); - if (state_ns) - which_xep = XEP_22; - } - } - - if (!which_xep) { /* Sender does not use chat states */ + if (!state_ns) { /* Sender does not use chat states */ return; } - if (which_xep == XEP_85) { /* XEP-0085 */ - xep85->support = CHATSTATES_SUPPORT_OK; - - if (!strcmp(state_ns->name, "composing")) { - xep85->last_state_rcvd = ROSTER_EVENT_COMPOSING; - } else if (!strcmp(state_ns->name, "active")) { - xep85->last_state_rcvd = ROSTER_EVENT_ACTIVE; - } else if (!strcmp(state_ns->name, "paused")) { - xep85->last_state_rcvd = ROSTER_EVENT_PAUSED; - } else if (!strcmp(state_ns->name, "inactive")) { - xep85->last_state_rcvd = ROSTER_EVENT_INACTIVE; - } else if (!strcmp(state_ns->name, "gone")) { - xep85->last_state_rcvd = ROSTER_EVENT_GONE; - } - events = xep85->last_state_rcvd; - } else { /* XEP-0022 */ -#ifdef XEP0022 - const char *body = lm_message_node_get_child_value(node, "body"); - const char *msgid; - xep22->support = CHATSTATES_SUPPORT_OK; - xep22->last_state_rcvd = ROSTER_EVENT_NONE; - - msgid = lm_message_node_get_attribute(node, "id"); + xep85->support = CHATSTATES_SUPPORT_OK; - if (lm_message_node_get_child(state_ns, "composing")) { - // Clear composing if the message contains a body - if (body) - events &= ~ROSTER_EVENT_COMPOSING; - else - events |= ROSTER_EVENT_COMPOSING; - xep22->last_state_rcvd |= ROSTER_EVENT_COMPOSING; - - } else { - events &= ~ROSTER_EVENT_COMPOSING; - } - - // Cache the message id - g_free(xep22->last_msgid_rcvd); - if (msgid) - xep22->last_msgid_rcvd = g_strdup(msgid); - else - xep22->last_msgid_rcvd = NULL; - - if (lm_message_node_get_child(state_ns, "delivered")) { - xep22->last_state_rcvd |= ROSTER_EVENT_DELIVERED; - - // Do we have to send back an ACK? - if (body) - xmpp_send_xep22_event(from, ROSTER_EVENT_DELIVERED); - } -#endif + if (!strcmp(state_ns->name, "composing")) { + xep85->last_state_rcvd = ROSTER_EVENT_COMPOSING; + } else if (!strcmp(state_ns->name, "active")) { + xep85->last_state_rcvd = ROSTER_EVENT_ACTIVE; + } else if (!strcmp(state_ns->name, "paused")) { + xep85->last_state_rcvd = ROSTER_EVENT_PAUSED; + } else if (!strcmp(state_ns->name, "inactive")) { + xep85->last_state_rcvd = ROSTER_EVENT_INACTIVE; + } else if (!strcmp(state_ns->name, "gone")) { + xep85->last_state_rcvd = ROSTER_EVENT_GONE; } - buddy_resource_setevents(sl_buddy->data, rname, events); - + buddy_resource_setevents(sl_buddy->data, rname, xep85->last_state_rcvd); update_roster = TRUE; #endif } @@ -1275,7 +1090,7 @@ if (mstype == LM_MESSAGE_SUB_TYPE_ERROR) { x = lm_message_node_get_child(m->node, "error"); display_server_error(x, from); -#if defined XEP0022 || defined XEP0085 +#ifdef XEP0085 // If the XEP85/22 support is probed, set it back to unknown so that // we probe it again. chatstates_reset_probed(from);