gobjectification: 789e8123: Fixed get_group helpers
aluink at soc.pidgin.im
aluink at soc.pidgin.im
Wed Jul 22 21:31:35 EDT 2009
-----------------------------------------------------------------
Revision: 789e8123cdafd71375bacb95d6e230027be32a9f
Ancestor: f67139a02e2b83a8fcaa0bc4a367fc89303daadf
Author: aluink at soc.pidgin.im
Date: 2009-07-23T01:26:06
Branch: im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/789e8123cdafd71375bacb95d6e230027be32a9f
Modified files:
libpurple/blist-node.c libpurple/blist-node.h
libpurple/blist.c libpurple/buddy.c libpurple/buddy.h
libpurple/chat.c libpurple/chat.h libpurple/group.c
libpurple/group.h
ChangeLog:
Fixed get_group helpers
-------------- next part --------------
============================================================
--- libpurple/blist-node.c 3a576af25217e09b66210c057caf55fb3894db67
+++ libpurple/blist-node.c 0edde9e80ddeabb5ea8494350d910cd6429d3fb9
@@ -416,6 +416,19 @@ purple_blist_node_contains(PurpleBlistNo
return node->parent == parent;
}
+PurpleBlistNode *
+purple_blist_node_find_container(PurpleBlistNode *node, GType type)
+{
+ PurpleBlistNode *parent;
+
+ g_return_val_if_fail(node, NULL);
+
+ parent = purple_blist_node_parent(node);
+ while(parent && !G_TYPE_CHECK_INSTANCE_TYPE(parent,type))
+ parent = purple_blist_node_parent(parent);
+ return parent;
+}
+
static void
purple_blist_node_real_add_child(PurpleBlistNode *parent, PurpleBlistNode *child)
{
============================================================
--- libpurple/blist-node.h 251d3842c905b054d6d9353fb448494727663832
+++ libpurple/blist-node.h 7c551a3b5950a1ec22cf358e449afa236cd39d72
@@ -59,7 +59,6 @@ typedef struct _PurpleBlistNodeClass Pur
#define PURPLE_GET_BLIST_NODE_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PURPLE_BLIST_NODE_TYPE, PurpleBlistNodeClass))
#define PURPLE_BLIST_NODE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), PURPLE_BLIST_NODE_TYPE, PurpleBlistNodePrivate))
-
/**
* A Buddy list node. This can represent a group, a buddy, or anything else.
* This is a base class for PurpleBuddy, PurpleContact, PurpleGroup, and for
@@ -333,6 +332,14 @@ PurpleBlistNodeFlags purple_blist_node_g
*/
PurpleBlistNodeFlags purple_blist_node_get_flags(PurpleBlistNode *node);
+/**
+ * Get the container of a given type for this node.
+ *
+ * @param node The node to find a container for
+ * @param type The type of container we are looking for
+ * @return the container if one is found, else NULL
+ */
+PurpleBlistNode *purple_blist_node_find_container(PurpleBlistNode *node, GType type);
/*@}*/
/**
============================================================
--- libpurple/blist.c 822fa8d3b66245ddf4ee707b5d6d48fdcc35d13a
+++ libpurple/blist.c 5e7091faa2c0bbd532f4313ac3b3ff2aea4f4c72
@@ -1495,14 +1495,6 @@ PurpleBuddy *purple_find_buddy_in_group(
return ret;
}
-PurpleGroup *
-purple_chat_get_group(PurpleChat *chat)
-{
- g_return_val_if_fail(chat != NULL, NULL);
-
- return PURPLE_GROUP(((PURPLE_BLIST_NODE(chat))->parent));
-}
-
static void
append_buddy(gpointer key, gpointer value, gpointer user_data)
{
============================================================
--- libpurple/buddy.c 56414ab0aa4e252ce19cf15ae78dc1a4c1c12cc5
+++ libpurple/buddy.c 7a2332c028f381431037b1c5dcfd88f4ce7a092e
@@ -531,6 +531,15 @@ purple_buddy_finalize(GObject *object)
parent_class->finalize(object);
}
+PurpleGroup *
+purple_buddy_get_group(PurpleBuddy *buddy)
+{
+ g_return_val_if_fail(buddy != NULL, NULL);
+
+ return PURPLE_GROUP(purple_blist_node_find_container(PURPLE_BLIST_NODE(buddy), PURPLE_GROUP_TYPE));
+
+}
+
static void
purple_buddy_set_property(GObject *obj, guint param_id, const GValue *value,
GParamSpec *pspec)
============================================================
--- libpurple/buddy.h e84e6d4d75d85d6466cd6f0c29ad42ae86a209a2
+++ libpurple/buddy.h cf28a3312c8746fbb70e281e3bb9e638ab0fdb1c
@@ -36,6 +36,7 @@ typedef struct _PurpleBuddyClass PurpleB
#include "buddyicon.h"
#include "status.h"
+#include "group.h"
#define PURPLE_BUDDY_TYPE (purple_buddy_get_type ())
#define PURPLE_BUDDY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PURPLE_BUDDY_TYPE, PurpleBuddy))
@@ -115,6 +116,14 @@ const char *purple_buddy_get_local_buddy
const char *purple_buddy_get_local_buddy_alias(PurpleBuddy *buddy);
/**
+ * Returns the group of which the buddy is a member.
+ *
+ * @param buddy The buddy
+ * @return The group or NULL if the buddy is not in a group
+ */
+PurpleGroup *purple_buddy_get_group(PurpleBuddy *buddy);
+
+/**
* Returns a buddy's account.
*
* @param buddy The buddy.
============================================================
--- libpurple/chat.c eb0b91d585f041dcbe0bf0482f8f967c8b08b668
+++ libpurple/chat.c abc184e30ae5a2b321af37c0213e5836fb7571cd
@@ -339,6 +339,14 @@ purple_chat_class_init(PurpleChatClass *
);
}
+PurpleGroup *
+purple_chat_get_group(PurpleChat *chat)
+{
+ g_return_val_if_fail(chat != NULL, NULL);
+
+ return PURPLE_GROUP(purple_blist_node_find_container(PURPLE_BLIST_NODE(chat), PURPLE_GROUP_TYPE));
+}
+
static void
purple_chat_init(GTypeInstance *instance, gpointer class)
{
============================================================
--- libpurple/chat.h 1eae39ee9c5c181ec9566cf71db75df3498ed853
+++ libpurple/chat.h e199901f0b0b69575d240498d2365644445d7df4
@@ -118,6 +118,15 @@ void purple_chat_set_alias(PurpleChat *c
void purple_chat_set_alias(PurpleChat *chat, const char *alias);
/**
+ * Returns the group of which the chat is a member.
+ *
+ * @param chat The chat.
+ *
+ * @return The parent group, or @c NULL if the chat is not in a group.
+*/
+PurpleGroup *purple_chat_get_group(PurpleChat *chat);
+
+/**
* Get the GType for PurpleChat
*/
GType purple_chat_get_type(void);
============================================================
--- libpurple/group.c 8b2cc9f79fcba27d4d09b87de649c8351dc72836
+++ libpurple/group.c eec07841c4f6965cde85db0f1b4edeca99cbc818
@@ -128,16 +128,6 @@ purple_group_remove_node(PurpleBlistNode
g_object_unref(G_OBJECT(child));
}
-PurpleGroup *purple_buddy_get_group(PurpleBuddy *buddy)
-{
- g_return_val_if_fail(buddy != NULL, NULL);
-
- if ((PURPLE_BLIST_NODE(buddy))->parent == NULL)
- return NULL;
-
- return PURPLE_GROUP(PURPLE_BLIST_NODE(buddy)->parent->parent);
-}
-
void
purple_group_destroy(PurpleGroup *group)
{
============================================================
--- libpurple/group.h 9e7f4f457edcf2509eedc8edfc0dcae558665e25
+++ libpurple/group.h b27a1d09dead92ca0dbdcfc1e8e99fc8af5668e6
@@ -81,14 +81,6 @@ void purple_group_destroy(PurpleGroup *g
void purple_group_destroy(PurpleGroup *group);
/**
- * Returns the group of which the buddy is a member.
- *
- * @param buddy The buddy
- * @return The group or NULL if the buddy is not in a group
- */
-PurpleGroup *purple_buddy_get_group(PurpleBuddy *buddy);
-
-/**
* Returns a list of accounts that have buddies in this group
*
* @param g The group
@@ -127,15 +119,6 @@ int purple_blist_get_group_size(PurpleGr
int purple_blist_get_group_size(PurpleGroup *group, gboolean offline);
/**
- * Returns the group of which the chat is a member.
- *
- * @param chat The chat.
- *
- * @return The parent group, or @c NULL if the chat is not in a group.
- */
-PurpleGroup *purple_chat_get_group(PurpleChat *chat);
-
-/**
* Determines the number of online buddies in a group
*
* @param group The group
More information about the Commits
mailing list