OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
OpenProfileClient.cs
Go to the documentation of this file.
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 {
49  public class OpenProfileClient
50  {
51 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 
53  private string m_serverURI;
54 
59  public OpenProfileClient(string serverURI)
60  {
61  m_serverURI = serverURI;
62  }
63 
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 }
A client for accessing a profile server using the OpenProfile protocol.
bool RequestAvatarPropertiesUsingOpenProfile(ref UserProfileProperties props)
Gets an avatar's profile using the OpenProfile protocol.
OpenProfileClient(string serverURI)
Creates a client for accessing a foreign grid's profile server using the OpenProfile protocol...
Interactive OpenSim region server
Definition: OpenSim.cs:55