Merge branch 'master' of ssh://opensimulator.org/var/git/opensim

bulletsim
Justin Clark-Casey (justincc) 2011-06-02 21:48:50 +01:00
commit b8e2ee6978
16 changed files with 164 additions and 42 deletions

View File

@ -25,7 +25,8 @@ COMMIT;
BEGIN;
ALTER TABLE `Friends` DROP PRIMARY KEY;
ALTER TABLE `Friends` ADD PRIMARY KEY(PrincipalID(36), Friend(36));
ALTER TABLE `Friends` MODIFY COLUMN PrincipalID varchar(255) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';
COMMIT;

View File

@ -187,12 +187,16 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
// Is the user a local user?
UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, toAgentID);
string url = string.Empty;
bool foreigner = false;
if (account == null) // foreign user
{
url = UserManagementModule.GetUserServerURL(toAgentID, "IMServerURI");
foreigner = true;
}
Util.FireAndForget(delegate
{
bool success = m_IMService.OutgoingInstantMessage(im, url);
bool success = m_IMService.OutgoingInstantMessage(im, url, foreigner);
if (!success && account == null)
{
// One last chance
@ -203,7 +207,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
UUID id; string u = string.Empty, first = string.Empty, last = string.Empty, secret = string.Empty;
if (Util.ParseUniversalUserIdentifier(recipientUUI, out id, out u, out first, out last, out secret))
{
success = m_IMService.OutgoingInstantMessage(im, u);
success = m_IMService.OutgoingInstantMessage(im, u, true);
if (success)
UserManagementModule.AddUser(toAgentID, u + ";" + first + " " + last);
}

View File

@ -57,9 +57,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Profile
public void Initialise(IConfigSource config)
{
if (config.Configs["Profiles"] != null)
if (config.Configs["Profile"] != null)
{
if (config.Configs["Profiles"].GetString("Module", string.Empty) != "BasicProfileModule")
if (config.Configs["Profile"].GetString("Module", string.Empty) != "BasicProfileModule")
return;
}

View File

@ -160,9 +160,9 @@ namespace OpenSim.Server.Handlers.Friends
byte[] StoreFriend(Dictionary<string, object> request)
{
FriendInfo friend = new FriendInfo(request);
bool success = m_FriendsService.StoreFriend(friend.PrincipalID.ToString(), friend.Friend, friend.MyFlags);
string principalID = string.Empty, friend = string.Empty; int flags = 0;
FromKeyValuePairs(request, out principalID, out friend, out flags);
bool success = m_FriendsService.StoreFriend(principalID, friend, flags);
if (success)
return SuccessResult();
@ -275,6 +275,19 @@ namespace OpenSim.Server.Handlers.Friends
return ms.ToArray();
}
void FromKeyValuePairs(Dictionary<string, object> kvp, out string principalID, out string friend, out int flags)
{
principalID = string.Empty;
if (kvp.ContainsKey("PrincipalID") && kvp["PrincipalID"] != null)
principalID = kvp["PrincipalID"].ToString();
friend = string.Empty;
if (kvp.ContainsKey("Friend") && kvp["Friend"] != null)
friend = kvp["Friend"].ToString();
flags = 0;
if (kvp.ContainsKey("MyFlags") && kvp["MyFlags"] != null)
Int32.TryParse(kvp["MyFlags"].ToString(), out flags);
}
#endregion
}
}

View File

@ -72,7 +72,7 @@ namespace OpenSim.Server.Handlers.Hypergrid
if (m_IMService == null)
throw new Exception("InstantMessage server connector cannot proceed because of missing service");
MainServer.Instance.AddXmlRPCHandler("grid_instant_message", ProcessInstantMessage, false);
server.AddXmlRPCHandler("grid_instant_message", ProcessInstantMessage, false);
}

View File

@ -161,19 +161,8 @@ namespace OpenSim.Services.Connectors.Friends
public bool StoreFriend(string PrincipalID, string Friend, int flags)
{
FriendInfo finfo = new FriendInfo();
try
{
finfo.PrincipalID = new UUID(PrincipalID);
}
catch
{
return false;
}
finfo.Friend = Friend;
finfo.MyFlags = flags;
Dictionary<string, object> sendData = finfo.ToKeyValuePairs();
Dictionary<string, object> sendData = ToKeyValuePairs(PrincipalID, Friend, flags);
sendData["METHOD"] = "storefriend";
@ -267,5 +256,16 @@ namespace OpenSim.Services.Connectors.Friends
}
#endregion
public Dictionary<string, object> ToKeyValuePairs(string principalID, string friend, int flags)
{
Dictionary<string, object> result = new Dictionary<string, object>();
result["PrincipalID"] = principalID;
result["Friend"] = friend;
result["MyFlags"] = flags;
return result;
}
}
}

View File

@ -61,7 +61,7 @@ namespace OpenSim.Services.Connectors.InstantMessage
try
{
XmlRpcResponse GridResp = GridReq.Send(url, 3000);
XmlRpcResponse GridResp = GridReq.Send(url, 10000);
Hashtable responseData = (Hashtable)GridResp.Value;

View File

@ -115,23 +115,23 @@ namespace OpenSim.Services.HypergridService
return m_IMSimConnector.SendInstantMessage(im);
}
else
return TrySendInstantMessage(im, "", true);
return TrySendInstantMessage(im, "", true, false);
}
public bool OutgoingInstantMessage(GridInstantMessage im, string url)
public bool OutgoingInstantMessage(GridInstantMessage im, string url, bool foreigner)
{
m_log.DebugFormat("[HG IM SERVICE]: Sending message from {0} to {1}@{2}", im.fromAgentID, im.toAgentID, url);
if (url != string.Empty)
return TrySendInstantMessage(im, url, true);
return TrySendInstantMessage(im, url, true, foreigner);
else
{
PresenceInfo upd = new PresenceInfo();
upd.RegionID = UUID.Zero;
return TrySendInstantMessage(im, upd, true);
return TrySendInstantMessage(im, upd, true, foreigner);
}
}
protected bool TrySendInstantMessage(GridInstantMessage im, object previousLocation, bool firstTime)
protected bool TrySendInstantMessage(GridInstantMessage im, object previousLocation, bool firstTime, bool foreigner)
{
UUID toAgentID = new UUID(im.toAgentID);
@ -185,7 +185,7 @@ namespace OpenSim.Services.HypergridService
}
}
if (upd == null)
if (upd == null && !foreigner)
{
// Let's check with the UAS if the user is elsewhere
m_log.DebugFormat("[HG IM SERVICE]: User is not present. Checking location with User Agent service");
@ -213,25 +213,25 @@ namespace OpenSim.Services.HypergridService
// ok, the user is around somewhere. Let's send back the reply with "success"
// even though the IM may still fail. Just don't keep the caller waiting for
// the entire time we're trying to deliver the IM
return SendIMToRegion(upd, im, toAgentID);
return SendIMToRegion(upd, im, toAgentID, foreigner);
}
else if (url != string.Empty)
{
// ok, the user is around somewhere. Let's send back the reply with "success"
// even though the IM may still fail. Just don't keep the caller waiting for
// the entire time we're trying to deliver the IM
return ForwardIMToGrid(url, im, toAgentID);
return ForwardIMToGrid(url, im, toAgentID, foreigner);
}
else if (firstTime && previousLocation is string && (string)previousLocation != string.Empty)
{
return ForwardIMToGrid((string)previousLocation, im, toAgentID);
return ForwardIMToGrid((string)previousLocation, im, toAgentID, foreigner);
}
else
m_log.DebugFormat("[HG IM SERVICE]: Unable to locate user {0}", toAgentID);
return false;
}
bool SendIMToRegion(PresenceInfo upd, GridInstantMessage im, UUID toAgentID)
bool SendIMToRegion(PresenceInfo upd, GridInstantMessage im, UUID toAgentID, bool foreigner)
{
bool imresult = false;
GridRegion reginfo = null;
@ -277,11 +277,11 @@ namespace OpenSim.Services.HypergridService
// The version that spawns the thread is SendGridInstantMessageViaXMLRPC
// This is recursive!!!!!
return TrySendInstantMessage(im, upd, false);
return TrySendInstantMessage(im, upd, false, foreigner);
}
}
bool ForwardIMToGrid(string url, GridInstantMessage im, UUID toAgentID)
bool ForwardIMToGrid(string url, GridInstantMessage im, UUID toAgentID, bool foreigner)
{
if (InstantMessageServiceConnector.SendInstantMessage(url, im))
{
@ -309,7 +309,7 @@ namespace OpenSim.Services.HypergridService
// The version that spawns the thread is SendGridInstantMessageViaXMLRPC
// This is recursive!!!!!
return TrySendInstantMessage(im, url, false);
return TrySendInstantMessage(im, url, false, foreigner);
}
}

View File

@ -197,8 +197,11 @@ namespace OpenSim.Services.HypergridService
agentCircuit.firstname, agentCircuit.lastname, region.ServerURI, reason);
// restore the old travel info
lock (m_TravelingAgents)
m_TravelingAgents[agentCircuit.SessionID] = old;
if(reason != "Logins Disabled")
{
lock (m_TravelingAgents)
m_TravelingAgents[agentCircuit.SessionID] = old;
}
return false;
}

View File

@ -72,7 +72,7 @@ namespace OpenSim.Services.Interfaces
public interface IInstantMessage
{
bool IncomingInstantMessage(GridInstantMessage im);
bool OutgoingInstantMessage(GridInstantMessage im, string url);
bool OutgoingInstantMessage(GridInstantMessage im, string url, bool foreigner);
}
public interface IFriendsSimConnector
{

View File

@ -0,0 +1,75 @@
/*
* 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 System.Text;
using System.Reflection;
using OpenMetaverse;
using log4net;
using log4net.Appender;
using log4net.Layout;
using OpenSim.Framework;
using OpenSim.Services.Interfaces;
using OpenSim.Services.Connectors.InstantMessage;
namespace OpenSim.Tests.Clients.InstantMessage
{
public class IMClient
{
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
public static void Main(string[] args)
{
ConsoleAppender consoleAppender = new ConsoleAppender();
consoleAppender.Layout =
new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline");
log4net.Config.BasicConfigurator.Configure(consoleAppender);
string serverURI = "http://127.0.0.1:8002";
GridInstantMessage im = new GridInstantMessage();
im.fromAgentID = new Guid();
im.toAgentID = new Guid();
im.message = "Hello";
im.imSessionID = new Guid();
bool success = InstantMessageServiceConnector.SendInstantMessage(serverURI, im);
if (success)
m_log.InfoFormat("[IM CLIENT]: Successfully IMed {0}", serverURI);
else
m_log.InfoFormat("[IM CLIENT]: failed to IM {0}", serverURI);
System.Console.WriteLine("\n");
}
}
}

View File

@ -27,7 +27,7 @@
SimulationServiceInConnector = true
LibraryModule = true
[Profiles]
[Profile]
Module = "BasicProfileModule"
[SimulationDataStore]

View File

@ -31,7 +31,7 @@
SimulationServiceInConnector = true
LibraryModule = true
[Profiles]
[Profile]
Module = "BasicProfileModule"
[SimulationDataStore]

View File

@ -22,7 +22,7 @@
LLLoginServiceInConnector = true
GridInfoServiceInConnector = true
[Profiles]
[Profile]
Module = "BasicProfileModule"
[SimulationDataStore]

View File

@ -32,7 +32,7 @@
AuthenticationServiceInConnector = true
SimulationServiceInConnector = true
[Profiles]
[Profile]
Module = "BasicProfileModule"
[Messaging]

View File

@ -2645,6 +2645,32 @@
</Files>
</Project>
<Project frameworkVersion="v3_5" name="OpenSim.Tests.Clients.InstantantMessage" path="OpenSim/Tests/Clients/InstantMessage" type="Exe">
<Configuration name="Debug">
<Options>
<OutputPath>../../../../bin/</OutputPath>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../../../bin/</OutputPath>
</Options>
</Configuration>
<ReferencePath>../../../../bin/</ReferencePath>
<Reference name="System"/>
<Reference name="OpenMetaverseTypes" path="../../../../bin/"/>
<Reference name="OpenMetaverse" path="../../../../bin/"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Services.Interfaces"/>
<Reference name="OpenSim.Services.Connectors"/>
<Reference name="Nini" path="../../../../bin/"/>
<Reference name="log4net" path="../../../../bin/"/>
<Files>
<Match pattern="*.cs" recurse="true"/>
</Files>
</Project>
<!-- Test assemblies -->
<Project frameworkVersion="v3_5" name="OpenSim.Tests.Common" path="OpenSim/Tests/Common" type="Library">