aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/IClientAPI.cs2
-rw-r--r--OpenSim/Framework/LandData.cs2
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs4
-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
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs16
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs4
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs2
-rw-r--r--OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs368
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs2
13 files changed, 467 insertions, 81 deletions
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index 004b1a6..881f815 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -717,7 +717,7 @@ namespace OpenSim.Framework
717 /// The scene agent for this client. This will only be set if the client has an agent in a scene (i.e. if it 717 /// The scene agent for this client. This will only be set if the client has an agent in a scene (i.e. if it
718 /// is connected). 718 /// is connected).
719 /// </summary> 719 /// </summary>
720 ISceneAgent SceneAgent { get; } 720 ISceneAgent SceneAgent { get; set; }
721 721
722 UUID SessionId { get; } 722 UUID SessionId { get; }
723 723
diff --git a/OpenSim/Framework/LandData.cs b/OpenSim/Framework/LandData.cs
index 9a9a6bf..dcaa46d 100644
--- a/OpenSim/Framework/LandData.cs
+++ b/OpenSim/Framework/LandData.cs
@@ -69,7 +69,7 @@ namespace OpenSim.Framework
69 (uint) ParcelFlags.AllowAPrimitiveEntry | 69 (uint) ParcelFlags.AllowAPrimitiveEntry |
70 (uint) ParcelFlags.AllowDeedToGroup | 70 (uint) ParcelFlags.AllowDeedToGroup |
71 (uint) ParcelFlags.CreateObjects | (uint) ParcelFlags.AllowOtherScripts | 71 (uint) ParcelFlags.CreateObjects | (uint) ParcelFlags.AllowOtherScripts |
72 (uint) ParcelFlags.SoundLocal; 72 (uint) ParcelFlags.SoundLocal | (uint) ParcelFlags.AllowVoiceChat;
73 73
74 private byte _landingType = 0; 74 private byte _landingType = 0;
75 private string _name = "Your Parcel"; 75 private string _name = "Your Parcel";
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index d0920d2..54fc7f4 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -396,7 +396,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
396 } 396 }
397 } 397 }
398 public UUID AgentId { get { return m_agentId; } } 398 public UUID AgentId { get { return m_agentId; } }
399 public ISceneAgent SceneAgent { get; private set; } 399 public ISceneAgent SceneAgent { get; set; }
400 public UUID ActiveGroupId { get { return m_activeGroupID; } } 400 public UUID ActiveGroupId { get { return m_activeGroupID; } }
401 public string ActiveGroupName { get { return m_activeGroupName; } } 401 public string ActiveGroupName { get { return m_activeGroupName; } }
402 public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } } 402 public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } }
@@ -719,7 +719,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
719 719
720 public virtual void Start() 720 public virtual void Start()
721 { 721 {
722 SceneAgent = m_scene.AddNewClient(this, PresenceType.User); 722 m_scene.AddNewClient(this, PresenceType.User);
723 723
724 RefreshGroupMembership(); 724 RefreshGroupMembership();
725 } 725 }
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}
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 470ce2e..741d233 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -75,6 +75,7 @@ namespace OpenSim.Region.Framework.Scenes
75 /// Triggered when a new client is added to the scene. 75 /// Triggered when a new client is added to the scene.
76 /// </summary> 76 /// </summary>
77 /// <remarks> 77 /// <remarks>
78 /// This is triggered for both child and root agent client connections.
78 /// Triggered before OnClientLogin. 79 /// Triggered before OnClientLogin.
79 /// </remarks> 80 /// </remarks>
80 public event OnNewClientDelegate OnNewClient; 81 public event OnNewClientDelegate OnNewClient;
@@ -195,7 +196,7 @@ namespace OpenSim.Region.Framework.Scenes
195 public delegate void ClientClosed(UUID clientID, Scene scene); 196 public delegate void ClientClosed(UUID clientID, Scene scene);
196 197
197 /// <summary> 198 /// <summary>
198 /// Fired when a client is removed from a scene. 199 /// Fired when a client is removed from a scene whether it's a child or a root agent.
199 /// </summary> 200 /// </summary>
200 /// <remarks> 201 /// <remarks>
201 /// At the point of firing, the scene still contains the client's scene presence. 202 /// At the point of firing, the scene still contains the client's scene presence.
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index cac178d..cf3270d 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2795,6 +2795,10 @@ namespace OpenSim.Region.Framework.Scenes
2795 sp.IsChildAgent ? "child" : "root", sp.Name, RegionInfo.RegionName); 2795 sp.IsChildAgent ? "child" : "root", sp.Name, RegionInfo.RegionName);
2796 } 2796 }
2797 2797
2798 // We must set this here so that TriggerOnNewClient and TriggerOnClientLogin can determine whether the
2799 // client is for a root or child agent.
2800 client.SceneAgent = sp;
2801
2798 m_LastLogin = Util.EnvironmentTickCount(); 2802 m_LastLogin = Util.EnvironmentTickCount();
2799 2803
2800 // Cache the user's name 2804 // Cache the user's name
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index ee8a236..ed3a7f1 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1237,22 +1237,6 @@ namespace OpenSim.Region.Framework.Scenes
1237 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); 1237 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
1238 } 1238 }
1239 1239
1240 // HACK HACK -- just seeing how the viewer responds
1241 // Let's send the Suitcase or the real root folder folder for incoming HG agents
1242 // Visiting agents get their suitcase contents; incoming local users get their real root folder's content
1243 AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(UUID);
1244 if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0)
1245 {
1246 // HACK FOR NOW. JUST TESTING, SO KEEPING EVERYONE ELSE OUT OF THESE TESTS
1247 IConfig config = m_scene.Config.Configs["HGEntityTransferModule"];
1248 if (config != null && config.GetBoolean("RestrictInventoryAccessAbroad", false))
1249 {
1250 m_log.DebugFormat("[SCENE]: Sending root folder to viewer...");
1251 InventoryFolderBase root = m_scene.InventoryService.GetRootFolder(client.AgentId);
1252 //InventoryCollection rootContents = InventoryService.GetFolderContent(client.AgentId, root.ID);
1253 client.SendBulkUpdateInventory(root);
1254 }
1255 }
1256 1240
1257// m_log.DebugFormat( 1241// m_log.DebugFormat(
1258// "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms", 1242// "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms",
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index 655f3a5..a37e997 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -55,7 +55,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
55 55
56 private UUID m_agentID = UUID.Random(); 56 private UUID m_agentID = UUID.Random();
57 57
58 public ISceneAgent SceneAgent { get; private set; } 58 public ISceneAgent SceneAgent { get; set; }
59 59
60 private string m_username; 60 private string m_username;
61 private string m_nick; 61 private string m_nick;
@@ -903,7 +903,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
903 903
904 public void Start() 904 public void Start()
905 { 905 {
906 SceneAgent = m_scene.AddNewClient(this, PresenceType.User); 906 m_scene.AddNewClient(this, PresenceType.User);
907 907
908 // Mimicking LLClientView which gets always set appearance from client. 908 // Mimicking LLClientView which gets always set appearance from client.
909 AvatarAppearance appearance; 909 AvatarAppearance appearance;
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index a2375fe..c3335f0 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -72,7 +72,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
72 get { return m_ownerID; } 72 get { return m_ownerID; }
73 } 73 }
74 74
75 public ISceneAgent SceneAgent { get { throw new NotImplementedException(); } } 75 public ISceneAgent SceneAgent { get; set; }
76 76
77 public void Say(string message) 77 public void Say(string message)
78 { 78 {
diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
new file mode 100644
index 0000000..a999886
--- /dev/null
+++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
@@ -0,0 +1,368 @@
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
28using System;
29using System.Collections.Generic;
30using OpenMetaverse;
31using log4net;
32using Nini.Config;
33using System.Reflection;
34using OpenSim.Services.Base;
35using OpenSim.Services.Interfaces;
36using OpenSim.Services.InventoryService;
37using OpenSim.Data;
38using OpenSim.Framework;
39using OpenSim.Server.Base;
40
41namespace OpenSim.Services.HypergridService
42{
43 /// <summary>
44 /// Hypergrid inventory service. It serves the IInventoryService interface,
45 /// but implements it in ways that are appropriate for inter-grid
46 /// inventory exchanges. Specifically, it does not performs deletions
47 /// and it responds to GetRootFolder requests with the ID of the
48 /// Suitcase folder, not the actual "My Inventory" folder.
49 /// </summary>
50 public class HGSuitcaseInventoryService : XInventoryService, IInventoryService
51 {
52 private static readonly ILog m_log =
53 LogManager.GetLogger(
54 MethodBase.GetCurrentMethod().DeclaringType);
55
56 private string m_HomeURL;
57 private IUserAccountService m_UserAccountService;
58
59 private UserAccountCache m_Cache;
60
61 public HGSuitcaseInventoryService(IConfigSource config, string configName)
62 : base(config, configName)
63 {
64 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Starting with config name {0}", configName);
65 if (configName != string.Empty)
66 m_ConfigName = configName;
67
68 if (m_Database == null)
69 m_log.WarnFormat("[XXX]: m_Database is null!");
70
71 //
72 // Try reading the [InventoryService] section, if it exists
73 //
74 IConfig invConfig = config.Configs[m_ConfigName];
75 if (invConfig != null)
76 {
77 // realm = authConfig.GetString("Realm", realm);
78 string userAccountsDll = invConfig.GetString("UserAccountsService", string.Empty);
79 if (userAccountsDll == string.Empty)
80 throw new Exception("Please specify UserAccountsService in HGInventoryService configuration");
81
82 Object[] args = new Object[] { config };
83 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountsDll, args);
84 if (m_UserAccountService == null)
85 throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll));
86
87 // legacy configuration [obsolete]
88 m_HomeURL = invConfig.GetString("ProfileServerURI", string.Empty);
89 // Preferred
90 m_HomeURL = invConfig.GetString("HomeURI", m_HomeURL);
91
92 m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
93 }
94
95 m_log.Debug("[HG SUITCASE INVENTORY SERVICE]: Starting...");
96 }
97
98 public override bool CreateUserInventory(UUID principalID)
99 {
100 // NOGO
101 return false;
102 }
103
104
105 public override List<InventoryFolderBase> GetInventorySkeleton(UUID principalID)
106 {
107 // NOGO for this inventory service
108 return new List<InventoryFolderBase>();
109 }
110
111 public override InventoryFolderBase GetRootFolder(UUID principalID)
112 {
113 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetRootFolder for {0}", principalID);
114 if (m_Database == null)
115 m_log.ErrorFormat("[XXX]: m_Database is NULL!");
116
117 // Let's find out the local root folder
118 XInventoryFolder root = GetRootXFolder(principalID); ;
119 if (root == null)
120 {
121 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve local root folder for user {0}", principalID);
122 }
123
124 // Warp! Root folder for travelers is the suitcase folder
125 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID);
126
127 if (suitcase == null)
128 {
129 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder. Creating it...", principalID);
130 // make one, and let's add it to the user's inventory as a direct child of the root folder
131 suitcase = CreateFolder(principalID, root.folderID, 100, "My Suitcase");
132 if (suitcase == null)
133 m_log.ErrorFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to create suitcase folder");
134
135 m_Database.StoreFolder(suitcase);
136 }
137
138 // Now let's change the folder ID to match that of the real root folder
139 SetAsRootFolder(suitcase, root.folderID);
140
141 return ConvertToOpenSim(suitcase);
142 }
143
144 public override InventoryFolderBase GetFolderForType(UUID principalID, AssetType type)
145 {
146 //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetFolderForType for {0} {0}", principalID, type);
147 return GetRootFolder(principalID);
148 }
149
150 //
151 // Use the inherited methods
152 //
153 public override InventoryCollection GetFolderContent(UUID principalID, UUID folderID)
154 {
155 InventoryCollection coll = null;
156 XInventoryFolder root = GetRootXFolder(principalID);
157 if (folderID == root.folderID) // someone's asking for the root folder, we'll give them the suitcase
158 {
159 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID);
160 if (suitcase != null)
161 {
162 coll = base.GetFolderContent(principalID, suitcase.folderID);
163 foreach (InventoryFolderBase f in coll.Folders)
164 f.ParentID = root.folderID;
165 foreach (InventoryItemBase i in coll.Items)
166 i.Folder = root.folderID;
167 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolderContent for root folder returned content for suitcase folder");
168 }
169 }
170 else
171 {
172 coll = base.GetFolderContent(principalID, folderID);
173 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolderContent for non-root folder {0}", folderID);
174 }
175 if (coll == null)
176 {
177 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Something wrong with user {0}'s suitcase folder", principalID);
178 coll = new InventoryCollection();
179 }
180 return coll;
181 }
182
183 //public List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID)
184 //{
185 //}
186
187 //public override bool AddFolder(InventoryFolderBase folder)
188 //{
189 // // Check if it's under the Suitcase folder
190 // List<InventoryFolderBase> skel = base.GetInventorySkeleton(folder.Owner);
191 // InventoryFolderBase suitcase = GetRootFolder(folder.Owner);
192 // List<InventoryFolderBase> suitDescendents = GetDescendents(skel, suitcase.ID);
193
194 // foreach (InventoryFolderBase f in suitDescendents)
195 // if (folder.ParentID == f.ID)
196 // {
197 // XInventoryFolder xFolder = ConvertFromOpenSim(folder);
198 // return m_Database.StoreFolder(xFolder);
199 // }
200 // return false;
201 //}
202
203 private List<InventoryFolderBase> GetDescendents(List<InventoryFolderBase> lst, UUID root)
204 {
205 List<InventoryFolderBase> direct = lst.FindAll(delegate(InventoryFolderBase f) { return f.ParentID == root; });
206 if (direct == null)
207 return new List<InventoryFolderBase>();
208
209 List<InventoryFolderBase> indirect = new List<InventoryFolderBase>();
210 foreach (InventoryFolderBase f in direct)
211 indirect.AddRange(GetDescendents(lst, f.ID));
212
213 direct.AddRange(indirect);
214 return direct;
215 }
216
217 // Use inherited method
218 //public bool UpdateFolder(InventoryFolderBase folder)
219 //{
220 //}
221
222 //public override bool MoveFolder(InventoryFolderBase folder)
223 //{
224 // XInventoryFolder[] x = m_Database.GetFolders(
225 // new string[] { "folderID" },
226 // new string[] { folder.ID.ToString() });
227
228 // if (x.Length == 0)
229 // return false;
230
231 // // Check if it's under the Suitcase folder
232 // List<InventoryFolderBase> skel = base.GetInventorySkeleton(folder.Owner);
233 // InventoryFolderBase suitcase = GetRootFolder(folder.Owner);
234 // List<InventoryFolderBase> suitDescendents = GetDescendents(skel, suitcase.ID);
235
236 // foreach (InventoryFolderBase f in suitDescendents)
237 // if (folder.ParentID == f.ID)
238 // {
239 // x[0].parentFolderID = folder.ParentID;
240 // return m_Database.StoreFolder(x[0]);
241 // }
242
243 // return false;
244 //}
245
246 public override bool DeleteFolders(UUID principalID, List<UUID> folderIDs)
247 {
248 // NOGO
249 return false;
250 }
251
252 public override bool PurgeFolder(InventoryFolderBase folder)
253 {
254 // NOGO
255 return false;
256 }
257
258 // Unfortunately we need to use the inherited method because of how DeRez works.
259 // The viewer sends the folderID hard-wired in the derez message
260 //public override bool AddItem(InventoryItemBase item)
261 //{
262 // // Check if it's under the Suitcase folder
263 // List<InventoryFolderBase> skel = base.GetInventorySkeleton(item.Owner);
264 // InventoryFolderBase suitcase = GetRootFolder(item.Owner);
265 // List<InventoryFolderBase> suitDescendents = GetDescendents(skel, suitcase.ID);
266
267 // foreach (InventoryFolderBase f in suitDescendents)
268 // if (item.Folder == f.ID)
269 // return m_Database.StoreItem(ConvertFromOpenSim(item));
270
271 // return false;
272 //}
273
274 //public override bool UpdateItem(InventoryItemBase item)
275 //{
276 // // Check if it's under the Suitcase folder
277 // List<InventoryFolderBase> skel = base.GetInventorySkeleton(item.Owner);
278 // InventoryFolderBase suitcase = GetRootFolder(item.Owner);
279 // List<InventoryFolderBase> suitDescendents = GetDescendents(skel, suitcase.ID);
280
281 // foreach (InventoryFolderBase f in suitDescendents)
282 // if (item.Folder == f.ID)
283 // return m_Database.StoreItem(ConvertFromOpenSim(item));
284
285 // return false;
286 //}
287
288 //public override bool MoveItems(UUID principalID, List<InventoryItemBase> items)
289 //{
290 // // Principal is b0rked. *sigh*
291 // //
292 // // Let's assume they all have the same principal
293 // // Check if it's under the Suitcase folder
294 // List<InventoryFolderBase> skel = base.GetInventorySkeleton(items[0].Owner);
295 // InventoryFolderBase suitcase = GetRootFolder(items[0].Owner);
296 // List<InventoryFolderBase> suitDescendents = GetDescendents(skel, suitcase.ID);
297
298 // foreach (InventoryItemBase i in items)
299 // {
300 // foreach (InventoryFolderBase f in suitDescendents)
301 // if (i.Folder == f.ID)
302 // m_Database.MoveItem(i.ID.ToString(), i.Folder.ToString());
303 // }
304
305 // return true;
306 //}
307
308 // Let these pass. Use inherited methods.
309 //public bool DeleteItems(UUID principalID, List<UUID> itemIDs)
310 //{
311 //}
312
313 //public override InventoryItemBase GetItem(InventoryItemBase item)
314 //{
315 // InventoryItemBase it = base.GetItem(item);
316 // if (it != null)
317 // {
318 // UserAccount user = m_Cache.GetUser(it.CreatorId);
319
320 // // Adjust the creator data
321 // if (user != null && it != null && (it.CreatorData == null || it.CreatorData == string.Empty))
322 // it.CreatorData = m_HomeURL + ";" + user.FirstName + " " + user.LastName;
323 // }
324 // return it;
325 //}
326
327 //public InventoryFolderBase GetFolder(InventoryFolderBase folder)
328 //{
329 //}
330
331 //public List<InventoryItemBase> GetActiveGestures(UUID principalID)
332 //{
333 //}
334
335 //public int GetAssetPermissions(UUID principalID, UUID assetID)
336 //{
337 //}
338
339 private XInventoryFolder GetRootXFolder(UUID principalID)
340 {
341 XInventoryFolder[] folders = m_Database.GetFolders(
342 new string[] { "agentID", "folderName", "type" },
343 new string[] { principalID.ToString(), "My Inventory", ((int)AssetType.RootFolder).ToString() });
344
345 if (folders != null && folders.Length > 0)
346 return folders[0];
347 return null;
348 }
349
350 private XInventoryFolder GetSuitcaseXFolder(UUID principalID)
351 {
352 // Warp! Root folder for travelers
353 XInventoryFolder[] folders = m_Database.GetFolders(
354 new string[] { "agentID", "type" },
355 new string[] { principalID.ToString(), "100" }); // This is a special folder type...
356
357 if (folders != null && folders.Length > 0)
358 return folders[0];
359 return null;
360 }
361
362 private void SetAsRootFolder(XInventoryFolder suitcase, UUID rootID)
363 {
364 suitcase.folderID = rootID;
365 suitcase.parentFolderID = UUID.Zero;
366 }
367 }
368}
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index 81a5cf7..64dd1e4 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -329,7 +329,7 @@ namespace OpenSim.Tests.Common.Mock
329 /// </value> 329 /// </value>
330 private UUID m_agentId; 330 private UUID m_agentId;
331 331
332 public ISceneAgent SceneAgent { get { throw new NotImplementedException(); } } 332 public ISceneAgent SceneAgent { get; set; }
333 333
334 /// <value> 334 /// <value>
335 /// The last caps seed url that this client was given. 335 /// The last caps seed url that this client was given.