From 61e99bcdcba5480aa8a2a8b8e2f2b0a66c08e6b4 Mon Sep 17 00:00:00 2001
From: Talun
Date: Tue, 8 May 2012 15:52:25 +0100
Subject: Mantis 6015 new LSL function llGetAgentList.
Details in the lsl wiki
---
.../Shared/Api/Implementation/LSL_Api.cs | 85 ++++++++++++++++++++++
.../ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | 1 +
.../Shared/Api/Runtime/LSL_Constants.cs | 5 ++
.../ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | 5 ++
4 files changed, 96 insertions(+)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index afd943b..5b5cab8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -5529,6 +5529,91 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
return "en-us";
}
+ ///
+ /// http://wiki.secondlife.com/wiki/LlGetAgentList
+ /// The list of options is currently not used in SL
+ /// scope is one of:-
+ /// AGENT_LIST_REGION - all in the region
+ /// AGENT_LIST_PARCEL - all in the same parcel as the scripted object
+ /// AGENT_LIST_PARCEL_OWNER - all in any parcel owned by the owner of the
+ /// current parcel.
+ ///
+ public LSL_List llGetAgentList(LSL_Integer scope, LSL_List options)
+ {
+ m_host.AddScriptLPS(1);
+
+ // the constants are 1, 2 and 4 so bits are being set, but you
+ // get an error "INVALID_SCOPE" if it is anything but 1, 2 and 4
+ bool regionWide = scope == ScriptBaseClass.AGENT_LIST_REGION;
+ bool parcelOwned = scope == ScriptBaseClass.AGENT_LIST_PARCEL_OWNER;
+ bool parcel = scope == ScriptBaseClass.AGENT_LIST_PARCEL;
+
+ LSL_List result = new LSL_List();
+
+ if (!regionWide && !parcelOwned && !parcel)
+ {
+ result.Add("INVALID_SCOPE");
+ return result;
+ }
+
+ ILandObject land;
+ Vector3 pos;
+ UUID id = UUID.Zero;
+ if (parcel || parcelOwned)
+ {
+ pos = m_host.ParentGroup.RootPart.GetWorldPosition();
+ land = World.LandChannel.GetLandObject(pos.X, pos.Y);
+ if (land == null)
+ {
+ id = UUID.Zero;
+ }
+ else
+ {
+ if (parcelOwned)
+ {
+ id = land.LandData.OwnerID;
+ }
+ else
+ {
+ id = land.LandData.GlobalID;
+ }
+ }
+ }
+ List presenceIds = new List();
+
+ World.ForEachRootScenePresence(
+ delegate (ScenePresence ssp)
+ {
+ // Gods are not listed in SL
+ if (!ssp.IsDeleted && ssp.GodLevel == 0.0 && !ssp.IsChildAgent)
+ {
+ if (!regionWide)
+ {
+ pos = ssp.AbsolutePosition;
+ land = World.LandChannel.GetLandObject(pos.X, pos.Y);
+ if (land != null)
+ {
+ if (parcelOwned && land.LandData.OwnerID == id ||
+ parcel && land.LandData.GlobalID == id)
+ {
+ result.Add(ssp.UUID.ToString());
+ }
+ }
+ }
+ else
+ {
+ result.Add(ssp.UUID.ToString());
+ }
+ }
+ // Maximum of 100 results
+ if (result.Length > 99)
+ {
+ return;
+ }
+ }
+ );
+ return result;
+ }
public void llAdjustSoundVolume(double volume)
{
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index 7a797ac..7f5d1fe 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -109,6 +109,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
LSL_Vector llGetAccel();
LSL_Integer llGetAgentInfo(string id);
LSL_String llGetAgentLanguage(string id);
+ LSL_List llGetAgentList(LSL_Integer scope, LSL_List options);
LSL_Vector llGetAgentSize(string id);
LSL_Float llGetAlpha(int face);
LSL_Float llGetAndResetTime();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index 2a28542..b6c21e6 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -501,6 +501,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int OBJECT_STREAMING_COST = 15;
public const int OBJECT_PHYSICS_COST = 16;
+ // for llGetAgentList
+ public const int AGENT_LIST_PARCEL = 1;
+ public const int AGENT_LIST_PARCEL_OWNER = 2;
+ public const int AGENT_LIST_REGION = 4;
+
// Can not be public const?
public static readonly vector ZERO_VECTOR = new vector(0.0, 0.0, 0.0);
public static readonly rotation ZERO_ROTATION = new rotation(0.0, 0.0, 0.0, 1.0);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
index 80fa530..c0bf29c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
@@ -389,6 +389,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
return m_LSL_Functions.llGetAgentLanguage(id);
}
+ public LSL_List llGetAgentList(LSL_Integer scope, LSL_List options)
+ {
+ return m_LSL_Functions.llGetAgentList(scope, options);
+ }
+
public LSL_Vector llGetAgentSize(string id)
{
return m_LSL_Functions.llGetAgentSize(id);
--
cgit v1.1
From e813f41478eefb50748e9bdc2b825fa8bc25c971 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 9 May 2012 20:52:54 +0100
Subject: Escape and unescape xml element names if necessary in
ServerUtils.BuildXmlData() and ParseElement()
If AvatarService appearance data is retrieved over the network, then ServerUtils was attempting to transfer names such as "Wearable 0:0" directly to xml element names, resulting in an exception.
Space is not valid in xml element names. Neither is : in this case since the intention is not to namespace. Using names directly as keys is not a good idea.
To get around this problem this patch escapes and unescapes the element names as appropriate.
This has no impact on existing xml (since it had to be valid in the first place) but allows AvatarService data to be used over the network.
Setting appearance (from simulator to AvatarService) did not suffer this problem since the values are passed in the query string which is already properly escaped.
---
OpenSim/Server/Base/ServerUtils.cs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs
index 0cc2a4b..42c82cf 100644
--- a/OpenSim/Server/Base/ServerUtils.cs
+++ b/OpenSim/Server/Base/ServerUtils.cs
@@ -268,7 +268,7 @@ namespace OpenSim.Server.Base
continue;
XmlElement elem = parent.OwnerDocument.CreateElement("",
- kvp.Key, "");
+ XmlConvert.EncodeLocalName(kvp.Key), "");
if (kvp.Value is Dictionary)
{
@@ -323,11 +323,11 @@ namespace OpenSim.Server.Base
XmlNode type = part.Attributes.GetNamedItem("type");
if (type == null || type.Value != "List")
{
- ret[part.Name] = part.InnerText;
+ ret[XmlConvert.DecodeName(part.Name)] = part.InnerText;
}
else
{
- ret[part.Name] = ParseElement(part);
+ ret[XmlConvert.DecodeName(part.Name)] = ParseElement(part);
}
}
--
cgit v1.1
From 6987aef38dbc4f5c24b6e2cc73601f9a7c5f4431 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 9 May 2012 23:12:30 +0100
Subject: Improve logging on the prim inventory script asset request path for
future use.
This adds name and description of the request handler to http request logging when DebugLevel >= 1
---
OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 4 ++--
.../ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 2 +-
OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 13 ++++++++-----
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 4 ++++
4 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index d0463c8..401dfd3 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -447,8 +447,8 @@ namespace OpenSim.Framework.Servers.HttpServer
{
if (DebugLevel >= 1)
m_log.DebugFormat(
- "[BASE HTTP SERVER]: Found stream handler for {0} {1}",
- request.HttpMethod, request.Url.PathAndQuery);
+ "[BASE HTTP SERVER]: Found stream handler for {0} {1} {2} {3}",
+ request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description);
// Okay, so this is bad, but should be considered temporary until everything is IStreamHandler.
byte[] buffer = null;
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
index 9791885..6c28e78 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
@@ -309,7 +309,7 @@ namespace OpenSim.Region.ClientStack.Linden
m_HostCapsObj.HttpListener.AddStreamHandler(
new BinaryStreamHandler(
- "POST", capsBase + uploaderPath, uploader.uploaderCaps, "BunchOfCaps", null));
+ "POST", capsBase + uploaderPath, uploader.uploaderCaps, "TaskInventoryScriptUpdater", null));
string protocol = "http://";
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index ae5cbff..4d6081c 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -11955,21 +11955,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP
protected void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID)
{
UUID requestID = UUID.Zero;
- if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
+ int sourceType = transferRequest.TransferInfo.SourceType;
+
+ if (sourceType == (int)SourceType.Asset)
{
requestID = new UUID(transferRequest.TransferInfo.Params, 0);
}
- else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
+ else if (sourceType == (int)SourceType.SimInventoryItem)
{
requestID = new UUID(transferRequest.TransferInfo.Params, 80);
}
- else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimEstate)
+ else if (sourceType == (int)SourceType.SimEstate)
{
requestID = taskID;
}
-
-// m_log.DebugFormat("[CLIENT]: {0} requesting asset {1}", Name, requestID);
+// m_log.DebugFormat(
+// "[LLCLIENTVIEW]: Received transfer request for {0} in {1} type {2} by {3}",
+// requestID, taskID, (SourceType)sourceType, Name);
m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived);
}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 816d3b6..8a26df1 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -300,6 +300,10 @@ namespace OpenSim.Region.Framework.Scenes
AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data, remoteClient.AgentId);
AssetService.Store(asset);
+// m_log.DebugFormat(
+// "[PRIM INVENTORY]: Stored asset {0} when updating item {1} in prim {2} for {3}",
+// asset.ID, item.Name, part.Name, remoteClient.Name);
+
if (isScriptRunning)
{
part.Inventory.RemoveScriptInstance(item.ItemID, false);
--
cgit v1.1
From d8a78374aa11c5460d6e58a6f4110fca61dfded4 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 9 May 2012 23:25:01 +0100
Subject: Where necessary, rename OpenSim/Services/Connectors/*.cs files to
reflect the actual class names.
This is usually because the file name was singular (*Service*) but the class name was plural (*Services*).
This is to make configuration easier rather than having to look in the c# code itself to find the slightly different name of the connector.
This does not affect existing configuration since the files are being renamed rather than the classes.
---
.../Connectors/Asset/AssetServiceConnector.cs | 329 ----------
.../Connectors/Asset/AssetServicesConnector.cs | 329 ++++++++++
.../AuthenticationServiceConnector.cs | 167 -----
.../AuthenticationServicesConnector.cs | 167 +++++
.../Authorization/AuthorizationServiceConnector.cs | 123 ----
.../AuthorizationServicesConnector.cs | 123 ++++
.../Connectors/Avatar/AvatarServiceConnector.cs | 326 ----------
.../Connectors/Avatar/AvatarServicesConnector.cs | 326 ++++++++++
.../Connectors/Friends/FriendsServiceConnector.cs | 267 --------
.../Connectors/Friends/FriendsServicesConnector.cs | 267 ++++++++
.../Connectors/Grid/GridServiceConnector.cs | 671 ---------------------
.../Connectors/Grid/GridServicesConnector.cs | 671 +++++++++++++++++++++
.../GridUser/GridUserServiceConnector.cs | 290 ---------
.../GridUser/GridUserServicesConnector.cs | 290 +++++++++
.../Hypergrid/HGFriendsServiceConnector.cs | 312 ----------
.../Hypergrid/HGFriendsServicesConnector.cs | 312 ++++++++++
.../Connectors/Hypergrid/HeloServiceConnector.cs | 100 ---
.../Connectors/Hypergrid/HeloServicesConnector.cs | 100 +++
.../Connectors/Inventory/XInventoryConnector.cs | 623 -------------------
.../Inventory/XInventoryServicesConnector.cs | 623 +++++++++++++++++++
.../Connectors/Land/LandServiceConnector.cs | 133 ----
.../Connectors/Land/LandServicesConnector.cs | 133 ++++
.../MapImage/MapImageServiceConnector.cs | 159 -----
.../MapImage/MapImageServicesConnector.cs | 159 +++++
.../Neighbour/NeighbourServiceConnector.cs | 206 -------
.../Neighbour/NeighbourServicesConnector.cs | 206 +++++++
.../Presence/PresenceServiceConnector.cs | 378 ------------
.../Presence/PresenceServicesConnector.cs | 378 ++++++++++++
.../UserAccounts/UserAccountServiceConnector.cs | 287 ---------
.../UserAccounts/UserAccountServicesConnector.cs | 287 +++++++++
30 files changed, 4371 insertions(+), 4371 deletions(-)
delete mode 100644 OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs
create mode 100644 OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
delete mode 100644 OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs
create mode 100644 OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs
delete mode 100644 OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs
create mode 100644 OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs
delete mode 100644 OpenSim/Services/Connectors/Avatar/AvatarServiceConnector.cs
create mode 100644 OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs
delete mode 100644 OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs
create mode 100644 OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs
delete mode 100644 OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
create mode 100644 OpenSim/Services/Connectors/Grid/GridServicesConnector.cs
delete mode 100644 OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs
create mode 100644 OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs
delete mode 100644 OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs
create mode 100644 OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs
delete mode 100644 OpenSim/Services/Connectors/Hypergrid/HeloServiceConnector.cs
create mode 100644 OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs
delete mode 100644 OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs
create mode 100644 OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
delete mode 100644 OpenSim/Services/Connectors/Land/LandServiceConnector.cs
create mode 100644 OpenSim/Services/Connectors/Land/LandServicesConnector.cs
delete mode 100644 OpenSim/Services/Connectors/MapImage/MapImageServiceConnector.cs
create mode 100644 OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs
delete mode 100644 OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs
create mode 100644 OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
delete mode 100644 OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs
create mode 100644 OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs
delete mode 100644 OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs
create mode 100644 OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs
diff --git a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs
deleted file mode 100644
index e4c3eaf..0000000
--- a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using log4net;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Reflection;
-using Nini.Config;
-using OpenSim.Framework;
-using OpenSim.Framework.Console;
-using OpenSim.Framework.Communications;
-using OpenSim.Services.Interfaces;
-using OpenMetaverse;
-
-namespace OpenSim.Services.Connectors
-{
- public class AssetServicesConnector : IAssetService
- {
- private static readonly ILog m_log =
- LogManager.GetLogger(
- MethodBase.GetCurrentMethod().DeclaringType);
-
- private string m_ServerURI = String.Empty;
- private IImprovedAssetCache m_Cache = null;
-
- private delegate void AssetRetrievedEx(AssetBase asset);
-
- // Keeps track of concurrent requests for the same asset, so that it's only loaded once.
- // Maps: Asset ID -> Handlers which will be called when the asset has been loaded
- private Dictionary m_AssetHandlers = new Dictionary();
-
-
- public AssetServicesConnector()
- {
- }
-
- public AssetServicesConnector(string serverURI)
- {
- m_ServerURI = serverURI.TrimEnd('/');
- }
-
- public AssetServicesConnector(IConfigSource source)
- {
- Initialise(source);
- }
-
- public virtual void Initialise(IConfigSource source)
- {
- IConfig assetConfig = source.Configs["AssetService"];
- if (assetConfig == null)
- {
- m_log.Error("[ASSET CONNECTOR]: AssetService missing from OpenSim.ini");
- throw new Exception("Asset connector init error");
- }
-
- string serviceURI = assetConfig.GetString("AssetServerURI",
- String.Empty);
-
- if (serviceURI == String.Empty)
- {
- m_log.Error("[ASSET CONNECTOR]: No Server URI named in section AssetService");
- throw new Exception("Asset connector init error");
- }
-
- m_ServerURI = serviceURI;
- }
-
- protected void SetCache(IImprovedAssetCache cache)
- {
- m_Cache = cache;
- }
-
- public AssetBase Get(string id)
- {
-// m_log.DebugFormat("[ASSET SERVICE CONNECTOR]: Synchronous get request for {0}", id);
-
- string uri = m_ServerURI + "/assets/" + id;
-
- AssetBase asset = null;
- if (m_Cache != null)
- asset = m_Cache.Get(id);
-
- if (asset == null)
- {
- asset = SynchronousRestObjectRequester.
- MakeRequest("GET", uri, 0);
-
- if (m_Cache != null)
- m_Cache.Cache(asset);
- }
- return asset;
- }
-
- public AssetBase GetCached(string id)
- {
-// m_log.DebugFormat("[ASSET SERVICE CONNECTOR]: Cache request for {0}", id);
-
- if (m_Cache != null)
- return m_Cache.Get(id);
-
- return null;
- }
-
- public AssetMetadata GetMetadata(string id)
- {
- if (m_Cache != null)
- {
- AssetBase fullAsset = m_Cache.Get(id);
-
- if (fullAsset != null)
- return fullAsset.Metadata;
- }
-
- string uri = m_ServerURI + "/assets/" + id + "/metadata";
-
- AssetMetadata asset = SynchronousRestObjectRequester.
- MakeRequest("GET", uri, 0);
- return asset;
- }
-
- public byte[] GetData(string id)
- {
- if (m_Cache != null)
- {
- AssetBase fullAsset = m_Cache.Get(id);
-
- if (fullAsset != null)
- return fullAsset.Data;
- }
-
- RestClient rc = new RestClient(m_ServerURI);
- rc.AddResourcePath("assets");
- rc.AddResourcePath(id);
- rc.AddResourcePath("data");
-
- rc.RequestMethod = "GET";
-
- Stream s = rc.Request();
-
- if (s == null)
- return null;
-
- if (s.Length > 0)
- {
- byte[] ret = new byte[s.Length];
- s.Read(ret, 0, (int)s.Length);
-
- return ret;
- }
-
- return null;
- }
-
- public bool Get(string id, Object sender, AssetRetrieved handler)
- {
-// m_log.DebugFormat("[ASSET SERVICE CONNECTOR]: Potentially asynchronous get request for {0}", id);
-
- string uri = m_ServerURI + "/assets/" + id;
-
- AssetBase asset = null;
- if (m_Cache != null)
- asset = m_Cache.Get(id);
-
- if (asset == null)
- {
- lock (m_AssetHandlers)
- {
- AssetRetrievedEx handlerEx = new AssetRetrievedEx(delegate(AssetBase _asset) { handler(id, sender, _asset); });
-
- AssetRetrievedEx handlers;
- if (m_AssetHandlers.TryGetValue(id, out handlers))
- {
- // Someone else is already loading this asset. It will notify our handler when done.
- handlers += handlerEx;
- return true;
- }
-
- // Load the asset ourselves
- handlers += handlerEx;
- m_AssetHandlers.Add(id, handlers);
- }
-
- bool success = false;
- try
- {
- AsynchronousRestObjectRequester.MakeRequest("GET", uri, 0,
- delegate(AssetBase a)
- {
- if (m_Cache != null)
- m_Cache.Cache(a);
-
- AssetRetrievedEx handlers;
- lock (m_AssetHandlers)
- {
- handlers = m_AssetHandlers[id];
- m_AssetHandlers.Remove(id);
- }
- handlers.Invoke(a);
- });
-
- success = true;
- }
- finally
- {
- if (!success)
- {
- lock (m_AssetHandlers)
- {
- m_AssetHandlers.Remove(id);
- }
- }
- }
- }
- else
- {
- handler(id, sender, asset);
- }
-
- return true;
- }
-
- public string Store(AssetBase asset)
- {
- if (asset.Temporary || asset.Local)
- {
- if (m_Cache != null)
- m_Cache.Cache(asset);
-
- return asset.ID;
- }
-
- string uri = m_ServerURI + "/assets/";
-
- string newID = string.Empty;
- try
- {
- newID = SynchronousRestObjectRequester.
- MakeRequest("POST", uri, asset);
- }
- catch (Exception e)
- {
- m_log.WarnFormat("[ASSET CONNECTOR]: Unable to send asset {0} to asset server. Reason: {1}", asset.ID, e.Message);
- }
-
- if (newID != String.Empty)
- {
- // Placing this here, so that this work with old asset servers that don't send any reply back
- // SynchronousRestObjectRequester returns somethins that is not an empty string
- if (newID != null)
- asset.ID = newID;
-
- if (m_Cache != null)
- m_Cache.Cache(asset);
- }
- return newID;
- }
-
- public bool UpdateContent(string id, byte[] data)
- {
- AssetBase asset = null;
-
- if (m_Cache != null)
- asset = m_Cache.Get(id);
-
- if (asset == null)
- {
- AssetMetadata metadata = GetMetadata(id);
- if (metadata == null)
- return false;
-
- asset = new AssetBase(metadata.FullID, metadata.Name, metadata.Type, UUID.Zero.ToString());
- asset.Metadata = metadata;
- }
- asset.Data = data;
-
- string uri = m_ServerURI + "/assets/" + id;
-
- if (SynchronousRestObjectRequester.
- MakeRequest("POST", uri, asset))
- {
- if (m_Cache != null)
- m_Cache.Cache(asset);
-
- return true;
- }
- return false;
- }
-
- public bool Delete(string id)
- {
- string uri = m_ServerURI + "/assets/" + id;
-
- if (SynchronousRestObjectRequester.
- MakeRequest("DELETE", uri, 0))
- {
- if (m_Cache != null)
- m_Cache.Expire(id);
-
- return true;
- }
- return false;
- }
- }
-}
\ No newline at end of file
diff --git a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
new file mode 100644
index 0000000..e4c3eaf
--- /dev/null
+++ b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
@@ -0,0 +1,329 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using log4net;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using Nini.Config;
+using OpenSim.Framework;
+using OpenSim.Framework.Console;
+using OpenSim.Framework.Communications;
+using OpenSim.Services.Interfaces;
+using OpenMetaverse;
+
+namespace OpenSim.Services.Connectors
+{
+ public class AssetServicesConnector : IAssetService
+ {
+ private static readonly ILog m_log =
+ LogManager.GetLogger(
+ MethodBase.GetCurrentMethod().DeclaringType);
+
+ private string m_ServerURI = String.Empty;
+ private IImprovedAssetCache m_Cache = null;
+
+ private delegate void AssetRetrievedEx(AssetBase asset);
+
+ // Keeps track of concurrent requests for the same asset, so that it's only loaded once.
+ // Maps: Asset ID -> Handlers which will be called when the asset has been loaded
+ private Dictionary m_AssetHandlers = new Dictionary();
+
+
+ public AssetServicesConnector()
+ {
+ }
+
+ public AssetServicesConnector(string serverURI)
+ {
+ m_ServerURI = serverURI.TrimEnd('/');
+ }
+
+ public AssetServicesConnector(IConfigSource source)
+ {
+ Initialise(source);
+ }
+
+ public virtual void Initialise(IConfigSource source)
+ {
+ IConfig assetConfig = source.Configs["AssetService"];
+ if (assetConfig == null)
+ {
+ m_log.Error("[ASSET CONNECTOR]: AssetService missing from OpenSim.ini");
+ throw new Exception("Asset connector init error");
+ }
+
+ string serviceURI = assetConfig.GetString("AssetServerURI",
+ String.Empty);
+
+ if (serviceURI == String.Empty)
+ {
+ m_log.Error("[ASSET CONNECTOR]: No Server URI named in section AssetService");
+ throw new Exception("Asset connector init error");
+ }
+
+ m_ServerURI = serviceURI;
+ }
+
+ protected void SetCache(IImprovedAssetCache cache)
+ {
+ m_Cache = cache;
+ }
+
+ public AssetBase Get(string id)
+ {
+// m_log.DebugFormat("[ASSET SERVICE CONNECTOR]: Synchronous get request for {0}", id);
+
+ string uri = m_ServerURI + "/assets/" + id;
+
+ AssetBase asset = null;
+ if (m_Cache != null)
+ asset = m_Cache.Get(id);
+
+ if (asset == null)
+ {
+ asset = SynchronousRestObjectRequester.
+ MakeRequest("GET", uri, 0);
+
+ if (m_Cache != null)
+ m_Cache.Cache(asset);
+ }
+ return asset;
+ }
+
+ public AssetBase GetCached(string id)
+ {
+// m_log.DebugFormat("[ASSET SERVICE CONNECTOR]: Cache request for {0}", id);
+
+ if (m_Cache != null)
+ return m_Cache.Get(id);
+
+ return null;
+ }
+
+ public AssetMetadata GetMetadata(string id)
+ {
+ if (m_Cache != null)
+ {
+ AssetBase fullAsset = m_Cache.Get(id);
+
+ if (fullAsset != null)
+ return fullAsset.Metadata;
+ }
+
+ string uri = m_ServerURI + "/assets/" + id + "/metadata";
+
+ AssetMetadata asset = SynchronousRestObjectRequester.
+ MakeRequest("GET", uri, 0);
+ return asset;
+ }
+
+ public byte[] GetData(string id)
+ {
+ if (m_Cache != null)
+ {
+ AssetBase fullAsset = m_Cache.Get(id);
+
+ if (fullAsset != null)
+ return fullAsset.Data;
+ }
+
+ RestClient rc = new RestClient(m_ServerURI);
+ rc.AddResourcePath("assets");
+ rc.AddResourcePath(id);
+ rc.AddResourcePath("data");
+
+ rc.RequestMethod = "GET";
+
+ Stream s = rc.Request();
+
+ if (s == null)
+ return null;
+
+ if (s.Length > 0)
+ {
+ byte[] ret = new byte[s.Length];
+ s.Read(ret, 0, (int)s.Length);
+
+ return ret;
+ }
+
+ return null;
+ }
+
+ public bool Get(string id, Object sender, AssetRetrieved handler)
+ {
+// m_log.DebugFormat("[ASSET SERVICE CONNECTOR]: Potentially asynchronous get request for {0}", id);
+
+ string uri = m_ServerURI + "/assets/" + id;
+
+ AssetBase asset = null;
+ if (m_Cache != null)
+ asset = m_Cache.Get(id);
+
+ if (asset == null)
+ {
+ lock (m_AssetHandlers)
+ {
+ AssetRetrievedEx handlerEx = new AssetRetrievedEx(delegate(AssetBase _asset) { handler(id, sender, _asset); });
+
+ AssetRetrievedEx handlers;
+ if (m_AssetHandlers.TryGetValue(id, out handlers))
+ {
+ // Someone else is already loading this asset. It will notify our handler when done.
+ handlers += handlerEx;
+ return true;
+ }
+
+ // Load the asset ourselves
+ handlers += handlerEx;
+ m_AssetHandlers.Add(id, handlers);
+ }
+
+ bool success = false;
+ try
+ {
+ AsynchronousRestObjectRequester.MakeRequest("GET", uri, 0,
+ delegate(AssetBase a)
+ {
+ if (m_Cache != null)
+ m_Cache.Cache(a);
+
+ AssetRetrievedEx handlers;
+ lock (m_AssetHandlers)
+ {
+ handlers = m_AssetHandlers[id];
+ m_AssetHandlers.Remove(id);
+ }
+ handlers.Invoke(a);
+ });
+
+ success = true;
+ }
+ finally
+ {
+ if (!success)
+ {
+ lock (m_AssetHandlers)
+ {
+ m_AssetHandlers.Remove(id);
+ }
+ }
+ }
+ }
+ else
+ {
+ handler(id, sender, asset);
+ }
+
+ return true;
+ }
+
+ public string Store(AssetBase asset)
+ {
+ if (asset.Temporary || asset.Local)
+ {
+ if (m_Cache != null)
+ m_Cache.Cache(asset);
+
+ return asset.ID;
+ }
+
+ string uri = m_ServerURI + "/assets/";
+
+ string newID = string.Empty;
+ try
+ {
+ newID = SynchronousRestObjectRequester.
+ MakeRequest("POST", uri, asset);
+ }
+ catch (Exception e)
+ {
+ m_log.WarnFormat("[ASSET CONNECTOR]: Unable to send asset {0} to asset server. Reason: {1}", asset.ID, e.Message);
+ }
+
+ if (newID != String.Empty)
+ {
+ // Placing this here, so that this work with old asset servers that don't send any reply back
+ // SynchronousRestObjectRequester returns somethins that is not an empty string
+ if (newID != null)
+ asset.ID = newID;
+
+ if (m_Cache != null)
+ m_Cache.Cache(asset);
+ }
+ return newID;
+ }
+
+ public bool UpdateContent(string id, byte[] data)
+ {
+ AssetBase asset = null;
+
+ if (m_Cache != null)
+ asset = m_Cache.Get(id);
+
+ if (asset == null)
+ {
+ AssetMetadata metadata = GetMetadata(id);
+ if (metadata == null)
+ return false;
+
+ asset = new AssetBase(metadata.FullID, metadata.Name, metadata.Type, UUID.Zero.ToString());
+ asset.Metadata = metadata;
+ }
+ asset.Data = data;
+
+ string uri = m_ServerURI + "/assets/" + id;
+
+ if (SynchronousRestObjectRequester.
+ MakeRequest("POST", uri, asset))
+ {
+ if (m_Cache != null)
+ m_Cache.Cache(asset);
+
+ return true;
+ }
+ return false;
+ }
+
+ public bool Delete(string id)
+ {
+ string uri = m_ServerURI + "/assets/" + id;
+
+ if (SynchronousRestObjectRequester.
+ MakeRequest("DELETE", uri, 0))
+ {
+ if (m_Cache != null)
+ m_Cache.Expire(id);
+
+ return true;
+ }
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs
deleted file mode 100644
index 2b77154..0000000
--- a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using log4net;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Reflection;
-using Nini.Config;
-using OpenSim.Framework;
-using OpenSim.Framework.Communications;
-using OpenSim.Services.Interfaces;
-using OpenSim.Server.Base;
-using OpenMetaverse;
-
-namespace OpenSim.Services.Connectors
-{
- public class AuthenticationServicesConnector : IAuthenticationService
- {
- private static readonly ILog m_log =
- LogManager.GetLogger(
- MethodBase.GetCurrentMethod().DeclaringType);
-
- private string m_ServerURI = String.Empty;
-
- public AuthenticationServicesConnector()
- {
- }
-
- public AuthenticationServicesConnector(string serverURI)
- {
- m_ServerURI = serverURI.TrimEnd('/');
- }
-
- public AuthenticationServicesConnector(IConfigSource source)
- {
- Initialise(source);
- }
-
- public virtual void Initialise(IConfigSource source)
- {
- IConfig assetConfig = source.Configs["AuthenticationService"];
- if (assetConfig == null)
- {
- m_log.Error("[AUTH CONNECTOR]: AuthenticationService missing from OpenSim.ini");
- throw new Exception("Authentication connector init error");
- }
-
- string serviceURI = assetConfig.GetString("AuthenticationServerURI",
- String.Empty);
-
- if (serviceURI == String.Empty)
- {
- m_log.Error("[AUTH CONNECTOR]: No Server URI named in section AuthenticationService");
- throw new Exception("Authentication connector init error");
- }
- m_ServerURI = serviceURI;
- }
-
- public string Authenticate(UUID principalID, string password, int lifetime)
- {
- Dictionary sendData = new Dictionary();
- sendData["LIFETIME"] = lifetime.ToString();
- sendData["PRINCIPAL"] = principalID.ToString();
- sendData["PASSWORD"] = password;
-
- sendData["METHOD"] = "authenticate";
-
- string reply = SynchronousRestFormsRequester.MakeRequest("POST",
- m_ServerURI + "/auth/plain",
- ServerUtils.BuildQueryString(sendData));
-
- Dictionary replyData = ServerUtils.ParseXmlResponse(
- reply);
-
- if (replyData["Result"].ToString() != "Success")
- return String.Empty;
-
- return replyData["Token"].ToString();
- }
-
- public bool Verify(UUID principalID, string token, int lifetime)
- {
- Dictionary sendData = new Dictionary();
- sendData["LIFETIME"] = lifetime.ToString();
- sendData["PRINCIPAL"] = principalID.ToString();
- sendData["TOKEN"] = token;
-
- sendData["METHOD"] = "verify";
-
- string reply = SynchronousRestFormsRequester.MakeRequest("POST",
- m_ServerURI + "/auth/plain",
- ServerUtils.BuildQueryString(sendData));
-
- Dictionary replyData = ServerUtils.ParseXmlResponse(
- reply);
-
- if (replyData["Result"].ToString() != "Success")
- return false;
-
- return true;
- }
-
- public bool Release(UUID principalID, string token)
- {
- Dictionary sendData = new Dictionary();
- sendData["PRINCIPAL"] = principalID.ToString();
- sendData["TOKEN"] = token;
-
- sendData["METHOD"] = "release";
-
- string reply = SynchronousRestFormsRequester.MakeRequest("POST",
- m_ServerURI + "/auth/plain",
- ServerUtils.BuildQueryString(sendData));
-
- Dictionary replyData = ServerUtils.ParseXmlResponse(
- reply);
-
- if (replyData["Result"].ToString() != "Success")
- return false;
-
- return true;
- }
-
- public bool SetPassword(UUID principalID, string passwd)
- {
- // nope, we don't do this
- return false;
- }
-
- public AuthInfo GetAuthInfo(UUID principalID)
- {
- // not done from remote simulators
- return null;
- }
-
- public bool SetAuthInfo(AuthInfo info)
- {
- // not done from remote simulators
- return false;
- }
- }
-}
diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs
new file mode 100644
index 0000000..2b77154
--- /dev/null
+++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using log4net;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using Nini.Config;
+using OpenSim.Framework;
+using OpenSim.Framework.Communications;
+using OpenSim.Services.Interfaces;
+using OpenSim.Server.Base;
+using OpenMetaverse;
+
+namespace OpenSim.Services.Connectors
+{
+ public class AuthenticationServicesConnector : IAuthenticationService
+ {
+ private static readonly ILog m_log =
+ LogManager.GetLogger(
+ MethodBase.GetCurrentMethod().DeclaringType);
+
+ private string m_ServerURI = String.Empty;
+
+ public AuthenticationServicesConnector()
+ {
+ }
+
+ public AuthenticationServicesConnector(string serverURI)
+ {
+ m_ServerURI = serverURI.TrimEnd('/');
+ }
+
+ public AuthenticationServicesConnector(IConfigSource source)
+ {
+ Initialise(source);
+ }
+
+ public virtual void Initialise(IConfigSource source)
+ {
+ IConfig assetConfig = source.Configs["AuthenticationService"];
+ if (assetConfig == null)
+ {
+ m_log.Error("[AUTH CONNECTOR]: AuthenticationService missing from OpenSim.ini");
+ throw new Exception("Authentication connector init error");
+ }
+
+ string serviceURI = assetConfig.GetString("AuthenticationServerURI",
+ String.Empty);
+
+ if (serviceURI == String.Empty)
+ {
+ m_log.Error("[AUTH CONNECTOR]: No Server URI named in section AuthenticationService");
+ throw new Exception("Authentication connector init error");
+ }
+ m_ServerURI = serviceURI;
+ }
+
+ public string Authenticate(UUID principalID, string password, int lifetime)
+ {
+ Dictionary sendData = new Dictionary();
+ sendData["LIFETIME"] = lifetime.ToString();
+ sendData["PRINCIPAL"] = principalID.ToString();
+ sendData["PASSWORD"] = password;
+
+ sendData["METHOD"] = "authenticate";
+
+ string reply = SynchronousRestFormsRequester.MakeRequest("POST",
+ m_ServerURI + "/auth/plain",
+ ServerUtils.BuildQueryString(sendData));
+
+ Dictionary replyData = ServerUtils.ParseXmlResponse(
+ reply);
+
+ if (replyData["Result"].ToString() != "Success")
+ return String.Empty;
+
+ return replyData["Token"].ToString();
+ }
+
+ public bool Verify(UUID principalID, string token, int lifetime)
+ {
+ Dictionary sendData = new Dictionary();
+ sendData["LIFETIME"] = lifetime.ToString();
+ sendData["PRINCIPAL"] = principalID.ToString();
+ sendData["TOKEN"] = token;
+
+ sendData["METHOD"] = "verify";
+
+ string reply = SynchronousRestFormsRequester.MakeRequest("POST",
+ m_ServerURI + "/auth/plain",
+ ServerUtils.BuildQueryString(sendData));
+
+ Dictionary replyData = ServerUtils.ParseXmlResponse(
+ reply);
+
+ if (replyData["Result"].ToString() != "Success")
+ return false;
+
+ return true;
+ }
+
+ public bool Release(UUID principalID, string token)
+ {
+ Dictionary sendData = new Dictionary();
+ sendData["PRINCIPAL"] = principalID.ToString();
+ sendData["TOKEN"] = token;
+
+ sendData["METHOD"] = "release";
+
+ string reply = SynchronousRestFormsRequester.MakeRequest("POST",
+ m_ServerURI + "/auth/plain",
+ ServerUtils.BuildQueryString(sendData));
+
+ Dictionary replyData = ServerUtils.ParseXmlResponse(
+ reply);
+
+ if (replyData["Result"].ToString() != "Success")
+ return false;
+
+ return true;
+ }
+
+ public bool SetPassword(UUID principalID, string passwd)
+ {
+ // nope, we don't do this
+ return false;
+ }
+
+ public AuthInfo GetAuthInfo(UUID principalID)
+ {
+ // not done from remote simulators
+ return null;
+ }
+
+ public bool SetAuthInfo(AuthInfo info)
+ {
+ // not done from remote simulators
+ return false;
+ }
+ }
+}
diff --git a/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs b/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs
deleted file mode 100644
index 35b7109..0000000
--- a/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using log4net;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Reflection;
-using Nini.Config;
-using OpenSim.Framework;
-using OpenSim.Framework.Communications;
-using OpenSim.Services.Interfaces;
-using OpenMetaverse;
-
-namespace OpenSim.Services.Connectors
-{
- public class AuthorizationServicesConnector
- {
- private static readonly ILog m_log =
- LogManager.GetLogger(
- MethodBase.GetCurrentMethod().DeclaringType);
-
- private string m_ServerURI = String.Empty;
- private bool m_ResponseOnFailure = true;
-
- public AuthorizationServicesConnector()
- {
- }
-
- public AuthorizationServicesConnector(string serverURI)
- {
- m_ServerURI = serverURI.TrimEnd('/');
- }
-
- public AuthorizationServicesConnector(IConfigSource source)
- {
- Initialise(source);
- }
-
- public virtual void Initialise(IConfigSource source)
- {
- IConfig authorizationConfig = source.Configs["AuthorizationService"];
- if (authorizationConfig == null)
- {
- //m_log.Info("[AUTHORIZATION CONNECTOR]: AuthorizationService missing from OpenSim.ini");
- throw new Exception("Authorization connector init error");
- }
-
- string serviceURI = authorizationConfig.GetString("AuthorizationServerURI",
- String.Empty);
-
- if (serviceURI == String.Empty)
- {
- m_log.Error("[AUTHORIZATION CONNECTOR]: No Server URI named in section AuthorizationService");
- throw new Exception("Authorization connector init error");
- }
- m_ServerURI = serviceURI;
-
- // this dictates what happens if the remote service fails, if the service fails and the value is true
- // the user is authorized for the region.
- bool responseOnFailure = authorizationConfig.GetBoolean("ResponseOnFailure",true);
-
- m_ResponseOnFailure = responseOnFailure;
- m_log.Info("[AUTHORIZATION CONNECTOR]: AuthorizationService initialized");
- }
-
- public bool IsAuthorizedForRegion(string userID, string firstname, string surname, string email, string regionName, string regionID, out string message)
- {
- // do a remote call to the authorization server specified in the AuthorizationServerURI
- m_log.InfoFormat("[AUTHORIZATION CONNECTOR]: IsAuthorizedForRegion checking {0} at remote server {1}", userID, m_ServerURI);
-
- string uri = m_ServerURI;
-
- AuthorizationRequest req = new AuthorizationRequest(userID, firstname, surname, email, regionName, regionID);
-
- AuthorizationResponse response;
- try
- {
- response = SynchronousRestObjectRequester.MakeRequest("POST", uri, req);
- }
- catch (Exception e)
- {
- m_log.WarnFormat("[AUTHORIZATION CONNECTOR]: Unable to send authorize {0} for region {1} error thrown during comms with remote server. Reason: {2}", userID, regionID, e.Message);
- message = "";
- return m_ResponseOnFailure;
- }
- if (response == null)
- {
- message = "Null response";
- return m_ResponseOnFailure;
- }
- m_log.DebugFormat("[AUTHORIZATION CONNECTOR] response from remote service was {0}", response.Message);
- message = response.Message;
-
- return response.IsAuthorized;
- }
-
- }
-}
diff --git a/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs b/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs
new file mode 100644
index 0000000..35b7109
--- /dev/null
+++ b/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using log4net;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using Nini.Config;
+using OpenSim.Framework;
+using OpenSim.Framework.Communications;
+using OpenSim.Services.Interfaces;
+using OpenMetaverse;
+
+namespace OpenSim.Services.Connectors
+{
+ public class AuthorizationServicesConnector
+ {
+ private static readonly ILog m_log =
+ LogManager.GetLogger(
+ MethodBase.GetCurrentMethod().DeclaringType);
+
+ private string m_ServerURI = String.Empty;
+ private bool m_ResponseOnFailure = true;
+
+ public AuthorizationServicesConnector()
+ {
+ }
+
+ public AuthorizationServicesConnector(string serverURI)
+ {
+ m_ServerURI = serverURI.TrimEnd('/');
+ }
+
+ public AuthorizationServicesConnector(IConfigSource source)
+ {
+ Initialise(source);
+ }
+
+ public virtual void Initialise(IConfigSource source)
+ {
+ IConfig authorizationConfig = source.Configs["AuthorizationService"];
+ if (authorizationConfig == null)
+ {
+ //m_log.Info("[AUTHORIZATION CONNECTOR]: AuthorizationService missing from OpenSim.ini");
+ throw new Exception("Authorization connector init error");
+ }
+
+ string serviceURI = authorizationConfig.GetString("AuthorizationServerURI",
+ String.Empty);
+
+ if (serviceURI == String.Empty)
+ {
+ m_log.Error("[AUTHORIZATION CONNECTOR]: No Server URI named in section AuthorizationService");
+ throw new Exception("Authorization connector init error");
+ }
+ m_ServerURI = serviceURI;
+
+ // this dictates what happens if the remote service fails, if the service fails and the value is true
+ // the user is authorized for the region.
+ bool responseOnFailure = authorizationConfig.GetBoolean("ResponseOnFailure",true);
+
+ m_ResponseOnFailure = responseOnFailure;
+ m_log.Info("[AUTHORIZATION CONNECTOR]: AuthorizationService initialized");
+ }
+
+ public bool IsAuthorizedForRegion(string userID, string firstname, string surname, string email, string regionName, string regionID, out string message)
+ {
+ // do a remote call to the authorization server specified in the AuthorizationServerURI
+ m_log.InfoFormat("[AUTHORIZATION CONNECTOR]: IsAuthorizedForRegion checking {0} at remote server {1}", userID, m_ServerURI);
+
+ string uri = m_ServerURI;
+
+ AuthorizationRequest req = new AuthorizationRequest(userID, firstname, surname, email, regionName, regionID);
+
+ AuthorizationResponse response;
+ try
+ {
+ response = SynchronousRestObjectRequester.MakeRequest("POST", uri, req);
+ }
+ catch (Exception e)
+ {
+ m_log.WarnFormat("[AUTHORIZATION CONNECTOR]: Unable to send authorize {0} for region {1} error thrown during comms with remote server. Reason: {2}", userID, regionID, e.Message);
+ message = "";
+ return m_ResponseOnFailure;
+ }
+ if (response == null)
+ {
+ message = "Null response";
+ return m_ResponseOnFailure;
+ }
+ m_log.DebugFormat("[AUTHORIZATION CONNECTOR] response from remote service was {0}", response.Message);
+ message = response.Message;
+
+ return response.IsAuthorized;
+ }
+
+ }
+}
diff --git a/OpenSim/Services/Connectors/Avatar/AvatarServiceConnector.cs b/OpenSim/Services/Connectors/Avatar/AvatarServiceConnector.cs
deleted file mode 100644
index ddfca57..0000000
--- a/OpenSim/Services/Connectors/Avatar/AvatarServiceConnector.cs
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using log4net;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Reflection;
-using Nini.Config;
-using OpenSim.Framework;
-using OpenSim.Framework.Communications;
-using OpenSim.Services.Interfaces;
-using GridRegion = OpenSim.Services.Interfaces.GridRegion;
-using IAvatarService = OpenSim.Services.Interfaces.IAvatarService;
-using OpenSim.Server.Base;
-using OpenMetaverse;
-
-namespace OpenSim.Services.Connectors
-{
- public class AvatarServicesConnector : IAvatarService
- {
- private static readonly ILog m_log =
- LogManager.GetLogger(
- MethodBase.GetCurrentMethod().DeclaringType);
-
- private string m_ServerURI = String.Empty;
-
- public AvatarServicesConnector()
- {
- }
-
- public AvatarServicesConnector(string serverURI)
- {
- m_ServerURI = serverURI.TrimEnd('/');
- }
-
- public AvatarServicesConnector(IConfigSource source)
- {
- Initialise(source);
- }
-
- public virtual void Initialise(IConfigSource source)
- {
- IConfig gridConfig = source.Configs["AvatarService"];
- if (gridConfig == null)
- {
- m_log.Error("[AVATAR CONNECTOR]: AvatarService missing from OpenSim.ini");
- throw new Exception("Avatar connector init error");
- }
-
- string serviceURI = gridConfig.GetString("AvatarServerURI",
- String.Empty);
-
- if (serviceURI == String.Empty)
- {
- m_log.Error("[AVATAR CONNECTOR]: No Server URI named in section AvatarService");
- throw new Exception("Avatar connector init error");
- }
- m_ServerURI = serviceURI;
- }
-
-
- #region IAvatarService
-
- public AvatarAppearance GetAppearance(UUID userID)
- {
- AvatarData avatar = GetAvatar(userID);
- return avatar.ToAvatarAppearance();
- }
-
- public bool SetAppearance(UUID userID, AvatarAppearance appearance)
- {
- AvatarData avatar = new AvatarData(appearance);
- return SetAvatar(userID,avatar);
- }
-
- public AvatarData GetAvatar(UUID userID)
- {
- Dictionary sendData = new Dictionary();
- //sendData["SCOPEID"] = scopeID.ToString();
- sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
- sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
- sendData["METHOD"] = "getavatar";
-
- sendData["UserID"] = userID;
-
- string reply = string.Empty;
- string reqString = ServerUtils.BuildQueryString(sendData);
- string uri = m_ServerURI + "/avatar";
- // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString);
- try
- {
- reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
- if (reply == null || (reply != null && reply == string.Empty))
- {
- m_log.DebugFormat("[AVATAR CONNECTOR]: GetAgent received null or empty reply");
- return null;
- }
- }
- catch (Exception e)
- {
- m_log.DebugFormat("[AVATAR CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message);
- }
-
- Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
- AvatarData avatar = null;
-
- if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null))
- {
- if (replyData["result"] is Dictionary)
- {
- avatar = new AvatarData((Dictionary)replyData["result"]);
- }
- }
-
- return avatar;
-
- }
-
- public bool SetAvatar(UUID userID, AvatarData avatar)
- {
- Dictionary sendData = new Dictionary();
- //sendData["SCOPEID"] = scopeID.ToString();
- sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
- sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
- sendData["METHOD"] = "setavatar";
-
- sendData["UserID"] = userID.ToString();
-
- Dictionary structData = avatar.ToKeyValuePairs();
-
- foreach (KeyValuePair kvp in structData)
- sendData[kvp.Key] = kvp.Value.ToString();
-
-
- string reqString = ServerUtils.BuildQueryString(sendData);
- string uri = m_ServerURI + "/avatar";
- //m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString);
- try
- {
- string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
- if (reply != string.Empty)
- {
- Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
-
- if (replyData.ContainsKey("result"))
- {
- if (replyData["result"].ToString().ToLower() == "success")
- return true;
- else
- return false;
- }
- else
- {
- m_log.DebugFormat("[AVATAR CONNECTOR]: SetAvatar reply data does not contain result field");
- }
- }
- else
- {
- m_log.DebugFormat("[AVATAR CONNECTOR]: SetAvatar received empty reply");
- }
- }
- catch (Exception e)
- {
- m_log.DebugFormat("[AVATAR CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message);
- }
-
- return false;
- }
-
- public bool ResetAvatar(UUID userID)
- {
- Dictionary sendData = new Dictionary();
- //sendData["SCOPEID"] = scopeID.ToString();
- sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
- sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
- sendData["METHOD"] = "resetavatar";
-
- sendData["UserID"] = userID.ToString();
-
- string reqString = ServerUtils.BuildQueryString(sendData);
- string uri = m_ServerURI + "/avatar";
- // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString);
- try
- {
- string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
- if (reply != string.Empty)
- {
- Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
-
- if (replyData.ContainsKey("result"))
- {
- if (replyData["result"].ToString().ToLower() == "success")
- return true;
- else
- return false;
- }
- else
- m_log.DebugFormat("[AVATAR CONNECTOR]: SetItems reply data does not contain result field");
-
- }
- else
- m_log.DebugFormat("[AVATAR CONNECTOR]: SetItems received empty reply");
- }
- catch (Exception e)
- {
- m_log.DebugFormat("[AVATAR CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message);
- }
-
- return false;
- }
-
- public bool SetItems(UUID userID, string[] names, string[] values)
- {
- Dictionary sendData = new Dictionary();
- sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
- sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
- sendData["METHOD"] = "setitems";
-
- sendData["UserID"] = userID.ToString();
- sendData["Names"] = new List(names);
- sendData["Values"] = new List(values);
-
- string reqString = ServerUtils.BuildQueryString(sendData);
- string uri = m_ServerURI + "/avatar";
- // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString);
- try
- {
- string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
- if (reply != string.Empty)
- {
- Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
-
- if (replyData.ContainsKey("result"))
- {
- if (replyData["result"].ToString().ToLower() == "success")
- return true;
- else
- return false;
- }
- else
- m_log.DebugFormat("[AVATAR CONNECTOR]: SetItems reply data does not contain result field");
-
- }
- else
- m_log.DebugFormat("[AVATAR CONNECTOR]: SetItems received empty reply");
- }
- catch (Exception e)
- {
- m_log.DebugFormat("[AVATAR CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message);
- }
-
- return false;
- }
-
- public bool RemoveItems(UUID userID, string[] names)
- {
- Dictionary sendData = new Dictionary();
- //sendData["SCOPEID"] = scopeID.ToString();
- sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
- sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
- sendData["METHOD"] = "removeitems";
-
- sendData["UserID"] = userID.ToString();
- sendData["Names"] = new List(names);
-
- string reqString = ServerUtils.BuildQueryString(sendData);
- string uri = m_ServerURI + "/avatar";
- // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString);
- try
- {
- string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
- if (reply != string.Empty)
- {
- Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
-
- if (replyData.ContainsKey("result"))
- {
- if (replyData["result"].ToString().ToLower() == "success")
- return true;
- else
- return false;
- }
- else
- m_log.DebugFormat("[AVATAR CONNECTOR]: RemoveItems reply data does not contain result field");
-
- }
- else
- m_log.DebugFormat("[AVATAR CONNECTOR]: RemoveItems received empty reply");
- }
- catch (Exception e)
- {
- m_log.DebugFormat("[AVATAR CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message);
- }
-
- return false;
- }
-
- #endregion
-
- }
-}
diff --git a/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs b/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs
new file mode 100644
index 0000000..ddfca57
--- /dev/null
+++ b/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs
@@ -0,0 +1,326 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using log4net;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using Nini.Config;
+using OpenSim.Framework;
+using OpenSim.Framework.Communications;
+using OpenSim.Services.Interfaces;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
+using IAvatarService = OpenSim.Services.Interfaces.IAvatarService;
+using OpenSim.Server.Base;
+using OpenMetaverse;
+
+namespace OpenSim.Services.Connectors
+{
+ public class AvatarServicesConnector : IAvatarService
+ {
+ private static readonly ILog m_log =
+ LogManager.GetLogger(
+ MethodBase.GetCurrentMethod().DeclaringType);
+
+ private string m_ServerURI = String.Empty;
+
+ public AvatarServicesConnector()
+ {
+ }
+
+ public AvatarServicesConnector(string serverURI)
+ {
+ m_ServerURI = serverURI.TrimEnd('/');
+ }
+
+ public AvatarServicesConnector(IConfigSource source)
+ {
+ Initialise(source);
+ }
+
+ public virtual void Initialise(IConfigSource source)
+ {
+ IConfig gridConfig = source.Configs["AvatarService"];
+ if (gridConfig == null)
+ {
+ m_log.Error("[AVATAR CONNECTOR]: AvatarService missing from OpenSim.ini");
+ throw new Exception("Avatar connector init error");
+ }
+
+ string serviceURI = gridConfig.GetString("AvatarServerURI",
+ String.Empty);
+
+ if (serviceURI == String.Empty)
+ {
+ m_log.Error("[AVATAR CONNECTOR]: No Server URI named in section AvatarService");
+ throw new Exception("Avatar connector init error");
+ }
+ m_ServerURI = serviceURI;
+ }
+
+
+ #region IAvatarService
+
+ public AvatarAppearance GetAppearance(UUID userID)
+ {
+ AvatarData avatar = GetAvatar(userID);
+ return avatar.ToAvatarAppearance();
+ }
+
+ public bool SetAppearance(UUID userID, AvatarAppearance appearance)
+ {
+ AvatarData avatar = new AvatarData(appearance);
+ return SetAvatar(userID,avatar);
+ }
+
+ public AvatarData GetAvatar(UUID userID)
+ {
+ Dictionary sendData = new Dictionary();
+ //sendData["SCOPEID"] = scopeID.ToString();
+ sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
+ sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
+ sendData["METHOD"] = "getavatar";
+
+ sendData["UserID"] = userID;
+
+ string reply = string.Empty;
+ string reqString = ServerUtils.BuildQueryString(sendData);
+ string uri = m_ServerURI + "/avatar";
+ // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString);
+ try
+ {
+ reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
+ if (reply == null || (reply != null && reply == string.Empty))
+ {
+ m_log.DebugFormat("[AVATAR CONNECTOR]: GetAgent received null or empty reply");
+ return null;
+ }
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[AVATAR CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message);
+ }
+
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+ AvatarData avatar = null;
+
+ if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null))
+ {
+ if (replyData["result"] is Dictionary)
+ {
+ avatar = new AvatarData((Dictionary)replyData["result"]);
+ }
+ }
+
+ return avatar;
+
+ }
+
+ public bool SetAvatar(UUID userID, AvatarData avatar)
+ {
+ Dictionary sendData = new Dictionary();
+ //sendData["SCOPEID"] = scopeID.ToString();
+ sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
+ sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
+ sendData["METHOD"] = "setavatar";
+
+ sendData["UserID"] = userID.ToString();
+
+ Dictionary structData = avatar.ToKeyValuePairs();
+
+ foreach (KeyValuePair kvp in structData)
+ sendData[kvp.Key] = kvp.Value.ToString();
+
+
+ string reqString = ServerUtils.BuildQueryString(sendData);
+ string uri = m_ServerURI + "/avatar";
+ //m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString);
+ try
+ {
+ string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
+ if (reply != string.Empty)
+ {
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+
+ if (replyData.ContainsKey("result"))
+ {
+ if (replyData["result"].ToString().ToLower() == "success")
+ return true;
+ else
+ return false;
+ }
+ else
+ {
+ m_log.DebugFormat("[AVATAR CONNECTOR]: SetAvatar reply data does not contain result field");
+ }
+ }
+ else
+ {
+ m_log.DebugFormat("[AVATAR CONNECTOR]: SetAvatar received empty reply");
+ }
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[AVATAR CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message);
+ }
+
+ return false;
+ }
+
+ public bool ResetAvatar(UUID userID)
+ {
+ Dictionary sendData = new Dictionary();
+ //sendData["SCOPEID"] = scopeID.ToString();
+ sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
+ sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
+ sendData["METHOD"] = "resetavatar";
+
+ sendData["UserID"] = userID.ToString();
+
+ string reqString = ServerUtils.BuildQueryString(sendData);
+ string uri = m_ServerURI + "/avatar";
+ // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString);
+ try
+ {
+ string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
+ if (reply != string.Empty)
+ {
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+
+ if (replyData.ContainsKey("result"))
+ {
+ if (replyData["result"].ToString().ToLower() == "success")
+ return true;
+ else
+ return false;
+ }
+ else
+ m_log.DebugFormat("[AVATAR CONNECTOR]: SetItems reply data does not contain result field");
+
+ }
+ else
+ m_log.DebugFormat("[AVATAR CONNECTOR]: SetItems received empty reply");
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[AVATAR CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message);
+ }
+
+ return false;
+ }
+
+ public bool SetItems(UUID userID, string[] names, string[] values)
+ {
+ Dictionary sendData = new Dictionary();
+ sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
+ sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
+ sendData["METHOD"] = "setitems";
+
+ sendData["UserID"] = userID.ToString();
+ sendData["Names"] = new List(names);
+ sendData["Values"] = new List(values);
+
+ string reqString = ServerUtils.BuildQueryString(sendData);
+ string uri = m_ServerURI + "/avatar";
+ // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString);
+ try
+ {
+ string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
+ if (reply != string.Empty)
+ {
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+
+ if (replyData.ContainsKey("result"))
+ {
+ if (replyData["result"].ToString().ToLower() == "success")
+ return true;
+ else
+ return false;
+ }
+ else
+ m_log.DebugFormat("[AVATAR CONNECTOR]: SetItems reply data does not contain result field");
+
+ }
+ else
+ m_log.DebugFormat("[AVATAR CONNECTOR]: SetItems received empty reply");
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[AVATAR CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message);
+ }
+
+ return false;
+ }
+
+ public bool RemoveItems(UUID userID, string[] names)
+ {
+ Dictionary sendData = new Dictionary();
+ //sendData["SCOPEID"] = scopeID.ToString();
+ sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
+ sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
+ sendData["METHOD"] = "removeitems";
+
+ sendData["UserID"] = userID.ToString();
+ sendData["Names"] = new List(names);
+
+ string reqString = ServerUtils.BuildQueryString(sendData);
+ string uri = m_ServerURI + "/avatar";
+ // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString);
+ try
+ {
+ string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
+ if (reply != string.Empty)
+ {
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+
+ if (replyData.ContainsKey("result"))
+ {
+ if (replyData["result"].ToString().ToLower() == "success")
+ return true;
+ else
+ return false;
+ }
+ else
+ m_log.DebugFormat("[AVATAR CONNECTOR]: RemoveItems reply data does not contain result field");
+
+ }
+ else
+ m_log.DebugFormat("[AVATAR CONNECTOR]: RemoveItems received empty reply");
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[AVATAR CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message);
+ }
+
+ return false;
+ }
+
+ #endregion
+
+ }
+}
diff --git a/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs
deleted file mode 100644
index b1dd84e..0000000
--- a/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using log4net;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Reflection;
-using Nini.Config;
-using OpenSim.Framework;
-using OpenSim.Framework.Communications;
-using OpenSim.Services.Interfaces;
-using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
-using OpenSim.Server.Base;
-using OpenMetaverse;
-
-namespace OpenSim.Services.Connectors.Friends
-{
- public class FriendsServicesConnector : IFriendsService
- {
- private static readonly ILog m_log =
- LogManager.GetLogger(
- MethodBase.GetCurrentMethod().DeclaringType);
-
- private string m_ServerURI = String.Empty;
-
- public FriendsServicesConnector()
- {
- }
-
- public FriendsServicesConnector(string serverURI)
- {
- m_ServerURI = serverURI.TrimEnd('/');
- }
-
- public FriendsServicesConnector(IConfigSource source)
- {
- Initialise(source);
- }
-
- public virtual void Initialise(IConfigSource source)
- {
- IConfig gridConfig = source.Configs["FriendsService"];
- if (gridConfig == null)
- {
- m_log.Error("[FRIENDS SERVICE CONNECTOR]: FriendsService missing from OpenSim.ini");
- throw new Exception("Friends connector init error");
- }
-
- string serviceURI = gridConfig.GetString("FriendsServerURI",
- String.Empty);
-
- if (serviceURI == String.Empty)
- {
- m_log.Error("[FRIENDS SERVICE CONNECTOR]: No Server URI named in section FriendsService");
- throw new Exception("Friends connector init error");
- }
- m_ServerURI = serviceURI;
- }
-
-
- #region IFriendsService
-
- public FriendInfo[] GetFriends(UUID PrincipalID)
- {
- Dictionary sendData = new Dictionary();
-
- sendData["PRINCIPALID"] = PrincipalID.ToString();
- sendData["METHOD"] = "getfriends";
-
- return GetFriends(sendData, PrincipalID.ToString());
- }
-
- public FriendInfo[] GetFriends(string PrincipalID)
- {
- Dictionary sendData = new Dictionary();
-
- sendData["PRINCIPALID"] = PrincipalID;
- sendData["METHOD"] = "getfriends_string";
-
- return GetFriends(sendData, PrincipalID);
- }
-
- protected FriendInfo[] GetFriends(Dictionary sendData, string PrincipalID)
- {
- string reqString = ServerUtils.BuildQueryString(sendData);
- string uri = m_ServerURI + "/friends";
-
- try
- {
- string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
- if (reply != string.Empty)
- {
- Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
-
- if (replyData != null)
- {
- if (replyData.ContainsKey("result") && (replyData["result"].ToString().ToLower() == "null"))
- {
- return new FriendInfo[0];
- }
-
- List finfos = new List();
- Dictionary.ValueCollection finfosList = replyData.Values;
- //m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count);
- foreach (object f in finfosList)
- {
- if (f is Dictionary)
- {
- FriendInfo finfo = new FriendInfo((Dictionary)f);
- finfos.Add(finfo);
- }
- else
- m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: GetFriends {0} received invalid response type {1}",
- PrincipalID, f.GetType());
- }
-
- // Success
- return finfos.ToArray();
- }
- else
- m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: GetFriends {0} received null response",
- PrincipalID);
-
- }
- }
- catch (Exception e)
- {
- m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: Exception when contacting friends server at {0}: {1}", uri, e.Message);
- }
-
- return new FriendInfo[0];
-
- }
-
- public bool StoreFriend(string PrincipalID, string Friend, int flags)
- {
-
- Dictionary sendData = ToKeyValuePairs(PrincipalID, Friend, flags);
-
- sendData["METHOD"] = "storefriend";
-
- string reply = string.Empty;
- string uri = m_ServerURI + "/friends";
- try
- {
- reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData));
- }
- catch (Exception e)
- {
- m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: Exception when contacting friends server at {0}: {1}", uri, e.Message);
- return false;
- }
-
- if (reply != string.Empty)
- {
- Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
-
- if ((replyData != null) && replyData.ContainsKey("Result") && (replyData["Result"] != null))
- {
- bool success = false;
- Boolean.TryParse(replyData["Result"].ToString(), out success);
- return success;
- }
- else
- m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: StoreFriend {0} {1} received null response",
- PrincipalID, Friend);
- }
- else
- m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: StoreFriend received null reply");
-
- return false;
-
- }
-
- public bool Delete(string PrincipalID, string Friend)
- {
- Dictionary sendData = new Dictionary();
- sendData["PRINCIPALID"] = PrincipalID.ToString();
- sendData["FRIEND"] = Friend;
- sendData["METHOD"] = "deletefriend_string";
-
- return Delete(sendData, PrincipalID, Friend);
- }
-
- public bool Delete(UUID PrincipalID, string Friend)
- {
- Dictionary sendData = new Dictionary();
- sendData["PRINCIPALID"] = PrincipalID.ToString();
- sendData["FRIEND"] = Friend;
- sendData["METHOD"] = "deletefriend";
-
- return Delete(sendData, PrincipalID.ToString(), Friend);
- }
-
- public bool Delete(Dictionary sendData, string PrincipalID, string Friend)
- {
- string reply = string.Empty;
- string uri = m_ServerURI + "/friends";
- try
- {
- reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData));
- }
- catch (Exception e)
- {
- m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: Exception when contacting friends server at {0}: {1}", uri, e.Message);
- return false;
- }
-
- if (reply != string.Empty)
- {
- Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
-
- if ((replyData != null) && replyData.ContainsKey("Result") && (replyData["Result"] != null))
- {
- bool success = false;
- Boolean.TryParse(replyData["Result"].ToString(), out success);
- return success;
- }
- else
- m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: DeleteFriend {0} {1} received null response",
- PrincipalID, Friend);
- }
- else
- m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: DeleteFriend received null reply");
-
- return false;
- }
-
- #endregion
-
- public Dictionary ToKeyValuePairs(string principalID, string friend, int flags)
- {
- Dictionary result = new Dictionary();
- result["PrincipalID"] = principalID;
- result["Friend"] = friend;
- result["MyFlags"] = flags;
-
- return result;
- }
-
- }
-}
\ No newline at end of file
diff --git a/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs
new file mode 100644
index 0000000..b1dd84e
--- /dev/null
+++ b/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs
@@ -0,0 +1,267 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using log4net;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using Nini.Config;
+using OpenSim.Framework;
+using OpenSim.Framework.Communications;
+using OpenSim.Services.Interfaces;
+using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
+using OpenSim.Server.Base;
+using OpenMetaverse;
+
+namespace OpenSim.Services.Connectors.Friends
+{
+ public class FriendsServicesConnector : IFriendsService
+ {
+ private static readonly ILog m_log =
+ LogManager.GetLogger(
+ MethodBase.GetCurrentMethod().DeclaringType);
+
+ private string m_ServerURI = String.Empty;
+
+ public FriendsServicesConnector()
+ {
+ }
+
+ public FriendsServicesConnector(string serverURI)
+ {
+ m_ServerURI = serverURI.TrimEnd('/');
+ }
+
+ public FriendsServicesConnector(IConfigSource source)
+ {
+ Initialise(source);
+ }
+
+ public virtual void Initialise(IConfigSource source)
+ {
+ IConfig gridConfig = source.Configs["FriendsService"];
+ if (gridConfig == null)
+ {
+ m_log.Error("[FRIENDS SERVICE CONNECTOR]: FriendsService missing from OpenSim.ini");
+ throw new Exception("Friends connector init error");
+ }
+
+ string serviceURI = gridConfig.GetString("FriendsServerURI",
+ String.Empty);
+
+ if (serviceURI == String.Empty)
+ {
+ m_log.Error("[FRIENDS SERVICE CONNECTOR]: No Server URI named in section FriendsService");
+ throw new Exception("Friends connector init error");
+ }
+ m_ServerURI = serviceURI;
+ }
+
+
+ #region IFriendsService
+
+ public FriendInfo[] GetFriends(UUID PrincipalID)
+ {
+ Dictionary sendData = new Dictionary();
+
+ sendData["PRINCIPALID"] = PrincipalID.ToString();
+ sendData["METHOD"] = "getfriends";
+
+ return GetFriends(sendData, PrincipalID.ToString());
+ }
+
+ public FriendInfo[] GetFriends(string PrincipalID)
+ {
+ Dictionary sendData = new Dictionary();
+
+ sendData["PRINCIPALID"] = PrincipalID;
+ sendData["METHOD"] = "getfriends_string";
+
+ return GetFriends(sendData, PrincipalID);
+ }
+
+ protected FriendInfo[] GetFriends(Dictionary sendData, string PrincipalID)
+ {
+ string reqString = ServerUtils.BuildQueryString(sendData);
+ string uri = m_ServerURI + "/friends";
+
+ try
+ {
+ string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
+ if (reply != string.Empty)
+ {
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+
+ if (replyData != null)
+ {
+ if (replyData.ContainsKey("result") && (replyData["result"].ToString().ToLower() == "null"))
+ {
+ return new FriendInfo[0];
+ }
+
+ List finfos = new List();
+ Dictionary.ValueCollection finfosList = replyData.Values;
+ //m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count);
+ foreach (object f in finfosList)
+ {
+ if (f is Dictionary)
+ {
+ FriendInfo finfo = new FriendInfo((Dictionary)f);
+ finfos.Add(finfo);
+ }
+ else
+ m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: GetFriends {0} received invalid response type {1}",
+ PrincipalID, f.GetType());
+ }
+
+ // Success
+ return finfos.ToArray();
+ }
+ else
+ m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: GetFriends {0} received null response",
+ PrincipalID);
+
+ }
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: Exception when contacting friends server at {0}: {1}", uri, e.Message);
+ }
+
+ return new FriendInfo[0];
+
+ }
+
+ public bool StoreFriend(string PrincipalID, string Friend, int flags)
+ {
+
+ Dictionary sendData = ToKeyValuePairs(PrincipalID, Friend, flags);
+
+ sendData["METHOD"] = "storefriend";
+
+ string reply = string.Empty;
+ string uri = m_ServerURI + "/friends";
+ try
+ {
+ reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData));
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: Exception when contacting friends server at {0}: {1}", uri, e.Message);
+ return false;
+ }
+
+ if (reply != string.Empty)
+ {
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+
+ if ((replyData != null) && replyData.ContainsKey("Result") && (replyData["Result"] != null))
+ {
+ bool success = false;
+ Boolean.TryParse(replyData["Result"].ToString(), out success);
+ return success;
+ }
+ else
+ m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: StoreFriend {0} {1} received null response",
+ PrincipalID, Friend);
+ }
+ else
+ m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: StoreFriend received null reply");
+
+ return false;
+
+ }
+
+ public bool Delete(string PrincipalID, string Friend)
+ {
+ Dictionary sendData = new Dictionary();
+ sendData["PRINCIPALID"] = PrincipalID.ToString();
+ sendData["FRIEND"] = Friend;
+ sendData["METHOD"] = "deletefriend_string";
+
+ return Delete(sendData, PrincipalID, Friend);
+ }
+
+ public bool Delete(UUID PrincipalID, string Friend)
+ {
+ Dictionary sendData = new Dictionary();
+ sendData["PRINCIPALID"] = PrincipalID.ToString();
+ sendData["FRIEND"] = Friend;
+ sendData["METHOD"] = "deletefriend";
+
+ return Delete(sendData, PrincipalID.ToString(), Friend);
+ }
+
+ public bool Delete(Dictionary sendData, string PrincipalID, string Friend)
+ {
+ string reply = string.Empty;
+ string uri = m_ServerURI + "/friends";
+ try
+ {
+ reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData));
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: Exception when contacting friends server at {0}: {1}", uri, e.Message);
+ return false;
+ }
+
+ if (reply != string.Empty)
+ {
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+
+ if ((replyData != null) && replyData.ContainsKey("Result") && (replyData["Result"] != null))
+ {
+ bool success = false;
+ Boolean.TryParse(replyData["Result"].ToString(), out success);
+ return success;
+ }
+ else
+ m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: DeleteFriend {0} {1} received null response",
+ PrincipalID, Friend);
+ }
+ else
+ m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: DeleteFriend received null reply");
+
+ return false;
+ }
+
+ #endregion
+
+ public Dictionary ToKeyValuePairs(string principalID, string friend, int flags)
+ {
+ Dictionary result = new Dictionary();
+ result["PrincipalID"] = principalID;
+ result["Friend"] = friend;
+ result["MyFlags"] = flags;
+
+ return result;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
deleted file mode 100644
index 34ed0d7..0000000
--- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
+++ /dev/null
@@ -1,671 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using log4net;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Reflection;
-using Nini.Config;
-using OpenSim.Framework;
-using OpenSim.Framework.Communications;
-using OpenSim.Services.Interfaces;
-using GridRegion = OpenSim.Services.Interfaces.GridRegion;
-using OpenSim.Server.Base;
-using OpenMetaverse;
-
-namespace OpenSim.Services.Connectors
-{
- public class GridServicesConnector : IGridService
- {
- private static readonly ILog m_log =
- LogManager.GetLogger(
- MethodBase.GetCurrentMethod().DeclaringType);
-
- private string m_ServerURI = String.Empty;
-
- public GridServicesConnector()
- {
- }
-
- public GridServicesConnector(string serverURI)
- {
- m_ServerURI = serverURI.TrimEnd('/');
- }
-
- public GridServicesConnector(IConfigSource source)
- {
- Initialise(source);
- }
-
- public virtual void Initialise(IConfigSource source)
- {
- IConfig gridConfig = source.Configs["GridService"];
- if (gridConfig == null)
- {
- m_log.Error("[GRID CONNECTOR]: GridService missing from OpenSim.ini");
- throw new Exception("Grid connector init error");
- }
-
- string serviceURI = gridConfig.GetString("GridServerURI",
- String.Empty);
-
- if (serviceURI == String.Empty)
- {
- m_log.Error("[GRID CONNECTOR]: No Server URI named in section GridService");
- throw new Exception("Grid connector init error");
- }
- m_ServerURI = serviceURI;
- }
-
-
- #region IGridService
-
- public string RegisterRegion(UUID scopeID, GridRegion regionInfo)
- {
- Dictionary rinfo = regionInfo.ToKeyValuePairs();
- Dictionary sendData = new Dictionary();
- foreach (KeyValuePair kvp in rinfo)
- sendData[kvp.Key] = (string)kvp.Value;
-
- sendData["SCOPEID"] = scopeID.ToString();
- sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
- sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
- sendData["METHOD"] = "register";
-
- string reqString = ServerUtils.BuildQueryString(sendData);
- string uri = m_ServerURI + "/grid";
- // m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
- try
- {
- string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
- if (reply != string.Empty)
- {
- Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
-
- if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "success"))
- {
- return String.Empty;
- }
- else if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "failure"))
- {
- m_log.ErrorFormat(
- "[GRID CONNECTOR]: Registration failed: {0} when contacting {1}", replyData["Message"], uri);
-
- return replyData["Message"].ToString();
- }
- else if (!replyData.ContainsKey("Result"))
- {
- m_log.ErrorFormat(
- "[GRID CONNECTOR]: reply data does not contain result field when contacting {0}", uri);
- }
- else
- {
- m_log.ErrorFormat(
- "[GRID CONNECTOR]: unexpected result {0} when contacting {1}", replyData["Result"], uri);
-
- return "Unexpected result " + replyData["Result"].ToString();
- }
- }
- else
- {
- m_log.ErrorFormat(
- "[GRID CONNECTOR]: RegisterRegion received null reply when contacting grid server at {0}", uri);
- }
- }
- catch (Exception e)
- {
- m_log.ErrorFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
- }
-
- return string.Format("Error communicating with the grid service at {0}", uri);
- }
-
- public bool DeregisterRegion(UUID regionID)
- {
- Dictionary sendData = new Dictionary();
-
- sendData["REGIONID"] = regionID.ToString();
-
- sendData["METHOD"] = "deregister";
-
- string uri = m_ServerURI + "/grid";
-
- try
- {
- string reply
- = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData));
-
- if (reply != string.Empty)
- {
- Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
-
- if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success"))
- return true;
- }
- else
- m_log.DebugFormat("[GRID CONNECTOR]: DeregisterRegion received null reply");
- }
- catch (Exception e)
- {
- m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
- }
-
- return false;
- }
-
- public List GetNeighbours(UUID scopeID, UUID regionID)
- {
- Dictionary sendData = new Dictionary();
-
- sendData["SCOPEID"] = scopeID.ToString();
- sendData["REGIONID"] = regionID.ToString();
-
- sendData["METHOD"] = "get_neighbours";
-
- List rinfos = new List();
-
- string reqString = ServerUtils.BuildQueryString(sendData);
- string reply = string.Empty;
- string uri = m_ServerURI + "/grid";
-
- try
- {
- reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
- }
- catch (Exception e)
- {
- m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
- return rinfos;
- }
-
- Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
-
- if (replyData != null)
- {
- Dictionary.ValueCollection rinfosList = replyData.Values;
- //m_log.DebugFormat("[GRID CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count);
- foreach (object r in rinfosList)
- {
- if (r is Dictionary)
- {
- GridRegion rinfo = new GridRegion((Dictionary)r);
- rinfos.Add(rinfo);
- }
- }
- }
- else
- m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received null response",
- scopeID, regionID);
-
- return rinfos;
- }
-
- public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
- {
- Dictionary sendData = new Dictionary();
-
- sendData["SCOPEID"] = scopeID.ToString();
- sendData["REGIONID"] = regionID.ToString();
-
- sendData["METHOD"] = "get_region_by_uuid";
-
- string reply = string.Empty;
- string uri = m_ServerURI + "/grid";
- try
- {
- reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData));
- }
- catch (Exception e)
- {
- m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
- return null;
- }
-
- GridRegion rinfo = null;
-
- if (reply != string.Empty)
- {
- Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
-
- if ((replyData != null) && (replyData["result"] != null))
- {
- if (replyData["result"] is Dictionary)
- rinfo = new GridRegion((Dictionary)replyData["result"]);
- //else
- // m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response",
- // scopeID, regionID);
- }
- else
- m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response",
- scopeID, regionID);
- }
- else
- m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID received null reply");
-
- return rinfo;
- }
-
- public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
- {
- Dictionary sendData = new Dictionary();
-
- sendData["SCOPEID"] = scopeID.ToString();
- sendData["X"] = x.ToString();
- sendData["Y"] = y.ToString();
-
- sendData["METHOD"] = "get_region_by_position";
- string reply = string.Empty;
- string uri = m_ServerURI + "/grid";
- try
- {
- reply = SynchronousRestFormsRequester.MakeRequest("POST",
- uri,
- ServerUtils.BuildQueryString(sendData));
- }
- catch (Exception e)
- {
- m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
- return null;
- }
-
- GridRegion rinfo = null;
- if (reply != string.Empty)
- {
- Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
-
- if ((replyData != null) && (replyData["result"] != null))
- {
- if (replyData["result"] is Dictionary)
- rinfo = new GridRegion((Dictionary)replyData["result"]);
- //else
- // m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received no region",
- // scopeID, x, y);
- }
- else
- m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response",
- scopeID, x, y);
- }
- else
- m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply");
-
- return rinfo;
- }
-
- public GridRegion GetRegionByName(UUID scopeID, string regionName)
- {
- Dictionary sendData = new Dictionary();
-
- sendData["SCOPEID"] = scopeID.ToString();
- sendData["NAME"] = regionName;
-
- sendData["METHOD"] = "get_region_by_name";
- string reply = string.Empty;
- string uri = m_ServerURI + "/grid";
- try
- {
- reply = SynchronousRestFormsRequester.MakeRequest("POST",
- uri,
- ServerUtils.BuildQueryString(sendData));
- }
- catch (Exception e)
- {
- m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
- return null;
- }
-
- GridRegion rinfo = null;
- if (reply != string.Empty)
- {
- Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
-
- if ((replyData != null) && (replyData["result"] != null))
- {
- if (replyData["result"] is Dictionary)
- rinfo = new GridRegion((Dictionary)replyData["result"]);
- }
- else
- m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received null response",
- scopeID, regionName);
- }
- else
- m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByName received null reply");
-
- return rinfo;
- }
-
- public List GetRegionsByName(UUID scopeID, string name, int maxNumber)
- {
- Dictionary sendData = new Dictionary();
-
- sendData["SCOPEID"] = scopeID.ToString();
- sendData["NAME"] = name;
- sendData["MAX"] = maxNumber.ToString();
-
- sendData["METHOD"] = "get_regions_by_name";
- List rinfos = new List();
- string reply = string.Empty;
- string uri = m_ServerURI + "/grid";
- try
- {
- reply = SynchronousRestFormsRequester.MakeRequest("POST",
- uri,
- ServerUtils.BuildQueryString(sendData));
- }
- catch (Exception e)
- {
- m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
- return rinfos;
- }
-
- if (reply != string.Empty)
- {
- Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
-
- if (replyData != null)
- {
- Dictionary.ValueCollection rinfosList = replyData.Values;
- foreach (object r in rinfosList)
- {
- if (r is Dictionary)
- {
- GridRegion rinfo = new GridRegion((Dictionary)r);
- rinfos.Add(rinfo);
- }
- }
- }
- else
- m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received null response",
- scopeID, name, maxNumber);
- }
- else
- m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName received null reply");
-
- return rinfos;
- }
-
- public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
- {
- Dictionary sendData = new Dictionary();
-
- sendData["SCOPEID"] = scopeID.ToString();
- sendData["XMIN"] = xmin.ToString();
- sendData["XMAX"] = xmax.ToString();
- sendData["YMIN"] = ymin.ToString();
- sendData["YMAX"] = ymax.ToString();
-
- sendData["METHOD"] = "get_region_range";
-
- List rinfos = new List();
- string reply = string.Empty;
- string uri = m_ServerURI + "/grid";
-
- try
- {
- reply = SynchronousRestFormsRequester.MakeRequest("POST",
- uri,
- ServerUtils.BuildQueryString(sendData));
-
- //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
- }
- catch (Exception e)
- {
- m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
- return rinfos;
- }
-
- if (reply != string.Empty)
- {
- Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
-
- if (replyData != null)
- {
- Dictionary.ValueCollection rinfosList = replyData.Values;
- foreach (object r in rinfosList)
- {
- if (r is Dictionary)
- {
- GridRegion rinfo = new GridRegion((Dictionary)r);
- rinfos.Add(rinfo);
- }
- }
- }
- else
- m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received null response",
- scopeID, xmin, xmax, ymin, ymax);
- }
- else
- m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange received null reply");
-
- return rinfos;
- }
-
- public List GetDefaultRegions(UUID scopeID)
- {
- Dictionary sendData = new Dictionary();
-
- sendData["SCOPEID"] = scopeID.ToString();
-
- sendData["METHOD"] = "get_default_regions";
-
- List rinfos = new List();
- string reply = string.Empty;
- string uri = m_ServerURI + "/grid";
- try
- {
- reply = SynchronousRestFormsRequester.MakeRequest("POST",
- uri,
- ServerUtils.BuildQueryString(sendData));
-
- //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
- }
- catch (Exception e)
- {
- m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
- return rinfos;
- }
-
- if (reply != string.Empty)
- {
- Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
-
- if (replyData != null)
- {
- Dictionary.ValueCollection rinfosList = replyData.Values;
- foreach (object r in rinfosList)
- {
- if (r is Dictionary)
- {
- GridRegion rinfo = new GridRegion((Dictionary)r);
- rinfos.Add(rinfo);
- }
- }
- }
- else
- m_log.DebugFormat("[GRID CONNECTOR]: GetDefaultRegions {0} received null response",
- scopeID);
- }
- else
- m_log.DebugFormat("[GRID CONNECTOR]: GetDefaultRegions received null reply");
-
- return rinfos;
- }
-
- public List GetFallbackRegions(UUID scopeID, int x, int y)
- {
- Dictionary sendData = new Dictionary();
-
- sendData["SCOPEID"] = scopeID.ToString();
- sendData["X"] = x.ToString();
- sendData["Y"] = y.ToString();
-
- sendData["METHOD"] = "get_fallback_regions";
-
- List rinfos = new List();
- string reply = string.Empty;
- string uri = m_ServerURI + "/grid";
- try
- {
- reply = SynchronousRestFormsRequester.MakeRequest("POST",
- uri,
- ServerUtils.BuildQueryString(sendData));
-
- //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
- }
- catch (Exception e)
- {
- m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
- return rinfos;
- }
-
- if (reply != string.Empty)
- {
- Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
-
- if (replyData != null)
- {
- Dictionary.ValueCollection rinfosList = replyData.Values;
- foreach (object r in rinfosList)
- {
- if (r is Dictionary)
- {
- GridRegion rinfo = new GridRegion((Dictionary)r);
- rinfos.Add(rinfo);
- }
- }
- }
- else
- m_log.DebugFormat("[GRID CONNECTOR]: GetFallbackRegions {0}, {1}-{2} received null response",
- scopeID, x, y);
- }
- else
- m_log.DebugFormat("[GRID CONNECTOR]: GetFallbackRegions received null reply");
-
- return rinfos;
- }
-
- public List GetHyperlinks(UUID scopeID)
- {
- Dictionary sendData = new Dictionary();
-
- sendData["SCOPEID"] = scopeID.ToString();
-
- sendData["METHOD"] = "get_hyperlinks";
-
- List rinfos = new List();
- string reply = string.Empty;
- string uri = m_ServerURI + "/grid";
- try
- {
- reply = SynchronousRestFormsRequester.MakeRequest("POST",
- uri,
- ServerUtils.BuildQueryString(sendData));
-
- //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
- }
- catch (Exception e)
- {
- m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
- return rinfos;
- }
-
- if (reply != string.Empty)
- {
- Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
-
- if (replyData != null)
- {
- Dictionary.ValueCollection rinfosList = replyData.Values;
- foreach (object r in rinfosList)
- {
- if (r is Dictionary)
- {
- GridRegion rinfo = new GridRegion((Dictionary)r);
- rinfos.Add(rinfo);
- }
- }
- }
- else
- m_log.DebugFormat("[GRID CONNECTOR]: GetHyperlinks {0} received null response",
- scopeID);
- }
- else
- m_log.DebugFormat("[GRID CONNECTOR]: GetHyperlinks received null reply");
-
- return rinfos;
- }
-
- public int GetRegionFlags(UUID scopeID, UUID regionID)
- {
- Dictionary sendData = new Dictionary();
-
- sendData["SCOPEID"] = scopeID.ToString();
- sendData["REGIONID"] = regionID.ToString();
-
- sendData["METHOD"] = "get_region_flags";
-
- string reply = string.Empty;
- string uri = m_ServerURI + "/grid";
- try
- {
- reply = SynchronousRestFormsRequester.MakeRequest("POST",
- uri,
- ServerUtils.BuildQueryString(sendData));
- }
- catch (Exception e)
- {
- m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
- return -1;
- }
-
- int flags = -1;
-
- if (reply != string.Empty)
- {
- Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
-
- if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null))
- {
- Int32.TryParse((string)replyData["result"], out flags);
- //else
- // m_log.DebugFormat("[GRID CONNECTOR]: GetRegionFlags {0}, {1} received wrong type {2}",
- // scopeID, regionID, replyData["result"].GetType());
- }
- else
- m_log.DebugFormat("[GRID CONNECTOR]: GetRegionFlags {0}, {1} received null response",
- scopeID, regionID);
- }
- else
- m_log.DebugFormat("[GRID CONNECTOR]: GetRegionFlags received null reply");
-
- return flags;
- }
-
- #endregion
-
- }
-}
diff --git a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs
new file mode 100644
index 0000000..34ed0d7
--- /dev/null
+++ b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs
@@ -0,0 +1,671 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using log4net;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using Nini.Config;
+using OpenSim.Framework;
+using OpenSim.Framework.Communications;
+using OpenSim.Services.Interfaces;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
+using OpenSim.Server.Base;
+using OpenMetaverse;
+
+namespace OpenSim.Services.Connectors
+{
+ public class GridServicesConnector : IGridService
+ {
+ private static readonly ILog m_log =
+ LogManager.GetLogger(
+ MethodBase.GetCurrentMethod().DeclaringType);
+
+ private string m_ServerURI = String.Empty;
+
+ public GridServicesConnector()
+ {
+ }
+
+ public GridServicesConnector(string serverURI)
+ {
+ m_ServerURI = serverURI.TrimEnd('/');
+ }
+
+ public GridServicesConnector(IConfigSource source)
+ {
+ Initialise(source);
+ }
+
+ public virtual void Initialise(IConfigSource source)
+ {
+ IConfig gridConfig = source.Configs["GridService"];
+ if (gridConfig == null)
+ {
+ m_log.Error("[GRID CONNECTOR]: GridService missing from OpenSim.ini");
+ throw new Exception("Grid connector init error");
+ }
+
+ string serviceURI = gridConfig.GetString("GridServerURI",
+ String.Empty);
+
+ if (serviceURI == String.Empty)
+ {
+ m_log.Error("[GRID CONNECTOR]: No Server URI named in section GridService");
+ throw new Exception("Grid connector init error");
+ }
+ m_ServerURI = serviceURI;
+ }
+
+
+ #region IGridService
+
+ public string RegisterRegion(UUID scopeID, GridRegion regionInfo)
+ {
+ Dictionary rinfo = regionInfo.ToKeyValuePairs();
+ Dictionary sendData = new Dictionary();
+ foreach (KeyValuePair kvp in rinfo)
+ sendData[kvp.Key] = (string)kvp.Value;
+
+ sendData["SCOPEID"] = scopeID.ToString();
+ sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
+ sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
+ sendData["METHOD"] = "register";
+
+ string reqString = ServerUtils.BuildQueryString(sendData);
+ string uri = m_ServerURI + "/grid";
+ // m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
+ try
+ {
+ string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
+ if (reply != string.Empty)
+ {
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+
+ if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "success"))
+ {
+ return String.Empty;
+ }
+ else if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "failure"))
+ {
+ m_log.ErrorFormat(
+ "[GRID CONNECTOR]: Registration failed: {0} when contacting {1}", replyData["Message"], uri);
+
+ return replyData["Message"].ToString();
+ }
+ else if (!replyData.ContainsKey("Result"))
+ {
+ m_log.ErrorFormat(
+ "[GRID CONNECTOR]: reply data does not contain result field when contacting {0}", uri);
+ }
+ else
+ {
+ m_log.ErrorFormat(
+ "[GRID CONNECTOR]: unexpected result {0} when contacting {1}", replyData["Result"], uri);
+
+ return "Unexpected result " + replyData["Result"].ToString();
+ }
+ }
+ else
+ {
+ m_log.ErrorFormat(
+ "[GRID CONNECTOR]: RegisterRegion received null reply when contacting grid server at {0}", uri);
+ }
+ }
+ catch (Exception e)
+ {
+ m_log.ErrorFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
+ }
+
+ return string.Format("Error communicating with the grid service at {0}", uri);
+ }
+
+ public bool DeregisterRegion(UUID regionID)
+ {
+ Dictionary sendData = new Dictionary();
+
+ sendData["REGIONID"] = regionID.ToString();
+
+ sendData["METHOD"] = "deregister";
+
+ string uri = m_ServerURI + "/grid";
+
+ try
+ {
+ string reply
+ = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData));
+
+ if (reply != string.Empty)
+ {
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+
+ if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success"))
+ return true;
+ }
+ else
+ m_log.DebugFormat("[GRID CONNECTOR]: DeregisterRegion received null reply");
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
+ }
+
+ return false;
+ }
+
+ public List GetNeighbours(UUID scopeID, UUID regionID)
+ {
+ Dictionary sendData = new Dictionary();
+
+ sendData["SCOPEID"] = scopeID.ToString();
+ sendData["REGIONID"] = regionID.ToString();
+
+ sendData["METHOD"] = "get_neighbours";
+
+ List rinfos = new List();
+
+ string reqString = ServerUtils.BuildQueryString(sendData);
+ string reply = string.Empty;
+ string uri = m_ServerURI + "/grid";
+
+ try
+ {
+ reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
+ return rinfos;
+ }
+
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+
+ if (replyData != null)
+ {
+ Dictionary.ValueCollection rinfosList = replyData.Values;
+ //m_log.DebugFormat("[GRID CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count);
+ foreach (object r in rinfosList)
+ {
+ if (r is Dictionary)
+ {
+ GridRegion rinfo = new GridRegion((Dictionary)r);
+ rinfos.Add(rinfo);
+ }
+ }
+ }
+ else
+ m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received null response",
+ scopeID, regionID);
+
+ return rinfos;
+ }
+
+ public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
+ {
+ Dictionary sendData = new Dictionary();
+
+ sendData["SCOPEID"] = scopeID.ToString();
+ sendData["REGIONID"] = regionID.ToString();
+
+ sendData["METHOD"] = "get_region_by_uuid";
+
+ string reply = string.Empty;
+ string uri = m_ServerURI + "/grid";
+ try
+ {
+ reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData));
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
+ return null;
+ }
+
+ GridRegion rinfo = null;
+
+ if (reply != string.Empty)
+ {
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+
+ if ((replyData != null) && (replyData["result"] != null))
+ {
+ if (replyData["result"] is Dictionary)
+ rinfo = new GridRegion((Dictionary)replyData["result"]);
+ //else
+ // m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response",
+ // scopeID, regionID);
+ }
+ else
+ m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response",
+ scopeID, regionID);
+ }
+ else
+ m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID received null reply");
+
+ return rinfo;
+ }
+
+ public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
+ {
+ Dictionary sendData = new Dictionary();
+
+ sendData["SCOPEID"] = scopeID.ToString();
+ sendData["X"] = x.ToString();
+ sendData["Y"] = y.ToString();
+
+ sendData["METHOD"] = "get_region_by_position";
+ string reply = string.Empty;
+ string uri = m_ServerURI + "/grid";
+ try
+ {
+ reply = SynchronousRestFormsRequester.MakeRequest("POST",
+ uri,
+ ServerUtils.BuildQueryString(sendData));
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
+ return null;
+ }
+
+ GridRegion rinfo = null;
+ if (reply != string.Empty)
+ {
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+
+ if ((replyData != null) && (replyData["result"] != null))
+ {
+ if (replyData["result"] is Dictionary)
+ rinfo = new GridRegion((Dictionary)replyData["result"]);
+ //else
+ // m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received no region",
+ // scopeID, x, y);
+ }
+ else
+ m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response",
+ scopeID, x, y);
+ }
+ else
+ m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply");
+
+ return rinfo;
+ }
+
+ public GridRegion GetRegionByName(UUID scopeID, string regionName)
+ {
+ Dictionary sendData = new Dictionary();
+
+ sendData["SCOPEID"] = scopeID.ToString();
+ sendData["NAME"] = regionName;
+
+ sendData["METHOD"] = "get_region_by_name";
+ string reply = string.Empty;
+ string uri = m_ServerURI + "/grid";
+ try
+ {
+ reply = SynchronousRestFormsRequester.MakeRequest("POST",
+ uri,
+ ServerUtils.BuildQueryString(sendData));
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
+ return null;
+ }
+
+ GridRegion rinfo = null;
+ if (reply != string.Empty)
+ {
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+
+ if ((replyData != null) && (replyData["result"] != null))
+ {
+ if (replyData["result"] is Dictionary)
+ rinfo = new GridRegion((Dictionary)replyData["result"]);
+ }
+ else
+ m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received null response",
+ scopeID, regionName);
+ }
+ else
+ m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByName received null reply");
+
+ return rinfo;
+ }
+
+ public List GetRegionsByName(UUID scopeID, string name, int maxNumber)
+ {
+ Dictionary sendData = new Dictionary();
+
+ sendData["SCOPEID"] = scopeID.ToString();
+ sendData["NAME"] = name;
+ sendData["MAX"] = maxNumber.ToString();
+
+ sendData["METHOD"] = "get_regions_by_name";
+ List rinfos = new List();
+ string reply = string.Empty;
+ string uri = m_ServerURI + "/grid";
+ try
+ {
+ reply = SynchronousRestFormsRequester.MakeRequest("POST",
+ uri,
+ ServerUtils.BuildQueryString(sendData));
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
+ return rinfos;
+ }
+
+ if (reply != string.Empty)
+ {
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+
+ if (replyData != null)
+ {
+ Dictionary.ValueCollection rinfosList = replyData.Values;
+ foreach (object r in rinfosList)
+ {
+ if (r is Dictionary)
+ {
+ GridRegion rinfo = new GridRegion((Dictionary)r);
+ rinfos.Add(rinfo);
+ }
+ }
+ }
+ else
+ m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received null response",
+ scopeID, name, maxNumber);
+ }
+ else
+ m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName received null reply");
+
+ return rinfos;
+ }
+
+ public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
+ {
+ Dictionary sendData = new Dictionary();
+
+ sendData["SCOPEID"] = scopeID.ToString();
+ sendData["XMIN"] = xmin.ToString();
+ sendData["XMAX"] = xmax.ToString();
+ sendData["YMIN"] = ymin.ToString();
+ sendData["YMAX"] = ymax.ToString();
+
+ sendData["METHOD"] = "get_region_range";
+
+ List rinfos = new List();
+ string reply = string.Empty;
+ string uri = m_ServerURI + "/grid";
+
+ try
+ {
+ reply = SynchronousRestFormsRequester.MakeRequest("POST",
+ uri,
+ ServerUtils.BuildQueryString(sendData));
+
+ //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
+ return rinfos;
+ }
+
+ if (reply != string.Empty)
+ {
+ Dictionary replyData = ServerUtils.ParseXmlResponse(reply);
+
+ if (replyData != null)
+ {
+ Dictionary