29 using System.Collections.Generic;
31 using System.Reflection;
34 using OpenSim.Framework;
35 using OpenSim.Server.Base;
36 using OpenSim.Framework.Servers.HttpServer;
37 using OpenSim.Region.Framework.Scenes;
38 using OpenSim.Region.Framework.Interfaces;
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53 : base(
"POST",
"/estate")
55 m_EstateModule = fmodule;
61 StreamReader sr =
new StreamReader(requestData);
62 string body = sr.ReadToEnd();
66 m_log.DebugFormat(
"[XESTATE HANDLER]: query String: {0}", body);
72 Dictionary<string, object> request =
73 ServerUtils.ParseQueryString(body);
75 if (!request.ContainsKey(
"METHOD"))
76 return FailureResult();
78 string method = request[
"METHOD"].ToString();
79 request.Remove(
"METHOD");
83 m_EstateModule.InInfoUpdate =
false;
87 case "update_covenant":
88 return UpdateCovenant(request);
90 return UpdateEstate(request);
91 case "estate_message":
92 return EstateMessage(request);
93 case "teleport_home_one_user":
94 return TeleportHomeOneUser(request);
95 case "teleport_home_all_users":
96 return TeleportHomeAllUsers(request);
101 m_EstateModule.InInfoUpdate =
false;
107 m_log.Debug(
"[XESTATE]: Exception {0}" + e.ToString());
110 return FailureResult();
113 byte[] TeleportHomeAllUsers(Dictionary<string, object> request)
115 UUID PreyID = UUID.Zero;
118 if (!request.ContainsKey(
"EstateID"))
119 return FailureResult();
121 if (!Int32.TryParse(request[
"EstateID"].ToString(), out EstateID))
122 return FailureResult();
124 foreach (
Scene s
in m_EstateModule.Scenes)
131 p.ControllingClient.SendTeleportStart(16);
132 s.TeleportClientHome(p.ControllingClient.AgentId, p.ControllingClient);
138 return SuccessResult();
141 byte[] TeleportHomeOneUser(Dictionary<string, object> request)
143 UUID PreyID = UUID.Zero;
146 if (!request.ContainsKey(
"PreyID") ||
147 !request.ContainsKey(
"EstateID"))
149 return FailureResult();
152 if (!
UUID.TryParse(request[
"PreyID"].ToString(), out PreyID))
153 return FailureResult();
155 if (!Int32.TryParse(request[
"EstateID"].ToString(), out EstateID))
156 return FailureResult();
158 foreach (
Scene s
in m_EstateModule.Scenes)
165 p.ControllingClient.SendTeleportStart(16);
166 s.TeleportClientHome(PreyID, p.ControllingClient);
171 return SuccessResult();
174 byte[] EstateMessage(Dictionary<string, object> request)
176 UUID FromID = UUID.Zero;
177 string FromName = String.Empty;
178 string Message = String.Empty;
181 if (!request.ContainsKey(
"FromID") ||
182 !request.ContainsKey(
"FromName") ||
183 !request.ContainsKey(
"Message") ||
184 !request.ContainsKey(
"EstateID"))
186 return FailureResult();
189 if (!
UUID.TryParse(request[
"FromID"].ToString(), out FromID))
190 return FailureResult();
192 if (!Int32.TryParse(request[
"EstateID"].ToString(), out EstateID))
193 return FailureResult();
195 FromName = request[
"FromName"].ToString();
196 Message = request[
"Message"].ToString();
198 foreach (
Scene s
in m_EstateModule.Scenes)
206 dm.SendNotificationToUsersInRegion(FromID, FromName,
212 return SuccessResult();
215 byte[] UpdateCovenant(Dictionary<string, object> request)
217 UUID CovenantID = UUID.Zero;
220 if (!request.ContainsKey(
"CovenantID") || !request.ContainsKey(
"EstateID"))
221 return FailureResult();
223 if (!
UUID.TryParse(request[
"CovenantID"].ToString(), out CovenantID))
224 return FailureResult();
226 if (!Int32.TryParse(request[
"EstateID"].ToString(), out EstateID))
227 return FailureResult();
229 foreach (
Scene s
in m_EstateModule.Scenes)
232 s.RegionInfo.RegionSettings.Covenant = CovenantID;
235 return SuccessResult();
238 byte[] UpdateEstate(Dictionary<string, object> request)
242 if (!request.ContainsKey(
"EstateID"))
243 return FailureResult();
244 if (!Int32.TryParse(request[
"EstateID"].ToString(), out EstateID))
245 return FailureResult();
247 foreach (
Scene s
in m_EstateModule.Scenes)
250 s.ReloadEstateData();
252 return SuccessResult();
255 private byte[] FailureResult()
257 return BoolResult(
false);
260 private byte[] SuccessResult()
262 return BoolResult(
true);
265 private byte[] BoolResult(
bool value)
267 XmlDocument doc =
new XmlDocument();
269 XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
272 doc.AppendChild(xmlnode);
274 XmlElement rootElement = doc.CreateElement(
"",
"ServerResponse",
277 doc.AppendChild(rootElement);
279 XmlElement result = doc.CreateElement(
"",
"RESULT",
"");
280 result.AppendChild(doc.CreateTextNode(value.ToString()));
282 rootElement.AppendChild(result);
284 return Util.DocToBytes(doc);
override byte[] ProcessRequest(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
EstateSettings EstateSettings
XEstateModule m_EstateModule
Base streamed request handler.
virtual RegionInfo RegionInfo
EstateRequestHandler(XEstateModule fmodule)