comparison mcabber/mcabber/carbons.c @ 2104:c7e9950fa741

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.
author Roeland Jago Douma <roeland@famdouma.nl>
date Sat, 02 Mar 2013 18:22:10 +0100
parents
children 1cc84780eb5f
comparison
equal deleted inserted replaced
2103:1210a22726d3 2104:c7e9950fa741
1 #include "carbons.h"
2 #include "settings.h"
3 #include "xmpp_helper.h"
4 #include "xmpp_defines.h"
5 #include "logprint.h"
6 #include "xmpp.h"
7
8 static int _carbons_available = 0;
9
10 static LmHandlerResult cb_carbons_enable(LmMessageHandler *h, LmConnection *c,
11 LmMessage *m, gpointer user_data);
12
13
14 void carbons_init()
15 {
16
17 }
18
19 void carbons_available()
20 {
21 int enable = 0;
22 _carbons_available = 1;
23
24 enable = settings_opt_get_int("carbons");
25
26 if (enable) {
27 carbons_enable();
28 }
29 }
30
31 void carbons_enable()
32 {
33 LmMessage *iq;
34 LmMessageNode *enable;
35 LmMessageHandler *handler;
36 GError *error = NULL;
37
38 iq = lm_message_new_with_sub_type(NULL, LM_MESSAGE_TYPE_IQ,
39 LM_MESSAGE_SUB_TYPE_SET);
40
41 enable = lm_message_node_add_child(iq->node, "enable", NULL);
42
43 lm_message_node_set_attribute(enable, "xmlns", NS_CARBONS_2);
44
45 handler = lm_message_handler_new(cb_carbons_enable, NULL, NULL);
46
47 lm_connection_send_with_reply(lconnection, iq, handler, &error);
48 lm_message_handler_unref(handler);
49 lm_message_unref(iq);
50
51 if (error) {
52 scr_LogPrint(LPRINT_LOGNORM, "Error sending IQ request: %s.", error->message);
53 g_error_free(error);
54 }
55 }
56
57 void carbons_disable()
58 {
59
60 }
61
62 static LmHandlerResult cb_carbons_enable(LmMessageHandler *h, LmConnection *c,
63 LmMessage *m, gpointer user_data)
64 {
65 scr_LogPrint(LPRINT_NORMAL|LPRINT_DEBUG, "We have a response! O Yeah!");
66 return LM_HANDLER_RESULT_REMOVE_MESSAGE;
67 }