2007-07-16 15:40:11 +00:00
|
|
|
/*
|
2007-09-10 08:14:38 +00:00
|
|
|
* Copyright (c) Contributors, http://opensimulator.org/
|
2007-07-16 15:40:11 +00:00
|
|
|
* 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 OpenSim 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.
|
|
|
|
*
|
|
|
|
*/
|
2007-10-03 06:20:00 +00:00
|
|
|
using System;
|
2007-07-16 15:40:11 +00:00
|
|
|
using libsecondlife;
|
2007-09-24 05:15:13 +00:00
|
|
|
using OpenSim.Framework.Communications.Cache;
|
2007-11-13 22:48:19 +00:00
|
|
|
using System.Collections.Generic;
|
2007-10-30 09:05:31 +00:00
|
|
|
using OpenSim.Framework.Console;
|
2007-07-16 15:40:11 +00:00
|
|
|
using OpenSim.Framework.Servers;
|
|
|
|
|
|
|
|
namespace OpenSim.Framework.Communications
|
|
|
|
{
|
|
|
|
public class CommunicationsManager
|
|
|
|
{
|
2007-10-05 09:41:41 +00:00
|
|
|
protected IUserService m_userService;
|
2007-10-30 09:05:31 +00:00
|
|
|
|
2007-10-05 09:41:41 +00:00
|
|
|
public IUserService UserService
|
2007-09-24 05:15:13 +00:00
|
|
|
{
|
2007-09-24 07:30:30 +00:00
|
|
|
get { return m_userService; }
|
2007-09-24 05:15:13 +00:00
|
|
|
}
|
|
|
|
|
2007-09-24 07:30:30 +00:00
|
|
|
protected IGridServices m_gridService;
|
2007-10-30 09:05:31 +00:00
|
|
|
|
2007-09-24 07:30:30 +00:00
|
|
|
public IGridServices GridService
|
2007-09-24 05:15:13 +00:00
|
|
|
{
|
2007-09-24 07:30:30 +00:00
|
|
|
get { return m_gridService; }
|
2007-09-24 05:15:13 +00:00
|
|
|
}
|
|
|
|
|
2007-09-24 07:30:30 +00:00
|
|
|
protected IInventoryServices m_inventoryService;
|
2007-10-30 09:05:31 +00:00
|
|
|
|
2007-09-24 07:30:30 +00:00
|
|
|
public IInventoryServices InventoryService
|
2007-09-24 05:15:13 +00:00
|
|
|
{
|
2007-09-24 07:30:30 +00:00
|
|
|
get { return m_inventoryService; }
|
2007-09-24 05:15:13 +00:00
|
|
|
}
|
|
|
|
|
2007-09-24 07:30:30 +00:00
|
|
|
protected IInterRegionCommunications m_interRegion;
|
2007-10-30 09:05:31 +00:00
|
|
|
|
2007-09-24 05:15:13 +00:00
|
|
|
public IInterRegionCommunications InterRegion
|
|
|
|
{
|
|
|
|
get { return m_interRegion; }
|
|
|
|
}
|
|
|
|
|
2007-12-02 14:56:23 +00:00
|
|
|
protected UserProfileCacheService m_userProfileCacheService;
|
2007-10-30 09:05:31 +00:00
|
|
|
|
2007-12-02 14:56:23 +00:00
|
|
|
public UserProfileCacheService UserProfileCacheService
|
2007-09-24 05:15:13 +00:00
|
|
|
{
|
2007-12-02 14:56:23 +00:00
|
|
|
get { return m_userProfileCacheService; }
|
2007-09-24 05:15:13 +00:00
|
|
|
}
|
|
|
|
|
2007-09-24 07:30:30 +00:00
|
|
|
protected AssetTransactionManager m_transactionsManager;
|
2007-10-30 09:05:31 +00:00
|
|
|
|
2007-09-24 05:15:13 +00:00
|
|
|
public AssetTransactionManager TransactionsManager
|
|
|
|
{
|
|
|
|
get { return m_transactionsManager; }
|
|
|
|
}
|
|
|
|
|
2007-09-24 07:30:30 +00:00
|
|
|
protected AssetCache m_assetCache;
|
2007-10-30 09:05:31 +00:00
|
|
|
|
2007-09-24 05:15:13 +00:00
|
|
|
public AssetCache AssetCache
|
|
|
|
{
|
|
|
|
get { return m_assetCache; }
|
|
|
|
}
|
|
|
|
|
2007-09-24 07:30:30 +00:00
|
|
|
protected NetworkServersInfo m_networkServersInfo;
|
2007-10-30 09:05:31 +00:00
|
|
|
|
2007-09-24 05:20:23 +00:00
|
|
|
public NetworkServersInfo NetworkServersInfo
|
2007-09-24 05:15:13 +00:00
|
|
|
{
|
2007-09-24 05:20:23 +00:00
|
|
|
get { return m_networkServersInfo; }
|
2007-07-16 15:40:11 +00:00
|
|
|
}
|
|
|
|
|
2007-10-30 09:05:31 +00:00
|
|
|
public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache,
|
|
|
|
bool dumpAssetsToFile)
|
2007-09-24 07:30:30 +00:00
|
|
|
{
|
|
|
|
m_networkServersInfo = serversInfo;
|
|
|
|
m_assetCache = assetCache;
|
2007-12-02 14:56:23 +00:00
|
|
|
m_userProfileCacheService = new UserProfileCacheService(this);
|
2007-10-30 09:05:31 +00:00
|
|
|
m_transactionsManager = new AssetTransactionManager(this, dumpAssetsToFile);
|
2007-09-24 07:30:30 +00:00
|
|
|
}
|
|
|
|
|
2007-10-03 06:20:00 +00:00
|
|
|
public void doCreate(string[] cmmdParams)
|
|
|
|
{
|
|
|
|
switch (cmmdParams[0])
|
|
|
|
{
|
|
|
|
case "user":
|
|
|
|
string firstName;
|
|
|
|
string lastName;
|
|
|
|
string password;
|
|
|
|
uint regX = 1000;
|
|
|
|
uint regY = 1000;
|
|
|
|
|
|
|
|
if (cmmdParams.Length < 2)
|
|
|
|
{
|
|
|
|
firstName = MainLog.Instance.CmdPrompt("First name", "Default");
|
|
|
|
lastName = MainLog.Instance.CmdPrompt("Last name", "User");
|
|
|
|
password = MainLog.Instance.PasswdPrompt("Password");
|
|
|
|
regX = Convert.ToUInt32(MainLog.Instance.CmdPrompt("Start Region X", "1000"));
|
|
|
|
regY = Convert.ToUInt32(MainLog.Instance.CmdPrompt("Start Region Y", "1000"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
firstName = cmmdParams[1];
|
|
|
|
lastName = cmmdParams[2];
|
|
|
|
password = cmmdParams[3];
|
|
|
|
regX = Convert.ToUInt32(cmmdParams[4]);
|
|
|
|
regY = Convert.ToUInt32(cmmdParams[5]);
|
|
|
|
}
|
|
|
|
|
|
|
|
AddUser(firstName, lastName, password, regX, regY);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public LLUUID AddUser(string firstName, string lastName, string password, uint regX, uint regY)
|
|
|
|
{
|
|
|
|
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + "");
|
|
|
|
|
|
|
|
m_userService.AddUserProfile(firstName, lastName, md5PasswdHash, regX, regY);
|
|
|
|
UserProfileData userProf = UserService.GetUserProfile(firstName, lastName);
|
|
|
|
if (userProf == null)
|
|
|
|
{
|
|
|
|
return LLUUID.Zero;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-30 09:05:31 +00:00
|
|
|
m_inventoryService.CreateNewUserInventory(userProf.UUID);
|
2007-10-03 06:20:00 +00:00
|
|
|
System.Console.WriteLine("Created new inventory set for " + firstName + " " + lastName);
|
|
|
|
return userProf.UUID;
|
|
|
|
}
|
|
|
|
}
|
2007-09-24 07:30:30 +00:00
|
|
|
|
2007-07-16 15:40:11 +00:00
|
|
|
#region Packet Handlers
|
2007-09-24 05:20:23 +00:00
|
|
|
|
2007-07-16 15:40:11 +00:00
|
|
|
public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client)
|
|
|
|
{
|
2007-12-02 14:56:23 +00:00
|
|
|
if (uuid == m_userProfileCacheService.libraryRoot.agentID)
|
2007-07-16 15:40:11 +00:00
|
|
|
{
|
2007-09-24 05:20:23 +00:00
|
|
|
remote_client.SendNameReply(uuid, "Mr", "OpenSim");
|
2007-07-25 18:19:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-09-24 07:30:30 +00:00
|
|
|
UserProfileData profileData = m_userService.GetUserProfile(uuid);
|
2007-07-25 18:19:38 +00:00
|
|
|
if (profileData != null)
|
|
|
|
{
|
|
|
|
LLUUID profileId = profileData.UUID;
|
2007-10-05 13:54:16 +00:00
|
|
|
string firstname = profileData.username;
|
|
|
|
string lastname = profileData.surname;
|
2007-07-16 15:40:11 +00:00
|
|
|
|
2007-07-25 18:19:38 +00:00
|
|
|
remote_client.SendNameReply(profileId, firstname, lastname);
|
|
|
|
}
|
|
|
|
}
|
2007-07-16 15:40:11 +00:00
|
|
|
}
|
2007-11-13 22:48:19 +00:00
|
|
|
public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID queryID, string query)
|
|
|
|
{
|
2007-12-02 14:56:23 +00:00
|
|
|
List<AvatarPickerAvatar> pickerlist = m_userService.GenerateAgentPickerRequestResponse(queryID, query);
|
2007-11-13 22:48:19 +00:00
|
|
|
return pickerlist;
|
|
|
|
}
|
2007-07-16 15:40:11 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
2007-09-24 05:20:23 +00:00
|
|
|
}
|