aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorMelanie2012-03-29 00:27:35 +0100
committerMelanie2012-03-29 00:27:35 +0100
commit7dad1ded2e969d50dd7a1bce9a219fb8ba6c760f (patch)
treeb09be52d5e7838b7c187c92f08f6c2bc73741a42 /OpenSim/Region/CoreModules
parentMerge branch 'master' into careminster (diff)
parentAdd comment about setting client.SceneAgent in AddNewClient() (diff)
downloadopensim-SC_OLD-7dad1ded2e969d50dd7a1bce9a219fb8ba6c760f.zip
opensim-SC_OLD-7dad1ded2e969d50dd7a1bce9a219fb8ba6c760f.tar.gz
opensim-SC_OLD-7dad1ded2e969d50dd7a1bce9a219fb8ba6c760f.tar.bz2
opensim-SC_OLD-7dad1ded2e969d50dd7a1bce9a219fb8ba6c760f.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs66
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs6
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs69
3 files changed, 85 insertions, 56 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 8e32fcc..4cc0e19 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -57,7 +57,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
57 { 57 {
58 public UUID PrincipalID; 58 public UUID PrincipalID;
59 public FriendInfo[] Friends; 59 public FriendInfo[] Friends;
60 public int Refcount;
61 60
62 public bool IsFriend(string friend) 61 public bool IsFriend(string friend)
63 { 62 {
@@ -255,6 +254,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
255 254
256 private void OnNewClient(IClientAPI client) 255 private void OnNewClient(IClientAPI client)
257 { 256 {
257 if (client.SceneAgent.IsChildAgent)
258 return;
259
258 client.OnInstantMessage += OnInstantMessage; 260 client.OnInstantMessage += OnInstantMessage;
259 client.OnApproveFriendRequest += OnApproveFriendRequest; 261 client.OnApproveFriendRequest += OnApproveFriendRequest;
260 client.OnDenyFriendRequest += OnDenyFriendRequest; 262 client.OnDenyFriendRequest += OnDenyFriendRequest;
@@ -281,23 +283,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
281 UUID agentID = client.AgentId; 283 UUID agentID = client.AgentId;
282 lock (m_Friends) 284 lock (m_Friends)
283 { 285 {
284 UserFriendData friendsData; 286 UserFriendData friendsData = new UserFriendData();
285 if (m_Friends.TryGetValue(agentID, out friendsData)) 287 friendsData.PrincipalID = agentID;
286 { 288 friendsData.Friends = GetFriendsFromService(client);
287 friendsData.Refcount++;
288 return false;
289 }
290 else
291 {
292 friendsData = new UserFriendData();
293 friendsData.PrincipalID = agentID;
294 friendsData.Friends = GetFriendsFromService(client);
295 friendsData.Refcount = 1;
296 289
297 m_Friends[agentID] = friendsData; 290 m_Friends[agentID] = friendsData;
298 return true;
299 }
300 } 291 }
292
293 return true;
301 } 294 }
302 295
303 private void OnClientClosed(UUID agentID, Scene scene) 296 private void OnClientClosed(UUID agentID, Scene scene)
@@ -307,23 +300,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
307 { 300 {
308 // do this for root agents closing out 301 // do this for root agents closing out
309 StatusChange(agentID, false); 302 StatusChange(agentID, false);
310 }
311 303
312 lock (m_Friends) 304 lock (m_Friends)
313 { 305 m_Friends.Remove(agentID);
314 UserFriendData friendsData;
315 if (m_Friends.TryGetValue(agentID, out friendsData))
316 {
317 friendsData.Refcount--;
318 if (friendsData.Refcount <= 0)
319 m_Friends.Remove(agentID);
320 }
321 } 306 }
322 } 307 }
323 308
324 private void OnMakeRootAgent(ScenePresence sp) 309 private void OnMakeRootAgent(ScenePresence sp)
325 { 310 {
326 RecacheFriends(sp.ControllingClient); 311 // FIXME: Ideally, we want to avoid doing this here since it sits the EventManager.OnMakeRootAgent event
312 // is on the critical path for transferring an avatar from one region to another.
313 CacheFriends(sp.ControllingClient);
327 } 314 }
328 315
329 private void OnClientLogin(IClientAPI client) 316 private void OnClientLogin(IClientAPI client)
@@ -628,8 +615,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
628 ccm.CreateCallingCard(client.AgentId, friendID, UUID.Zero); 615 ccm.CreateCallingCard(client.AgentId, friendID, UUID.Zero);
629 } 616 }
630 617
631 // Update the local cache 618 // Update the local cache.
632 RecacheFriends(client); 619 CacheFriends(client);
633 620
634 // 621 //
635 // Notify the friend 622 // Notify the friend
@@ -691,7 +678,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
691 client.SendAlertMessage("Unable to terminate friendship on this sim."); 678 client.SendAlertMessage("Unable to terminate friendship on this sim.");
692 679
693 // Update local cache 680 // Update local cache
694 RecacheFriends(client); 681 CacheFriends(client);
695 682
696 client.SendTerminateFriend(exfriendID); 683 client.SendTerminateFriend(exfriendID);
697 684
@@ -812,7 +799,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
812 799
813 800
814 // Update the local cache 801 // Update the local cache
815 RecacheFriends(friendClient); 802 CacheFriends(friendClient);
816 803
817 // we're done 804 // we're done
818 return true; 805 return true;
@@ -845,7 +832,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
845 // the friend in this sim as root agent 832 // the friend in this sim as root agent
846 friendClient.SendTerminateFriend(exfriendID); 833 friendClient.SendTerminateFriend(exfriendID);
847 // update local cache 834 // update local cache
848 RecacheFriends(friendClient); 835 CacheFriends(friendClient);
849 // we're done 836 // we're done
850 return true; 837 return true;
851 } 838 }
@@ -946,19 +933,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
946 return FriendsService.GetFriends(client.AgentId); 933 return FriendsService.GetFriends(client.AgentId);
947 } 934 }
948 935
949 protected void RecacheFriends(IClientAPI client)
950 {
951 // FIXME: Ideally, we want to avoid doing this here since it sits the EventManager.OnMakeRootAgent event
952 // is on the critical path for transferring an avatar from one region to another.
953 UUID agentID = client.AgentId;
954 lock (m_Friends)
955 {
956 UserFriendData friendsData;
957 if (m_Friends.TryGetValue(agentID, out friendsData))
958 friendsData.Friends = GetFriendsFromService(client);
959 }
960 }
961
962 /// <summary> 936 /// <summary>
963 /// Are friends cached on this simulator for a particular user? 937 /// Are friends cached on this simulator for a particular user?
964 /// </summary> 938 /// </summary>
@@ -1052,4 +1026,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
1052 } 1026 }
1053 } 1027 }
1054 } 1028 }
1055} \ No newline at end of file 1029}
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
index e50a84a..7bc3018 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
@@ -121,7 +121,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
121 { 121 {
122 UUID agentID = client.AgentId; 122 UUID agentID = client.AgentId;
123 // we do this only for the root agent 123 // we do this only for the root agent
124 if (m_Friends[agentID].Refcount == 1) 124 if (!client.SceneAgent.IsChildAgent)
125 { 125 {
126 // We need to preload the user management cache with the names 126 // We need to preload the user management cache with the names
127 // of foreign friends, just like we do with SOPs' creators 127 // of foreign friends, just like we do with SOPs' creators
@@ -426,14 +426,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
426 agentClientCircuit = ((Scene)(agentClient.Scene)).AuthenticateHandler.GetAgentCircuitData(agentClient.CircuitCode); 426 agentClientCircuit = ((Scene)(agentClient.Scene)).AuthenticateHandler.GetAgentCircuitData(agentClient.CircuitCode);
427 agentUUI = Util.ProduceUserUniversalIdentifier(agentClientCircuit); 427 agentUUI = Util.ProduceUserUniversalIdentifier(agentClientCircuit);
428 agentFriendService = agentClientCircuit.ServiceURLs["FriendsServerURI"].ToString(); 428 agentFriendService = agentClientCircuit.ServiceURLs["FriendsServerURI"].ToString();
429 RecacheFriends(agentClient); 429 CacheFriends(agentClient);
430 } 430 }
431 if (friendClient != null) 431 if (friendClient != null)
432 { 432 {
433 friendClientCircuit = ((Scene)(friendClient.Scene)).AuthenticateHandler.GetAgentCircuitData(friendClient.CircuitCode); 433 friendClientCircuit = ((Scene)(friendClient.Scene)).AuthenticateHandler.GetAgentCircuitData(friendClient.CircuitCode);
434 friendUUI = Util.ProduceUserUniversalIdentifier(friendClientCircuit); 434 friendUUI = Util.ProduceUserUniversalIdentifier(friendClientCircuit);
435 friendFriendService = friendClientCircuit.ServiceURLs["FriendsServerURI"].ToString(); 435 friendFriendService = friendClientCircuit.ServiceURLs["FriendsServerURI"].ToString();
436 RecacheFriends(friendClient); 436 CacheFriends(friendClient);
437 } 437 }
438 438
439 m_log.DebugFormat("[HGFRIENDS MODULE] HG Friendship! thisUUI={0}; friendUUI={1}; foreignThisFriendService={2}; foreignFriendFriendService={3}", 439 m_log.DebugFormat("[HGFRIENDS MODULE] HG Friendship! thisUUI={0}; friendUUI={1}; foreignThisFriendService={2}; foreignFriendFriendService={3}",
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index aaba7fd..6fc8e4d 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -71,7 +71,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
71 if (name == Name) 71 if (name == Name)
72 { 72 {
73 InitialiseCommon(source); 73 InitialiseCommon(source);
74 IConfig transferConfig = source.Configs["HGEntityTransfer"]; 74 IConfig transferConfig = source.Configs["HGEntityTransferModule"];
75 if (transferConfig != null) 75 if (transferConfig != null)
76 m_RestrictInventoryAccessAbroad = transferConfig.GetBoolean("RestrictInventoryAccessAbroad", false); 76 m_RestrictInventoryAccessAbroad = transferConfig.GetBoolean("RestrictInventoryAccessAbroad", false);
77 77
@@ -94,6 +94,31 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
94 client.OnTeleportHomeRequest += TriggerTeleportHome; 94 client.OnTeleportHomeRequest += TriggerTeleportHome;
95 client.OnTeleportLandmarkRequest += RequestTeleportLandmark; 95 client.OnTeleportLandmarkRequest += RequestTeleportLandmark;
96 client.OnConnectionClosed += new Action<IClientAPI>(OnConnectionClosed); 96 client.OnConnectionClosed += new Action<IClientAPI>(OnConnectionClosed);
97 client.OnCompleteMovementToRegion += new Action<IClientAPI, bool>(OnCompleteMovementToRegion);
98 }
99
100 protected void OnCompleteMovementToRegion(IClientAPI client, bool arg2)
101 {
102 // HACK HACK -- just seeing how the viewer responds
103 // Let's send the Suitcase or the real root folder folder for incoming HG agents
104 // Visiting agents get their suitcase contents; incoming local users get their real root folder's content
105 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: OnCompleteMovementToRegion of user {0}", client.AgentId);
106 object sp = null;
107 if (client.Scene.TryGetScenePresence(client.AgentId, out sp))
108 {
109 if (sp is ScenePresence)
110 {
111 AgentCircuitData aCircuit = ((ScenePresence)sp).Scene.AuthenticateHandler.GetAgentCircuitData(client.AgentId);
112 if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0)
113 {
114 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: ViaHGLogin");
115 if (m_RestrictInventoryAccessAbroad)
116 {
117 RestoreRootFolderContents(client);
118 }
119 }
120 }
121 }
97 } 122 }
98 123
99 124
@@ -105,6 +130,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
105 { 130 {
106 m_GatekeeperConnector = new GatekeeperServiceConnector(scene.AssetService); 131 m_GatekeeperConnector = new GatekeeperServiceConnector(scene.AssetService);
107 m_Initialized = true; 132 m_Initialized = true;
133
134 scene.AddCommand(
135 "HG", this, "send inventory",
136 "send inventory",
137 "Don't use this",
138 HandleSendInventory);
139
108 } 140 }
109 141
110 } 142 }
@@ -374,7 +406,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
374 InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId); 406 InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId);
375 if (root != null) 407 if (root != null)
376 { 408 {
377 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Removing root inventory"); 409 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Removing root inventory for user {0}", client.AgentId);
378 InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID); 410 InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID);
379 UUID[] ids = new UUID[content.Folders.Count]; 411 UUID[] ids = new UUID[content.Folders.Count];
380 int i = 0; 412 int i = 0;
@@ -393,12 +425,26 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
393 425
394 private void RestoreRootFolderContents(IClientAPI client) 426 private void RestoreRootFolderContents(IClientAPI client)
395 { 427 {
396 // Restore the user's inventory, because we removed it earlier on 428 if (client is IClientCore)
397 InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId);
398 if (root != null)
399 { 429 {
400 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Restoring root inventory"); 430 IClientCore core = (IClientCore)client;
401 client.SendBulkUpdateInventory(root); 431 IClientInventory inv;
432
433 if (core.TryGet<IClientInventory>(out inv))
434 {
435 InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId);
436 client.SendBulkUpdateInventory(root);
437 //if (root != null)
438 //{
439 // m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Restoring root inventory for user {0}", client.AgentId);
440 // InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID);
441 // m_log.DebugFormat("[XXX]: Folder name {0}, id {1}, parent {2}", root.Name, root.ID, root.ParentID);
442 // foreach (InventoryItemBase i in content.Items)
443 // m_log.DebugFormat("[XXX]: Name={0}, folderID={1}", i.Name, i.Folder);
444
445 // inv.SendBulkUpdateInventory(content.Folders.ToArray(), content.Items.ToArray());
446 //}
447 }
402 } 448 }
403 } 449 }
404 450
@@ -418,5 +464,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
418 region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), (int)0); 464 region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), (int)0);
419 return region; 465 return region;
420 } 466 }
467
468 protected void HandleSendInventory(string module, string[] cmd)
469 {
470 m_Scenes[0].ForEachClient(delegate(IClientAPI client)
471 {
472 RestoreRootFolderContents(client);
473 });
474 }
475
421 } 476 }
422} 477}