pidgin.next.minor: 6aa03fde: This effectively moves Etan's API additi...

rekkanoryo at pidgin.im rekkanoryo at pidgin.im
Wed Sep 16 12:01:43 EDT 2009


-----------------------------------------------------------------
Revision: 6aa03fdea8a7360d07b6a8c72cfd0796a2990753
Ancestor: 91d04fec37b328ffc2e552ea14a5a520d27161f2
Author: rekkanoryo at pidgin.im
Date: 2009-09-16T15:44:26
Branch: im.pidgin.pidgin.next.minor
URL: http://d.pidgin.im/viewmtn/revision/info/6aa03fdea8a7360d07b6a8c72cfd0796a2990753

Modified files:
        ChangeLog.API libpurple/account.c libpurple/account.h

ChangeLog: 

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 at 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


-------------- next part --------------
============================================================
--- ChangeLog.API	21d058413be3a081ed5824f03180a72fe6493bfe
+++ ChangeLog.API	c644911393a049f0f582b8ad10df196460049aad
@@ -3,6 +3,7 @@ version 2.7.0 (??/??/????):
 version 2.7.0 (??/??/????):
 	libpurple:
 		Added:
+		* purple_account_get_name_for_display
 		* purple_network_get_all_local_system_ips
 
 version 2.6.1 (08/18/2009):
============================================================
--- libpurple/account.c	82931533b8174bb99ab4d62337d1072bf3af2d8c
+++ libpurple/account.c	50856a9735c7db9bb2524301648dd520654e6dee
@@ -2019,6 +2019,42 @@ purple_account_get_connection(const Purp
 	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)
 {
============================================================
--- libpurple/account.h	ea27697ac2f242986507da6d4844daf5af06dbc2
+++ libpurple/account.h	c9d99fc93e46a046438ffed828a5033f02923fbd
@@ -630,6 +630,20 @@ PurpleConnection *purple_account_get_con
 PurpleConnection *purple_account_get_connection(const PurpleAccount *account);
 
 /**
+ * Returns a name for this account appropriate for display to the user. In
+ * order of preference: the account's alias; the contact or buddy alias (if
+ * the account exists on its own buddy list); the connection's display name;
+ * the account's username.
+ *
+ * @param account The account.
+ *
+ * @return The name to display.
+ *
+ * @since 2.7.0
+ */
+const gchar *purple_account_get_name_for_display(const PurpleAccount *account);
+
+/**
  * Returns whether or not this account should save its password.
  *
  * @param account The account.


More information about the Commits mailing list