aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Interfaces/OpenProfileClient.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/Interfaces/OpenProfileClient.cs')
-rw-r--r--OpenSim/Services/Interfaces/OpenProfileClient.cs136
1 files changed, 136 insertions, 0 deletions
diff --git a/OpenSim/Services/Interfaces/OpenProfileClient.cs b/OpenSim/Services/Interfaces/OpenProfileClient.cs
new file mode 100644
index 0000000..4126c35
--- /dev/null
+++ b/OpenSim/Services/Interfaces/OpenProfileClient.cs
@@ -0,0 +1,136 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Linq;
32using System.Net;
33using System.Net.Sockets;
34using System.Reflection;
35using System.Text;
36using System.Xml;
37using log4net;
38using OpenMetaverse;
39using OpenSim.Framework;
40
41namespace OpenSim.Services.UserProfilesService
42{
43 /// <summary>
44 /// A client for accessing a profile server using the OpenProfile protocol.
45 /// </summary>
46 /// <remarks>
47 /// This class was adapted from the full OpenProfile class. Since it's only a client, and not a server,
48 /// it's much simpler.
49 /// </remarks>
50 public class OpenProfileClient
51 {
52 static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53
54 private string m_serverURI;
55
56 /// <summary>
57 /// Creates a client for accessing a foreign grid's profile server using the OpenProfile protocol.
58 /// </summary>
59 /// <param name="serverURI">The grid's profile server URL</param>
60 public OpenProfileClient(string serverURI)
61 {
62 m_serverURI = serverURI;
63 }
64
65
66 /// <summary>
67 /// Gets an avatar's profile using the OpenProfile protocol.
68 /// </summary>
69 /// <param name="props">On success, this will contain the avatar's profile</param>
70 /// <returns>Success/failure</returns>
71 /// <remarks>
72 /// There are two profile modules currently in use in OpenSim: the older one is OpenProfile, and the newer
73 /// one is UserProfileModule (this file). This method attempts to read an avatar's profile from a foreign
74 /// grid using the OpenProfile protocol.
75 /// </remarks>
76 public bool RequestAvatarPropertiesUsingOpenProfile(ref UserProfileProperties props)
77 {
78 Hashtable ReqHash = new Hashtable();
79 ReqHash["avatar_id"] = props.UserId.ToString();
80
81 Hashtable profileData = XMLRPCRequester.SendRequest(ReqHash, "avatar_properties_request", m_serverURI);
82
83 if (profileData == null)
84 return false;
85 if (!profileData.ContainsKey("data"))
86 return false;
87
88 ArrayList dataArray = (ArrayList)profileData["data"];
89
90 if (dataArray == null || dataArray[0] == null)
91 return false;
92 profileData = (Hashtable)dataArray[0];
93
94 props.WebUrl = string.Empty;
95 props.AboutText = String.Empty;
96 props.FirstLifeText = String.Empty;
97 props.ImageId = UUID.Zero;
98 props.FirstLifeImageId = UUID.Zero;
99 props.PartnerId = UUID.Zero;
100
101 if (profileData["ProfileUrl"] != null)
102 props.WebUrl = profileData["ProfileUrl"].ToString();
103 if (profileData["AboutText"] != null)
104 props.AboutText = profileData["AboutText"].ToString();
105 if (profileData["FirstLifeAboutText"] != null)
106 props.FirstLifeText = profileData["FirstLifeAboutText"].ToString();
107 if (profileData["Image"] != null)
108 props.ImageId = new UUID(profileData["Image"].ToString());
109 if (profileData["FirstLifeImage"] != null)
110 props.FirstLifeImageId = new UUID(profileData["FirstLifeImage"].ToString());
111 if (profileData["Partner"] != null)
112 props.PartnerId = new UUID(profileData["Partner"].ToString());
113
114 props.WantToMask = 0;
115 props.WantToText = String.Empty;
116 props.SkillsMask = 0;
117 props.SkillsText = String.Empty;
118 props.Language = String.Empty;
119
120 if (profileData["wantmask"] != null)
121 props.WantToMask = Convert.ToInt32(profileData["wantmask"].ToString());
122 if (profileData["wanttext"] != null)
123 props.WantToText = profileData["wanttext"].ToString();
124
125 if (profileData["skillsmask"] != null)
126 props.SkillsMask = Convert.ToInt32(profileData["skillsmask"].ToString());
127 if (profileData["skillstext"] != null)
128 props.SkillsText = profileData["skillstext"].ToString();
129
130 if (profileData["languages"] != null)
131 props.Language = profileData["languages"].ToString();
132
133 return true;
134 }
135 }
136}