diff options
author | Melanie | 2012-03-21 00:26:02 +0000 |
---|---|---|
committer | Melanie | 2012-03-21 00:26:02 +0000 |
commit | ee9210f656f754e2caa40cb6ff39463cbf286347 (patch) | |
tree | 8097bad8a37e210bfbdeff113a9ab00d853ad9ac /OpenSim/Framework | |
parent | Merge branch 'master' into careminster (diff) | |
parent | Refix the fixed fix! (diff) | |
download | opensim-SC_OLD-ee9210f656f754e2caa40cb6ff39463cbf286347.zip opensim-SC_OLD-ee9210f656f754e2caa40cb6ff39463cbf286347.tar.gz opensim-SC_OLD-ee9210f656f754e2caa40cb6ff39463cbf286347.tar.bz2 opensim-SC_OLD-ee9210f656f754e2caa40cb6ff39463cbf286347.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Util.cs | 150 |
1 files changed, 92 insertions, 58 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index d89bb3a..728cda0 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -35,7 +35,7 @@ using System.IO; | |||
35 | using System.IO.Compression; | 35 | using System.IO.Compression; |
36 | using System.Net; | 36 | using System.Net; |
37 | using System.Net.Sockets; | 37 | using System.Net.Sockets; |
38 | using System.Reflection; | 38 | using System.Reflection; |
39 | using System.Runtime.InteropServices; | 39 | using System.Runtime.InteropServices; |
40 | using System.Runtime.Serialization; | 40 | using System.Runtime.Serialization; |
41 | using System.Runtime.Serialization.Formatters.Binary; | 41 | using System.Runtime.Serialization.Formatters.Binary; |
@@ -378,20 +378,20 @@ namespace OpenSim.Framework | |||
378 | } | 378 | } |
379 | 379 | ||
380 | return sb.ToString(); | 380 | return sb.ToString(); |
381 | } | 381 | } |
382 | 382 | ||
383 | /// <summary> | 383 | /// <summary> |
384 | /// Is the platform Windows? | 384 | /// Is the platform Windows? |
385 | /// </summary> | 385 | /// </summary> |
386 | /// <returns>true if so, false otherwise</returns> | 386 | /// <returns>true if so, false otherwise</returns> |
387 | public static bool IsWindows() | 387 | public static bool IsWindows() |
388 | { | 388 | { |
389 | PlatformID platformId = Environment.OSVersion.Platform; | 389 | PlatformID platformId = Environment.OSVersion.Platform; |
390 | 390 | ||
391 | return (platformId == PlatformID.Win32NT | 391 | return (platformId == PlatformID.Win32NT |
392 | || platformId == PlatformID.Win32S | 392 | || platformId == PlatformID.Win32S |
393 | || platformId == PlatformID.Win32Windows | 393 | || platformId == PlatformID.Win32Windows |
394 | || platformId == PlatformID.WinCE); | 394 | || platformId == PlatformID.WinCE); |
395 | } | 395 | } |
396 | 396 | ||
397 | public static bool LoadArchSpecificWindowsDll(string libraryName) | 397 | public static bool LoadArchSpecificWindowsDll(string libraryName) |
@@ -1516,27 +1516,27 @@ namespace OpenSim.Framework | |||
1516 | } | 1516 | } |
1517 | 1517 | ||
1518 | return data; | 1518 | return data; |
1519 | } | 1519 | } |
1520 | 1520 | ||
1521 | /// <summary> | 1521 | /// <summary> |
1522 | /// Used to trigger an early library load on Windows systems. | 1522 | /// Used to trigger an early library load on Windows systems. |
1523 | /// </summary> | 1523 | /// </summary> |
1524 | /// <remarks> | 1524 | /// <remarks> |
1525 | /// Required to get 32-bit and 64-bit processes to automatically use the | 1525 | /// Required to get 32-bit and 64-bit processes to automatically use the |
1526 | /// appropriate native library. | 1526 | /// appropriate native library. |
1527 | /// </remarks> | 1527 | /// </remarks> |
1528 | /// <param name="dllToLoad"></param> | 1528 | /// <param name="dllToLoad"></param> |
1529 | /// <returns></returns> | 1529 | /// <returns></returns> |
1530 | [DllImport("kernel32.dll")] | 1530 | [DllImport("kernel32.dll")] |
1531 | public static extern IntPtr LoadLibrary(string dllToLoad); | 1531 | public static extern IntPtr LoadLibrary(string dllToLoad); |
1532 | 1532 | ||
1533 | /// <summary> | 1533 | /// <summary> |
1534 | /// Determine whether the current process is 64 bit | 1534 | /// Determine whether the current process is 64 bit |
1535 | /// </summary> | 1535 | /// </summary> |
1536 | /// <returns>true if so, false if not</returns> | 1536 | /// <returns>true if so, false if not</returns> |
1537 | public static bool Is64BitProcess() | 1537 | public static bool Is64BitProcess() |
1538 | { | 1538 | { |
1539 | return IntPtr.Size == 8; | 1539 | return IntPtr.Size == 8; |
1540 | } | 1540 | } |
1541 | 1541 | ||
1542 | #region FireAndForget Threading Pattern | 1542 | #region FireAndForget Threading Pattern |
@@ -1952,11 +1952,12 @@ namespace OpenSim.Framework | |||
1952 | #region Universal User Identifiers | 1952 | #region Universal User Identifiers |
1953 | /// <summary> | 1953 | /// <summary> |
1954 | /// </summary> | 1954 | /// </summary> |
1955 | /// <param name="value">uuid[;endpoint[;name]]</param> | 1955 | /// <param name="value">uuid[;endpoint[;first last[;secret]]]</param> |
1956 | /// <param name="uuid"></param> | 1956 | /// <param name="uuid">the uuid part</param> |
1957 | /// <param name="url"></param> | 1957 | /// <param name="url">the endpoint part (e.g. http://foo.com)</param> |
1958 | /// <param name="firstname"></param> | 1958 | /// <param name="firstname">the first name part (e.g. Test)</param> |
1959 | /// <param name="lastname"></param> | 1959 | /// <param name="lastname">the last name part (e.g User)</param> |
1960 | /// <param name="secret">the secret part</param> | ||
1960 | public static bool ParseUniversalUserIdentifier(string value, out UUID uuid, out string url, out string firstname, out string lastname, out string secret) | 1961 | public static bool ParseUniversalUserIdentifier(string value, out UUID uuid, out string url, out string firstname, out string lastname, out string secret) |
1961 | { | 1962 | { |
1962 | uuid = UUID.Zero; url = string.Empty; firstname = "Unknown"; lastname = "User"; secret = string.Empty; | 1963 | uuid = UUID.Zero; url = string.Empty; firstname = "Unknown"; lastname = "User"; secret = string.Empty; |
@@ -1985,31 +1986,64 @@ namespace OpenSim.Framework | |||
1985 | } | 1986 | } |
1986 | 1987 | ||
1987 | /// <summary> | 1988 | /// <summary> |
1988 | /// | 1989 | /// Produces a universal (HG) system-facing identifier given the information |
1989 | /// </summary> | 1990 | /// </summary> |
1990 | /// <param name="acircuit"></param> | 1991 | /// <param name="acircuit"></param> |
1991 | /// <returns>uuid[;endpoint[;name]]</returns> | 1992 | /// <returns>uuid[;homeURI[;first last]]</returns> |
1992 | public static string ProduceUserUniversalIdentifier(AgentCircuitData acircuit) | 1993 | public static string ProduceUserUniversalIdentifier(AgentCircuitData acircuit) |
1993 | { | 1994 | { |
1994 | if (acircuit.ServiceURLs.ContainsKey("HomeURI")) | 1995 | if (acircuit.ServiceURLs.ContainsKey("HomeURI")) |
1996 | return UniversalIdentifier(acircuit.AgentID, acircuit.firstname, acircuit.lastname, acircuit.ServiceURLs["HomeURI"].ToString()); | ||
1997 | else | ||
1998 | return acircuit.AgentID.ToString(); | ||
1999 | } | ||
2000 | |||
2001 | /// <summary> | ||
2002 | /// Produces a universal (HG) system-facing identifier given the information | ||
2003 | /// </summary> | ||
2004 | /// <param name="id">UUID of the user</param> | ||
2005 | /// <param name="firstName">first name (e.g Test)</param> | ||
2006 | /// <param name="lastName">last name (e.g. User)</param> | ||
2007 | /// <param name="homeURI">homeURI (e.g. http://foo.com)</param> | ||
2008 | /// <returns>a string of the form uuid[;homeURI[;first last]]</returns> | ||
2009 | public static string UniversalIdentifier(UUID id, String firstName, String lastName, String homeURI) | ||
2010 | { | ||
2011 | string agentsURI = homeURI; | ||
2012 | if (!agentsURI.EndsWith("/")) | ||
2013 | agentsURI += "/"; | ||
2014 | |||
2015 | // This is ugly, but there's no other way, given that the name is changed | ||
2016 | // in the agent circuit data for foreigners | ||
2017 | if (lastName.Contains("@")) | ||
1995 | { | 2018 | { |
1996 | string agentsURI = acircuit.ServiceURLs["HomeURI"].ToString(); | 2019 | string[] parts = firstName.Split(new char[] { '.' }); |
1997 | if (!agentsURI.EndsWith("/")) | 2020 | if (parts.Length == 2) |
1998 | agentsURI += "/"; | 2021 | return id.ToString() + ";" + agentsURI + ";" + parts[0] + " " + parts[1]; |
2022 | } | ||
2023 | return id.ToString() + ";" + agentsURI + ";" + firstName + " " + lastName; | ||
1999 | 2024 | ||
2000 | // This is ugly, but there's no other way, given that the name is changed | 2025 | } |
2001 | // in the agent circuit data for foreigners | 2026 | |
2002 | if (acircuit.lastname.Contains("@")) | 2027 | /// <summary> |
2003 | { | 2028 | /// Produces a universal (HG) user-facing name given the information |
2004 | string[] parts = acircuit.firstname.Split(new char[] { '.' }); | 2029 | /// </summary> |
2005 | if (parts.Length == 2) | 2030 | /// <param name="firstName"></param> |
2006 | return acircuit.AgentID.ToString() + ";" + agentsURI + ";" + parts[0] + " " + parts[1]; | 2031 | /// <param name="lastName"></param> |
2007 | } | 2032 | /// <param name="homeURI"></param> |
2008 | return acircuit.AgentID.ToString() + ";" + agentsURI + ";" + acircuit.firstname + " " + acircuit.lastname; | 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) | ||
2035 | { | ||
2036 | Uri uri = null; | ||
2037 | try | ||
2038 | { | ||
2039 | uri = new Uri(homeURI); | ||
2009 | } | 2040 | } |
2010 | else | 2041 | catch (UriFormatException) |
2011 | return acircuit.AgentID.ToString(); | 2042 | { |
2012 | } | 2043 | return firstName + " " + lastName; |
2044 | } | ||
2045 | return firstName + "." + lastName + " " + "@" + uri.Authority; | ||
2046 | } | ||
2013 | #endregion | 2047 | #endregion |
2014 | } | 2048 | } |
2015 | } | 2049 | } |