/// <summary> /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client /// </summary> /// <param name="xferManager"></param> public void RequestInventoryFile(IClientAPI client, IXfer xferManager) { CreateInventoryFile(); if (m_inventorySerial == 0) // No inventory { client.SendTaskInventory(m_part.UUID, 0, new byte[0]); return; } // In principle, we should only do the rest if the inventory changed; // by sending m_inventorySerial to the client, it ought to know // that nothing changed and that it doesn't need to request the file. // Unfortunately, it doesn't look like the client optimizes this; // the client seems to always come back and request the Xfer, // no matter what value m_inventorySerial has. if (m_inventoryFileData.Length > 2) { // Add the file for Xfer xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); } // Tell the client we're ready to Xfer the file client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, Util.StringToBytes256(m_inventoryFileName)); }
public void RegionLoaded(Scene scene) { if (!m_Enabled) { return; } IXfer xfer = scene.RequestModuleInterface <IXfer>(); if (xfer == null) { m_log.ErrorFormat("[MuteListModuleTst]: Xfer not availble in region {0}. Module Disabled", scene.Name); m_Enabled = false; return; } IMuteListService srv = scene.RequestModuleInterface <IMuteListService>(); if (srv == null) { m_log.ErrorFormat("[MuteListModuleTst]: MuteListService not availble in region {0}. Module Disabled", scene.Name); m_Enabled = false; return; } lock (m_SceneList) { if (m_service == null) { m_service = srv; } m_SceneList.Add(scene); scene.EventManager.OnNewClient += OnNewClient; } }
/// <summary> /// Return serialized inventory metadata for the given constituent prim /// </summary> /// <param name="localID"></param> /// <param name="xferManager"></param> public void RequestInventoryFile(IClientAPI client, uint localID, IXfer xferManager) { SceneObjectPart part = GetChildPart(localID); if (part == null) { m_log.ErrorFormat( "[PRIM INVENTORY]: " + "Couldn't find part {0} in object group {1}, {2} to request inventory data", localID, Name, UUID); return; } /* * if (GetPartInventoryFileName(client, localID, xferManager)) * SceneObjectPart part = GetChildPart(localID); * if (part != null) * { * return part.Inventory.AllocateInventoryFile(remoteClient, localID, xferManager); * } * else * { * m_log.ErrorFormat( * "[PRIM INVENTORY]: " + * "Couldn't find part {0} in object group {1}, {2} to retreive prim inventory", * localID, Name, UUID); * } * return false; */ part.Inventory.RequestInventoryFile(client, xferManager); }
private void OnMuteListRequest(IClientAPI client, uint crc) { string mutelist; IXfer xfer = client.Scene.RequestModuleInterface <IXfer>(); if (xfer == null) { return; } m_log.DebugFormat("[OS MUTELIST] Got mute list request"); string filename = "mutes" + client.AgentId.ToString(); Hashtable ReqHash = new Hashtable(); ReqHash["avataruuid"] = client.AgentId.ToString(); string serverURI = String.Empty; GetUserMutelistServerURI(client.AgentId, out serverURI); Hashtable result = GenericXMLRPCRequest(ReqHash, "mutelist_request", serverURI); //If no mutelist exists PHP sends "<string/>" which results in the //mutelist hashtable entry being null rather than an empty string. if (!Convert.ToBoolean(result["success"]) || result["mutelist"] == null) { mutelist = null; } else { mutelist = result["mutelist"].ToString(); } if (mutelist == null || mutelist.Length == 0) { xfer.AddNewFile(filename, new Byte[0]); } else { Byte[] filedata = Util.UTF8.GetBytes(mutelist); uint dataCrc = Crc32.Compute(filedata); if (dataCrc == crc) { client.SendUseCachedMuteList(); return; } xfer.AddNewFile(filename, filedata); } client.SendMuteListUpdate(filename); }
// Apparently this is needed in order for the viewer to request the IMs. private void OnMuteListRequest(IClientAPI client, uint crc) { m_log.DebugFormat("[OfflineIM.V2] Got mute list request for crc {0}", crc); string filename = "mutes" + client.AgentId.ToString(); IXfer xfer = client.Scene.RequestModuleInterface<IXfer>(); if (xfer != null) { xfer.AddNewFile(filename, new Byte[0]); client.SendMuteListUpdate(filename); } }
private void OnMuteListRequest(IClientAPI client, uint crc) { m_log.DebugFormat("[MUTE LIST] List request for crc {0}", crc); string filename = "mutes" + client.AgentId.ToString(); IXfer xfer = client.Scene.RequestModuleInterface <IXfer>(); if (xfer != null) { xfer.AddNewFile(filename, GetMuteListFileData(client.AgentId)); client.SendMuteListUpdate(filename); } }
/// <summary> /// Get all the mutes the client has set /// </summary> /// <param name="client"></param> /// <param name="crc"></param> private void OnMuteListRequest(IClientAPI client, uint crc) { if (!m_useMuteListModule) { return; } //Sends the name of the file being sent by the xfer module DO NOT EDIT!!! string filename = "mutes" + client.AgentId.ToString(); byte[] fileData = new byte[0]; string invString = ""; int i = 0; bool cached = false; MuteList[] List = GetMutes(client.AgentId, out cached); if (List == null) { return; } /*if (cached) * { * client.SendUseCachedMuteList(); * return; * }*/ Dictionary <UUID, bool> cache = new Dictionary <UUID, bool>(); foreach (MuteList mute in List) { cache[mute.MuteID] = true; invString += (mute.MuteType + " " + mute.MuteID + " " + mute.MuteName + " |\n"); i++; } if (invString != "") { invString = invString.Remove(invString.Length - 3, 3); } fileData = Utils.StringToBytes(invString); IXfer xfer = client.Scene.RequestModuleInterface <IXfer>(); if (xfer != null) { xfer.AddNewFile(filename, fileData); client.SendMuteListUpdate(filename); } }
/// <summary> /// Return serialized inventory metadata for the given constituent prim /// </summary> /// <param name="localID"></param> /// <param name="xferManager"></param> public void RequestInventoryFile(IClientAPI client, uint localID, IXfer xferManager) { SceneObjectPart part = GetChildPart(localID); if (part != null) { part.Inventory.RequestInventoryFile(client, xferManager); } else { m_log.ErrorFormat( "[PRIM INVENTORY]: " + "Couldn't find part {0} in object group {1}, {2} to request inventory data", localID, Name, UUID); } }
private void OnMuteListRequest(IClientAPI client, uint crc) { string filename = "mutes" + client.AgentId.ToString(); IXfer xfer = client.Scene.RequestModuleInterface <IXfer>(); if (xfer != null) { MuteData[] data = m_MuteTable.Get("AgentID", client.AgentId.ToString()); if (data == null || data.Length == 0) { xfer.AddNewFile(filename, new Byte[0]); } else { StringBuilder sb = new StringBuilder(1024); foreach (MuteData d in data) { sb.AppendFormat("{0} {1} {2}|{3}\n", d.MuteType, d.MuteID.ToString(), d.MuteName, d.MuteFlags); } Byte[] filedata = Util.UTF8.GetBytes(sb.ToString()); uint dataCrc = Crc32.Compute(filedata); if (dataCrc == crc) { client.SendUseCachedMuteList(); return; } xfer.AddNewFile(filename, filedata); } client.SendMuteListUpdate(filename); } }
private void OnMuteListRequest(IClientAPI client, uint crc) { //m_log.DebugFormat("[NSL MUTE LIST] Got MUTE LIST request for crc {0}", crc); int cnt = 0; string str = ""; string url = m_RestURL + "/RequestList/"; //List<GridMuteList> mllist = SynchronousRestObjectPoster.BeginPostObject<UUID, List<GridMuteList>>("POST", url, client.AgentId); List <GridMuteList> mllist = SynchronousRestObjectRequester.MakeRequest <UUID, List <GridMuteList> >("POST", url, client.AgentId); while (mllist == null && cnt < 10) // retry //mllist = SynchronousRestObjectPoster.BeginPostObject<UUID, List<GridMuteList>>("POST", url, client.AgentId); { mllist = SynchronousRestObjectRequester.MakeRequest <UUID, List <GridMuteList> >("POST", url, client.AgentId); cnt++; } if (mllist != null) { foreach (GridMuteList ml in mllist) { str += ml.muteType.ToString() + " " + ml.muteID.ToString() + " " + ml.muteName + "|" + ml.muteFlags.ToString() + "\n"; } } else { m_log.ErrorFormat("[NSL MUTE LIST] Not response from mute.php"); return; } string filename = "mutes" + client.AgentId.ToString(); IXfer xfer = client.Scene.RequestModuleInterface <IXfer>(); if (xfer != null) { byte[] byteArray = System.Text.Encoding.GetEncoding("UTF-8").GetBytes(str); xfer.AddNewFile(filename, byteArray); client.SendMuteListUpdate(filename); } }
/// <summary> /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client /// </summary> /// <param name="xferManager"></param> public void RequestInventoryFile(IClientAPI client, IXfer xferManager) { lock (m_items) { // Don't send a inventory xfer name if there are no items. Doing so causes viewer 3 to crash when rezzing // a new script if any previous deletion has left the prim inventory empty. if (m_items.Count == 0) // No inventory { // m_log.DebugFormat( // "[PRIM INVENTORY]: Not sending inventory data for part {0} {1} {2} for {3} since no items", // m_part.Name, m_part.LocalId, m_part.UUID, client.Name); client.SendTaskInventory(m_part.UUID, 0, new byte[0]); return; } CreateInventoryFile(); // In principle, we should only do the rest if the inventory changed; // by sending m_inventorySerial to the client, it ought to know // that nothing changed and that it doesn't need to request the file. // Unfortunately, it doesn't look like the client optimizes this; // the client seems to always come back and request the Xfer, // no matter what value m_inventorySerial has. // FIXME: Could probably be > 0 here rather than > 2 if (m_inventoryFileData.Length > 2) { // Add the file for Xfer // m_log.DebugFormat( // "[PRIM INVENTORY]: Adding inventory file {0} (length {1}) for transfer on {2} {3} {4}", // m_inventoryFileName, m_inventoryFileData.Length, m_part.Name, m_part.UUID, m_part.LocalId); xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); } // Tell the client we're ready to Xfer the file client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, Util.StringToBytes256(m_inventoryFileName)); } }
/// <summary> /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client /// </summary> /// <param name="client"></param> public void RequestInventoryFile(IClientAPI client) { IXfer xferManager = client.Scene.RequestModuleInterface <IXfer>(); if (m_inventorySerial == 0) { //No inventory, no sending client.SendTaskInventory(m_part.UUID, 0, new byte[0]); return; } //If update == true, we need to recreate the file for the client bool Update = GetInventoryFileName(); if (!Update) { //We don't need to update the fileData, so just send the cached info and exit out of this method if (m_fileData.Length > 2) { client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, Utils.StringToBytes(m_inventoryFileName)); xferManager.AddNewFile(m_inventoryFileName, m_fileData); } else { client.SendTaskInventory(m_part.UUID, 0, new byte[0]); } return; } // Confusingly, the folder item has to be the object id, while the 'parent id' has to be zero. This matches // what appears to happen in the Second Life protocol. If this isn't the case. then various functionality // isn't available (such as drag from prim inventory to agent inventory) InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); bool includeAssets = false; if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) { includeAssets = true; } List <TaskInventoryItem> items = m_items.Clone2List(); foreach (TaskInventoryItem item in items) { UUID ownerID = item.OwnerID; const uint everyoneMask = 0; uint baseMask = item.BasePermissions; uint ownerMask = item.CurrentPermissions; uint groupMask = item.GroupPermissions; invString.AddItemStart(); invString.AddNameValueLine("item_id", item.ItemID.ToString()); invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); invString.AddPermissionsStart(); invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); invString.AddNameValueLine("owner_id", ownerID.ToString()); invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); invString.AddNameValueLine("group_id", item.GroupID.ToString()); invString.AddSectionEnd(); invString.AddNameValueLine("asset_id", includeAssets ? item.AssetID.ToString() : UUID.Zero.ToString()); invString.AddNameValueLine("type", TaskInventoryItemHelpers.Types[item.Type]); invString.AddNameValueLine("inv_type", TaskInventoryItemHelpers.InvTypes[item.InvType]); invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); invString.AddSaleStart(); invString.AddNameValueLine("sale_type", TaskInventoryItemHelpers.SaleTypes[item.SaleType]); invString.AddNameValueLine("sale_price", item.SalePrice.ToString()); invString.AddSectionEnd(); invString.AddNameValueLine("name", item.Name + "|"); invString.AddNameValueLine("desc", item.Description + "|"); invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); invString.AddSectionEnd(); } string str = invString.GetString(); if (str.Length > 0) { str = str.Substring(0, str.Length - 1); } m_fileData = Utils.StringToBytes(str); //MainConsole.Instance.Debug(Utils.BytesToString(fileData)); //MainConsole.Instance.Debug("[PRIM INVENTORY]: RequestInventoryFile fileData: " + Utils.BytesToString(fileData)); if (m_fileData.Length > 2) { client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, Utils.StringToBytes(m_inventoryFileName)); xferManager.AddNewFile(m_inventoryFileName, m_fileData); } else { client.SendTaskInventory(m_part.UUID, 0, new byte[0]); } }
/// <summary> /// Sets up references to modules required by the scene /// </summary> public void SetModuleInterfaces() { m_xmlrpcModule = RequestModuleInterface<IXMLRPC>(); m_worldCommModule = RequestModuleInterface<IWorldComm>(); XferManager = RequestModuleInterface<IXfer>(); m_AvatarFactory = RequestModuleInterface<IAvatarFactory>(); m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); m_interregionCommsOut = RequestModuleInterface<IInterregionCommsOut>(); m_interregionCommsIn = RequestModuleInterface<IInterregionCommsIn>(); m_dialogModule = RequestModuleInterface<IDialogModule>(); m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); m_teleportModule = RequestModuleInterface<ITeleportModule>(); }
/// <summary> /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client /// </summary> /// <param name="xferManager"></param> public void RequestInventoryFile(IClientAPI client, IXfer xferManager) { byte[] fileData = new byte[0]; if (m_inventorySerial <= 0) // no inventory to send { client.SendTaskInventory(m_part.UUID, 0, new byte[0]); return; // client notified above } // Confusingly, the folder item has to be the object id, while the 'parent id' has to be zero. This matches // what appears to happen in the Second Life protocol. If this isn't the case. then various functionality // isn't available (such as drag from prim inventory to agent inventory) InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); lock (m_items) { // int items = 0; foreach (TaskInventoryItem item in m_items.Values) { UUID ownerID = item.OwnerID; uint everyoneMask = 0; uint baseMask = item.BasePermissions; uint ownerMask = item.CurrentPermissions; uint groupMask = item.GroupPermissions; string itemID; string desc; // only the owner of the item can see the UUIDs of Contents and possibly private data if (ownerID == client.AgentId) { itemID = item.AssetID.ToString(); desc = item.Description; // m_log.DebugFormat("[ASSETS]: RequestInventoryFile returning item #{0} itemID {1} asset {2}", ++items, item.ItemID, item.AssetID); } else { itemID = UUID.Zero.ToString(); desc = "(not owner)"; } invString.AddSectionEnd(); invString.AddItemStart(); invString.AddNameValueLine("item_id", item.ItemID.ToString()); invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); invString.AddPermissionsStart(); invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); invString.AddNameValueLine("owner_id", ownerID.ToString()); invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); invString.AddNameValueLine("group_id", item.GroupID.ToString()); invString.AddSectionEnd(); invString.AddNameValueLine("asset_id", itemID); invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); invString.AddSaleStart(); invString.AddNameValueLine("sale_type", "not"); invString.AddNameValueLine("sale_price", "0"); invString.AddSectionEnd(); invString.AddNameValueLine("name", item.Name + "|"); invString.AddNameValueLine("desc", desc + "|"); invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); invString.AddSectionEnd(); } } invString.AddEnd(); fileData = Utils.StringToBytes(invString.BuildString.ToString()); if (fileData.Length > 2) { // There is inventory to send. Allocate temp file. UpdateInventoryTempFileName(xferManager); // Add the data to the NewFiles list and await the viewer request for it. xferManager.AddNewFile(m_inventoryFileName, fileData); // Notify the viewer of the available file download. client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, Utils.StringToBytes(m_inventoryFileName)); } }
/// <summary> /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client /// </summary> /// <param name="xferManager"></param> public void RequestInventoryFile(IClientAPI client, IXfer xferManager) { byte[] fileData = new byte[0]; // Confusingly, the folder item has to be the object id, while the 'parent id' has to be zero. This matches // what appears to happen in the Second Life protocol. If this isn't the case. then various functionality // isn't available (such as drag from prim inventory to agent inventory) InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); lock (m_items) { foreach (TaskInventoryItem item in m_items.Values) { UUID ownerID = item.OwnerID; uint everyoneMask = 0; uint baseMask = item.BasePermissions; uint ownerMask = item.CurrentPermissions; invString.AddItemStart(); invString.AddNameValueLine("item_id", item.ItemID.ToString()); invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); invString.AddPermissionsStart(); invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0)); invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); invString.AddNameValueLine("owner_id", ownerID.ToString()); invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); invString.AddNameValueLine("group_id", item.GroupID.ToString()); invString.AddSectionEnd(); invString.AddNameValueLine("asset_id", item.AssetID.ToString()); invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); invString.AddSaleStart(); invString.AddNameValueLine("sale_type", "not"); invString.AddNameValueLine("sale_price", "0"); invString.AddSectionEnd(); invString.AddNameValueLine("name", item.Name + "|"); invString.AddNameValueLine("desc", item.Description + "|"); invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); invString.AddSectionEnd(); } } fileData = Utils.StringToBytes(invString.BuildString); //m_log.Debug(Utils.BytesToString(fileData)); //m_log.Debug("[PRIM INVENTORY]: RequestInventoryFile fileData: " + Utils.BytesToString(fileData)); if (fileData.Length > 2) { xferManager.AddNewFile(m_inventoryFileName, fileData); } }
/// <summary> /// Sets up references to modules required by the scene /// </summary> public void SetModuleInterfaces() { m_xmlrpcModule = RequestModuleInterface<IXMLRPC>(); m_worldCommModule = RequestModuleInterface<IWorldComm>(); XferManager = RequestModuleInterface<IXfer>(); m_AvatarFactory = RequestModuleInterface<IAvatarFactory>(); AttachmentsModule = RequestModuleInterface<IAttachmentsModule>(); m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); m_dialogModule = RequestModuleInterface<IDialogModule>(); m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); m_teleportModule = RequestModuleInterface<IEntityTransferModule>(); }
// This function initializes or updates the member variable m_inventoryFileName as needed. private void UpdateInventoryTempFileName(IXfer xferManager) { bool needNew = String.IsNullOrEmpty(m_inventoryFileName); // if first instance // If the version has changed, we need a new file name even if we have one needNew |= (m_inventoryFileNameSerial < m_inventorySerial); // or new version if (needNew) { // if (!String.IsNullOrEmpty(m_inventoryFileName)) xferManager.RemoveNewFile(m_inventoryFileName); // replace existing with new update m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; } }
private void OnMuteListRequest(IClientAPI client, uint crc) { if (!m_Enabled || IsForeign(client)) { if (crc == 0) { client.SendEmpytMuteList(); } else { client.SendUseCachedMuteList(); } return; } IXfer xfer = client.Scene.RequestModuleInterface <IXfer>(); if (xfer == null) { if (crc == 0) { client.SendEmpytMuteList(); } else { client.SendUseCachedMuteList(); } return; } Byte[] data = m_service.MuteListRequest(client.AgentId, crc); if (data == null) { if (crc == 0) { client.SendEmpytMuteList(); } else { client.SendUseCachedMuteList(); } return; } if (data.Length == 0) { client.SendEmpytMuteList(); return; } if (data.Length == 1) { if (crc == 0) { client.SendEmpytMuteList(); } else { client.SendUseCachedMuteList(); } return; } string filename = "mutes" + client.AgentId.ToString(); xfer.AddNewFile(filename, data); client.SendMuteListUpdate(filename); }
/// <summary> /// Return serialized inventory metadata for the given constituent prim /// </summary> /// <param name="localID"></param> /// <param name="xferManager"></param> public void RequestInventoryFile(IClientAPI client, uint localID, IXfer xferManager) { SceneObjectPart part = GetChildPart(localID); if (part == null) { m_log.ErrorFormat( "[PRIM INVENTORY]: " + "Couldn't find part {0} in object group {1}, {2} to request inventory data", localID, Name, UUID); return; } /* if (GetPartInventoryFileName(client, localID, xferManager)) SceneObjectPart part = GetChildPart(localID); if (part != null) { return part.Inventory.AllocateInventoryFile(remoteClient, localID, xferManager); } else { m_log.ErrorFormat( "[PRIM INVENTORY]: " + "Couldn't find part {0} in object group {1}, {2} to retreive prim inventory", localID, Name, UUID); } return false; */ part.Inventory.RequestInventoryFile(client, xferManager); }
/// <summary> /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client /// </summary> /// <param name="xferManager"></param> public void RequestInventoryFile(IClientAPI client, IXfer xferManager) { lock (m_inventoryFileLock) { string filename = "inventory_" + UUID.Random().ToString() + ".tmp"; bool changed = false; if (m_inventoryFileNameSerial < m_inventorySerial) { m_inventoryFileNameSerial = m_inventorySerial; changed = true; } if (m_inventoryFileData.Length < 2) changed = true; bool includeAssets = false; if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) includeAssets = true; if (m_inventoryPrivileged != includeAssets) changed = true; Items.LockItemsForRead(true); if (m_inventorySerial == 0) // No inventory { Items.LockItemsForRead(false); client.SendTaskInventory(m_part.UUID, 0, new byte[0]); return; } if (m_items.Count == 0) // No inventory { Items.LockItemsForRead(false); client.SendTaskInventory(m_part.UUID, 0, new byte[0]); return; } if (!changed) { Items.LockItemsForRead(false); xferManager.AddNewFile(filename, m_inventoryFileData); client.SendTaskInventory(m_part.UUID, (short)m_inventoryFileNameSerial, Util.StringToBytes256(filename)); return; } m_inventoryPrivileged = includeAssets; InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); foreach (TaskInventoryItem item in m_items.Values) { UUID ownerID = item.OwnerID; uint everyoneMask = 0; uint baseMask = item.BasePermissions; uint ownerMask = item.CurrentPermissions; uint groupMask = item.GroupPermissions; invString.AddItemStart(); invString.AddNameValueLine("item_id", item.ItemID.ToString()); invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); invString.AddPermissionsStart(); invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); invString.AddNameValueLine("owner_id", ownerID.ToString()); invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); invString.AddNameValueLine("group_id", item.GroupID.ToString()); invString.AddSectionEnd(); if (includeAssets) invString.AddNameValueLine("asset_id", item.AssetID.ToString()); else invString.AddNameValueLine("asset_id", UUID.Zero.ToString()); invString.AddNameValueLine("type", Utils.AssetTypeToString((AssetType)item.Type)); invString.AddNameValueLine("inv_type", Utils.InventoryTypeToString((InventoryType)item.InvType)); invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); invString.AddSaleStart(); invString.AddNameValueLine("sale_type", "not"); invString.AddNameValueLine("sale_price", "0"); invString.AddSectionEnd(); invString.AddNameValueLine("name", item.Name + "|"); invString.AddNameValueLine("desc", item.Description + "|"); invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); invString.AddSectionEnd(); } Items.LockItemsForRead(false); m_inventoryFileData = Utils.StringToBytes(invString.BuildString); if (m_inventoryFileData.Length > 2) { xferManager.AddNewFile(filename, m_inventoryFileData); client.SendTaskInventory(m_part.UUID, (short)m_inventoryFileNameSerial, Util.StringToBytes256(filename)); return; } client.SendTaskInventory(m_part.UUID, 0, new byte[0]); } }
/// <summary> /// Sets up references to modules required by the scene /// </summary> public void SetModuleInterfaces() { m_xmlrpcModule = RequestModuleInterface<IXMLRPC>(); m_worldCommModule = RequestModuleInterface<IWorldComm>(); XferManager = RequestModuleInterface<IXfer>(); m_AvatarFactory = RequestModuleInterface<IAvatarFactoryModule>(); AttachmentsModule = RequestModuleInterface<IAttachmentsModule>(); m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); m_dialogModule = RequestModuleInterface<IDialogModule>(); m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); EntityTransferModule = RequestModuleInterface<IEntityTransferModule>(); m_groupsModule = RequestModuleInterface<IGroupsModule>(); AgentTransactionsModule = RequestModuleInterface<IAgentAssetTransactions>(); UserManagementModule = RequestModuleInterface<IUserManagement>(); }
/// <summary> /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client /// </summary> /// <param name="xferManager"></param> public void RequestInventoryFile(IClientAPI client, IXfer xferManager) { CreateInventoryFile(); if (m_inventorySerial == 0) // No inventory { client.SendTaskInventory(m_part.UUID, 0, new byte[0]); return; } // In principle, we should only do the rest if the inventory changed; // by sending m_inventorySerial to the client, it ought to know // that nothing changed and that it doesn't need to request the file. // Unfortunately, it doesn't look like the client optimizes this; // the client seems to always come back and request the Xfer, // no matter what value m_inventorySerial has. if (m_inventoryFileData.Length > 2) // Add the file for Xfer xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); // Tell the client we're ready to Xfer the file client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, Util.StringToBytes256(m_inventoryFileName)); }
/// <summary> /// Sets up references to modules required by the scene /// </summary> public void SetModuleInterfaces() { m_xmlrpcModule = RequestModuleInterface<IXMLRPC>(); m_worldCommModule = RequestModuleInterface<IWorldComm>(); XferManager = RequestModuleInterface<IXfer>(); m_AvatarFactory = RequestModuleInterface<IAvatarFactory>(); AttachmentsModule = RequestModuleInterface<IAttachmentsModule>(); m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); m_dialogModule = RequestModuleInterface<IDialogModule>(); m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); m_teleportModule = RequestModuleInterface<IEntityTransferModule>(); // Shoving this in here for now, because we have the needed // interfaces at this point // // TODO: Find a better place for this // while (m_regInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null) { MainConsole.Instance.Output("The current estate " + m_regInfo.EstateSettings.EstateName + " has no owner set."); List<char> excluded = new List<char>(new char[1] { ' ' }); string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test", excluded); string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User", excluded); UserAccount account = UserAccountService.GetUserAccount(m_regInfo.ScopeID, first, last); if (account == null) { // Create a new account account = new UserAccount(m_regInfo.ScopeID, first, last, String.Empty); if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0)) { account.ServiceURLs = new Dictionary<string, object>(); account.ServiceURLs["HomeURI"] = string.Empty; account.ServiceURLs["GatekeeperURI"] = string.Empty; account.ServiceURLs["InventoryServerURI"] = string.Empty; account.ServiceURLs["AssetServerURI"] = string.Empty; } if (UserAccountService.StoreUserAccount(account)) { string password = MainConsole.Instance.PasswdPrompt("Password"); string email = MainConsole.Instance.CmdPrompt("Email", ""); account.Email = email; UserAccountService.StoreUserAccount(account); bool success = false; success = AuthenticationService.SetPassword(account.PrincipalID, password); if (!success) m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.", first, last); GridRegion home = null; if (GridService != null) { List<GridRegion> defaultRegions = GridService.GetDefaultRegions(UUID.Zero); if (defaultRegions != null && defaultRegions.Count >= 1) home = defaultRegions[0]; if (GridUserService != null && home != null) GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); else m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.", first, last); } else m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.", first, last); if (InventoryService != null) success = InventoryService.CreateUserInventory(account.PrincipalID); if (!success) m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.", first, last); m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", first, last); m_regInfo.EstateSettings.EstateOwner = account.PrincipalID; m_regInfo.EstateSettings.Save(); } else m_log.ErrorFormat("[SCENE]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first."); } else { m_regInfo.EstateSettings.EstateOwner = account.PrincipalID; m_regInfo.EstateSettings.Save(); } } }
/// <summary> /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client /// </summary> /// <param name="xferManager"></param> public void RequestInventoryFile(IClientAPI client, IXfer xferManager) { if (m_inventorySerial == 0) { //No inventory, no sending client.SendTaskInventory(m_part.UUID, 0, new byte[0]); return; } //If update == true, we need to recreate the file for the client bool Update = GetInventoryFileName(); client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, Utils.StringToBytes(m_inventoryFileName)); if (!Update) { //We don't need to update the fileData, so just send the cached info and exit out of this method if (m_fileData.Length > 2) { xferManager.AddNewFile(m_inventoryFileName, m_fileData); } return; } // Confusingly, the folder item has to be the object id, while the 'parent id' has to be zero. This matches // what appears to happen in the Second Life protocol. If this isn't the case. then various functionality // isn't available (such as drag from prim inventory to agent inventory) InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); bool includeAssets = false; if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) includeAssets = true; List<TaskInventoryItem> items = (List<TaskInventoryItem>)m_items.Clone2List(); lock (items) { foreach (TaskInventoryItem item in items) { UUID ownerID = item.OwnerID; uint everyoneMask = 0; uint baseMask = item.BasePermissions; uint ownerMask = item.CurrentPermissions; uint groupMask = item.GroupPermissions; invString.AddItemStart(); invString.AddNameValueLine("item_id", item.ItemID.ToString()); invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); invString.AddPermissionsStart(); invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); invString.AddNameValueLine("owner_id", ownerID.ToString()); invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); invString.AddNameValueLine("group_id", item.GroupID.ToString()); invString.AddSectionEnd(); if (includeAssets) invString.AddNameValueLine("asset_id", item.AssetID.ToString()); else invString.AddNameValueLine("asset_id", UUID.Zero.ToString()); invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); invString.AddSaleStart(); invString.AddNameValueLine("sale_type", TaskInventoryItem.SaleTypes[item.SaleType]); invString.AddNameValueLine("sale_price", item.SalePrice.ToString()); invString.AddSectionEnd(); invString.AddNameValueLine("name", item.Name + "|"); invString.AddNameValueLine("desc", item.Description + "|"); invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); invString.AddSectionEnd(); } } m_fileData = Utils.StringToBytes(invString.BuildString.ToString()); //m_log.Debug(Utils.BytesToString(fileData)); //m_log.Debug("[PRIM INVENTORY]: RequestInventoryFile fileData: " + Utils.BytesToString(fileData)); if (m_fileData.Length > 2) { xferManager.AddNewFile(m_inventoryFileName, m_fileData); } }