Merge branch 'integration' of /home/opensim/var/repo/opensim
Conflicts: OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.csintegration
commit
28b4beead7
|
@ -125,7 +125,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
|
||||||
bool changed = m_openSim.PopulateRegionEstateInfo(regionsToLoad[i]);
|
bool changed = m_openSim.PopulateRegionEstateInfo(regionsToLoad[i]);
|
||||||
m_openSim.CreateRegion(regionsToLoad[i], true, out scene);
|
m_openSim.CreateRegion(regionsToLoad[i], true, out scene);
|
||||||
if (changed)
|
if (changed)
|
||||||
regionsToLoad[i].EstateSettings.Save();
|
regionsToLoad[i].EstateSettings.Save();
|
||||||
|
|
||||||
if (scene != null)
|
if (scene != null)
|
||||||
{
|
{
|
||||||
|
@ -137,6 +137,10 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//[TODO]: Temporary fix for an issue after the mono-addis upgrade
|
||||||
|
// PostInilise can fire before the region is loaded, so need to
|
||||||
|
// track down the cause of that
|
||||||
|
Thread.Sleep(300);
|
||||||
m_openSim.ModuleLoader.PostInitialise();
|
m_openSim.ModuleLoader.PostInitialise();
|
||||||
m_openSim.ModuleLoader.ClearCache();
|
m_openSim.ModuleLoader.ClearCache();
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ namespace OpenSim.Data
|
||||||
bool Store(PresenceData data);
|
bool Store(PresenceData data);
|
||||||
|
|
||||||
PresenceData Get(UUID sessionID);
|
PresenceData Get(UUID sessionID);
|
||||||
|
PresenceData Verify(UUID s_sessionID);
|
||||||
void LogoutRegionAgents(UUID regionID);
|
void LogoutRegionAgents(UUID regionID);
|
||||||
bool ReportAgent(UUID sessionID, UUID regionID);
|
bool ReportAgent(UUID sessionID, UUID regionID);
|
||||||
PresenceData[] Get(string field, string data);
|
PresenceData[] Get(string field, string data);
|
||||||
|
|
|
@ -61,6 +61,17 @@ namespace OpenSim.Data.MSSQL
|
||||||
return ret[0];
|
return ret[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PresenceData Verify(UUID s_sessionID)
|
||||||
|
{
|
||||||
|
PresenceData[] ret = Get("SecureSessionID",
|
||||||
|
s_sessionID.ToString());
|
||||||
|
|
||||||
|
if (ret.Length == 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return ret[0];
|
||||||
|
}
|
||||||
|
|
||||||
public void LogoutRegionAgents(UUID regionID)
|
public void LogoutRegionAgents(UUID regionID)
|
||||||
{
|
{
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||||
|
|
|
@ -61,6 +61,17 @@ namespace OpenSim.Data.MySQL
|
||||||
return ret[0];
|
return ret[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PresenceData Verify(UUID s_sessionID)
|
||||||
|
{
|
||||||
|
PresenceData[] ret = Get("SecureSessionID",
|
||||||
|
s_sessionID.ToString());
|
||||||
|
|
||||||
|
if (ret.Length == 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return ret[0];
|
||||||
|
}
|
||||||
|
|
||||||
public void LogoutRegionAgents(UUID regionID)
|
public void LogoutRegionAgents(UUID regionID)
|
||||||
{
|
{
|
||||||
using (MySqlCommand cmd = new MySqlCommand())
|
using (MySqlCommand cmd = new MySqlCommand())
|
||||||
|
|
|
@ -79,6 +79,19 @@ namespace OpenSim.Data.Null
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PresenceData Verify(UUID s_sessionID)
|
||||||
|
{
|
||||||
|
if (Instance != this)
|
||||||
|
return Instance.Verify(s_sessionID);
|
||||||
|
|
||||||
|
if (m_presenceData.ContainsKey(s_sessionID))
|
||||||
|
{
|
||||||
|
return m_presenceData[s_sessionID];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void LogoutRegionAgents(UUID regionID)
|
public void LogoutRegionAgents(UUID regionID)
|
||||||
{
|
{
|
||||||
if (Instance != this)
|
if (Instance != this)
|
||||||
|
|
|
@ -658,14 +658,9 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "R":
|
case "R":
|
||||||
// We need to place this newFont inside its own context so that the .NET compiler
|
// Font newFont = new Font(myFont, FontStyle.Regular);
|
||||||
// doesn't complain about a redefinition of an existing newFont, even though there is none
|
myFont.Dispose();
|
||||||
// The mono compiler doesn't produce this error.
|
myFont = new Font(myFont, FontStyle.Regular);
|
||||||
{
|
|
||||||
Font newFont = new Font(myFont, FontStyle.Regular);
|
|
||||||
myFont.Dispose();
|
|
||||||
myFont = newFont;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,6 +193,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
|
||||||
return m_PresenceService.GetAgents(userIDs);
|
return m_PresenceService.GetAgents(userIDs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PresenceInfo VerifyAgent(UUID s_sessionID)
|
||||||
|
{
|
||||||
|
return m_PresenceService.VerifyAgent(s_sessionID);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,6 +153,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
|
||||||
return m_RemoteConnector.GetAgents(userIDs);
|
return m_RemoteConnector.GetAgents(userIDs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PresenceInfo VerifyAgent(UUID sessionID)
|
||||||
|
{
|
||||||
|
return m_RemoteConnector.VerifyAgent(sessionID);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ using System.Collections.Generic;
|
||||||
using log4net;
|
using log4net;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
|
using OpenMetaverse.StructuredData;
|
||||||
|
|
||||||
namespace OpenSim.Server.Base
|
namespace OpenSim.Server.Base
|
||||||
{
|
{
|
||||||
|
@ -333,5 +334,36 @@ namespace OpenSim.Server.Base
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool ParseStringToOSDMap(string input, out OSDMap map)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
map = null;
|
||||||
|
OSD tmpbuff = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tmpbuff = OSDParser.DeserializeJson(input);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
m_log.DebugFormat("[ServerUtils]: Parse Caught Error Deserializei {0} ", input);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (tmpbuff.Type == OSDType.Map)
|
||||||
|
{
|
||||||
|
map = (OSDMap)tmpbuff;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (NullReferenceException e)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat("[ServerUtils]: exception on ParseStringToJson {0}", e.Message);
|
||||||
|
map = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
* 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 System;
|
||||||
|
using Nini.Config;
|
||||||
|
using OpenSim.Server.Base;
|
||||||
|
using OpenSim.Services.Interfaces;
|
||||||
|
using OpenSim.Framework.Servers.HttpServer;
|
||||||
|
using OpenSim.Server.Handlers.Base;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
|
||||||
|
|
||||||
|
namespace OpenSim.Server.Handlers.Integration
|
||||||
|
{
|
||||||
|
public class IntegrationServiceConnector : ServiceConnector
|
||||||
|
{
|
||||||
|
|
||||||
|
private IIntegrationService m_IntegrationService;
|
||||||
|
private string m_ConfigName = "IntegrationService";
|
||||||
|
|
||||||
|
public IntegrationServiceConnector(IConfigSource config, IHttpServer server, string configName) :
|
||||||
|
base(config, server, configName)
|
||||||
|
{
|
||||||
|
IConfig serverConfig = config.Configs[m_ConfigName];
|
||||||
|
if (serverConfig == null)
|
||||||
|
throw new Exception(String.Format("No section {0} in config file", m_ConfigName));
|
||||||
|
|
||||||
|
string service = serverConfig.GetString("LocalServiceModule",
|
||||||
|
String.Empty);
|
||||||
|
|
||||||
|
if (service == String.Empty)
|
||||||
|
throw new Exception("No LocalServiceModule in config file");
|
||||||
|
|
||||||
|
Object[] args = new Object[] { config, server };
|
||||||
|
m_IntegrationService = ServerUtils.LoadPlugin<IIntegrationService>(service, args);
|
||||||
|
|
||||||
|
server.AddStreamHandler(new IntegrationServerHandler(m_IntegrationService));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,234 @@
|
||||||
|
/*
|
||||||
|
* 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 OpenSim.Server.Base;
|
||||||
|
using OpenSim.Services.Interfaces;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
using OpenSim.Framework.Servers.HttpServer;
|
||||||
|
using OpenMetaverse;
|
||||||
|
using OpenMetaverse.StructuredData;
|
||||||
|
using log4net;
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace OpenSim.Server.Handlers.Integration
|
||||||
|
{
|
||||||
|
public class IntegrationServerHandler : BaseStreamHandler
|
||||||
|
{
|
||||||
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
private IIntegrationService m_IntegrationService;
|
||||||
|
|
||||||
|
public IntegrationServerHandler(IIntegrationService service) :
|
||||||
|
base("POST", "/integration")
|
||||||
|
{
|
||||||
|
m_IntegrationService = service;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte[] Handle(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||||
|
{
|
||||||
|
StreamReader sr = new StreamReader(requestData);
|
||||||
|
string body = sr.ReadToEnd();
|
||||||
|
sr.Close();
|
||||||
|
body = body.Trim();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
OSDMap request = null;
|
||||||
|
if (ServerUtils.ParseStringToOSDMap(body, out request) == false)
|
||||||
|
{
|
||||||
|
return FailureResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!request.ContainsKey("command"))
|
||||||
|
{
|
||||||
|
return FailureResult("Error, no command defined!");
|
||||||
|
}
|
||||||
|
|
||||||
|
string command = request["command"].AsString();
|
||||||
|
|
||||||
|
switch (command)
|
||||||
|
{
|
||||||
|
case "list_plugins":
|
||||||
|
return HandleListPlugins(request);
|
||||||
|
|
||||||
|
case "list_available":
|
||||||
|
return HandleListAvailablePlugins(request);
|
||||||
|
|
||||||
|
case "show_info":
|
||||||
|
return HandlePluginInfo(request);
|
||||||
|
|
||||||
|
case "install_plugin":
|
||||||
|
return HandleInstallPlugin(request);
|
||||||
|
|
||||||
|
case "uninstall_plugin":
|
||||||
|
return HandleUnInstallPlugin(request);
|
||||||
|
|
||||||
|
case "enable_plugin":
|
||||||
|
return HandleEnablePlugin(request);
|
||||||
|
|
||||||
|
case "disable_plugin":
|
||||||
|
return HandleDisblePlugin(request);
|
||||||
|
|
||||||
|
case "plugin_info":
|
||||||
|
return HandlePluginInfo(request);
|
||||||
|
|
||||||
|
case "list_repos":
|
||||||
|
return HandleListRepositories(request);
|
||||||
|
|
||||||
|
case "add_repo":
|
||||||
|
return HandleAddRepository(request);
|
||||||
|
|
||||||
|
case "remove_repo":
|
||||||
|
return HandleRemoveRepository(request);
|
||||||
|
|
||||||
|
case "enable_repo":
|
||||||
|
return HandleEnablePlugin(request);
|
||||||
|
|
||||||
|
case "disable_repo":
|
||||||
|
return HandleDisableRepository(request);
|
||||||
|
|
||||||
|
default:
|
||||||
|
m_log.DebugFormat(
|
||||||
|
"[INTEGRATION HANDLER]: unknown method {0} request {1}",
|
||||||
|
command.Length,
|
||||||
|
command
|
||||||
|
);
|
||||||
|
return FailureResult("IntegrationHandler: Unrecognized method requested!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.DebugFormat("[INTEGRATION HANDLER]: Exception {0}", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return FailureResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
#region web handlers
|
||||||
|
// List installed plugins
|
||||||
|
private byte[] HandleListPlugins(OSDMap request)
|
||||||
|
{
|
||||||
|
return m_IntegrationService.HandleWebListPlugins(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show plugin info
|
||||||
|
private byte[] HandlePluginInfo(OSDMap request)
|
||||||
|
{
|
||||||
|
return m_IntegrationService.HandleWebPluginInfo(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable plugin
|
||||||
|
private byte[] HandleEnablePlugin(OSDMap request)
|
||||||
|
{
|
||||||
|
return m_IntegrationService.HandleWebEnablePlugin(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable plugin
|
||||||
|
private byte[] HandleDisblePlugin(OSDMap request)
|
||||||
|
{
|
||||||
|
return m_IntegrationService.HandleWebDisablePlugin(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Install plugin
|
||||||
|
public byte[] HandleInstallPlugin(OSDMap request)
|
||||||
|
{
|
||||||
|
return m_IntegrationService.HandleWebInstallPlugin(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Uninstall plugin
|
||||||
|
public byte[] HandleUnInstallPlugin(OSDMap request)
|
||||||
|
{
|
||||||
|
return m_IntegrationService.HandleWebUnInstallPlugin(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
// List available plugins
|
||||||
|
public byte[] HandleListAvailablePlugins(OSDMap request)
|
||||||
|
{
|
||||||
|
return m_IntegrationService.HandleWebListAvailablePlugins(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
// List repositories
|
||||||
|
public byte[] HandleListRepositories(OSDMap request)
|
||||||
|
{
|
||||||
|
return m_IntegrationService.HandleWebListRepositories(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add repository
|
||||||
|
public byte[] HandleAddRepository(OSDMap request)
|
||||||
|
{
|
||||||
|
return m_IntegrationService.HandleWebAddRepository(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove repository
|
||||||
|
public byte[] HandleRemoveRepository(OSDMap request)
|
||||||
|
{
|
||||||
|
return m_IntegrationService.HandleWebRemoveRepositroy(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable repository
|
||||||
|
public byte[] HandleEnableRepository(OSDMap request)
|
||||||
|
{
|
||||||
|
return m_IntegrationService.HandleEnableRepository(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable repository
|
||||||
|
public byte[] HandleDisableRepository(OSDMap request)
|
||||||
|
{
|
||||||
|
return m_IntegrationService.HandleWebDisableRepository(request);
|
||||||
|
}
|
||||||
|
#endregion web handlers
|
||||||
|
|
||||||
|
#region utility
|
||||||
|
// These are in IntegrationUtils.cs for plugins
|
||||||
|
private byte[] FailureResult()
|
||||||
|
{
|
||||||
|
return FailureResult(String.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
private byte[] FailureResult(string msg)
|
||||||
|
{
|
||||||
|
OSDMap doc = new OSDMap(2);
|
||||||
|
doc["Result"] = OSD.FromString("Failure");
|
||||||
|
doc["Message"] = OSD.FromString(msg);
|
||||||
|
|
||||||
|
return DocToBytes(doc);
|
||||||
|
}
|
||||||
|
|
||||||
|
private byte[] DocToBytes(OSDMap doc)
|
||||||
|
{
|
||||||
|
return Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(doc));
|
||||||
|
}
|
||||||
|
#endregion utility
|
||||||
|
}
|
||||||
|
}
|
|
@ -41,6 +41,7 @@ using OpenSim.Services.Interfaces;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Servers.HttpServer;
|
using OpenSim.Framework.Servers.HttpServer;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
|
using OpenMetaverse.StructuredData;
|
||||||
|
|
||||||
namespace OpenSim.Server.Handlers.Presence
|
namespace OpenSim.Server.Handlers.Presence
|
||||||
{
|
{
|
||||||
|
|
|
@ -371,6 +371,49 @@ namespace OpenSim.Services.Connectors
|
||||||
return rinfos.ToArray();
|
return rinfos.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PresenceInfo VerifyAgent(UUID s_sessionID)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> sendData = new Dictionary<string, object>();
|
||||||
|
//sendData["SCOPEID"] = scopeID.ToString();
|
||||||
|
sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
|
||||||
|
sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
|
||||||
|
sendData["METHOD"] = "verifyagent";
|
||||||
|
|
||||||
|
sendData["SecureSessionID"] = s_sessionID.ToString();
|
||||||
|
|
||||||
|
string reply = string.Empty;
|
||||||
|
string reqString = ServerUtils.BuildQueryString(sendData);
|
||||||
|
string uri = m_ServerURI + "/presence";
|
||||||
|
// m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
reply = SynchronousRestFormsRequester.MakeRequest("POST",
|
||||||
|
uri,
|
||||||
|
reqString);
|
||||||
|
if (reply == null || (reply != null && reply == string.Empty))
|
||||||
|
{
|
||||||
|
m_log.DebugFormat("[PRESENCE CONNECTOR]: VerifyAgent received null or empty reply");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
|
||||||
|
PresenceInfo pinfo = null;
|
||||||
|
|
||||||
|
if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null))
|
||||||
|
{
|
||||||
|
if (replyData["result"] is Dictionary<string, object>)
|
||||||
|
{
|
||||||
|
pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pinfo;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
@ -260,6 +260,12 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PresenceInfo VerifyAgent(UUID s_sessionID)
|
||||||
|
{
|
||||||
|
// Not implemented
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
|
public bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
|
||||||
{
|
{
|
||||||
// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Logging out user " + userID);
|
// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Logging out user " + userID);
|
||||||
|
|
|
@ -0,0 +1,458 @@
|
||||||
|
/*
|
||||||
|
* 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 System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Linq;
|
||||||
|
using OpenSim.Server.Base;
|
||||||
|
using OpenSim.Services.Interfaces;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
using OpenSim.Framework.Servers.HttpServer;
|
||||||
|
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
||||||
|
using OpenMetaverse;
|
||||||
|
using OpenMetaverse.StructuredData;
|
||||||
|
using Nini.Config;
|
||||||
|
using log4net;
|
||||||
|
using Mono.Addins;
|
||||||
|
using Ux = OpenSim.Services.IntegrationService.IntegrationUtils;
|
||||||
|
|
||||||
|
// ****[ Robust ] Keep the core services here and rebrand it as a more generic
|
||||||
|
// ****[ Robust ] service for use in buthe OpenSim.exe and Robust.exe
|
||||||
|
//
|
||||||
|
namespace OpenSim.Services.IntegrationService
|
||||||
|
{
|
||||||
|
public class IntegrationService : IntegrationServiceBase, IIntegrationService
|
||||||
|
{
|
||||||
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
public IntegrationService(IConfigSource config, IHttpServer server)
|
||||||
|
: base(config, server)
|
||||||
|
{
|
||||||
|
m_log.DebugFormat("[INTEGRATION SERVICE]: Loaded");
|
||||||
|
|
||||||
|
// Add commands to the console
|
||||||
|
if (MainConsole.Instance != null)
|
||||||
|
{
|
||||||
|
AddConsoleCommands();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ****[ Robust ] We have console commands to manage the repositories and modules.
|
||||||
|
// ****[ Robust ] We can add/remove/enable/disable repositories and modules
|
||||||
|
// ****[ Robust ] We can query repositories for available modules and updates
|
||||||
|
// ****[ Robust ] The manager needs to be moved to OpenSim.Framework so we can
|
||||||
|
// ****[ Robust ] use it to complete the region module loader
|
||||||
|
//
|
||||||
|
// Our console commands
|
||||||
|
private void AddConsoleCommands()
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||||
|
"install", "install \"plugin name\"", "Install plugin from repository",
|
||||||
|
HandleConsoleInstallPlugin);
|
||||||
|
|
||||||
|
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||||
|
"uninstall", "uninstall \"plugin name\"", "Remove plugin from repository",
|
||||||
|
HandleConsoleUnInstallPlugin);
|
||||||
|
|
||||||
|
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||||
|
"check installed", "check installed \"plugin name=\"","Check installed plugin",
|
||||||
|
HandleConsoleCheckInstalledPlugin);
|
||||||
|
|
||||||
|
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||||
|
"list installed", "list installed \"plugin name=\"","List install plugins",
|
||||||
|
HandleConsoleListInstalledPlugin);
|
||||||
|
|
||||||
|
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||||
|
"list available", "list available \"plugin name=\"","List available plugins",
|
||||||
|
HandleConsoleListAvailablePlugin);
|
||||||
|
|
||||||
|
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||||
|
"list updates", "list updates","List availble updates",
|
||||||
|
HandleConsoleListUpdates);
|
||||||
|
|
||||||
|
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||||
|
"update", "update \"plugin name=\"","Update the plugin",
|
||||||
|
HandleConsoleUpdatePlugin);
|
||||||
|
|
||||||
|
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||||
|
"add repo", "add repo \"url\"","Add repository",
|
||||||
|
HandleConsoleAddRepo);
|
||||||
|
|
||||||
|
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||||
|
"get repo", "get repo \"url\"", "Sync with a registered repository",
|
||||||
|
HandleConsoleGetRepo);
|
||||||
|
|
||||||
|
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||||
|
"remove repo", "remove repo \"[url | index]\"","Remove registered repository",
|
||||||
|
HandleConsoleRemoveRepo);
|
||||||
|
|
||||||
|
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||||
|
"enable repo", "enable repo \"[url | index]\"","Enable registered repository",
|
||||||
|
HandleConsoleEnableRepo);
|
||||||
|
|
||||||
|
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||||
|
"disable repo", "disable repo \"[url | index]\"","Disable registered repository",
|
||||||
|
HandleConsoleDisableRepo);
|
||||||
|
|
||||||
|
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||||
|
"list repos", "list repos","List registered repositories",
|
||||||
|
HandleConsoleListRepos);
|
||||||
|
|
||||||
|
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||||
|
"show info", "show info \"plugin name\"","Show detailed information for plugin",
|
||||||
|
HandleConsoleShowAddinInfo);
|
||||||
|
|
||||||
|
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||||
|
"disable plugin", "disable plugin \"plugin name\"","disable the plugin",
|
||||||
|
HandleConsoleDisablePlugin);
|
||||||
|
|
||||||
|
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||||
|
"enable plugin", "enable plugin \"plugin name\"","enable the plugin",
|
||||||
|
HandleConsoleEnablePlugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region console handlers
|
||||||
|
// Handle our console commands
|
||||||
|
//
|
||||||
|
// Install plugin from registered repository
|
||||||
|
/// <summary>
|
||||||
|
/// Handles the console install plugin command. Attempts to install the selected plugin
|
||||||
|
/// and
|
||||||
|
/// </summary>
|
||||||
|
/// <param name='module'>
|
||||||
|
/// Module.
|
||||||
|
/// </param>
|
||||||
|
/// <param name='cmd'>
|
||||||
|
/// Cmd.
|
||||||
|
/// </param>
|
||||||
|
private void HandleConsoleInstallPlugin(string module, string[] cmd)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||||
|
|
||||||
|
if (cmd.Length == 2)
|
||||||
|
{
|
||||||
|
int ndx = Convert.ToInt16(cmd[1]);
|
||||||
|
if (m_PluginManager.InstallPlugin(ndx, out result) == true)
|
||||||
|
{
|
||||||
|
ArrayList s = new ArrayList();
|
||||||
|
s.AddRange(result.Keys);
|
||||||
|
s.Sort();
|
||||||
|
|
||||||
|
var list = result.Keys.ToList();
|
||||||
|
list.Sort();
|
||||||
|
foreach (var k in list)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> plugin = (Dictionary<string, object>)result[k];
|
||||||
|
bool enabled = (bool)plugin["enabled"];
|
||||||
|
MainConsole.Instance.OutputFormat("{0}) {1} {2} rev. {3}",
|
||||||
|
k,
|
||||||
|
enabled == true ? "[ ]" : "[X]",
|
||||||
|
plugin["name"], plugin["version"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove installed plugin
|
||||||
|
private void HandleConsoleUnInstallPlugin(string module, string[] cmd)
|
||||||
|
{
|
||||||
|
if (cmd.Length == 2)
|
||||||
|
{
|
||||||
|
int ndx = Convert.ToInt16(cmd[1]);
|
||||||
|
m_PluginManager.UnInstall(ndx);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check installed plugins **not working
|
||||||
|
private void HandleConsoleCheckInstalledPlugin(string module, string[] cmd)
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output(m_PluginManager.CheckInstalled());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// List installed plugins
|
||||||
|
private void HandleConsoleListInstalledPlugin(string module, string[] cmd)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||||
|
m_PluginManager.ListInstalledAddins(out result);
|
||||||
|
|
||||||
|
ArrayList s = new ArrayList();
|
||||||
|
s.AddRange(result.Keys);
|
||||||
|
s.Sort();
|
||||||
|
|
||||||
|
var list = result.Keys.ToList();
|
||||||
|
list.Sort();
|
||||||
|
foreach (var k in list)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> plugin = (Dictionary<string, object>)result[k];
|
||||||
|
bool enabled = (bool)plugin["enabled"];
|
||||||
|
MainConsole.Instance.OutputFormat("{0}) {1} {2} rev. {3}",
|
||||||
|
k,
|
||||||
|
enabled == true ? "[ ]" : "[X]",
|
||||||
|
plugin["name"], plugin["version"]);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// List available plugins on registered repositories
|
||||||
|
private void HandleConsoleListAvailablePlugin(string module, string[] cmd)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||||
|
m_PluginManager.ListAvailable(out result);
|
||||||
|
|
||||||
|
var list = result.Keys.ToList();
|
||||||
|
list.Sort();
|
||||||
|
foreach (var k in list)
|
||||||
|
{
|
||||||
|
// name, version, repository
|
||||||
|
Dictionary<string, object> plugin = (Dictionary<string, object>)result[k];
|
||||||
|
MainConsole.Instance.OutputFormat("{0}) {1} rev. {2} {3}",
|
||||||
|
k,
|
||||||
|
plugin["name"],
|
||||||
|
plugin["version"],
|
||||||
|
plugin["repository"]);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// List available updates **not ready
|
||||||
|
private void HandleConsoleListUpdates(string module, string[] cmd)
|
||||||
|
{
|
||||||
|
m_PluginManager.ListUpdates();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update plugin **not ready
|
||||||
|
private void HandleConsoleUpdatePlugin(string module, string[] cmd)
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output(m_PluginManager.Update());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register repository
|
||||||
|
private void HandleConsoleAddRepo(string module, string[] cmd)
|
||||||
|
{
|
||||||
|
if ( cmd.Length == 3)
|
||||||
|
{
|
||||||
|
m_PluginManager.AddRepository(cmd[2]);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get repository status **not working
|
||||||
|
private void HandleConsoleGetRepo(string module, string[] cmd)
|
||||||
|
{
|
||||||
|
m_PluginManager.GetRepository();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove registered repository
|
||||||
|
private void HandleConsoleRemoveRepo(string module, string[] cmd)
|
||||||
|
{
|
||||||
|
if (cmd.Length == 3)
|
||||||
|
m_PluginManager.RemoveRepository(cmd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable repository
|
||||||
|
private void HandleConsoleEnableRepo(string module, string[] cmd)
|
||||||
|
{
|
||||||
|
m_PluginManager.EnableRepository(cmd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable repository
|
||||||
|
private void HandleConsoleDisableRepo(string module, string[] cmd)
|
||||||
|
{
|
||||||
|
m_PluginManager.DisableRepository(cmd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// List repositories
|
||||||
|
private void HandleConsoleListRepos(string module, string[] cmd)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||||
|
m_PluginManager.ListRepositories(out result);
|
||||||
|
|
||||||
|
var list = result.Keys.ToList();
|
||||||
|
list.Sort();
|
||||||
|
foreach (var k in list)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> repo = (Dictionary<string, object>)result[k];
|
||||||
|
bool enabled = (bool)repo["enabled"];
|
||||||
|
MainConsole.Instance.OutputFormat("{0}) {1} {2}",
|
||||||
|
k,
|
||||||
|
enabled == true ? "[ ]" : "[X]",
|
||||||
|
repo["name"], repo["url"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show description information
|
||||||
|
private void HandleConsoleShowAddinInfo(string module, string[] cmd)
|
||||||
|
{
|
||||||
|
if (cmd.Length >= 3)
|
||||||
|
{
|
||||||
|
|
||||||
|
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||||
|
|
||||||
|
int ndx = Convert.ToInt16(cmd[2]);
|
||||||
|
m_PluginManager.AddinInfo(ndx, out result);
|
||||||
|
|
||||||
|
MainConsole.Instance.OutputFormat("Name: {0}\nURL: {1}\nFile: {2}\nAuthor: {3}\nCategory: {4}\nDesc: {5}",
|
||||||
|
result["name"],
|
||||||
|
result["url"],
|
||||||
|
result["file_name"],
|
||||||
|
result["author"],
|
||||||
|
result["category"],
|
||||||
|
result["description"]);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable plugin
|
||||||
|
private void HandleConsoleDisablePlugin(string module, string[] cmd)
|
||||||
|
{
|
||||||
|
m_PluginManager.DisablePlugin(cmd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable plugin
|
||||||
|
private void HandleConsoleEnablePlugin(string module, string[] cmd)
|
||||||
|
{
|
||||||
|
m_PluginManager.EnablePlugin(cmd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
// ****[ Robust ] These are handlers that relate to the console commands, but
|
||||||
|
// ****[ Robust ] are connecting to remote applications. It would be ok to do
|
||||||
|
// ****[ Robust ] this later in a separate module
|
||||||
|
//
|
||||||
|
#region IIntegrationService implementation
|
||||||
|
// Will hold back on implementing things here that can actually make changes
|
||||||
|
// Need to secure it first
|
||||||
|
public byte[] HandleWebListRepositories(OSDMap request)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||||
|
m_PluginManager.ListRepositories(out result);
|
||||||
|
string json = LitJson.JsonMapper.ToJson(result);
|
||||||
|
return Ux.DocToBytes(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] HandleWebAddRepository(OSDMap request)
|
||||||
|
{
|
||||||
|
return Ux.FailureResult("Not Implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] HandleWebRemoveRepositroy(OSDMap request)
|
||||||
|
{
|
||||||
|
return Ux.FailureResult("Not Implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] HandleEnableRepository(OSDMap request)
|
||||||
|
{
|
||||||
|
return Ux.FailureResult("Not Implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] HandleWebDisableRepository(OSDMap request)
|
||||||
|
{
|
||||||
|
return Ux.FailureResult("Not Implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] HandleWebListPlugins(OSDMap request)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||||
|
m_PluginManager.ListInstalledAddins(out result);
|
||||||
|
string json = LitJson.JsonMapper.ToJson(result);
|
||||||
|
return Ux.DocToBytes(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] HandleWebPluginInfo(OSDMap request)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||||
|
|
||||||
|
if(!String.IsNullOrEmpty(request["index"].ToString()))
|
||||||
|
{
|
||||||
|
int ndx = Convert.ToInt16(request["index"].ToString());
|
||||||
|
m_PluginManager.AddinInfo(ndx, out result);
|
||||||
|
string json = LitJson.JsonMapper.ToJson(result);
|
||||||
|
return Ux.DocToBytes(json);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Ux.FailureResult("No index supplied");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] HandleWebListAvailablePlugins(OSDMap request)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||||
|
m_PluginManager.ListAvailable(out result);
|
||||||
|
string json = LitJson.JsonMapper.ToJson(result);
|
||||||
|
return Ux.DocToBytes(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] HandleWebInstallPlugin(OSDMap request)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||||
|
int ndx = Convert.ToInt16(request["index"].ToString());
|
||||||
|
if (m_PluginManager.InstallPlugin(ndx, out result) == true)
|
||||||
|
{
|
||||||
|
string json = LitJson.JsonMapper.ToJson(result);
|
||||||
|
return Ux.DocToBytes(json);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Ux.FailureResult("No index supplied");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] HandleWebUnInstallPlugin(OSDMap request)
|
||||||
|
{
|
||||||
|
return Ux.FailureResult("Not Implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] HandleWebEnablePlugin(OSDMap request)
|
||||||
|
{
|
||||||
|
return Ux.FailureResult("Not Implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] HandleWebDisablePlugin(OSDMap request)
|
||||||
|
{
|
||||||
|
return Ux.FailureResult("Not Implemented");
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,301 @@
|
||||||
|
/*
|
||||||
|
* 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 System;
|
||||||
|
using System.IO;
|
||||||
|
using OpenSim.Services.Interfaces;
|
||||||
|
using OpenSim.Services.Base;
|
||||||
|
using OpenSim.Framework.Servers.HttpServer;
|
||||||
|
using System.Reflection;
|
||||||
|
using Nini.Config;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
||||||
|
using Mono.Addins;
|
||||||
|
using log4net;
|
||||||
|
using Ux = OpenSim.Services.IntegrationService.IntegrationUtils;
|
||||||
|
|
||||||
|
|
||||||
|
// ****[ Robust ] Re-factor to use in both OpenSim.exe and Robust.exe
|
||||||
|
// ****[ Robust ] ** Loading can be done in modules that overide a base
|
||||||
|
// ****[ Robust ] ** class that provides the base services for the
|
||||||
|
// ****[ Robust ] ** discovery, loading and event queing of the modules
|
||||||
|
|
||||||
|
|
||||||
|
// ****[ Robust ] We need to define our root to graft our modules into
|
||||||
|
[assembly:AddinRoot("IntegrationService", "2.1")]
|
||||||
|
namespace OpenSim.Services.IntegrationService
|
||||||
|
{
|
||||||
|
// ****[ Robust ] The name our modules look for as a dependency
|
||||||
|
[TypeExtensionPoint(Path="/OpenSim/IntegrationService", Name="IntegrationService")]
|
||||||
|
public interface IntegrationPlugin
|
||||||
|
{
|
||||||
|
void Init(IConfigSource MainConfig, IConfigSource PluginConfig, IHttpServer server, ServiceBase service);
|
||||||
|
void Unload();
|
||||||
|
string PluginName { get; }
|
||||||
|
string ConfigName { get; }
|
||||||
|
string DefaultConfig { get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hide the nasty stuff in here, let the IntegrationService be clean for
|
||||||
|
// our command and request handlers
|
||||||
|
public class IntegrationServiceBase : ServiceBase
|
||||||
|
{
|
||||||
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
private string m_ConfigName = "IntegrationService";
|
||||||
|
|
||||||
|
protected IHttpServer m_Server;
|
||||||
|
|
||||||
|
protected string m_IntegrationConfig;
|
||||||
|
protected PluginManager m_PluginManager;
|
||||||
|
AddinManager am;
|
||||||
|
|
||||||
|
protected IConfig m_IntegrationServerConfig;
|
||||||
|
protected string m_IntegrationConfigLoc;
|
||||||
|
IConfigSource m_ConfigSource;
|
||||||
|
|
||||||
|
public IntegrationServiceBase(IConfigSource config, IHttpServer server)
|
||||||
|
: base(config)
|
||||||
|
{
|
||||||
|
m_ConfigSource = config;
|
||||||
|
m_Server = server;
|
||||||
|
|
||||||
|
IConfig serverConfig = m_ConfigSource.Configs[m_ConfigName];
|
||||||
|
if (serverConfig == null)
|
||||||
|
throw new Exception(String.Format("No section {0} in config file", m_ConfigName));
|
||||||
|
|
||||||
|
m_IntegrationConfigLoc = serverConfig.GetString("IntegrationConfig", String.Empty);
|
||||||
|
AddinRegistry registry ;
|
||||||
|
bool DEVELOPMENT = serverConfig.GetBoolean("DevelopmentMode", false);
|
||||||
|
|
||||||
|
// ****[ Robust ] Would be able to load as a local Robust module,
|
||||||
|
// ****[ Robust ] during development, by adding the info to the
|
||||||
|
// ****[ Robust ] ServiceConnectors. Also allows modules to be
|
||||||
|
// ****[ Robust ] loaded locally under normal operations
|
||||||
|
//
|
||||||
|
// Are we developing plugins? We will load them now.
|
||||||
|
// This will allow debugging of the modules and will
|
||||||
|
// use the runtime directory for the registry. Will not
|
||||||
|
// be able to use the repo/registry commands ...
|
||||||
|
if (DEVELOPMENT == true)
|
||||||
|
{
|
||||||
|
AddinManager.Initialize(".");
|
||||||
|
registry = new AddinRegistry(".", ".");
|
||||||
|
registry.Update();
|
||||||
|
|
||||||
|
AddinManager.AddinLoaded += on_addinloaded_;
|
||||||
|
AddinManager.AddinLoadError += on_addinloaderror_;
|
||||||
|
AddinManager.AddinUnloaded += HandleAddinManagerAddinUnloaded;
|
||||||
|
AddinManager.AddinEngine.ExtensionChanged += HandleAddinManagerAddinEngineExtensionChanged;
|
||||||
|
|
||||||
|
registry.Update();
|
||||||
|
foreach (IntegrationPlugin cmd in AddinManager.GetExtensionObjects("/OpenSim/IntegrationService"))
|
||||||
|
{
|
||||||
|
m_log.DebugFormat("[INTEGRATION SERVICE]: Processing Addin {0}", cmd.PluginName);
|
||||||
|
LoadingPlugin(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
Addin[] addins = registry.GetAddins();
|
||||||
|
foreach (Addin addin in addins)
|
||||||
|
{
|
||||||
|
if (addin.Description.Category == "IntegrationPlugin")
|
||||||
|
{
|
||||||
|
m_log.DebugFormat("[INTEGRATION SERVICE]: Processing O Addin {0}", addin.Name);
|
||||||
|
addin.Enabled = true;
|
||||||
|
registry.EnableAddin(addin.Id);
|
||||||
|
registry.Update();
|
||||||
|
AddinManager.AddinEngine.LoadAddin(null, addin.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ****[ Robust ] Place this in a loader that getsd called from
|
||||||
|
// Robust after the main server is running
|
||||||
|
//
|
||||||
|
// ****[ Robust ] Make generic version of this to be overridden
|
||||||
|
// ****[ Robust ] by OpenSim.exe and Robust.exe
|
||||||
|
//
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// defaults to the ./bin directory
|
||||||
|
string RegistryLocation = serverConfig.GetString("PluginRegistryLocation", ".");
|
||||||
|
|
||||||
|
registry = new AddinRegistry(RegistryLocation, ".");
|
||||||
|
m_PluginManager = new PluginManager(registry);
|
||||||
|
|
||||||
|
// Deal with files only for now - will add url/environment later
|
||||||
|
m_IntegrationConfigLoc = serverConfig.GetString("IntegrationConfig", String.Empty);
|
||||||
|
if(String.IsNullOrEmpty(m_IntegrationConfigLoc))
|
||||||
|
m_log.Error("[INTEGRATION SERVICE]: No IntegrationConfig defined in the Robust.ini");
|
||||||
|
|
||||||
|
|
||||||
|
m_IntegrationServerConfig = m_ConfigSource.Configs["IntegrationService"];
|
||||||
|
if (m_IntegrationServerConfig == null)
|
||||||
|
{
|
||||||
|
throw new Exception("[INTEGRATION SERVICE]: Missing configuration");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AddinManager.Initialize(RegistryLocation);
|
||||||
|
AddinManager.Registry.Update();
|
||||||
|
|
||||||
|
AddinManager.AddinLoaded += on_addinloaded_;
|
||||||
|
AddinManager.AddinLoadError += on_addinloaderror_;
|
||||||
|
AddinManager.AddinUnloaded += HandleAddinManagerAddinUnloaded;
|
||||||
|
|
||||||
|
// Installed extensions are queried here and cause the registered events to fire
|
||||||
|
AddinManager.AddExtensionNodeHandler("/OpenSim/IntegrationService", OnExtensionChanged);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region addin event handlers
|
||||||
|
void HandleAddinManagerAddinEngineExtensionChanged(object sender, ExtensionEventArgs args)
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output(String.Format("Plugin Extension Change Path:{0}", args.Path));
|
||||||
|
}
|
||||||
|
|
||||||
|
private IConfigSource GetConfig(string configName)
|
||||||
|
{
|
||||||
|
return new IniConfigSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HandleAddinManagerAddinUnloaded(object sender, AddinEventArgs args)
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output("Plugin Unloaded");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void on_addinloaderror_(object sender, AddinErrorEventArgs args)
|
||||||
|
{
|
||||||
|
if (args.Exception == null)
|
||||||
|
m_log.Error("[INTEGRATION SERVICE]: Plugin Error: "
|
||||||
|
+ args.Message);
|
||||||
|
else
|
||||||
|
m_log.Error("[INTEGRATION SERVICE]: Plugin Error: "
|
||||||
|
+ args.Exception.Message + "\n"
|
||||||
|
+ args.Exception.StackTrace);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ****[ Robust ] This is where we get control of the plugin during
|
||||||
|
// ****[ Robust ] the loading and unloading
|
||||||
|
//
|
||||||
|
// This is our init
|
||||||
|
// We can do build-up and tear-down of our plugin
|
||||||
|
void OnExtensionChanged(object s, ExtensionNodeEventArgs args)
|
||||||
|
{
|
||||||
|
// This is our plugin
|
||||||
|
IntegrationPlugin ip = (IntegrationPlugin) args.ExtensionObject;
|
||||||
|
// We will need to get the name and path of the dll for the connector to
|
||||||
|
// be able to load the service in the refactored version...
|
||||||
|
// Might also use this to check for updates to alert the user
|
||||||
|
Addin a = m_PluginManager.Registry.GetAddin(args.ExtensionNode.Addin.Id);
|
||||||
|
m_log.InfoFormat("[INTEGRATION SERVICE]: Plugin Change {0}",a.AddinFile);
|
||||||
|
|
||||||
|
switch (args.Change)
|
||||||
|
{
|
||||||
|
// Build up
|
||||||
|
case ExtensionChange.Add:
|
||||||
|
|
||||||
|
m_log.DebugFormat("[INTEGRATION SERVICE]: Plugin Added {0}", ip.PluginName);
|
||||||
|
LoadingPlugin(ip);
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Tear down
|
||||||
|
case ExtensionChange.Remove:
|
||||||
|
|
||||||
|
m_log.DebugFormat("[INTEGRATION SERVICE]: Plugin Remove {0}", ip.PluginName);
|
||||||
|
UnLoadingPlugin(ip);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void on_addinloaded_(object sender, AddinEventArgs args)
|
||||||
|
{
|
||||||
|
m_log.Info("[INTEGRATION SERVICE]: Plugin Loaded: " + args.AddinId);
|
||||||
|
}
|
||||||
|
#endregion addin-event handlers
|
||||||
|
|
||||||
|
// ****[ Robust ] We are taking the module from the event handler and
|
||||||
|
// ****[ Robust ] taking it through the initialization process
|
||||||
|
// ****[ Robust ] This is using a mixture of the user's existing ini
|
||||||
|
// ****[ Robust ] and the developer supplied initial configuration
|
||||||
|
// ****[ Robust ]
|
||||||
|
// ****[ Robust ] We should first check the user's ini for existing entries
|
||||||
|
// ****[ Robust ] in case they have configured the module ahead of time.
|
||||||
|
//
|
||||||
|
private void LoadingPlugin(IntegrationPlugin plugin)
|
||||||
|
{
|
||||||
|
string ConfigPath = String.Format("{0}/(1)", m_IntegrationConfigLoc,plugin.ConfigName);
|
||||||
|
IConfigSource PlugConfig = Ux.GetConfigSource(m_IntegrationConfigLoc, plugin.ConfigName);
|
||||||
|
|
||||||
|
// We maintain a configuration per-plugin to enhance modularity
|
||||||
|
// If ConfigSource is null, we will get the default from the repo
|
||||||
|
// and write it to our directory
|
||||||
|
// Fetch the starter ini
|
||||||
|
if (PlugConfig == null)
|
||||||
|
{
|
||||||
|
m_log.DebugFormat("[INTEGRATION SERVICE]: Fetching starter config for {0} from {1}", plugin.PluginName, plugin.DefaultConfig);
|
||||||
|
|
||||||
|
// Send the default data service
|
||||||
|
IConfig DataService = m_ConfigSource.Configs["DatabaseService"];
|
||||||
|
m_log.DebugFormat("[INTEGRATION SERVICE]: Writing initial config to {0}", plugin.ConfigName);
|
||||||
|
|
||||||
|
IniConfigSource source = new IniConfigSource();
|
||||||
|
IConfig Init = source.AddConfig("DatabaseService");
|
||||||
|
Init.Set("StorageProvider",(string)DataService.GetString("StorageProvider"));
|
||||||
|
Init.Set("ConnectionString", String.Format("\"{0}\"",DataService.GetString("ConnectionString")));
|
||||||
|
|
||||||
|
PlugConfig = Ux.LoadInitialConfig(plugin.DefaultConfig);
|
||||||
|
source.Merge(PlugConfig);
|
||||||
|
source.Save(Path.Combine(m_IntegrationConfigLoc, plugin.ConfigName));
|
||||||
|
PlugConfig = Ux.GetConfigSource(m_IntegrationConfigLoc, plugin.ConfigName);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_log.DebugFormat("[INTEGRATION SERVICE]: ****** In Loading Plugin {0}", plugin.PluginName);
|
||||||
|
plugin.Init(m_ConfigSource, PlugConfig, m_Server, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ****[ Robust ] We are taking the plugin from the event handler to unload it
|
||||||
|
// ****[ Robust ] and we need to tear down to release all objects.
|
||||||
|
//
|
||||||
|
private void UnLoadingPlugin(IntegrationPlugin plugin)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
plugin.Unload();
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
// Getting some "Error Object reference not set to an instance of an object"
|
||||||
|
// when the plugins are unloaded. This keeps things quiet for now
|
||||||
|
// m_log.DebugFormat("[INTEGRATION SERVICE]: Error {0}", e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,161 @@
|
||||||
|
/*
|
||||||
|
* 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 System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Xml;
|
||||||
|
using log4net;
|
||||||
|
using Nini.Config;
|
||||||
|
using OpenMetaverse.StructuredData;
|
||||||
|
|
||||||
|
|
||||||
|
namespace OpenSim.Services.IntegrationService
|
||||||
|
{
|
||||||
|
public static class IntegrationUtils
|
||||||
|
{
|
||||||
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
// ****[ Robust ] Only a couple of these are needed in the core management system
|
||||||
|
// ****[ Robust ] These could be moved to the implementation instead of being in
|
||||||
|
// ****[ Robust ] a separate file
|
||||||
|
//
|
||||||
|
#region web utils
|
||||||
|
public static bool ParseStringToOSDMap(string input, out OSDMap json)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
json = null;
|
||||||
|
OSD tmpbuff = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tmpbuff = OSDParser.DeserializeJson(input.ToString());
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tmpbuff.Type == OSDType.Map)
|
||||||
|
{
|
||||||
|
json = (OSDMap)tmpbuff;
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (NullReferenceException e)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat("[IUtil]: exception on ParseStringToJson {0}", e.Message);
|
||||||
|
json = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] FailureResult()
|
||||||
|
{
|
||||||
|
return FailureResult(String.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] FailureResult(string msg)
|
||||||
|
{
|
||||||
|
OSDMap doc = new OSDMap(2);
|
||||||
|
doc["result"] = OSD.FromString("failure");
|
||||||
|
doc["message"] = OSD.FromString(msg);
|
||||||
|
|
||||||
|
return DocToBytes(doc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] ResponseMessage(string message)
|
||||||
|
{
|
||||||
|
OSDMap doc = new OSDMap(2);
|
||||||
|
doc["result"] = OSD.FromString("success");
|
||||||
|
doc["message"] = OSD.FromString(message);
|
||||||
|
|
||||||
|
return DocToBytes(doc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] DocToBytes(OSDMap doc)
|
||||||
|
{
|
||||||
|
return Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(doc));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] DocToBytes(string json)
|
||||||
|
{
|
||||||
|
return Encoding.UTF8.GetBytes(json);
|
||||||
|
}
|
||||||
|
#endregion web utils
|
||||||
|
|
||||||
|
#region config utils
|
||||||
|
public static IConfigSource GetConfigSource(string IniPath, string IniName)
|
||||||
|
{
|
||||||
|
string configFilePath = Path.GetFullPath(
|
||||||
|
Path.Combine(IniPath, IniName));
|
||||||
|
|
||||||
|
if (File.Exists(configFilePath))
|
||||||
|
{
|
||||||
|
IConfigSource config = new IniConfigSource(configFilePath);
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IConfigSource LoadInitialConfig(string url)
|
||||||
|
{
|
||||||
|
IConfigSource source = new XmlConfigSource();
|
||||||
|
m_log.InfoFormat("[CONFIG]: {0} is a http:// URI, fetching ...", url);
|
||||||
|
|
||||||
|
// The ini file path is a http URI
|
||||||
|
// Try to read it
|
||||||
|
try
|
||||||
|
{
|
||||||
|
XmlReader r = XmlReader.Create(url);
|
||||||
|
IConfigSource cs = new XmlConfigSource(r);
|
||||||
|
source.Merge(cs);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.FatalFormat("[CONFIG]: Exception reading config from URI {0}\n" + e.ToString(), url);
|
||||||
|
Environment.Exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
#endregion config utils
|
||||||
|
|
||||||
|
public static T LoadPlugin<T>(string dllName, Object[] args) where T:class
|
||||||
|
{
|
||||||
|
return OpenSim.Server.Base.ServerUtils.LoadPlugin<T>(dllName, args);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,561 @@
|
||||||
|
/*
|
||||||
|
* 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 System;
|
||||||
|
using System.Text;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using Mono.Addins;
|
||||||
|
using Mono.Addins.Setup;
|
||||||
|
using Mono.Addins.Description;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
using Ux = OpenSim.Services.IntegrationService.IntegrationUtils;
|
||||||
|
|
||||||
|
namespace OpenSim.Services.IntegrationService
|
||||||
|
{
|
||||||
|
// ****[ Robust ] These are the functions that connect our console
|
||||||
|
// ****[ Robust ] commands to the addin management. This needs to
|
||||||
|
// ****[ Robust ] be maintained in a file separately from the main
|
||||||
|
// ****[ Robust ] implementation in the same namespace. Any generaly
|
||||||
|
// ****[ Robust ] usefull methods can be located in one of the existing
|
||||||
|
// ****[ Robust ] places
|
||||||
|
// ****[ Robust ]
|
||||||
|
// ****[ Robust ] This needs to be in OpenSim.Framework so it can be
|
||||||
|
// ****[ Robust ] used to complete the region module management
|
||||||
|
//
|
||||||
|
// This will maintain the plugin repositories and plugins
|
||||||
|
public class PluginManager : SetupService
|
||||||
|
{
|
||||||
|
protected AddinRegistry m_Registry;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="OpenSim.Services.IntegrationService.PluginManager"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name='r'>
|
||||||
|
/// R.
|
||||||
|
/// </param>
|
||||||
|
internal PluginManager(AddinRegistry r): base (r)
|
||||||
|
{
|
||||||
|
m_Registry = r;
|
||||||
|
m_Registry.Update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Installs the plugin.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// The plugin.
|
||||||
|
/// </returns>
|
||||||
|
/// <param name='args'>
|
||||||
|
/// Arguments.
|
||||||
|
/// </param>
|
||||||
|
public bool InstallPlugin(int ndx, out Dictionary<string, object> result)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> res = new Dictionary<string, object>();
|
||||||
|
|
||||||
|
PackageCollection pack = new PackageCollection();
|
||||||
|
PackageCollection toUninstall;
|
||||||
|
DependencyCollection unresolved;
|
||||||
|
|
||||||
|
IProgressStatus ps = new ConsoleProgressStatus(false);
|
||||||
|
|
||||||
|
AddinRepositoryEntry[] available = GetSortedAvailbleAddins();
|
||||||
|
|
||||||
|
if (ndx > (available.Length - 1))
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output("Selection out of range");
|
||||||
|
result = res;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
AddinRepositoryEntry aentry = available[ndx];
|
||||||
|
|
||||||
|
Package p = Package.FromRepository(aentry);
|
||||||
|
pack.Add(p);
|
||||||
|
|
||||||
|
ResolveDependencies(ps, pack, out toUninstall, out unresolved);
|
||||||
|
|
||||||
|
// Attempt to install the plugin disabled
|
||||||
|
if (Install(ps, pack) == true)
|
||||||
|
{
|
||||||
|
m_Registry.Update(ps);
|
||||||
|
Addin addin = m_Registry.GetAddin(aentry.Addin.Id);
|
||||||
|
m_Registry.DisableAddin(addin.Id);
|
||||||
|
addin.Enabled = false;
|
||||||
|
|
||||||
|
MainConsole.Instance.Output("Installation Success");
|
||||||
|
ListInstalledAddins(out res);
|
||||||
|
result = res;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output("Installation Failed");
|
||||||
|
result = res;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove plugin
|
||||||
|
/// <summary>
|
||||||
|
/// Uns the install.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name='args'>
|
||||||
|
/// Arguments.
|
||||||
|
/// </param>
|
||||||
|
public void UnInstall(int ndx)
|
||||||
|
{
|
||||||
|
Addin[] addins = GetSortedAddinList("IntegrationPlugin");
|
||||||
|
|
||||||
|
if (ndx > (addins.Length -1))
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output("Selection out of range");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Addin addin = addins[ndx];
|
||||||
|
MainConsole.Instance.OutputFormat("Uninstalling plugin {0}", addin.Id);
|
||||||
|
AddinManager.Registry.DisableAddin(addin.Id);
|
||||||
|
addin.Enabled = false;
|
||||||
|
IProgressStatus ps = new ConsoleProgressStatus(false);
|
||||||
|
Uninstall(ps, addin.Id);
|
||||||
|
MainConsole.Instance.Output("Uninstall Success - restart to complete operation");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks the installed.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// The installed.
|
||||||
|
/// </returns>
|
||||||
|
public string CheckInstalled()
|
||||||
|
{
|
||||||
|
return "CheckInstall";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Lists the installed addins.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name='result'>
|
||||||
|
/// Result.
|
||||||
|
/// </param>
|
||||||
|
public void ListInstalledAddins(out Dictionary<string, object> result)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> res = new Dictionary<string, object>();
|
||||||
|
|
||||||
|
Addin[] addins = GetSortedAddinList("IntegrationPlugin");
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
foreach (Addin addin in addins)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> r = new Dictionary<string, object>();
|
||||||
|
r["enabled"] = addin.Enabled == true ? true : false;
|
||||||
|
r["name"] = addin.LocalId;
|
||||||
|
r["version"] = addin.Version;
|
||||||
|
|
||||||
|
res.Add(count.ToString(), r);
|
||||||
|
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
result = res;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// List compatible plugins in registered repositories
|
||||||
|
/// <summary>
|
||||||
|
/// Lists the available.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name='result'>
|
||||||
|
/// Result.
|
||||||
|
/// </param>
|
||||||
|
public void ListAvailable(out Dictionary<string, object> result)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> res = new Dictionary<string, object>();
|
||||||
|
|
||||||
|
AddinRepositoryEntry[] addins = GetSortedAvailbleAddins();
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
foreach (AddinRepositoryEntry addin in addins)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> r = new Dictionary<string, object>();
|
||||||
|
r["name"] = addin.Addin.Name;
|
||||||
|
r["version"] = addin.Addin.Version;
|
||||||
|
r["repository"] = addin.RepositoryName;
|
||||||
|
|
||||||
|
res.Add(count.ToString(), r);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
result = res;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// List available updates ** 1
|
||||||
|
/// <summary>
|
||||||
|
/// Lists the updates.
|
||||||
|
/// </summary>
|
||||||
|
public void ListUpdates()
|
||||||
|
{
|
||||||
|
IProgressStatus ps = new ConsoleProgressStatus(true);
|
||||||
|
Console.WriteLine ("Looking for updates...");
|
||||||
|
Repositories.UpdateAllRepositories (ps);
|
||||||
|
Console.WriteLine ("Available add-in updates:");
|
||||||
|
bool found = false;
|
||||||
|
AddinRepositoryEntry[] entries = Repositories.GetAvailableUpdates();
|
||||||
|
|
||||||
|
foreach (AddinRepositoryEntry entry in entries)
|
||||||
|
{
|
||||||
|
Console.WriteLine(String.Format("{0}",entry.Addin.Id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sync to repositories
|
||||||
|
/// <summary>
|
||||||
|
/// Update this instance.
|
||||||
|
/// </summary>
|
||||||
|
public string Update()
|
||||||
|
{
|
||||||
|
IProgressStatus ps = new ConsoleProgressStatus(true);
|
||||||
|
Repositories.UpdateAllRepositories(ps);
|
||||||
|
return "Update";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register a repository
|
||||||
|
/// <summary>
|
||||||
|
/// Register a repository with our server.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// result of the action
|
||||||
|
/// </returns>
|
||||||
|
/// <param name='repo'>
|
||||||
|
/// The URL of the repository we want to add
|
||||||
|
/// </param>
|
||||||
|
public bool AddRepository(string repo)
|
||||||
|
{
|
||||||
|
Repositories.RegisterRepository(null, repo, true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the repository.
|
||||||
|
/// </summary>
|
||||||
|
public void GetRepository()
|
||||||
|
{
|
||||||
|
Repositories.UpdateAllRepositories(new ConsoleProgressStatus(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove a repository from the list
|
||||||
|
/// <summary>
|
||||||
|
/// Removes the repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name='args'>
|
||||||
|
/// Arguments.
|
||||||
|
/// </param>
|
||||||
|
public void RemoveRepository(string[] args)
|
||||||
|
{
|
||||||
|
AddinRepository[] reps = Repositories.GetRepositories();
|
||||||
|
Array.Sort(reps, (r1,r2) => r1.Title.CompareTo(r2.Title));
|
||||||
|
if (reps.Length == 0)
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output("No repositories have been registered.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int n = Convert.ToInt16(args[2]);
|
||||||
|
if (n > (reps.Length -1))
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output("Selection out of range");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AddinRepository rep = reps[n];
|
||||||
|
Repositories.RemoveRepository(rep.Url);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable repository
|
||||||
|
/// <summary>
|
||||||
|
/// Enables the repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name='args'>
|
||||||
|
/// Arguments.
|
||||||
|
/// </param>
|
||||||
|
public void EnableRepository(string[] args)
|
||||||
|
{
|
||||||
|
AddinRepository[] reps = Repositories.GetRepositories();
|
||||||
|
Array.Sort(reps, (r1,r2) => r1.Title.CompareTo(r2.Title));
|
||||||
|
if (reps.Length == 0)
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output("No repositories have been registered.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int n = Convert.ToInt16(args[2]);
|
||||||
|
if (n > (reps.Length -1))
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output("Selection out of range");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AddinRepository rep = reps[n];
|
||||||
|
Repositories.SetRepositoryEnabled(rep.Url, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable a repository
|
||||||
|
/// <summary>
|
||||||
|
/// Disables the repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name='args'>
|
||||||
|
/// Arguments.
|
||||||
|
/// </param>
|
||||||
|
public void DisableRepository(string[] args)
|
||||||
|
{
|
||||||
|
AddinRepository[] reps = Repositories.GetRepositories();
|
||||||
|
Array.Sort(reps, (r1,r2) => r1.Title.CompareTo(r2.Title));
|
||||||
|
if (reps.Length == 0)
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output("No repositories have been registered.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int n = Convert.ToInt16(args[2]);
|
||||||
|
if (n > (reps.Length -1))
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output("Selection out of range");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AddinRepository rep = reps[n];
|
||||||
|
Repositories.SetRepositoryEnabled(rep.Url, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// List registered repositories
|
||||||
|
/// <summary>
|
||||||
|
/// Lists the repositories.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name='result'>
|
||||||
|
/// Result.
|
||||||
|
/// </param>
|
||||||
|
public void ListRepositories(out Dictionary<string, object> result)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> res = new Dictionary<string, object>();
|
||||||
|
result = res;
|
||||||
|
|
||||||
|
AddinRepository[] reps = GetSortedAddinRepo();
|
||||||
|
if (reps.Length == 0)
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output("No repositories have been registered.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
foreach (AddinRepository rep in reps)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> r = new Dictionary<string, object>();
|
||||||
|
r["enabled"] = rep.Enabled == true ? true : false;
|
||||||
|
r["name"] = rep.Name;
|
||||||
|
r["url"] = rep.Url;
|
||||||
|
|
||||||
|
res.Add(count.ToString(), r);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the registry.
|
||||||
|
/// </summary>
|
||||||
|
public void UpdateRegistry()
|
||||||
|
{
|
||||||
|
m_Registry.Update();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show plugin info
|
||||||
|
/// <summary>
|
||||||
|
/// Addins the info.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// The info.
|
||||||
|
/// </returns>
|
||||||
|
/// <param name='args'>
|
||||||
|
/// Arguments.
|
||||||
|
/// </param>
|
||||||
|
public bool AddinInfo(int ndx, out Dictionary<string, object> result)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> res = new Dictionary<string, object>();
|
||||||
|
result = res;
|
||||||
|
|
||||||
|
Addin[] addins = GetSortedAddinList("IntegrationPlugin");
|
||||||
|
|
||||||
|
if (ndx > (addins.Length - 1))
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output("Selection out of range");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// author category description
|
||||||
|
Addin addin = addins[ndx];
|
||||||
|
|
||||||
|
res["author"] = addin.Description.Author;
|
||||||
|
res["category"] = addin.Description.Category;
|
||||||
|
res["description"] = addin.Description.Description;
|
||||||
|
res["name"] = addin.Name;
|
||||||
|
res["url"] = addin.Description.Url;
|
||||||
|
res["file_name"] = addin.Description.FileName;
|
||||||
|
|
||||||
|
result = res;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable a plugin
|
||||||
|
/// <summary>
|
||||||
|
/// Disables the plugin.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name='args'>
|
||||||
|
/// Arguments.
|
||||||
|
/// </param>
|
||||||
|
public void DisablePlugin(string[] args)
|
||||||
|
{
|
||||||
|
Addin[] addins = GetSortedAddinList("IntegrationPlugin");
|
||||||
|
|
||||||
|
int n = Convert.ToInt16(args[2]);
|
||||||
|
if (n > (addins.Length -1))
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output("Selection out of range");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Addin addin = addins[n];
|
||||||
|
AddinManager.Registry.DisableAddin(addin.Id);
|
||||||
|
addin.Enabled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable plugin
|
||||||
|
/// <summary>
|
||||||
|
/// Enables the plugin.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name='args'>
|
||||||
|
/// Arguments.
|
||||||
|
/// </param>
|
||||||
|
public void EnablePlugin(string[] args)
|
||||||
|
{
|
||||||
|
Addin[] addins = GetSortedAddinList("IntegrationPlugin");
|
||||||
|
|
||||||
|
int n = Convert.ToInt16(args[2]);
|
||||||
|
if (n > (addins.Length -1))
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output("Selection out of range");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Addin addin = addins[n];
|
||||||
|
|
||||||
|
addin.Enabled = true;
|
||||||
|
AddinManager.Registry.EnableAddin(addin.Id);
|
||||||
|
// AddinManager.Registry.Update();
|
||||||
|
if(m_Registry.IsAddinEnabled(addin.Id))
|
||||||
|
{
|
||||||
|
ConsoleProgressStatus ps = new ConsoleProgressStatus(false);
|
||||||
|
if (!AddinManager.AddinEngine.IsAddinLoaded(addin.Id))
|
||||||
|
{
|
||||||
|
AddinManager.Registry.Rebuild(ps);
|
||||||
|
AddinManager.AddinEngine.LoadAddin(ps, addin.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MainConsole.Instance.OutputFormat("Not Enabled in this domain {0}", addin.Name);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Util
|
||||||
|
private void Testing()
|
||||||
|
{
|
||||||
|
Addin[] list = Registry.GetAddins();
|
||||||
|
|
||||||
|
var addins = list.Where( a => a.Description.Category == "IntegrationPlugin");
|
||||||
|
|
||||||
|
foreach (Addin addin in addins)
|
||||||
|
{
|
||||||
|
MainConsole.Instance.OutputFormat("Addin {0}", addin.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// These will let us deal with numbered lists instead
|
||||||
|
// of needing to type in the full ids
|
||||||
|
private AddinRepositoryEntry[] GetSortedAvailbleAddins()
|
||||||
|
{
|
||||||
|
ArrayList list = new ArrayList();
|
||||||
|
list.AddRange(Repositories.GetAvailableAddins());
|
||||||
|
|
||||||
|
AddinRepositoryEntry[] addins = list.ToArray(typeof(AddinRepositoryEntry)) as AddinRepositoryEntry[];
|
||||||
|
|
||||||
|
Array.Sort(addins,(r1,r2) => r1.Addin.Id.CompareTo(r2.Addin.Id));
|
||||||
|
|
||||||
|
return addins;
|
||||||
|
}
|
||||||
|
|
||||||
|
private AddinRepository[] GetSortedAddinRepo()
|
||||||
|
{
|
||||||
|
ArrayList list = new ArrayList();
|
||||||
|
list.AddRange(Repositories.GetRepositories());
|
||||||
|
|
||||||
|
AddinRepository[] repos = list.ToArray(typeof(AddinRepository)) as AddinRepository[];
|
||||||
|
Array.Sort (repos,(r1,r2) => r1.Name.CompareTo(r2.Name));
|
||||||
|
|
||||||
|
return repos;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Addin[] GetSortedAddinList(string category)
|
||||||
|
{
|
||||||
|
ArrayList list = new ArrayList();
|
||||||
|
list.AddRange(m_Registry.GetAddins());
|
||||||
|
ArrayList xlist = new ArrayList();
|
||||||
|
|
||||||
|
foreach (Addin addin in list)
|
||||||
|
{
|
||||||
|
if (addin.Description.Category == category)
|
||||||
|
xlist.Add(addin);
|
||||||
|
}
|
||||||
|
|
||||||
|
Addin[] addins = xlist.ToArray(typeof(Addin)) as Addin[];
|
||||||
|
Array.Sort(addins,(r1,r2) => r1.Id.CompareTo(r2.Id));
|
||||||
|
|
||||||
|
return addins;
|
||||||
|
}
|
||||||
|
#endregion Util
|
||||||
|
|
||||||
|
#region Notes
|
||||||
|
// ** 1 Not working
|
||||||
|
#endregion Notes
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* 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 System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using OpenMetaverse;
|
||||||
|
using OpenMetaverse.StructuredData;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
|
||||||
|
namespace OpenSim.Services.Interfaces
|
||||||
|
{
|
||||||
|
public interface IIntegrationService
|
||||||
|
{
|
||||||
|
#region Web handlers
|
||||||
|
byte[] HandleWebListRepositories(OSDMap request);
|
||||||
|
byte[] HandleWebAddRepository(OSDMap request);
|
||||||
|
byte[] HandleWebRemoveRepositroy(OSDMap request);
|
||||||
|
byte[] HandleEnableRepository(OSDMap request);
|
||||||
|
byte[] HandleWebDisableRepository(OSDMap request);
|
||||||
|
byte[] HandleWebListPlugins(OSDMap request);
|
||||||
|
byte[] HandleWebPluginInfo(OSDMap request);
|
||||||
|
byte[] HandleWebListAvailablePlugins(OSDMap request);
|
||||||
|
byte[] HandleWebInstallPlugin(OSDMap request);
|
||||||
|
byte[] HandleWebUnInstallPlugin(OSDMap request);
|
||||||
|
byte[] HandleWebEnablePlugin(OSDMap request);
|
||||||
|
byte[] HandleWebDisablePlugin(OSDMap request);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -68,6 +68,7 @@ namespace OpenSim.Services.Interfaces
|
||||||
bool ReportAgent(UUID sessionID, UUID regionID);
|
bool ReportAgent(UUID sessionID, UUID regionID);
|
||||||
|
|
||||||
PresenceInfo GetAgent(UUID sessionID);
|
PresenceInfo GetAgent(UUID sessionID);
|
||||||
|
PresenceInfo VerifyAgent(UUID s_sessionID);
|
||||||
PresenceInfo[] GetAgents(string[] userIDs);
|
PresenceInfo[] GetAgents(string[] userIDs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,5 +158,19 @@ namespace OpenSim.Services.PresenceService
|
||||||
|
|
||||||
return info.ToArray();
|
return info.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PresenceInfo VerifyAgent(UUID s_sessionID)
|
||||||
|
{
|
||||||
|
PresenceInfo ret = new PresenceInfo();
|
||||||
|
|
||||||
|
PresenceData data = m_Database.Verify(s_sessionID);
|
||||||
|
if (data == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
ret.UserID = data.UserID;
|
||||||
|
ret.RegionID = data.RegionID;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -21,7 +21,7 @@
|
||||||
; * [[<ConfigName>@]<port>/]<dll name>[:<class name>]
|
; * [[<ConfigName>@]<port>/]<dll name>[:<class name>]
|
||||||
; *
|
; *
|
||||||
[Startup]
|
[Startup]
|
||||||
ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003/OpenSim.Server.Handlers.dll:XInventoryInConnector,8004/OpenSim.Server.Handlers.dll:FreeswitchServerConnector,8003/OpenSim.Server.Handlers.dll:GridServiceConnector,8002/OpenSim.Server.Handlers.dll:GridInfoServerInConnector,8003/OpenSim.Server.Handlers.dll:AuthenticationServiceConnector,8002/OpenSim.Server.Handlers.dll:OpenIdServerConnector,8003/OpenSim.Server.Handlers.dll:AvatarServiceConnector,8002/OpenSim.Server.Handlers.dll:LLLoginServiceInConnector,8003/OpenSim.Server.Handlers.dll:PresenceServiceConnector,8003/OpenSim.Server.Handlers.dll:UserAccountServiceConnector,8003/OpenSim.Server.Handlers.dll:GridUserServiceConnector,8003/OpenSim.Server.Handlers.dll:FriendsServiceConnector,8002/OpenSim.Server.Handlers.dll:GatekeeperServiceInConnector,8002/OpenSim.Server.Handlers.dll:UserAgentServerConnector,HGInventoryService@8002/OpenSim.Server.Handlers.dll:XInventoryInConnector,HGAssetService@8002/OpenSim.Server.Handlers.dll:AssetServiceConnector,8002/OpenSim.Server.Handlers.dll:HeloServiceInConnector,8002/OpenSim.Server.Handlers.dll:HGFriendsServerConnector,8002/OpenSim.Server.Handlers.dll:InstantMessageServerConnector,8003/OpenSim.Server.Handlers.dll:MapAddServiceConnector,8002/OpenSim.Server.Handlers.dll:MapGetServiceConnector"
|
ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003/OpenSim.Server.Handlers.dll:XInventoryInConnector,8004/OpenSim.Server.Handlers.dll:FreeswitchServerConnector,8003/OpenSim.Server.Handlers.dll:GridServiceConnector,8002/OpenSim.Server.Handlers.dll:GridInfoServerInConnector,8003/OpenSim.Server.Handlers.dll:AuthenticationServiceConnector,8002/OpenSim.Server.Handlers.dll:OpenIdServerConnector,8003/OpenSim.Server.Handlers.dll:AvatarServiceConnector,8002/OpenSim.Server.Handlers.dll:LLLoginServiceInConnector,8003/OpenSim.Server.Handlers.dll:PresenceServiceConnector,8003/OpenSim.Server.Handlers.dll:UserAccountServiceConnector,8003/OpenSim.Server.Handlers.dll:GridUserServiceConnector,8003/OpenSim.Server.Handlers.dll:FriendsServiceConnector,8002/OpenSim.Server.Handlers.dll:GatekeeperServiceInConnector,8002/OpenSim.Server.Handlers.dll:UserAgentServerConnector,HGInventoryService@8002/OpenSim.Server.Handlers.dll:XInventoryInConnector,HGAssetService@8002/OpenSim.Server.Handlers.dll:AssetServiceConnector,8002/OpenSim.Server.Handlers.dll:HeloServiceInConnector,8002/OpenSim.Server.Handlers.dll:HGFriendsServerConnector,8002/OpenSim.Server.Handlers.dll:InstantMessageServerConnector,8003/OpenSim.Server.Handlers.dll:MapAddServiceConnector,8002/OpenSim.Server.Handlers.dll:MapGetServiceConnector,8002/OpenSim.Server.Handlers.dll:IntegrationServiceConnector"
|
||||||
|
|
||||||
; * This is common for all services, it's the network setup for the entire
|
; * This is common for all services, it's the network setup for the entire
|
||||||
; * server instance, if none is specified above
|
; * server instance, if none is specified above
|
||||||
|
@ -465,3 +465,18 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
|
||||||
;; This applies to the core groups module (Flotsam) only.
|
;; This applies to the core groups module (Flotsam) only.
|
||||||
; ForwardOfflineGroupMessages = true
|
; ForwardOfflineGroupMessages = true
|
||||||
|
|
||||||
|
[IntegrationService]
|
||||||
|
|
||||||
|
LocalServiceModule = "OpenSim.Services.IntegrationService.dll:IntegrationService"
|
||||||
|
|
||||||
|
;; Location for plugin management data, default is "."
|
||||||
|
PluginRegistryLocation="/home/opensim/var/run/addin/Integration"
|
||||||
|
;;
|
||||||
|
;; Each plugin uses it's own ini (for now these are files only)
|
||||||
|
;; The initial files are supplied by the plugin when it is installed
|
||||||
|
;; and this is the location for the directory for these.
|
||||||
|
IntegrationConfig = "/home/opensim/etc/Integration"
|
||||||
|
|
||||||
|
GridService = "OpenSim.Services.GridService.dll:GridService"
|
||||||
|
PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService"
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
; * [[<ConfigName>@]<port>/]<dll name>[:<class name>]
|
; * [[<ConfigName>@]<port>/]<dll name>[:<class name>]
|
||||||
; *
|
; *
|
||||||
[Startup]
|
[Startup]
|
||||||
ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003/OpenSim.Server.Handlers.dll:XInventoryInConnector,8004/OpenSim.Server.Handlers.dll:FreeswitchServerConnector,8003/OpenSim.Server.Handlers.dll:GridServiceConnector,8002/OpenSim.Server.Handlers.dll:GridInfoServerInConnector,8003/OpenSim.Server.Handlers.dll:AuthenticationServiceConnector,8002/OpenSim.Server.Handlers.dll:OpenIdServerConnector,8003/OpenSim.Server.Handlers.dll:AvatarServiceConnector,8002/OpenSim.Server.Handlers.dll:LLLoginServiceInConnector,8003/OpenSim.Server.Handlers.dll:PresenceServiceConnector,8003/OpenSim.Server.Handlers.dll:UserAccountServiceConnector,8003/OpenSim.Server.Handlers.dll:GridUserServiceConnector,8003/OpenSim.Server.Handlers.dll:FriendsServiceConnector,8003/OpenSim.Server.Handlers.dll:MapAddServiceConnector,8002/OpenSim.Server.Handlers.dll:MapGetServiceConnector"
|
ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003/OpenSim.Server.Handlers.dll:XInventoryInConnector,8004/OpenSim.Server.Handlers.dll:FreeswitchServerConnector,8003/OpenSim.Server.Handlers.dll:GridServiceConnector,8002/OpenSim.Server.Handlers.dll:GridInfoServerInConnector,8003/OpenSim.Server.Handlers.dll:AuthenticationServiceConnector,8002/OpenSim.Server.Handlers.dll:OpenIdServerConnector,8003/OpenSim.Server.Handlers.dll:AvatarServiceConnector,8002/OpenSim.Server.Handlers.dll:LLLoginServiceInConnector,8003/OpenSim.Server.Handlers.dll:PresenceServiceConnector,8003/OpenSim.Server.Handlers.dll:UserAccountServiceConnector,8003/OpenSim.Server.Handlers.dll:GridUserServiceConnector,8003/OpenSim.Server.Handlers.dll:FriendsServiceConnector,8003/OpenSim.Server.Handlers.dll:MapAddServiceConnector,8002/OpenSim.Server.Handlers.dll:MapGetServiceConnector,8002/OpenSim.Server.Handlers.dll:IntegrationServiceConnector"
|
||||||
|
|
||||||
; * This is common for all services, it's the network setup for the entire
|
; * This is common for all services, it's the network setup for the entire
|
||||||
; * server instance, if none is specified above
|
; * server instance, if none is specified above
|
||||||
|
@ -327,3 +327,19 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
|
||||||
|
|
||||||
; password help: optional: page providing password assistance for users of your grid
|
; password help: optional: page providing password assistance for users of your grid
|
||||||
;password = http://127.0.0.1/password
|
;password = http://127.0.0.1/password
|
||||||
|
|
||||||
|
[IntegrationService]
|
||||||
|
|
||||||
|
LocalServiceModule = "OpenSim.Services.IntegrationService.dll:IntegrationService"
|
||||||
|
|
||||||
|
;; Location for plugin management data, default is "."
|
||||||
|
PluginRegistryLocation="/home/opensim/var/run/addin/Integration"
|
||||||
|
;;
|
||||||
|
;; Each plugin uses it's own ini (for now these are files only)
|
||||||
|
;; The initial files are supplied by the plugin when it is installed
|
||||||
|
;; and this is the location for the directory for these.
|
||||||
|
IntegrationConfig = "/home/opensim/etc/Integration"
|
||||||
|
|
||||||
|
GridService = "OpenSim.Services.GridService.dll:GridService"
|
||||||
|
PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService"
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
39
prebuild.xml
39
prebuild.xml
|
@ -733,6 +733,7 @@
|
||||||
<Reference name="System.Xml"/>
|
<Reference name="System.Xml"/>
|
||||||
<Reference name="System.Web"/>
|
<Reference name="System.Web"/>
|
||||||
<Reference name="OpenMetaverseTypes" path="../../../bin/"/>
|
<Reference name="OpenMetaverseTypes" path="../../../bin/"/>
|
||||||
|
<Reference name="OpenMetaverse.StructuredData" path="../../../bin/"/>
|
||||||
<Reference name="OpenMetaverse" path="../../../bin/"/>
|
<Reference name="OpenMetaverse" path="../../../bin/"/>
|
||||||
<Reference name="OpenSim.Framework"/>
|
<Reference name="OpenSim.Framework"/>
|
||||||
<Reference name="OpenSim.Framework.Console"/>
|
<Reference name="OpenSim.Framework.Console"/>
|
||||||
|
@ -1096,6 +1097,44 @@
|
||||||
</Files>
|
</Files>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
||||||
|
<Project frameworkVersion="v3_5" name="OpenSim.Services.IntegrationService" path="OpenSim/Services/IntegrationService" type="Library">
|
||||||
|
<Configuration name="Debug">
|
||||||
|
<Options>
|
||||||
|
<OutputPath>../../../bin/</OutputPath>
|
||||||
|
</Options>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration name="Release">
|
||||||
|
<Options>
|
||||||
|
<OutputPath>../../../bin/</OutputPath>
|
||||||
|
</Options>
|
||||||
|
</Configuration>
|
||||||
|
|
||||||
|
<ReferencePath>../../../bin/</ReferencePath>
|
||||||
|
<Reference name="System"/>
|
||||||
|
<Reference name="System.Core"/>
|
||||||
|
<Reference name="System.Xml"/>
|
||||||
|
<Reference name="OpenMetaverseTypes" path="../../../bin/"/>
|
||||||
|
<Reference name="OpenMetaverse" path="../../../bin/"/>
|
||||||
|
<Reference name="OpenMetaverse.StructuredData" path="../../../bin/"/>
|
||||||
|
<Reference name="OpenSim.Framework"/>
|
||||||
|
<Reference name="OpenSim.Framework.Console"/>
|
||||||
|
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
|
||||||
|
<Reference name="OpenSim.Services.Interfaces"/>
|
||||||
|
<Reference name="OpenSim.Services.Base"/>
|
||||||
|
<Reference name="OpenSim.Services.Connectors"/>
|
||||||
|
<Reference name="OpenSim.Data"/>
|
||||||
|
<Reference name="OpenSim.Server.Base"/>
|
||||||
|
<Reference name="Nini" path="../../../bin/"/>
|
||||||
|
<Reference name="log4net" path="../../../bin/"/>
|
||||||
|
<Reference name="Mono.Addins" path="../../../bin/"/>
|
||||||
|
<Reference name="Mono.Addins.Setup" path="../../../bin/"/>
|
||||||
|
<Reference name="Mono.Addins" path="../../../bin/"/>
|
||||||
|
|
||||||
|
<Files>
|
||||||
|
<Match pattern="*.cs" recurse="true"/>
|
||||||
|
</Files>
|
||||||
|
</Project>
|
||||||
|
|
||||||
<Project frameworkVersion="v3_5" name="OpenSim.Services.InventoryService" path="OpenSim/Services/InventoryService" type="Library">
|
<Project frameworkVersion="v3_5" name="OpenSim.Services.InventoryService" path="OpenSim/Services/InventoryService" type="Library">
|
||||||
<Configuration name="Debug">
|
<Configuration name="Debug">
|
||||||
<Options>
|
<Options>
|
||||||
|
|
Loading…
Reference in New Issue