aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules
diff options
context:
space:
mode:
authorHomer Horwitz2008-10-19 16:49:10 +0000
committerHomer Horwitz2008-10-19 16:49:10 +0000
commit1ee10d919aae59e8b97b7f24dff14a16cb50e8df (patch)
treeed53a4418624c0f1c7aff4b2474184e989ae3f8d /OpenSim/Region/Environment/Modules
parentUpdate svn properties. (diff)
downloadopensim-SC_OLD-1ee10d919aae59e8b97b7f24dff14a16cb50e8df.zip
opensim-SC_OLD-1ee10d919aae59e8b97b7f24dff14a16cb50e8df.tar.gz
opensim-SC_OLD-1ee10d919aae59e8b97b7f24dff14a16cb50e8df.tar.bz2
opensim-SC_OLD-1ee10d919aae59e8b97b7f24dff14a16cb50e8df.tar.xz
Added calling cards. Fixes Mantis#2409 and part of #1515.
Diffstat (limited to 'OpenSim/Region/Environment/Modules')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs124
-rw-r--r--OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs16
2 files changed, 133 insertions, 7 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs
index 0be540d..c51bcc1 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs
@@ -48,6 +48,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
48 private Dictionary<UUID, ulong> m_rootAgents = new Dictionary<UUID, ulong>(); 48 private Dictionary<UUID, ulong> m_rootAgents = new Dictionary<UUID, ulong>();
49 private Dictionary<UUID, List<StoredFriendListUpdate>> StoredFriendListUpdates = new Dictionary<UUID, List<StoredFriendListUpdate>>(); 49 private Dictionary<UUID, List<StoredFriendListUpdate>> StoredFriendListUpdates = new Dictionary<UUID, List<StoredFriendListUpdate>>();
50 50
51 private Dictionary<UUID, UUID> m_pendingCallingcardRequests = new Dictionary<UUID,UUID>();
52
51 private List<Scene> m_scene = new List<Scene>(); 53 private List<Scene> m_scene = new List<Scene>();
52 54
53 #region IRegionModule Members 55 #region IRegionModule Members
@@ -109,7 +111,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
109 111
110 UUID.TryParse((string)requestData["agent_id"], out notifyAboutAgentId); 112 UUID.TryParse((string)requestData["agent_id"], out notifyAboutAgentId);
111 m_log.InfoFormat("[PRESENCE]: Got presence update for {0}, and we're telling {1}, with a status {2}", notifyAboutAgentId.ToString(), notifyAgentId.ToString(), notifyOnlineStatus.ToString()); 113 m_log.InfoFormat("[PRESENCE]: Got presence update for {0}, and we're telling {1}, with a status {2}", notifyAboutAgentId.ToString(), notifyAgentId.ToString(), notifyOnlineStatus.ToString());
112 ScenePresence avatar = GetPresenceFromAgentID(notifyAgentId); 114 ScenePresence avatar = GetRootPresenceFromAgentID(notifyAgentId);
113 if (avatar != null) 115 if (avatar != null)
114 { 116 {
115 if (avatar.IsChildAgent) 117 if (avatar.IsChildAgent)
@@ -184,6 +186,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
184 client.OnApproveFriendRequest += OnApprovedFriendRequest; 186 client.OnApproveFriendRequest += OnApprovedFriendRequest;
185 client.OnDenyFriendRequest += OnDenyFriendRequest; 187 client.OnDenyFriendRequest += OnDenyFriendRequest;
186 client.OnTerminateFriendship += OnTerminateFriendship; 188 client.OnTerminateFriendship += OnTerminateFriendship;
189 client.OnOfferCallingCard += OnOfferCallingCard;
190 client.OnAcceptCallingCard += OnAcceptCallingCard;
191 client.OnDeclineCallingCard += OnDeclineCallingCard;
187 192
188 doFriendListUpdateOnline(client.AgentId); 193 doFriendListUpdateOnline(client.AgentId);
189 194
@@ -228,7 +233,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
228 } 233 }
229 foreach (UUID user in UpdateUsers) 234 foreach (UUID user in UpdateUsers)
230 { 235 {
231 ScenePresence av = GetPresenceFromAgentID(user); 236 ScenePresence av = GetRootPresenceFromAgentID(user);
232 if (av != null) 237 if (av != null)
233 { 238 {
234 List<FriendListItem> usrfl = new List<FriendListItem>(); 239 List<FriendListItem> usrfl = new List<FriendListItem>();
@@ -257,7 +262,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
257 262
258 if (UpdateUsers.Count > 0) 263 if (UpdateUsers.Count > 0)
259 { 264 {
260 ScenePresence avatar = GetPresenceFromAgentID(AgentId); 265 ScenePresence avatar = GetRootPresenceFromAgentID(AgentId);
261 if (avatar != null) 266 if (avatar != null)
262 { 267 {
263 avatar.ControllingClient.SendAgentOnline(UpdateUsers.ToArray()); 268 avatar.ControllingClient.SendAgentOnline(UpdateUsers.ToArray());
@@ -349,7 +354,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
349 354
350 for (int i = 0; i < updateUsers.Count; i++) 355 for (int i = 0; i < updateUsers.Count; i++)
351 { 356 {
352 ScenePresence av = GetPresenceFromAgentID(updateUsers[i]); 357 ScenePresence av = GetRootPresenceFromAgentID(updateUsers[i]);
353 if (av != null) 358 if (av != null)
354 { 359 {
355 UUID[] agents = new UUID[1]; 360 UUID[] agents = new UUID[1];
@@ -427,7 +432,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
427 } 432 }
428 } 433 }
429 434
430 private ScenePresence GetPresenceFromAgentID(UUID AgentID) 435 private ScenePresence GetRootPresenceFromAgentID(UUID AgentID)
431 { 436 {
432 ScenePresence returnAgent = null; 437 ScenePresence returnAgent = null;
433 lock (m_scene) 438 lock (m_scene)
@@ -449,6 +454,25 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
449 return returnAgent; 454 return returnAgent;
450 } 455 }
451 456
457 private ScenePresence GetAnyPresenceFromAgentID(UUID AgentID)
458 {
459 ScenePresence returnAgent = null;
460 lock (m_scene)
461 {
462 ScenePresence queryagent = null;
463 for (int i = 0; i < m_scene.Count; i++)
464 {
465 queryagent = m_scene[i].GetScenePresence(AgentID);
466 if (queryagent != null)
467 {
468 returnAgent = queryagent;
469 break;
470 }
471 }
472 }
473 return returnAgent;
474 }
475
452 #region FriendRequestHandling 476 #region FriendRequestHandling
453 477
454 private void OnInstantMessage(IClientAPI client, UUID fromAgentID, 478 private void OnInstantMessage(IClientAPI client, UUID fromAgentID,
@@ -520,7 +544,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
520 Scene SceneAgentIn = m_scene[0]; 544 Scene SceneAgentIn = m_scene[0];
521 545
522 // Found Pending Friend Request with that Transaction.. 546 // Found Pending Friend Request with that Transaction..
523 ScenePresence agentpresence = GetPresenceFromAgentID(agentID); 547 ScenePresence agentpresence = GetRootPresenceFromAgentID(agentID);
524 if (agentpresence != null) 548 if (agentpresence != null)
525 { 549 {
526 SceneAgentIn = agentpresence.Scene; 550 SceneAgentIn = agentpresence.Scene;
@@ -564,7 +588,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
564 Scene SceneAgentIn = m_scene[0]; 588 Scene SceneAgentIn = m_scene[0];
565 589
566 // Found Pending Friend Request with that Transaction.. 590 // Found Pending Friend Request with that Transaction..
567 ScenePresence agentpresence = GetPresenceFromAgentID(agentID); 591 ScenePresence agentpresence = GetRootPresenceFromAgentID(agentID);
568 if (agentpresence != null) 592 if (agentpresence != null)
569 { 593 {
570 SceneAgentIn = agentpresence.Scene; 594 SceneAgentIn = agentpresence.Scene;
@@ -607,8 +631,94 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
607 } 631 }
608 632
609 #endregion 633 #endregion
634
635 #region CallingCards
636
637 private void OnOfferCallingCard(IClientAPI client, UUID destID, UUID transactionID)
638 {
639 m_log.DebugFormat("[CALLING CARD]: got offer from {0} for {1}, transaction {2}",
640 client.AgentId, destID, transactionID);
641 // This might be slightly wrong. On a multi-region server, we might get the child-agent instead of the root-agent
642 // (or the root instead of the child)
643 ScenePresence destAgent = GetAnyPresenceFromAgentID(destID);
644 if (destAgent == null)
645 {
646 client.SendAlertMessage("The person you have offered a card to can't be found anymore.");
647 return;
648 }
649
650 m_pendingCallingcardRequests[transactionID] = client.AgentId;
651 // inform the destination agent about the offer
652 destAgent.ControllingClient.SendOfferCallingCard(client.AgentId, transactionID);
653 }
654
655 private void CreateCallingCard(IClientAPI client, UUID creator, UUID folder, string name)
656 {
657 InventoryItemBase item = new InventoryItemBase();
658 item.AssetID = UUID.Zero;
659 item.AssetType = (int)AssetType.CallingCard;
660 item.BasePermissions = (uint)PermissionMask.Copy;
661 item.CreationDate = Util.UnixTimeSinceEpoch();
662 item.Creator = creator;
663 item.CurrentPermissions = item.BasePermissions;
664 item.Description = "";
665 item.EveryOnePermissions = (uint)PermissionMask.None;
666 item.Flags = 0;
667 item.Folder = folder;
668 item.GroupID = UUID.Zero;
669 item.GroupOwned = false;
670 item.ID = UUID.Random();
671 item.InvType = (int)InventoryType.CallingCard;
672 item.Name = name;
673 item.NextPermissions = item.EveryOnePermissions;
674 item.Owner = client.AgentId;
675 item.SalePrice = 10;
676 item.SaleType = (byte)SaleType.Not;
677 ((Scene)client.Scene).AddInventoryItem(client, item);
678 }
679
680 private void OnAcceptCallingCard(IClientAPI client, UUID transactionID, UUID folderID)
681 {
682 m_log.DebugFormat("[CALLING CARD]: User {0} ({1} {2}) accepted tid {3}, folder {4}",
683 client.AgentId,
684 client.FirstName, client.LastName,
685 transactionID, folderID);
686 UUID destID;
687 if (m_pendingCallingcardRequests.TryGetValue(transactionID, out destID))
688 {
689 m_pendingCallingcardRequests.Remove(transactionID);
690
691 ScenePresence destAgent = GetAnyPresenceFromAgentID(destID);
692 // inform sender of the card that destination declined the offer
693 if (destAgent != null) destAgent.ControllingClient.SendAcceptCallingCard(transactionID);
694
695 // put a calling card into the inventory of receiver
696 CreateCallingCard(client, destID, folderID, destAgent.Name);
697 }
698 else m_log.WarnFormat("[CALLING CARD]: Got a AcceptCallingCard from {0} {1} without an offer before.",
699 client.FirstName, client.LastName);
700 }
701
702 private void OnDeclineCallingCard(IClientAPI client, UUID transactionID)
703 {
704 m_log.DebugFormat("[CALLING CARD]: User {0} declined card, tid {2}",
705 client.AgentId, transactionID);
706 UUID destID;
707 if (m_pendingCallingcardRequests.TryGetValue(transactionID, out destID))
708 {
709 m_pendingCallingcardRequests.Remove(transactionID);
710
711 ScenePresence destAgent = GetAnyPresenceFromAgentID(destID);
712 // inform sender of the card that destination declined the offer
713 if (destAgent != null) destAgent.ControllingClient.SendDeclineCallingCard(transactionID);
714 }
715 else m_log.WarnFormat("[CALLING CARD]: Got a DeclineCallingCard from {0} {1} without an offer before.",
716 client.FirstName, client.LastName);
717 }
610 } 718 }
611 719
720 #endregion
721
612 public struct StoredFriendListUpdate 722 public struct StoredFriendListUpdate
613 { 723 {
614 public UUID storedFor; 724 public UUID storedFor;
diff --git a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs
index 52a2792..9aa0403 100644
--- a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs
@@ -334,6 +334,10 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
334 334
335 public event MapItemRequest OnMapItemRequest; 335 public event MapItemRequest OnMapItemRequest;
336 336
337 public event OfferCallingCard OnOfferCallingCard;
338 public event AcceptCallingCard OnAcceptCallingCard;
339 public event DeclineCallingCard OnDeclineCallingCard;
340
337 341
338#pragma warning restore 67 342#pragma warning restore 67
339 343
@@ -939,5 +943,17 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
939 public void SendEventInfoReply (EventData info) 943 public void SendEventInfoReply (EventData info)
940 { 944 {
941 } 945 }
946
947 public void SendOfferCallingCard (UUID destID, UUID transactionID)
948 {
949 }
950
951 public void SendAcceptCallingCard (UUID transactionID)
952 {
953 }
954
955 public void SendDeclineCallingCard (UUID transactionID)
956 {
957 }
942 } 958 }
943} 959}