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
|
||||
{
|
||||
public class UserHTTPServer {
|
||||
public Thread HTTPD;
|
||||
public HttpListener Listener;
|
||||
public class UserHTTPServer
|
||||
{
|
||||
public Thread HTTPD;
|
||||
public HttpListener Listener;
|
||||
|
||||
public UserHTTPServer() {
|
||||
MainConsole.Instance.WriteLine("Starting up HTTP Server");
|
||||
HTTPD = new Thread(new ThreadStart(StartHTTP));
|
||||
HTTPD.Start();
|
||||
}
|
||||
public UserHTTPServer()
|
||||
{
|
||||
MainConsole.Instance.WriteLine("Starting up HTTP Server");
|
||||
HTTPD = new Thread(new ThreadStart(StartHTTP));
|
||||
HTTPD.Start();
|
||||
}
|
||||
|
||||
public void StartHTTP() {
|
||||
MainConsole.Instance.WriteLine("UserHttp.cs:StartHTTP() - Spawned main thread OK");
|
||||
Listener = new HttpListener();
|
||||
public void StartHTTP()
|
||||
{
|
||||
MainConsole.Instance.WriteLine("UserHttp.cs:StartHTTP() - Spawned main thread OK");
|
||||
Listener = new HttpListener();
|
||||
|
||||
Listener.Prefixes.Add("http://+:8002/userserver/");
|
||||
Listener.Prefixes.Add("http://+:8002/usersessions/");
|
||||
Listener.Start();
|
||||
Listener.Prefixes.Add("http://+:8002/userserver/");
|
||||
Listener.Prefixes.Add("http://+:8002/usersessions/");
|
||||
Listener.Start();
|
||||
|
||||
HttpListenerContext context;
|
||||
while(true) {
|
||||
context = Listener.GetContext();
|
||||
ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
|
||||
}
|
||||
}
|
||||
HttpListenerContext context;
|
||||
while (true)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
static string ParseREST(HttpListenerRequest www_req) {
|
||||
Console.WriteLine("INCOMING REST - " + www_req.RawUrl);
|
||||
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();
|
||||
}
|
||||
}
|
||||
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 "OK";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
static void HandleRequest(Object stateinfo) {
|
||||
HttpListenerContext context=(HttpListenerContext)stateinfo;
|
||||
static void HandleRequest(Object stateinfo)
|
||||
{
|
||||
HttpListenerContext context = (HttpListenerContext)stateinfo;
|
||||
|
||||
HttpListenerRequest request = context.Request;
|
||||
HttpListenerResponse response = context.Response;
|
||||
HttpListenerRequest request = context.Request;
|
||||
HttpListenerResponse response = context.Response;
|
||||
|
||||
response.KeepAlive=false;
|
||||
response.SendChunked=false;
|
||||
response.KeepAlive = false;
|
||||
response.SendChunked = false;
|
||||
|
||||
System.IO.Stream body = request.InputStream;
|
||||
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
|
||||
System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
|
||||
System.IO.Stream body = request.InputStream;
|
||||
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
|
||||
System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
|
||||
|
||||
string requestBody = reader.ReadToEnd();
|
||||
body.Close();
|
||||
reader.Close();
|
||||
string requestBody = reader.ReadToEnd();
|
||||
body.Close();
|
||||
reader.Close();
|
||||
|
||||
string responseString="";
|
||||
switch(request.ContentType) {
|
||||
case "text/xml":
|
||||
// must be XML-RPC, so pass to the XML-RPC parser
|
||||
string responseString = "";
|
||||
switch (request.ContentType)
|
||||
{
|
||||
case "text/xml":
|
||||
// must be XML-RPC, so pass to the XML-RPC parser
|
||||
|
||||
responseString=ParseXMLRPC(requestBody);
|
||||
response.AddHeader("Content-type","text/xml");
|
||||
break;
|
||||
responseString = ParseXMLRPC(requestBody);
|
||||
response.AddHeader("Content-type", "text/xml");
|
||||
break;
|
||||
|
||||
case "text/plaintext":
|
||||
responseString=ParseREST(request);
|
||||
response.AddHeader("Content-type","text/plaintext");
|
||||
break;
|
||||
}
|
||||
case "text/plaintext":
|
||||
responseString = ParseREST(request);
|
||||
response.AddHeader("Content-type", "text/plaintext");
|
||||
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();
|
||||
}
|
||||
}
|
||||
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.Text;
|
||||
using libsecondlife;
|
||||
using libsecondlife.Packets;
|
||||
using OpenSim.Framework.Assets;
|
||||
|
||||
namespace OpenSim.Framework.Inventory
|
||||
|
@ -105,7 +106,7 @@ namespace OpenSim.Framework.Inventory
|
|||
return false;
|
||||
}
|
||||
|
||||
public bool UpdateItem(LLUUID itemID, AssetBase asset)
|
||||
public bool UpdateItemAsset(LLUUID itemID, AssetBase asset)
|
||||
{
|
||||
if(this.InventoryItems.ContainsKey(itemID))
|
||||
{
|
||||
|
@ -117,6 +118,20 @@ namespace OpenSim.Framework.Inventory
|
|||
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)
|
||||
{
|
||||
if (this.InventoryFolders.ContainsKey(folderID))
|
||||
|
|
|
@ -197,6 +197,7 @@ namespace OpenSim
|
|||
trans.Asset.Description = Helpers.FieldToString(packet.InventoryBlock.Description);
|
||||
trans.Asset.Name = Helpers.FieldToString(packet.InventoryBlock.Name);
|
||||
trans.Asset.Type = packet.InventoryBlock.Type;
|
||||
trans.Asset.InvType = packet.InventoryBlock.InvType;
|
||||
if (trans.UploadComplete)
|
||||
{
|
||||
//already complete so we can add it to the inventory
|
||||
|
|
|
@ -141,11 +141,27 @@ namespace OpenSim.Assets
|
|||
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))
|
||||
{
|
||||
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)
|
||||
{
|
||||
InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[itemID];
|
||||
|
|
|
@ -78,7 +78,7 @@ namespace OpenSim.CAPS
|
|||
//Console.WriteLine(requestBody);
|
||||
comp = requestBody.Split(delimiter);
|
||||
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
|
||||
|
|
|
@ -49,7 +49,6 @@ namespace OpenSim
|
|||
/// </summary>
|
||||
public class SimClient
|
||||
{
|
||||
|
||||
public LLUUID AgentID;
|
||||
public LLUUID SessionID;
|
||||
public LLUUID SecureSessionID = LLUUID.Zero;
|
||||
|
@ -354,6 +353,7 @@ namespace OpenSim
|
|||
break;
|
||||
case PacketType.UpdateInventoryItem:
|
||||
UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack;
|
||||
Console.WriteLine(Pack.ToString());
|
||||
for (int i = 0; i < update.InventoryData.Length; i++)
|
||||
{
|
||||
if (update.InventoryData[i].TransactionID != LLUUID.Zero)
|
||||
|
@ -362,7 +362,7 @@ namespace OpenSim
|
|||
if (asset != null)
|
||||
{
|
||||
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
|
||||
{
|
||||
|
@ -370,7 +370,7 @@ namespace OpenSim
|
|||
if (asset != null)
|
||||
{
|
||||
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
|
||||
{
|
||||
|
@ -378,6 +378,10 @@ namespace OpenSim
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]); ;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PacketType.ViewerEffect:
|
||||
|
|
Loading…
Reference in New Issue