29 using System.Collections.Generic;
30 using System.Reflection;
34 using OpenSim.Framework;
35 using OpenSim.Region.Framework.Interfaces;
36 using OpenSim.Region.Framework.Scenes;
37 using OpenSim.Services.Interfaces;
43 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"XCallingCard")]
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 protected List<Scene> m_Scenes =
new List<Scene>();
48 protected bool m_Enabled =
true;
52 IConfig ccConfig = source.Configs[
"XCallingCard"];
54 m_Enabled = ccConfig.GetBoolean(
"Enabled",
true);
72 m_Scenes.Remove(scene);
74 scene.EventManager.OnNewClient -= OnNewClient;
75 scene.EventManager.OnIncomingInstantMessage +=
76 OnIncomingInstantMessage;
85 scene.EventManager.OnNewClient += OnNewClient;
96 public Type ReplaceableInterface
103 get {
return "XCallingCardModule"; }
108 client.OnOfferCallingCard += OnOfferCallingCard;
109 client.OnAcceptCallingCard += OnAcceptCallingCard;
110 client.OnDeclineCallingCard += OnDeclineCallingCard;
113 private void OnOfferCallingCard(
IClientAPI client, UUID destID, UUID transactionID)
123 CreateCallingCard(client.
AgentId, destID,
UUID.Zero,
true);
131 DoCallingCardOffer(dest, client.
AgentId);
138 if (transferModule != null)
143 destID, (byte)211,
false,
145 transactionID,
false,
new Vector3(),
new byte[0],
true),
146 delegate(
bool success) {} );
150 private void DoCallingCardOffer(
IClientAPI dest, UUID from)
154 dest.SendOfferCallingCard(from, itemID);
164 return CreateCallingCard(userID, creatorID, folderID,
false);
167 private UUID CreateCallingCard(UUID userID, UUID creatorID, UUID folderID,
bool isGod)
173 UserAccount info = userv.GetUserAccount(UUID.Zero, creatorID);
181 if (folderID ==
UUID.Zero)
184 FolderType.CallingCard);
189 folderID = folder.ID;
192 m_log.DebugFormat(
"[XCALLINGCARD]: Creating calling card for {0} in inventory of {1}", info.Name, userID);
195 item.AssetID = UUID.Zero;
196 item.AssetType = (int)AssetType.CallingCard;
197 item.BasePermissions = (uint)(PermissionMask.Copy | PermissionMask.Modify);
202 item.CurrentPermissions = item.BasePermissions;
203 item.NextPermissions = (uint)(PermissionMask.Copy | PermissionMask.Modify);
205 item.ID = UUID.Random();
206 item.CreatorId = creatorID.ToString();
208 item.GroupID = UUID.Zero;
209 item.GroupOwned =
false;
210 item.Folder = folderID;
212 item.CreationDate = Util.UnixTimeSinceEpoch();
213 item.InvType = (int)InventoryType.CallingCard;
216 item.Name = info.
Name;
217 item.Description =
"";
220 item.SaleType = (byte)SaleType.Not;
226 client.SendBulkUpdateInventory(item);
231 private void OnAcceptCallingCard(
IClientAPI client, UUID transactionID, UUID folderID)
235 private void OnDeclineCallingCard(
IClientAPI client, UUID transactionID)
240 invService.GetFolderForType(client.AgentId, FolderType.Trash);
243 item = invService.GetItem(item);
245 if (item != null && trashFolder != null)
247 item.Folder = trashFolder.ID;
248 List<UUID> uuids =
new List<UUID>();
250 invService.DeleteItems(item.Owner, uuids);
251 m_Scenes[0].AddInventoryItem(client, item);
257 Scene scene = GetClientScene(agentID);
262 if (presence == null)
265 return presence.ControllingClient;
268 private Scene GetClientScene(UUID agentId)
272 foreach (
Scene scene
in m_Scenes)
275 if (presence != null)
289 foreach (
Scene scene
in m_Scenes)
292 if (presence != null)
304 if (msg.
dialog == (uint)211)
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
UUID CreateCallingCard(UUID userID, UUID creatorID, UUID folderID)
OpenSim.Framework.PermissionMask PermissionMask
IClientAPI FindClientObject(UUID agentID)
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
Inventory Item - contains all the properties associated with an individual inventory piece...
void Initialise(IConfigSource source)
This is called to initialize the region module. For shared modules, this is called exactly once...
Interactive OpenSim region server
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
void PostInitialise()
This is called exactly once after all the shared region-modules have been instanciated and IRegionMod...
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...