OSDN Git Service

RAD-260: [patch] Extend NameManager with methods to retrieve UserName and DisplayName
authorLatif Khalifa <latifer@streamgrid.net>
Mon, 16 May 2011 13:07:40 +0000 (13:07 +0000)
committerLatif Khalifa <latifer@streamgrid.net>
Mon, 16 May 2011 13:07:40 +0000 (13:07 +0000)
Patch by Tim Hart

git-svn-id: https://radegast.googlecode.com/svn/trunk@860 f7a694da-4d33-11de-9ad6-1127a62b9fcd

Radegast/Core/NameManager.cs

index 2492bf8..54bb735 100644 (file)
@@ -418,6 +418,48 @@ namespace Radegast
         }
 
         /// <summary>
+        /// Gets UserName
+        /// </summary>
+        /// <param name="agentID">UUID of the agent</param>
+        /// <returns></returns>
+        public string GetUserName(UUID agentID)
+        {
+            if (agentID == UUID.Zero) return "(???) (???)";
+
+            lock (names)
+            {
+                if (names.ContainsKey(agentID))
+                {
+                    return names[agentID].UserName;
+                }
+            }
+
+            QueueNameRequest(agentID);
+            return RadegastInstance.INCOMPLETE_NAME;
+        }
+
+        /// <summary>
+        /// Gets DisplayName
+        /// </summary>
+        /// <param name="agentID">UUID of the agent</param>
+        /// <returns></returns>
+        public string GetDisplayName(UUID agentID)
+        {
+            if (agentID == UUID.Zero) return "(???) (???)";
+
+            lock (names)
+            {
+                if (names.ContainsKey(agentID))
+                {
+                    return names[agentID].DisplayName;
+                }
+            }
+
+            QueueNameRequest(agentID);
+            return RadegastInstance.INCOMPLETE_NAME;
+        }
+
+        /// <summary>
         /// Get avatar display name, or queue fetching of the name
         /// </summary>
         /// <param name="agentID">UUID of avatar to lookup</param>