private UUID CreateGroup(string name) { if (!CogbotHelpers.IsNullOrZero(base.NewID)) { return(base.NewID); } if (!IsGroup) { return(CreatePerson(name)); } Group newGroup = GetNewGroup(); WaitOnCreate.Reset(); if (IsLocalScene) { if (OldName == name) { return(base.NewID = OldID); } return(base.NewID = UUID.Random()); } Importing.Client.Groups.GroupCreatedReply += GroupCreateReply; Importing.Client.Groups.RequestCreateGroup(newGroup); if (!WaitOnCreate.WaitOne(5000)) { return(Importing.Client.Self.ActiveGroup); } return(base.NewID); }
public void KillInWorld(UUID oldobjid) { Vector3 at; if (!IsExisting(oldobjid, out at)) { return; } KillInWorldTask.Enqueue(() => { SimObject O = GetSimObjectFromUUID(oldobjid); if (O != null) { UUID into = CogbotHelpers.NonZero(FolderCalled("TaskInvKilled"), Client.Inventory.FindFolderForType(AssetType.TrashFolder)); Client.Inventory.RequestDeRezToInventory(O.LocalID, DeRezDestination.TrashFolder, into, UUID.Random()); return; } else { KillInWorld(oldobjid); } }); }
private UUID FindUser(string name) { if (IsGroup) { return(FindGroup(name)); } if (!CogbotHelpers.IsNullOrZero(base.NewID)) { return(base.NewID); } if (IsLocalScene) { if (OldName == name) { return(base.NewID = OldID); } return(base.NewID = UUID.Random()); } WaitOnCreate = WaitOnCreate ?? new ManualResetEvent(false); WaitOnCreate.Reset(); // should we use this instead?? // Running.Client.Avatars.RequestAvatarNameSearch(name.Replace(" ", ", "), OldID); Importing.Client.Directory.DirPeopleReply += PeopleSearchReply; QueryID = Importing.Client.Directory.StartPeopleSearch(name, 0); WaitOnCreate.WaitOne(3000); return(base.NewID); }
/// <summary> /// Returns ImageDownload object of the /// image from the local image cache, null if it does not exist /// </summary> /// <param name="imageID">UUID of the image we want to get</param> /// <returns>ImageDownload object containing the image, or null on failure</returns> public ImageDownload GetCachedImage(UUID imageID) { if (CogbotHelpers.IsNullOrZero(imageID)) { return(null); } if (!Operational()) { return(null); } byte[] imageData = GetCachedAssetBytes(imageID, AssetType.Texture); if (imageData == null) { return(null); } ImageDownload transfer = new ImageDownload(); transfer.AssetType = AssetType.Texture; transfer.ID = imageID; transfer.Simulator = Client.Network.CurrentSim; transfer.Size = imageData.Length; transfer.Success = true; transfer.Transferred = imageData.Length; transfer.AssetData = imageData; return(transfer); }
/// <summary> /// For now it just returns our name /// </summary> /// <param name="name"></param> /// <returns></returns> private UUID CreatePerson(string name) { if (!CogbotHelpers.IsNullOrZero(base.NewID)) { return(base.NewID); } if (name == "MISSINGPERSON" && !CogbotHelpers.IsNullOrZero(Importing.MISSINGPERSON)) { return(Importing.MISSINGPERSON); } if (name == "LINDENZERO" && !CogbotHelpers.IsNullOrZero(Importing.LINDENZERO)) { return(Importing.LINDENZERO); } if (IsLocalScene) { if (OldName == name) { return(base.NewID = OldID); } return(base.NewID = UUID.Random()); } if (IsGroup) { return(Importing.Client.Self.ActiveGroup); } return(base.NewID = Importing.Client.Self.AgentID); }
public void CreateWorkflow(UUID agentSyncFolderHolder) { string taskFile = ExportCommand.dumpDir + OldID + ".task"; if (File.Exists(taskFile)) { string taskDataS = File.ReadAllText(taskFile); if (string.IsNullOrEmpty(taskDataS) || taskDataS.Length < 30) { sourceObjectinventory = new List <InventoryBase>(); TaskItemsToCreate = new List <TaskItemToCreate>(); TaskInvComplete = true; return; } } if (CogbotHelpers.IsNullOrZero(AgentSyncFolder)) { AgentSyncFolder = Exporting.FolderCalled(OldID.ToString(), agentSyncFolderHolder); } if (TaskItemsToCreate != null) { return; } TaskItemsToCreate = new List <TaskItemToCreate>(); if (IsLocalScene) { return; } Client.Objects.ObjectProperties += TaskInventoryItemReceived; }
private bool checkTaskPerm(SimObject exportPrim, InventoryItem item, BotClient Client, OutputDelegate Failure, bool mustModify) { SimAvatarClient theAvatar = Client.TheSimAvatar; PermissionWho pw = theAvatar.EffectivePermissionWho(item.OwnerID, item.GroupID, item.GroupOwned); PermissionMask pm = CogbotHelpers.PermMaskForWho(pw, item.Permissions); bool modify = Permissions.HasPermissions(pm, PermissionMask.Modify); bool cmt = Permissions.HasPermissions(pm, PermissionMask.Copy) || Permissions.HasPermissions(pm, PermissionMask.Modify) || Permissions.HasPermissions(pm, PermissionMask.Transfer); if (mustModify) { if (!modify) { Failure("ItemPerms NOMODIFY " + pm + " for " + pw + " on " + ItemDesc(item, exportPrim)); return(false); } } if (!cmt) { Failure("ItemPerms " + pm + " for " + pw + " on " + ItemDesc(item, exportPrim)); var p = exportPrim.Parent; if (p != null && p != exportPrim) { exportPrim = p; } lock (SIPrims) SIPrims.Add(exportPrim); return(false); } return(true); }
private void LoadProgressFile() { if (CogbotHelpers.IsNullOrZero(NewID)) { string importProgress = ProgressFile; var item = ExportCommand.Exporting.GetInvItem(Importing.Client, "" + OldID, GetAssetUploadsFolder()); if (item != null) { NewID = item.AssetUUID; RezRequested = true; NewItemID = item.UUID; NewTaskID = Importing.Client.Self.AgentID; lock (ExportCommand.fileWriterLock) if (File.Exists(importProgress)) { return; } WriteProgress(); return; } if (File.Exists(importProgress)) { string data = File.ReadAllText(importProgress); var sdata = data.Split(','); NewID = new UUID(sdata[1]); // NewLocalID = uint.Parse(sdata[1]); RezRequested = true; } } }
public bool PutItemToTaskInv(BotClient Client, uint localID, SimObject exportPrim, string name) { InventoryItem found = GetInvItem(Client, name); if (found == null) { Failure("Cant find InvItem " + name); return(false); } bool canModifyObject = true; if (exportPrim != null) { PermissionWho pwo = Importing.TheSimAvatar.EffectivePermissionWho(exportPrim); PermissionMask pmo = CogbotHelpers.PermMaskForWho(pwo, exportPrim.Properties.Permissions); canModifyObject = Permissions.HasPermissions(pmo, PermissionMask.Modify); if (!canModifyObject) { } } if (found.InventoryType == InventoryType.LSL) { Client.Inventory.CopyScriptToTask(localID, (InventoryItem)found, true); //Client.Inventory.RequestSetScriptRunning(exportPrim.ID, found.UUID, true); } else { Client.Inventory.UpdateTaskInventory(localID, (InventoryItem)found); } return(canModifyObject); }
private UUID FindGroup(string name) { if (!IsGroup) { return(FindUser(name)); } if (!CogbotHelpers.IsNullOrZero(base.NewID)) { return(base.NewID); } if (IsLocalScene) { if (OldName == name) { return(base.NewID = OldID); } return(base.NewID = UUID.Random()); } WaitOnCreate = WaitOnCreate ?? new ManualResetEvent(false); WaitOnCreate.Reset(); Importing.Client.Directory.DirGroupsReply += GroupSearchReply; QueryID = Importing.Client.Directory.StartGroupSearch(name, 0); if (!WaitOnCreate.WaitOne(3000)) { return(Importing.Client.Self.ActiveGroup); } return(base.NewID); }
static private void AddExportUser(UUID userID) { if (CogbotHelpers.IsNullOrZero(userID)) { return; } ExportUsers.Add(userID); }
private void FindOrCreateAsset(UUID uuid, AssetType type) { if (!CogbotHelpers.IsNullOrZero(uuid)) { return; } //if (type != AssetType.Object) SimAssetStore.FindOrCreateAsset(uuid, type); }
public static string uuidString(UUID uuid) { if (CogbotHelpers.IsNullOrZero(uuid)) { return("Zero"); } return(uuid.ToString()); }
static private void AddExportGroup(UUID groupID) { if (CogbotHelpers.IsNullOrZero(groupID)) { return; } ExportGroup.Add(groupID); }
public void KillInWorldAndDisk(UUID oldobjid) { if (CogbotHelpers.IsNullOrZero(oldobjid)) { return; } Importing.KillID(oldobjid); KillInWorld(oldobjid); }
public void AssetComplete(UUID assetID) { if (CogbotHelpers.IsNullOrZero(assetID)) { return; } lock (ToDownloadAssets) ToDownloadAssets.Remove(assetID); lock (CompletedAssets) CompletedAssets.Add(assetID); }
public override CmdResult ExecuteRequest(CmdRequest args) { try { var fromAgentID = CogbotHelpers.NonZero((UUID)BotClient.SessionToCallerId(args.CallerAgent), UUID.Zero); return(Execute0(args, fromAgentID, WriteLine)); } catch (Exception e) { return(Failure("" + e)); } }
public bool EnsureTaskInv(bool useCache) { if (File.Exists(ExportCommand.assetDumpDir + OldID + ".object")) { return(true); } var o = Rezed; if (MissingTASK(OldID) && o != null) { var taskinv = o.TaskInventory; if (taskinv == null) { return(false); } Exporting.SaveTaskOSD(OldID, taskinv); } string taskFile = ExportCommand.dumpDir + OldID + ".task"; if (!File.Exists(taskFile)) { return(false); } string taskDataS = File.ReadAllText(taskFile); if (string.IsNullOrEmpty(taskDataS) || taskDataS.Length < 30) { sourceObjectinventory = new List <InventoryBase>(); TaskItemsToCreate = new List <TaskItemToCreate>(); TaskInvComplete = true; return(true); } var agentSyncFolderHolder = Exporting.FolderCalled("TaskInvHolder"); CreateWorkflow(agentSyncFolderHolder); LoadTaskOSD(Importing.WriteLine); var ti = SourceTaskInventory(useCache); foreach (InventoryBase i in ti) { InventoryItem item = i as InventoryItem; if (item == null) { continue; } if (CogbotHelpers.IsNullOrZero(item.AssetUUID)) { return(false); } } return(true); }
private void RelayToSim(string nick, string data) { if (!Client.IsLoggedInAndReady) { return; } Client.Self.Chat(string.Format("{0}: {1}", nick, data), 0, ChatType.Normal); if (!CogbotHelpers.IsNullOrZero(groupToRelayTo)) { Client.Self.InstantMessageGroup(nick, groupToRelayTo, data); } }
private void UpdateTaskInvAssetID(SimObject o, UUID uuid, UUID id) { if (o == null) { return; } var ti = o.TaskInventory; if (ti == null) { return; } bool fixedIt = false; bool somethingBroke = false; foreach (InventoryBase b in ti) { InventoryItem it = b as InventoryItem; if (it == null) { continue; } if (b.UUID == uuid) { if (CogbotHelpers.IsNullOrZero(it.AssetUUID)) { it.AssetUUID = id; fixedIt = true; } if (it.AssetType == AssetType.Object) { if (CogbotHelpers.IsNullOrZero(it.RezzID)) { it.RezzID = id; fixedIt = true; } } } if (CogbotHelpers.IsNullOrZero(it.AssetUUID) && CogbotHelpers.IsNullOrZero(it.RezzID)) { somethingBroke = true; } } if (fixedIt) { if (somethingBroke) { // return; } SaveTaskOSD(o.ID, ti); } }
public OSDMap UnpackTaskItem(BotClient Client, SimObject exportPrim, InventoryItem item, OutputDelegate Failure, out bool missing) { UUID itemID = item.UUID; lock (CompletedTaskItem) if (CompletedTaskItem.Contains(itemID)) { missing = false; return(OSDSerializeMembers(item)); } lock (CompletedTaskItem) if (!CogbotHelpers.IsNullOrZero(item.AssetUUID) && CompletedAssets.Contains(item.AssetUUID)) { TaskItemComplete(exportPrim.ID, itemID, item.AssetUUID, item.AssetType); missing = false; return(OSDSerializeMembers(item)); } if (showsMissingOnly) { Failure("NEED TASKITEM: " + ItemDesc(item, exportPrim)); missing = true; return(OSDSerializeMembers(item)); } ExportTaskAsset ho; AutoResetEvent waitUntilDL = new AutoResetEvent(false); lock (TaskAssetWaiting) if (!TaskAssetWaiting.TryGetValue(itemID, out ho)) { TaskAssetWaiting[itemID] = ho = new ExportTaskAsset { SourceItem = item, O = exportPrim }; ho.waiting = waitUntilDL; } waitUntilDL = ho.waiting; lock (CompletedTaskItem) if (!CogbotHelpers.IsNullOrZero(item.AssetUUID) && CompletedAssets.Contains(item.AssetUUID)) { TaskItemComplete(exportPrim.ID, itemID, item.AssetUUID, item.AssetType); missing = false; return(OSDSerializeMembers(item)); } SlowlyDo(ho.Request); missing = waitUntilDL == null || !waitUntilDL.WaitOne(4000); if (CogbotHelpers.IsNullOrZero(item.AssetUUID)) { Failure("ASSET ZERO " + ItemDesc(item, exportPrim)); missing = true; } AddRelated(item.AssetUUID, item.AssetType); FindOrCreateAsset(item.AssetUUID, item.AssetType); return(OSDSerializeMembers(item)); }
private ItemToCreate FindItemToCreate(UUID uuid, AssetType assetType, bool sameIds) { var itc = GetOld(uuid) as ItemToCreate; if (itc == null) { itc = new ItemToCreate(uuid, assetType); UUID2OBJECT[uuid] = itc; if (!CogbotHelpers.IsNullOrZero(itc.NewID)) { NewUUID2OBJECT[itc.NewID] = itc; } } return(itc); }
private UUID GetChange(UUID id) { if (CogbotHelpers.IsNullOrZero(id)) { throw new NullReferenceException("GetOldPRim"); } lock (WorkFlowLock) { UUIDChange ptc; if (UUID2OBJECT.TryGetValue(id, out ptc)) { return(ptc.NewID); } } return(UUID.Zero); }
public bool InGroup(UUID uuid) { if (CogbotHelpers.IsNullOrZero(uuid)) { return(false); } if (GroupRoles != null) { if (GroupRoles.ContainsKey(uuid)) { return(true); } } var ag = AvatarGroups; return(ag != null && ag.Contains(uuid)); }
public override CmdResult ExecuteRequest(CmdRequest args) { var fromAgentID = CogbotHelpers.NonZero((UUID)BotClient.SessionToCallerId(args.CallerAgent), UUID.Zero); if (fromAgentID == UUID.Zero) { return(Failure("Unable to send money to console. This command only works when IMed.")); } if (fromAgentID == Client.Self.AgentID) { return(Failure("Unable to send money to self.")); } int amount = Client.Self.Balance; Client.Self.GiveAvatarMoney(fromAgentID, Client.Self.Balance, "BotClient.GiveAll"); return(Success("Gave $" + amount + " to " + fromAgentID)); }
public bool HasAsset(UUID assetID, AssetType assetType) { if (CogbotHelpers.IsNullOrZero(assetID)) { return(false); } if (!Operational()) { return(false); } else if (File.Exists(FileName(assetID, assetType))) { return(true); } else { return(Exists(StaticFileName(assetID))); } }
private byte[] GetCachedAssetBytes0(UUID assetID, AssetType assetType) { if (CogbotHelpers.IsNullOrZero(assetID)) { return(null); } if (!Operational()) { return(null); } try { byte[] data = null; string fileName = FileName(assetID, assetType); bool exists = File.Exists(fileName); if (!exists) { string sfn = StaticFileName(assetID); //Logger.DebugLog("Reading " + fileName + " from asset cache. (missing) null"); if (Exists(sfn)) { data = File.ReadAllBytes(sfn); File.Copy(sfn, fileName); } } else { Logger.DebugLog("Reading " + fileName + " from asset cache."); data = File.ReadAllBytes(fileName); } return(data); } catch (FileNotFoundException ex) { return(null); } catch (Exception ex) { Logger.Log("Failed reading asset from cache (" + ex.Message + ")", Helpers.LogLevel.Warning, Client); return(null); } }
private static bool IsIncluded(UUID id, uint lid) { ImportCommand importing = ImportCommand.Importing; if (!CogbotHelpers.IsNullOrZero(id)) { if (Exporting.TasksRezed.ContainsKey(id) || importing.MustExport.Contains(id)) { return(true); } } if (lid != 0) { if (importing.MustExportUINT.Contains(lid) || importing.GetOldPrim(lid) != null) { return(true); } } return(false); }
OSDMap SaveEachTaskItem(ImportSettings arglist, BotClient Client, SimObject exportPrim, InventoryBase b, OutputDelegate Failure, out bool missing) { InventoryFolder fldr = b as InventoryFolder; if (fldr != null) { missing = false; return(OSDSerializeMembers(b)); } InventoryItem item = b as InventoryItem; if (item == null) { string errorMsg = "" + b.UUID + ",ERROR," + b.UUID + "," + b.Name; Failure("No an Item"); missing = true; return(OSDSerializeMembers(b)); } bool exportable = checkTaskPerm(exportPrim, item, Client, Failure, false); lock (TaskAssetWaiting) { lock (CompletedTaskItem) { UUID itemID = item.UUID; if (CompletedTaskItem.Contains(itemID)) { missing = false; return(OSDSerializeMembers(item)); } } } if (item.InventoryType == InventoryType.Object) { //UUID newObjID; //return UnpackTaskObject(arglist, exportPrim, item as InventoryObject, Client, Failure, out missing, taskobj, out newObjID); } missing = CogbotHelpers.IsNullOrZero(item.AssetUUID); return(OSDSerializeMembers(item)); //UnpackTaskItem(Client, exportPrim, item, Failure, out missing); }
private void EnsureUploaded(ItemToCreate itc, bool alwayReupload, ref int uploaded, ref int reuploaded) { if (!itc.RezRequested) { itc.UploadAssetData(false); if (!CogbotHelpers.IsNullOrZero(itc.NewID)) { NewUUID2OBJECT[itc.NewID] = itc; } uploaded++; } else if (alwayReupload) { itc.UpdateAsset(itc.AssetData); reuploaded++; } if (!CogbotHelpers.IsNullOrZero(itc.NewID)) { NewUUID2OBJECT[itc.NewID] = itc; } }