pidgin: 02982091: Clean up jabber prpl memory allocations ...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Sun May 3 16:20:30 EDT 2009
-----------------------------------------------------------------
Revision: 02982091b25d51cf15064b67811f0ff347e3ec48
Ancestor: b3703f5983a0cc2409d0c9af899feaef255fe973
Author: hebnern at gmail.com
Date: 2009-05-03T20:17:09
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/02982091b25d51cf15064b67811f0ff347e3ec48
Modified files:
libpurple/protocols/jabber/caps.c
libpurple/protocols/jabber/ibb.c
libpurple/protocols/jabber/jabber.c
libpurple/protocols/jabber/jabber.h
libpurple/protocols/jabber/libxmpp.c
libpurple/protocols/jabber/pep.c
ChangeLog:
Clean up jabber prpl memory allocations on uninit.
Thanks to Nick Hebner. I had previously done some work on this, which is why
this patch doesn't look as similar as it might to jabber_memory_cleanup.diff.
Closes #8683.
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/caps.c 9d177f7f83ddc4b5325031317a31907bc3fba840
+++ libpurple/protocols/jabber/caps.c 3c5eea3fb2cdc32875e903beba953763c0b668de
@@ -349,7 +349,7 @@ void jabber_caps_uninit(void)
}
g_hash_table_destroy(capstable);
g_hash_table_destroy(nodetable);
- capstable = NULL;
+ capstable = nodetable = NULL;
}
typedef struct _jabber_caps_cbplususerdata {
============================================================
--- libpurple/protocols/jabber/ibb.c 9561150e4111478d80108b5979d5f02c249b89a7
+++ libpurple/protocols/jabber/ibb.c 3908b7beaecbd1eb5c8d08e5e069f6ad3002d512
@@ -503,6 +503,8 @@ jabber_ibb_init(void)
{
jabber_ibb_sessions = g_hash_table_new(g_str_hash, g_str_equal);
+ jabber_add_feature(XEP_0047_NAMESPACE, NULL);
+
jabber_iq_register_handler("close", XEP_0047_NAMESPACE, jabber_ibb_parse);
jabber_iq_register_handler("data", XEP_0047_NAMESPACE, jabber_ibb_parse);
jabber_iq_register_handler("open", XEP_0047_NAMESPACE, jabber_ibb_parse);
============================================================
--- libpurple/protocols/jabber/jabber.c ec7aa5f556b98a3c5ff5178f5ff525138859639c
+++ libpurple/protocols/jabber/jabber.c 86ab306b3c9de6a66f39d2d6cf5f811fc297fc12
@@ -70,6 +70,7 @@ GList *jabber_identities = NULL;
static PurplePlugin *my_protocol = NULL;
GList *jabber_features = NULL;
GList *jabber_identities = NULL;
+GSList *jabber_cmds = NULL;
static void jabber_unregister_account_cb(JabberStream *js);
static void try_srv_connect(JabberStream *js);
@@ -3159,89 +3160,126 @@ void jabber_register_commands(void)
void jabber_register_commands(void)
{
- purple_cmd_register("config", "", PURPLE_CMD_P_PRPL,
+ PurpleCmdId id;
+ id = purple_cmd_register("config", "", PURPLE_CMD_P_PRPL,
PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
"prpl-jabber", jabber_cmd_chat_config,
_("config: Configure a chat room."), NULL);
- purple_cmd_register("configure", "", PURPLE_CMD_P_PRPL,
+ jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
+
+ id = purple_cmd_register("configure", "", PURPLE_CMD_P_PRPL,
PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
"prpl-jabber", jabber_cmd_chat_config,
_("configure: Configure a chat room."), NULL);
- purple_cmd_register("nick", "s", PURPLE_CMD_P_PRPL,
+ jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
+
+ id = purple_cmd_register("nick", "s", PURPLE_CMD_P_PRPL,
PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
"prpl-jabber", jabber_cmd_chat_nick,
_("nick <new nickname>: Change your nickname."),
NULL);
- purple_cmd_register("part", "s", PURPLE_CMD_P_PRPL,
+ jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
+
+ id = purple_cmd_register("part", "s", PURPLE_CMD_P_PRPL,
PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
jabber_cmd_chat_part, _("part [room]: Leave the room."),
NULL);
- purple_cmd_register("register", "", PURPLE_CMD_P_PRPL,
+ jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
+
+ id = purple_cmd_register("register", "", PURPLE_CMD_P_PRPL,
PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
"prpl-jabber", jabber_cmd_chat_register,
_("register: Register with a chat room."), NULL);
+ jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
+
/* XXX: there needs to be a core /topic cmd, methinks */
- purple_cmd_register("topic", "s", PURPLE_CMD_P_PRPL,
+ id = purple_cmd_register("topic", "s", PURPLE_CMD_P_PRPL,
PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
jabber_cmd_chat_topic,
_("topic [new topic]: View or change the topic."),
NULL);
- purple_cmd_register("ban", "ws", PURPLE_CMD_P_PRPL,
+ jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
+
+ id = purple_cmd_register("ban", "ws", PURPLE_CMD_P_PRPL,
PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
jabber_cmd_chat_ban,
_("ban <user> [reason]: Ban a user from the room."),
NULL);
- purple_cmd_register("affiliate", "ws", PURPLE_CMD_P_PRPL,
+ jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
+
+ id = purple_cmd_register("affiliate", "ws", PURPLE_CMD_P_PRPL,
PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
jabber_cmd_chat_affiliate,
_("affiliate <owner|admin|member|outcast|none> [nick1] [nick2] ...: Get the users with an affiliation or set users' affiliation with the room."),
NULL);
- purple_cmd_register("role", "ws", PURPLE_CMD_P_PRPL,
+ jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
+
+ id = purple_cmd_register("role", "ws", PURPLE_CMD_P_PRPL,
PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
jabber_cmd_chat_role,
_("role <moderator|participant|visitor|none> [nick1] [nick2] ...: Get the users with an role or set users' role with the room."),
NULL);
- purple_cmd_register("invite", "ws", PURPLE_CMD_P_PRPL,
+ jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
+
+ id = purple_cmd_register("invite", "ws", PURPLE_CMD_P_PRPL,
PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
jabber_cmd_chat_invite,
_("invite <user> [message]: Invite a user to the room."),
NULL);
- purple_cmd_register("join", "ws", PURPLE_CMD_P_PRPL,
+ jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
+
+ id = purple_cmd_register("join", "ws", PURPLE_CMD_P_PRPL,
PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
jabber_cmd_chat_join,
_("join: <room> [password]: Join a chat on this server."),
NULL);
- purple_cmd_register("kick", "ws", PURPLE_CMD_P_PRPL,
+ jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
+
+ id = purple_cmd_register("kick", "ws", PURPLE_CMD_P_PRPL,
PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
jabber_cmd_chat_kick,
_("kick <user> [reason]: Kick a user from the room."),
NULL);
- purple_cmd_register("msg", "ws", PURPLE_CMD_P_PRPL,
+ jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
+
+ id = purple_cmd_register("msg", "ws", PURPLE_CMD_P_PRPL,
PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
"prpl-jabber", jabber_cmd_chat_msg,
_("msg <user> <message>: Send a private message to another user."),
NULL);
- purple_cmd_register("ping", "w", PURPLE_CMD_P_PRPL,
+ jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
+
+ id = purple_cmd_register("ping", "w", PURPLE_CMD_P_PRPL,
PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM |
PURPLE_CMD_FLAG_PRPL_ONLY,
"prpl-jabber", jabber_cmd_ping,
_("ping <jid>: Ping a user/component/server."),
NULL);
- purple_cmd_register("buzz", "w", PURPLE_CMD_P_PRPL,
+ jabber_cmds = g_slist_prepend(jabber_cmds, GUINT_TO_POINTER(id));
+
+ id = purple_cmd_register("buzz", "w", PURPLE_CMD_P_PRPL,
PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_PRPL_ONLY |
PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS,
"prpl-jabber", jabber_cmd_buzz,
_("buzz: Buzz a user to get their attention"), NULL);
}
+void jabber_unregister_commands(void)
+{
+ while (jabber_cmds != NULL) {
+ purple_cmd_unregister(GPOINTER_TO_UINT(jabber_cmds->data));
+ jabber_cmds = g_slist_delete_link(jabber_cmds, jabber_cmds);
+ }
+}
+
/* IPC functions */
/**
@@ -3317,6 +3355,12 @@ jabber_init_plugin(PurplePlugin *plugin)
jabber_add_feature("http://jabber.org/protocol/xhtml-im", 0);
jabber_add_feature("urn:xmpp:ping", 0);
+ /* Buzz/Attention */
+ jabber_add_feature(XEP_0224_NAMESPACE, jabber_buzz_isenabled);
+
+ /* Bits Of Binary */
+ jabber_add_feature(XEP_0231_NAMESPACE, jabber_custom_smileys_isenabled);
+
/* Jingle features! */
jabber_add_feature(JINGLE, 0);
jabber_add_feature(JINGLE_TRANSPORT_RAWUDP, 0);
============================================================
--- libpurple/protocols/jabber/jabber.h e115eba1ef348da582027e003f25208f8704354c
+++ libpurple/protocols/jabber/jabber.h 3aa5419d7cee083fb06962c961551cb75bc73301
@@ -366,6 +366,7 @@ void jabber_register_commands(void);
PurpleMediaCaps jabber_get_media_caps(PurpleAccount *account, const char *who);
void jabber_register_commands(void);
+void jabber_unregister_commands(void);
void jabber_init_plugin(PurplePlugin *plugin);
void jabber_uninit_plugin(void);
============================================================
--- libpurple/protocols/jabber/libxmpp.c b4050f1d4cc28f2a493ec3838fdd640f815a2c42
+++ libpurple/protocols/jabber/libxmpp.c 55e5d9b2c392cc4cac72fd57d5710ef0b52f404c
@@ -161,6 +161,8 @@ static gboolean unload_plugin(PurplePlug
jabber_caps_uninit();
jabber_iq_uninit();
+ jabber_unregister_commands();
+
/* Stay on target...stay on target... Almost there... */
jabber_uninit_plugin();
@@ -298,10 +300,6 @@ init_plugin(PurplePlugin *plugin)
jabber_ibb_init();
jabber_si_init();
-
- jabber_add_feature(XEP_0224_NAMESPACE, jabber_buzz_isenabled);
- jabber_add_feature(XEP_0231_NAMESPACE, jabber_custom_smileys_isenabled);
- jabber_add_feature(XEP_0047_NAMESPACE, NULL);
}
============================================================
--- libpurple/protocols/jabber/pep.c a123e50ced058cf5954343fcf124e6f5709dc819
+++ libpurple/protocols/jabber/pep.c 30f69644f7809b59bbf52d78b6a250dda1f5c73d
@@ -44,7 +44,10 @@ void jabber_pep_uninit(void) {
}
void jabber_pep_uninit(void) {
- /* any PEP handlers that need to clean things up go here */
+ /* any PEP handlers that need to clean things up go here. The standard
+ * cleanup of removing the handler and feature are handled here and by
+ * jabber_features_destroy() in jabber.c
+ */
g_hash_table_destroy(pep_handlers);
pep_handlers = NULL;
}
More information about the Commits
mailing list