[liboobs] Add oobs_user_get_full_name_fallback()



commit 8f93c70bc15e382846763dfc321b492a7d5e9af6
Author: Milan Bouchet-Valat <nalimilan club fr>
Date:   Sun Aug 22 15:05:25 2010 +0200

    Add oobs_user_get_full_name_fallback()
    
    Convenience function for place where GUIs don't want to show
    the real name, but rather some use identifier. If real name
    is missing, using login is the best solution in most places.

 oobs/oobs-user.c |   26 ++++++++++++++++++++++++++
 oobs/oobs-user.h |    1 +
 2 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/oobs/oobs-user.c b/oobs/oobs-user.c
index 9de6406..e94f11b 100644
--- a/oobs/oobs-user.c
+++ b/oobs/oobs-user.c
@@ -903,6 +903,32 @@ oobs_user_get_full_name (OobsUser *user)
 }
 
 /**
+ * oobs_user_get_full_name_fallback:
+ * @user: An #OobsUser.
+ * 
+ * Returns the first GECOS field, usually the full name of the user,
+ * or the login name if the field is empty.
+ * 
+ * Return Value: A pointer to the full name or login name as a string.
+ *               This string must not be freed, modified or stored.
+ **/
+G_CONST_RETURN gchar*
+oobs_user_get_full_name_fallback (OobsUser *user)
+{
+  OobsUserPrivate *priv;
+
+  g_return_val_if_fail (user != NULL, NULL);
+  g_return_val_if_fail (OOBS_IS_USER (user), NULL);
+
+  priv = user->_priv;
+
+  if (priv->full_name && *priv->full_name != '\0')
+    return priv->full_name;
+  else
+    return priv->username;
+}
+
+/**
  * oobs_user_set_full_name:
  * @user: An #OobsUser.
  * @full_name: new full name for the user.
diff --git a/oobs/oobs-user.h b/oobs/oobs-user.h
index 19c3dcb..5197292 100644
--- a/oobs/oobs-user.h
+++ b/oobs/oobs-user.h
@@ -98,6 +98,7 @@ G_CONST_RETURN gchar* oobs_user_get_shell (OobsUser *user);
 void oobs_user_set_shell (OobsUser *user, const gchar *shell);
 
 G_CONST_RETURN gchar* oobs_user_get_full_name (OobsUser *user);
+G_CONST_RETURN gchar* oobs_user_get_full_name_fallback (OobsUser *user);
 void oobs_user_set_full_name (OobsUser *user, const gchar *full_name);
 
 G_CONST_RETURN gchar* oobs_user_get_room_number (OobsUser *user);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]