diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Framework/Util.cs | 178 |
1 files changed, 89 insertions, 89 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 26b7070..ea1de80 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -1758,26 +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> | 1761 | /// <param name="newValue"></param> |
1762 | /// <param name="prevValue"></param> | 1762 | /// <param name="prevValue"></param> |
1763 | /// <returns>subtraction of passed prevValue from current Environment.TickCount</returns> | 1763 | /// <returns>subtraction of passed prevValue from current Environment.TickCount</returns> |
1764 | public static Int32 EnvironmentTickCountSubtract(Int32 newValue, Int32 prevValue) | 1764 | public static Int32 EnvironmentTickCountSubtract(Int32 newValue, Int32 prevValue) |
1765 | { | 1765 | { |
1766 | Int32 diff = newValue - prevValue; | 1766 | Int32 diff = newValue - prevValue; |
1767 | return (diff >= 0) ? diff : (diff + EnvironmentTickCountMask + 1); | 1767 | return (diff >= 0) ? diff : (diff + EnvironmentTickCountMask + 1); |
1768 | } | 1768 | } |
1769 | 1769 | ||
1770 | /// <summary> | 1770 | /// <summary> |
1771 | /// Environment.TickCount is an int but it counts all 32 bits so it goes positive | 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 | 1772 | /// and negative every 24.9 days. Subtracts the passed value (previously fetched by |
1773 | /// 'EnvironmentTickCount()') and accounts for any wrapping. | 1773 | /// 'EnvironmentTickCount()') and accounts for any wrapping. |
1774 | /// </summary> | 1774 | /// </summary> |
1775 | /// <returns>subtraction of passed prevValue from current Environment.TickCount</returns> | 1775 | /// <returns>subtraction of passed prevValue from current Environment.TickCount</returns> |
1776 | public static Int32 EnvironmentTickCountSubtract(Int32 prevValue) | 1776 | public static Int32 EnvironmentTickCountSubtract(Int32 prevValue) |
1777 | { | 1777 | { |
1778 | return EnvironmentTickCountSubtract(EnvironmentTickCount(), prevValue); | 1778 | return EnvironmentTickCountSubtract(EnvironmentTickCount(), prevValue); |
1779 | } | 1779 | } |
1780 | 1780 | ||
1781 | // 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 |
1782 | // 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(). |
1783 | // A positive return value indicates A occured later than B | 1783 | // A positive return value indicates A occured later than B |
@@ -1940,12 +1940,12 @@ namespace OpenSim.Framework | |||
1940 | #region Universal User Identifiers | 1940 | #region Universal User Identifiers |
1941 | /// <summary> | 1941 | /// <summary> |
1942 | /// </summary> | 1942 | /// </summary> |
1943 | /// <param name="value">uuid[;endpoint[;first last[;secret]]]</param> | 1943 | /// <param name="value">uuid[;endpoint[;first last[;secret]]]</param> |
1944 | /// <param name="uuid">the uuid part</param> | 1944 | /// <param name="uuid">the uuid part</param> |
1945 | /// <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> |
1946 | /// <param name="firstname">the first name part (e.g. Test)</param> | 1946 | /// <param name="firstname">the first name part (e.g. Test)</param> |
1947 | /// <param name="lastname">the last name part (e.g User)</param> | 1947 | /// <param name="lastname">the last name part (e.g User)</param> |
1948 | /// <param name="secret">the secret part</param> | 1948 | /// <param name="secret">the secret part</param> |
1949 | 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) |
1950 | { | 1950 | { |
1951 | 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; |
@@ -1974,79 +1974,79 @@ namespace OpenSim.Framework | |||
1974 | } | 1974 | } |
1975 | 1975 | ||
1976 | /// <summary> | 1976 | /// <summary> |
1977 | /// Produces a universal (HG) system-facing identifier given the information | 1977 | /// Produces a universal (HG) system-facing identifier given the information |
1978 | /// </summary> | 1978 | /// </summary> |
1979 | /// <param name="acircuit"></param> | 1979 | /// <param name="acircuit"></param> |
1980 | /// <returns>uuid[;homeURI[;first last]]</returns> | 1980 | /// <returns>uuid[;homeURI[;first last]]</returns> |
1981 | public static string ProduceUserUniversalIdentifier(AgentCircuitData acircuit) | 1981 | public static string ProduceUserUniversalIdentifier(AgentCircuitData acircuit) |
1982 | { | 1982 | { |
1983 | if (acircuit.ServiceURLs.ContainsKey("HomeURI")) | 1983 | if (acircuit.ServiceURLs.ContainsKey("HomeURI")) |
1984 | 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()); |
1985 | else | 1985 | else |
1986 | return acircuit.AgentID.ToString(); | 1986 | return acircuit.AgentID.ToString(); |
1987 | } | 1987 | } |
1988 | 1988 | ||
1989 | /// <summary> | 1989 | /// <summary> |
1990 | /// Produces a universal (HG) system-facing identifier given the information | 1990 | /// Produces a universal (HG) system-facing identifier given the information |
1991 | /// </summary> | 1991 | /// </summary> |
1992 | /// <param name="id">UUID of the user</param> | 1992 | /// <param name="id">UUID of the user</param> |
1993 | /// <param name="firstName">first name (e.g Test)</param> | 1993 | /// <param name="firstName">first name (e.g Test)</param> |
1994 | /// <param name="lastName">last name (e.g. User)</param> | 1994 | /// <param name="lastName">last name (e.g. User)</param> |
1995 | /// <param name="homeURI">homeURI (e.g. http://foo.com)</param> | 1995 | /// <param name="homeURI">homeURI (e.g. http://foo.com)</param> |
1996 | /// <returns>a string of the form uuid[;homeURI[;first last]]</returns> | 1996 | /// <returns>a string of the form uuid[;homeURI[;first last]]</returns> |
1997 | 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) |
1998 | { | 1998 | { |
1999 | string agentsURI = homeURI; | 1999 | string agentsURI = homeURI; |
2000 | if (!agentsURI.EndsWith("/")) | 2000 | if (!agentsURI.EndsWith("/")) |
2001 | agentsURI += "/"; | 2001 | agentsURI += "/"; |
2002 | 2002 | ||
2003 | // 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 |
2004 | // in the agent circuit data for foreigners | 2004 | // in the agent circuit data for foreigners |
2005 | if (lastName.Contains("@")) | 2005 | if (lastName.Contains("@")) |
2006 | { | 2006 | { |
2007 | string agentsURI = acircuit.ServiceURLs["HomeURI"].ToString(); | 2007 | string agentsURI = acircuit.ServiceURLs["HomeURI"].ToString(); |
2008 | if (!agentsURI.EndsWith("/")) | 2008 | if (!agentsURI.EndsWith("/")) |
2009 | agentsURI += "/"; | 2009 | agentsURI += "/"; |
2010 | string[] parts = firstName.Split(new char[] { '.' }); | 2010 | string[] parts = firstName.Split(new char[] { '.' }); |
2011 | if (parts.Length == 2) | 2011 | if (parts.Length == 2) |
2012 | return id.ToString() + ";" + agentsURI + ";" + parts[0] + " " + parts[1]; | 2012 | return id.ToString() + ";" + agentsURI + ";" + parts[0] + " " + parts[1]; |
2013 | } | 2013 | } |
2014 | return id.ToString() + ";" + agentsURI + ";" + firstName + " " + lastName; | 2014 | return id.ToString() + ";" + agentsURI + ";" + firstName + " " + lastName; |
2015 | 2015 | ||
2016 | } | 2016 | } |
2017 | 2017 | ||
2018 | // This is ugly, but there's no other way, given that the name is changed | 2018 | // This is ugly, but there's no other way, given that the name is changed |
2019 | // in the agent circuit data for foreigners | 2019 | // in the agent circuit data for foreigners |
2020 | if (acircuit.lastname.Contains("@")) | 2020 | if (acircuit.lastname.Contains("@")) |
2021 | { | 2021 | { |
2022 | string[] parts = acircuit.firstname.Split(new char[] { '.' }); | 2022 | string[] parts = acircuit.firstname.Split(new char[] { '.' }); |
2023 | if (parts.Length == 2) | 2023 | if (parts.Length == 2) |
2024 | return acircuit.AgentID.ToString() + ";" + agentsURI + ";" + parts[0] + " " + parts[1]; | 2024 | return acircuit.AgentID.ToString() + ";" + agentsURI + ";" + parts[0] + " " + parts[1]; |
2025 | } | 2025 | } |
2026 | return acircuit.AgentID.ToString() + ";" + agentsURI + ";" + acircuit.firstname + " " + acircuit.lastname; | 2026 | return acircuit.AgentID.ToString() + ";" + agentsURI + ";" + acircuit.firstname + " " + acircuit.lastname; |
2027 | /// <summary> | 2027 | /// <summary> |
2028 | /// Produces a universal (HG) user-facing name given the information | 2028 | /// Produces a universal (HG) user-facing name given the information |
2029 | /// </summary> | 2029 | /// </summary> |
2030 | /// <param name="firstName"></param> | 2030 | /// <param name="firstName"></param> |
2031 | /// <param name="lastName"></param> | 2031 | /// <param name="lastName"></param> |
2032 | /// <param name="homeURI"></param> | 2032 | /// <param name="homeURI"></param> |
2033 | /// <returns>string of the form first.last @foo.com or first last</returns> | 2033 | /// <returns>string of the form first.last @foo.com or first last</returns> |
2034 | public static string UniversalName(String firstName, String lastName, String homeURI) | 2034 | public static string UniversalName(String firstName, String lastName, String homeURI) |
2035 | { | 2035 | { |
2036 | Uri uri = null; | 2036 | Uri uri = null; |
2037 | try | 2037 | try |
2038 | { | 2038 | { |
2039 | uri = new Uri(homeURI); | 2039 | uri = new Uri(homeURI); |
2040 | } | 2040 | } |
2041 | else | 2041 | else |
2042 | return acircuit.AgentID.ToString(); | 2042 | return acircuit.AgentID.ToString(); |
2043 | } | 2043 | } |
2044 | catch (UriFormatException) | 2044 | catch (UriFormatException) |
2045 | { | 2045 | { |
2046 | return firstName + " " + lastName; | 2046 | return firstName + " " + lastName; |
2047 | } | 2047 | } |
2048 | return firstName + "." + lastName + " " + "@" + uri.Authority; | 2048 | return firstName + "." + lastName + " " + "@" + uri.Authority; |
2049 | } | 2049 | } |
2050 | #endregion | 2050 | #endregion |
2051 | } | 2051 | } |
2052 | } | 2052 | } |