Mercurial > hg
changeset 2106:72876dcf9094
Bit more checks for enabling carbons
-Make sure we do not enable carbons if they are already enabled
-Return status of carbons
author | Roeland Jago Douma <roeland@famdouma.nl> |
---|---|
date | Tue, 15 Oct 2013 18:51:39 +0200 |
parents | 1cc84780eb5f |
children | 1bd9978ed5d0 |
files | mcabber/mcabber/carbons.c mcabber/mcabber/carbons.h |
diffstat | 2 files changed, 33 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mcabber/mcabber/carbons.c Sun Mar 03 14:32:16 2013 +0100 +++ b/mcabber/mcabber/carbons.c Tue Oct 15 18:51:39 2013 +0200 @@ -6,6 +6,7 @@ #include "xmpp.h" static int _carbons_available = 0; +static int _carbons_enabled = 0; static LmHandlerResult cb_carbons_enable(LmMessageHandler *h, LmConnection *c, LmMessage *m, gpointer user_data); @@ -30,6 +31,10 @@ void carbons_enable() { + if (_carbons_available == 0) { + return; + } + LmMessage *iq; LmMessageNode *enable; LmMessageHandler *handler; @@ -44,23 +49,44 @@ handler = lm_message_handler_new(cb_carbons_enable, NULL, NULL); - lm_connection_send_with_reply(lconnection, iq, handler, &error); + if (!lm_connection_send_with_reply(lconnection, iq, handler, &error)) { + scr_LogPrint(LPRINT_DEBUG, "Error sending IQ request: %s.", error->message); + g_error_free(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() { + if (_carbons_available == 0) { + return; + } +} +void carbons_info() +{ + if (_carbons_enabled) { + scr_LogPrint(LPRINT_NORMAL, "Carbons enabled."); + } else { + if (_carbons_available) { + scr_LogPrint(LPRINT_NORMAL, "Carbons available, but not enabled."); + } else { + scr_LogPrint(LPRINT_NORMAL, "Carbons not available."); + } + } } static LmHandlerResult cb_carbons_enable(LmMessageHandler *h, LmConnection *c, LmMessage *m, gpointer user_data) { + if (lm_message_get_sub_type(m) == LM_MESSAGE_SUB_TYPE_RESULT) { + _carbons_enabled = _carbons_enabled == 0 ? 1 : 0; + } else { + //Handle error cases + } + return LM_HANDLER_RESULT_REMOVE_MESSAGE; } +