pidgin: da24d9ca: Make the use of xmpp_iq_cb_data->context...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Tue Jul 7 13:45:34 EDT 2009


-----------------------------------------------------------------
Revision: da24d9ca9777582ee69619f69067bd6e205cc64b
Ancestor: 921a6693312cc38dd6dbc93e91d6bf5c60938634
Author: darkrain42 at pidgin.im
Date: 2009-07-07T05:09:53
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/da24d9ca9777582ee69619f69067bd6e205cc64b

Modified files:
        pidgin/plugins/disco/xmppdisco.c

ChangeLog: 

Make the use of xmpp_iq_cb_data->context explicit.

-------------- next part --------------
============================================================
--- pidgin/plugins/disco/xmppdisco.c	f07675efa50ceb781bfe41b6f3951b72798e7a70
+++ pidgin/plugins/disco/xmppdisco.c	e73772af62e1b9be2bba28ebaee048b8ca00a099
@@ -59,19 +59,26 @@ typedef void (*XmppIqCallback)(PurpleCon
                                const char *id, const char *from, xmlnode *iq,
                                gpointer data);
 
+struct item_data {
+	PidginDiscoList *list;
+	XmppDiscoService *parent;
+	char *name;
+	char *node; /* disco#info replies don't always include the node */
+};
+
 struct xmpp_iq_cb_data
 {
-	gpointer context;
+	/*
+	 * Every IQ callback in this plugin uses the same structure for the
+	 * callback data. It's a hack (it wouldn't scale), but it's used so that
+	 * it's easy to clean up all the callbacks when the account disconnects
+	 * (see remove_iq_callbacks_by_pc below).
+	 */
+	struct item_data *context;
 	PurpleConnection *pc;
 	XmppIqCallback cb;
 };
 
-struct item_data {
-	PidginDiscoList *list;
-	XmppDiscoService *parent;
-	char *name;
-	char *node; /* disco#info replies don't always include the node */
-};
 
 static char*
 generate_next_id()
@@ -93,11 +100,6 @@ remove_iq_callbacks_by_pc(gpointer key, 
 	struct xmpp_iq_cb_data *cb_data = value;
 
 	if (cb_data && cb_data->pc == user_data) {
-		/*
-		 * This is a hack. All the IQ callback datas in this code are
-		 * the same structure so that we can free them here. Ideally they'd
-		 * be objects and this would be polymorphic. That's overkill, here.
-		 */
 		struct item_data *item_data = cb_data->context;
 
 		if (item_data) {


More information about the Commits mailing list