summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2012-05-10 14:14:17 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2012-05-10 20:20:02 +0100
commit05542224e7a75936e13aa066180de0fa7b934f37 (patch)
treef4e563d30207dc78179541ef903f70b5d4e24af1 /src
parent5b210484408cf7ce82e6cd79e227785cec8eb811 (diff)
Various dull C89-compliance
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Reviewed-by: Xavier Claessens <xavier.claessens@collabora.co.uk>
Diffstat (limited to 'src')
-rw-r--r--src/idle-connection.c29
-rw-r--r--src/idle-ctcp.c22
-rw-r--r--src/idle-debug.c3
-rw-r--r--src/idle-handles.c14
-rw-r--r--src/idle-im-channel.c39
-rw-r--r--src/idle-muc-channel.c7
-rw-r--r--src/idle-muc-manager.c55
-rw-r--r--src/idle-text.c6
8 files changed, 104 insertions, 71 deletions
diff --git a/src/idle-connection.c b/src/idle-connection.c
index 382d8ae..a2e232e 100644
--- a/src/idle-connection.c
+++ b/src/idle-connection.c
@@ -1059,13 +1059,16 @@ static IdleParserHandlerResult _ping_handler(IdleParser *parser, IdleParserMessa
static IdleParserHandlerResult _version_privmsg_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray *args, gpointer user_data) {
IdleConnection *conn = IDLE_CONNECTION(user_data);
const gchar *msg = g_value_get_string(g_value_array_get_nth(args, 2));
+ TpHandle handle;
+ const gchar *nick;
+ gchar *reply;
if (g_ascii_strcasecmp(msg, "\001VERSION\001"))
return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED;
- TpHandle handle = g_value_get_uint(g_value_array_get_nth(args, 0));
- const gchar *nick = tp_handle_inspect(tp_base_connection_get_handles(TP_BASE_CONNECTION(conn), TP_HANDLE_TYPE_CONTACT), handle);
- gchar *reply = g_strdup_printf("VERSION telepathy-idle %s Telepathy IM/VoIP Framework http://telepathy.freedesktop.org", VERSION);
+ handle = g_value_get_uint(g_value_array_get_nth(args, 0));
+ nick = tp_handle_inspect(tp_base_connection_get_handles(TP_BASE_CONNECTION(conn), TP_HANDLE_TYPE_CONTACT), handle);
+ reply = g_strdup_printf("VERSION telepathy-idle %s Telepathy IM/VoIP Framework http://telepathy.freedesktop.org", VERSION);
idle_ctcp_notice(nick, reply, conn);
@@ -1095,11 +1098,15 @@ _whois_user_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray
TpHandle handle = g_value_get_uint(g_value_array_get_nth(args, 0));
TpHandle self = tp_base_connection_get_self_handle(TP_BASE_CONNECTION(conn));
if (handle == self) {
+ const char *user;
+ const char *host;
+
if (priv->relay_prefix != NULL) {
g_free(priv->relay_prefix);
}
- const char* user = g_value_get_string(g_value_array_get_nth(args, 1));
- const char* host = g_value_get_string(g_value_array_get_nth(args, 2));
+
+ user = g_value_get_string(g_value_array_get_nth(args, 1));
+ host = g_value_get_string(g_value_array_get_nth(args, 2));
priv->relay_prefix = g_strdup_printf("%s!%s@%s", priv->nickname, user, host);
IDLE_DEBUG("user host prefix = %s", priv->relay_prefix);
}
@@ -1271,6 +1278,7 @@ idle_connection_get_aliases (
TpHandleRepoIface *repo = tp_base_connection_get_handles (
TP_BASE_CONNECTION (iface), TP_HANDLE_TYPE_CONTACT);
GError *error = NULL;
+ GHashTable *aliases;
if (!tp_handles_are_valid (repo, handles, FALSE, &error))
{
@@ -1279,7 +1287,7 @@ idle_connection_get_aliases (
return;
}
- GHashTable *aliases = g_hash_table_new (NULL, NULL);
+ aliases = g_hash_table_new (NULL, NULL);
for (guint i = 0; i < handles->len; i++)
{
@@ -1297,6 +1305,7 @@ idle_connection_get_aliases (
static void idle_connection_request_aliases(TpSvcConnectionInterfaceAliasing *iface, const GArray *handles, DBusGMethodInvocation *context) {
TpHandleRepoIface *repo = tp_base_connection_get_handles(TP_BASE_CONNECTION(iface), TP_HANDLE_TYPE_CONTACT);
GError *error = NULL;
+ const gchar **aliases;
if (!tp_handles_are_valid(repo, handles, FALSE, &error)) {
dbus_g_method_return_error(context, error);
@@ -1304,7 +1313,7 @@ static void idle_connection_request_aliases(TpSvcConnectionInterfaceAliasing *if
return;
}
- const gchar **aliases = g_new0(const gchar *, handles->len + 1);
+ aliases = g_new0(const gchar *, handles->len + 1);
for (guint i = 0; i < handles->len; i++) {
TpHandle handle = g_array_index(handles, TpHandle, i);
@@ -1318,17 +1327,17 @@ static void idle_connection_request_aliases(TpSvcConnectionInterfaceAliasing *if
static gboolean _send_rename_request(IdleConnection *obj, const gchar *nick, DBusGMethodInvocation *context) {
TpHandleRepoIface *handles = tp_base_connection_get_handles(TP_BASE_CONNECTION(obj), TP_HANDLE_TYPE_CONTACT);
TpHandle handle = tp_handle_ensure(handles, nick, NULL, NULL);
+ gchar msg[IRC_MSG_MAXLEN + 1];
if (handle == 0) {
- IDLE_DEBUG("failed to get handle for \"%s\"", nick);
-
GError error = {TP_ERROR, TP_ERROR_NOT_AVAILABLE, "Invalid nickname requested"};
+
+ IDLE_DEBUG("failed to get handle for \"%s\"", nick);
dbus_g_method_return_error(context, &error);
return FALSE;
}
- gchar msg[IRC_MSG_MAXLEN + 1];
g_snprintf(msg, IRC_MSG_MAXLEN + 1, "NICK %s", nick);
idle_connection_send(obj, msg);
diff --git a/src/idle-ctcp.c b/src/idle-ctcp.c
index 12752db..6285e69 100644
--- a/src/idle-ctcp.c
+++ b/src/idle-ctcp.c
@@ -84,11 +84,13 @@ const gchar *idle_ctcp_notice(const gchar *target, const gchar *ctcp, IdleConnec
}
gchar *idle_ctcp_kill_blingbling(const gchar *msg) {
+ gchar *killed, *killed_iter;
+
if (msg == NULL)
return NULL;
- gchar *killed = g_malloc0(strlen(msg) + 1);
- gchar *killed_iter = killed;
+ killed = g_malloc0(strlen(msg) + 1);
+ killed_iter = killed;
for (const gchar *iter = msg; *iter != '\0';) {
switch (*iter) {
@@ -125,15 +127,19 @@ gchar *idle_ctcp_kill_blingbling(const gchar *msg) {
}
gchar **idle_ctcp_decode(const gchar *msg) {
+ GPtrArray *tokens;
+ gchar cur_token[IRC_MSG_MAXLEN] = {'\0'};
+ gchar *cur_iter = cur_token;
+ gchar **ret;
+ const gchar *iter;
+ gboolean string = FALSE;
+
if (!msg || (msg[0] != '\001') || !msg[1] || (msg[1] == '\001'))
return NULL;
- GPtrArray *tokens = g_ptr_array_new();
- gchar cur_token[IRC_MSG_MAXLEN] = {'\0'};
- gchar *cur_iter = cur_token;
+ tokens = g_ptr_array_new();
- const gchar *iter = msg + 1;
- gboolean string = FALSE;
+ iter = msg + 1;
while (*iter != '\0') {
switch (*iter) {
case '\\':
@@ -194,7 +200,7 @@ gchar **idle_ctcp_decode(const gchar *msg) {
g_ptr_array_add(tokens, NULL);
- gchar **ret = (gchar **) tokens->pdata;
+ ret = (gchar **) tokens->pdata;
g_ptr_array_free(tokens, FALSE);
return ret;
diff --git a/src/idle-debug.c b/src/idle-debug.c
index 8ae65bf..b335c15 100644
--- a/src/idle-debug.c
+++ b/src/idle-debug.c
@@ -37,10 +37,11 @@ static GDebugKey _keys[] = {
};
void idle_debug_init() {
+ const gchar *flags_string = g_getenv("IDLE_DEBUG");
guint nkeys;
+
for (nkeys = 0; _keys[nkeys].value; nkeys++);
- const gchar *flags_string = g_getenv("IDLE_DEBUG");
if (flags_string) {
tp_debug_set_flags(flags_string);
_flags |= g_parse_debug_string(flags_string, _keys, nkeys);
diff --git a/src/idle-handles.c b/src/idle-handles.c
index 5e3843e..3aa07d9 100644
--- a/src/idle-handles.c
+++ b/src/idle-handles.c
@@ -92,11 +92,13 @@ gboolean idle_nickname_is_valid(const gchar *nickname, gboolean strict_mode) {
static gboolean _channelname_is_valid(const gchar *channel) {
static const gchar not_allowed_chars[] = {' ', '\007', ',', '\r', '\n', ':', '\0'};
+ gsize len;
+ const gchar *tmp;
if (!idle_muc_channel_is_typechar(channel[0]))
return FALSE;
- gsize len = strlen(channel);
+ len = strlen(channel);
if ((len < 2) || (len > 50))
return FALSE;
@@ -107,7 +109,7 @@ static gboolean _channelname_is_valid(const gchar *channel) {
}
}
- const gchar *tmp = strchr(channel + 1, ':');
+ tmp = strchr(channel + 1, ':');
if (tmp != NULL) {
for (const gchar *tmp2 = channel + 1; tmp2 != tmp; tmp2++) {
if (strchr(not_allowed_chars, *tmp2))
@@ -129,12 +131,14 @@ static gboolean _channelname_is_valid(const gchar *channel) {
}
gchar *idle_normalize_nickname (const gchar *id, GError **error) {
+ gchar *normalized;
+
if (!idle_nickname_is_valid(id, FALSE)) {
g_set_error(error, TP_ERROR, TP_ERROR_INVALID_HANDLE, "invalid nickname");
return NULL;
}
- gchar *normalized = g_utf8_strdown(id, -1);
+ normalized = g_utf8_strdown(id, -1);
return normalized;
}
@@ -144,12 +148,14 @@ static gchar *_nick_normalize_func(TpHandleRepoIface *repo, const gchar *id, gpo
}
static gchar *_channel_normalize_func(TpHandleRepoIface *repo, const gchar *id, gpointer ctx, GError **error) {
+ gchar *normalized;
+
if (!_channelname_is_valid(id)) {
g_set_error(error, TP_ERROR, TP_ERROR_INVALID_HANDLE, "invalid channel ID");
return NULL;
}
- gchar *normalized = g_utf8_strdown(id, -1);
+ normalized = g_utf8_strdown(id, -1);
return normalized;
}
diff --git a/src/idle-im-channel.c b/src/idle-im-channel.c
index 6d144bd..d510e14 100644
--- a/src/idle-im-channel.c
+++ b/src/idle-im-channel.c
@@ -263,6 +263,25 @@ static void idle_im_channel_set_property(GObject *object, guint property_id, con
}
static void idle_im_channel_class_init (IdleIMChannelClass *idle_im_channel_class) {
+ static TpDBusPropertiesMixinPropImpl channel_props[] = {
+ { "Interfaces", "interfaces", NULL },
+ { "ChannelType", "channel-type", NULL },
+ { "TargetHandleType", "handle-type", NULL },
+ { "TargetHandle", "handle", NULL },
+ { "TargetID", "target-id", NULL },
+ { "InitiatorHandle", "initiator-handle", NULL },
+ { "InitiatorID", "initiator-id", NULL },
+ { "Requested", "requested", NULL },
+ { NULL }
+ };
+ static TpDBusPropertiesMixinIfaceImpl prop_interfaces[] = {
+ { TP_IFACE_CHANNEL,
+ tp_dbus_properties_mixin_getter_gobject_properties,
+ NULL,
+ channel_props,
+ },
+ { NULL }
+ };
GObjectClass *object_class = G_OBJECT_CLASS(idle_im_channel_class);
GParamSpec *param_spec;
@@ -320,26 +339,6 @@ static void idle_im_channel_class_init (IdleIMChannelClass *idle_im_channel_clas
NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_INITIATOR_ID, param_spec);
- static TpDBusPropertiesMixinPropImpl channel_props[] = {
- { "Interfaces", "interfaces", NULL },
- { "ChannelType", "channel-type", NULL },
- { "TargetHandleType", "handle-type", NULL },
- { "TargetHandle", "handle", NULL },
- { "TargetID", "target-id", NULL },
- { "InitiatorHandle", "initiator-handle", NULL },
- { "InitiatorID", "initiator-id", NULL },
- { "Requested", "requested", NULL },
- { NULL }
- };
- static TpDBusPropertiesMixinIfaceImpl prop_interfaces[] = {
- { TP_IFACE_CHANNEL,
- tp_dbus_properties_mixin_getter_gobject_properties,
- NULL,
- channel_props,
- },
- { NULL }
- };
-
idle_im_channel_class->dbus_props_class.interfaces = prop_interfaces;
tp_dbus_properties_mixin_class_init(object_class, G_STRUCT_OFFSET(IdleIMChannelClass, dbus_props_class));
tp_message_mixin_init_dbus_properties (object_class);
diff --git a/src/idle-muc-channel.c b/src/idle-muc-channel.c
index baa283a..c27c704 100644
--- a/src/idle-muc-channel.c
+++ b/src/idle-muc-channel.c
@@ -1934,11 +1934,12 @@ static void send_properties_request(IdleMUCChannel *obj, const GPtrArray *proper
irc_mode = to_irc_mode(prop_id);
if (irc_mode != '\0') {
- g_assert(G_VALUE_TYPE(prop_val) == G_TYPE_BOOLEAN);
+ gboolean state;
+ size_t seq = 0;
- gboolean state = g_value_get_boolean(prop_val);
+ g_assert(G_VALUE_TYPE(prop_val) == G_TYPE_BOOLEAN);
- size_t seq = 0;
+ state = g_value_get_boolean(prop_val);
body[seq++] = state ? '+' : '-';
diff --git a/src/idle-muc-manager.c b/src/idle-muc-manager.c
index 684d4eb..5c9f0bd 100644
--- a/src/idle-muc-manager.c
+++ b/src/idle-muc-manager.c
@@ -181,13 +181,14 @@ static void idle_muc_manager_class_init(IdleMUCManagerClass *klass) {
static IdleParserHandlerResult _numeric_error_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray *args, gpointer user_data) {
IdleMUCManagerPrivate *priv = IDLE_MUC_MANAGER_GET_PRIVATE(user_data);
TpHandle room_handle = g_value_get_uint(g_value_array_get_nth(args, 0));
+ IdleMUCChannel *chan;
if (!priv->channels) {
IDLE_DEBUG("Channels hash table missing, ignoring...");
return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED;
}
- IdleMUCChannel *chan = g_hash_table_lookup(priv->channels, GUINT_TO_POINTER(room_handle));
+ chan = g_hash_table_lookup(priv->channels, GUINT_TO_POINTER(room_handle));
if (!chan)
return IDLE_PARSER_HANDLER_RESULT_HANDLED;
@@ -221,13 +222,14 @@ static IdleParserHandlerResult _numeric_topic_handler(IdleParser *parser, IdlePa
IdleMUCManagerPrivate *priv = IDLE_MUC_MANAGER_GET_PRIVATE(user_data);
TpHandle room_handle = g_value_get_uint(g_value_array_get_nth(args, 0));
const gchar *topic = g_value_get_string(g_value_array_get_nth(args, 1));
+ IdleMUCChannel *chan;
if (!priv->channels) {
IDLE_DEBUG("Channels hash table missing, ignoring...");
return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED;
}
- IdleMUCChannel *chan = g_hash_table_lookup(priv->channels, GUINT_TO_POINTER(room_handle));
+ chan = g_hash_table_lookup(priv->channels, GUINT_TO_POINTER(room_handle));
if (chan)
idle_muc_channel_topic(chan, topic);
@@ -240,13 +242,14 @@ static IdleParserHandlerResult _numeric_topic_stamp_handler(IdleParser *parser,
TpHandle room_handle = g_value_get_uint(g_value_array_get_nth(args, 0));
TpHandle toucher_handle = g_value_get_uint(g_value_array_get_nth(args, 1));
time_t touched = g_value_get_uint(g_value_array_get_nth(args, 2));
+ IdleMUCChannel *chan;
if (!priv->channels) {
IDLE_DEBUG("Channels hash table missing, ignoring...");
return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED;
}
- IdleMUCChannel *chan = g_hash_table_lookup(priv->channels, GUINT_TO_POINTER(room_handle));
+ chan = g_hash_table_lookup(priv->channels, GUINT_TO_POINTER(room_handle));
idle_connection_emit_queued_aliases_changed(priv->conn);
@@ -262,6 +265,7 @@ static IdleParserHandlerResult _invite_handler(IdleParser *parser, IdleParserMes
TpHandle inviter_handle = g_value_get_uint(g_value_array_get_nth(args, 0));
TpHandle invited_handle = g_value_get_uint(g_value_array_get_nth(args, 1));
TpHandle room_handle = g_value_get_uint(g_value_array_get_nth(args, 2));
+ IdleMUCChannel *chan;
if (invited_handle != priv->conn->parent.self_handle)
return IDLE_PARSER_HANDLER_RESULT_HANDLED;
@@ -271,7 +275,7 @@ static IdleParserHandlerResult _invite_handler(IdleParser *parser, IdleParserMes
return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED;
}
- IdleMUCChannel *chan = g_hash_table_lookup(priv->channels, GUINT_TO_POINTER(room_handle));
+ chan = g_hash_table_lookup(priv->channels, GUINT_TO_POINTER(room_handle));
idle_connection_emit_queued_aliases_changed(priv->conn);
@@ -289,6 +293,7 @@ static IdleParserHandlerResult _join_handler(IdleParser *parser, IdleParserMessa
IdleMUCManagerPrivate *priv = IDLE_MUC_MANAGER_GET_PRIVATE(manager);
TpHandle joiner_handle = g_value_get_uint(g_value_array_get_nth(args, 0));
TpHandle room_handle = g_value_get_uint(g_value_array_get_nth(args, 1));
+ IdleMUCChannel *chan;
idle_connection_emit_queued_aliases_changed(priv->conn);
@@ -297,7 +302,7 @@ static IdleParserHandlerResult _join_handler(IdleParser *parser, IdleParserMessa
return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED;
}
- IdleMUCChannel *chan = g_hash_table_lookup(priv->channels, GUINT_TO_POINTER(room_handle));
+ chan = g_hash_table_lookup(priv->channels, GUINT_TO_POINTER(room_handle));
if (!chan) {
/* TODO: If we're in "bouncer mode", maybe these should be Requested:
@@ -316,13 +321,14 @@ static IdleParserHandlerResult _kick_handler(IdleParser *parser, IdleParserMessa
TpHandle room_handle = g_value_get_uint(g_value_array_get_nth(args, 1));
TpHandle kicked_handle = g_value_get_uint(g_value_array_get_nth(args, 2));
const gchar *message = (args->n_values == 4) ? g_value_get_string(g_value_array_get_nth(args, 3)) : NULL;
+ IdleMUCChannel *chan;
if (!priv->channels) {
IDLE_DEBUG("Channels hash table missing, ignoring...");
return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED;
}
- IdleMUCChannel *chan = g_hash_table_lookup(priv->channels, GUINT_TO_POINTER(room_handle));
+ chan = g_hash_table_lookup(priv->channels, GUINT_TO_POINTER(room_handle));
if (chan)
idle_muc_channel_kick(chan, kicked_handle, kicker_handle, message);
@@ -333,13 +339,14 @@ static IdleParserHandlerResult _kick_handler(IdleParser *parser, IdleParserMessa
static IdleParserHandlerResult _numeric_namereply_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray *args, gpointer user_data) {
IdleMUCManagerPrivate *priv = IDLE_MUC_MANAGER_GET_PRIVATE(user_data);
TpHandle room_handle = g_value_get_uint(g_value_array_get_nth(args, 0));
+ IdleMUCChannel *chan;
if (!priv->channels) {
IDLE_DEBUG("Channels hash table missing, ignoring...");
return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED;
}
- IdleMUCChannel *chan = g_hash_table_lookup(priv->channels, GUINT_TO_POINTER(room_handle));
+ chan = g_hash_table_lookup(priv->channels, GUINT_TO_POINTER(room_handle));
if (chan)
idle_muc_channel_namereply(chan, args);
@@ -350,13 +357,14 @@ static IdleParserHandlerResult _numeric_namereply_handler(IdleParser *parser, Id
static IdleParserHandlerResult _numeric_namereply_end_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray *args, gpointer user_data) {
IdleMUCManagerPrivate *priv = IDLE_MUC_MANAGER_GET_PRIVATE(user_data);
TpHandle room_handle = g_value_get_uint(g_value_array_get_nth(args, 0));
+ IdleMUCChannel *chan;
if (!priv->channels) {
IDLE_DEBUG("Channels hash table missing, ignoring...");
return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED;
}
- IdleMUCChannel *chan = g_hash_table_lookup(priv->channels, GUINT_TO_POINTER(room_handle));
+ chan = g_hash_table_lookup(priv->channels, GUINT_TO_POINTER(room_handle));
if (chan)
idle_muc_channel_namereply_end(chan);
@@ -367,13 +375,14 @@ static IdleParserHandlerResult _numeric_namereply_end_handler(IdleParser *parser
static IdleParserHandlerResult _mode_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray *args, gpointer user_data) {
IdleMUCManagerPrivate *priv = IDLE_MUC_MANAGER_GET_PRIVATE(user_data);
TpHandle room_handle = g_value_get_uint(g_value_array_get_nth(args, 0));
+ IdleMUCChannel *chan;
if (!priv->channels) {
IDLE_DEBUG("Channels hash table missing, ignoring...");
return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED;
}
- IdleMUCChannel *chan = g_hash_table_lookup(priv->channels, GUINT_TO_POINTER(room_handle));
+ chan = g_hash_table_lookup(priv->channels, GUINT_TO_POINTER(room_handle));
if (chan)
idle_muc_channel_mode(chan, args);
@@ -412,22 +421,22 @@ static IdleParserHandlerResult _notice_privmsg_handler(IdleParser *parser, IdleP
IdleMUCManagerPrivate *priv = IDLE_MUC_MANAGER_GET_PRIVATE(manager);
TpHandle sender_handle = (TpHandle) g_value_get_uint(g_value_array_get_nth(args, 0));
TpHandle room_handle = (TpHandle) g_value_get_uint(g_value_array_get_nth(args, 1));
+ IdleMUCChannel *chan;
+ TpChannelTextMessageType type;
+ gchar *body;
if (!priv->channels) {
IDLE_DEBUG("Channels hash table missing, ignoring...");
return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED;
}
- IdleMUCChannel *chan = g_hash_table_lookup(priv->channels, GUINT_TO_POINTER(room_handle));
+ chan = g_hash_table_lookup(priv->channels, GUINT_TO_POINTER(room_handle));
/* XXX: just check for chan == NULL here and bail with NOT_HANDLED if room
* was not found ? Currently we go through all of the decoding of the
* message, but don't actually deliver the message to a channel if chan is
* NULL, and then we return 'HANDLED', which seems wrong
*/
- TpChannelTextMessageType type;
- gchar *body;
-
if (code == IDLE_PARSER_PREFIXCMD_NOTICE_CHANNEL) {
type = TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE;
body = idle_ctcp_kill_blingbling(g_value_get_string(g_value_array_get_nth(args, 2)));
@@ -451,13 +460,14 @@ static IdleParserHandlerResult _part_handler(IdleParser *parser, IdleParserMessa
TpHandle leaver_handle = g_value_get_uint(g_value_array_get_nth(args, 0));
TpHandle room_handle = g_value_get_uint(g_value_array_get_nth(args, 1));
const gchar *message = (args->n_values == 3) ? g_value_get_string(g_value_array_get_nth(args, 2)) : NULL;
+ IdleMUCChannel *chan;
if (!priv->channels) {
IDLE_DEBUG("Channels hash table missing, ignoring...");
return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED;
}
- IdleMUCChannel *chan = g_hash_table_lookup(priv->channels, GUINT_TO_POINTER(room_handle));
+ chan = g_hash_table_lookup(priv->channels, GUINT_TO_POINTER(room_handle));
if (chan)
idle_muc_channel_part(chan, leaver_handle, message);
@@ -495,13 +505,14 @@ static IdleParserHandlerResult _topic_handler(IdleParser *parser, IdleParserMess
TpHandle room_handle = g_value_get_uint(g_value_array_get_nth(args, 1));
const gchar *topic = (args->n_values == 3) ? g_value_get_string(g_value_array_get_nth(args, 2)) : NULL;
time_t stamp = time(NULL);
+ IdleMUCChannel *chan;
if (!priv->channels) {
IDLE_DEBUG("Channels hash table missing, ignoring...");
return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED;
}
- IdleMUCChannel *chan = g_hash_table_lookup(priv->channels, GUINT_TO_POINTER(room_handle));
+ chan = g_hash_table_lookup(priv->channels, GUINT_TO_POINTER(room_handle));
if (chan) {
if (topic)
@@ -527,9 +538,7 @@ static void _muc_manager_close_all(IdleMUCManager *manager)
return;
}
- GHashTable *tmp = priv->channels;
- priv->channels = NULL;
- g_hash_table_destroy(tmp);
+ tp_clear_pointer (&priv->channels, g_hash_table_destroy);
}
static void
@@ -687,16 +696,16 @@ static void _channel_join_ready_cb(IdleMUCChannel *chan, guint err, gpointer use
TpChannelManager *manager = TP_CHANNEL_MANAGER(user_data);
IdleMUCManagerPrivate *priv = IDLE_MUC_MANAGER_GET_PRIVATE(user_data);
GSList *reqs = take_request_tokens(user_data, chan);
+ gint err_code = 0;
+ const gchar* err_msg = NULL;
+ TpHandle handle;
+ GSList *l;
if (err == MUC_CHANNEL_JOIN_ERROR_NONE) {
tp_channel_manager_emit_new_channel(manager, (TpExportableChannel *) chan, reqs);
goto out;
}
- gint err_code = 0;
- const gchar* err_msg = NULL;
- TpHandle handle;
-
g_object_get(chan, "handle", &handle, NULL);
switch (err) {
@@ -720,7 +729,7 @@ static void _channel_join_ready_cb(IdleMUCChannel *chan, guint err, gpointer use
break;
}
- for (GSList *l = reqs; reqs != NULL; reqs = reqs->next) {
+ for (l = reqs; reqs != NULL; reqs = reqs->next) {
tp_channel_manager_emit_request_failed(manager, l->data, TP_ERROR, err_code, err_msg);
}
diff --git a/src/idle-text.c b/src/idle-text.c
index 4b439a4..a168787 100644
--- a/src/idle-text.c
+++ b/src/idle-text.c
@@ -159,6 +159,8 @@ void idle_text_send(GObject *obj, TpMessage *message, TpMessageSendingFlags flag
guint n_parts;
GStrv messages;
GStrv bodies;
+ gsize msg_len;
+ guint i;
#define INVALID_ARGUMENT(msg, ...) \
G_STMT_START { \
@@ -198,12 +200,12 @@ void idle_text_send(GObject *obj, TpMessage *message, TpMessageSendingFlags flag
/* Okay, it's valid. Let's send it. */
- gsize msg_len = idle_connection_get_max_message_length(conn);
+ msg_len = idle_connection_get_max_message_length(conn);
messages = idle_text_encode_and_split(type, recipient, text, msg_len, &bodies, &error);
if (messages == NULL)
goto failed;
- for(guint i = 0; messages[i] != NULL; i++) {
+ for(i = 0; messages[i] != NULL; i++) {
g_assert(bodies[i] != NULL);
idle_connection_send(conn, messages[i]);
}