aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Util.cs
diff options
context:
space:
mode:
authorDiva Canto2012-03-20 17:19:14 -0700
committerDiva Canto2012-03-20 17:19:14 -0700
commit3fa51f66ec2f032134f333bf1fa047275a77f6e0 (patch)
tree952df67fcc209ecc81ce66b92f4bdf93a7017e08 /OpenSim/Framework/Util.cs
parentHG Friends: allow the establishment of HG friendships without requiring co-pr... (diff)
parentAdd ability to log warn if a frame takes longer than twice the expected time.... (diff)
downloadopensim-SC_OLD-3fa51f66ec2f032134f333bf1fa047275a77f6e0.zip
opensim-SC_OLD-3fa51f66ec2f032134f333bf1fa047275a77f6e0.tar.gz
opensim-SC_OLD-3fa51f66ec2f032134f333bf1fa047275a77f6e0.tar.bz2
opensim-SC_OLD-3fa51f66ec2f032134f333bf1fa047275a77f6e0.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Conflicts: OpenSim/Framework/Util.cs
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r--OpenSim/Framework/Util.cs150
1 files changed, 89 insertions, 61 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 0b9e0e7..26b7070 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -1758,13 +1758,26 @@ namespace OpenSim.Framework
1758 /// and negative every 24.9 days. Subtracts the passed value (previously fetched by 1758 /// and negative every 24.9 days. Subtracts the passed value (previously fetched by
1759 /// 'EnvironmentTickCount()') and accounts for any wrapping. 1759 /// 'EnvironmentTickCount()') and accounts for any wrapping.
1760 /// </summary> 1760 /// </summary>
1761 /// <param name="newValue"></param>
1762 /// <param name="prevValue"></param>
1761 /// <returns>subtraction of passed prevValue from current Environment.TickCount</returns> 1763 /// <returns>subtraction of passed prevValue from current Environment.TickCount</returns>
1762 public static Int32 EnvironmentTickCountSubtract(Int32 prevValue) 1764 public static Int32 EnvironmentTickCountSubtract(Int32 newValue, Int32 prevValue)
1763 { 1765 {
1764 Int32 diff = EnvironmentTickCount() - prevValue; 1766 Int32 diff = newValue - prevValue;
1765 return (diff >= 0) ? diff : (diff + EnvironmentTickCountMask + 1); 1767 return (diff >= 0) ? diff : (diff + EnvironmentTickCountMask + 1);
1766 } 1768 }
1767 1769
1770 /// <summary>
1771 /// Environment.TickCount is an int but it counts all 32 bits so it goes positive
1772 /// and negative every 24.9 days. Subtracts the passed value (previously fetched by
1773 /// 'EnvironmentTickCount()') and accounts for any wrapping.
1774 /// </summary>
1775 /// <returns>subtraction of passed prevValue from current Environment.TickCount</returns>
1776 public static Int32 EnvironmentTickCountSubtract(Int32 prevValue)
1777 {
1778 return EnvironmentTickCountSubtract(EnvironmentTickCount(), prevValue);
1779 }
1780
1768 // Returns value of Tick Count A - TickCount B accounting for wrapping of TickCount 1781 // Returns value of Tick Count A - TickCount B accounting for wrapping of TickCount
1769 // Assumes both tcA and tcB came from previous calls to Util.EnvironmentTickCount(). 1782 // Assumes both tcA and tcB came from previous calls to Util.EnvironmentTickCount().
1770 // A positive return value indicates A occured later than B 1783 // A positive return value indicates A occured later than B
@@ -1927,12 +1940,12 @@ namespace OpenSim.Framework
1927 #region Universal User Identifiers 1940 #region Universal User Identifiers
1928 /// <summary> 1941 /// <summary>
1929 /// </summary> 1942 /// </summary>
1930 /// <param name="value">uuid[;endpoint[;first last[;secret]]]</param> 1943 /// <param name="value">uuid[;endpoint[;first last[;secret]]]</param>
1931 /// <param name="uuid">the uuid part</param> 1944 /// <param name="uuid">the uuid part</param>
1932 /// <param name="url">the endpoint part (e.g. http://foo.com)</param> 1945 /// <param name="url">the endpoint part (e.g. http://foo.com)</param>
1933 /// <param name="firstname">the first name part (e.g. Test)</param> 1946 /// <param name="firstname">the first name part (e.g. Test)</param>
1934 /// <param name="lastname">the last name part (e.g User)</param> 1947 /// <param name="lastname">the last name part (e.g User)</param>
1935 /// <param name="secret">the secret part</param> 1948 /// <param name="secret">the secret part</param>
1936 public static bool ParseUniversalUserIdentifier(string value, out UUID uuid, out string url, out string firstname, out string lastname, out string secret) 1949 public static bool ParseUniversalUserIdentifier(string value, out UUID uuid, out string url, out string firstname, out string lastname, out string secret)
1937 { 1950 {
1938 uuid = UUID.Zero; url = string.Empty; firstname = "Unknown"; lastname = "User"; secret = string.Empty; 1951 uuid = UUID.Zero; url = string.Empty; firstname = "Unknown"; lastname = "User"; secret = string.Empty;
@@ -1961,64 +1974,79 @@ namespace OpenSim.Framework
1961 } 1974 }
1962 1975
1963 /// <summary> 1976 /// <summary>
1964 /// Produces a universal (HG) system-facing identifier given the information 1977 /// Produces a universal (HG) system-facing identifier given the information
1965 /// </summary> 1978 /// </summary>
1966 /// <param name="acircuit"></param> 1979 /// <param name="acircuit"></param>
1967 /// <returns>uuid[;homeURI[;first last]]</returns> 1980 /// <returns>uuid[;homeURI[;first last]]</returns>
1968 public static string ProduceUserUniversalIdentifier(AgentCircuitData acircuit) 1981 public static string ProduceUserUniversalIdentifier(AgentCircuitData acircuit)
1969 { 1982 {
1970 if (acircuit.ServiceURLs.ContainsKey("HomeURI")) 1983 if (acircuit.ServiceURLs.ContainsKey("HomeURI"))
1971 return UniversalIdentifier(acircuit.AgentID, acircuit.firstname, acircuit.lastname, acircuit.ServiceURLs["HomeURI"].ToString()); 1984 return UniversalIdentifier(acircuit.AgentID, acircuit.firstname, acircuit.lastname, acircuit.ServiceURLs["HomeURI"].ToString());
1972 else 1985 else
1973 return acircuit.AgentID.ToString(); 1986 return acircuit.AgentID.ToString();
1974 } 1987 }
1975 1988
1976 /// <summary> 1989 /// <summary>
1977 /// Produces a universal (HG) system-facing identifier given the information 1990 /// Produces a universal (HG) system-facing identifier given the information
1978 /// </summary> 1991 /// </summary>
1979 /// <param name="id">UUID of the user</param> 1992 /// <param name="id">UUID of the user</param>
1980 /// <param name="firstName">first name (e.g Test)</param> 1993 /// <param name="firstName">first name (e.g Test)</param>
1981 /// <param name="lastName">last name (e.g. User)</param> 1994 /// <param name="lastName">last name (e.g. User)</param>
1982 /// <param name="homeURI">homeURI (e.g. http://foo.com)</param> 1995 /// <param name="homeURI">homeURI (e.g. http://foo.com)</param>
1983 /// <returns>a string of the form uuid[;homeURI[;first last]]</returns> 1996 /// <returns>a string of the form uuid[;homeURI[;first last]]</returns>
1984 public static string UniversalIdentifier(UUID id, String firstName, String lastName, String homeURI) 1997 public static string UniversalIdentifier(UUID id, String firstName, String lastName, String homeURI)
1985 { 1998 {
1986 string agentsURI = homeURI; 1999 string agentsURI = homeURI;
1987 if (!agentsURI.EndsWith("/")) 2000 if (!agentsURI.EndsWith("/"))
1988 agentsURI += "/"; 2001 agentsURI += "/";
1989 2002
1990 // This is ugly, but there's no other way, given that the name is changed 2003 // This is ugly, but there's no other way, given that the name is changed
1991 // in the agent circuit data for foreigners 2004 // in the agent circuit data for foreigners
1992 if (lastName.Contains("@")) 2005 if (lastName.Contains("@"))
1993 { 2006 {
1994 string[] parts = firstName.Split(new char[] { '.' }); 2007 string agentsURI = acircuit.ServiceURLs["HomeURI"].ToString();
1995 if (parts.Length == 2) 2008 if (!agentsURI.EndsWith("/"))
1996 return id.ToString() + ";" + agentsURI + ";" + parts[0] + " " + parts[1]; 2009 agentsURI += "/";
1997 } 2010 string[] parts = firstName.Split(new char[] { '.' });
1998 return id.ToString() + ";" + agentsURI + ";" + firstName + " " + lastName; 2011 if (parts.Length == 2)
1999 2012 return id.ToString() + ";" + agentsURI + ";" + parts[0] + " " + parts[1];
2000 } 2013 }
2001 2014 return id.ToString() + ";" + agentsURI + ";" + firstName + " " + lastName;
2002 /// <summary> 2015
2003 /// Produces a universal (HG) user-facing name given the information 2016 }
2004 /// </summary> 2017
2005 /// <param name="firstName"></param> 2018 // This is ugly, but there's no other way, given that the name is changed
2006 /// <param name="lastName"></param> 2019 // in the agent circuit data for foreigners
2007 /// <param name="homeURI"></param> 2020 if (acircuit.lastname.Contains("@"))
2008 /// <returns>string of the form first.last @foo.com or first last</returns> 2021 {
2009 public static string UniversalName(String firstName, String lastName, String homeURI) 2022 string[] parts = acircuit.firstname.Split(new char[] { '.' });
2010 { 2023 if (parts.Length == 2)
2011 Uri uri = null; 2024 return acircuit.AgentID.ToString() + ";" + agentsURI + ";" + parts[0] + " " + parts[1];
2012 try 2025 }
2013 { 2026 return acircuit.AgentID.ToString() + ";" + agentsURI + ";" + acircuit.firstname + " " + acircuit.lastname;
2014 uri = new Uri(homeURI); 2027 /// <summary>
2015 } 2028 /// Produces a universal (HG) user-facing name given the information
2016 catch (UriFormatException) 2029 /// </summary>
2017 { 2030 /// <param name="firstName"></param>
2018 return firstName + " " + lastName; 2031 /// <param name="lastName"></param>
2019 } 2032 /// <param name="homeURI"></param>
2020 return firstName + "." + lastName + " " + "@" + uri.Authority; 2033 /// <returns>string of the form first.last @foo.com or first last</returns>
2021 } 2034 public static string UniversalName(String firstName, String lastName, String homeURI)
2035 {
2036 Uri uri = null;
2037 try
2038 {
2039 uri = new Uri(homeURI);
2040 }
2041 else
2042 return acircuit.AgentID.ToString();
2043 }
2044 catch (UriFormatException)
2045 {
2046 return firstName + " " + lastName;
2047 }
2048 return firstName + "." + lastName + " " + "@" + uri.Authority;
2049 }
2022 #endregion 2050 #endregion
2023 } 2051 }
2024} 2052}