aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/IClientAPI.cs13
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs68
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs124
-rw-r--r--OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs16
-rw-r--r--OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs16
5 files changed, 229 insertions, 8 deletions
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index 0bb790c..bf31a78 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -324,6 +324,10 @@ namespace OpenSim.Framework
324 324
325 public delegate void MapItemRequest(IClientAPI remoteClient, uint flags, uint EstateID, bool godlike, uint itemtype, ulong regionhandle); 325 public delegate void MapItemRequest(IClientAPI remoteClient, uint flags, uint EstateID, bool godlike, uint itemtype, ulong regionhandle);
326 326
327 public delegate void OfferCallingCard(IClientAPI remoteClient, UUID destID, UUID transactionID);
328 public delegate void AcceptCallingCard(IClientAPI remoteClient, UUID transactionID, UUID folderID);
329 public delegate void DeclineCallingCard(IClientAPI remoteClient, UUID transactionID);
330
327 #endregion 331 #endregion
328 332
329 public struct DirPlacesReplyData 333 public struct DirPlacesReplyData
@@ -625,6 +629,9 @@ namespace OpenSim.Framework
625 629
626 event MapItemRequest OnMapItemRequest; 630 event MapItemRequest OnMapItemRequest;
627 631
632 event OfferCallingCard OnOfferCallingCard;
633 event AcceptCallingCard OnAcceptCallingCard;
634 event DeclineCallingCard OnDeclineCallingCard;
628 635
629 // void ActivateGesture(UUID assetId, UUID gestureId); 636 // void ActivateGesture(UUID assetId, UUID gestureId);
630 637
@@ -894,7 +901,11 @@ namespace OpenSim.Framework
894 void SendEventInfoReply(EventData info); 901 void SendEventInfoReply(EventData info);
895 902
896 void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags); 903 void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags);
897 904
905 void SendOfferCallingCard(UUID srcID, UUID transactionID);
906 void SendAcceptCallingCard(UUID transactionID);
907 void SendDeclineCallingCard(UUID transactionID);
908
898 void KillEndDone(); 909 void KillEndDone();
899 } 910 }
900} 911}
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 412f969..19983dc 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -1009,6 +1009,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1009 1009
1010 public event MapItemRequest OnMapItemRequest; 1010 public event MapItemRequest OnMapItemRequest;
1011 1011
1012 public event OfferCallingCard OnOfferCallingCard;
1013 public event AcceptCallingCard OnAcceptCallingCard;
1014 public event DeclineCallingCard OnDeclineCallingCard;
1015
1012 // voire si c'est necessaire 1016 // voire si c'est necessaire
1013 public void ActivateGesture(UUID assetId, UUID gestureId) 1017 public void ActivateGesture(UUID assetId, UUID gestureId)
1014 { 1018 {
@@ -6447,6 +6451,38 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6447 parcelSetOtherCleanTimePacket.ParcelData.OtherCleanTime); 6451 parcelSetOtherCleanTimePacket.ParcelData.OtherCleanTime);
6448 } 6452 }
6449 break; 6453 break;
6454
6455 case PacketType.OfferCallingCard:
6456 OfferCallingCardPacket offerCallingCardPacket = (OfferCallingCardPacket)Pack;
6457 if (OnOfferCallingCard != null)
6458 {
6459 OnOfferCallingCard(this,
6460 offerCallingCardPacket.AgentBlock.DestID,
6461 offerCallingCardPacket.AgentBlock.TransactionID);
6462 }
6463 break;
6464
6465 case PacketType.AcceptCallingCard:
6466 AcceptCallingCardPacket acceptCallingCardPacket = (AcceptCallingCardPacket)Pack;
6467 // according to http://wiki.secondlife.com/wiki/AcceptCallingCard FolderData should
6468 // contain exactly one entry
6469 if (OnAcceptCallingCard != null && acceptCallingCardPacket.FolderData.Length > 0)
6470 {
6471 OnAcceptCallingCard(this,
6472 acceptCallingCardPacket.TransactionBlock.TransactionID,
6473 acceptCallingCardPacket.FolderData[0].FolderID);
6474 }
6475 break;
6476
6477 case PacketType.DeclineCallingCard:
6478 DeclineCallingCardPacket declineCallingCardPacket = (DeclineCallingCardPacket)Pack;
6479 if (OnDeclineCallingCard != null)
6480 {
6481 OnDeclineCallingCard(this,
6482 declineCallingCardPacket.TransactionBlock.TransactionID);
6483 }
6484 break;
6485
6450 default: 6486 default:
6451 m_log.Warn("[CLIENT]: unhandled packet " + Pack.ToString()); 6487 m_log.Warn("[CLIENT]: unhandled packet " + Pack.ToString());
6452 break; 6488 break;
@@ -7161,6 +7197,38 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7161 7197
7162 } 7198 }
7163 7199
7200 public void SendOfferCallingCard(UUID srcID, UUID transactionID)
7201 {
7202 // a bit special, as this uses AgentID to store the source instead
7203 // of the destination. The destination (the receiver) goes into destID
7204 OfferCallingCardPacket p = (OfferCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.OfferCallingCard);
7205 p.AgentData.AgentID = srcID;
7206 p.AgentData.SessionID = UUID.Zero;
7207 p.AgentBlock.DestID = AgentId;
7208 p.AgentBlock.TransactionID = transactionID;
7209 OutPacket(p, ThrottleOutPacketType.Task);
7210 }
7211
7212 public void SendAcceptCallingCard(UUID transactionID)
7213 {
7214 AcceptCallingCardPacket p = (AcceptCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.AcceptCallingCard);
7215 p.AgentData.AgentID = AgentId;
7216 p.AgentData.SessionID = UUID.Zero;
7217 p.FolderData = new AcceptCallingCardPacket.FolderDataBlock[1];
7218 p.FolderData[0] = new AcceptCallingCardPacket.FolderDataBlock();
7219 p.FolderData[0].FolderID = UUID.Zero;
7220 OutPacket(p, ThrottleOutPacketType.Task);
7221 }
7222
7223 public void SendDeclineCallingCard(UUID transactionID)
7224 {
7225 DeclineCallingCardPacket p = (DeclineCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.DeclineCallingCard);
7226 p.AgentData.AgentID = AgentId;
7227 p.AgentData.SessionID = UUID.Zero;
7228 p.TransactionBlock.TransactionID = transactionID;
7229 OutPacket(p, ThrottleOutPacketType.Task);
7230 }
7231
7164 public void KillEndDone() 7232 public void KillEndDone()
7165 { 7233 {
7166 KillPacket kp = new KillPacket(); 7234 KillPacket kp = new KillPacket();
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}
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
index af60323..5e7523f 100644
--- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
@@ -229,6 +229,10 @@ namespace OpenSim.Region.Examples.SimpleModule
229 229
230 public event MapItemRequest OnMapItemRequest; 230 public event MapItemRequest OnMapItemRequest;
231 231
232 public event OfferCallingCard OnOfferCallingCard;
233 public event AcceptCallingCard OnAcceptCallingCard;
234 public event DeclineCallingCard OnDeclineCallingCard;
235
232 236
233#pragma warning restore 67 237#pragma warning restore 67
234 238
@@ -938,5 +942,17 @@ namespace OpenSim.Region.Examples.SimpleModule
938 public void SendEventInfoReply (EventData info) 942 public void SendEventInfoReply (EventData info)
939 { 943 {
940 } 944 }
945
946 public void SendOfferCallingCard (UUID destID, UUID transactionID)
947 {
948 }
949
950 public void SendAcceptCallingCard (UUID transactionID)
951 {
952 }
953
954 public void SendDeclineCallingCard (UUID transactionID)
955 {
956 }
941 } 957 }
942} 958}