clockwerk-opensim – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 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 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  
65 /// <summary>
66 /// Gets an avatar's profile using the OpenProfile protocol.
67 /// </summary>
68 /// <param name="props">On success, this will contain the avatar's profile</param>
69 /// <returns>Success/failure</returns>
70 /// <remarks>
71 /// There are two profile modules currently in use in OpenSim: the older one is OpenProfile, and the newer
72 /// one is UserProfileModule (this file). This method attempts to read an avatar's profile from a foreign
73 /// grid using the OpenProfile protocol.
74 /// </remarks>
75 public bool RequestAvatarPropertiesUsingOpenProfile(ref UserProfileProperties props)
76 {
77 Hashtable ReqHash = new Hashtable();
78 ReqHash["avatar_id"] = props.UserId.ToString();
79  
80 Hashtable profileData = XMLRPCRequester.SendRequest(ReqHash, "avatar_properties_request", m_serverURI);
81  
82 if (profileData == null)
83 return false;
84 if (!profileData.ContainsKey("data"))
85 return false;
86  
87 ArrayList dataArray = (ArrayList)profileData["data"];
88  
89 if (dataArray == null || dataArray[0] == null)
90 return false;
91 profileData = (Hashtable)dataArray[0];
92  
93 props.WebUrl = string.Empty;
94 props.AboutText = String.Empty;
95 props.FirstLifeText = String.Empty;
96 props.ImageId = UUID.Zero;
97 props.FirstLifeImageId = UUID.Zero;
98 props.PartnerId = UUID.Zero;
99  
100 if (profileData["ProfileUrl"] != null)
101 props.WebUrl = profileData["ProfileUrl"].ToString();
102 if (profileData["AboutText"] != null)
103 props.AboutText = profileData["AboutText"].ToString();
104 if (profileData["FirstLifeAboutText"] != null)
105 props.FirstLifeText = profileData["FirstLifeAboutText"].ToString();
106 if (profileData["Image"] != null)
107 props.ImageId = new UUID(profileData["Image"].ToString());
108 if (profileData["FirstLifeImage"] != null)
109 props.FirstLifeImageId = new UUID(profileData["FirstLifeImage"].ToString());
110 if (profileData["Partner"] != null)
111 props.PartnerId = new UUID(profileData["Partner"].ToString());
112  
113 props.WantToMask = 0;
114 props.WantToText = String.Empty;
115 props.SkillsMask = 0;
116 props.SkillsText = String.Empty;
117 props.Language = String.Empty;
118  
119 if (profileData["wantmask"] != null)
120 props.WantToMask = Convert.ToInt32(profileData["wantmask"].ToString());
121 if (profileData["wanttext"] != null)
122 props.WantToText = profileData["wanttext"].ToString();
123  
124 if (profileData["skillsmask"] != null)
125 props.SkillsMask = Convert.ToInt32(profileData["skillsmask"].ToString());
126 if (profileData["skillstext"] != null)
127 props.SkillsText = profileData["skillstext"].ToString();
128  
129 if (profileData["languages"] != null)
130 props.Language = profileData["languages"].ToString();
131  
132 return true;
133 }
134 }
135 }