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 using System;
28 using System.Collections;
29 using System.Collections.Generic;
30 using System.Net;
31 using System.Reflection;
32  
33 using OpenSim.Services.Interfaces;
34 using GridRegion = OpenSim.Services.Interfaces.GridRegion;
35  
36 using log4net;
37 using Nwc.XmlRpc;
38 using OpenMetaverse;
39  
40 namespace OpenSim.Server.Handlers.Hypergrid
41 {
42 public class HypergridHandlers
43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45  
46 private IGatekeeperService m_GatekeeperService;
47  
48 public HypergridHandlers(IGatekeeperService gatekeeper)
49 {
50 m_GatekeeperService = gatekeeper;
51 m_log.DebugFormat("[HYPERGRID HANDLERS]: Active");
52 }
53  
54 /// <summary>
55 /// Someone wants to link to us
56 /// </summary>
57 /// <param name="request"></param>
58 /// <returns></returns>
59 public XmlRpcResponse LinkRegionRequest(XmlRpcRequest request, IPEndPoint remoteClient)
60 {
61 Hashtable requestData = (Hashtable)request.Params[0];
62 //string host = (string)requestData["host"];
63 //string portstr = (string)requestData["port"];
64 string name = (string)requestData["region_name"];
65 if (name == null)
66 name = string.Empty;
67  
68 UUID regionID = UUID.Zero;
69 string externalName = string.Empty;
70 string imageURL = string.Empty;
71 ulong regionHandle = 0;
72 string reason = string.Empty;
73  
74 bool success = m_GatekeeperService.LinkRegion(name, out regionID, out regionHandle, out externalName, out imageURL, out reason);
75  
76 Hashtable hash = new Hashtable();
77 hash["result"] = success.ToString();
78 hash["uuid"] = regionID.ToString();
79 hash["handle"] = regionHandle.ToString();
80 hash["region_image"] = imageURL;
81 hash["external_name"] = externalName;
82  
83 XmlRpcResponse response = new XmlRpcResponse();
84 response.Value = hash;
85 return response;
86 }
87  
88 public XmlRpcResponse GetRegion(XmlRpcRequest request, IPEndPoint remoteClient)
89 {
90 Hashtable requestData = (Hashtable)request.Params[0];
91 //string host = (string)requestData["host"];
92 //string portstr = (string)requestData["port"];
93 string regionID_str = (string)requestData["region_uuid"];
94 UUID regionID = UUID.Zero;
95 UUID.TryParse(regionID_str, out regionID);
96  
97 UUID agentID = UUID.Zero;
98 string agentHomeURI = null;
99 if (requestData.ContainsKey("agent_id"))
100 agentID = UUID.Parse((string)requestData["agent_id"]);
101 if (requestData.ContainsKey("agent_home_uri"))
102 agentHomeURI = (string)requestData["agent_home_uri"];
103  
104 string message;
105 GridRegion regInfo = m_GatekeeperService.GetHyperlinkRegion(regionID, agentID, agentHomeURI, out message);
106  
107 Hashtable hash = new Hashtable();
108 if (regInfo == null)
109 {
110 hash["result"] = "false";
111 }
112 else
113 {
114 hash["result"] = "true";
115 hash["uuid"] = regInfo.RegionID.ToString();
116 hash["x"] = regInfo.RegionLocX.ToString();
117 hash["y"] = regInfo.RegionLocY.ToString();
118 hash["size_x"] = regInfo.RegionSizeX.ToString();
119 hash["size_y"] = regInfo.RegionSizeY.ToString();
120 hash["region_name"] = regInfo.RegionName;
121 hash["hostname"] = regInfo.ExternalHostName;
122 hash["http_port"] = regInfo.HttpPort.ToString();
123 hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString();
124 }
125  
126 if (message != null)
127 hash["message"] = message;
128  
129 XmlRpcResponse response = new XmlRpcResponse();
130 response.Value = hash;
131 return response;
132  
133 }
134  
135 }
136 }