im.pidgin.pidgin: 72bbb00c0c78543131719af4cdd9dfc2d9a1c3ef

sadrul at pidgin.im sadrul at pidgin.im
Sat Jan 26 17:00:49 EST 2008


-----------------------------------------------------------------
Revision: 72bbb00c0c78543131719af4cdd9dfc2d9a1c3ef
Ancestor: dcc6cd243138670a283a38b44b88f6d9cc1ea360
Author: sadrul at pidgin.im
Date: 2008-01-26T20:32:26
Branch: im.pidgin.pidgin

Modified files:
        ChangeLog.API finch/gntblist.c finch/gntconv.c
        finch/gntrequest.c finch/plugins/gnthistory.c
        libpurple/blist.c libpurple/blist.h

ChangeLog: 

Add API so Finch doesn't need to touch the internals of PurpleBlistNode.

-------------- next part --------------
============================================================
--- ChangeLog.API	9ced79cf0babca5d7bd0fb8bd7534fe4221b0eea
+++ ChangeLog.API	4c3735bb44480dae63b5ba97ad431065215058d3
@@ -34,6 +34,7 @@ version 2.4.0 (??/??/????):
 			* purple_blist_node_get_parent
 			* purple_blist_node_get_first_child
 			* purple_blist_node_get_sibling_next
+			* purple_blist_node_get_sibling_prev
 			* purple_chat_get_account
 		* Added last_received to PurpleConnection, the time_t of the
 		  last received packet.
============================================================
--- finch/gntblist.c	c9e3e50355973c76308a9cb4ed329ae6cadd7caa
+++ finch/gntblist.c	0e620928f08f2b77fa10c61734dfe1a34365bb94
@@ -2158,7 +2158,7 @@ blist_node_compare_position(PurpleBlistN
 static int
 blist_node_compare_position(PurpleBlistNode *n1, PurpleBlistNode *n2)
 {
-	while ((n1 = n1->prev) != NULL)
+	while ((n1 = purple_blist_node_get_sibling_prev(n1)) != NULL)
 		if (n1 == n2)
 			return 1;
 	return -1;
@@ -2171,10 +2171,10 @@ blist_node_compare_text(PurpleBlistNode 
 	char *us1, *us2;
 	int ret;
 
-	if (n1->type != n2->type)
+	if (purple_blist_node_get_type(n1) != purple_blist_node_get_type(n2))
 		return blist_node_compare_position(n1, n2);
 
-	switch (n1->type)
+	switch (purple_blist_node_get_type(n1))
 	{
 		case PURPLE_BLIST_CHAT_NODE:
 			s1 = purple_chat_get_name((PurpleChat*)n1);
@@ -2206,10 +2206,10 @@ blist_node_compare_status(PurpleBlistNod
 {
 	int ret;
 
-	if (n1->type != n2->type)
+	if (purple_blist_node_get_type(n1) != purple_blist_node_get_type(n2))
 		return blist_node_compare_position(n1, n2);
 
-	switch (n1->type) {
+	switch (purple_blist_node_get_type(n1)) {
 		case PURPLE_BLIST_CONTACT_NODE:
 			n1 = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact*)n1);
 			n2 = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact*)n2);
@@ -2251,10 +2251,10 @@ blist_node_compare_log(PurpleBlistNode *
 	int ret;
 	PurpleBuddy *b1, *b2;
 
-	if (n1->type != n2->type)
+	if (purple_blist_node_get_type(n1) != purple_blist_node_get_type(n2))
 		return blist_node_compare_position(n1, n2);
 
-	switch (n1->type) {
+	switch (purple_blist_node_get_type(n1)) {
 		case PURPLE_BLIST_BUDDY_NODE:
 			b1 = (PurpleBuddy*)n1;
 			b2 = (PurpleBuddy*)n2;
============================================================
--- finch/gntconv.c	79eaca4ce54d24e1b281a77d8d2cfc168dbb3e01
+++ finch/gntconv.c	917dbec5c5000682efb7336cc6e79f9fa2cfd57b
@@ -79,7 +79,7 @@ get_conversation_blist_node(PurpleConver
 	switch (purple_conversation_get_type(conv)) {
 		case PURPLE_CONV_TYPE_IM:
 			node = (PurpleBlistNode*)purple_find_buddy(conv->account, conv->name);
-			node = node ? node->parent : NULL;
+			node = node ? purple_blist_node_get_parent(node) : NULL;
 			break;
 		case PURPLE_CONV_TYPE_CHAT:
 			node = (PurpleBlistNode*)purple_blist_find_chat(conv->account, conv->name);
@@ -236,7 +236,8 @@ find_conv_with_contact(PurpleAccount *ac
 	if (!buddy)
 		return NULL;
 
-	for (node = ((PurpleBlistNode*)buddy)->parent->child; node; node = node->next) {
+	for (node = purple_blist_node_get_first_child(purple_blist_node_get_parent((PurpleBlistNode*)buddy));
+				node; node = purple_blist_node_get_sibling_next(node)) {
 		if (node == (PurpleBlistNode*)buddy)
 			continue;
 		if ((ret = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM,
@@ -476,7 +477,8 @@ generate_send_to_menu(FinchConv *ggc)
 
 	for (; buds; buds = g_slist_delete_link(buds, buds)) {
 		PurpleBlistNode *node = (PurpleBlistNode *)purple_buddy_get_contact((PurpleBuddy *)buds->data);
-		for (node = node->child; node != NULL; node = node->next) {
+		for (node = purple_blist_node_get_first_child(node); node != NULL;
+				node = purple_blist_node_get_sibling_next(node)) {
 			PurpleBuddy *buddy = (PurpleBuddy *)node;
 			PurpleAccount *account = purple_buddy_get_account(buddy);
 			if (purple_account_is_connected(account)) {
============================================================
--- finch/gntrequest.c	85721a590a0e3aeaef4d9dcf2844a74f54722038
+++ finch/gntrequest.c	c047f3dbf21bb39d63c61b6b30da6e59b61ab808
@@ -424,7 +424,8 @@ create_string_field(PurpleRequestField *
 			*screenname = entry;
 	} else if (hint && !strcmp(hint, "group")) {
 		PurpleBlistNode *node;
-		for (node = purple_blist_get_root(); node; node = node->next) {
+		for (node = purple_blist_get_root(); node;
+				node = purple_blist_node_get_sibling_next(node)) {
 			if (PURPLE_BLIST_NODE_IS_GROUP(node))
 				gnt_entry_add_suggest(GNT_ENTRY(entry), ((PurpleGroup *)node)->name);
 		}
============================================================
--- finch/plugins/gnthistory.c	866bbaaf096996c787d2f978d19b9c6b3e2c7104
+++ finch/plugins/gnthistory.c	a604ebc8b52bcb44c408e1b0a9673c859d24c464
@@ -51,8 +51,7 @@ static void historize(PurpleConversation
 	PurpleMessageFlags mflag;
 
 	convtype = purple_conversation_get_type(c);
-	if (convtype == PURPLE_CONV_TYPE_IM)
-	{
+	if (convtype == PURPLE_CONV_TYPE_IM) {
 		GSList *buddies;
 		GSList *cur;
 
@@ -62,17 +61,17 @@ static void historize(PurpleConversation
 			return;
 
 		/* Find buddies for this conversation. */
-	        buddies = purple_find_buddies(account, name);
+		buddies = purple_find_buddies(account, name);
 
 		/* If we found at least one buddy, save the first buddy's alias. */
 		if (buddies != NULL)
 			alias = purple_buddy_get_contact_alias((PurpleBuddy *)buddies->data);
 
-	        for (cur = buddies; cur != NULL; cur = cur->next)
-	        {
-	                PurpleBlistNode *node = cur->data;
-	                if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL)))
-	                {
+		for (cur = buddies; cur != NULL; cur = cur->next) {
+			PurpleBlistNode *node = cur->data;
+			if ((node != NULL) &&
+					((purple_blist_node_get_sibling_prev(node) != NULL) ||
+						(purple_blist_node_get_sibling_next(node) != NULL))) {
 				PurpleBlistNode *node2;
 
 				alias = purple_buddy_get_contact_alias((PurpleBuddy *)node);
@@ -80,26 +79,24 @@ static void historize(PurpleConversation
 				/* We've found a buddy that matches this conversation.  It's part of a
 				 * PurpleContact with more than one PurpleBuddy.  Loop through the PurpleBuddies
 				 * in the contact and get all the logs. */
-				for (node2 = node->parent->child ; node2 != NULL ; node2 = node2->next)
-				{
+				for (node2 = purple_blist_node_get_first_child(purple_blist_node_get_parent(node));
+						node2 != NULL ; node2 = purple_blist_node_get_sibling_next(node2)) {
 					logs = g_list_concat(
-						purple_log_get_logs(PURPLE_LOG_IM,
-							purple_buddy_get_name((PurpleBuddy *)node2),
-							purple_buddy_get_account((PurpleBuddy *)node2)),
-						logs);
+							purple_log_get_logs(PURPLE_LOG_IM,
+								purple_buddy_get_name((PurpleBuddy *)node2),
+								purple_buddy_get_account((PurpleBuddy *)node2)),
+							logs);
 				}
 				break;
-	                }
-	        }
-	        g_slist_free(buddies);
+			}
+		}
+		g_slist_free(buddies);
 
 		if (logs == NULL)
 			logs = purple_log_get_logs(PURPLE_LOG_IM, name, account);
 		else
 			logs = g_list_sort(logs, purple_log_compare);
-	}
-	else if (convtype == PURPLE_CONV_TYPE_CHAT)
-	{
+	} else if (convtype == PURPLE_CONV_TYPE_CHAT) {
 		/* If we're not logging, don't show anything.
 		 * Otherwise, we might show a very old log. */
 		if (!purple_prefs_get_bool("/purple/logging/log_chats"))
@@ -115,7 +112,7 @@ static void historize(PurpleConversation
 	history = purple_log_read((PurpleLog*)logs->data, &flags);
 
 	header = g_strdup_printf(_("<b>Conversation with %s on %s:</b><br>"), alias,
-							 purple_date_format_full(localtime(&((PurpleLog *)logs->data)->time)));
+			purple_date_format_full(localtime(&((PurpleLog *)logs->data)->time)));
 	purple_conversation_write(c, "", header, mflag, time(NULL));
 	g_free(header);
 
============================================================
--- libpurple/blist.c	ac450236ede90d2c33c36142013dbc069e6ac8e6
+++ libpurple/blist.c	1c4a5cf9fa2a7e7458741c9943794de3f507dc91
@@ -768,6 +768,11 @@ PurpleBlistNode *purple_blist_node_get_s
 	return node? node->next : NULL;
 }
 
+PurpleBlistNode *purple_blist_node_get_sibling_prev(PurpleBlistNode *node)
+{
+	return node? node->prev : NULL;
+}
+
 void
 purple_blist_update_buddy_status(PurpleBuddy *buddy, PurpleStatus *old_status)
 {
============================================================
--- libpurple/blist.h	9a8627da46eb6fe352820cace26ce03fcca01f5c
+++ libpurple/blist.h	4433863091966bac35d3c530d2f7105a553a4764
@@ -53,10 +53,10 @@ typedef enum
 
 } PurpleBlistNodeType;
 
-#define PURPLE_BLIST_NODE_IS_CHAT(n)    ((n)->type == PURPLE_BLIST_CHAT_NODE)
-#define PURPLE_BLIST_NODE_IS_BUDDY(n)   ((n)->type == PURPLE_BLIST_BUDDY_NODE)
-#define PURPLE_BLIST_NODE_IS_CONTACT(n) ((n)->type == PURPLE_BLIST_CONTACT_NODE)
-#define PURPLE_BLIST_NODE_IS_GROUP(n)   ((n)->type == PURPLE_BLIST_GROUP_NODE)
+#define PURPLE_BLIST_NODE_IS_CHAT(n)    (purple_blist_node_get_type(n) == PURPLE_BLIST_CHAT_NODE)
+#define PURPLE_BLIST_NODE_IS_BUDDY(n)   (purple_blist_node_get_type(n) == PURPLE_BLIST_BUDDY_NODE)
+#define PURPLE_BLIST_NODE_IS_CONTACT(n) (purple_blist_node_get_type(n) == PURPLE_BLIST_CONTACT_NODE)
+#define PURPLE_BLIST_NODE_IS_GROUP(n)   (purple_blist_node_get_type(n) == PURPLE_BLIST_GROUP_NODE)
 
 #define PURPLE_BUDDY_IS_ONLINE(b) \
 	((b) != NULL && purple_account_is_connected((b)->account) && \
@@ -234,6 +234,7 @@ PurpleBlistNode *purple_blist_get_root(v
  * @see purple_blist_node_get_parent
  * @see purple_blist_node_get_first_child
  * @see purple_blist_node_get_sibling_next
+ * @see purple_blist_node_get_sibling_prev
  */
 PurpleBlistNode *purple_blist_node_next(PurpleBlistNode *node, gboolean offline);
 
@@ -245,6 +246,7 @@ PurpleBlistNode *purple_blist_node_next(
  * @since 2.4.0
  * @see purple_blist_node_get_first_child
  * @see purple_blist_node_get_sibling_next
+ * @see purple_blist_node_get_sibling_prev
  * @see purple_blist_node_next
  */
 PurpleBlistNode *purple_blist_node_get_parent(PurpleBlistNode *node);
@@ -257,6 +259,7 @@ PurpleBlistNode *purple_blist_node_get_p
  * @since 2.4.0
  * @see purple_blist_node_get_parent
  * @see purple_blist_node_get_sibling_next
+ * @see purple_blist_node_get_sibling_prev
  * @see purple_blist_node_next
  */
 PurpleBlistNode *purple_blist_node_get_first_child(PurpleBlistNode *node);
@@ -269,11 +272,25 @@ PurpleBlistNode *purple_blist_node_get_f
  * @since 2.4.0
  * @see purple_blist_node_get_parent
  * @see purple_blist_node_get_first_child
+ * @see purple_blist_node_get_sibling_prev
  * @see purple_blist_node_next
  */
 PurpleBlistNode *purple_blist_node_get_sibling_next(PurpleBlistNode *node);
 
 /**
+ * Returns the previous sibling node of a given node.
+ *
+ * @param node A node.
+ * @return  The sibling node.
+ * @since 2.4.0
+ * @see purple_blist_node_get_parent
+ * @see purple_blist_node_get_first_child
+ * @see purple_blist_node_get_sibling_next
+ * @see purple_blist_node_next
+ */
+PurpleBlistNode *purple_blist_node_get_sibling_prev(PurpleBlistNode *node);
+
+/**
  * Shows the buddy list, creating a new one if necessary.
  */
 void purple_blist_show(void);


More information about the Commits mailing list