[Telepathy-commits] [telepathy-idle/master] Don't use an invalid enum value as a failure flag
Will Thompson
will.thompson at collabora.co.uk
Wed Sep 24 02:47:07 PDT 2008
---
src/idle-im-factory.c | 7 +++----
src/idle-muc-factory.c | 7 +++----
src/idle-text.c | 7 ++++---
src/idle-text.h | 2 +-
4 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/src/idle-im-factory.c b/src/idle-im-factory.c
index 25880b2..972c8e3 100644
--- a/src/idle-im-factory.c
+++ b/src/idle-im-factory.c
@@ -124,12 +124,11 @@ static IdleParserHandlerResult _notice_privmsg_handler(IdleParser *parser, IdleP
type = TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE;
body = idle_ctcp_kill_blingbling(g_value_get_string(g_value_array_get_nth(args, 2)));
} else {
- idle_text_decode(g_value_get_string(g_value_array_get_nth(args, 2)), &type, &body);
+ gboolean decoded = idle_text_decode(g_value_get_string(g_value_array_get_nth(args, 2)), &type, &body);
+ if (!decoded)
+ return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED;
}
- if (type == -1)
- return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED;
-
idle_connection_emit_queued_aliases_changed(priv->conn);
if (!priv->channels) {
diff --git a/src/idle-muc-factory.c b/src/idle-muc-factory.c
index d29de69..ffbf5ef 100644
--- a/src/idle-muc-factory.c
+++ b/src/idle-muc-factory.c
@@ -375,12 +375,11 @@ static IdleParserHandlerResult _notice_privmsg_handler(IdleParser *parser, IdleP
type = TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE;
body = idle_ctcp_kill_blingbling(g_value_get_string(g_value_array_get_nth(args, 2)));
} else {
- idle_text_decode(g_value_get_string(g_value_array_get_nth(args, 2)), &type, &body);
+ gboolean decoded = idle_text_decode(g_value_get_string(g_value_array_get_nth(args, 2)), &type, &body);
+ if (!decoded)
+ return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED;
}
- if (type == -1)
- return IDLE_PARSER_HANDLER_RESULT_NOT_HANDLED;
-
if (chan)
idle_muc_channel_receive(chan, type, sender_handle, body);
diff --git a/src/idle-text.c b/src/idle-text.c
index 982c5ea..bd71eec 100644
--- a/src/idle-text.c
+++ b/src/idle-text.c
@@ -29,7 +29,7 @@
#include "idle-ctcp.h"
#include "idle-debug.h"
-void idle_text_decode(const gchar *text, TpChannelTextMessageType *type, gchar **body) {
+gboolean idle_text_decode(const gchar *text, TpChannelTextMessageType *type, gchar **body) {
gchar *tmp = NULL;
if (text[0] != '\001') {
@@ -41,13 +41,14 @@ void idle_text_decode(const gchar *text, TpChannelTextMessageType *type, gchar *
*type = TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION;
tmp = g_strndup(text + actionlen, strlen(text + actionlen) - 1);
} else {
- *type = -1;
- tmp = NULL;
+ *body = NULL;
+ return FALSE;
}
}
*body = idle_ctcp_kill_blingbling(tmp);
g_free(tmp);
+ return TRUE;
}
void idle_text_send(GObject *obj, guint type, const gchar *recipient, const gchar *text, IdleConnection *conn, DBusGMethodInvocation *context) {
diff --git a/src/idle-text.h b/src/idle-text.h
index 8aa10f5..94ee8a1 100644
--- a/src/idle-text.h
+++ b/src/idle-text.h
@@ -30,7 +30,7 @@
G_BEGIN_DECLS
-void idle_text_decode(const gchar *text, TpChannelTextMessageType *type, gchar **body);
+gboolean idle_text_decode(const gchar *text, TpChannelTextMessageType *type, gchar **body);
void idle_text_send(GObject *obj, guint type, const gchar *recipient, const gchar *text, IdleConnection *conn, DBusGMethodInvocation *ctx);
G_END_DECLS
--
1.5.6.5
More information about the Telepathy-commits
mailing list