Mercurial > pidgin.yaz
diff libpurple/account.c @ 29499:94f85ba7e5a9
This effectively moves Etan's API addition off im.pidgin.pidgin and onto
im.pidgin.pidgin.next.minor so we don't force a 2.7.0 too soon.
*** Plucked rev f7d26d95395d5013710b12cfdfcf131aa1033e0c (deryni@pidgin.im):
Add a purple_account_get_name_for_display function (I'm not a huge fan of that
name but didn't want to use get_display_name as that means something else for
connections).
This wants to be used in places where we need to display an identifier for the
account to the user and honor the appropriate aliases/etc.
Refs #8391
author | John Bailey <rekkanoryo@rekkanoryo.org> |
---|---|
date | Wed, 16 Sep 2009 15:44:26 +0000 |
parents | 3896cbf6336a |
children | 339cb6c7f0fd |
line wrap: on
line diff
--- a/libpurple/account.c Thu Sep 10 21:51:32 2009 +0000 +++ b/libpurple/account.c Wed Sep 16 15:44:26 2009 +0000 @@ -2019,6 +2019,42 @@ return account->gc; } +const gchar * +purple_account_get_name_for_display(const PurpleAccount *account) +{ + PurpleBuddy *self = NULL; + PurpleConnection *gc = NULL; + const gchar *name = NULL, *username = NULL, *displayname = NULL; + + name = purple_account_get_alias(account); + + if (name) { + return name; + } + + username = purple_account_get_username(account); + self = purple_find_buddy((PurpleAccount *)account, username); + + if (self) { + const gchar *calias= purple_buddy_get_contact_alias(self); + + /* We don't want to return the buddy name if the buddy/contact + * doesn't have an alias set. */ + if (!purple_strequal(username, calias)) { + return calias; + } + } + + gc = purple_account_get_connection(account); + displayname = purple_connection_get_display_name(gc); + + if (displayname) { + return displayname; + } + + return username; +} + gboolean purple_account_get_remember_password(const PurpleAccount *account) {