Send service-unavailable when Last Activity is disabled
According to XEP-0012, the client should return a <service-unavailable/> error
when it doesn't wish to divulge the information.
This patch also adds a new option: iq_last_disable_when_notavail.
--- a/mcabber/mcabberrc.example Wed Jun 27 23:03:22 2007 +0200
+++ b/mcabber/mcabberrc.example Sun Jul 01 12:22:54 2007 +0200
@@ -139,8 +139,11 @@
#set iq_version_hide_os = 0
#
# Set iq_last_disable to 1 if you want to disable response to jabber:iq:last
-# queries (XEP-0012).
+# queries (XEP-0012). Set iq_last_disable_when_notavail to 1 if you want
+# to disable Last Activity reports only when the not-available status is set.
+# (Default is 0 for both options)
#set iq_last_disable = 0
+#set iq_last_disable = 1
# Beep
# Set beep_on_message to 1 if you want mcabber to beep when receiving
--- a/mcabber/src/jab_iq.c Wed Jun 27 23:03:22 2007 +0200
+++ b/mcabber/src/jab_iq.c Sun Jul 01 12:22:54 2007 +0200
@@ -931,6 +931,26 @@
xmlnode_free(x);
}
+// FIXME highly duplicated code
+static void send_iq_not_available(jconn conn, char *from, xmlnode xmldata)
+{
+ xmlnode x, y, z;
+ // Not available.
+ x = xmlnode_dup(xmldata);
+ xmlnode_put_attrib(x, "to", xmlnode_get_attrib(xmldata, "from"));
+ xmlnode_hide_attrib(x, "from");
+
+ xmlnode_put_attrib(x, "type", TMSG_ERROR);
+ y = xmlnode_insert_tag(x, TMSG_ERROR);
+ xmlnode_put_attrib(y, "code", "503");
+ xmlnode_put_attrib(y, "type", "cancel");
+ z = xmlnode_insert_tag(y, "service-unavailable");
+ xmlnode_put_attrib(z, "xmlns", NS_XMPP_STANZAS);
+
+ jab_send(conn, x);
+ xmlnode_free(x);
+}
+
/*
static void send_iq_commands_bad_action(jconn conn, char *from, xmlnode xmldata)
{
@@ -1523,9 +1543,13 @@
handle_iq_disco_items(conn, from, id, xmldata);
} else if (ns && !strcmp(ns, NS_VERSION)) {
handle_iq_version(conn, from, id, xmldata);
- } else if (ns && !strcmp(ns, NS_LAST) &&
- !settings_opt_get_int("iq_last_disable")) {
- handle_iq_last(conn, from, id, xmldata);
+ } else if (ns && !strcmp(ns, NS_LAST)) {
+ if (!settings_opt_get_int("iq_last_disable") &&
+ (!settings_opt_get_int("iq_last_disable_when_notavail") ||
+ jb_getstatus() != notavail))
+ handle_iq_last(conn, from, id, xmldata);
+ else
+ send_iq_not_available(conn, from, xmldata);
} else if (ns && !strcmp(ns, NS_TIME)) {
handle_iq_time(conn, from, id, xmldata);
} else {