Mercurial > pidgin.yaz
changeset 24256:0d0088b03745
Hide the blistnode, buddy, contact, group, and chat structs
Updated the libpurple plugins to use api rather than the structs directly
author | Gary Kramlich <grim@reaperworld.com> |
---|---|
date | Tue, 28 Oct 2008 04:22:57 +0000 |
parents | 4490b3002b89 |
children | 848542528965 882a1c4c11b4 |
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 |
diffstat | 6 files changed, 173 insertions(+), 58 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/blist.c Tue Oct 28 03:05:32 2008 +0000 +++ b/libpurple/blist.c Tue Oct 28 04:22:57 2008 +0000 @@ -42,6 +42,59 @@ 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 * *********************************************************************/
--- a/libpurple/blist.h Tue Oct 28 03:05:32 2008 +0000 +++ b/libpurple/blist.h Tue Oct 28 04:22:57 2008 +0000 @@ -89,6 +89,8 @@ /* 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,6 +156,8 @@ PurpleAccount *account; /**< The account this chat is attached to */ }; +#endif /* PURPLE_HIDE_STRUCTS */ + /** * The Buddy List
--- a/libpurple/plugins/autoaccept.c Tue Oct 28 03:05:32 2008 +0000 +++ b/libpurple/plugins/autoaccept.c Tue Oct 28 04:22:57 2008 +0000 @@ -104,7 +104,7 @@ 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 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 @@ 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"),
--- a/libpurple/plugins/log_reader.c Tue Oct 28 03:05:32 2008 +0000 +++ b/libpurple/plugins/log_reader.c Tue Oct 28 04:22:57 2008 +0000 @@ -661,8 +661,10 @@ 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 @@ * 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 @@ 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 @@ } 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 @@ } } 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 @@ */ 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 @@ g_string_append(formatted, "</b>"); footer = NULL; } else if (strstr(line, " signed off ")) { - if (buddy != NULL && buddy->alias) - g_string_append_printf(formatted, - _("%s has signed off."), buddy->alias); - else + 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."), 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 @@ 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 @@ 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;
--- a/libpurple/plugins/signals-test.c Tue Oct 28 03:05:32 2008 +0000 +++ b/libpurple/plugins/signals-test.c Tue Oct 28 04:22:57 2008 +0000 @@ -116,8 +116,9 @@ 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 @@ 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 @@ 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 @@ 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)); + } }
--- a/libpurple/plugins/statenotify.c Tue Oct 28 03:05:32 2008 +0000 +++ b/libpurple/plugins/statenotify.c Tue Oct 28 04:22:57 2008 +0000 @@ -15,13 +15,18 @@ 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;