From 29355de6ee01b1f44f32ea45b9c06f636ae9a241 Mon Sep 17 00:00:00 2001
From: lbsa71
Date: Mon, 13 Apr 2009 20:04:18 +0000
Subject: * Some more experimental work on distributed assets. Nothing hotwired
yet. * Introduced preprocess step in FetchAsset (Might revert this later)
* Some minor CCC * Added actual implementation of GetUserProfile( uri ) and
the corresponding handler to OGS1. * Introduced non-functioning GetUserUri(
userProfile) awaiting user server wireup (this might move elsewhere)
---
OpenSim/Data/AssetDataBase.cs | 11 +-
OpenSim/Data/MSSQL/MSSQLAssetData.cs | 78 +++++-----
OpenSim/Data/MySQL/MySQLAssetData.cs | 36 ++---
OpenSim/Data/NHibernate/NHibernateAssetData.cs | 2 +-
OpenSim/Data/SQLite/SQLiteAssetData.cs | 2 +-
.../Framework/Communications/Cache/AssetCache.cs | 10 +-
OpenSim/Framework/Communications/IUserService.cs | 2 +
.../Communications/Tests/Cache/AssetCacheTests.cs | 5 +
.../Framework/Communications/UserManagerBase.cs | 8 +-
OpenSim/Framework/Servers/GetAssetStreamHandler.cs | 67 ++++++--
.../Communications/Hypergrid/HGUserServices.cs | 5 +
.../Region/Communications/OGS1/OGS1UserServices.cs | 168 ++++++++++++---------
12 files changed, 241 insertions(+), 153 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Data/AssetDataBase.cs b/OpenSim/Data/AssetDataBase.cs
index d699f17..e67d9cb 100644
--- a/OpenSim/Data/AssetDataBase.cs
+++ b/OpenSim/Data/AssetDataBase.cs
@@ -25,7 +25,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+using System;
using System.Collections.Generic;
+using System.Text;
+using System.Text.RegularExpressions;
using OpenMetaverse;
using OpenSim.Framework;
@@ -33,7 +36,13 @@ namespace OpenSim.Data
{
public abstract class AssetDataBase : IAssetDataPlugin
{
- public abstract AssetBase FetchAsset(UUID uuid);
+ public virtual AssetBase FetchAsset(UUID uuid)
+ {
+ return FetchStoredAsset(uuid);
+ }
+
+ protected abstract AssetBase FetchStoredAsset(UUID uuid);
+
public abstract void CreateAsset(AssetBase asset);
public abstract void UpdateAsset(AssetBase asset);
public abstract bool ExistsAsset(UUID uuid);
diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs
index 54578bc..927b02b 100644
--- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs
@@ -43,11 +43,11 @@ namespace OpenSim.Data.MSSQL
private const string _migrationStore = "AssetStore";
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- private long TicksToEpoch;
+ private long m_ticksToEpoch;
///
/// Database manager
///
- private MSSQLManager database;
+ private MSSQLManager m_database;
#region IPlugin Members
@@ -72,11 +72,11 @@ namespace OpenSim.Data.MSSQL
/// connect string
override public void Initialise(string connectionString)
{
- TicksToEpoch = new System.DateTime(1970, 1, 1).Ticks;
+ m_ticksToEpoch = new System.DateTime(1970, 1, 1).Ticks;
if (!string.IsNullOrEmpty(connectionString))
{
- database = new MSSQLManager(connectionString);
+ m_database = new MSSQLManager(connectionString);
}
else
{
@@ -88,13 +88,13 @@ namespace OpenSim.Data.MSSQL
string settingUserId = gridDataMSSqlFile.ParseFileReadValue("user_id");
string settingPassword = gridDataMSSqlFile.ParseFileReadValue("password");
- database =
+ m_database =
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
settingPassword);
}
//New migration to check for DB changes
- database.CheckMigration(_migrationStore);
+ m_database.CheckMigration(_migrationStore);
}
///
@@ -102,7 +102,7 @@ namespace OpenSim.Data.MSSQL
///
override public string Version
{
- get { return database.getVersion(); }
+ get { return m_database.getVersion(); }
}
///
@@ -118,15 +118,15 @@ namespace OpenSim.Data.MSSQL
#region IAssetDataPlugin Members
///
- /// Fetch Asset from database
+ /// Fetch Asset from m_database
///
/// the asset UUID
///
- override public AssetBase FetchAsset(UUID assetID)
+ override protected AssetBase FetchStoredAsset(UUID assetID)
{
- using (AutoClosingSqlCommand command = database.Query("SELECT * FROM assets WHERE id = @id"))
+ using (AutoClosingSqlCommand command = m_database.Query("SELECT * FROM assets WHERE id = @id"))
{
- command.Parameters.Add(database.CreateParameter("id", assetID));
+ command.Parameters.Add(m_database.CreateParameter("id", assetID));
using (IDataReader reader = command.ExecuteReader())
{
if (reader.Read())
@@ -148,7 +148,7 @@ namespace OpenSim.Data.MSSQL
}
///
- /// Create asset in database
+ /// Create asset in m_database
///
/// the asset
override public void CreateAsset(AssetBase asset)
@@ -158,33 +158,33 @@ namespace OpenSim.Data.MSSQL
return;
}
- using (AutoClosingSqlCommand command = database.Query(
+ using (AutoClosingSqlCommand command = m_database.Query(
"INSERT INTO assets ([id], [name], [description], [assetType], [local], [temporary], [create_time], [access_time], [data])" +
" VALUES " +
"(@id, @name, @description, @assetType, @local, @temporary, @create_time, @access_time, @data)"))
{
- int now = (int)((System.DateTime.Now.Ticks - TicksToEpoch) / 10000000);
- command.Parameters.Add(database.CreateParameter("id", asset.FullID));
- command.Parameters.Add(database.CreateParameter("name", asset.Name));
- command.Parameters.Add(database.CreateParameter("description", asset.Description));
- command.Parameters.Add(database.CreateParameter("assetType", asset.Type));
- command.Parameters.Add(database.CreateParameter("local", asset.Local));
- command.Parameters.Add(database.CreateParameter("temporary", asset.Temporary));
- command.Parameters.Add(database.CreateParameter("access_time", now));
- command.Parameters.Add(database.CreateParameter("create_time", now));
- command.Parameters.Add(database.CreateParameter("data", asset.Data));
+ int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000);
+ command.Parameters.Add(m_database.CreateParameter("id", asset.FullID));
+ command.Parameters.Add(m_database.CreateParameter("name", asset.Name));
+ command.Parameters.Add(m_database.CreateParameter("description", asset.Description));
+ command.Parameters.Add(m_database.CreateParameter("assetType", asset.Type));
+ command.Parameters.Add(m_database.CreateParameter("local", asset.Local));
+ command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary));
+ command.Parameters.Add(m_database.CreateParameter("access_time", now));
+ command.Parameters.Add(m_database.CreateParameter("create_time", now));
+ command.Parameters.Add(m_database.CreateParameter("data", asset.Data));
command.ExecuteNonQuery();
}
}
///
- /// Update asset in database
+ /// Update asset in m_database
///
/// the asset
override public void UpdateAsset(AssetBase asset)
{
- using (AutoClosingSqlCommand command = database.Query("UPDATE assets set id = @id, " +
+ using (AutoClosingSqlCommand command = m_database.Query("UPDATE assets set id = @id, " +
"name = @name, " +
"description = @description," +
"assetType = @assetType," +
@@ -193,14 +193,14 @@ namespace OpenSim.Data.MSSQL
"data = @data where " +
"id = @keyId;"))
{
- command.Parameters.Add(database.CreateParameter("id", asset.FullID));
- command.Parameters.Add(database.CreateParameter("name", asset.Name));
- command.Parameters.Add(database.CreateParameter("description", asset.Description));
- command.Parameters.Add(database.CreateParameter("assetType", asset.Type));
- command.Parameters.Add(database.CreateParameter("local", asset.Local));
- command.Parameters.Add(database.CreateParameter("temporary", asset.Temporary));
- command.Parameters.Add(database.CreateParameter("data", asset.Data));
- command.Parameters.Add(database.CreateParameter("@keyId", asset.FullID));
+ command.Parameters.Add(m_database.CreateParameter("id", asset.FullID));
+ command.Parameters.Add(m_database.CreateParameter("name", asset.Name));
+ command.Parameters.Add(m_database.CreateParameter("description", asset.Description));
+ command.Parameters.Add(m_database.CreateParameter("assetType", asset.Type));
+ command.Parameters.Add(m_database.CreateParameter("local", asset.Local));
+ command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary));
+ command.Parameters.Add(m_database.CreateParameter("data", asset.Data));
+ command.Parameters.Add(m_database.CreateParameter("@keyId", asset.FullID));
try
{
@@ -216,9 +216,9 @@ namespace OpenSim.Data.MSSQL
// Commented out since currently unused - this probably should be called in FetchAsset()
// private void UpdateAccessTime(AssetBase asset)
// {
-// using (AutoClosingSqlCommand cmd = database.Query("UPDATE assets SET access_time = @access_time WHERE id=@id"))
+// using (AutoClosingSqlCommand cmd = m_database.Query("UPDATE assets SET access_time = @access_time WHERE id=@id"))
// {
-// int now = (int)((System.DateTime.Now.Ticks - TicksToEpoch) / 10000000);
+// int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000);
// cmd.Parameters.AddWithValue("@id", asset.FullID.ToString());
// cmd.Parameters.AddWithValue("@access_time", now);
// try
@@ -233,7 +233,7 @@ namespace OpenSim.Data.MSSQL
// }
///
- /// Check if asset exist in database
+ /// Check if asset exist in m_database
///
///
/// true if exist.
@@ -258,10 +258,10 @@ namespace OpenSim.Data.MSSQL
{
List retList = new List(count);
- using (AutoClosingSqlCommand command = database.Query("SELECT (name,description,assetType,temporary,id), Row = ROW_NUMBER() OVER (ORDER BY (some column to order by)) WHERE Row >= @Start AND Row < @Start + @Count"))
+ using (AutoClosingSqlCommand command = m_database.Query("SELECT (name,description,assetType,temporary,id), Row = ROW_NUMBER() OVER (ORDER BY (some column to order by)) WHERE Row >= @Start AND Row < @Start + @Count"))
{
- command.Parameters.Add(database.CreateParameter("start", start));
- command.Parameters.Add(database.CreateParameter("count", count));
+ command.Parameters.Add(m_database.CreateParameter("start", start));
+ command.Parameters.Add(m_database.CreateParameter("count", count));
using (IDataReader reader = command.ExecuteReader())
{
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index 20b2673..cc16389 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -109,6 +109,24 @@ namespace OpenSim.Data.MySQL
public override void Dispose() { }
+ ///
+ /// Database provider version
+ ///
+ override public string Version
+ {
+ get { return _dbConnection.getVersion(); }
+ }
+
+ ///
+ /// The name of this DB provider
+ ///
+ override public string Name
+ {
+ get { return "MySQL Asset storage engine"; }
+ }
+
+ #endregion
+
#region IAssetDataPlugin Members
///
@@ -117,7 +135,7 @@ namespace OpenSim.Data.MySQL
/// Asset UUID to fetch
/// Return the asset
/// On failure : throw an exception and attempt to reconnect to database
- override public AssetBase FetchAsset(UUID assetID)
+ override protected AssetBase FetchStoredAsset(UUID assetID)
{
AssetBase asset = null;
lock (_dbConnection)
@@ -364,22 +382,6 @@ namespace OpenSim.Data.MySQL
#endregion
- ///
- /// Database provider version
- ///
- override public string Version
- {
- get { return _dbConnection.getVersion(); }
- }
- ///
- /// The name of this DB provider
- ///
- override public string Name
- {
- get { return "MySQL Asset storage engine"; }
- }
-
- #endregion
}
}
diff --git a/OpenSim/Data/NHibernate/NHibernateAssetData.cs b/OpenSim/Data/NHibernate/NHibernateAssetData.cs
index 4e8f708..6e13dbb 100644
--- a/OpenSim/Data/NHibernate/NHibernateAssetData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateAssetData.cs
@@ -65,7 +65,7 @@ namespace OpenSim.Data.NHibernate
}
- override public AssetBase FetchAsset(UUID uuid)
+ override protected AssetBase FetchStoredAsset(UUID uuid)
{
return (AssetBase)manager.Get(typeof(AssetBase), uuid);
}
diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs
index d3f1308..41a75a3 100644
--- a/OpenSim/Data/SQLite/SQLiteAssetData.cs
+++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs
@@ -90,7 +90,7 @@ namespace OpenSim.Data.SQLite
///
/// UUID of ... ?
/// Asset base
- override public AssetBase FetchAsset(UUID uuid)
+ override protected AssetBase FetchStoredAsset(UUID uuid)
{
lock (this)
{
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs
index cbb2a5a..4d2db17 100644
--- a/OpenSim/Framework/Communications/Cache/AssetCache.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs
@@ -336,7 +336,7 @@ namespace OpenSim.Framework.Communications.Cache
{
AssetInfo assetInf = new AssetInfo(asset);
- ProcessReceivedAsset(IsTexture, assetInf);
+ ProcessReceivedAsset(IsTexture, assetInf, null);
if (!m_memcache.Contains(assetInf.FullID))
{
@@ -391,11 +391,11 @@ namespace OpenSim.Framework.Communications.Cache
}
}
- protected void ProcessReceivedAsset(bool IsTexture, AssetInfo assetInf)
+ protected void ProcessReceivedAsset(bool IsTexture, AssetInfo assetInf, IUserService userService)
{
if(!IsTexture && assetInf.ContainsReferences && false )
{
- assetInf.Data = ProcessAssetData(assetInf.Data);
+ assetInf.Data = ProcessAssetData(assetInf.Data, userService );
}
}
@@ -554,11 +554,11 @@ namespace OpenSim.Framework.Communications.Cache
}
}
- public byte[] ProcessAssetData(byte[] assetData)
+ public byte[] ProcessAssetData(byte[] assetData, IUserService userService)
{
string data = Encoding.ASCII.GetString(assetData);
- data = ProcessAssetDataString(data, null);
+ data = ProcessAssetDataString(data, userService );
return Encoding.ASCII.GetBytes( data );
}
diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs
index 38c360a..3c09b40 100644
--- a/OpenSim/Framework/Communications/IUserService.cs
+++ b/OpenSim/Framework/Communications/IUserService.cs
@@ -50,6 +50,8 @@ namespace OpenSim.Framework.Communications
UserProfileData GetUserProfile(Uri uri);
+ Uri GetUserUri(UserProfileData userProfile);
+
UserAgentData GetAgentByUUID(UUID userId);
void ClearUserAgent(UUID avatarID);
diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs
index 3779f55..9d9810b 100644
--- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs
+++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs
@@ -108,6 +108,11 @@ namespace OpenSim.Framework.Communications.Tests
return userProfile;
}
+ public Uri GetUserUri(UserProfileData userProfile)
+ {
+ throw new NotImplementedException();
+ }
+
public UserAgentData GetAgentByUUID(UUID userId)
{
throw new NotImplementedException();
diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs
index b7280d3..155f5cd 100644
--- a/OpenSim/Framework/Communications/UserManagerBase.cs
+++ b/OpenSim/Framework/Communications/UserManagerBase.cs
@@ -124,7 +124,7 @@ namespace OpenSim.Framework.Communications
public UserProfileData GetUserProfile(Uri uri)
{
- throw new System.NotImplementedException();
+ throw new NotImplementedException();
}
public UserAgentData GetAgentByUUID(UUID userId)
@@ -142,6 +142,11 @@ namespace OpenSim.Framework.Communications
return null;
}
+ public Uri GetUserUri(UserProfileData userProfile)
+ {
+ throw new NotImplementedException();
+ }
+
// see IUserService
public virtual UserProfileData GetUserProfile(UUID uuid)
{
@@ -835,6 +840,5 @@ namespace OpenSim.Framework.Communications
}
#endregion
-
}
}
diff --git a/OpenSim/Framework/Servers/GetAssetStreamHandler.cs b/OpenSim/Framework/Servers/GetAssetStreamHandler.cs
index 91d1a28..ffd7ef4 100644
--- a/OpenSim/Framework/Servers/GetAssetStreamHandler.cs
+++ b/OpenSim/Framework/Servers/GetAssetStreamHandler.cs
@@ -29,6 +29,7 @@ using System;
using System.IO;
using System.Reflection;
using System.Text;
+using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Serialization;
using log4net;
@@ -64,9 +65,9 @@ namespace OpenSim.Framework.Servers
OSHttpRequest httpRequest, OSHttpResponse httpResponse)
{
string param = GetParam(path);
- byte[] result = new byte[] {};
+ byte[] result = new byte[] { };
- string[] p = param.Split(new char[] {'/', '?', '&'}, StringSplitOptions.RemoveEmptyEntries);
+ string[] p = param.Split(new char[] { '/', '?', '&' }, StringSplitOptions.RemoveEmptyEntries);
if (p.Length > 0)
{
@@ -85,7 +86,12 @@ namespace OpenSim.Framework.Servers
AssetBase asset = m_assetProvider.FetchAsset(assetID);
if (asset != null)
{
- XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
+ if (asset.ContainsReferences && false)
+ {
+ asset.Data = ProcessOutgoingAssetData(asset.Data);
+ }
+
+ XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
MemoryStream ms = new MemoryStream();
XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8);
xw.Formatting = Formatting.Indented;
@@ -97,15 +103,7 @@ namespace OpenSim.Framework.Servers
result = ms.GetBuffer();
-//Ckrinke 1/11/09 Commenting out the succesful REST message as under heavy use there
-//are multiple messages in a second and that is usually (in my experience) meaning
-//the logging itself is slowing down the program. Leaving the unsuccesful message
-//as we need to know about that path.
-// m_log.InfoFormat(
-// "[REST]: GET:/asset found {0} with name {1}, size {2} bytes",
-// assetID, asset.Name, result.Length);
-
- Array.Resize(ref result, (int) ms.Length);
+ Array.Resize(ref result, (int)ms.Length);
}
else
{
@@ -118,5 +116,50 @@ namespace OpenSim.Framework.Servers
return result;
}
+
+ private byte[] ProcessOutgoingAssetData(byte[] assetData)
+ {
+ string data = Encoding.ASCII.GetString(assetData);
+
+ data = ProcessAssetDataString(data);
+
+ return Encoding.ASCII.GetBytes(data);
+ }
+
+ public string ProcessAssetDataString(string data)
+ {
+ Regex regex = new Regex("(creator_id|owner_id)\\s+(\\S+)");
+
+ // IUserService userService = null;
+
+ data = regex.Replace(data, delegate(Match m)
+ {
+ string result = String.Empty;
+
+ string key = m.Groups[1].Captures[0].Value;
+
+ string value = m.Groups[2].Captures[0].Value;
+
+ Guid userUri;
+
+ switch (key)
+ {
+ case "creator_id":
+ userUri = new Guid(value);
+ // result = "creator_url " + userService(userService, userUri);
+ break;
+
+ case "owner_id":
+ userUri = new Guid(value);
+ // result = "owner_url " + ResolveUserUri(userService, userUri);
+ break;
+ }
+
+ return result;
+ });
+
+ return data;
+ }
+
}
}
\ No newline at end of file
diff --git a/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs b/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs
index 6a39876..ef08421 100644
--- a/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs
+++ b/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs
@@ -63,6 +63,11 @@ namespace OpenSim.Region.Communications.Hypergrid
throw new System.NotImplementedException();
}
+ public Uri GetUserUri(UserProfileData userProfile)
+ {
+ throw new NotImplementedException();
+ }
+
///
/// Get a user agent from the user server
///
diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
index 09c1d6a..3fe78a3 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
@@ -31,6 +31,7 @@ using System.Collections.Generic;
using System.Net;
using System.Reflection;
using System.Text.RegularExpressions;
+using System.Xml.Serialization;
using log4net;
using Nwc.XmlRpc;
using OpenMetaverse;
@@ -62,46 +63,46 @@ namespace OpenSim.Region.Communications.OGS1
}
UserProfileData userData = new UserProfileData();
- userData.FirstName = (string) data["firstname"];
- userData.SurName = (string) data["lastname"];
- userData.ID = new UUID((string) data["uuid"]);
+ userData.FirstName = (string)data["firstname"];
+ userData.SurName = (string)data["lastname"];
+ userData.ID = new UUID((string)data["uuid"]);
userData.Created = Convert.ToInt32(data["profile_created"]);
- userData.UserInventoryURI = (string) data["server_inventory"];
- userData.UserAssetURI = (string) data["server_asset"];
- userData.FirstLifeAboutText = (string) data["profile_firstlife_about"];
- userData.FirstLifeImage = new UUID((string) data["profile_firstlife_image"]);
- userData.CanDoMask = Convert.ToUInt32((string) data["profile_can_do"]);
+ userData.UserInventoryURI = (string)data["server_inventory"];
+ userData.UserAssetURI = (string)data["server_asset"];
+ userData.FirstLifeAboutText = (string)data["profile_firstlife_about"];
+ userData.FirstLifeImage = new UUID((string)data["profile_firstlife_image"]);
+ userData.CanDoMask = Convert.ToUInt32((string)data["profile_can_do"]);
userData.WantDoMask = Convert.ToUInt32(data["profile_want_do"]);
userData.AboutText = (string)data["profile_about"];
- userData.Image = new UUID((string) data["profile_image"]);
- userData.LastLogin = Convert.ToInt32((string) data["profile_lastlogin"]);
- userData.HomeRegion = Convert.ToUInt64((string) data["home_region"]);
+ userData.Image = new UUID((string)data["profile_image"]);
+ userData.LastLogin = Convert.ToInt32((string)data["profile_lastlogin"]);
+ userData.HomeRegion = Convert.ToUInt64((string)data["home_region"]);
if (data.Contains("home_region_id"))
userData.HomeRegionID = new UUID((string)data["home_region_id"]);
else
userData.HomeRegionID = UUID.Zero;
userData.HomeLocation =
- new Vector3((float) Convert.ToDecimal((string) data["home_coordinates_x"]),
- (float) Convert.ToDecimal((string) data["home_coordinates_y"]),
- (float) Convert.ToDecimal((string) data["home_coordinates_z"]));
+ new Vector3((float)Convert.ToDecimal((string)data["home_coordinates_x"]),
+ (float)Convert.ToDecimal((string)data["home_coordinates_y"]),
+ (float)Convert.ToDecimal((string)data["home_coordinates_z"]));
userData.HomeLookAt =
- new Vector3((float) Convert.ToDecimal((string) data["home_look_x"]),
- (float) Convert.ToDecimal((string) data["home_look_y"]),
- (float) Convert.ToDecimal((string) data["home_look_z"]));
+ new Vector3((float)Convert.ToDecimal((string)data["home_look_x"]),
+ (float)Convert.ToDecimal((string)data["home_look_y"]),
+ (float)Convert.ToDecimal((string)data["home_look_z"]));
if (data.Contains("user_flags"))
- userData.UserFlags = Convert.ToInt32((string) data["user_flags"]);
+ userData.UserFlags = Convert.ToInt32((string)data["user_flags"]);
if (data.Contains("god_level"))
- userData.GodLevel = Convert.ToInt32((string) data["god_level"]);
+ userData.GodLevel = Convert.ToInt32((string)data["god_level"]);
if (data.Contains("custom_type"))
- userData.CustomType = (string) data["custom_type"];
+ userData.CustomType = (string)data["custom_type"];
else
userData.CustomType = "";
if (userData.CustomType == null)
userData.CustomType = "";
if (data.Contains("partner"))
- userData.Partner = new UUID((string) data["partner"]);
+ userData.Partner = new UUID((string)data["partner"]);
else
userData.Partner = UUID.Zero;
@@ -110,7 +111,21 @@ namespace OpenSim.Region.Communications.OGS1
public UserProfileData GetUserProfile(Uri uri)
{
- throw new System.NotImplementedException();
+ WebRequest request = WebRequest.Create(uri);
+
+ WebResponse webResponse = request.GetResponse();
+
+ XmlSerializer deserializer = new XmlSerializer(typeof(XmlRpcResponse));
+ XmlRpcResponse xmlRpcResponse = (XmlRpcResponse)deserializer.Deserialize(webResponse.GetResponseStream());
+
+ Hashtable respData = (Hashtable)xmlRpcResponse.Value;
+
+ return ConvertXMLRPCDataToUserProfile(respData);
+ }
+
+ public Uri GetUserUri(UserProfileData userProfile)
+ {
+ throw new NotImplementedException();
}
///
@@ -120,40 +135,42 @@ namespace OpenSim.Region.Communications.OGS1
/// null if the request fails
public UserAgentData GetAgentByUUID(UUID userId)
{
- try
- {
- Hashtable param = new Hashtable();
- param["avatar_uuid"] = userId.ToString();
- IList parameters = new ArrayList();
- parameters.Add(param);
- XmlRpcRequest req = new XmlRpcRequest("get_agent_by_uuid", parameters);
- XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 6000);
- Hashtable respData = (Hashtable) resp.Value;
- if (respData.Contains("error_type"))
- {
- //m_log.Warn("[GRID]: " +
- // "Error sent by user server when trying to get agent: (" +
- // (string) respData["error_type"] +
- // "): " + (string)respData["error_desc"]);
- return null;
- }
- UUID sessionid = UUID.Zero;
-
- UserAgentData userAgent = new UserAgentData();
- userAgent.Handle = Convert.ToUInt64((string)respData["handle"]);
- UUID.TryParse((string)respData["sessionid"], out sessionid);
- userAgent.SessionID = sessionid;
-
- if ((string)respData["agent_online"] == "TRUE")
- {
- userAgent.AgentOnline = true;
- }
- else
- {
- userAgent.AgentOnline = false;
- }
-
- return userAgent;
+ try
+ {
+ Hashtable param = new Hashtable();
+ param["avatar_uuid"] = userId.ToString();
+ IList parameters = new ArrayList();
+ parameters.Add(param);
+ XmlRpcRequest req = new XmlRpcRequest("get_agent_by_uuid", parameters);
+ string url = m_commsManager.NetworkServersInfo.UserURL;
+
+ XmlRpcResponse resp = req.Send(url, 6000);
+ Hashtable respData = (Hashtable)resp.Value;
+ if (respData.Contains("error_type"))
+ {
+ //m_log.Warn("[GRID]: " +
+ // "Error sent by user server when trying to get agent: (" +
+ // (string) respData["error_type"] +
+ // "): " + (string)respData["error_desc"]);
+ return null;
+ }
+ UUID sessionid = UUID.Zero;
+
+ UserAgentData userAgent = new UserAgentData();
+ userAgent.Handle = Convert.ToUInt64((string)respData["handle"]);
+ UUID.TryParse((string)respData["sessionid"], out sessionid);
+ userAgent.SessionID = sessionid;
+
+ if ((string)respData["agent_online"] == "TRUE")
+ {
+ userAgent.AgentOnline = true;
+ }
+ else
+ {
+ userAgent.AgentOnline = false;
+ }
+
+ return userAgent;
}
catch (Exception e)
{
@@ -192,16 +209,16 @@ namespace OpenSim.Region.Communications.OGS1
public List ConvertXMLRPCDataToAvatarPickerList(UUID queryID, Hashtable data)
{
List pickerlist = new List();
- int pickercount = Convert.ToInt32((string) data["avcount"]);
- UUID respqueryID = new UUID((string) data["queryid"]);
+ int pickercount = Convert.ToInt32((string)data["avcount"]);
+ UUID respqueryID = new UUID((string)data["queryid"]);
if (queryID == respqueryID)
{
for (int i = 0; i < pickercount; i++)
{
AvatarPickerAvatar apicker = new AvatarPickerAvatar();
- UUID avatarID = new UUID((string) data["avatarid" + i.ToString()]);
- string firstname = (string) data["firstname" + i.ToString()];
- string lastname = (string) data["lastname" + i.ToString()];
+ UUID avatarID = new UUID((string)data["avatarid" + i.ToString()]);
+ string firstname = (string)data["firstname" + i.ToString()];
+ string lastname = (string)data["lastname" + i.ToString()];
apicker.AvatarID = avatarID;
apicker.firstName = firstname;
apicker.lastName = lastname;
@@ -298,13 +315,13 @@ namespace OpenSim.Region.Communications.OGS1
try
{
Hashtable param = new Hashtable();
- param["queryid"] = (string) queryID.ToString();
+ param["queryid"] = (string)queryID.ToString();
param["avquery"] = objAlphaNumericPattern.Replace(query, String.Empty);
IList parameters = new ArrayList();
parameters.Add(param);
XmlRpcRequest req = new XmlRpcRequest("get_avatar_picker_avatar", parameters);
XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 3000);
- Hashtable respData = (Hashtable) resp.Value;
+ Hashtable respData = (Hashtable)resp.Value;
pickerlist = ConvertXMLRPCDataToAvatarPickerList(queryID, respData);
}
catch (WebException e)
@@ -331,7 +348,7 @@ namespace OpenSim.Region.Communications.OGS1
parameters.Add(param);
XmlRpcRequest req = new XmlRpcRequest("get_user_by_name", parameters);
XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000);
- Hashtable respData = (Hashtable) resp.Value;
+ Hashtable respData = (Hashtable)resp.Value;
return ConvertXMLRPCDataToUserProfile(respData);
}
@@ -360,7 +377,7 @@ namespace OpenSim.Region.Communications.OGS1
parameters.Add(param);
XmlRpcRequest req = new XmlRpcRequest("get_user_by_uuid", parameters);
XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000);
- Hashtable respData = (Hashtable) resp.Value;
+ Hashtable respData = (Hashtable)resp.Value;
return ConvertXMLRPCDataToUserProfile(respData);
}
@@ -423,11 +440,11 @@ namespace OpenSim.Region.Communications.OGS1
{
throw new Exception("The method or operation is not implemented.");
}
-
+
public bool ResetUserPassword(string firstName, string lastName, string newPassword)
{
throw new Exception("The method or operation is not implemented.");
- }
+ }
public bool UpdateUserProfile(UserProfileData userProfile)
{
@@ -483,7 +500,7 @@ namespace OpenSim.Region.Communications.OGS1
m_log.Warn("[GRID]: Unable to update user profile, UserServer didn't understand me!");
return false;
}
-
+
return true;
}
@@ -659,7 +676,7 @@ namespace OpenSim.Region.Communications.OGS1
parameters.Add(param);
XmlRpcRequest req = new XmlRpcRequest("get_user_friend_list", parameters);
XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 8000);
- Hashtable respData = (Hashtable) resp.Value;
+ Hashtable respData = (Hashtable)resp.Value;
if (respData != null && respData.Contains("avcount"))
{
@@ -676,7 +693,7 @@ namespace OpenSim.Region.Communications.OGS1
return buddylist;
}
- public Dictionary GetFriendRegionInfos (List uuids)
+ public Dictionary GetFriendRegionInfos(List uuids)
{
Dictionary result = new Dictionary();
@@ -697,10 +714,11 @@ namespace OpenSim.Region.Communications.OGS1
parameters.Add(map);
- try {
+ try
+ {
XmlRpcRequest req = new XmlRpcRequest("get_presence_info_bulk", parameters);
XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.MessagingURL, 8000);
- Hashtable respData = resp != null ? (Hashtable) resp.Value : null;
+ Hashtable respData = resp != null ? (Hashtable)resp.Value : null;
if (respData == null || respData.ContainsKey("faultMessage"))
{
@@ -748,7 +766,7 @@ namespace OpenSim.Region.Communications.OGS1
{
m_log.ErrorFormat("[OGS1 USER SERVICES]: Network problems when trying to fetch friend infos: {0}", e.Message);
}
-
+
m_log.DebugFormat("[OGS1 USER SERVICES]: Returning {0} entries", result.Count);
return result;
}
@@ -769,7 +787,7 @@ namespace OpenSim.Region.Communications.OGS1
parameters.Add(param);
XmlRpcRequest req = new XmlRpcRequest("get_avatar_appearance", parameters);
XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 8000);
- Hashtable respData = (Hashtable) resp.Value;
+ Hashtable respData = (Hashtable)resp.Value;
return ConvertXMLRPCDataToAvatarAppearance(respData);
}
@@ -792,7 +810,7 @@ namespace OpenSim.Region.Communications.OGS1
parameters.Add(param);
XmlRpcRequest req = new XmlRpcRequest("update_avatar_appearance", parameters);
XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 8000);
- Hashtable respData = (Hashtable) resp.Value;
+ Hashtable respData = (Hashtable)resp.Value;
if (respData != null)
{
--
cgit v1.1