From b46387091470f3d1465c05625a656228ca54fd61 Mon Sep 17 00:00:00 2001
From: BlueWall
Date: Mon, 27 Oct 2014 17:27:42 -0400
Subject: Add hypergrid teleporting support to user profiles picks
---
OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 8 +-
.../Data/MySQL/Resources/UserProfiles.migrations | 7 +-
OpenSim/Framework/UserProfiles.cs | 1 +
.../Avatar/UserProfiles/UserProfileModule.cs | 113 ++++++++++++++++++---
OpenSim/Services/LLLoginService/LLLoginService.cs | 7 ++
5 files changed, 117 insertions(+), 19 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
index c8479f0..cab0ca8 100644
--- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
@@ -397,6 +397,7 @@ namespace OpenSim.Data.MySQL
UUID.TryParse((string)reader["parceluuid"], out pick.ParcelId);
UUID.TryParse((string)reader["snapshotuuid"], out pick.SnapshotId);
pick.GlobalPos = (string)reader["posglobal"];
+ pick.Gatekeeper = (string)reader["gatekeeper"];
bool.TryParse((string)reader["toppick"], out pick.TopPick);
bool.TryParse((string)reader["enabled"], out pick.Enabled);
pick.Name = (string)reader["name"];
@@ -436,14 +437,16 @@ namespace OpenSim.Data.MySQL
query += "?SimName,";
query += "?GlobalPos,";
query += "?SortOrder,";
- query += "?Enabled) ";
+ query += "?Enabled,";
+ query += "?Gatekeeper)";
query += "ON DUPLICATE KEY UPDATE ";
query += "parceluuid=?ParcelId,";
query += "name=?Name,";
query += "description=?Desc,";
query += "snapshotuuid=?SnapshotId,";
query += "pickuuid=?PickId,";
- query += "posglobal=?GlobalPos";
+ query += "posglobal=?GlobalPos,";
+ query += "gatekeeper=?Gatekeeper";
try
{
@@ -463,6 +466,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?Original", pick.OriginalName.ToString());
cmd.Parameters.AddWithValue("?SimName",pick.SimName.ToString());
cmd.Parameters.AddWithValue("?GlobalPos", pick.GlobalPos);
+ cmd.Parameters.AddWithValue("?Gatekeeper",pick.Gatekeeper);
cmd.Parameters.AddWithValue("?SortOrder", pick.SortOrder.ToString ());
cmd.Parameters.AddWithValue("?Enabled", pick.Enabled.ToString());
diff --git a/OpenSim/Data/MySQL/Resources/UserProfiles.migrations b/OpenSim/Data/MySQL/Resources/UserProfiles.migrations
index bd325da..87e99fa 100644
--- a/OpenSim/Data/MySQL/Resources/UserProfiles.migrations
+++ b/OpenSim/Data/MySQL/Resources/UserProfiles.migrations
@@ -90,4 +90,9 @@ CREATE TABLE IF NOT EXISTS `usersettings` (
`email` varchar(254) NOT NULL,
PRIMARY KEY (`useruuid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-commit;
\ No newline at end of file
+commit;
+
+:VERSION 4 # -------------------------------
+begin;
+ALTER TABLE userpicks ADD COLUMN gatekeeper varchar(255);
+commit;
diff --git a/OpenSim/Framework/UserProfiles.cs b/OpenSim/Framework/UserProfiles.cs
index 492f6b9..bfc2f6b 100644
--- a/OpenSim/Framework/UserProfiles.cs
+++ b/OpenSim/Framework/UserProfiles.cs
@@ -80,6 +80,7 @@ namespace OpenSim.Framework
public string User = string.Empty;
public string SimName = string.Empty;
public string GlobalPos = "<0,0,0>";
+ public string Gatekeeper = string.Empty;
public int SortOrder = 0;
public bool Enabled = false;
}
diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
index f4a4f17..8337a2f 100644
--- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
@@ -48,6 +48,8 @@ using Mono.Addins;
using OpenSim.Services.Connectors.Hypergrid;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.UserProfilesService;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
+using Microsoft.CSharp;
namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
{
@@ -78,7 +80,8 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
///
/// The configuration
///
- public IConfigSource Config {
+ public IConfigSource Config
+ {
get;
set;
}
@@ -89,7 +92,8 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
///
/// The profile server URI.
///
- public string ProfileServerUri {
+ public string ProfileServerUri
+ {
get;
set;
}
@@ -111,11 +115,17 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
///
/// true if enabled; otherwise, false.
///
- public bool Enabled {
+ public bool Enabled
+ {
get;
set;
}
+ public string MyGatekeeper
+ {
+ get; private set;
+ }
+
#region IRegionModuleBase implementation
///
@@ -152,6 +162,9 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
m_log.Debug("[PROFILES]: Full Profiles Enabled");
ReplaceableInterface = null;
Enabled = true;
+
+ MyGatekeeper = Util.GetConfigVarFromSections(source, "GatekeeperURI",
+ new string[] { "Startup", "Hypergrid", "UserProfiles" }, String.Empty);
}
///
@@ -599,30 +612,64 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
return;
UUID targetID;
- UUID.TryParse(args[0], out targetID);
+ UUID.TryParse (args [0], out targetID);
string serverURI = string.Empty;
- GetUserProfileServerURI(targetID, out serverURI);
+ GetUserProfileServerURI (targetID, out serverURI);
+
+ string theirGatekeeperURI;
+ GetUserGatekeeperURI (targetID, out theirGatekeeperURI);
+
IClientAPI remoteClient = (IClientAPI)sender;
- UserProfilePick pick = new UserProfilePick();
- UUID.TryParse(args[0], out pick.CreatorId);
- UUID.TryParse(args[1], out pick.PickId);
+ UserProfilePick pick = new UserProfilePick ();
+ UUID.TryParse (args [0], out pick.CreatorId);
+ UUID.TryParse (args [1], out pick.PickId);
object Pick = (object)pick;
- if(!rpc.JsonRpcRequest(ref Pick, "pickinforequest", serverURI, UUID.Random().ToString()))
- {
- remoteClient.SendAgentAlertMessage(
+ if (!rpc.JsonRpcRequest (ref Pick, "pickinforequest", serverURI, UUID.Random ().ToString ())) {
+ remoteClient.SendAgentAlertMessage (
"Error selecting pick", false);
return;
}
- pick = (UserProfilePick) Pick;
-
- Vector3 globalPos;
- Vector3.TryParse(pick.GlobalPos,out globalPos);
+ pick = (UserProfilePick)Pick;
+
+ Vector3 globalPos = new Vector3(Vector3.Zero);
+
+ // Smoke and mirrors
+ if (pick.Gatekeeper == MyGatekeeper)
+ {
+ Vector3.TryParse(pick.GlobalPos,out globalPos);
+ }
+ else
+ {
+ // Setup the illusion
+ string region = string.Format("{0} {1}",pick.Gatekeeper,pick.SimName);
+ GridRegion target = Scene.GridService.GetRegionByName(Scene.RegionInfo.ScopeID, region);
+
+ if(target == null)
+ {
+ // This is a dead or unreachable region
+ }
+ else
+ {
+ // Work our slight of hand
+ int x = target.RegionLocX;
+ int y = target.RegionLocY;
+
+ dynamic synthX = globalPos.X - (globalPos.X/Constants.RegionSize) * Constants.RegionSize;
+ synthX += x;
+ globalPos.X = synthX;
+
+ dynamic synthY = globalPos.Y - (globalPos.Y/Constants.RegionSize) * Constants.RegionSize;
+ synthY += y;
+ globalPos.Y = synthY;
+ }
+ }
m_log.DebugFormat("[PROFILES]: PickInfoRequest: {0} : {1}", pick.Name.ToString(), pick.SnapshotId.ToString());
+ // Pull the rabbit out of the hat
remoteClient.SendPickInfoReply(pick.PickId,pick.CreatorId,pick.TopPick,pick.ParcelId,pick.Name,
pick.Desc,pick.SnapshotId,pick.User,pick.OriginalName,pick.SimName,
globalPos,pick.SortOrder,pick.Enabled);
@@ -659,7 +706,8 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
/// Enabled.
///
public void PickInfoUpdate(IClientAPI remoteClient, UUID pickID, UUID creatorID, bool topPick, string name, string desc, UUID snapshotID, int sortOrder, bool enabled)
- {
+ {
+ //TODO: See how this works with NPC, May need to test
m_log.DebugFormat("[PROFILES]: Start PickInfoUpdate Name: {0} PickId: {1} SnapshotId: {2}", name, pickID.ToString(), snapshotID.ToString());
UserProfilePick pick = new UserProfilePick();
@@ -699,6 +747,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
avaPos.X, avaPos.Y, p.Scene.Name);
}
+
pick.PickId = pickID;
pick.CreatorId = creatorID;
pick.TopPick = topPick;
@@ -708,6 +757,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
pick.SnapshotId = snapshotID;
pick.User = landOwnerName;
pick.SimName = remoteClient.Scene.RegionInfo.RegionName;
+ pick.Gatekeeper = MyGatekeeper;
pick.GlobalPos = posGlobal.ToString();
pick.SortOrder = sortOrder;
pick.Enabled = enabled;
@@ -1260,6 +1310,37 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
}
///
+ /// Gets the user gatekeeper server URI.
+ ///
+ ///
+ /// The user gatekeeper server URI.
+ ///
+ ///
+ /// If set to true user URI.
+ ///
+ ///
+ /// If set to true server URI.
+ ///
+ bool GetUserGatekeeperURI(UUID userID, out string serverURI)
+ {
+ bool local;
+ local = UserManagementModule.IsLocalGridUser(userID);
+
+ if (!local)
+ {
+ serverURI = UserManagementModule.GetUserServerURL(userID, "GatekeeperURI");
+ // Is Foreign
+ return true;
+ }
+ else
+ {
+ serverURI = MyGatekeeper;
+ // Is local
+ return false;
+ }
+ }
+
+ ///
/// Gets the user profile server UR.
///
///
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index 8059652..b1aabe6 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -945,6 +945,13 @@ namespace OpenSim.Services.LLLoginService
m_log.DebugFormat("[LLLOGIN SERVICE]: found new key {0} {1}", keyName, aCircuit.ServiceURLs[keyName]);
}
+ if (!account.ServiceURLs.ContainsKey("GatekeeperURI") && !string.IsNullOrEmpty(m_GatekeeperURL))
+ {
+ m_log.DebugFormat("[LLLOGIN SERVICE]: adding gatekeeper uri {0}", m_GatekeeperURL);
+ account.ServiceURLs["GatekeeperURI"] = m_GatekeeperURL;
+ newUrls = true;
+ }
+
// The grid operator decided to override the defaults in the
// [LoginService] configuration. Let's store the correct ones.
if (newUrls)
--
cgit v1.1