Misc. style updates
--- a/mcabber/doc/help/en/hlp_carbons.txt Tue Oct 15 19:12:10 2013 +0200
+++ b/mcabber/doc/help/en/hlp_carbons.txt Sun May 11 17:18:18 2014 +0200
@@ -1,11 +1,11 @@
- /carbons info
- /carbons enable
- /carbons disable
+ /CARBONS info
+ /CARBONS enable
+ /CARBONS disable
/carbons info
- Print information about the current state of carbons
+ Print information about the current state of carbons
/carbons enable
- Enable carbons
-/carbons distable
- Disable carbons
+ Enable carbons
+/carbons disable
+ Disable carbons
--- 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... */
--- a/mcabber/mcabber/commands.c Tue Oct 15 19:12:10 2013 +0200
+++ b/mcabber/mcabber/commands.c Sun May 11 17:18:18 2014 +0200
@@ -192,7 +192,8 @@
cmd_add("bind", "Add an key binding", 0, 0, &do_bind, NULL);
cmd_add("buffer", "Manipulate current buddy's buffer (chat window)",
COMPL_BUFFER, 0, &do_buffer, NULL);
- cmd_add("carbons", "Mange carbons settings", COMPL_CARBONS, 0, &do_carbons, NULL);
+ cmd_add("carbons", "Manage carbons settings", COMPL_CARBONS, 0,
+ &do_carbons, NULL);
cmd_add("chat_disable", "Disable chat mode", 0, 0, &do_chat_disable, NULL);
cmd_add("clear", "Clear the dialog window", 0, 0, &do_clear, NULL);
cmd_add("color", "Set coloring options", COMPL_COLOR, 0, &do_color, NULL);
--- a/mcabber/mcabber/utils.c Tue Oct 15 19:12:10 2013 +0200
+++ b/mcabber/mcabber/utils.c Sun May 11 17:18:18 2014 +0200
@@ -79,6 +79,7 @@
return alias;
}
+// The caller must free the string after use.
char *jid_get_username(const char *fjid)
{
char *ptr;
@@ -91,6 +92,7 @@
return username;
}
+// The caller must free the string after use.
char *get_servername(const char *username, const char *servername)
{
char *ptr;
@@ -101,9 +103,10 @@
return server;
}
- return servername;
+ return g_strdup(servername);
}
+// The caller must free the string after use.
char *compose_jid(const char *username, const char *servername,
const char *resource)
{
@@ -209,6 +212,7 @@
return TRUE;
}
+// The caller must free the string after use.
static gchar *tracelog_level_guard(const gchar *key, const gchar *new_value)
{
int new_level = 0;
@@ -221,6 +225,7 @@
return g_strdup(new_value);
}
+// The caller must free the string after use.
static gchar *tracelog_file_guard(const gchar *key, const gchar *new_value)
{
gchar *new_fname = NULL;
@@ -242,7 +247,7 @@
}
// ut_init_debug()
-// Installs otpion guards before initial config file parsing.
+// Install option guards before initial config file parsing.
void ut_init_debug(void)
{
DebugEnabled = 0;
--- a/mcabber/mcabber/xmpp_defines.h Tue Oct 15 19:12:10 2013 +0200
+++ b/mcabber/mcabber/xmpp_defines.h Sun May 11 17:18:18 2014 +0200
@@ -61,8 +61,7 @@
#define NS_PING "urn:xmpp:ping"
#define NS_RECEIPTS "urn:xmpp:receipts"
-//XEP-0280 (message carbons)
-#define NS_CARBONS_2 "urn:xmpp:carbons:2"
+#define NS_CARBONS_2 "urn:xmpp:carbons:2" // XEP-0280 (message carbons)
#define NS_JABBERD_STOREDPRESENCE "http://jabberd.org/ns/storedpresence"
#define NS_JABBERD_HISTORY "http://jabberd.org/ns/history"
--- a/mcabber/mcabber/xmpp_iqrequest.c Tue Oct 15 19:12:10 2013 +0200
+++ b/mcabber/mcabber/xmpp_iqrequest.c Sun May 11 17:18:18 2014 +0200
@@ -89,7 +89,7 @@
ansqry = lm_message_node_get_child(m->node, "query");
feature = lm_message_node_get_child(ansqry, "feature");
- for(;feature;feature = feature->next) {
+ for (; feature; feature = feature->next) {
const char *v = lm_message_node_get_attribute(feature, "var");
if (!g_strcmp0(v, NS_CARBONS_2)) {
@@ -185,7 +185,8 @@
data = (gpointer)now;
notifier = g_free;
} else if (!g_strcmp0(xmlns, NS_DISCO_INFO)) {
- gchar *servername = get_servername(settings_opt_get("jid"), settings_opt_get("server"));
+ gchar *servername = get_servername(settings_opt_get("jid"),
+ settings_opt_get("server"));
lm_message_node_set_attribute(iq->node, "to", servername);
g_free(servername);
}