Added option to enable carbons (set carbons = 1 in mcabberrc)
If the server supports carbons and the user has carbons enabled we enable them.
Now we need to handle XEP-0297 (Stanza Forwarding) stanzas to make sure the
messages end up at the correct place.
--- a/mcabber/mcabber/Makefile.am Fri Mar 01 15:27:29 2013 +0100
+++ b/mcabber/mcabber/Makefile.am Sat Mar 02 18:22:10 2013 +0100
@@ -7,7 +7,7 @@
xmpp.c xmpp.h xmpp_helper.c xmpp_helper.h xmpp_defines.h \
xmpp_iq.c xmpp_iq.h xmpp_iqrequest.c xmpp_iqrequest.h \
xmpp_muc.c xmpp_muc.h xmpp_s10n.c xmpp_s10n.h \
- caps.c caps.h help.c help.h
+ caps.c caps.h help.c help.h carbons.c carbons.h
if OTR
mcabber_SOURCES += otr.c otr.h nohtml.c nohtml.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mcabber/mcabber/carbons.c Sat Mar 02 18:22:10 2013 +0100
@@ -0,0 +1,67 @@
+#include "carbons.h"
+#include "settings.h"
+#include "xmpp_helper.h"
+#include "xmpp_defines.h"
+#include "logprint.h"
+#include "xmpp.h"
+
+static int _carbons_available = 0;
+
+static LmHandlerResult cb_carbons_enable(LmMessageHandler *h, LmConnection *c,
+ LmMessage *m, gpointer user_data);
+
+
+void carbons_init()
+{
+
+}
+
+void carbons_available()
+{
+ int enable = 0;
+ _carbons_available = 1;
+
+ enable = settings_opt_get_int("carbons");
+
+ if (enable) {
+ carbons_enable();
+ }
+}
+
+void carbons_enable()
+{
+ LmMessage *iq;
+ LmMessageNode *enable;
+ LmMessageHandler *handler;
+ GError *error = NULL;
+
+ iq = lm_message_new_with_sub_type(NULL, LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET);
+
+ enable = lm_message_node_add_child(iq->node, "enable", NULL);
+
+ lm_message_node_set_attribute(enable, "xmlns", NS_CARBONS_2);
+
+ handler = lm_message_handler_new(cb_carbons_enable, NULL, NULL);
+
+ lm_connection_send_with_reply(lconnection, iq, handler, &error);
+ lm_message_handler_unref(handler);
+ lm_message_unref(iq);
+
+ if (error) {
+ scr_LogPrint(LPRINT_LOGNORM, "Error sending IQ request: %s.", error->message);
+ g_error_free(error);
+ }
+}
+
+void carbons_disable()
+{
+
+}
+
+static LmHandlerResult cb_carbons_enable(LmMessageHandler *h, LmConnection *c,
+ LmMessage *m, gpointer user_data)
+{
+ scr_LogPrint(LPRINT_NORMAL|LPRINT_DEBUG, "We have a response! O Yeah!");
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mcabber/mcabber/carbons.h Sat Mar 02 18:22:10 2013 +0100
@@ -0,0 +1,9 @@
+#ifndef __MCABBER_CARBONS_H__
+#define __MCABBER_CARBONS_H__ 1
+
+void carbons_init();
+void carbons_available();
+void carbons_enable();
+void carbons_disable();
+
+#endif //__MCABBER_CARBONS_H__
--- a/mcabber/mcabber/main.c Fri Mar 01 15:27:29 2013 +0100
+++ b/mcabber/mcabber/main.c Sat Mar 02 18:22:10 2013 +0100
@@ -374,6 +374,7 @@
scr_init_bindings();
scr_init_settings();
caps_init();
+ carbons_init();
#ifdef MODULES_ENABLE
modules_init();
#endif
--- a/mcabber/mcabber/xmpp_iqrequest.c Fri Mar 01 15:27:29 2013 +0100
+++ b/mcabber/mcabber/xmpp_iqrequest.c Sat Mar 02 18:22:10 2013 +0100
@@ -31,6 +31,7 @@
#include "settings.h"
#include "hooks.h"
#include "hbuf.h"
+#include "carbons.h"
extern LmMessageNode *bookmarks;
extern LmMessageNode *rosternotes;
@@ -92,7 +93,7 @@
const char *v = lm_message_node_get_attribute(feature, "var");
if (!g_strcmp0(v, NS_CARBONS_2)) {
- scr_LogPrint(LPRINT_NORMAL|LPRINT_DEBUG, "We have carbons!");
+ carbons_available();
}
}