diff mcabber/mcabber/carbons.c @ 2111:9023a6f2bf6c

Misc. style updates
author Mikael Berthe <mikael@lilotux.net>
date Sun, 11 May 2014 17:18:18 +0200
parents 9b4b7941647c
children 51fde9c25401
line wrap: on
line diff
--- a/mcabber/mcabber/carbons.c	Tue Oct 15 19:12:10 2013 +0200
+++ b/mcabber/mcabber/carbons.c	Sun May 11 17:18:18 2014 +0200
@@ -1,3 +1,24 @@
+/*
+ * carbons.c        -- Support for Message Carbons (XEP 0280)
+ *
+ * Copyright (C) 2013 Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
 #include "carbons.h"
 #include "settings.h"
 #include "xmpp_helper.h"
@@ -26,9 +47,14 @@
 
 void carbons_enable()
 {
+  LmMessage *iq;
+  LmMessageNode *enable;
+  LmMessageHandler *handler;
+  GError *error = NULL;
+
   //We cannot enable carbons if there is no carbons support
   if (_carbons_available == 0) {
-    scr_LogPrint(LPRINT_NORMAL, "Carbons not available on this server!");
+    scr_log_print(LPRINT_NORMAL, "Carbons not available on this server!");
     return;
   }
 
@@ -37,11 +63,6 @@
     return;
   }
 
-  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);
 
@@ -50,7 +71,8 @@
   handler = lm_message_handler_new(cb_carbons, NULL, NULL);
 
   if (!lm_connection_send_with_reply(lconnection, iq, handler, &error)) {
-    scr_LogPrint(LPRINT_DEBUG, "Error sending IQ request: %s.", error->message);
+    scr_log_print(LPRINT_DEBUG, "Error sending IQ request: %s.",
+                  error->message);
     g_error_free(error);
   }
 
@@ -60,21 +82,21 @@
 
 void carbons_disable()
 {
+  LmMessage *iq;
+  LmMessageNode *disable;
+  LmMessageHandler *handler;
+  GError *error = NULL;
+
   //We cannot disable carbons if there is no carbon support on the server
   if (_carbons_available == 0) {
-    scr_LogPrint(LPRINT_NORMAL, "Carbons not available on this server!");
+    scr_log_print(LPRINT_NORMAL, "Carbons not available on this server!");
     return;
   }
 
   //We can only disable carbons if they are disabled
   if (_carbons_enabled == 0) {
     return;
-  } 
-
-  LmMessage *iq;
-  LmMessageNode *disable;
-  LmMessageHandler *handler;
-  GError *error = NULL;
+  }
 
   iq = lm_message_new_with_sub_type(NULL, LM_MESSAGE_TYPE_IQ,
                                     LM_MESSAGE_SUB_TYPE_SET);
@@ -84,24 +106,25 @@
   handler = lm_message_handler_new(cb_carbons, NULL, NULL);
 
   if (!lm_connection_send_with_reply(lconnection, iq, handler, &error)) {
-    scr_LogPrint(LPRINT_DEBUG, "Error sending IQ request: %s.", error->message);
+    scr_log_print(LPRINT_DEBUG, "Error sending IQ request: %s.",
+                  error->message);
     g_error_free(error);
   }
 
   lm_message_handler_unref(handler);
   lm_message_unref(iq);
- 
+
 }
 
 void carbons_info()
 {
   if (_carbons_enabled) {
-    scr_LogPrint(LPRINT_NORMAL, "Carbons enabled.");
+    scr_log_print(LPRINT_NORMAL, "Carbons enabled.");
   } else {
     if (_carbons_available) {
-      scr_LogPrint(LPRINT_NORMAL, "Carbons available, but not enabled.");
+      scr_log_print(LPRINT_NORMAL, "Carbons available, but not enabled.");
     } else {
-      scr_LogPrint(LPRINT_NORMAL, "Carbons not available.");     
+      scr_log_print(LPRINT_NORMAL, "Carbons not available.");
     }
   }
 }
@@ -110,7 +133,12 @@
                                   LmMessage *m, gpointer user_data)
 {
   if (lm_message_get_sub_type(m) == LM_MESSAGE_SUB_TYPE_RESULT) {
-    _carbons_enabled = _carbons_enabled == 0 ? 1 : 0;
+    _carbons_enabled = (_carbons_enabled == 0 ? 1 : 0);
+    if (_carbons_enabled) {
+      scr_log_print(LPRINT_NORMAL, "Carbons enabled.");
+    } else {
+      scr_log_print(LPRINT_NORMAL, "Carbons disabled.");
+    }
   } else {
     //Handle error cases
   }
@@ -118,3 +146,4 @@
   return LM_HANDLER_RESULT_REMOVE_MESSAGE;
 }
 
+/* vim: set et cindent cinoptions=>2\:2(0 ts=2 sw=2:  For Vim users... */