mirror of
https://github.com/opensim/opensim.git
synced 2026-08-10 03:06:05 +08:00
Merge branch 'master' into bigmerge
Conflicts: OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
|
||||
// Instantiate the request handler
|
||||
IHttpServer server = MainServer.GetHttpServer((uint)mPort);
|
||||
server.AddStreamHandler(new FriendsRequestHandler(this));
|
||||
|
||||
if (server != null)
|
||||
server.AddStreamHandler(new FriendsRequestHandler(this));
|
||||
}
|
||||
|
||||
if (m_FriendsService == null)
|
||||
@@ -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.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>
|
||||
|
||||
@@ -141,7 +141,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||
{
|
||||
List<string> fList = new List<string>();
|
||||
foreach (string s in friendList)
|
||||
fList.Add(s.Substring(0, 36));
|
||||
{
|
||||
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)
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user