aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/UserServer.Modules/UserServerAvatarAppearanceModule.cs
diff options
context:
space:
mode:
authorMW2009-02-24 15:37:03 +0000
committerMW2009-02-24 15:37:03 +0000
commitea26bd415329fb3f030819c9cbaf210825cf5c34 (patch)
treec419cf51b14e33d56532298888c0bec3dfeeaaaa /OpenSim/Grid/UserServer.Modules/UserServerAvatarAppearanceModule.cs
parentDeleted the files from Messagingserver that are now in OpenSim.Grid.Framework (diff)
downloadopensim-SC_OLD-ea26bd415329fb3f030819c9cbaf210825cf5c34.zip
opensim-SC_OLD-ea26bd415329fb3f030819c9cbaf210825cf5c34.tar.gz
opensim-SC_OLD-ea26bd415329fb3f030819c9cbaf210825cf5c34.tar.bz2
opensim-SC_OLD-ea26bd415329fb3f030819c9cbaf210825cf5c34.tar.xz
First step in separating out the Userserver console command handling to a "module".
Added OpenSim.Grid.UserServer.Modules project/dll which now contains the components of the userserver. With the OpenSim.Grid.UserServer being the setup and initiate exe.
Diffstat (limited to 'OpenSim/Grid/UserServer.Modules/UserServerAvatarAppearanceModule.cs')
-rw-r--r--OpenSim/Grid/UserServer.Modules/UserServerAvatarAppearanceModule.cs124
1 files changed, 124 insertions, 0 deletions
diff --git a/OpenSim/Grid/UserServer.Modules/UserServerAvatarAppearanceModule.cs b/OpenSim/Grid/UserServer.Modules/UserServerAvatarAppearanceModule.cs
new file mode 100644
index 0000000..1c8c0c8
--- /dev/null
+++ b/OpenSim/Grid/UserServer.Modules/UserServerAvatarAppearanceModule.cs
@@ -0,0 +1,124 @@
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 OpenSim 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.Reflection;
32using log4net;
33using Nwc.XmlRpc;
34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Framework.Communications;
37using OpenSim.Framework.Servers;
38
39namespace OpenSim.Grid.UserServer.Modules
40{
41 public class UserServerAvatarAppearanceModule
42 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44
45 private UserDataBaseService m_userDataBaseService;
46 private BaseHttpServer m_httpServer;
47
48 public UserServerAvatarAppearanceModule(UserDataBaseService userDataBaseService)
49 {
50 m_userDataBaseService = userDataBaseService;
51 }
52
53 public void Initialise()
54 {
55
56 }
57
58 public void PostInitialise()
59 {
60
61 }
62
63 public void RegisterHandlers(BaseHttpServer httpServer)
64 {
65 m_httpServer = httpServer;
66
67 m_httpServer.AddXmlRPCHandler("get_avatar_appearance", XmlRPCGetAvatarAppearance);
68 m_httpServer.AddXmlRPCHandler("update_avatar_appearance", XmlRPCUpdateAvatarAppearance);
69 }
70
71 public XmlRpcResponse XmlRPCGetAvatarAppearance(XmlRpcRequest request)
72 {
73 XmlRpcResponse response = new XmlRpcResponse();
74 Hashtable requestData = (Hashtable)request.Params[0];
75 AvatarAppearance appearance;
76 Hashtable responseData;
77 if (requestData.Contains("owner"))
78 {
79 appearance = m_userDataBaseService.GetUserAppearance(new UUID((string)requestData["owner"]));
80 if (appearance == null)
81 {
82 responseData = new Hashtable();
83 responseData["error_type"] = "no appearance";
84 responseData["error_desc"] = "There was no appearance found for this avatar";
85 }
86 else
87 {
88 responseData = appearance.ToHashTable();
89 }
90 }
91 else
92 {
93 responseData = new Hashtable();
94 responseData["error_type"] = "unknown_avatar";
95 responseData["error_desc"] = "The avatar appearance requested is not in the database";
96 }
97
98 response.Value = responseData;
99 return response;
100 }
101
102 public XmlRpcResponse XmlRPCUpdateAvatarAppearance(XmlRpcRequest request)
103 {
104 XmlRpcResponse response = new XmlRpcResponse();
105 Hashtable requestData = (Hashtable)request.Params[0];
106 Hashtable responseData;
107 if (requestData.Contains("owner"))
108 {
109 AvatarAppearance appearance = new AvatarAppearance(requestData);
110 m_userDataBaseService.UpdateUserAppearance(new UUID((string)requestData["owner"]), appearance);
111 responseData = new Hashtable();
112 responseData["returnString"] = "TRUE";
113 }
114 else
115 {
116 responseData = new Hashtable();
117 responseData["error_type"] = "unknown_avatar";
118 responseData["error_desc"] = "The avatar appearance requested is not in the database";
119 }
120 response.Value = responseData;
121 return response;
122 }
123 }
124}