aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorDiva Canto2010-06-04 10:59:59 -0700
committerDiva Canto2010-06-04 10:59:59 -0700
commit952029380a6a038e382dd3b2c312b3e16ff08625 (patch)
tree400586c159859d0ff437685d4c37179e8cba89f1 /OpenSim/Region
parentMerge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff)
downloadopensim-SC_OLD-952029380a6a038e382dd3b2c312b3e16ff08625.zip
opensim-SC_OLD-952029380a6a038e382dd3b2c312b3e16ff08625.tar.gz
opensim-SC_OLD-952029380a6a038e382dd3b2c312b3e16ff08625.tar.bz2
opensim-SC_OLD-952029380a6a038e382dd3b2c312b3e16ff08625.tar.xz
Fixed a couple of buglets in Friendship offers / acceptance / decline when avies are in different sims.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs56
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs13
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs4
3 files changed, 44 insertions, 29 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 0c81f44..0050653 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -111,10 +111,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
111 111
112 protected IGridService GridService 112 protected IGridService GridService
113 { 113 {
114 get 114 get { return m_Scenes[0].GridService; }
115 { 115 }
116 return m_Scenes[0].GridService; 116
117 } 117 public IUserAccountService UserAccountService
118 {
119 get { return m_Scenes[0].UserAccountService; }
118 } 120 }
119 121
120 public IScene Scene 122 public IScene Scene
@@ -220,33 +222,37 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
220 222
221 client.OnLogout += OnLogout; 223 client.OnLogout += OnLogout;
222 224
223 if (m_Friends.ContainsKey(client.AgentId)) 225 lock (m_Friends)
224 { 226 {
225 m_Friends[client.AgentId].Refcount++; 227 if (m_Friends.ContainsKey(client.AgentId))
226 return; 228 {
227 } 229 m_Friends[client.AgentId].Refcount++;
230 return;
231 }
228 232
229 UserFriendData newFriends = new UserFriendData(); 233 UserFriendData newFriends = new UserFriendData();
230 234
231 newFriends.PrincipalID = client.AgentId; 235 newFriends.PrincipalID = client.AgentId;
232 newFriends.Friends = m_FriendsService.GetFriends(client.AgentId); 236 newFriends.Friends = m_FriendsService.GetFriends(client.AgentId);
233 newFriends.Refcount = 1; 237 newFriends.Refcount = 1;
234 newFriends.RegionID = UUID.Zero; 238 newFriends.RegionID = UUID.Zero;
235 239
236 m_Friends.Add(client.AgentId, newFriends); 240 m_Friends.Add(client.AgentId, newFriends);
241 }
237 242
238 //StatusChange(client.AgentId, true); 243 //StatusChange(client.AgentId, true);
239 } 244 }
240 245
241 private void OnClientClosed(UUID agentID, Scene scene) 246 private void OnClientClosed(UUID agentID, Scene scene)
242 { 247 {
243 if (m_Friends.ContainsKey(agentID)) 248 lock (m_Friends)
244 { 249 if (m_Friends.ContainsKey(agentID))
245 if (m_Friends[agentID].Refcount == 1) 250 {
246 m_Friends.Remove(agentID); 251 if (m_Friends[agentID].Refcount == 1)
247 else 252 m_Friends.Remove(agentID);
248 m_Friends[agentID].Refcount--; 253 else
249 } 254 m_Friends[agentID].Refcount--;
255 }
250 } 256 }
251 257
252 private void OnLogout(IClientAPI client) 258 private void OnLogout(IClientAPI client)
@@ -518,12 +524,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
518 524
519 private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders) 525 private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders)
520 { 526 {
527 m_log.DebugFormat("[FRIENDS]: {0} accepted friendship from {1}", agentID, friendID);
528
521 FriendsService.StoreFriend(agentID, friendID.ToString(), 1); 529 FriendsService.StoreFriend(agentID, friendID.ToString(), 1);
522 FriendsService.StoreFriend(friendID, agentID.ToString(), 1); 530 FriendsService.StoreFriend(friendID, agentID.ToString(), 1);
523 // update the local cache 531 // update the local cache
524 m_Friends[agentID].Friends = FriendsService.GetFriends(agentID); 532 m_Friends[agentID].Friends = FriendsService.GetFriends(agentID);
525 533
526 m_log.DebugFormat("[FRIENDS]: {0} accepted friendship from {1}", agentID, friendID);
527 534
528 // 535 //
529 // Notify the friend 536 // Notify the friend
@@ -572,7 +579,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
572 if (friendSession != null) 579 if (friendSession != null)
573 { 580 {
574 GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); 581 GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
575 m_FriendsSimConnector.FriendshipDenied(region, agentID, client.Name, friendID); 582 if (region != null)
583 m_FriendsSimConnector.FriendshipDenied(region, agentID, client.Name, friendID);
584 else
585 m_log.WarnFormat("[FRIENDS]: Could not find region {0} in locating {1}", friendSession.RegionID, friendID);
576 } 586 }
577 } 587 }
578 } 588 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs
index 0883c5b..496f2ab 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs
@@ -35,6 +35,7 @@ using OpenSim.Framework;
35using OpenSim.Server.Base; 35using OpenSim.Server.Base;
36using OpenSim.Framework.Servers.HttpServer; 36using OpenSim.Framework.Servers.HttpServer;
37using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; 37using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
38using OpenSim.Services.Interfaces;
38 39
39using OpenMetaverse; 40using OpenMetaverse;
40using log4net; 41using log4net;
@@ -61,7 +62,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
61 sr.Close(); 62 sr.Close();
62 body = body.Trim(); 63 body = body.Trim();
63 64
64 m_log.DebugFormat("[XXX]: query String: {0}", body); 65 //m_log.DebugFormat("[XXX]: query String: {0}", body);
65 66
66 try 67 try
67 { 68 {
@@ -115,9 +116,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
115 if (!UUID.TryParse(request["ToID"].ToString(), out toID)) 116 if (!UUID.TryParse(request["ToID"].ToString(), out toID))
116 return FailureResult(); 117 return FailureResult();
117 118
118 GridInstantMessage im = new GridInstantMessage(m_FriendsModule.Scene, fromID, "", toID, 119 UserAccount account = m_FriendsModule.UserAccountService.GetUserAccount(m_FriendsModule.Scene.RegionInfo.ScopeID, fromID);
120 string name = (account == null) ? "Unknown" : account.FirstName + " " + account.LastName;
121
122 GridInstantMessage im = new GridInstantMessage(m_FriendsModule.Scene, fromID, name, toID,
119 (byte)InstantMessageDialog.FriendshipOffered, message, false, Vector3.Zero); 123 (byte)InstantMessageDialog.FriendshipOffered, message, false, Vector3.Zero);
120 124
125 // !! HACK
126 im.imSessionID = im.fromAgentID;
127
121 if (m_FriendsModule.LocalFriendshipOffered(toID, im)) 128 if (m_FriendsModule.LocalFriendshipOffered(toID, im))
122 return SuccessResult(); 129 return SuccessResult();
123 130
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs
index a355661..e1bc243 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs
@@ -44,10 +44,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
44 44
45 public UserAccountCache() 45 public UserAccountCache()
46 { 46 {
47 // Warning: the size values are a bit fuzzy. What matters
48 // most for this cache is the count value (128 entries).
49 m_UUIDCache = new ExpiringCache<UUID, UserAccount>(); 47 m_UUIDCache = new ExpiringCache<UUID, UserAccount>();
50 m_NameCache = new ExpiringCache<string, UUID>(); // this one is unbound 48 m_NameCache = new ExpiringCache<string, UUID>();
51 } 49 }
52 50
53 public void Cache(UUID userID, UserAccount account) 51 public void Cache(UUID userID, UserAccount account)