/soc/2013/ankitkv/gobjectification: 2406671e3c44: Buddy list now...
Ankit Vani
a at nevitus.org
Tue Jul 9 12:38:46 EDT 2013
Changeset: 2406671e3c44b5feec0dfd2ae2e9731adc9bf511
Author: Ankit Vani <a at nevitus.org>
Date: 2013-07-09 22:08 +0530
Branch: soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/2406671e3c44
Description:
Buddy list now compiles.
* Removed purple_blist_node_update(), use ui_ops->update()
* Added purple_blist_node_get_settings()
diffstat:
libpurple/blistnodes.c | 21 +++---
libpurple/blistnodes.h | 16 ++--
libpurple/blistnodetypes.c | 58 +++++++++++------
libpurple/buddyicon.c | 7 +-
libpurple/buddylist.c | 139 +++++++++++++++++++++++++++-----------------
5 files changed, 147 insertions(+), 94 deletions(-)
diffs (truncated from 569 to 300 lines):
diff --git a/libpurple/blistnodes.c b/libpurple/blistnodes.c
--- a/libpurple/blistnodes.c
+++ b/libpurple/blistnodes.c
@@ -174,6 +174,16 @@ purple_blist_node_get_dont_save(PurpleBL
return priv->dont_save;
}
+GHashTable *
+purple_blist_node_get_settings(PurpleBListNode *node)
+{
+ PurpleBListNodePrivate *priv = PURPLE_BLIST_NODE_GET_PRIVATE(node);
+
+ g_return_val_if_fail(priv != NULL, NULL);
+
+ return priv->settings;
+}
+
gboolean
purple_blist_node_has_setting(PurpleBListNode* node, const char *key)
{
@@ -325,17 +335,6 @@ purple_blist_node_get_extended_menu(Purp
return menu;
}
-void
-purple_blist_node_update(PurpleBListNode *node)
-{
- PurpleBListUiOps *ops = purple_blist_get_ui_ops();
-
- g_return_if_fail(node != NULL);
-
- if (ops && ops->update)
- ops->update(purple_blist_get_buddy_list(), node);
-}
-
static void
purple_blist_node_setting_free(gpointer data)
{
diff --git a/libpurple/blistnodes.h b/libpurple/blistnodes.h
--- a/libpurple/blistnodes.h
+++ b/libpurple/blistnodes.h
@@ -209,6 +209,15 @@ gpointer purple_blist_node_get_ui_data(c
void purple_blist_node_set_ui_data(PurpleBListNode *node, gpointer ui_data);
/**
+ * Returns a node's settings
+ *
+ * @param node The node to from which to get settings
+ *
+ * @return The hash table with the node's settings
+ */
+GHashTable *purple_blist_node_get_settings(PurpleBListNode *node);
+
+/**
* Checks whether a named setting exists for a node in the buddy list
*
* @param node The node to check from which to check settings
@@ -312,13 +321,6 @@ gboolean purple_blist_node_get_dont_save
*/
GList *purple_blist_node_get_extended_menu(PurpleBListNode *n);
-/**
- * Updates a node's UI, such as when its custom icon has been changed.
- *
- * @param node The PurpleBListNode that is to be updated.
- */
-void purple_blist_node_update(PurpleBListNode *node);
-
/*@}*/
/**************************************************************************/
diff --git a/libpurple/blistnodetypes.c b/libpurple/blistnodetypes.c
--- a/libpurple/blistnodetypes.c
+++ b/libpurple/blistnodetypes.c
@@ -146,6 +146,7 @@ PurpleBListNode *purple_blist_get_last_c
void
purple_buddy_set_icon(PurpleBuddy *buddy, PurpleBuddyIcon *icon)
{
+ PurpleBListUiOps *ops = purple_blist_get_ui_ops();
PurpleBuddyPrivate *priv = PURPLE_BUDDY_GET_PRIVATE(buddy);
g_return_if_fail(priv != NULL);
@@ -158,7 +159,8 @@ purple_buddy_set_icon(PurpleBuddy *buddy
purple_signal_emit(purple_blist_get_handle(), "buddy-icon-changed", buddy);
- purple_blist_node_update(PURPLE_BLIST_NODE(buddy));
+ if (ops && ops->update)
+ ops->update(purple_blist_get_buddy_list(), PURPLE_BLIST_NODE(buddy));
}
PurpleBuddyIcon *
@@ -194,10 +196,12 @@ purple_buddy_set_name(PurpleBuddy *buddy
g_free(priv->name);
priv->name = purple_utf8_strip_unprintables(name);
- if (ops && ops->save_node)
- ops->save_node(PURPLE_BLIST_NODE(buddy));
-
- purple_blist_node_update(PURPLE_BLIST_NODE(buddy));
+ if (ops) {
+ if (ops->save_node)
+ ops->save_node(PURPLE_BLIST_NODE(buddy));
+ if (ops->update)
+ ops->update(purple_blist_get_buddy_list(), PURPLE_BLIST_NODE(buddy));
+ }
}
const char *
@@ -322,7 +326,8 @@ purple_buddy_set_local_alias(PurpleBuddy
if (ops && ops->save_node)
ops->save_node(PURPLE_BLIST_NODE(buddy));
- purple_blist_node_update(PURPLE_BLIST_NODE(buddy));
+ if (ops && ops->update)
+ ops->update(purple_blist_get_buddy_list(), PURPLE_BLIST_NODE(buddy));
im = purple_conversations_find_im_with_account(priv->name,
priv->account);
@@ -371,10 +376,12 @@ purple_buddy_set_server_alias(PurpleBudd
g_free(new_alias); /* could be "\0"; */
}
- if (ops && ops->save_node)
- ops->save_node(PURPLE_BLIST_NODE(buddy));
-
- purple_blist_node_update(PURPLE_BLIST_NODE(buddy));
+ if (ops) {
+ if (ops->save_node)
+ ops->save_node(PURPLE_BLIST_NODE(buddy));
+ if (ops->update)
+ ops->update(purple_blist_get_buddy_list(), PURPLE_BLIST_NODE(buddy));
+ }
im = purple_conversations_find_im_with_account(priv->name,
priv->account);
@@ -421,6 +428,7 @@ purple_buddy_update_status(PurpleBuddy *
PurpleBListNode *cnode;
PurpleContact *contact;
PurpleCountingNode *contact_counter, *group_counter;
+ PurpleBListUiOps *ops = purple_blist_get_ui_ops();
PurpleBuddyPrivate *priv = PURPLE_BUDDY_GET_PRIVATE(buddy);
g_return_if_fail(priv != NULL);
@@ -474,7 +482,9 @@ purple_buddy_update_status(PurpleBuddy *
* certainly won't hurt anything. Unless you're on a K6-2 300.
*/
purple_contact_invalidate_priority_buddy(purple_buddy_get_contact(buddy));
- purple_blist_node_update(PURPLE_BLIST_NODE(buddy));
+
+ if (ops && ops->update)
+ ops->update(purple_blist_get_buddy_list(), PURPLE_BLIST_NODE(buddy));
}
PurpleMediaCaps purple_buddy_get_media_caps(const PurpleBuddy *buddy)
@@ -833,10 +843,12 @@ purple_contact_set_alias(PurpleContact *
g_free(new_alias); /* could be "\0" */
}
- if (ops && ops->save_node)
- ops->save_node(PURPLE_BLIST_NODE(contact));
-
- purple_blist_node_update(PURPLE_BLIST_NODE(contact));
+ if (ops) {
+ if (ops->save_node)
+ ops->save_node(PURPLE_BLIST_NODE(contact));
+ if (ops->update)
+ ops->update(purple_blist_get_buddy_list(), PURPLE_BLIST_NODE(contact));
+ }
for(bnode = PURPLE_BLIST_NODE(contact)->child; bnode != NULL; bnode = bnode->next)
{
@@ -971,10 +983,11 @@ purple_contact_get_property(GObject *obj
GParamSpec *pspec)
{
PurpleContact *contact = PURPLE_CONTACT(obj);
+ PurpleContactPrivate *priv = PURPLE_CONTACT_GET_PRIVATE(contact);
switch (param_id) {
case CONTACT_PROP_ALIAS:
- g_value_set_string(value, purple_contact_get_alias(contact));
+ g_value_set_string(value, priv->alias);
break;
case CONTACT_PROP_PRIORITY_BUDDY:
g_value_set_object(value, purple_contact_get_priority_buddy(contact));
@@ -1136,10 +1149,12 @@ purple_chat_set_alias(PurpleChat *chat,
g_free(new_alias); /* could be "\0" */
}
- if (ops && ops->save_node)
- ops->save_node(PURPLE_BLIST_NODE(chat));
-
- purple_blist_node_update(PURPLE_BLIST_NODE(chat));
+ if (ops) {
+ if (ops->save_node)
+ ops->save_node(PURPLE_BLIST_NODE(chat));
+ if (ops->update)
+ ops->update(purple_blist_get_buddy_list(), PURPLE_BLIST_NODE(chat));
+ }
purple_signal_emit(purple_blist_get_handle(), "blist-node-aliased",
chat, old_alias);
@@ -1472,7 +1487,8 @@ void purple_group_set_name(PurpleGroup *
ops->save_node(PURPLE_BLIST_NODE(source));
/* Update the UI */
- purple_blist_node_update(PURPLE_BLIST_NODE(source));
+ if (ops && ops->update)
+ ops->update(purple_blist_get_buddy_list(), PURPLE_BLIST_NODE(source));
/* Notify all PRPLs */
/* TODO: Is this condition needed? Seems like it would always be TRUE */
diff --git a/libpurple/buddyicon.c b/libpurple/buddyicon.c
--- a/libpurple/buddyicon.c
+++ b/libpurple/buddyicon.c
@@ -838,6 +838,7 @@ purple_buddy_icons_node_set_custom_icon(
char *old_icon;
PurpleStoredImage *old_img;
PurpleStoredImage *img = NULL;
+ PurpleBListUiOps *ops = purple_blist_get_ui_ops();
g_return_val_if_fail(node != NULL, NULL);
@@ -891,7 +892,8 @@ purple_buddy_icons_node_set_custom_icon(
/* Is this call necessary anymore? Can the buddies
* themselves need updating when the custom buddy
* icon changes? */
- purple_blist_node_update((PurpleBListNode*)buddy);
+ if (ops && ops->update)
+ ops->update(purple_blist_get_buddy_list(), PURPLE_BLIST_NODE(buddy));
}
} else if (PURPLE_IS_CHAT(node)) {
PurpleChatConversation *chat = NULL;
@@ -902,7 +904,8 @@ purple_buddy_icons_node_set_custom_icon(
}
}
- purple_blist_node_update(node);
+ if (ops && ops->update)
+ ops->update(purple_blist_get_buddy_list(), node);
if (old_img) {
purple_imgstore_unref(old_img);
diff --git a/libpurple/buddylist.c b/libpurple/buddylist.c
--- a/libpurple/buddylist.c
+++ b/libpurple/buddylist.c
@@ -55,6 +55,8 @@ static GHashTable *groups_cache = NULL;
static guint save_timer = 0;
static gboolean blist_loaded = FALSE;
+PurpleBListNode *purple_blist_get_last_child(PurpleBListNode *node);
+
/*********************************************************************
* Private utility functions *
*********************************************************************/
@@ -122,7 +124,6 @@ purple_blist_buddies_cache_remove_accoun
g_hash_table_remove(buddies_cache, account);
}
-
/*********************************************************************
* Writing to disk *
*********************************************************************/
@@ -182,19 +183,20 @@ static xmlnode *
buddy_to_xmlnode(PurpleBuddy *buddy)
{
xmlnode *node, *child;
- PurpleBuddyPrivate *priv = PURPLE_BUDDY_GET_PRIVATE(buddy);
+ PurpleAccount *account = purple_buddy_get_account(buddy);
+ const char *alias = purple_buddy_get_local_alias(buddy);
node = xmlnode_new("buddy");
- xmlnode_set_attrib(node, "account", purple_account_get_username(buddy->account));
- xmlnode_set_attrib(node, "proto", purple_account_get_protocol_id(buddy->account));
+ xmlnode_set_attrib(node, "account", purple_account_get_username(account));
+ xmlnode_set_attrib(node, "proto", purple_account_get_protocol_id(account));
child = xmlnode_new_child(node, "name");
- xmlnode_insert_data(child, priv->name, -1);
+ xmlnode_insert_data(child, purple_buddy_get_name(buddy), -1);
- if (priv->alias != NULL)
+ if (alias != NULL)
{
child = xmlnode_new_child(node, "alias");
- xmlnode_insert_data(child, priv->alias, -1);
+ xmlnode_insert_data(child, alias, -1);
}
/* Write buddy settings */
@@ -209,23 +211,24 @@ contact_to_xmlnode(PurpleContact *contac
{
xmlnode *node, *child;
PurpleBListNode *bnode;
- PurpleContactPrivate *priv = PURPLE_CONTACT_GET_PRIVATE(contact);
+ gchar *alias;
node = xmlnode_new("contact");
+ g_object_get(contact, "alias", &alias, NULL);
More information about the Commits
mailing list