Mercurial > pidgin.yaz
changeset 20000:ab38146f8f78
There shouldn't be assert()s in pretty much any libpurple code.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Fri, 14 Sep 2007 00:17:33 +0000 |
parents | da29f5c7dc1a |
children | 94718bbf29d2 |
files | libpurple/protocols/jabber/adhoccommands.c libpurple/protocols/jabber/jabber.c libpurple/protocols/jabber/usermood.c libpurple/protocols/jabber/usernick.c libpurple/protocols/jabber/usertune.c |
diffstat | 5 files changed, 25 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/adhoccommands.c Fri Sep 14 00:03:30 2007 +0000 +++ b/libpurple/protocols/jabber/adhoccommands.c Fri Sep 14 00:17:33 2007 +0000 @@ -22,7 +22,6 @@ #include "internal.h" #include "adhoccommands.h" -#include <assert.h> #include <string.h> #include "internal.h" #include "xdata.h"
--- a/libpurple/protocols/jabber/jabber.c Fri Sep 14 00:03:30 2007 +0000 +++ b/libpurple/protocols/jabber/jabber.c Fri Sep 14 00:17:33 2007 +0000 @@ -57,8 +57,6 @@ #include "pep.h" #include "adhoccommands.h" -#include <assert.h> - #define JABBER_CONNECT_STEPS (js->gsc ? 9 : 5) static PurplePlugin *my_protocol = NULL; @@ -1134,17 +1132,17 @@ static void jabber_unregister_account_cb(JabberStream *js) { JabberIq *iq; xmlnode *query; - assert(js->unregistration); - - iq = jabber_iq_new_query(js,JABBER_IQ_SET,"jabber:iq:register"); - assert(iq); - query = xmlnode_get_child_with_namespace(iq->node,"query","jabber:iq:register"); - assert(query); - xmlnode_new_child(query,"remove"); - - xmlnode_set_attrib(iq->node,"to",js->user->domain); - jabber_iq_set_callback(iq,jabber_unregister_account_iq_cb,NULL); - + + g_return_if_fail(js->unregistration); + + iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); + + query = xmlnode_get_child_with_namespace(iq->node, "query", "jabber:iq:register"); + + xmlnode_new_child(query, "remove"); + xmlnode_set_attrib(iq->node, "to", js->user->domain); + + jabber_iq_set_callback(iq, jabber_unregister_account_iq_cb, NULL); jabber_iq_send(iq); } @@ -1163,11 +1161,16 @@ } js = gc->proto_data; - assert(!js->unregistration); /* don't allow multiple calls */ + + if (js->unregistration) { + purple_debug_error("jabber", "Unregistration in process; ignoring duplicate request.\n"); + return; + } + js->unregistration = TRUE; js->unregistration_cb = cb; js->unregistration_user_data = user_data; - + jabber_unregister_account_cb(js); } @@ -1325,10 +1328,10 @@ void jabber_add_feature(const char *shortname, const char *namespace, JabberFeatureEnabled cb) { JabberFeature *feat; - - assert(shortname != NULL); - assert(namespace != NULL); - + + g_return_if_fail(shortname != NULL); + g_return_if_fail(namespace != NULL); + feat = g_new0(JabberFeature,1); feat->shortname = g_strdup(shortname); feat->namespace = g_strdup(namespace);
--- a/libpurple/protocols/jabber/usermood.c Fri Sep 14 00:03:30 2007 +0000 +++ b/libpurple/protocols/jabber/usermood.c Fri Sep 14 00:17:33 2007 +0000 @@ -23,7 +23,6 @@ #include "usermood.h" #include "pep.h" -#include <assert.h> #include <string.h> #include "internal.h" #include "request.h" @@ -195,9 +194,9 @@ void jabber_mood_set(JabberStream *js, const char *mood, const char *text) { xmlnode *publish, *moodnode; - - assert(mood != NULL); - + + g_return_if_fail(mood != NULL); + publish = xmlnode_new("publish"); xmlnode_set_attrib(publish,"node","http://jabber.org/protocol/mood"); moodnode = xmlnode_new_child(xmlnode_new_child(publish, "item"), "mood");