Merge branch 'master' into bigmerge

Conflicts:
	OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
avinationmerge
Melanie 2011-11-14 20:03:47 +00:00
commit afca742392
12 changed files with 159 additions and 23 deletions

View File

@ -56,13 +56,21 @@ namespace OpenSim.Data.Null
/// <returns></returns>
public FriendsData[] GetFriends(string userID)
{
List<FriendsData> lst = m_Data.FindAll(delegate (FriendsData fdata)
List<FriendsData> lst = m_Data.FindAll(fdata =>
{
return fdata.PrincipalID == userID.ToString();
});
if (lst != null)
{
lst.ForEach(f =>
{
FriendsData f2 = m_Data.Find(candidateF2 => f.Friend == candidateF2.PrincipalID);
if (f2 != null) { f.Data["TheirFlags"] = f2.Data["Flags"]; }
});
return lst.ToArray();
}
return new FriendsData[0];
}

View File

@ -11197,6 +11197,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
Utils.BytesToString(avatarInterestUpdate.PropertiesData.LanguagesText));
return true;
}
private bool HandleGrantUserRights(IClientAPI sender, Packet Pack)
{
GrantUserRightsPacket GrantUserRights =
@ -11217,6 +11218,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
GrantUserRights.Rights[0].RelatedRights);
return true;
}
private bool HandlePlacesQuery(IClientAPI sender, Packet Pack)
{
PlacesQueryPacket placesQueryPacket =

View File

@ -46,7 +46,6 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
// Fields
private bool m_dumpAssetsToFile;
private Scene m_Scene;
private UUID UserID;
private Dictionary<UUID, AssetXferUploader> XferUploaders = new Dictionary<UUID, AssetXferUploader>();
// Methods
@ -54,7 +53,6 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
bool dumpAssetsToFile)
{
m_Scene = scene;
UserID = agentID;
m_dumpAssetsToFile = dumpAssetsToFile;
}

View File

@ -165,6 +165,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
// Instantiate the request handler
IHttpServer server = MainServer.GetHttpServer((uint)mPort);
if (server != null)
server.AddStreamHandler(new FriendsRequestHandler(this));
}
@ -352,20 +354,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
continue;
}
PresenceInfo presence = null;
PresenceInfo[] presences = PresenceService.GetAgents(new string[] { fid });
if (presences != null && presences.Length > 0)
presence = presences[0];
if (presence != null)
im.offline = 0;
im.fromAgentID = fromAgentID.Guid;
im.fromAgentName = firstname + " " + lastname;
im.offline = (byte)((presence == null) ? 1 : 0);
im.imSessionID = im.fromAgentID;
im.message = FriendshipMessage(fid);
// Finally
LocalFriendshipOffered(agentID, im);
}
@ -576,9 +571,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders)
{
m_log.DebugFormat("[FRIENDS]: {0} accepted friendship from {1}", agentID, friendID);
m_log.DebugFormat("[FRIENDS]: {0} accepted friendship from {1}", client.AgentId, friendID);
StoreFriendships(agentID, friendID);
AddFriend(client, friendID);
}
public void AddFriend(IClientAPI client, UUID friendID)
{
StoreFriendships(client.AgentId, friendID);
ICallingCardModule ccm = client.Scene.RequestModuleInterface<ICallingCardModule>();
if (ccm != null)
@ -594,7 +594,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
//
// Try Local
if (LocalFriendshipApproved(agentID, client.Name, friendID))
if (LocalFriendshipApproved(client.AgentId, client.Name, friendID))
{
client.SendAgentOnline(new UUID[] { friendID });
return;
@ -608,7 +608,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
if (friendSession != null)
{
GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
m_FriendsSimConnector.FriendshipApproved(region, agentID, client.Name, friendID);
m_FriendsSimConnector.FriendshipApproved(region, client.AgentId, client.Name, friendID);
client.SendAgentOnline(new UUID[] { friendID });
}
}
@ -882,7 +882,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
}
/// <summary>
/// Update loca cache only
/// Update local cache only
/// </summary>
/// <param name="userID"></param>
/// <param name="friendID"></param>

View File

@ -141,7 +141,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
{
List<string> fList = new List<string>();
foreach (string s in friendList)
{
if (s.Length < 36)
m_log.WarnFormat(
"[HGFRIENDS MODULE]: Ignoring friend {0} ({1} chars) for {2} since identifier too short",
s, s.Length, userID);
else
fList.Add(s.Substring(0, 36));
}
PresenceInfo[] presence = PresenceService.GetAgents(fList.ToArray());
foreach (PresenceInfo pi in presence)

View File

@ -0,0 +1,97 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using Nini.Config;
using NUnit.Framework;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.CoreModules.Avatar.Friends;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests
{
[TestFixture]
public class FriendsModuleTests
{
private FriendsModule m_fm;
private TestScene m_scene;
[SetUp]
public void Init()
{
IConfigSource config = new IniConfigSource();
config.AddConfig("Modules");
// Not strictly necessary since FriendsModule assumes it is the default (!)
config.Configs["Modules"].Set("FriendsModule", "FriendsModule");
config.AddConfig("Friends");
config.Configs["Friends"].Set("Connector", "OpenSim.Services.FriendsService.dll");
config.AddConfig("FriendsService");
config.Configs["FriendsService"].Set("StorageProvider", "OpenSim.Data.Null.dll");
m_scene = SceneHelpers.SetupScene();
m_fm = new FriendsModule();
SceneHelpers.SetupSceneModules(m_scene, config, m_fm);
}
[Test]
public void TestNoFriends()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
UUID userId = TestHelpers.ParseTail(0x1);
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
Assert.That(((TestClient)sp.ControllingClient).OfflineNotificationsReceived.Count, Is.EqualTo(0));
Assert.That(((TestClient)sp.ControllingClient).OnlineNotificationsReceived.Count, Is.EqualTo(0));
}
[Test]
public void TestAddFriendWhileOnline()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
UUID userId = TestHelpers.ParseTail(0x1);
UUID user2Id = TestHelpers.ParseTail(0x2);
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
SceneHelpers.AddScenePresence(m_scene, user2Id);
// This friendship is currently only one-way, which might be pathalogical in Second Life.
m_fm.AddFriend(sp.ControllingClient, user2Id);
Assert.That(((TestClient)sp.ControllingClient).OfflineNotificationsReceived.Count, Is.EqualTo(0));
Assert.That(((TestClient)sp.ControllingClient).OnlineNotificationsReceived.Count, Is.EqualTo(1));
}
}
}

View File

@ -225,12 +225,13 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
foreach (Scene scene in m_Scenes)
{
ScenePresence sp = scene.GetScenePresence(toAgentID);
if(!sp.IsChildAgent)
if(sp != null && !sp.IsChildAgent)
{
scene.EventManager.TriggerIncomingInstantMessage(gim);
successful = true;
}
}
if (!successful)
{
// If the message can't be delivered to an agent, it

View File

@ -50,8 +50,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
/// </summary>
public Scene Scene { get; set; }
private bool m_Enabled = false;
private Scene m_Scene;
private bool m_Enabled;
private XInventoryServicesConnector m_RemoteConnector;
private IUserManagement m_UserManager;

View File

@ -33,6 +33,20 @@ namespace OpenSim.Region.Framework.Interfaces
{
public interface IFriendsModule
{
/// <summary>
/// Add a friend for the given user.
/// </summary>
/// <remarks>
/// This is a one-way friendship. To make a two way friendship you will need to call this again with the
/// client and friend reversed.
///
/// Ultimately, it would be more useful to take in a user account here rather than having to have a user
/// present in the scene.
/// </remarks>
/// <param name="client"></param>
/// <param name="friendID"></param>
void AddFriend(IClientAPI client, UUID friendID);
uint GetFriendPerms(UUID PrincipalID, UUID FriendID);
bool SendFriendsOnlineIfNeeded(IClientAPI client);
}

View File

@ -2862,6 +2862,8 @@ namespace OpenSim.Region.Framework.Scenes
Velocity = Vector3.Zero;
AbsolutePosition = pos;
// m_log.DebugFormat("[SCENE PRESENCE]: Prevented flyoff for {0} at {1}", Name, AbsolutePosition);
AddToPhysicalScene(isFlying);
}
}

View File

@ -56,6 +56,10 @@ namespace OpenSim.Tests.Common.Mock
private IScene m_scene;
// Properties so that we can get at received data for test purposes
public List<UUID> OfflineNotificationsReceived { get; private set; }
public List<UUID> OnlineNotificationsReceived { get; private set; }
// disable warning: public events, part of the public API
#pragma warning disable 67
@ -440,6 +444,9 @@ namespace OpenSim.Tests.Common.Mock
m_circuitCode = agentData.circuitcode;
m_scene = scene;
CapsSeedUrl = agentData.CapsPath;
OfflineNotificationsReceived = new List<UUID>();
OnlineNotificationsReceived = new List<UUID>();
}
/// <summary>
@ -827,12 +834,12 @@ namespace OpenSim.Tests.Common.Mock
public void SendAgentOffline(UUID[] agentIDs)
{
OfflineNotificationsReceived.AddRange(agentIDs);
}
public void SendAgentOnline(UUID[] agentIDs)
{
OnlineNotificationsReceived.AddRange(agentIDs);
}
public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot,

View File

@ -2947,6 +2947,7 @@
<Match path="Asset/Tests" pattern="*.cs" recurse="true"/>
<Match path="Avatar/Attachments/Tests" pattern="*.cs" recurse="true"/>
<Match path="Avatar/AvatarFactory/Tests" pattern="*.cs" recurse="true"/>
<Match path="Avatar/Friends/Tests" pattern="*.cs" recurse="true"/>
<Match path="Avatar/Inventory/Archiver/Tests" pattern="*.cs" recurse="true"/>
<Match path="Framework/InventoryAccess/Tests" pattern="*.cs" recurse="true"/>
<Match path="World/Archiver/Tests" pattern="*.cs" recurse="true"/>