1
0

TaskInventoryItem.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Reflection;
  29. using log4net;
  30. using OpenMetaverse;
  31. namespace OpenSim.Framework
  32. {
  33. /// <summary>
  34. /// Represents an item in a task inventory
  35. /// </summary>
  36. public class TaskInventoryItem : ICloneable
  37. {
  38. // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  39. private const uint FULL_MASK_PERMISSIONS_GENERAL = 2147483647;
  40. public UUID AssetID { get; set; }
  41. public uint CreationDate { get; set; }
  42. UUID _creatorID = UUID.Zero;
  43. public UUID CreatorID
  44. {
  45. get { return _creatorID; }
  46. set { _creatorID = value; }
  47. }
  48. private string _creatorData = string.Empty;
  49. public string CreatorData // = <profile url>;<name>
  50. {
  51. get { return _creatorData; }
  52. set { _creatorData = value; }
  53. }
  54. /// <summary>
  55. /// Used by the DB layer to retrieve / store the entire user identification.
  56. /// The identification can either be a simple UUID or a string of the form
  57. /// uuid[;profile_url[;name]]
  58. /// </summary>
  59. public string CreatorIdentification
  60. {
  61. get
  62. {
  63. if (!string.IsNullOrEmpty(_creatorData))
  64. return _creatorID.ToString() + ';' + _creatorData;
  65. else
  66. return _creatorID.ToString();
  67. }
  68. set
  69. {
  70. if (string.IsNullOrEmpty(value))
  71. {
  72. _creatorData = string.Empty;
  73. return;
  74. }
  75. if (!value.Contains(';')) // plain UUID
  76. {
  77. _= UUID.TryParse(value, out _creatorID);
  78. }
  79. else // <uuid>[;<endpoint>[;name]]
  80. {
  81. string name = "Unknown User";
  82. string[] parts = value.Split(';');
  83. if (parts.Length >= 1)
  84. {
  85. _ = UUID.TryParse(parts[0], out _creatorID);
  86. }
  87. if (parts.Length >= 2)
  88. _creatorData = parts[1];
  89. if (parts.Length >= 3)
  90. name = parts[2];
  91. _creatorData += ';' + name;
  92. }
  93. }
  94. }
  95. public uint Flags { get; set; }
  96. public int Type { get; set; }
  97. public int InvType { get; set; }
  98. public UUID ItemID { get; set; }
  99. public UUID OldItemID { get; set; }
  100. public UUID LoadedItemID { get; set; }
  101. public UUID RezzerID { get; set; }
  102. public string Name { get; set; }
  103. public string Description { get; set; }
  104. public UUID OwnerID { get; set; }
  105. public UUID LastOwnerID { get; set; }
  106. public UUID GroupID { get; set; }
  107. public UUID ParentID { get; set; }
  108. public UUID ParentPartID { get; set; }
  109. public uint BasePermissions { get; set; } = FULL_MASK_PERMISSIONS_GENERAL;
  110. public uint CurrentPermissions { get; set; } = FULL_MASK_PERMISSIONS_GENERAL;
  111. public uint EveryonePermissions { get; set; } = FULL_MASK_PERMISSIONS_GENERAL;
  112. public uint GroupPermissions { get; set; } = FULL_MASK_PERMISSIONS_GENERAL;
  113. public uint NextPermissions { get; set; } = FULL_MASK_PERMISSIONS_GENERAL;
  114. public UUID PermsGranter { get; set; }
  115. public int PermsMask { get; set; }
  116. private bool _ownerChanged = false;
  117. public bool OwnerChanged
  118. {
  119. get { return _ownerChanged; }
  120. set
  121. {
  122. _ownerChanged = value;
  123. //m_log.DebugFormat(
  124. // "[TASK INVENTORY ITEM]: Owner changed set {0} for {1} {2} owned by {3}",
  125. // _ownerChanged, Name, ItemID, OwnerID);
  126. }
  127. }
  128. /// <summary>
  129. /// This used ONLY during copy. It can't be relied on at other times!
  130. /// </summary>
  131. /// <remarks>
  132. /// For true script running status, use IEntityInventory.TryGetScriptInstanceRunning() for now.
  133. /// </remarks>
  134. public bool ScriptRunning { get; set; }
  135. // See ICloneable
  136. #region ICloneable Members
  137. public Object Clone()
  138. {
  139. return MemberwiseClone();
  140. }
  141. #endregion
  142. /// <summary>
  143. /// Reset the UUIDs for this item.
  144. /// </summary>
  145. /// <param name="partID">The new part ID to which this item belongs</param>
  146. public void ResetIDs(UUID partID)
  147. {
  148. LoadedItemID = OldItemID;
  149. OldItemID = ItemID;
  150. ItemID = UUID.Random();
  151. ParentPartID = partID;
  152. ParentID = partID;
  153. }
  154. public TaskInventoryItem()
  155. {
  156. ScriptRunning = true;
  157. CreationDate = (uint)Util.UnixTimeSinceEpoch();
  158. }
  159. }
  160. }