diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Services/Interfaces/OpenProfileClient.cs | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/OpenSim/Services/Interfaces/OpenProfileClient.cs b/OpenSim/Services/Interfaces/OpenProfileClient.cs new file mode 100644 index 0000000..bda8151 --- /dev/null +++ b/OpenSim/Services/Interfaces/OpenProfileClient.cs | |||
@@ -0,0 +1,134 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Net.Sockets; | ||
33 | using System.Reflection; | ||
34 | using System.Text; | ||
35 | using System.Xml; | ||
36 | using log4net; | ||
37 | using OpenMetaverse; | ||
38 | using OpenSim.Framework; | ||
39 | |||
40 | namespace OpenSim.Services.UserProfilesService | ||
41 | { | ||
42 | /// <summary> | ||
43 | /// A client for accessing a profile server using the OpenProfile protocol. | ||
44 | /// </summary> | ||
45 | /// <remarks> | ||
46 | /// This class was adapted from the full OpenProfile class. Since it's only a client, and not a server, | ||
47 | /// it's much simpler. | ||
48 | /// </remarks> | ||
49 | public class OpenProfileClient | ||
50 | { | ||
51 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | |||
53 | private string m_serverURI; | ||
54 | |||
55 | /// <summary> | ||
56 | /// Creates a client for accessing a foreign grid's profile server using the OpenProfile protocol. | ||
57 | /// </summary> | ||
58 | /// <param name="serverURI">The grid's profile server URL</param> | ||
59 | public OpenProfileClient(string serverURI) | ||
60 | { | ||
61 | m_serverURI = serverURI; | ||
62 | } | ||
63 | |||
64 | /// <summary> | ||
65 | /// Gets an avatar's profile using the OpenProfile protocol. | ||
66 | /// </summary> | ||
67 | /// <param name="props">On success, this will contain the avatar's profile</param> | ||
68 | /// <returns>Success/failure</returns> | ||
69 | /// <remarks> | ||
70 | /// There are two profile modules currently in use in OpenSim: the older one is OpenProfile, and the newer | ||
71 | /// one is UserProfileModule (this file). This method attempts to read an avatar's profile from a foreign | ||
72 | /// grid using the OpenProfile protocol. | ||
73 | /// </remarks> | ||
74 | public bool RequestAvatarPropertiesUsingOpenProfile(ref UserProfileProperties props) | ||
75 | { | ||
76 | Hashtable ReqHash = new Hashtable(); | ||
77 | ReqHash["avatar_id"] = props.UserId.ToString(); | ||
78 | |||
79 | Hashtable profileData = XMLRPCRequester.SendRequest(ReqHash, "avatar_properties_request", m_serverURI); | ||
80 | |||
81 | if (profileData == null) | ||
82 | return false; | ||
83 | if (!profileData.ContainsKey("data")) | ||
84 | return false; | ||
85 | |||
86 | ArrayList dataArray = (ArrayList)profileData["data"]; | ||
87 | |||
88 | if (dataArray == null || dataArray[0] == null) | ||
89 | return false; | ||
90 | profileData = (Hashtable)dataArray[0]; | ||
91 | |||
92 | props.WebUrl = string.Empty; | ||
93 | props.AboutText = String.Empty; | ||
94 | props.FirstLifeText = String.Empty; | ||
95 | props.ImageId = UUID.Zero; | ||
96 | props.FirstLifeImageId = UUID.Zero; | ||
97 | props.PartnerId = UUID.Zero; | ||
98 | |||
99 | if (profileData["ProfileUrl"] != null) | ||
100 | props.WebUrl = profileData["ProfileUrl"].ToString(); | ||
101 | if (profileData["AboutText"] != null) | ||
102 | props.AboutText = profileData["AboutText"].ToString(); | ||
103 | if (profileData["FirstLifeAboutText"] != null) | ||
104 | props.FirstLifeText = profileData["FirstLifeAboutText"].ToString(); | ||
105 | if (profileData["Image"] != null) | ||
106 | props.ImageId = new UUID(profileData["Image"].ToString()); | ||
107 | if (profileData["FirstLifeImage"] != null) | ||
108 | props.FirstLifeImageId = new UUID(profileData["FirstLifeImage"].ToString()); | ||
109 | if (profileData["Partner"] != null) | ||
110 | props.PartnerId = new UUID(profileData["Partner"].ToString()); | ||
111 | |||
112 | props.WantToMask = 0; | ||
113 | props.WantToText = String.Empty; | ||
114 | props.SkillsMask = 0; | ||
115 | props.SkillsText = String.Empty; | ||
116 | props.Language = String.Empty; | ||
117 | |||
118 | if (profileData["wantmask"] != null) | ||
119 | props.WantToMask = Convert.ToInt32(profileData["wantmask"].ToString()); | ||
120 | if (profileData["wanttext"] != null) | ||
121 | props.WantToText = profileData["wanttext"].ToString(); | ||
122 | |||
123 | if (profileData["skillsmask"] != null) | ||
124 | props.SkillsMask = Convert.ToInt32(profileData["skillsmask"].ToString()); | ||
125 | if (profileData["skillstext"] != null) | ||
126 | props.SkillsText = profileData["skillstext"].ToString(); | ||
127 | |||
128 | if (profileData["languages"] != null) | ||
129 | props.Language = profileData["languages"].ToString(); | ||
130 | |||
131 | return true; | ||
132 | } | ||
133 | } | ||
134 | } \ No newline at end of file | ||