When you change the name of a inventory item, it should no longer revert after a logout / login

0.1-prestable
MW 2007-03-29 20:55:44 +00:00
parent feaf036aa2
commit b2ae86dd6a
6 changed files with 139 additions and 91 deletions

View File

@ -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() { public UserHTTPServer()
MainConsole.Instance.WriteLine("Starting up HTTP Server"); {
HTTPD = new Thread(new ThreadStart(StartHTTP)); MainConsole.Instance.WriteLine("Starting up HTTP Server");
HTTPD.Start(); HTTPD = new Thread(new ThreadStart(StartHTTP));
} HTTPD.Start();
}
public void StartHTTP() { public void StartHTTP()
MainConsole.Instance.WriteLine("UserHttp.cs:StartHTTP() - Spawned main thread OK"); {
Listener = new HttpListener(); MainConsole.Instance.WriteLine("UserHttp.cs:StartHTTP() - Spawned main thread OK");
Listener = new HttpListener();
Listener.Prefixes.Add("http://+:8002/userserver/"); Listener.Prefixes.Add("http://+:8002/userserver/");
Listener.Prefixes.Add("http://+:8002/usersessions/"); Listener.Prefixes.Add("http://+:8002/usersessions/");
Listener.Start(); Listener.Start();
HttpListenerContext context; HttpListenerContext context;
while(true) { while (true)
context = Listener.GetContext(); {
ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context); context = Listener.GetContext();
} ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
} }
}
static string ParseXMLRPC(string requestBody) { 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) { static string ParseREST(HttpListenerRequest www_req)
Console.WriteLine("INCOMING REST - " + www_req.RawUrl); {
Console.WriteLine("INCOMING REST - " + www_req.RawUrl);
char[] splitter = {'/'}; char[] splitter = { '/' };
string[] rest_params = www_req.RawUrl.Split(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 string req_type = rest_params[1]; // First part of the URL is the type of request - usersessions/userprofiles/inventory/blabla
switch(req_type) { switch (req_type)
case "usersessions": {
LLUUID sessionid = new LLUUID(rest_params[2]); // get usersessions/sessionid case "usersessions":
if(www_req.HttpMethod=="DELETE") { LLUUID sessionid = new LLUUID(rest_params[2]); // get usersessions/sessionid
foreach (libsecondlife.LLUUID UUID in OpenUser_Main.userserver._profilemanager.UserProfiles.Keys) { if (www_req.HttpMethod == "DELETE")
if(OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID==sessionid) { {
OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID=null; foreach (libsecondlife.LLUUID UUID in OpenUser_Main.userserver._profilemanager.UserProfiles.Keys)
OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSecureSessionID=null; {
OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].Circuits.Clear(); 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 "OK";
} }
return ""; return "";
} }
static void HandleRequest(Object stateinfo) { static void HandleRequest(Object stateinfo)
HttpListenerContext context=(HttpListenerContext)stateinfo; {
HttpListenerContext context = (HttpListenerContext)stateinfo;
HttpListenerRequest request = context.Request; HttpListenerRequest request = context.Request;
HttpListenerResponse response = context.Response; HttpListenerResponse response = context.Response;
response.KeepAlive=false; response.KeepAlive = false;
response.SendChunked=false; response.SendChunked = false;
System.IO.Stream body = request.InputStream; System.IO.Stream body = request.InputStream;
System.Text.Encoding encoding = System.Text.Encoding.UTF8; System.Text.Encoding encoding = System.Text.Encoding.UTF8;
System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding); System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
string requestBody = reader.ReadToEnd(); string requestBody = reader.ReadToEnd();
body.Close(); body.Close();
reader.Close(); reader.Close();
string responseString=""; string responseString = "";
switch(request.ContentType) { switch (request.ContentType)
case "text/xml": {
// must be XML-RPC, so pass to the XML-RPC parser case "text/xml":
// must be XML-RPC, so pass to the XML-RPC parser
responseString=ParseXMLRPC(requestBody); responseString = ParseXMLRPC(requestBody);
response.AddHeader("Content-type","text/xml"); response.AddHeader("Content-type", "text/xml");
break; break;
case "text/plaintext": case "text/plaintext":
responseString=ParseREST(request); responseString = ParseREST(request);
response.AddHeader("Content-type","text/plaintext"); response.AddHeader("Content-type", "text/plaintext");
break; break;
} }
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString); byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
System.IO.Stream output = response.OutputStream; System.IO.Stream output = response.OutputStream;
response.SendChunked=false; response.SendChunked = false;
response.ContentLength64=buffer.Length; response.ContentLength64 = buffer.Length;
output.Write(buffer,0,buffer.Length); output.Write(buffer, 0, buffer.Length);
output.Close(); output.Close();
} }
} }
} }

View File

@ -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))

View File

@ -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

View File

@ -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];

View File

@ -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

View File

@ -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: