pidgin: 65d5236e: Hide the blistnode, buddy, contact, grou...

grim at pidgin.im grim at pidgin.im
Wed Oct 29 23:05:37 EDT 2008


-----------------------------------------------------------------
Revision: 65d5236e936af6170109ef8c5af76c7871b9cc12
Ancestor: e15ae03551529f08eedcd38fa27b03fc4812bae8
Author: grim at pidgin.im
Date: 2008-10-28T04:22:57
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/65d5236e936af6170109ef8c5af76c7871b9cc12

Modified files:
        libpurple/blist.c libpurple/blist.h
        libpurple/plugins/autoaccept.c
        libpurple/plugins/log_reader.c
        libpurple/plugins/signals-test.c
        libpurple/plugins/statenotify.c

ChangeLog: 

Hide the blistnode, buddy, contact, group, and chat structs
Updated the libpurple plugins to use api rather than the structs directly


-------------- next part --------------
============================================================
--- libpurple/blist.c	dbd2ec408d1293102a651e6b04d02232eb79f2db
+++ libpurple/blist.c	75c3e7939b998bb26041fbd1341779ad2165828a
@@ -42,6 +42,59 @@ static gboolean       blist_loaded = FAL
 static gboolean       blist_loaded = FALSE;
 
 
+/******************************************************************************
+ * Structs
+ *****************************************************************************/
+#ifdef PURPLE_HIDE_STRUCTS
+struct _PurpleBlistNode {
+    PurpleBlistNodeType type;
+    PurpleBlistNode *prev;
+    PurpleBlistNode *next;
+    PurpleBlistNode *parent;
+    PurpleBlistNode *child;
+    GHashTable *settings;
+    void *ui_data;
+    PurpleBlistNodeFlags flags;
+};
+
+struct _PurpleBuddy {
+    PurpleBlistNode node;
+    char *name;
+    char *alias;
+    char *server_alias;
+    void *proto_data;
+    PurpleBuddyIcon *icon;
+    PurpleAccount *account;
+    PurplePresence *presence;
+};
+
+struct _PurpleContact {
+    PurpleBlistNode node;
+    char *alias;
+    int totalsize;
+    int currentsize;
+    int online;
+    PurpleBuddy *priority;
+    gboolean priority_valid;
+};
+
+struct _PurpleGroup {
+    PurpleBlistNode node;
+    char *name;
+    int totalsize;
+    int currentsize;
+    int online;
+};
+
+struct _PurpleChat {
+    PurpleBlistNode node;
+    char *alias;
+    GHashTable *components;
+    PurpleAccount *account;
+};
+
+#endif /* PURPLE_HIDE_STRUCTS */
+
 /*********************************************************************
  * Private utility functions                                         *
  *********************************************************************/
============================================================
--- libpurple/blist.h	b1dac94a9ac59d6dc854ceed75d0a1e5438bd57c
+++ libpurple/blist.h	2758bf86cdd320c8d3ac0088d58c3a0af10ffba1
@@ -89,6 +89,8 @@ typedef enum
 /* Data Structures                                                        */
 /**************************************************************************/
 
+#ifndef PURPLE_HIDE_STRUCTS
+
 /**
  * A Buddy list node.  This can represent a group, a buddy, or anything else.
  * This is a base class for struct buddy and struct group and for anything
@@ -154,7 +156,9 @@ struct _PurpleChat {
 	PurpleAccount *account; /**< The account this chat is attached to */
 };
 
+#endif /* PURPLE_HIDE_STRUCTS */
 
+
 /**
  * The Buddy List
  */
============================================================
--- libpurple/plugins/autoaccept.c	648ab517f31ecdf43ee1f517f4836506be8a55b3
+++ libpurple/plugins/autoaccept.c	56985f7a523a2c93c8e40b3ecf7648d47808f2ce
@@ -104,7 +104,7 @@ file_recv_request_cb(PurpleXfer *xfer, g
 		return;
 	}
 
-	node = node->parent;
+	node = purple_blist_node_get_parent(node);
 	g_return_if_fail(PURPLE_BLIST_NODE_IS_CONTACT(node));
 
 	pref = purple_prefs_get_string(PREF_PATH);
@@ -179,7 +179,7 @@ save_cb(PurpleBlistNode *node, int choic
 save_cb(PurpleBlistNode *node, int choice)
 {
 	if (PURPLE_BLIST_NODE_IS_BUDDY(node))
-		node = node->parent;
+		node = purple_blist_node_get_parent(node);
 	g_return_if_fail(PURPLE_BLIST_NODE_IS_CONTACT(node));
 	purple_blist_node_set_int(node, "autoaccept", choice);
 }
@@ -190,7 +190,7 @@ set_auto_accept_settings(PurpleBlistNode
 	char *message;
 
 	if (PURPLE_BLIST_NODE_IS_BUDDY(node))
-		node = node->parent;
+		node = purple_blist_node_get_parent(node);
 	g_return_if_fail(PURPLE_BLIST_NODE_IS_CONTACT(node));
 
 	message = g_strdup_printf(_("When a file-transfer request arrives from %s"), 
============================================================
--- libpurple/plugins/log_reader.c	eadb58343fb6a768e8f145ede32959adb25119d6
+++ libpurple/plugins/log_reader.c	c271903fb8c785eb7daa263bf8c8c02116ea6398
@@ -661,8 +661,10 @@ static GList *msn_logger_list(PurpleLogT
 		username = g_strdup(purple_normalize(account, account->username));
 	}
 
-	if (buddy)
-		savedfilename = purple_blist_node_get_string(&buddy->node, "log_reader_msn_log_filename");
+	if (buddy) {
+		PurpleBlistNode *node = (PurpleBlistNode *)buddy;
+		savedfilename = purple_blist_node_get_string(node, "log_reader_msn_log_filename");
+	}
 
 	if (savedfilename) {
 		/* As a special case, we allow the null string to kill the parsing
@@ -822,7 +824,8 @@ static GList *msn_logger_list(PurpleLogT
 	 * detected for both buddies.
 	 */
 	if (buddy && logfile) {
-		purple_blist_node_set_string(&buddy->node, "log_reader_msn_log_filename", logfile);
+		PurpleBlistNode *node = (PurpleBlistNode *)buddy;
+		purple_blist_node_set_string(node, "log_reader_msn_log_filename", logfile);
 		g_free(logfile);
 	}
 
@@ -981,8 +984,8 @@ static char * msn_logger_read (PurpleLog
 				gboolean from_name_matches;
 				gboolean to_name_matches;
 
-				if (buddy && buddy->alias)
-					their_name = buddy->alias;
+				if (buddy)
+					their_name = purple_buddy_get_alias(buddy);
 
 				if (log->account->alias)
 				{
@@ -1018,13 +1021,17 @@ static char * msn_logger_read (PurpleLog
 				} else if (to_name_matches) {
 					name_guessed = NAME_GUESS_THEM;
 				} else {
-					if (buddy && buddy->alias) {
-						char *alias = g_strdup(buddy->alias);
+					if (buddy) {
+						const gchar *a = NULL, *server_alias = NULL;
+						gchar *alias = NULL, *temp = NULL;
+						
+						a = purple_buddy_get_alias(buddy);
+						if(a)
+							alias = g_strdup(a);
 
 						/* "Truncate" the string at the first non-alphanumeric
 						 * character. The idea is to relax the comparison.
 						 */
-						char *temp;
 						for (temp = alias; *temp ; temp++) {
 							if (!isalnum(*temp)) {
 								*temp = '\0';
@@ -1056,9 +1063,9 @@ static char * msn_logger_read (PurpleLog
 							}
 						} else if (to_name_matches) {
 							name_guessed = NAME_GUESS_ME;
-						} else if (buddy->server_alias) {
+						} else if ((server_alias = purple_buddy_get_server_alias(buddy))) {
 							friendly_name_length =
-								strlen(buddy->server_alias);
+								strlen(server_alias);
 
 							/* Try to guess which user is them.
 							 * The first step is to determine if either of
@@ -1068,13 +1075,13 @@ static char * msn_logger_read (PurpleLog
 							 */
 							from_name_matches = (purple_str_has_prefix(
 									from_name,
-									buddy->server_alias) &&
+									server_alias) &&
 									!isalnum(*(from_name +
 									friendly_name_length)));
 
 							to_name_matches = to_name && (
 									(purple_str_has_prefix(
-									to_name, buddy->server_alias) &&
+									to_name, server_alias) &&
 									!isalnum(*(to_name +
 									friendly_name_length))));
 
@@ -1565,18 +1572,31 @@ static char * trillian_logger_read (Purp
 					g_string_append(formatted, "</b>");
 					footer = NULL;
 				} else if (strstr(line, " signed off ")) {
-					if (buddy != NULL && buddy->alias)
+					if (buddy != NULL) {
+						const gchar *alias = purple_buddy_get_alias(buddy);
+
+						if(alias != NULL)
+							g_string_append_printf(formatted,
+								_("%s has signed off."), alias);
+						else
+							g_string_append_printf(formatted,
+								_("%s has signed off."), log->name);
+					} else {
 						g_string_append_printf(formatted,
-							_("%s has signed off."), buddy->alias);
-					else
-						g_string_append_printf(formatted,
 							_("%s has signed off."), log->name);
+					}
 					line = "";
 				} else if (strstr(line, " signed on ")) {
-					if (buddy != NULL && buddy->alias)
-						g_string_append(formatted, buddy->alias);
-					else
+					if (buddy != NULL) {
+						const gchar *alias = purple_buddy_get_alias(buddy);
+
+						if(alias)
+							g_string_append(formatted, alias);
+						else
+							g_string_append(formatted, log->name);
+					} else {
 						g_string_append(formatted, log->name);
+					}
 					line = " logged in.";
 				} else if (purple_str_has_prefix(line,
 					"One or more messages may have been undeliverable.")) {
@@ -1631,11 +1651,15 @@ static char * trillian_logger_read (Purp
 					footer = "</span></b>";
 				}
 			} else if (purple_str_has_prefix(line, data->their_nickname)) {
-				if (buddy != NULL && buddy->alias) {
-					line += strlen(data->their_nickname) + 2;
-					g_string_append_printf(formatted,
-						"<span style=\"color: #A82F2F;\">"
-						"<b>%s</b></span>: ", buddy->alias);
+				if (buddy != NULL) {
+					const gchar *alias = purple_buddy_get_alias(buddy);
+
+					if(alias != NULL) {
+						line += strlen(data->their_nickname) + 2;
+						g_string_append_printf(formatted,
+							"<span style=\"color: #A82F2F;\">"
+							"<b>%s</b></span>: ", alias);
+					}
 				}
 			} else {
 				const char *line2 = strstr(line, ":");
@@ -2001,10 +2025,14 @@ static char *qip_logger_read(PurpleLog *
 					g_string_append(formatted, "</font> ");
 
 					if (is_in_message) {
-						if (buddy_name != NULL && buddy != NULL && buddy->alias) {
+						const gchar *alias = NULL;
+
+						if (buddy_name != NULL && buddy != NULL &&
+							(alias = purple_buddy_get_alias(buddy)))
+						{
 							g_string_append_printf(formatted,
 								"<span style=\"color: #A82F2F;\">"
-								"<b>%s</b></span>: ", buddy->alias);
+								"<b>%s</b></span>: ", alias);
 						}
 					} else {
 						const char *acct_name;
============================================================
--- libpurple/plugins/signals-test.c	b7600533cdeeb74dcd9530c9fdba328903a5115b
+++ libpurple/plugins/signals-test.c	6fd6f5f657418e082b36247affc3d4ed1ea24c21
@@ -116,8 +116,9 @@ buddy_status_changed_cb(PurpleBuddy *bud
                         PurpleStatus *status, void *data)
 {
 	purple_debug_misc("signals test", "buddy-status-changed (%s %s to %s)\n",
-	                buddy->name, purple_status_get_id(old_status),
-	                purple_status_get_id(status));
+	                  purple_buddy_get_name(buddy),
+	                  purple_status_get_id(old_status),
+	                  purple_status_get_id(status));
 }
 
 static void
@@ -125,25 +126,29 @@ buddy_idle_changed_cb(PurpleBuddy *buddy
                       void *data)
 {
 	purple_debug_misc("signals test", "buddy-idle-changed (%s %s)\n",
-	                buddy->name, old_idle ? "unidled" : "idled");
+	                  purple_buddy_get_name(buddy),
+	                  old_idle ? "unidled" : "idled");
 }
 
 static void
 buddy_signed_on_cb(PurpleBuddy *buddy, void *data)
 {
-	purple_debug_misc("signals test", "buddy-signed-on (%s)\n", buddy->name);
+	purple_debug_misc("signals test", "buddy-signed-on (%s)\n",
+	                  purple_buddy_get_name(buddy));
 }
 
 static void
 buddy_signed_off_cb(PurpleBuddy *buddy, void *data)
 {
-	purple_debug_misc("signals test", "buddy-signed-off (%s)\n", buddy->name);
+	purple_debug_misc("signals test", "buddy-signed-off (%s)\n",
+	                  purple_buddy_get_name(buddy));
 }
 
 static void
 buddy_added_cb(PurpleBuddy *buddy, void *data)
 {
-	purple_debug_misc("signals test", "buddy_added_cb (%s)\n", purple_buddy_get_name(buddy));
+	purple_debug_misc("signals test", "buddy_added_cb (%s)\n",
+	                  purple_buddy_get_name(buddy));
 }
 
 static void
@@ -160,17 +165,27 @@ blist_node_aliased(PurpleBlistNode *node
 	PurpleChat *c = (PurpleChat *)node;
 	PurpleGroup *g = (PurpleGroup *)node;
 
-	if (PURPLE_BLIST_NODE_IS_CONTACT(node))
-		purple_debug_misc("signals test", "blist-node-aliased (Contact: %s, %s)\n", p->alias, old_alias);
-	else if (PURPLE_BLIST_NODE_IS_BUDDY(node))
-		purple_debug_misc("signals test", "blist-node-aliased (Buddy: %s, %s)\n", b->name, old_alias);
-	else if (PURPLE_BLIST_NODE_IS_CHAT(node))
-		purple_debug_misc("signals test", "blist-node-aliased (Chat: %s, %s)\n", c->alias, old_alias);
-	else if (PURPLE_BLIST_NODE_IS_GROUP(node))
-		purple_debug_misc("signals test", "blist-node-aliased (Group: %s, %s)\n", g->name, old_alias);
-	else
-		purple_debug_misc("signals test", "blist-node-aliased (UNKNOWN: %d, %s)\n", node->type, old_alias);
-
+	if (PURPLE_BLIST_NODE_IS_CONTACT(node)) {
+		purple_debug_misc("signals test",
+		                  "blist-node-aliased (Contact: %s, %s)\n",
+		                  purple_contact_get_alias(p), old_alias);
+	} else if (PURPLE_BLIST_NODE_IS_BUDDY(node)) {
+		purple_debug_misc("signals test",
+		                  "blist-node-aliased (Buddy: %s, %s)\n",
+		                  purple_buddy_get_name(b), old_alias);
+	} else if (PURPLE_BLIST_NODE_IS_CHAT(node)) {
+		purple_debug_misc("signals test",
+		                  "blist-node-aliased (Chat: %s, %s)\n",
+		                  purple_chat_get_name(c), old_alias);
+	} else if (PURPLE_BLIST_NODE_IS_GROUP(node)) {
+		purple_debug_misc("signals test",
+		                  "blist-node-aliased (Group: %s, %s)\n",
+		                  purple_group_get_name(g), old_alias);
+	} else {
+		purple_debug_misc("signals test",
+		                  "blist-node-aliased (UNKNOWN: %d, %s)\n",
+		                  purple_blist_node_get_type(node), old_alias);
+	}
 }
 
 static void
@@ -181,17 +196,27 @@ blist_node_extended_menu_cb(PurpleBlistN
 	PurpleChat *c = (PurpleChat *)node;
 	PurpleGroup *g = (PurpleGroup *)node;
 
-	if (PURPLE_BLIST_NODE_IS_CONTACT(node))
-		purple_debug_misc("signals test", "blist-node-extended-menu (Contact: %s)\n", p->alias);
-	else if (PURPLE_BLIST_NODE_IS_BUDDY(node))
-		purple_debug_misc("signals test", "blist-node-extended-menu (Buddy: %s)\n", b->name);
-	else if (PURPLE_BLIST_NODE_IS_CHAT(node))
-		purple_debug_misc("signals test", "blist-node-extended-menu (Chat: %s)\n", c->alias);
-	else if (PURPLE_BLIST_NODE_IS_GROUP(node))
-		purple_debug_misc("signals test", "blist-node-extended-menu (Group: %s)\n", g->name);
-	else
-		purple_debug_misc("signals test", "blist-node-extended-menu (UNKNOWN: %d)\n", node->type);
-
+	if (PURPLE_BLIST_NODE_IS_CONTACT(node)) {
+		purple_debug_misc("signals test",
+		                  "blist-node-extended-menu (Contact: %s)\n",
+		                  purple_contact_get_alias(p));
+	} else if (PURPLE_BLIST_NODE_IS_BUDDY(node)) {
+		purple_debug_misc("signals test",
+		                  "blist-node-extended-menu (Buddy: %s)\n",
+		                  purple_buddy_get_name(b));
+	} else if (PURPLE_BLIST_NODE_IS_CHAT(node)) {
+		purple_debug_misc("signals test",
+		                  "blist-node-extended-menu (Chat: %s)\n",
+		                  purple_chat_get_name(c));
+	} else if (PURPLE_BLIST_NODE_IS_GROUP(node)) {
+		purple_debug_misc("signals test",
+		                  "blist-node-extended-menu (Group: %s)\n",
+		                  purple_group_get_name(g));
+	} else {
+		purple_debug_misc("signals test",
+		                  "blist-node-extended-menu (UNKNOWN: %d)\n",
+		                  purple_blist_node_get_type(node));
+	}
 }
 
 
============================================================
--- libpurple/plugins/statenotify.c	caac5d791421b201b76ac8111f2cf4698fbedb5b
+++ libpurple/plugins/statenotify.c	0aa8c83c7474506fdf41e4062d77ddc420a563ae
@@ -15,13 +15,18 @@ write_status(PurpleBuddy *buddy, const c
 static void
 write_status(PurpleBuddy *buddy, const char *message)
 {
+	PurpleAccount *account = NULL;
 	PurpleConversation *conv;
 	const char *who;
 	char buf[256];
 	char *escaped;
+	const gchar *buddy_name = NULL;
 
+	account = purple_buddy_get_account(buddy);
+	buddy_name = purple_buddy_get_name(buddy);
+
 	conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM,
-											   buddy->name, buddy->account);
+												 buddy_name, account);
 
 	if (conv == NULL)
 		return;


More information about the Commits mailing list