When you change the name of a inventory item, it should no longer revert after a logout / login
parent
feaf036aa2
commit
b2ae86dd6a
|
@ -44,102 +44,114 @@ using OpenSim.Framework.Console;
|
||||||
|
|
||||||
namespace OpenGridServices.UserServer
|
namespace OpenGridServices.UserServer
|
||||||
{
|
{
|
||||||
public class UserHTTPServer {
|
public class UserHTTPServer
|
||||||
public Thread HTTPD;
|
{
|
||||||
public HttpListener Listener;
|
public Thread HTTPD;
|
||||||
|
public HttpListener Listener;
|
||||||
public UserHTTPServer() {
|
|
||||||
MainConsole.Instance.WriteLine("Starting up HTTP Server");
|
|
||||||
HTTPD = new Thread(new ThreadStart(StartHTTP));
|
|
||||||
HTTPD.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void StartHTTP() {
|
public UserHTTPServer()
|
||||||
MainConsole.Instance.WriteLine("UserHttp.cs:StartHTTP() - Spawned main thread OK");
|
{
|
||||||
Listener = new HttpListener();
|
MainConsole.Instance.WriteLine("Starting up HTTP Server");
|
||||||
|
HTTPD = new Thread(new ThreadStart(StartHTTP));
|
||||||
|
HTTPD.Start();
|
||||||
|
}
|
||||||
|
|
||||||
Listener.Prefixes.Add("http://+:8002/userserver/");
|
public void StartHTTP()
|
||||||
Listener.Prefixes.Add("http://+:8002/usersessions/");
|
{
|
||||||
Listener.Start();
|
MainConsole.Instance.WriteLine("UserHttp.cs:StartHTTP() - Spawned main thread OK");
|
||||||
|
Listener = new HttpListener();
|
||||||
|
|
||||||
HttpListenerContext context;
|
Listener.Prefixes.Add("http://+:8002/userserver/");
|
||||||
while(true) {
|
Listener.Prefixes.Add("http://+:8002/usersessions/");
|
||||||
context = Listener.GetContext();
|
Listener.Start();
|
||||||
ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static string ParseXMLRPC(string requestBody) {
|
HttpListenerContext context;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
context = Listener.GetContext();
|
||||||
|
ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static string ParseXMLRPC(string requestBody)
|
||||||
|
{
|
||||||
return OpenUser_Main.userserver._profilemanager.ParseXMLRPC(requestBody);
|
return OpenUser_Main.userserver._profilemanager.ParseXMLRPC(requestBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
static string ParseREST(HttpListenerRequest www_req) {
|
|
||||||
Console.WriteLine("INCOMING REST - " + www_req.RawUrl);
|
|
||||||
|
|
||||||
char[] splitter = {'/'};
|
|
||||||
string[] rest_params = www_req.RawUrl.Split(splitter);
|
|
||||||
string req_type = rest_params[1]; // First part of the URL is the type of request - usersessions/userprofiles/inventory/blabla
|
|
||||||
switch(req_type) {
|
|
||||||
case "usersessions":
|
|
||||||
LLUUID sessionid = new LLUUID(rest_params[2]); // get usersessions/sessionid
|
|
||||||
if(www_req.HttpMethod=="DELETE") {
|
|
||||||
foreach (libsecondlife.LLUUID UUID in OpenUser_Main.userserver._profilemanager.UserProfiles.Keys) {
|
|
||||||
if(OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID==sessionid) {
|
|
||||||
OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID=null;
|
|
||||||
OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSecureSessionID=null;
|
|
||||||
OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].Circuits.Clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
static string ParseREST(HttpListenerRequest www_req)
|
||||||
return "OK";
|
{
|
||||||
}
|
Console.WriteLine("INCOMING REST - " + www_req.RawUrl);
|
||||||
|
|
||||||
return "";
|
char[] splitter = { '/' };
|
||||||
}
|
string[] rest_params = www_req.RawUrl.Split(splitter);
|
||||||
|
string req_type = rest_params[1]; // First part of the URL is the type of request - usersessions/userprofiles/inventory/blabla
|
||||||
|
switch (req_type)
|
||||||
|
{
|
||||||
|
case "usersessions":
|
||||||
|
LLUUID sessionid = new LLUUID(rest_params[2]); // get usersessions/sessionid
|
||||||
|
if (www_req.HttpMethod == "DELETE")
|
||||||
|
{
|
||||||
|
foreach (libsecondlife.LLUUID UUID in OpenUser_Main.userserver._profilemanager.UserProfiles.Keys)
|
||||||
|
{
|
||||||
|
if (OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID == sessionid)
|
||||||
|
{
|
||||||
|
OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID = null;
|
||||||
|
OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSecureSessionID = null;
|
||||||
|
OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].Circuits.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return "OK";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void HandleRequest(Object stateinfo) {
|
static void HandleRequest(Object stateinfo)
|
||||||
HttpListenerContext context=(HttpListenerContext)stateinfo;
|
{
|
||||||
|
HttpListenerContext context = (HttpListenerContext)stateinfo;
|
||||||
HttpListenerRequest request = context.Request;
|
|
||||||
HttpListenerResponse response = context.Response;
|
|
||||||
|
|
||||||
response.KeepAlive=false;
|
HttpListenerRequest request = context.Request;
|
||||||
response.SendChunked=false;
|
HttpListenerResponse response = context.Response;
|
||||||
|
|
||||||
System.IO.Stream body = request.InputStream;
|
response.KeepAlive = false;
|
||||||
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
|
response.SendChunked = false;
|
||||||
System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
|
|
||||||
|
|
||||||
string requestBody = reader.ReadToEnd();
|
|
||||||
body.Close();
|
|
||||||
reader.Close();
|
|
||||||
|
|
||||||
string responseString="";
|
System.IO.Stream body = request.InputStream;
|
||||||
switch(request.ContentType) {
|
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
|
||||||
case "text/xml":
|
System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
|
||||||
// must be XML-RPC, so pass to the XML-RPC parser
|
|
||||||
|
string requestBody = reader.ReadToEnd();
|
||||||
responseString=ParseXMLRPC(requestBody);
|
body.Close();
|
||||||
response.AddHeader("Content-type","text/xml");
|
reader.Close();
|
||||||
break;
|
|
||||||
|
string responseString = "";
|
||||||
case "text/plaintext":
|
switch (request.ContentType)
|
||||||
responseString=ParseREST(request);
|
{
|
||||||
response.AddHeader("Content-type","text/plaintext");
|
case "text/xml":
|
||||||
break;
|
// must be XML-RPC, so pass to the XML-RPC parser
|
||||||
}
|
|
||||||
|
responseString = ParseXMLRPC(requestBody);
|
||||||
|
response.AddHeader("Content-type", "text/xml");
|
||||||
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
|
break;
|
||||||
System.IO.Stream output = response.OutputStream;
|
|
||||||
response.SendChunked=false;
|
case "text/plaintext":
|
||||||
response.ContentLength64=buffer.Length;
|
responseString = ParseREST(request);
|
||||||
output.Write(buffer,0,buffer.Length);
|
response.AddHeader("Content-type", "text/plaintext");
|
||||||
output.Close();
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
|
||||||
|
System.IO.Stream output = response.OutputStream;
|
||||||
|
response.SendChunked = false;
|
||||||
|
response.ContentLength64 = buffer.Length;
|
||||||
|
output.Write(buffer, 0, buffer.Length);
|
||||||
|
output.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
|
using libsecondlife.Packets;
|
||||||
using OpenSim.Framework.Assets;
|
using OpenSim.Framework.Assets;
|
||||||
|
|
||||||
namespace OpenSim.Framework.Inventory
|
namespace OpenSim.Framework.Inventory
|
||||||
|
@ -105,7 +106,7 @@ namespace OpenSim.Framework.Inventory
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool UpdateItem(LLUUID itemID, AssetBase asset)
|
public bool UpdateItemAsset(LLUUID itemID, AssetBase asset)
|
||||||
{
|
{
|
||||||
if(this.InventoryItems.ContainsKey(itemID))
|
if(this.InventoryItems.ContainsKey(itemID))
|
||||||
{
|
{
|
||||||
|
@ -117,6 +118,20 @@ namespace OpenSim.Framework.Inventory
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool UpdateItemDetails(LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet)
|
||||||
|
{
|
||||||
|
Console.WriteLine("updating inventory item details");
|
||||||
|
if (this.InventoryItems.ContainsKey(itemID))
|
||||||
|
{
|
||||||
|
Console.WriteLine("changing name to "+ Helpers.FieldToString(packet.Name));
|
||||||
|
InventoryItem Item = this.InventoryItems[itemID];
|
||||||
|
Item.Name = Helpers.FieldToString(packet.Name);
|
||||||
|
Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated());
|
||||||
|
//TODO need to update the rest of the info
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public LLUUID AddToInventory(LLUUID folderID, AssetBase asset)
|
public LLUUID AddToInventory(LLUUID folderID, AssetBase asset)
|
||||||
{
|
{
|
||||||
if (this.InventoryFolders.ContainsKey(folderID))
|
if (this.InventoryFolders.ContainsKey(folderID))
|
||||||
|
|
|
@ -197,6 +197,7 @@ namespace OpenSim
|
||||||
trans.Asset.Description = Helpers.FieldToString(packet.InventoryBlock.Description);
|
trans.Asset.Description = Helpers.FieldToString(packet.InventoryBlock.Description);
|
||||||
trans.Asset.Name = Helpers.FieldToString(packet.InventoryBlock.Name);
|
trans.Asset.Name = Helpers.FieldToString(packet.InventoryBlock.Name);
|
||||||
trans.Asset.Type = packet.InventoryBlock.Type;
|
trans.Asset.Type = packet.InventoryBlock.Type;
|
||||||
|
trans.Asset.InvType = packet.InventoryBlock.InvType;
|
||||||
if (trans.UploadComplete)
|
if (trans.UploadComplete)
|
||||||
{
|
{
|
||||||
//already complete so we can add it to the inventory
|
//already complete so we can add it to the inventory
|
||||||
|
|
|
@ -141,11 +141,27 @@ namespace OpenSim.Assets
|
||||||
return newItem;
|
return newItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool UpdateInventoryItem(SimClient remoteClient, LLUUID itemID, OpenSim.Framework.Assets.AssetBase asset)
|
public bool UpdateInventoryItemAsset(SimClient remoteClient, LLUUID itemID, OpenSim.Framework.Assets.AssetBase asset)
|
||||||
{
|
{
|
||||||
if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
|
if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
|
||||||
{
|
{
|
||||||
bool res = _agentsInventory[remoteClient.AgentID].UpdateItem(itemID, asset);
|
bool res = _agentsInventory[remoteClient.AgentID].UpdateItemAsset(itemID, asset);
|
||||||
|
if (res)
|
||||||
|
{
|
||||||
|
InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[itemID];
|
||||||
|
this.SendItemUpdateCreate(remoteClient, Item);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool UpdateInventoryItemDetails(SimClient remoteClient, LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet)
|
||||||
|
{
|
||||||
|
if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
|
||||||
|
{
|
||||||
|
bool res = _agentsInventory[remoteClient.AgentID].UpdateItemDetails(itemID, packet);
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[itemID];
|
InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[itemID];
|
||||||
|
|
|
@ -78,7 +78,7 @@ namespace OpenSim.CAPS
|
||||||
//Console.WriteLine(requestBody);
|
//Console.WriteLine(requestBody);
|
||||||
comp = requestBody.Split(delimiter);
|
comp = requestBody.Split(delimiter);
|
||||||
passw = comp[3].Split(delimiter2);
|
passw = comp[3].Split(delimiter2);
|
||||||
if (passw[1] == passWord)
|
if (passw[1] == passWord) // check admin password is correct
|
||||||
{
|
{
|
||||||
|
|
||||||
line = comp[0].Split(delimiter2); //split firstname
|
line = comp[0].Split(delimiter2); //split firstname
|
||||||
|
|
|
@ -49,7 +49,6 @@ namespace OpenSim
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SimClient
|
public class SimClient
|
||||||
{
|
{
|
||||||
|
|
||||||
public LLUUID AgentID;
|
public LLUUID AgentID;
|
||||||
public LLUUID SessionID;
|
public LLUUID SessionID;
|
||||||
public LLUUID SecureSessionID = LLUUID.Zero;
|
public LLUUID SecureSessionID = LLUUID.Zero;
|
||||||
|
@ -354,6 +353,7 @@ namespace OpenSim
|
||||||
break;
|
break;
|
||||||
case PacketType.UpdateInventoryItem:
|
case PacketType.UpdateInventoryItem:
|
||||||
UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack;
|
UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack;
|
||||||
|
Console.WriteLine(Pack.ToString());
|
||||||
for (int i = 0; i < update.InventoryData.Length; i++)
|
for (int i = 0; i < update.InventoryData.Length; i++)
|
||||||
{
|
{
|
||||||
if (update.InventoryData[i].TransactionID != LLUUID.Zero)
|
if (update.InventoryData[i].TransactionID != LLUUID.Zero)
|
||||||
|
@ -362,7 +362,7 @@ namespace OpenSim
|
||||||
if (asset != null)
|
if (asset != null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache");
|
Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache");
|
||||||
m_inventoryCache.UpdateInventoryItem(this, update.InventoryData[i].ItemID, asset);
|
m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -370,7 +370,7 @@ namespace OpenSim
|
||||||
if (asset != null)
|
if (asset != null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("updating inventory item, adding asset" + asset.FullID.ToStringHyphenated() + " to cache");
|
Console.WriteLine("updating inventory item, adding asset" + asset.FullID.ToStringHyphenated() + " to cache");
|
||||||
m_inventoryCache.UpdateInventoryItem(this, update.InventoryData[i].ItemID, asset);
|
m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -378,6 +378,10 @@ namespace OpenSim
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]); ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketType.ViewerEffect:
|
case PacketType.ViewerEffect:
|
||||||
|
|
Loading…
Reference in New Issue