diff options
110 files changed, 9500 insertions, 2312 deletions
diff --git a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs index 6fd3d30..1e85a22 100644 --- a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs +++ b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs | |||
@@ -102,8 +102,6 @@ namespace OpenSim.ApplicationPlugins.LoadRegions | |||
102 | m_log.Info("[LOADREGIONSPLUGIN]: Loading specific shared modules..."); | 102 | m_log.Info("[LOADREGIONSPLUGIN]: Loading specific shared modules..."); |
103 | m_log.Info("[LOADREGIONSPLUGIN]: DynamicTextureModule..."); | 103 | m_log.Info("[LOADREGIONSPLUGIN]: DynamicTextureModule..."); |
104 | m_openSim.ModuleLoader.LoadDefaultSharedModule(new DynamicTextureModule()); | 104 | m_openSim.ModuleLoader.LoadDefaultSharedModule(new DynamicTextureModule()); |
105 | m_log.Info("[LOADREGIONSPLUGIN]: InstantMessageModule..."); | ||
106 | m_openSim.ModuleLoader.LoadDefaultSharedModule(new InstantMessageModule()); | ||
107 | m_log.Info("[LOADREGIONSPLUGIN]: LoadImageURLModule..."); | 105 | m_log.Info("[LOADREGIONSPLUGIN]: LoadImageURLModule..."); |
108 | m_openSim.ModuleLoader.LoadDefaultSharedModule(new LoadImageURLModule()); | 106 | m_openSim.ModuleLoader.LoadDefaultSharedModule(new LoadImageURLModule()); |
109 | m_log.Info("[LOADREGIONSPLUGIN]: XMLRPCModule..."); | 107 | m_log.Info("[LOADREGIONSPLUGIN]: XMLRPCModule..."); |
@@ -217,4 +215,4 @@ namespace OpenSim.ApplicationPlugins.LoadRegions | |||
217 | } | 215 | } |
218 | } | 216 | } |
219 | } | 217 | } |
220 | } \ No newline at end of file | 218 | } |
diff --git a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs index 6c0c74d..2e883d6 100644 --- a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs +++ b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs | |||
@@ -65,9 +65,13 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController | |||
65 | 65 | ||
66 | public void Initialise (OpenSimBase openSim) | 66 | public void Initialise (OpenSimBase openSim) |
67 | { | 67 | { |
68 | m_log.DebugFormat("[REGIONMODULES]: Initializing..."); | ||
69 | m_openSim = openSim; | 68 | m_openSim = openSim; |
70 | openSim.ApplicationRegistry.RegisterInterface<IRegionModulesController>(this); | 69 | } |
70 | |||
71 | public void PostInitialise () | ||
72 | { | ||
73 | m_log.DebugFormat("[REGIONMODULES]: Initializing..."); | ||
74 | m_openSim.ApplicationRegistry.RegisterInterface<IRegionModulesController>(this); | ||
71 | 75 | ||
72 | // Who we are | 76 | // Who we are |
73 | string id = AddinManager.CurrentAddin.Id; | 77 | string id = AddinManager.CurrentAddin.Id; |
@@ -81,9 +85,9 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController | |||
81 | 85 | ||
82 | // The [Modules] section in the ini file | 86 | // The [Modules] section in the ini file |
83 | IConfig modulesConfig = | 87 | IConfig modulesConfig = |
84 | openSim.ConfigSource.Source.Configs["Modules"]; | 88 | m_openSim.ConfigSource.Source.Configs["Modules"]; |
85 | if (modulesConfig == null) | 89 | if (modulesConfig == null) |
86 | modulesConfig = openSim.ConfigSource.Source.AddConfig("Modules"); | 90 | modulesConfig = m_openSim.ConfigSource.Source.AddConfig("Modules"); |
87 | 91 | ||
88 | // Scan modules and load all that aren't disabled | 92 | // Scan modules and load all that aren't disabled |
89 | foreach (TypeExtensionNode node in | 93 | foreach (TypeExtensionNode node in |
@@ -195,7 +199,7 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController | |||
195 | 199 | ||
196 | // OK, we're up and running | 200 | // OK, we're up and running |
197 | m_sharedInstances.Add(module); | 201 | m_sharedInstances.Add(module); |
198 | module.Initialise(openSim.ConfigSource.Source); | 202 | module.Initialise(m_openSim.ConfigSource.Source); |
199 | } | 203 | } |
200 | 204 | ||
201 | // Immediately run PostInitialise on shared modules | 205 | // Immediately run PostInitialise on shared modules |
@@ -205,10 +209,6 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController | |||
205 | } | 209 | } |
206 | } | 210 | } |
207 | 211 | ||
208 | public void PostInitialise () | ||
209 | { | ||
210 | } | ||
211 | |||
212 | #endregion | 212 | #endregion |
213 | 213 | ||
214 | #region IPlugin implementation | 214 | #region IPlugin implementation |
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/Rest.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/Rest.cs index 7db705e..8d62423 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/Rest.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/Rest.cs | |||
@@ -36,6 +36,7 @@ using OpenSim.Framework; | |||
36 | using OpenSim.Framework.Communications; | 36 | using OpenSim.Framework.Communications; |
37 | using OpenSim.Services.Interfaces; | 37 | using OpenSim.Services.Interfaces; |
38 | using IUserService = OpenSim.Framework.Communications.IUserService; | 38 | using IUserService = OpenSim.Framework.Communications.IUserService; |
39 | using IAvatarService = OpenSim.Framework.Communications.IAvatarService; | ||
39 | 40 | ||
40 | namespace OpenSim.ApplicationPlugins.Rest.Inventory | 41 | namespace OpenSim.ApplicationPlugins.Rest.Inventory |
41 | { | 42 | { |
diff --git a/OpenSim/Client/Linden/LLStandaloneLoginService.cs b/OpenSim/Client/Linden/LLStandaloneLoginService.cs index 122110d..a975fa2 100644 --- a/OpenSim/Client/Linden/LLStandaloneLoginService.cs +++ b/OpenSim/Client/Linden/LLStandaloneLoginService.cs | |||
@@ -37,6 +37,7 @@ using OpenMetaverse; | |||
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Communications; | 38 | using OpenSim.Framework.Communications; |
39 | using OpenSim.Framework.Communications.Services; | 39 | using OpenSim.Framework.Communications.Services; |
40 | using LoginResponse = OpenSim.Framework.Communications.Services.LoginResponse; | ||
40 | using OpenSim.Framework.Communications.Cache; | 41 | using OpenSim.Framework.Communications.Cache; |
41 | using OpenSim.Framework.Capabilities; | 42 | using OpenSim.Framework.Capabilities; |
42 | using OpenSim.Framework.Servers; | 43 | using OpenSim.Framework.Servers; |
diff --git a/OpenSim/Client/Linden/Resources/LindenModules.addin.xml b/OpenSim/Client/Linden/Resources/LindenModules.addin.xml index 6a55ce8..a07a00f 100644 --- a/OpenSim/Client/Linden/Resources/LindenModules.addin.xml +++ b/OpenSim/Client/Linden/Resources/LindenModules.addin.xml | |||
@@ -8,8 +8,10 @@ | |||
8 | </Dependencies> | 8 | </Dependencies> |
9 | 9 | ||
10 | <Extension path = "/OpenSim/RegionModules"> | 10 | <Extension path = "/OpenSim/RegionModules"> |
11 | <!-- | ||
11 | <RegionModule id="LLStandaloneLoginModule" type="OpenSim.Client.Linden.LLStandaloneLoginModule" /> | 12 | <RegionModule id="LLStandaloneLoginModule" type="OpenSim.Client.Linden.LLStandaloneLoginModule" /> |
12 | <RegionModule id="LLProxyLoginModule" type="OpenSim.Client.Linden.LLProxyLoginModule" /> | 13 | <RegionModule id="LLProxyLoginModule" type="OpenSim.Client.Linden.LLProxyLoginModule" /> |
14 | --> | ||
13 | <RegionModule id="LLClientStackModule" type="OpenSim.Client.Linden.LLClientStackModule" /> | 15 | <RegionModule id="LLClientStackModule" type="OpenSim.Client.Linden.LLClientStackModule" /> |
14 | </Extension> | 16 | </Extension> |
15 | </Addin> | 17 | </Addin> |
diff --git a/OpenSim/Data/IAvatarData.cs b/OpenSim/Data/IAvatarData.cs new file mode 100644 index 0000000..0a18e21 --- /dev/null +++ b/OpenSim/Data/IAvatarData.cs | |||
@@ -0,0 +1,49 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | |||
33 | namespace OpenSim.Data | ||
34 | { | ||
35 | // This MUST be a ref type! | ||
36 | public class AvatarBaseData | ||
37 | { | ||
38 | public UUID PrincipalID; | ||
39 | public Dictionary<string, string> Data; | ||
40 | } | ||
41 | |||
42 | public interface IAvatarData | ||
43 | { | ||
44 | AvatarBaseData[] Get(string field, string val); | ||
45 | bool Store(AvatarBaseData data); | ||
46 | bool Delete(UUID principalID, string name); | ||
47 | bool Delete(string field, string val); | ||
48 | } | ||
49 | } | ||
diff --git a/OpenSim/Data/IPresenceData.cs b/OpenSim/Data/IPresenceData.cs index e5a8ebd..71d0e31 100644 --- a/OpenSim/Data/IPresenceData.cs +++ b/OpenSim/Data/IPresenceData.cs | |||
@@ -32,25 +32,28 @@ using OpenSim.Framework; | |||
32 | 32 | ||
33 | namespace OpenSim.Data | 33 | namespace OpenSim.Data |
34 | { | 34 | { |
35 | public struct PresenceData | 35 | // This MUST be a ref type! |
36 | public class PresenceData | ||
36 | { | 37 | { |
37 | public UUID UUID; | 38 | public string UserID; |
38 | public UUID currentRegion; | 39 | public UUID RegionID; |
40 | public UUID SessionID; | ||
39 | public Dictionary<string, string> Data; | 41 | public Dictionary<string, string> Data; |
40 | } | 42 | } |
41 | 43 | ||
42 | /// <summary> | 44 | /// <summary> |
43 | /// An interface for connecting to the authentication datastore | 45 | /// An interface for connecting to the presence datastore |
44 | /// </summary> | 46 | /// </summary> |
45 | public interface IPresenceData | 47 | public interface IPresenceData |
46 | { | 48 | { |
47 | bool Store(PresenceData data); | 49 | bool Store(PresenceData data); |
48 | 50 | ||
49 | PresenceData Get(UUID principalID); | 51 | PresenceData Get(UUID sessionID); |
50 | 52 | void LogoutRegionAgents(UUID regionID); | |
51 | bool SetUserDataItem(UUID principalID, string item, string value); | 53 | bool ReportAgent(UUID sessionID, UUID regionID, string position, string lookAt); |
52 | bool SetRegionDataItem(UUID principalID, string item, string value); | 54 | bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt); |
53 | 55 | PresenceData[] Get(string field, string data); | |
54 | bool Delete(UUID regionID); | 56 | void Prune(string userID); |
57 | bool Delete(string field, string val); | ||
55 | } | 58 | } |
56 | } | 59 | } |
diff --git a/OpenSim/Data/IUserAccountData.cs b/OpenSim/Data/IUserAccountData.cs index 6bec188..6ee5995 100644 --- a/OpenSim/Data/IUserAccountData.cs +++ b/OpenSim/Data/IUserAccountData.cs | |||
@@ -36,20 +36,18 @@ namespace OpenSim.Data | |||
36 | { | 36 | { |
37 | public UUID PrincipalID; | 37 | public UUID PrincipalID; |
38 | public UUID ScopeID; | 38 | public UUID ScopeID; |
39 | public Dictionary<string, object> Data; | 39 | public string FirstName; |
40 | public string LastName; | ||
41 | public Dictionary<string, string> Data; | ||
40 | } | 42 | } |
41 | 43 | ||
42 | /// <summary> | 44 | /// <summary> |
43 | /// An interface for connecting to the authentication datastore | 45 | /// An interface for connecting to the user accounts datastore |
44 | /// </summary> | 46 | /// </summary> |
45 | public interface IUserAccountData | 47 | public interface IUserAccountData |
46 | { | 48 | { |
47 | UserAccountData Get(UUID principalID, UUID ScopeID); | 49 | UserAccountData[] Get(string[] fields, string[] values); |
48 | |||
49 | List<UserAccountData> Query(UUID principalID, UUID ScopeID, string query); | ||
50 | |||
51 | bool Store(UserAccountData data); | 50 | bool Store(UserAccountData data); |
52 | 51 | UserAccountData[] GetUsers(UUID scopeID, string query); | |
53 | bool SetDataItem(UUID principalID, string item, string value); | ||
54 | } | 52 | } |
55 | } | 53 | } |
diff --git a/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs b/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs index 2d92cb1..01c64dc 100644 --- a/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs +++ b/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs | |||
@@ -65,7 +65,7 @@ namespace OpenSim.Data.MSSQL | |||
65 | public UserAccountData Get(UUID principalID, UUID scopeID) | 65 | public UserAccountData Get(UUID principalID, UUID scopeID) |
66 | { | 66 | { |
67 | UserAccountData ret = new UserAccountData(); | 67 | UserAccountData ret = new UserAccountData(); |
68 | ret.Data = new Dictionary<string, object>(); | 68 | ret.Data = new Dictionary<string, string>(); |
69 | 69 | ||
70 | string sql = string.Format("select * from {0} where UUID = @principalID", m_Realm); | 70 | string sql = string.Format("select * from {0} where UUID = @principalID", m_Realm); |
71 | if (scopeID != UUID.Zero) | 71 | if (scopeID != UUID.Zero) |
@@ -168,6 +168,11 @@ namespace OpenSim.Data.MSSQL | |||
168 | return true; | 168 | return true; |
169 | } | 169 | } |
170 | 170 | ||
171 | public bool Store(UserAccountData data, UUID principalID, string token) | ||
172 | { | ||
173 | return false; | ||
174 | } | ||
175 | |||
171 | public bool SetDataItem(UUID principalID, string item, string value) | 176 | public bool SetDataItem(UUID principalID, string item, string value) |
172 | { | 177 | { |
173 | string sql = string.Format("update {0} set {1} = @{1} where UUID = @UUID", m_Realm, item); | 178 | string sql = string.Format("update {0} set {1} = @{1} where UUID = @UUID", m_Realm, item); |
@@ -184,5 +189,15 @@ namespace OpenSim.Data.MSSQL | |||
184 | } | 189 | } |
185 | return false; | 190 | return false; |
186 | } | 191 | } |
192 | |||
193 | public UserAccountData[] Get(string[] keys, string[] vals) | ||
194 | { | ||
195 | return null; | ||
196 | } | ||
197 | |||
198 | public UserAccountData[] GetUsers(UUID scopeID, string query) | ||
199 | { | ||
200 | return null; | ||
201 | } | ||
187 | } | 202 | } |
188 | } | 203 | } |
diff --git a/OpenSim/Data/Migration.cs b/OpenSim/Data/Migration.cs index e51dc22..4622e23 100644 --- a/OpenSim/Data/Migration.cs +++ b/OpenSim/Data/Migration.cs | |||
@@ -128,7 +128,7 @@ namespace OpenSim.Data | |||
128 | return; | 128 | return; |
129 | 129 | ||
130 | // to prevent people from killing long migrations. | 130 | // to prevent people from killing long migrations. |
131 | m_log.InfoFormat("[MIGRATIONS] Upgrading {0} to latest revision.", _type); | 131 | m_log.InfoFormat("[MIGRATIONS] Upgrading {0} to latest revision {1}.", _type, migrations.Keys[migrations.Count - 1]); |
132 | m_log.Info("[MIGRATIONS] NOTE: this may take a while, don't interupt this process!"); | 132 | m_log.Info("[MIGRATIONS] NOTE: this may take a while, don't interupt this process!"); |
133 | 133 | ||
134 | DbCommand cmd = _conn.CreateCommand(); | 134 | DbCommand cmd = _conn.CreateCommand(); |
@@ -138,7 +138,15 @@ namespace OpenSim.Data | |||
138 | cmd.CommandText = kvp.Value; | 138 | cmd.CommandText = kvp.Value; |
139 | // we need to up the command timeout to infinite as we might be doing long migrations. | 139 | // we need to up the command timeout to infinite as we might be doing long migrations. |
140 | cmd.CommandTimeout = 0; | 140 | cmd.CommandTimeout = 0; |
141 | cmd.ExecuteNonQuery(); | 141 | try |
142 | { | ||
143 | cmd.ExecuteNonQuery(); | ||
144 | } | ||
145 | catch (Exception e) | ||
146 | { | ||
147 | m_log.DebugFormat("[MIGRATIONS] Cmd was {0}", cmd.CommandText); | ||
148 | m_log.DebugFormat("[MIGRATIONS]: An error has occurred in the migration {0}.\n This may mean you could see errors trying to run OpenSim. If you see database related errors, you will need to fix the issue manually. Continuing.", e.Message); | ||
149 | } | ||
142 | 150 | ||
143 | if (version == 0) | 151 | if (version == 0) |
144 | { | 152 | { |
@@ -246,7 +254,8 @@ namespace OpenSim.Data | |||
246 | if (m.Success) | 254 | if (m.Success) |
247 | { | 255 | { |
248 | int version = int.Parse(m.Groups[1].ToString()); | 256 | int version = int.Parse(m.Groups[1].ToString()); |
249 | if (version > after) { | 257 | if (version > after) |
258 | { | ||
250 | using (Stream resource = _assem.GetManifestResourceStream(s)) | 259 | using (Stream resource = _assem.GetManifestResourceStream(s)) |
251 | { | 260 | { |
252 | using (StreamReader resourceReader = new StreamReader(resource)) | 261 | using (StreamReader resourceReader = new StreamReader(resource)) |
diff --git a/OpenSim/Services/UserService/UserService.cs b/OpenSim/Data/MySQL/MySQLAvatarData.cs index e8b9fc3..5611302 100644 --- a/OpenSim/Services/UserService/UserService.cs +++ b/OpenSim/Data/MySQL/MySQLAvatarData.cs | |||
@@ -26,51 +26,42 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Reflection; | ||
30 | using Nini.Config; | ||
31 | using OpenSim.Data; | ||
32 | using OpenSim.Services.Interfaces; | ||
33 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Data; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using log4net; | ||
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using OpenSim.Framework; | ||
36 | using MySql.Data.MySqlClient; | ||
35 | 37 | ||
36 | namespace OpenSim.Services.UserAccountService | 38 | namespace OpenSim.Data.MySQL |
37 | { | 39 | { |
38 | public class UserAccountService : UserAccountServiceBase, IUserAccountService | 40 | /// <summary> |
41 | /// A MySQL Interface for the Grid Server | ||
42 | /// </summary> | ||
43 | public class MySQLAvatarData : MySQLGenericTableHandler<AvatarBaseData>, | ||
44 | IAvatarData | ||
39 | { | 45 | { |
40 | public UserAccountService(IConfigSource config) : base(config) | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
41 | { | ||
42 | } | ||
43 | 47 | ||
44 | public UserAccount GetUserAccount(UUID scopeID, string firstName, | 48 | public MySQLAvatarData(string connectionString, string realm) : |
45 | string lastName) | 49 | base(connectionString, realm, "Avatar") |
46 | { | 50 | { |
47 | return null; | ||
48 | } | 51 | } |
49 | 52 | ||
50 | public UserAccount GetUserAccount(UUID scopeID, UUID userID) | 53 | public bool Delete(UUID principalID, string name) |
51 | { | 54 | { |
52 | return null; | 55 | MySqlCommand cmd = new MySqlCommand(); |
53 | } | ||
54 | 56 | ||
55 | public bool SetHomePosition(UserAccount data, UUID regionID, UUID regionSecret) | 57 | cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = ?PrincipalID and `Name` = ?Name", m_Realm); |
56 | { | 58 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); |
57 | return false; | 59 | cmd.Parameters.AddWithValue("?Name", name); |
58 | } | ||
59 | 60 | ||
60 | public bool SetUserAccount(UserAccount data, UUID principalID, string token) | 61 | if (ExecuteNonQuery(cmd) > 0) |
61 | { | 62 | return true; |
62 | return false; | ||
63 | } | ||
64 | 63 | ||
65 | public bool CreateUserAccount(UserAccount data, UUID principalID, string token) | ||
66 | { | ||
67 | return false; | 64 | return false; |
68 | } | 65 | } |
69 | |||
70 | public List<UserAccount> GetUserAccount(UUID scopeID, | ||
71 | string query) | ||
72 | { | ||
73 | return null; | ||
74 | } | ||
75 | } | 66 | } |
76 | } | 67 | } |
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index fdb98eb..2269d20 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | |||
@@ -95,12 +95,12 @@ namespace OpenSim.Data.MySQL | |||
95 | } | 95 | } |
96 | } | 96 | } |
97 | 97 | ||
98 | public T[] Get(string field, string key) | 98 | public virtual T[] Get(string field, string key) |
99 | { | 99 | { |
100 | return Get(new string[] { field }, new string[] { key }); | 100 | return Get(new string[] { field }, new string[] { key }); |
101 | } | 101 | } |
102 | 102 | ||
103 | public T[] Get(string[] fields, string[] keys) | 103 | public virtual T[] Get(string[] fields, string[] keys) |
104 | { | 104 | { |
105 | if (fields.Length != keys.Length) | 105 | if (fields.Length != keys.Length) |
106 | return new T[0]; | 106 | return new T[0]; |
@@ -182,12 +182,14 @@ namespace OpenSim.Data.MySQL | |||
182 | result.Add(row); | 182 | result.Add(row); |
183 | } | 183 | } |
184 | 184 | ||
185 | reader.Close(); | ||
186 | |||
185 | CloseReaderCommand(cmd); | 187 | CloseReaderCommand(cmd); |
186 | 188 | ||
187 | return result.ToArray(); | 189 | return result.ToArray(); |
188 | } | 190 | } |
189 | 191 | ||
190 | public T[] Get(string where) | 192 | public virtual T[] Get(string where) |
191 | { | 193 | { |
192 | MySqlCommand cmd = new MySqlCommand(); | 194 | MySqlCommand cmd = new MySqlCommand(); |
193 | 195 | ||
@@ -199,7 +201,7 @@ namespace OpenSim.Data.MySQL | |||
199 | return DoQuery(cmd); | 201 | return DoQuery(cmd); |
200 | } | 202 | } |
201 | 203 | ||
202 | public bool Store(T row) | 204 | public virtual bool Store(T row) |
203 | { | 205 | { |
204 | MySqlCommand cmd = new MySqlCommand(); | 206 | MySqlCommand cmd = new MySqlCommand(); |
205 | 207 | ||
@@ -237,7 +239,7 @@ namespace OpenSim.Data.MySQL | |||
237 | return false; | 239 | return false; |
238 | } | 240 | } |
239 | 241 | ||
240 | public bool Delete(string field, string val) | 242 | public virtual bool Delete(string field, string val) |
241 | { | 243 | { |
242 | MySqlCommand cmd = new MySqlCommand(); | 244 | MySqlCommand cmd = new MySqlCommand(); |
243 | 245 | ||
diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs new file mode 100644 index 0000000..e5dd0e5 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs | |||
@@ -0,0 +1,149 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Data; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using log4net; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using MySql.Data.MySqlClient; | ||
37 | |||
38 | namespace OpenSim.Data.MySQL | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// A MySQL Interface for the Grid Server | ||
42 | /// </summary> | ||
43 | public class MySQLPresenceData : MySQLGenericTableHandler<PresenceData>, | ||
44 | IPresenceData | ||
45 | { | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | public MySQLPresenceData(string connectionString, string realm) : | ||
49 | base(connectionString, realm, "Presence") | ||
50 | { | ||
51 | } | ||
52 | |||
53 | public PresenceData Get(UUID sessionID) | ||
54 | { | ||
55 | PresenceData[] ret = Get("SessionID", | ||
56 | sessionID.ToString()); | ||
57 | |||
58 | if (ret.Length == 0) | ||
59 | return null; | ||
60 | |||
61 | return ret[0]; | ||
62 | } | ||
63 | |||
64 | public void LogoutRegionAgents(UUID regionID) | ||
65 | { | ||
66 | MySqlCommand cmd = new MySqlCommand(); | ||
67 | |||
68 | cmd.CommandText = String.Format("update {0} set Online='false' where `RegionID`=?RegionID", m_Realm); | ||
69 | |||
70 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | ||
71 | |||
72 | ExecuteNonQuery(cmd); | ||
73 | } | ||
74 | |||
75 | public bool ReportAgent(UUID sessionID, UUID regionID, string position, | ||
76 | string lookAt) | ||
77 | { | ||
78 | PresenceData[] pd = Get("SessionID", sessionID.ToString()); | ||
79 | if (pd.Length == 0) | ||
80 | return false; | ||
81 | |||
82 | MySqlCommand cmd = new MySqlCommand(); | ||
83 | |||
84 | cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, Position=?Position, LookAt=?LookAt, Online='true' where `SessionID`=?SessionID", m_Realm); | ||
85 | |||
86 | cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString()); | ||
87 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | ||
88 | cmd.Parameters.AddWithValue("?Position", position.ToString()); | ||
89 | cmd.Parameters.AddWithValue("?LookAt", lookAt.ToString()); | ||
90 | |||
91 | if (ExecuteNonQuery(cmd) == 0) | ||
92 | return false; | ||
93 | |||
94 | return true; | ||
95 | } | ||
96 | |||
97 | public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
98 | { | ||
99 | PresenceData[] pd = Get("UserID", userID); | ||
100 | if (pd.Length == 0) | ||
101 | return false; | ||
102 | |||
103 | MySqlCommand cmd = new MySqlCommand(); | ||
104 | |||
105 | cmd.CommandText = String.Format("update {0} set HomeRegionID=?HomeRegionID, HomePosition=?HomePosition, HomeLookAt=?HomeLookAt where UserID=?UserID", m_Realm); | ||
106 | |||
107 | cmd.Parameters.AddWithValue("?UserID", userID); | ||
108 | cmd.Parameters.AddWithValue("?HomeRegionID", regionID.ToString()); | ||
109 | cmd.Parameters.AddWithValue("?HomePosition", position); | ||
110 | cmd.Parameters.AddWithValue("?HomeLookAt", lookAt); | ||
111 | |||
112 | if (ExecuteNonQuery(cmd) == 0) | ||
113 | return false; | ||
114 | |||
115 | return true; | ||
116 | } | ||
117 | |||
118 | public void Prune(string userID) | ||
119 | { | ||
120 | MySqlCommand cmd = new MySqlCommand(); | ||
121 | |||
122 | cmd.CommandText = String.Format("select * from {0} where UserID=?UserID", m_Realm); | ||
123 | |||
124 | cmd.Parameters.AddWithValue("?UserID", userID); | ||
125 | |||
126 | IDataReader reader = ExecuteReader(cmd); | ||
127 | |||
128 | List<UUID> deleteSessions = new List<UUID>(); | ||
129 | int online = 0; | ||
130 | |||
131 | while(reader.Read()) | ||
132 | { | ||
133 | if (bool.Parse(reader["Online"].ToString())) | ||
134 | online++; | ||
135 | else | ||
136 | deleteSessions.Add(new UUID(reader["SessionID"].ToString())); | ||
137 | } | ||
138 | |||
139 | if (online == 0 && deleteSessions.Count > 0) | ||
140 | deleteSessions.RemoveAt(0); | ||
141 | |||
142 | reader.Close(); | ||
143 | CloseReaderCommand(cmd); | ||
144 | |||
145 | foreach (UUID s in deleteSessions) | ||
146 | Delete("SessionID", s.ToString()); | ||
147 | } | ||
148 | } | ||
149 | } | ||
diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index d48144d..aa69d68 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs | |||
@@ -35,146 +35,50 @@ using MySql.Data.MySqlClient; | |||
35 | 35 | ||
36 | namespace OpenSim.Data.MySQL | 36 | namespace OpenSim.Data.MySQL |
37 | { | 37 | { |
38 | public class MySqlUserAccountData : MySqlFramework, IUserAccountData | 38 | public class MySqlUserAccountData : MySQLGenericTableHandler<UserAccountData>, IUserAccountData |
39 | { | 39 | { |
40 | private string m_Realm; | ||
41 | private List<string> m_ColumnNames = null; | ||
42 | // private int m_LastExpire = 0; | ||
43 | |||
44 | public MySqlUserAccountData(string connectionString, string realm) | 40 | public MySqlUserAccountData(string connectionString, string realm) |
45 | : base(connectionString) | 41 | : base(connectionString, realm, "UserAccount") |
46 | { | ||
47 | m_Realm = realm; | ||
48 | |||
49 | Migration m = new Migration(m_Connection, GetType().Assembly, "UserStore"); | ||
50 | m.Update(); | ||
51 | } | ||
52 | |||
53 | public List<UserAccountData> Query(UUID principalID, UUID scopeID, string query) | ||
54 | { | 42 | { |
55 | return null; | ||
56 | } | 43 | } |
57 | 44 | ||
58 | public UserAccountData Get(UUID principalID, UUID scopeID) | 45 | public UserAccountData[] GetUsers(UUID scopeID, string query) |
59 | { | 46 | { |
60 | UserAccountData ret = new UserAccountData(); | 47 | string[] words = query.Split(new char[] {' '}); |
61 | ret.Data = new Dictionary<string, object>(); | ||
62 | 48 | ||
63 | string command = "select * from `"+m_Realm+"` where UUID = ?principalID"; | 49 | for (int i = 0 ; i < words.Length ; i++) |
64 | if (scopeID != UUID.Zero) | ||
65 | command += " and ScopeID = ?scopeID"; | ||
66 | |||
67 | MySqlCommand cmd = new MySqlCommand(command); | ||
68 | |||
69 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); | ||
70 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); | ||
71 | |||
72 | IDataReader result = ExecuteReader(cmd); | ||
73 | |||
74 | if (result.Read()) | ||
75 | { | 50 | { |
76 | ret.PrincipalID = principalID; | 51 | if (words[i].Length < 3) |
77 | UUID scope; | ||
78 | UUID.TryParse(result["ScopeID"].ToString(), out scope); | ||
79 | ret.ScopeID = scope; | ||
80 | |||
81 | if (m_ColumnNames == null) | ||
82 | { | 52 | { |
83 | m_ColumnNames = new List<string>(); | 53 | if (i != words.Length - 1) |
84 | 54 | Array.Copy(words, i + 1, words, i, words.Length - i - 1); | |
85 | DataTable schemaTable = result.GetSchemaTable(); | 55 | Array.Resize(ref words, words.Length - 1); |
86 | foreach (DataRow row in schemaTable.Rows) | ||
87 | m_ColumnNames.Add(row["ColumnName"].ToString()); | ||
88 | } | ||
89 | |||
90 | foreach (string s in m_ColumnNames) | ||
91 | { | ||
92 | if (s == "UUID") | ||
93 | continue; | ||
94 | if (s == "ScopeID") | ||
95 | continue; | ||
96 | |||
97 | ret.Data[s] = result[s].ToString(); | ||
98 | } | 56 | } |
99 | |||
100 | result.Close(); | ||
101 | CloseReaderCommand(cmd); | ||
102 | |||
103 | return ret; | ||
104 | } | 57 | } |
105 | 58 | ||
106 | result.Close(); | 59 | if (words.Length == 0) |
107 | CloseReaderCommand(cmd); | 60 | return new UserAccountData[0]; |
108 | 61 | ||
109 | return null; | 62 | if (words.Length > 2) |
110 | } | 63 | return new UserAccountData[0]; |
111 | |||
112 | public bool Store(UserAccountData data) | ||
113 | { | ||
114 | if (data.Data.ContainsKey("UUID")) | ||
115 | data.Data.Remove("UUID"); | ||
116 | if (data.Data.ContainsKey("ScopeID")) | ||
117 | data.Data.Remove("ScopeID"); | ||
118 | |||
119 | string[] fields = new List<string>(data.Data.Keys).ToArray(); | ||
120 | 64 | ||
121 | MySqlCommand cmd = new MySqlCommand(); | 65 | MySqlCommand cmd = new MySqlCommand(); |
122 | 66 | ||
123 | string update = "update `"+m_Realm+"` set "; | 67 | if (words.Length == 1) |
124 | bool first = true; | ||
125 | foreach (string field in fields) | ||
126 | { | 68 | { |
127 | if (!first) | 69 | cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?search or LastName like ?search)", m_Realm); |
128 | update += ", "; | 70 | cmd.Parameters.AddWithValue("?search", "%" + words[0] + "%"); |
129 | update += "`" + field + "` = ?"+field; | 71 | cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); |
130 | |||
131 | first = false; | ||
132 | |||
133 | cmd.Parameters.AddWithValue("?"+field, data.Data[field]); | ||
134 | } | 72 | } |
135 | 73 | else | |
136 | update += " where UUID = ?principalID"; | ||
137 | |||
138 | if (data.ScopeID != UUID.Zero) | ||
139 | update += " and ScopeID = ?scopeID"; | ||
140 | |||
141 | cmd.CommandText = update; | ||
142 | cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); | ||
143 | cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); | ||
144 | |||
145 | if (ExecuteNonQuery(cmd) < 1) | ||
146 | { | 74 | { |
147 | string insert = "insert into `" + m_Realm + "` (`UUID`, `ScopeID`, `" + | 75 | cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst or LastName like ?searchLast)", m_Realm); |
148 | String.Join("`, `", fields) + | 76 | cmd.Parameters.AddWithValue("?searchFirst", "%" + words[0] + "%"); |
149 | "`) values (?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; | 77 | cmd.Parameters.AddWithValue("?searchLast", "%" + words[1] + "%"); |
150 | 78 | cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); | |
151 | cmd.CommandText = insert; | ||
152 | |||
153 | if (ExecuteNonQuery(cmd) < 1) | ||
154 | { | ||
155 | cmd.Dispose(); | ||
156 | return false; | ||
157 | } | ||
158 | } | 79 | } |
159 | 80 | ||
160 | cmd.Dispose(); | 81 | return DoQuery(cmd); |
161 | |||
162 | return true; | ||
163 | } | ||
164 | |||
165 | public bool SetDataItem(UUID principalID, string item, string value) | ||
166 | { | ||
167 | MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + | ||
168 | "` set `" + item + "` = ?" + item + " where UUID = ?UUID"); | ||
169 | |||
170 | |||
171 | cmd.Parameters.AddWithValue("?"+item, value); | ||
172 | cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); | ||
173 | |||
174 | if (ExecuteNonQuery(cmd) > 0) | ||
175 | return true; | ||
176 | |||
177 | return false; | ||
178 | } | 82 | } |
179 | } | 83 | } |
180 | } | 84 | } |
diff --git a/OpenSim/Data/MySQL/Resources/001_Avatar.sql b/OpenSim/Data/MySQL/Resources/001_Avatar.sql new file mode 100644 index 0000000..27a3072 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/001_Avatar.sql | |||
@@ -0,0 +1,5 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | CREATE TABLE Avatars (PrincipalID CHAR(36) NOT NULL, Name VARCHAR(32) NOT NULL, Value VARCHAR(255) NOT NULL DEFAULT '', PRIMARY KEY(PrincipalID, Name), KEY(PrincipalID)); | ||
4 | |||
5 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/001_Friends.sql b/OpenSim/Data/MySQL/Resources/001_Friends.sql new file mode 100644 index 0000000..e158a2c --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/001_Friends.sql | |||
@@ -0,0 +1,9 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | CREATE TABLE `Friends` ( | ||
4 | `PrincipalID` CHAR(36) NOT NULL, | ||
5 | `FriendID` VARCHAR(255) NOT NULL, | ||
6 | `Flags` CHAR(16) NOT NULL DEFAULT '0' | ||
7 | ) ENGINE=InnoDB; | ||
8 | |||
9 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/001_Presence.sql b/OpenSim/Data/MySQL/Resources/001_Presence.sql new file mode 100644 index 0000000..b8abaf7 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/001_Presence.sql | |||
@@ -0,0 +1,15 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | CREATE TABLE `Presence` ( | ||
4 | `UserID` VARCHAR(255) NOT NULL, | ||
5 | `RegionID` CHAR(36) NOT NULL, | ||
6 | `SessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', | ||
7 | `SecureSessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', | ||
8 | `Online` CHAR(5) NOT NULL DEFAULT 'false', | ||
9 | `Login` CHAR(16) NOT NULL DEFAULT '0', | ||
10 | `Logout` CHAR(16) NOT NULL DEFAULT '0', | ||
11 | `Position` CHAR(64) NOT NULL DEFAULT '<0,0,0>', | ||
12 | `LookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>' | ||
13 | ) ENGINE=InnoDB; | ||
14 | |||
15 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/001_UserAccount.sql b/OpenSim/Data/MySQL/Resources/001_UserAccount.sql new file mode 100644 index 0000000..07da571 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/001_UserAccount.sql | |||
@@ -0,0 +1,13 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | CREATE TABLE `UserAccounts` ( | ||
4 | `PrincipalID` CHAR(36) NOT NULL, | ||
5 | `ScopeID` CHAR(36) NOT NULL, | ||
6 | `FirstName` VARCHAR(64) NOT NULL, | ||
7 | `LastName` VARCHAR(64) NOT NULL, | ||
8 | `Email` VARCHAR(64), | ||
9 | `ServiceURLs` TEXT, | ||
10 | `Created` INT(11) | ||
11 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
12 | |||
13 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/002_AuthStore.sql b/OpenSim/Data/MySQL/Resources/002_AuthStore.sql new file mode 100644 index 0000000..dc7dfe0 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/002_AuthStore.sql | |||
@@ -0,0 +1,5 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | INSERT INTO auth (UUID, passwordHash, passwordSalt, webLoginKey) SELECT `UUID` AS UUID, `passwordHash` AS passwordHash, `passwordSalt` AS passwordSalt, `webLoginKey` AS webLoginKey FROM users; | ||
4 | |||
5 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/002_Friends.sql b/OpenSim/Data/MySQL/Resources/002_Friends.sql new file mode 100644 index 0000000..5ff6438 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/002_Friends.sql | |||
@@ -0,0 +1,5 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | INSERT INTO Friends (PrincipalID, FriendID, Flags) SELECT ownerID, friendID, friendPerms FROM userfriends; | ||
4 | |||
5 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/002_Presence.sql b/OpenSim/Data/MySQL/Resources/002_Presence.sql new file mode 100644 index 0000000..e65f105 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/002_Presence.sql | |||
@@ -0,0 +1,7 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | ALTER TABLE Presence ADD COLUMN `HomeRegionID` CHAR(36) NOT NULL; | ||
4 | ALTER TABLE Presence ADD COLUMN `HomePosition` CHAR(64) NOT NULL DEFAULT '<0,0,0>'; | ||
5 | ALTER TABLE Presence ADD COLUMN `HomeLookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>'; | ||
6 | |||
7 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/002_UserAccount.sql b/OpenSim/Data/MySQL/Resources/002_UserAccount.sql new file mode 100644 index 0000000..ad2ddda --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/002_UserAccount.sql | |||
@@ -0,0 +1,5 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | INSERT INTO UserAccounts (PrincipalID, ScopeID, FirstName, LastName, Email, ServiceURLs, Created) SELECT `UUID` AS PrincipalID, '00000000-0000-0000-0000-000000000000' AS ScopeID, username AS FirstName, lastname AS LastName, email as Email, CONCAT('AssetServerURI=', userAssetURI, ' InventoryServerURI=', userInventoryURI, ' GatewayURI= HomeURI=') AS ServiceURLs, created as Created FROM users; | ||
4 | |||
5 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/003_Presence.sql b/OpenSim/Data/MySQL/Resources/003_Presence.sql new file mode 100644 index 0000000..0efefa8 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/003_Presence.sql | |||
@@ -0,0 +1,6 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | CREATE UNIQUE INDEX SessionID ON Presence(SessionID); | ||
4 | CREATE INDEX UserID ON Presence(UserID); | ||
5 | |||
6 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/003_UserAccount.sql b/OpenSim/Data/MySQL/Resources/003_UserAccount.sql new file mode 100644 index 0000000..e42d93b --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/003_UserAccount.sql | |||
@@ -0,0 +1,9 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | CREATE UNIQUE INDEX PrincipalID ON UserAccounts(PrincipalID); | ||
4 | CREATE INDEX Email ON UserAccounts(Email); | ||
5 | CREATE INDEX FirstName ON UserAccounts(FirstName); | ||
6 | CREATE INDEX LastName ON UserAccounts(LastName); | ||
7 | CREATE INDEX Name ON UserAccounts(FirstName,LastName); | ||
8 | |||
9 | COMMIT; | ||
diff --git a/OpenSim/Data/Null/NullPresenceData.cs b/OpenSim/Data/Null/NullPresenceData.cs new file mode 100644 index 0000000..52fdc6f --- /dev/null +++ b/OpenSim/Data/Null/NullPresenceData.cs | |||
@@ -0,0 +1,223 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Data; | ||
34 | |||
35 | namespace OpenSim.Data.Null | ||
36 | { | ||
37 | public class NullPresenceData : IPresenceData | ||
38 | { | ||
39 | Dictionary<UUID, PresenceData> m_presenceData = new Dictionary<UUID, PresenceData>(); | ||
40 | |||
41 | public NullPresenceData(string connectionString, string realm) | ||
42 | { | ||
43 | //Console.WriteLine("[XXX] NullRegionData constructor"); | ||
44 | // Let's stick in a test presence | ||
45 | PresenceData p = new PresenceData(); | ||
46 | p.SessionID = UUID.Zero; | ||
47 | p.UserID = UUID.Zero.ToString(); | ||
48 | p.Data = new Dictionary<string, string>(); | ||
49 | p.Data["Online"] = "true"; | ||
50 | m_presenceData.Add(UUID.Zero, p); | ||
51 | } | ||
52 | |||
53 | public bool Store(PresenceData data) | ||
54 | { | ||
55 | m_presenceData[data.SessionID] = data; | ||
56 | return true; | ||
57 | } | ||
58 | |||
59 | public PresenceData Get(UUID sessionID) | ||
60 | { | ||
61 | if (m_presenceData.ContainsKey(sessionID)) | ||
62 | return m_presenceData[sessionID]; | ||
63 | |||
64 | return null; | ||
65 | } | ||
66 | |||
67 | public void LogoutRegionAgents(UUID regionID) | ||
68 | { | ||
69 | List<UUID> toBeDeleted = new List<UUID>(); | ||
70 | foreach (KeyValuePair<UUID, PresenceData> kvp in m_presenceData) | ||
71 | if (kvp.Value.RegionID == regionID) | ||
72 | toBeDeleted.Add(kvp.Key); | ||
73 | |||
74 | foreach (UUID u in toBeDeleted) | ||
75 | m_presenceData.Remove(u); | ||
76 | } | ||
77 | |||
78 | public bool ReportAgent(UUID sessionID, UUID regionID, string position, string lookAt) | ||
79 | { | ||
80 | if (m_presenceData.ContainsKey(sessionID)) | ||
81 | { | ||
82 | m_presenceData[sessionID].RegionID = regionID; | ||
83 | m_presenceData[sessionID].Data["Position"] = position; | ||
84 | m_presenceData[sessionID].Data["LookAt"] = lookAt; | ||
85 | return true; | ||
86 | } | ||
87 | |||
88 | return false; | ||
89 | } | ||
90 | |||
91 | public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
92 | { | ||
93 | bool foundone = false; | ||
94 | foreach (PresenceData p in m_presenceData.Values) | ||
95 | { | ||
96 | if (p.UserID == userID) | ||
97 | { | ||
98 | p.Data["HomeRegionID"] = regionID.ToString(); | ||
99 | p.Data["HomePosition"] = position.ToString(); | ||
100 | p.Data["HomeLookAt"] = lookAt.ToString(); | ||
101 | foundone = true; | ||
102 | } | ||
103 | } | ||
104 | |||
105 | return foundone; | ||
106 | } | ||
107 | |||
108 | public PresenceData[] Get(string field, string data) | ||
109 | { | ||
110 | List<PresenceData> presences = new List<PresenceData>(); | ||
111 | if (field == "UserID") | ||
112 | { | ||
113 | foreach (PresenceData p in m_presenceData.Values) | ||
114 | if (p.UserID == data) | ||
115 | presences.Add(p); | ||
116 | return presences.ToArray(); | ||
117 | } | ||
118 | else if (field == "SessionID") | ||
119 | { | ||
120 | UUID session = UUID.Zero; | ||
121 | if (!UUID.TryParse(data, out session)) | ||
122 | return presences.ToArray(); | ||
123 | |||
124 | if (m_presenceData.ContainsKey(session)) | ||
125 | { | ||
126 | presences.Add(m_presenceData[session]); | ||
127 | return presences.ToArray(); | ||
128 | } | ||
129 | } | ||
130 | else if (field == "RegionID") | ||
131 | { | ||
132 | UUID region = UUID.Zero; | ||
133 | if (!UUID.TryParse(data, out region)) | ||
134 | return presences.ToArray(); | ||
135 | foreach (PresenceData p in m_presenceData.Values) | ||
136 | if (p.RegionID == region) | ||
137 | presences.Add(p); | ||
138 | return presences.ToArray(); | ||
139 | } | ||
140 | else | ||
141 | { | ||
142 | foreach (PresenceData p in m_presenceData.Values) | ||
143 | { | ||
144 | if (p.Data.ContainsKey(field) && p.Data[field] == data) | ||
145 | presences.Add(p); | ||
146 | } | ||
147 | return presences.ToArray(); | ||
148 | } | ||
149 | |||
150 | return presences.ToArray(); | ||
151 | } | ||
152 | |||
153 | public void Prune(string userID) | ||
154 | { | ||
155 | List<UUID> deleteSessions = new List<UUID>(); | ||
156 | int online = 0; | ||
157 | |||
158 | foreach (KeyValuePair<UUID, PresenceData> kvp in m_presenceData) | ||
159 | { | ||
160 | bool on = false; | ||
161 | if (bool.TryParse(kvp.Value.Data["Online"], out on) && on) | ||
162 | online++; | ||
163 | else | ||
164 | deleteSessions.Add(kvp.Key); | ||
165 | } | ||
166 | if (online == 0 && deleteSessions.Count > 0) | ||
167 | deleteSessions.RemoveAt(0); | ||
168 | |||
169 | foreach (UUID s in deleteSessions) | ||
170 | m_presenceData.Remove(s); | ||
171 | |||
172 | } | ||
173 | |||
174 | public bool Delete(string field, string data) | ||
175 | { | ||
176 | List<UUID> presences = new List<UUID>(); | ||
177 | if (field == "UserID") | ||
178 | { | ||
179 | foreach (KeyValuePair<UUID, PresenceData> p in m_presenceData) | ||
180 | if (p.Value.UserID == data) | ||
181 | presences.Add(p.Key); | ||
182 | } | ||
183 | else if (field == "SessionID") | ||
184 | { | ||
185 | UUID session = UUID.Zero; | ||
186 | if (UUID.TryParse(data, out session)) | ||
187 | { | ||
188 | if (m_presenceData.ContainsKey(session)) | ||
189 | { | ||
190 | presences.Add(session); | ||
191 | } | ||
192 | } | ||
193 | } | ||
194 | else if (field == "RegionID") | ||
195 | { | ||
196 | UUID region = UUID.Zero; | ||
197 | if (UUID.TryParse(data, out region)) | ||
198 | { | ||
199 | foreach (KeyValuePair<UUID, PresenceData> p in m_presenceData) | ||
200 | if (p.Value.RegionID == region) | ||
201 | presences.Add(p.Key); | ||
202 | } | ||
203 | } | ||
204 | else | ||
205 | { | ||
206 | foreach (KeyValuePair<UUID, PresenceData> p in m_presenceData) | ||
207 | { | ||
208 | if (p.Value.Data.ContainsKey(field) && p.Value.Data[field] == data) | ||
209 | presences.Add(p.Key); | ||
210 | } | ||
211 | } | ||
212 | |||
213 | foreach (UUID u in presences) | ||
214 | m_presenceData.Remove(u); | ||
215 | |||
216 | if (presences.Count == 0) | ||
217 | return false; | ||
218 | |||
219 | return true; | ||
220 | } | ||
221 | |||
222 | } | ||
223 | } | ||
diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs index 5ceaf39..ee7dec8 100644 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs | |||
@@ -83,7 +83,7 @@ namespace OpenSim.Framework.Communications.Clients | |||
83 | } | 83 | } |
84 | // Add the regionhandle of the destination region | 84 | // Add the regionhandle of the destination region |
85 | ulong regionHandle = GetRegionHandle(region.RegionHandle); | 85 | ulong regionHandle = GetRegionHandle(region.RegionHandle); |
86 | args["destination_handle"] = OSD.FromString(regionHandle.ToString()); | 86 | args["destination_handle"] = OSD.FromString(regionHandle.ToString()); |
87 | args["teleport_flags"] = OSD.FromString(teleportFlags.ToString()); | 87 | args["teleport_flags"] = OSD.FromString(teleportFlags.ToString()); |
88 | 88 | ||
89 | string strBuffer = ""; | 89 | string strBuffer = ""; |
diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs index 8067052..27b3d47 100644 --- a/OpenSim/Framework/IScene.cs +++ b/OpenSim/Framework/IScene.cs | |||
@@ -66,6 +66,8 @@ namespace OpenSim.Framework | |||
66 | 66 | ||
67 | float TimeDilation { get; } | 67 | float TimeDilation { get; } |
68 | 68 | ||
69 | bool AllowScriptCrossings { get; } | ||
70 | |||
69 | event restart OnRestart; | 71 | event restart OnRestart; |
70 | 72 | ||
71 | void AddNewClient(IClientAPI client); | 73 | void AddNewClient(IClientAPI client); |
@@ -96,5 +98,7 @@ namespace OpenSim.Framework | |||
96 | void StackModuleInterface<M>(M mod); | 98 | void StackModuleInterface<M>(M mod); |
97 | 99 | ||
98 | void AddCommand(object module, string command, string shorthelp, string longhelp, CommandDelegate callback); | 100 | void AddCommand(object module, string command, string shorthelp, string longhelp, CommandDelegate callback); |
101 | |||
102 | ISceneObject DeserializeObject(string representation); | ||
99 | } | 103 | } |
100 | } | 104 | } |
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 7215086..234021c 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -1186,6 +1186,33 @@ namespace OpenSim.Framework | |||
1186 | return null; | 1186 | return null; |
1187 | } | 1187 | } |
1188 | 1188 | ||
1189 | public static OSDMap GetOSDMap(string data) | ||
1190 | { | ||
1191 | OSDMap args = null; | ||
1192 | try | ||
1193 | { | ||
1194 | OSD buffer; | ||
1195 | // We should pay attention to the content-type, but let's assume we know it's Json | ||
1196 | buffer = OSDParser.DeserializeJson(data); | ||
1197 | if (buffer.Type == OSDType.Map) | ||
1198 | { | ||
1199 | args = (OSDMap)buffer; | ||
1200 | return args; | ||
1201 | } | ||
1202 | else | ||
1203 | { | ||
1204 | // uh? | ||
1205 | m_log.Debug(("[UTILS]: Got OSD of unexpected type " + buffer.Type.ToString())); | ||
1206 | return null; | ||
1207 | } | ||
1208 | } | ||
1209 | catch (Exception ex) | ||
1210 | { | ||
1211 | m_log.Debug("[UTILS]: exception on GetOSDMap " + ex.Message); | ||
1212 | return null; | ||
1213 | } | ||
1214 | } | ||
1215 | |||
1189 | public static string[] Glob(string path) | 1216 | public static string[] Glob(string path) |
1190 | { | 1217 | { |
1191 | string vol=String.Empty; | 1218 | string vol=String.Empty; |
diff --git a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs b/OpenSim/Grid/UserServer.Modules/UserLoginService.cs index d46ff9b..fb808ca 100644 --- a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs +++ b/OpenSim/Grid/UserServer.Modules/UserLoginService.cs | |||
@@ -39,6 +39,7 @@ using OpenSim.Data; | |||
39 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
40 | using OpenSim.Framework.Communications; | 40 | using OpenSim.Framework.Communications; |
41 | using OpenSim.Framework.Communications.Services; | 41 | using OpenSim.Framework.Communications.Services; |
42 | using LoginResponse = OpenSim.Framework.Communications.Services.LoginResponse; | ||
42 | using OpenSim.Framework.Communications.Cache; | 43 | using OpenSim.Framework.Communications.Cache; |
43 | using OpenSim.Framework.Capabilities; | 44 | using OpenSim.Framework.Capabilities; |
44 | using OpenSim.Framework.Servers; | 45 | using OpenSim.Framework.Servers; |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 9944852..3a802df 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | |||
@@ -6962,7 +6962,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6962 | assetRequestItem = invService.GetItem(assetRequestItem); | 6962 | assetRequestItem = invService.GetItem(assetRequestItem); |
6963 | if (assetRequestItem == null) | 6963 | if (assetRequestItem == null) |
6964 | { | 6964 | { |
6965 | assetRequestItem = ((Scene)m_scene).CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); | 6965 | ILibraryService lib = m_scene.RequestModuleInterface<ILibraryService>(); |
6966 | if (lib != null) | ||
6967 | assetRequestItem = lib.LibraryRootFolder.FindItem(itemID); | ||
6966 | if (assetRequestItem == null) | 6968 | if (assetRequestItem == null) |
6967 | return true; | 6969 | return true; |
6968 | } | 6970 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index a4a649c..123e2dd 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -44,1111 +44,49 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
44 | 44 | ||
45 | namespace OpenSim.Region.CoreModules.Avatar.Friends | 45 | namespace OpenSim.Region.CoreModules.Avatar.Friends |
46 | { | 46 | { |
47 | /* | 47 | public class FriendsModule : ISharedRegionModule, IFriendsModule |
48 | This module handles adding/removing friends, and the the presence | ||
49 | notification process for login/logoff of friends. | ||
50 | |||
51 | The presence notification works as follows: | ||
52 | - After the user initially connects to a region (so we now have a UDP | ||
53 | connection to work with), this module fetches the friends of user | ||
54 | (those are cached), their on-/offline status, and info about the | ||
55 | region they are in from the MessageServer. | ||
56 | - (*) It then informs the user about the on-/offline status of her friends. | ||
57 | - It then informs all online friends currently on this region-server about | ||
58 | user's new online status (this will save some network traffic, as local | ||
59 | messages don't have to be transferred inter-region, and it will be all | ||
60 | that has to be done in Standalone Mode). | ||
61 | - For the rest of the online friends (those not on this region-server), | ||
62 | this module uses the provided region-information to map users to | ||
63 | regions, and sends one notification to every region containing the | ||
64 | friends to inform on that server. | ||
65 | - The region-server will handle that in the following way: | ||
66 | - If it finds the friend, it informs her about the user being online. | ||
67 | - If it doesn't find the friend (maybe she TPed away in the meantime), | ||
68 | it stores that information. | ||
69 | - After it processed all friends, it returns the list of friends it | ||
70 | couldn't find. | ||
71 | - If this list isn't empty, the FriendsModule re-requests information | ||
72 | about those online friends that have been missed and starts at (*) | ||
73 | again until all friends have been found, or until it tried 3 times | ||
74 | (to prevent endless loops due to some uncaught error). | ||
75 | |||
76 | NOTE: Online/Offline notifications don't need to be sent on region change. | ||
77 | |||
78 | We implement two XMLRpc handlers here, handling all the inter-region things | ||
79 | we have to handle: | ||
80 | - On-/Offline-Notifications (bulk) | ||
81 | - Terminate Friendship messages (single) | ||
82 | */ | ||
83 | |||
84 | public class FriendsModule : IRegionModule, IFriendsModule | ||
85 | { | 48 | { |
86 | private class Transaction | 49 | public void Initialise(IConfigSource config) |
87 | { | 50 | { |
88 | public UUID agentID; | ||
89 | public string agentName; | ||
90 | public uint count; | ||
91 | |||
92 | public Transaction(UUID agentID, string agentName) | ||
93 | { | ||
94 | this.agentID = agentID; | ||
95 | this.agentName = agentName; | ||
96 | this.count = 1; | ||
97 | } | ||
98 | } | ||
99 | |||
100 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
101 | |||
102 | private Cache m_friendLists = new Cache(CacheFlags.AllowUpdate); | ||
103 | |||
104 | private Dictionary<UUID, ulong> m_rootAgents = new Dictionary<UUID, ulong>(); | ||
105 | |||
106 | private Dictionary<UUID, UUID> m_pendingCallingcardRequests = new Dictionary<UUID,UUID>(); | ||
107 | |||
108 | private Scene m_initialScene; // saves a lookup if we don't have a specific scene | ||
109 | private Dictionary<ulong, Scene> m_scenes = new Dictionary<ulong,Scene>(); | ||
110 | private IMessageTransferModule m_TransferModule = null; | ||
111 | |||
112 | private IGridService m_gridServices = null; | ||
113 | |||
114 | #region IRegionModule Members | ||
115 | |||
116 | public void Initialise(Scene scene, IConfigSource config) | ||
117 | { | ||
118 | lock (m_scenes) | ||
119 | { | ||
120 | if (m_scenes.Count == 0) | ||
121 | { | ||
122 | MainServer.Instance.AddXmlRPCHandler("presence_update_bulk", processPresenceUpdateBulk); | ||
123 | MainServer.Instance.AddXmlRPCHandler("terminate_friend", processTerminateFriend); | ||
124 | m_friendLists.DefaultTTL = new TimeSpan(1, 0, 0); // store entries for one hour max | ||
125 | m_initialScene = scene; | ||
126 | } | ||
127 | |||
128 | if (!m_scenes.ContainsKey(scene.RegionInfo.RegionHandle)) | ||
129 | m_scenes[scene.RegionInfo.RegionHandle] = scene; | ||
130 | } | ||
131 | |||
132 | scene.RegisterModuleInterface<IFriendsModule>(this); | ||
133 | |||
134 | scene.EventManager.OnNewClient += OnNewClient; | ||
135 | scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; | ||
136 | scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; | ||
137 | scene.EventManager.OnMakeChildAgent += MakeChildAgent; | ||
138 | scene.EventManager.OnClientClosed += ClientClosed; | ||
139 | } | 51 | } |
140 | 52 | ||
141 | public void PostInitialise() | 53 | public void PostInitialise() |
142 | { | 54 | { |
143 | if (m_scenes.Count > 0) | ||
144 | { | ||
145 | m_TransferModule = m_initialScene.RequestModuleInterface<IMessageTransferModule>(); | ||
146 | m_gridServices = m_initialScene.GridService; | ||
147 | } | ||
148 | if (m_TransferModule == null) | ||
149 | m_log.Error("[FRIENDS]: Unable to find a message transfer module, friendship offers will not work"); | ||
150 | } | 55 | } |
151 | 56 | ||
152 | public void Close() | 57 | public void Close() |
153 | { | 58 | { |
154 | } | 59 | } |
155 | 60 | ||
156 | public string Name | 61 | public void AddRegion(Scene scene) |
157 | { | ||
158 | get { return "FriendsModule"; } | ||
159 | } | ||
160 | |||
161 | public bool IsSharedModule | ||
162 | { | ||
163 | get { return true; } | ||
164 | } | ||
165 | |||
166 | #endregion | ||
167 | |||
168 | #region IInterregionFriendsComms | ||
169 | |||
170 | public List<UUID> InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List<UUID> friends, bool online) | ||
171 | { | 62 | { |
172 | List<UUID> tpdAway = new List<UUID>(); | ||
173 | |||
174 | // destRegionHandle is a region on another server | ||
175 | uint x = 0, y = 0; | ||
176 | Utils.LongToUInts(destRegionHandle, out x, out y); | ||
177 | GridRegion info = m_gridServices.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, (int)x, (int)y); | ||
178 | if (info != null) | ||
179 | { | ||
180 | string httpServer = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/presence_update_bulk"; | ||
181 | |||
182 | Hashtable reqParams = new Hashtable(); | ||
183 | reqParams["agentID"] = agentId.ToString(); | ||
184 | reqParams["agentOnline"] = online; | ||
185 | int count = 0; | ||
186 | foreach (UUID uuid in friends) | ||
187 | { | ||
188 | reqParams["friendID_" + count++] = uuid.ToString(); | ||
189 | } | ||
190 | reqParams["friendCount"] = count; | ||
191 | |||
192 | IList parameters = new ArrayList(); | ||
193 | parameters.Add(reqParams); | ||
194 | try | ||
195 | { | ||
196 | XmlRpcRequest request = new XmlRpcRequest("presence_update_bulk", parameters); | ||
197 | XmlRpcResponse response = request.Send(httpServer, 5000); | ||
198 | Hashtable respData = (Hashtable)response.Value; | ||
199 | |||
200 | count = (int)respData["friendCount"]; | ||
201 | for (int i = 0; i < count; ++i) | ||
202 | { | ||
203 | UUID uuid; | ||
204 | if (UUID.TryParse((string)respData["friendID_" + i], out uuid)) tpdAway.Add(uuid); | ||
205 | } | ||
206 | } | ||
207 | catch (WebException e) | ||
208 | { | ||
209 | // Ignore connect failures, simulators come and go | ||
210 | // | ||
211 | if (!e.Message.Contains("ConnectFailure")) | ||
212 | { | ||
213 | m_log.Error("[OGS1 GRID SERVICES]: InformFriendsInOtherRegion XMLRPC failure: ", e); | ||
214 | } | ||
215 | } | ||
216 | catch (Exception e) | ||
217 | { | ||
218 | m_log.Error("[OGS1 GRID SERVICES]: InformFriendsInOtherRegion XMLRPC failure: ", e); | ||
219 | } | ||
220 | } | ||
221 | else m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}???", destRegionHandle); | ||
222 | |||
223 | return tpdAway; | ||
224 | } | 63 | } |
225 | 64 | ||
226 | public bool TriggerTerminateFriend(ulong destRegionHandle, UUID agentID, UUID exFriendID) | 65 | public void RegionLoaded(Scene scene) |
227 | { | 66 | { |
228 | // destRegionHandle is a region on another server | ||
229 | uint x = 0, y = 0; | ||
230 | Utils.LongToUInts(destRegionHandle, out x, out y); | ||
231 | GridRegion info = m_gridServices.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, (int)x, (int)y); | ||
232 | if (info == null) | ||
233 | { | ||
234 | m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}", destRegionHandle); | ||
235 | return false; // region not found??? | ||
236 | } | ||
237 | |||
238 | string httpServer = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/presence_update_bulk"; | ||
239 | |||
240 | Hashtable reqParams = new Hashtable(); | ||
241 | reqParams["agentID"] = agentID.ToString(); | ||
242 | reqParams["friendID"] = exFriendID.ToString(); | ||
243 | |||
244 | IList parameters = new ArrayList(); | ||
245 | parameters.Add(reqParams); | ||
246 | try | ||
247 | { | ||
248 | XmlRpcRequest request = new XmlRpcRequest("terminate_friend", parameters); | ||
249 | XmlRpcResponse response = request.Send(httpServer, 5000); | ||
250 | Hashtable respData = (Hashtable)response.Value; | ||
251 | |||
252 | return (bool)respData["success"]; | ||
253 | } | ||
254 | catch (Exception e) | ||
255 | { | ||
256 | m_log.Error("[OGS1 GRID SERVICES]: InformFriendsInOtherRegion XMLRPC failure: ", e); | ||
257 | return false; | ||
258 | } | ||
259 | } | 67 | } |
260 | 68 | ||
261 | #endregion | 69 | public void RemoveRegion(Scene scene) |
262 | |||
263 | #region Incoming XMLRPC messages | ||
264 | /// <summary> | ||
265 | /// Receive presence information changes about clients in other regions. | ||
266 | /// </summary> | ||
267 | /// <param name="req"></param> | ||
268 | /// <returns></returns> | ||
269 | public XmlRpcResponse processPresenceUpdateBulk(XmlRpcRequest req, IPEndPoint remoteClient) | ||
270 | { | 70 | { |
271 | Hashtable requestData = (Hashtable)req.Params[0]; | ||
272 | |||
273 | List<UUID> friendsNotHere = new List<UUID>(); | ||
274 | |||
275 | // this is called with the expectation that all the friends in the request are on this region-server. | ||
276 | // But as some time passed since we checked (on the other region-server, via the MessagingServer), | ||
277 | // some of the friends might have teleported away. | ||
278 | // Actually, even now, between this line and the sending below, some people could TP away. So, | ||
279 | // we'll have to lock the m_rootAgents list for the duration to prevent/delay that. | ||
280 | lock (m_rootAgents) | ||
281 | { | ||
282 | List<ScenePresence> friendsHere = new List<ScenePresence>(); | ||
283 | |||
284 | try | ||
285 | { | ||
286 | UUID agentID = new UUID((string)requestData["agentID"]); | ||
287 | bool agentOnline = (bool)requestData["agentOnline"]; | ||
288 | int count = (int)requestData["friendCount"]; | ||
289 | for (int i = 0; i < count; ++i) | ||
290 | { | ||
291 | UUID uuid; | ||
292 | if (UUID.TryParse((string)requestData["friendID_" + i], out uuid)) | ||
293 | { | ||
294 | if (m_rootAgents.ContainsKey(uuid)) friendsHere.Add(GetRootPresenceFromAgentID(uuid)); | ||
295 | else friendsNotHere.Add(uuid); | ||
296 | } | ||
297 | } | ||
298 | |||
299 | // now send, as long as they are still here... | ||
300 | UUID[] agentUUID = new UUID[] { agentID }; | ||
301 | if (agentOnline) | ||
302 | { | ||
303 | foreach (ScenePresence agent in friendsHere) | ||
304 | { | ||
305 | agent.ControllingClient.SendAgentOnline(agentUUID); | ||
306 | } | ||
307 | } | ||
308 | else | ||
309 | { | ||
310 | foreach (ScenePresence agent in friendsHere) | ||
311 | { | ||
312 | agent.ControllingClient.SendAgentOffline(agentUUID); | ||
313 | } | ||
314 | } | ||
315 | } | ||
316 | catch(Exception e) | ||
317 | { | ||
318 | m_log.Warn("[FRIENDS]: Got exception while parsing presence_update_bulk request:", e); | ||
319 | } | ||
320 | } | ||
321 | |||
322 | // no need to lock anymore; if TPs happen now, worst case is that we have an additional agent in this region, | ||
323 | // which should be caught on the next iteration... | ||
324 | Hashtable result = new Hashtable(); | ||
325 | int idx = 0; | ||
326 | foreach (UUID uuid in friendsNotHere) | ||
327 | { | ||
328 | result["friendID_" + idx++] = uuid.ToString(); | ||
329 | } | ||
330 | result["friendCount"] = idx; | ||
331 | |||
332 | XmlRpcResponse response = new XmlRpcResponse(); | ||
333 | response.Value = result; | ||
334 | |||
335 | return response; | ||
336 | } | 71 | } |
337 | 72 | ||
338 | public XmlRpcResponse processTerminateFriend(XmlRpcRequest req, IPEndPoint remoteClient) | 73 | public string Name |
339 | { | ||
340 | Hashtable requestData = (Hashtable)req.Params[0]; | ||
341 | |||
342 | bool success = false; | ||
343 | |||
344 | UUID agentID; | ||
345 | UUID friendID; | ||
346 | if (requestData.ContainsKey("agentID") && UUID.TryParse((string)requestData["agentID"], out agentID) && | ||
347 | requestData.ContainsKey("friendID") && UUID.TryParse((string)requestData["friendID"], out friendID)) | ||
348 | { | ||
349 | // try to find it and if it is there, prevent it to vanish before we sent the message | ||
350 | lock (m_rootAgents) | ||
351 | { | ||
352 | if (m_rootAgents.ContainsKey(agentID)) | ||
353 | { | ||
354 | m_log.DebugFormat("[FRIEND]: Sending terminate friend {0} to agent {1}", friendID, agentID); | ||
355 | GetRootPresenceFromAgentID(agentID).ControllingClient.SendTerminateFriend(friendID); | ||
356 | success = true; | ||
357 | } | ||
358 | } | ||
359 | } | ||
360 | |||
361 | // return whether we were successful | ||
362 | Hashtable result = new Hashtable(); | ||
363 | result["success"] = success; | ||
364 | |||
365 | XmlRpcResponse response = new XmlRpcResponse(); | ||
366 | response.Value = result; | ||
367 | return response; | ||
368 | } | ||
369 | |||
370 | #endregion | ||
371 | |||
372 | #region Scene events | ||
373 | |||
374 | private void OnNewClient(IClientAPI client) | ||
375 | { | ||
376 | // All friends establishment protocol goes over instant message | ||
377 | // There's no way to send a message from the sim | ||
378 | // to a user to 'add a friend' without causing dialog box spam | ||
379 | |||
380 | // Subscribe to instant messages | ||
381 | client.OnInstantMessage += OnInstantMessage; | ||
382 | |||
383 | // Friend list management | ||
384 | client.OnApproveFriendRequest += OnApproveFriendRequest; | ||
385 | client.OnDenyFriendRequest += OnDenyFriendRequest; | ||
386 | client.OnTerminateFriendship += OnTerminateFriendship; | ||
387 | |||
388 | // ... calling card handling... | ||
389 | client.OnOfferCallingCard += OnOfferCallingCard; | ||
390 | client.OnAcceptCallingCard += OnAcceptCallingCard; | ||
391 | client.OnDeclineCallingCard += OnDeclineCallingCard; | ||
392 | |||
393 | // we need this one exactly once per agent session (see comments in the handler below) | ||
394 | client.OnEconomyDataRequest += OnEconomyDataRequest; | ||
395 | |||
396 | // if it leaves, we want to know, too | ||
397 | client.OnLogout += OnLogout; | ||
398 | |||
399 | client.OnGrantUserRights += GrantUserFriendRights; | ||
400 | client.OnTrackAgentEvent += FindAgent; | ||
401 | client.OnFindAgentEvent += FindAgent; | ||
402 | |||
403 | } | ||
404 | |||
405 | private void ClientClosed(UUID AgentId, Scene scene) | ||
406 | { | ||
407 | // agent's client was closed. As we handle logout in OnLogout, this here has only to handle | ||
408 | // TPing away (root agent is closed) or TPing/crossing in a region far enough away (client | ||
409 | // agent is closed). | ||
410 | // NOTE: In general, this doesn't mean that the agent logged out, just that it isn't around | ||
411 | // in one of the regions here anymore. | ||
412 | lock (m_rootAgents) | ||
413 | { | ||
414 | if (m_rootAgents.ContainsKey(AgentId)) | ||
415 | { | ||
416 | m_rootAgents.Remove(AgentId); | ||
417 | } | ||
418 | } | ||
419 | } | ||
420 | |||
421 | private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID) | ||
422 | { | ||
423 | lock (m_rootAgents) | ||
424 | { | ||
425 | m_rootAgents[avatar.UUID] = avatar.RegionHandle; | ||
426 | // Claim User! my user! Mine mine mine! | ||
427 | } | ||
428 | } | ||
429 | |||
430 | private void MakeChildAgent(ScenePresence avatar) | ||
431 | { | 74 | { |
432 | lock (m_rootAgents) | 75 | get { return "FriendsModule"; } |
433 | { | ||
434 | if (m_rootAgents.ContainsKey(avatar.UUID)) | ||
435 | { | ||
436 | // only delete if the region matches. As this is a shared module, the avatar could be | ||
437 | // root agent in another region on this server. | ||
438 | if (m_rootAgents[avatar.UUID] == avatar.RegionHandle) | ||
439 | { | ||
440 | m_rootAgents.Remove(avatar.UUID); | ||
441 | // m_log.Debug("[FRIEND]: Removing " + avatar.Firstname + " " + avatar.Lastname + " as a root agent"); | ||
442 | } | ||
443 | } | ||
444 | } | ||
445 | } | 76 | } |
446 | #endregion | ||
447 | 77 | ||
448 | private ScenePresence GetRootPresenceFromAgentID(UUID AgentID) | 78 | public Type ReplaceableInterface |
449 | { | 79 | { |
450 | ScenePresence returnAgent = null; | 80 | get { return null; } |
451 | lock (m_scenes) | ||
452 | { | ||
453 | ScenePresence queryagent = null; | ||
454 | foreach (Scene scene in m_scenes.Values) | ||
455 | { | ||
456 | queryagent = scene.GetScenePresence(AgentID); | ||
457 | if (queryagent != null) | ||
458 | { | ||
459 | if (!queryagent.IsChildAgent) | ||
460 | { | ||
461 | returnAgent = queryagent; | ||
462 | break; | ||
463 | } | ||
464 | } | ||
465 | } | ||
466 | } | ||
467 | return returnAgent; | ||
468 | } | 81 | } |
469 | 82 | ||
470 | private ScenePresence GetAnyPresenceFromAgentID(UUID AgentID) | ||
471 | { | ||
472 | ScenePresence returnAgent = null; | ||
473 | lock (m_scenes) | ||
474 | { | ||
475 | ScenePresence queryagent = null; | ||
476 | foreach (Scene scene in m_scenes.Values) | ||
477 | { | ||
478 | queryagent = scene.GetScenePresence(AgentID); | ||
479 | if (queryagent != null) | ||
480 | { | ||
481 | returnAgent = queryagent; | ||
482 | break; | ||
483 | } | ||
484 | } | ||
485 | } | ||
486 | return returnAgent; | ||
487 | } | ||
488 | |||
489 | public void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, string offerMessage) | 83 | public void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, string offerMessage) |
490 | { | 84 | { |
491 | CachedUserInfo userInfo = m_initialScene.CommsManager.UserProfileCacheService.GetUserDetails(fromUserId); | ||
492 | |||
493 | if (userInfo != null) | ||
494 | { | ||
495 | GridInstantMessage msg = new GridInstantMessage( | ||
496 | toUserClient.Scene, fromUserId, userInfo.UserProfile.Name, toUserClient.AgentId, | ||
497 | (byte)InstantMessageDialog.FriendshipOffered, offerMessage, false, Vector3.Zero); | ||
498 | |||
499 | FriendshipOffered(msg); | ||
500 | } | ||
501 | else | ||
502 | { | ||
503 | m_log.ErrorFormat("[FRIENDS]: No user found for id {0} in OfferFriendship()", fromUserId); | ||
504 | } | ||
505 | } | ||
506 | |||
507 | #region FriendRequestHandling | ||
508 | |||
509 | private void OnInstantMessage(IClientAPI client, GridInstantMessage im) | ||
510 | { | ||
511 | // Friend Requests go by Instant Message.. using the dialog param | ||
512 | // https://wiki.secondlife.com/wiki/ImprovedInstantMessage | ||
513 | |||
514 | if (im.dialog == (byte)InstantMessageDialog.FriendshipOffered) // 38 | ||
515 | { | ||
516 | // fromAgentName is the *destination* name (the friend we offer friendship to) | ||
517 | ScenePresence initiator = GetAnyPresenceFromAgentID(new UUID(im.fromAgentID)); | ||
518 | im.fromAgentName = initiator != null ? initiator.Name : "(hippo)"; | ||
519 | |||
520 | FriendshipOffered(im); | ||
521 | } | ||
522 | else if (im.dialog == (byte)InstantMessageDialog.FriendshipAccepted) // 39 | ||
523 | { | ||
524 | FriendshipAccepted(client, im); | ||
525 | } | ||
526 | else if (im.dialog == (byte)InstantMessageDialog.FriendshipDeclined) // 40 | ||
527 | { | ||
528 | FriendshipDeclined(client, im); | ||
529 | } | ||
530 | } | ||
531 | |||
532 | /// <summary> | ||
533 | /// Invoked when a user offers a friendship. | ||
534 | /// </summary> | ||
535 | /// | ||
536 | /// <param name="im"></param> | ||
537 | /// <param name="client"></param> | ||
538 | private void FriendshipOffered(GridInstantMessage im) | ||
539 | { | ||
540 | // this is triggered by the initiating agent: | ||
541 | // A local agent offers friendship to some possibly remote friend. | ||
542 | // A IM is triggered, processed here and sent to the friend (possibly in a remote region). | ||
543 | |||
544 | m_log.DebugFormat("[FRIEND]: Offer(38) - From: {0}, FromName: {1} To: {2}, Session: {3}, Message: {4}, Offline {5}", | ||
545 | im.fromAgentID, im.fromAgentName, im.toAgentID, im.imSessionID, im.message, im.offline); | ||
546 | |||
547 | // 1.20 protocol sends an UUID in the message field, instead of the friendship offer text. | ||
548 | // For interoperability, we have to clear that | ||
549 | if (Util.isUUID(im.message)) im.message = ""; | ||
550 | |||
551 | // be sneeky and use the initiator-UUID as transactionID. This means we can be stateless. | ||
552 | // we have to look up the agent name on friendship-approval, though. | ||
553 | im.imSessionID = im.fromAgentID; | ||
554 | |||
555 | if (m_TransferModule != null) | ||
556 | { | ||
557 | // Send it to whoever is the destination. | ||
558 | // If new friend is local, it will send an IM to the viewer. | ||
559 | // If new friend is remote, it will cause a OnGridInstantMessage on the remote server | ||
560 | m_TransferModule.SendInstantMessage( | ||
561 | im, | ||
562 | delegate(bool success) | ||
563 | { | ||
564 | m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success); | ||
565 | } | ||
566 | ); | ||
567 | } | ||
568 | } | ||
569 | |||
570 | /// <summary> | ||
571 | /// Invoked when a user accepts a friendship offer. | ||
572 | /// </summary> | ||
573 | /// <param name="im"></param> | ||
574 | /// <param name="client"></param> | ||
575 | private void FriendshipAccepted(IClientAPI client, GridInstantMessage im) | ||
576 | { | ||
577 | m_log.DebugFormat("[FRIEND]: 39 - from client {0}, agent {2} {3}, imsession {4} to {5}: {6} (dialog {7})", | ||
578 | client.AgentId, im.fromAgentID, im.fromAgentName, im.imSessionID, im.toAgentID, im.message, im.dialog); | ||
579 | } | ||
580 | |||
581 | /// <summary> | ||
582 | /// Invoked when a user declines a friendship offer. | ||
583 | /// </summary> | ||
584 | /// May not currently be used - see OnDenyFriendRequest() instead | ||
585 | /// <param name="im"></param> | ||
586 | /// <param name="client"></param> | ||
587 | private void FriendshipDeclined(IClientAPI client, GridInstantMessage im) | ||
588 | { | ||
589 | UUID fromAgentID = new UUID(im.fromAgentID); | ||
590 | UUID toAgentID = new UUID(im.toAgentID); | ||
591 | |||
592 | // declining the friendship offer causes a type 40 IM being sent to the (possibly remote) initiator | ||
593 | // toAgentID is initiator, fromAgentID declined friendship | ||
594 | m_log.DebugFormat("[FRIEND]: 40 - from client {0}, agent {1} {2}, imsession {3} to {4}: {5} (dialog {6})", | ||
595 | client != null ? client.AgentId.ToString() : "<null>", | ||
596 | fromAgentID, im.fromAgentName, im.imSessionID, im.toAgentID, im.message, im.dialog); | ||
597 | |||
598 | // Send the decline to whoever is the destination. | ||
599 | GridInstantMessage msg | ||
600 | = new GridInstantMessage( | ||
601 | client.Scene, fromAgentID, client.Name, toAgentID, | ||
602 | im.dialog, im.message, im.offline != 0, im.Position); | ||
603 | |||
604 | // If new friend is local, it will send an IM to the viewer. | ||
605 | // If new friend is remote, it will cause a OnGridInstantMessage on the remote server | ||
606 | m_TransferModule.SendInstantMessage(msg, | ||
607 | delegate(bool success) { | ||
608 | m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success); | ||
609 | } | ||
610 | ); | ||
611 | } | ||
612 | |||
613 | private void OnGridInstantMessage(GridInstantMessage msg) | ||
614 | { | ||
615 | // This event won't be raised unless we have that agent, | ||
616 | // so we can depend on the above not trying to send | ||
617 | // via grid again | ||
618 | //m_log.DebugFormat("[FRIEND]: Got GridIM from {0}, to {1}, imSession {2}, message {3}, dialog {4}", | ||
619 | // msg.fromAgentID, msg.toAgentID, msg.imSessionID, msg.message, msg.dialog); | ||
620 | |||
621 | if (msg.dialog == (byte)InstantMessageDialog.FriendshipOffered || | ||
622 | msg.dialog == (byte)InstantMessageDialog.FriendshipAccepted || | ||
623 | msg.dialog == (byte)InstantMessageDialog.FriendshipDeclined) | ||
624 | { | ||
625 | // this should succeed as we *know* the root agent is here. | ||
626 | m_TransferModule.SendInstantMessage(msg, | ||
627 | delegate(bool success) { | ||
628 | //m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success); | ||
629 | } | ||
630 | ); | ||
631 | } | ||
632 | |||
633 | if (msg.dialog == (byte)InstantMessageDialog.FriendshipAccepted) | ||
634 | { | ||
635 | // for accept friendship, we have to do a bit more | ||
636 | ApproveFriendship(new UUID(msg.fromAgentID), new UUID(msg.toAgentID), msg.fromAgentName); | ||
637 | } | ||
638 | } | ||
639 | |||
640 | private void ApproveFriendship(UUID fromAgentID, UUID toAgentID, string fromName) | ||
641 | { | ||
642 | m_log.DebugFormat("[FRIEND]: Approve friendship from {0} (ID: {1}) to {2}", | ||
643 | fromAgentID, fromName, toAgentID); | ||
644 | |||
645 | // a new friend was added in the initiator's and friend's data, so the cache entries are wrong now. | ||
646 | lock (m_friendLists) | ||
647 | { | ||
648 | m_friendLists.Invalidate(fromAgentID.ToString()); | ||
649 | m_friendLists.Invalidate(toAgentID.ToString()); | ||
650 | } | ||
651 | |||
652 | // now send presence update and add a calling card for the new friend | ||
653 | |||
654 | ScenePresence initiator = GetAnyPresenceFromAgentID(toAgentID); | ||
655 | if (initiator == null) | ||
656 | { | ||
657 | // quite wrong. Shouldn't happen. | ||
658 | m_log.WarnFormat("[FRIEND]: Coudn't find initiator of friend request {0}", toAgentID); | ||
659 | return; | ||
660 | } | ||
661 | |||
662 | m_log.DebugFormat("[FRIEND]: Tell {0} that {1} is online", | ||
663 | initiator.Name, fromName); | ||
664 | // tell initiator that friend is online | ||
665 | initiator.ControllingClient.SendAgentOnline(new UUID[] { fromAgentID }); | ||
666 | |||
667 | // find the folder for the friend... | ||
668 | //InventoryFolderImpl folder = | ||
669 | // initiator.Scene.CommsManager.UserProfileCacheService.GetUserDetails(toAgentID).FindFolderForType((int)InventoryType.CallingCard); | ||
670 | IInventoryService invService = initiator.Scene.InventoryService; | ||
671 | InventoryFolderBase folder = invService.GetFolderForType(toAgentID, AssetType.CallingCard); | ||
672 | if (folder != null) | ||
673 | { | ||
674 | // ... and add the calling card | ||
675 | CreateCallingCard(initiator.ControllingClient, fromAgentID, folder.ID, fromName); | ||
676 | } | ||
677 | } | ||
678 | |||
679 | private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders) | ||
680 | { | ||
681 | m_log.DebugFormat("[FRIEND]: Got approve friendship from {0} {1}, agentID {2}, tid {3}", | ||
682 | client.Name, client.AgentId, agentID, friendID); | ||
683 | |||
684 | // store the new friend persistently for both avatars | ||
685 | m_initialScene.StoreAddFriendship(friendID, agentID, (uint) FriendRights.CanSeeOnline); | ||
686 | |||
687 | // The cache entries aren't valid anymore either, as we just added a friend to both sides. | ||
688 | lock (m_friendLists) | ||
689 | { | ||
690 | m_friendLists.Invalidate(agentID.ToString()); | ||
691 | m_friendLists.Invalidate(friendID.ToString()); | ||
692 | } | ||
693 | |||
694 | // if it's a local friend, we don't have to do the lookup | ||
695 | ScenePresence friendPresence = GetAnyPresenceFromAgentID(friendID); | ||
696 | |||
697 | if (friendPresence != null) | ||
698 | { | ||
699 | m_log.Debug("[FRIEND]: Local agent detected."); | ||
700 | |||
701 | // create calling card | ||
702 | CreateCallingCard(client, friendID, callingCardFolders[0], friendPresence.Name); | ||
703 | |||
704 | // local message means OnGridInstantMessage won't be triggered, so do the work here. | ||
705 | friendPresence.ControllingClient.SendInstantMessage( | ||
706 | new GridInstantMessage(client.Scene, agentID, | ||
707 | client.Name, friendID, | ||
708 | (byte)InstantMessageDialog.FriendshipAccepted, | ||
709 | agentID.ToString(), false, Vector3.Zero)); | ||
710 | ApproveFriendship(agentID, friendID, client.Name); | ||
711 | } | ||
712 | else | ||
713 | { | ||
714 | m_log.Debug("[FRIEND]: Remote agent detected."); | ||
715 | |||
716 | // fetch the friend's name for the calling card. | ||
717 | CachedUserInfo info = m_initialScene.CommsManager.UserProfileCacheService.GetUserDetails(friendID); | ||
718 | |||
719 | // create calling card | ||
720 | CreateCallingCard(client, friendID, callingCardFolders[0], | ||
721 | info.UserProfile.FirstName + " " + info.UserProfile.SurName); | ||
722 | |||
723 | // Compose (remote) response to friend. | ||
724 | GridInstantMessage msg = new GridInstantMessage(client.Scene, agentID, client.Name, friendID, | ||
725 | (byte)InstantMessageDialog.FriendshipAccepted, | ||
726 | agentID.ToString(), false, Vector3.Zero); | ||
727 | if (m_TransferModule != null) | ||
728 | { | ||
729 | m_TransferModule.SendInstantMessage(msg, | ||
730 | delegate(bool success) { | ||
731 | m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success); | ||
732 | } | ||
733 | ); | ||
734 | } | ||
735 | } | ||
736 | |||
737 | // tell client that new friend is online | ||
738 | client.SendAgentOnline(new UUID[] { friendID }); | ||
739 | } | ||
740 | |||
741 | private void OnDenyFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders) | ||
742 | { | ||
743 | m_log.DebugFormat("[FRIEND]: Got deny friendship from {0} {1}, agentID {2}, tid {3}", | ||
744 | client.Name, client.AgentId, agentID, friendID); | ||
745 | |||
746 | // Compose response to other agent. | ||
747 | GridInstantMessage msg = new GridInstantMessage(client.Scene, agentID, client.Name, friendID, | ||
748 | (byte)InstantMessageDialog.FriendshipDeclined, | ||
749 | agentID.ToString(), false, Vector3.Zero); | ||
750 | // send decline to initiator | ||
751 | if (m_TransferModule != null) | ||
752 | { | ||
753 | m_TransferModule.SendInstantMessage(msg, | ||
754 | delegate(bool success) { | ||
755 | m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success); | ||
756 | } | ||
757 | ); | ||
758 | } | ||
759 | } | ||
760 | |||
761 | private void OnTerminateFriendship(IClientAPI client, UUID agentID, UUID exfriendID) | ||
762 | { | ||
763 | // client.AgentId == agentID! | ||
764 | |||
765 | // this removes the friends from the stored friendlists. After the next login, they will be gone... | ||
766 | m_initialScene.StoreRemoveFriendship(agentID, exfriendID); | ||
767 | |||
768 | // ... now tell the two involved clients that they aren't friends anymore. | ||
769 | |||
770 | // I don't know why we have to tell <agent>, as this was caused by her, but that's how it works in SL... | ||
771 | client.SendTerminateFriend(exfriendID); | ||
772 | |||
773 | // now send the friend, if online | ||
774 | ScenePresence presence = GetAnyPresenceFromAgentID(exfriendID); | ||
775 | if (presence != null) | ||
776 | { | ||
777 | m_log.DebugFormat("[FRIEND]: Sending terminate friend {0} to agent {1}", agentID, exfriendID); | ||
778 | presence.ControllingClient.SendTerminateFriend(agentID); | ||
779 | } | ||
780 | else | ||
781 | { | ||
782 | // retry 3 times, in case the agent TPed from the last known region... | ||
783 | for (int retry = 0; retry < 3; ++retry) | ||
784 | { | ||
785 | // wasn't sent, so ex-friend wasn't around on this region-server. Fetch info and try to send | ||
786 | UserAgentData data = m_initialScene.CommsManager.UserService.GetAgentByUUID(exfriendID); | ||
787 | |||
788 | if (null == data) | ||
789 | break; | ||
790 | |||
791 | if (!data.AgentOnline) | ||
792 | { | ||
793 | m_log.DebugFormat("[FRIEND]: {0} is offline, so not sending TerminateFriend", exfriendID); | ||
794 | break; // if ex-friend isn't online, we don't need to send | ||
795 | } | ||
796 | |||
797 | m_log.DebugFormat("[FRIEND]: Sending remote terminate friend {0} to agent {1}@{2}", | ||
798 | agentID, exfriendID, data.Handle); | ||
799 | |||
800 | // try to send to foreign region, retry if it fails (friend TPed away, for example) | ||
801 | if (TriggerTerminateFriend(data.Handle, exfriendID, agentID)) break; | ||
802 | } | ||
803 | } | ||
804 | |||
805 | // clean up cache: FriendList is wrong now... | ||
806 | lock (m_friendLists) | ||
807 | { | ||
808 | m_friendLists.Invalidate(agentID.ToString()); | ||
809 | m_friendLists.Invalidate(exfriendID.ToString()); | ||
810 | } | ||
811 | } | ||
812 | |||
813 | #endregion | ||
814 | |||
815 | #region CallingCards | ||
816 | |||
817 | private void OnOfferCallingCard(IClientAPI client, UUID destID, UUID transactionID) | ||
818 | { | ||
819 | m_log.DebugFormat("[CALLING CARD]: got offer from {0} for {1}, transaction {2}", | ||
820 | client.AgentId, destID, transactionID); | ||
821 | // This might be slightly wrong. On a multi-region server, we might get the child-agent instead of the root-agent | ||
822 | // (or the root instead of the child) | ||
823 | ScenePresence destAgent = GetAnyPresenceFromAgentID(destID); | ||
824 | if (destAgent == null) | ||
825 | { | ||
826 | client.SendAlertMessage("The person you have offered a card to can't be found anymore."); | ||
827 | return; | ||
828 | } | ||
829 | |||
830 | lock (m_pendingCallingcardRequests) | ||
831 | { | ||
832 | m_pendingCallingcardRequests[transactionID] = client.AgentId; | ||
833 | } | ||
834 | // inform the destination agent about the offer | ||
835 | destAgent.ControllingClient.SendOfferCallingCard(client.AgentId, transactionID); | ||
836 | } | ||
837 | |||
838 | private void CreateCallingCard(IClientAPI client, UUID creator, UUID folder, string name) | ||
839 | { | ||
840 | InventoryItemBase item = new InventoryItemBase(); | ||
841 | item.AssetID = UUID.Zero; | ||
842 | item.AssetType = (int)AssetType.CallingCard; | ||
843 | item.BasePermissions = (uint)PermissionMask.Copy; | ||
844 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
845 | item.CreatorId = creator.ToString(); | ||
846 | item.CurrentPermissions = item.BasePermissions; | ||
847 | item.Description = ""; | ||
848 | item.EveryOnePermissions = (uint)PermissionMask.None; | ||
849 | item.Flags = 0; | ||
850 | item.Folder = folder; | ||
851 | item.GroupID = UUID.Zero; | ||
852 | item.GroupOwned = false; | ||
853 | item.ID = UUID.Random(); | ||
854 | item.InvType = (int)InventoryType.CallingCard; | ||
855 | item.Name = name; | ||
856 | item.NextPermissions = item.EveryOnePermissions; | ||
857 | item.Owner = client.AgentId; | ||
858 | item.SalePrice = 10; | ||
859 | item.SaleType = (byte)SaleType.Not; | ||
860 | ((Scene)client.Scene).AddInventoryItem(client, item); | ||
861 | } | ||
862 | |||
863 | private void OnAcceptCallingCard(IClientAPI client, UUID transactionID, UUID folderID) | ||
864 | { | ||
865 | m_log.DebugFormat("[CALLING CARD]: User {0} ({1} {2}) accepted tid {3}, folder {4}", | ||
866 | client.AgentId, | ||
867 | client.FirstName, client.LastName, | ||
868 | transactionID, folderID); | ||
869 | UUID destID; | ||
870 | lock (m_pendingCallingcardRequests) | ||
871 | { | ||
872 | if (!m_pendingCallingcardRequests.TryGetValue(transactionID, out destID)) | ||
873 | { | ||
874 | m_log.WarnFormat("[CALLING CARD]: Got a AcceptCallingCard from {0} without an offer before.", | ||
875 | client.Name); | ||
876 | return; | ||
877 | } | ||
878 | // else found pending calling card request with that transaction. | ||
879 | m_pendingCallingcardRequests.Remove(transactionID); | ||
880 | } | ||
881 | |||
882 | |||
883 | ScenePresence destAgent = GetAnyPresenceFromAgentID(destID); | ||
884 | // inform sender of the card that destination declined the offer | ||
885 | if (destAgent != null) destAgent.ControllingClient.SendAcceptCallingCard(transactionID); | ||
886 | |||
887 | // put a calling card into the inventory of receiver | ||
888 | CreateCallingCard(client, destID, folderID, destAgent.Name); | ||
889 | } | ||
890 | |||
891 | private void OnDeclineCallingCard(IClientAPI client, UUID transactionID) | ||
892 | { | ||
893 | m_log.DebugFormat("[CALLING CARD]: User {0} (ID:{1}) declined card, tid {2}", | ||
894 | client.Name, client.AgentId, transactionID); | ||
895 | UUID destID; | ||
896 | lock (m_pendingCallingcardRequests) | ||
897 | { | ||
898 | if (!m_pendingCallingcardRequests.TryGetValue(transactionID, out destID)) | ||
899 | { | ||
900 | m_log.WarnFormat("[CALLING CARD]: Got a AcceptCallingCard from {0} without an offer before.", | ||
901 | client.Name); | ||
902 | return; | ||
903 | } | ||
904 | // else found pending calling card request with that transaction. | ||
905 | m_pendingCallingcardRequests.Remove(transactionID); | ||
906 | } | ||
907 | |||
908 | ScenePresence destAgent = GetAnyPresenceFromAgentID(destID); | ||
909 | // inform sender of the card that destination declined the offer | ||
910 | if (destAgent != null) destAgent.ControllingClient.SendDeclineCallingCard(transactionID); | ||
911 | } | ||
912 | |||
913 | /// <summary> | ||
914 | /// Send presence information about a client to other clients in both this region and others. | ||
915 | /// </summary> | ||
916 | /// <param name="client"></param> | ||
917 | /// <param name="friendList"></param> | ||
918 | /// <param name="iAmOnline"></param> | ||
919 | private void SendPresenceState(IClientAPI client, List<FriendListItem> friendList, bool iAmOnline) | ||
920 | { | ||
921 | //m_log.DebugFormat("[FRIEND]: {0} logged {1}; sending presence updates", client.Name, iAmOnline ? "in" : "out"); | ||
922 | |||
923 | if (friendList == null || friendList.Count == 0) | ||
924 | { | ||
925 | //m_log.DebugFormat("[FRIEND]: {0} doesn't have friends.", client.Name); | ||
926 | return; // nothing we can do if she doesn't have friends... | ||
927 | } | ||
928 | |||
929 | // collect sets of friendIDs; to send to (online and offline), and to receive from | ||
930 | // TODO: If we ever switch to .NET >= 3, replace those Lists with HashSets. | ||
931 | // I can't believe that we have Dictionaries, but no Sets, considering Java introduced them years ago... | ||
932 | List<UUID> friendIDsToSendTo = new List<UUID>(); | ||
933 | List<UUID> candidateFriendIDsToReceive = new List<UUID>(); | ||
934 | |||
935 | foreach (FriendListItem item in friendList) | ||
936 | { | ||
937 | if (((item.FriendListOwnerPerms | item.FriendPerms) & (uint)FriendRights.CanSeeOnline) != 0) | ||
938 | { | ||
939 | // friend is allowed to see my presence => add | ||
940 | if ((item.FriendListOwnerPerms & (uint)FriendRights.CanSeeOnline) != 0) | ||
941 | friendIDsToSendTo.Add(item.Friend); | ||
942 | |||
943 | if ((item.FriendPerms & (uint)FriendRights.CanSeeOnline) != 0) | ||
944 | candidateFriendIDsToReceive.Add(item.Friend); | ||
945 | } | ||
946 | } | ||
947 | |||
948 | // we now have a list of "interesting" friends (which we have to find out on-/offline state for), | ||
949 | // friends we want to send our online state to (if *they* are online, too), and | ||
950 | // friends we want to receive online state for (currently unknown whether online or not) | ||
951 | |||
952 | // as this processing might take some time and friends might TP away, we try up to three times to | ||
953 | // reach them. Most of the time, we *will* reach them, and this loop won't loop | ||
954 | int retry = 0; | ||
955 | do | ||
956 | { | ||
957 | // build a list of friends to look up region-information and on-/offline-state for | ||
958 | List<UUID> friendIDsToLookup = new List<UUID>(friendIDsToSendTo); | ||
959 | foreach (UUID uuid in candidateFriendIDsToReceive) | ||
960 | { | ||
961 | if (!friendIDsToLookup.Contains(uuid)) friendIDsToLookup.Add(uuid); | ||
962 | } | ||
963 | |||
964 | m_log.DebugFormat( | ||
965 | "[FRIEND]: {0} to lookup, {1} to send to, {2} candidates to receive from for agent {3}", | ||
966 | friendIDsToLookup.Count, friendIDsToSendTo.Count, candidateFriendIDsToReceive.Count, client.Name); | ||
967 | |||
968 | // we have to fetch FriendRegionInfos, as the (cached) FriendListItems don't | ||
969 | // necessarily contain the correct online state... | ||
970 | Dictionary<UUID, FriendRegionInfo> friendRegions = m_initialScene.GetFriendRegionInfos(friendIDsToLookup); | ||
971 | m_log.DebugFormat( | ||
972 | "[FRIEND]: Found {0} regionInfos for {1} friends of {2}", | ||
973 | friendRegions.Count, friendIDsToLookup.Count, client.Name); | ||
974 | |||
975 | // argument for SendAgentOn/Offline; we shouldn't generate that repeatedly within loops. | ||
976 | UUID[] agentArr = new UUID[] { client.AgentId }; | ||
977 | |||
978 | // first, send to friend presence state to me, if I'm online... | ||
979 | if (iAmOnline) | ||
980 | { | ||
981 | List<UUID> friendIDsToReceive = new List<UUID>(); | ||
982 | |||
983 | for (int i = candidateFriendIDsToReceive.Count - 1; i >= 0; --i) | ||
984 | { | ||
985 | UUID uuid = candidateFriendIDsToReceive[i]; | ||
986 | FriendRegionInfo info; | ||
987 | if (friendRegions.TryGetValue(uuid, out info) && info != null && info.isOnline) | ||
988 | { | ||
989 | friendIDsToReceive.Add(uuid); | ||
990 | } | ||
991 | } | ||
992 | |||
993 | m_log.DebugFormat( | ||
994 | "[FRIEND]: Sending {0} online friends to {1}", friendIDsToReceive.Count, client.Name); | ||
995 | |||
996 | if (friendIDsToReceive.Count > 0) | ||
997 | client.SendAgentOnline(friendIDsToReceive.ToArray()); | ||
998 | |||
999 | // clear them for a possible second iteration; we don't have to repeat this | ||
1000 | candidateFriendIDsToReceive.Clear(); | ||
1001 | } | ||
1002 | |||
1003 | // now, send my presence state to my friends | ||
1004 | for (int i = friendIDsToSendTo.Count - 1; i >= 0; --i) | ||
1005 | { | ||
1006 | UUID uuid = friendIDsToSendTo[i]; | ||
1007 | FriendRegionInfo info; | ||
1008 | if (friendRegions.TryGetValue(uuid, out info) && info != null && info.isOnline) | ||
1009 | { | ||
1010 | // any client is good enough, root or child... | ||
1011 | ScenePresence agent = GetAnyPresenceFromAgentID(uuid); | ||
1012 | if (agent != null) | ||
1013 | { | ||
1014 | //m_log.DebugFormat("[FRIEND]: Found local agent {0}", agent.Name); | ||
1015 | |||
1016 | // friend is online and on this server... | ||
1017 | if (iAmOnline) agent.ControllingClient.SendAgentOnline(agentArr); | ||
1018 | else agent.ControllingClient.SendAgentOffline(agentArr); | ||
1019 | |||
1020 | // done, remove it | ||
1021 | friendIDsToSendTo.RemoveAt(i); | ||
1022 | } | ||
1023 | } | ||
1024 | else | ||
1025 | { | ||
1026 | //m_log.DebugFormat("[FRIEND]: Friend {0} ({1}) is offline; not sending.", uuid, i); | ||
1027 | |||
1028 | // friend is offline => no need to try sending | ||
1029 | friendIDsToSendTo.RemoveAt(i); | ||
1030 | } | ||
1031 | } | ||
1032 | |||
1033 | m_log.DebugFormat("[FRIEND]: Have {0} friends to contact via inter-region comms.", friendIDsToSendTo.Count); | ||
1034 | |||
1035 | // we now have all the friends left that are online (we think), but not on this region-server | ||
1036 | if (friendIDsToSendTo.Count > 0) | ||
1037 | { | ||
1038 | // sort them into regions | ||
1039 | Dictionary<ulong, List<UUID>> friendsInRegion = new Dictionary<ulong,List<UUID>>(); | ||
1040 | foreach (UUID uuid in friendIDsToSendTo) | ||
1041 | { | ||
1042 | ulong handle = friendRegions[uuid].regionHandle; // this can't fail as we filtered above already | ||
1043 | List<UUID> friends; | ||
1044 | if (!friendsInRegion.TryGetValue(handle, out friends)) | ||
1045 | { | ||
1046 | friends = new List<UUID>(); | ||
1047 | friendsInRegion[handle] = friends; | ||
1048 | } | ||
1049 | friends.Add(uuid); | ||
1050 | } | ||
1051 | m_log.DebugFormat("[FRIEND]: Found {0} regions to send to.", friendRegions.Count); | ||
1052 | |||
1053 | // clear uuids list and collect missed friends in it for the next retry | ||
1054 | friendIDsToSendTo.Clear(); | ||
1055 | |||
1056 | // send bulk updates to the region | ||
1057 | foreach (KeyValuePair<ulong, List<UUID>> pair in friendsInRegion) | ||
1058 | { | ||
1059 | //m_log.DebugFormat("[FRIEND]: Inform {0} friends in region {1} that user {2} is {3}line", | ||
1060 | // pair.Value.Count, pair.Key, client.Name, iAmOnline ? "on" : "off"); | ||
1061 | |||
1062 | friendIDsToSendTo.AddRange(InformFriendsInOtherRegion(client.AgentId, pair.Key, pair.Value, iAmOnline)); | ||
1063 | } | ||
1064 | } | ||
1065 | // now we have in friendIDsToSendTo only the agents left that TPed away while we tried to contact them. | ||
1066 | // In most cases, it will be empty, and it won't loop here. But sometimes, we have to work harder and try again... | ||
1067 | } | ||
1068 | while (++retry < 3 && friendIDsToSendTo.Count > 0); | ||
1069 | } | ||
1070 | |||
1071 | private void OnEconomyDataRequest(UUID agentID) | ||
1072 | { | ||
1073 | // KLUDGE: This is the only way I found to get a message (only) after login was completed and the | ||
1074 | // client is connected enough to receive UDP packets). | ||
1075 | // This packet seems to be sent only once, just after connection was established to the first | ||
1076 | // region after login. | ||
1077 | // We use it here to trigger a presence update; the old update-on-login was never be heard by | ||
1078 | // the freshly logged in viewer, as it wasn't connected to the region at that time. | ||
1079 | // TODO: Feel free to replace this by a better solution if you find one. | ||
1080 | |||
1081 | // get the agent. This should work every time, as we just got a packet from it | ||
1082 | //ScenePresence agent = GetRootPresenceFromAgentID(agentID); | ||
1083 | // KLUDGE 2: As this is sent quite early, the avatar isn't here as root agent yet. So, we have to cheat a bit | ||
1084 | ScenePresence agent = GetAnyPresenceFromAgentID(agentID); | ||
1085 | |||
1086 | // just to be paranoid... | ||
1087 | if (agent == null) | ||
1088 | { | ||
1089 | m_log.ErrorFormat("[FRIEND]: Got a packet from agent {0} who can't be found anymore!?", agentID); | ||
1090 | return; | ||
1091 | } | ||
1092 | |||
1093 | List<FriendListItem> fl; | ||
1094 | lock (m_friendLists) | ||
1095 | { | ||
1096 | fl = (List<FriendListItem>)m_friendLists.Get(agent.ControllingClient.AgentId.ToString(), | ||
1097 | m_initialScene.GetFriendList); | ||
1098 | } | ||
1099 | |||
1100 | // tell everyone that we are online | ||
1101 | SendPresenceState(agent.ControllingClient, fl, true); | ||
1102 | } | ||
1103 | |||
1104 | private void OnLogout(IClientAPI remoteClient) | ||
1105 | { | ||
1106 | List<FriendListItem> fl; | ||
1107 | lock (m_friendLists) | ||
1108 | { | ||
1109 | fl = (List<FriendListItem>)m_friendLists.Get(remoteClient.AgentId.ToString(), | ||
1110 | m_initialScene.GetFriendList); | ||
1111 | } | ||
1112 | |||
1113 | // tell everyone that we are offline | ||
1114 | SendPresenceState(remoteClient, fl, false); | ||
1115 | } | ||
1116 | private void GrantUserFriendRights(IClientAPI remoteClient, UUID requester, UUID target, int rights) | ||
1117 | { | ||
1118 | ((Scene)remoteClient.Scene).CommsManager.UpdateUserFriendPerms(requester, target, (uint)rights); | ||
1119 | } | ||
1120 | public void FindAgent(IClientAPI remoteClient, UUID hunter, UUID target) | ||
1121 | { | ||
1122 | List<FriendListItem> friendList = GetUserFriends(hunter); | ||
1123 | foreach (FriendListItem item in friendList) | ||
1124 | { | ||
1125 | if (item.onlinestatus == true) | ||
1126 | { | ||
1127 | if (item.Friend == target && (item.FriendPerms & (uint)FriendRights.CanSeeOnMap) != 0) | ||
1128 | { | ||
1129 | ScenePresence SPTarget = ((Scene)remoteClient.Scene).GetScenePresence(target); | ||
1130 | string regionname = SPTarget.Scene.RegionInfo.RegionName; | ||
1131 | remoteClient.SendScriptTeleportRequest("FindAgent", regionname,new Vector3(SPTarget.AbsolutePosition),new Vector3(SPTarget.Lookat)); | ||
1132 | } | ||
1133 | } | ||
1134 | else | ||
1135 | { | ||
1136 | remoteClient.SendAgentAlertMessage("The agent you are looking for is not online.", false); | ||
1137 | } | ||
1138 | } | ||
1139 | } | 85 | } |
1140 | 86 | ||
1141 | public List<FriendListItem> GetUserFriends(UUID agentID) | 87 | public List<FriendListItem> GetUserFriends(UUID agentID) |
1142 | { | 88 | { |
1143 | List<FriendListItem> fl; | 89 | return null; |
1144 | lock (m_friendLists) | ||
1145 | { | ||
1146 | fl = (List<FriendListItem>)m_friendLists.Get(agentID.ToString(), | ||
1147 | m_initialScene.GetFriendList); | ||
1148 | } | ||
1149 | |||
1150 | return fl; | ||
1151 | } | 90 | } |
1152 | } | 91 | } |
1153 | #endregion | ||
1154 | } | 92 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs index 9a68749..ab141eb 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs | |||
@@ -24,6 +24,7 @@ | |||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using System; | ||
27 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
28 | using System.Reflection; | 29 | using System.Reflection; |
29 | using log4net; | 30 | using log4net; |
@@ -36,9 +37,10 @@ using OpenSim.Region.Framework.Scenes; | |||
36 | 37 | ||
37 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | 38 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
38 | { | 39 | { |
39 | public class InstantMessageModule : IRegionModule | 40 | public class InstantMessageModule : ISharedRegionModule |
40 | { | 41 | { |
41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 42 | private static readonly ILog m_log = LogManager.GetLogger( |
43 | MethodBase.GetCurrentMethod().DeclaringType); | ||
42 | 44 | ||
43 | /// <value> | 45 | /// <value> |
44 | /// Is this module enabled? | 46 | /// Is this module enabled? |
@@ -51,7 +53,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
51 | 53 | ||
52 | private IMessageTransferModule m_TransferModule = null; | 54 | private IMessageTransferModule m_TransferModule = null; |
53 | 55 | ||
54 | public void Initialise(Scene scene, IConfigSource config) | 56 | public void Initialise(IConfigSource config) |
55 | { | 57 | { |
56 | if (config.Configs["Messaging"] != null) | 58 | if (config.Configs["Messaging"] != null) |
57 | { | 59 | { |
@@ -62,6 +64,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
62 | } | 64 | } |
63 | 65 | ||
64 | m_enabled = true; | 66 | m_enabled = true; |
67 | } | ||
68 | |||
69 | public void AddRegion(Scene scene) | ||
70 | { | ||
71 | if (!m_enabled) | ||
72 | return; | ||
65 | 73 | ||
66 | lock (m_scenes) | 74 | lock (m_scenes) |
67 | { | 75 | { |
@@ -74,6 +82,39 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
74 | } | 82 | } |
75 | } | 83 | } |
76 | 84 | ||
85 | public void RegionLoaded(Scene scene) | ||
86 | { | ||
87 | if (!m_enabled) | ||
88 | return; | ||
89 | |||
90 | if (m_TransferModule == null) | ||
91 | { | ||
92 | m_TransferModule = | ||
93 | scene.RequestModuleInterface<IMessageTransferModule>(); | ||
94 | |||
95 | if (m_TransferModule == null) | ||
96 | { | ||
97 | m_log.Error("[INSTANT MESSAGE]: No message transfer module, IM will not work!"); | ||
98 | scene.EventManager.OnClientConnect -= OnClientConnect; | ||
99 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; | ||
100 | |||
101 | m_scenes.Clear(); | ||
102 | m_enabled = false; | ||
103 | } | ||
104 | } | ||
105 | } | ||
106 | |||
107 | public void RemoveRegion(Scene scene) | ||
108 | { | ||
109 | if (!m_enabled) | ||
110 | return; | ||
111 | |||
112 | lock (m_scenes) | ||
113 | { | ||
114 | m_scenes.Remove(scene); | ||
115 | } | ||
116 | } | ||
117 | |||
77 | void OnClientConnect(IClientCore client) | 118 | void OnClientConnect(IClientCore client) |
78 | { | 119 | { |
79 | IClientIM clientIM; | 120 | IClientIM clientIM; |
@@ -85,15 +126,6 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
85 | 126 | ||
86 | public void PostInitialise() | 127 | public void PostInitialise() |
87 | { | 128 | { |
88 | if (!m_enabled) | ||
89 | return; | ||
90 | |||
91 | m_TransferModule = | ||
92 | m_scenes[0].RequestModuleInterface<IMessageTransferModule>(); | ||
93 | |||
94 | if (m_TransferModule == null) | ||
95 | m_log.Error("[INSTANT MESSAGE]: No message transfer module, "+ | ||
96 | "IM will not work!"); | ||
97 | } | 129 | } |
98 | 130 | ||
99 | public void Close() | 131 | public void Close() |
@@ -105,9 +137,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
105 | get { return "InstantMessageModule"; } | 137 | get { return "InstantMessageModule"; } |
106 | } | 138 | } |
107 | 139 | ||
108 | public bool IsSharedModule | 140 | public Type ReplaceableInterface |
109 | { | 141 | { |
110 | get { return true; } | 142 | get { return null; } |
111 | } | 143 | } |
112 | 144 | ||
113 | #endregion | 145 | #endregion |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index e5159b3..2d4b421 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs | |||
@@ -40,18 +40,17 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
40 | 40 | ||
41 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | 41 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
42 | { | 42 | { |
43 | public class MessageTransferModule : IRegionModule, IMessageTransferModule | 43 | public class MessageTransferModule : ISharedRegionModule, IMessageTransferModule |
44 | { | 44 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | // private bool m_Enabled = false; | 47 | private bool m_Enabled = false; |
48 | protected bool m_Gridmode = false; | ||
49 | protected List<Scene> m_Scenes = new List<Scene>(); | 48 | protected List<Scene> m_Scenes = new List<Scene>(); |
50 | protected Dictionary<UUID, ulong> m_UserRegionMap = new Dictionary<UUID, ulong>(); | 49 | protected Dictionary<UUID, ulong> m_UserRegionMap = new Dictionary<UUID, ulong>(); |
51 | 50 | ||
52 | public event UndeliveredMessage OnUndeliveredMessage; | 51 | public event UndeliveredMessage OnUndeliveredMessage; |
53 | 52 | ||
54 | public virtual void Initialise(Scene scene, IConfigSource config) | 53 | public virtual void Initialise(IConfigSource config) |
55 | { | 54 | { |
56 | IConfig cnf = config.Configs["Messaging"]; | 55 | IConfig cnf = config.Configs["Messaging"]; |
57 | if (cnf != null && cnf.GetString( | 56 | if (cnf != null && cnf.GetString( |
@@ -62,20 +61,16 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
62 | return; | 61 | return; |
63 | } | 62 | } |
64 | 63 | ||
65 | cnf = config.Configs["Startup"]; | 64 | m_Enabled = true; |
66 | if (cnf != null) | 65 | } |
67 | m_Gridmode = cnf.GetBoolean("gridmode", false); | ||
68 | 66 | ||
69 | // m_Enabled = true; | 67 | public virtual void AddRegion(Scene scene) |
68 | { | ||
69 | if (!m_Enabled) | ||
70 | return; | ||
70 | 71 | ||
71 | lock (m_Scenes) | 72 | lock (m_Scenes) |
72 | { | 73 | { |
73 | if (m_Scenes.Count == 0) | ||
74 | { | ||
75 | MainServer.Instance.AddXmlRPCHandler( | ||
76 | "grid_instant_message", processXMLRPCGridInstantMessage); | ||
77 | } | ||
78 | |||
79 | m_log.Debug("[MESSAGE TRANSFER]: Message transfer module active"); | 74 | m_log.Debug("[MESSAGE TRANSFER]: Message transfer module active"); |
80 | scene.RegisterModuleInterface<IMessageTransferModule>(this); | 75 | scene.RegisterModuleInterface<IMessageTransferModule>(this); |
81 | m_Scenes.Add(scene); | 76 | m_Scenes.Add(scene); |
@@ -84,6 +79,26 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
84 | 79 | ||
85 | public virtual void PostInitialise() | 80 | public virtual void PostInitialise() |
86 | { | 81 | { |
82 | if (!m_Enabled) | ||
83 | return; | ||
84 | |||
85 | MainServer.Instance.AddXmlRPCHandler( | ||
86 | "grid_instant_message", processXMLRPCGridInstantMessage); | ||
87 | } | ||
88 | |||
89 | public virtual void RegionLoaded(Scene scene) | ||
90 | { | ||
91 | } | ||
92 | |||
93 | public virtual void RemoveRegion(Scene scene) | ||
94 | { | ||
95 | if (!m_Enabled) | ||
96 | return; | ||
97 | |||
98 | lock(m_Scenes) | ||
99 | { | ||
100 | m_Scenes.Remove(scene); | ||
101 | } | ||
87 | } | 102 | } |
88 | 103 | ||
89 | public virtual void Close() | 104 | public virtual void Close() |
@@ -95,9 +110,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
95 | get { return "MessageTransferModule"; } | 110 | get { return "MessageTransferModule"; } |
96 | } | 111 | } |
97 | 112 | ||
98 | public virtual bool IsSharedModule | 113 | public virtual Type ReplaceableInterface |
99 | { | 114 | { |
100 | get { return true; } | 115 | get { return null; } |
101 | } | 116 | } |
102 | 117 | ||
103 | public virtual void SendInstantMessage(GridInstantMessage im, MessageResultNotification result) | 118 | public virtual void SendInstantMessage(GridInstantMessage im, MessageResultNotification result) |
@@ -148,15 +163,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
148 | } | 163 | } |
149 | } | 164 | } |
150 | 165 | ||
151 | if (m_Gridmode) | 166 | SendGridInstantMessageViaXMLRPC(im, result); |
152 | { | ||
153 | //m_log.DebugFormat("[INSTANT MESSAGE]: Delivering via grid"); | ||
154 | // Still here, try send via Grid | ||
155 | SendGridInstantMessageViaXMLRPC(im, result); | ||
156 | return; | ||
157 | } | ||
158 | |||
159 | HandleUndeliveredMessage(im, result); | ||
160 | 167 | ||
161 | return; | 168 | return; |
162 | } | 169 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs index 2d4a635..24cbaeb 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs | |||
@@ -37,9 +37,9 @@ using OpenSim.Framework.Client; | |||
37 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
38 | using OpenSim.Region.Framework.Scenes; | 38 | using OpenSim.Region.Framework.Scenes; |
39 | 39 | ||
40 | namespace OpenSim.Region.CoreModules.Avatar.MuteList | 40 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
41 | { | 41 | { |
42 | public class MuteListModule : IRegionModule | 42 | public class MuteListModule : ISharedRegionModule |
43 | { | 43 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 45 | ||
@@ -47,11 +47,8 @@ namespace OpenSim.Region.CoreModules.Avatar.MuteList | |||
47 | private List<Scene> m_SceneList = new List<Scene>(); | 47 | private List<Scene> m_SceneList = new List<Scene>(); |
48 | private string m_RestURL = String.Empty; | 48 | private string m_RestURL = String.Empty; |
49 | 49 | ||
50 | public void Initialise(Scene scene, IConfigSource config) | 50 | public void Initialise(IConfigSource config) |
51 | { | 51 | { |
52 | if (!enabled) | ||
53 | return; | ||
54 | |||
55 | IConfig cnf = config.Configs["Messaging"]; | 52 | IConfig cnf = config.Configs["Messaging"]; |
56 | if (cnf == null) | 53 | if (cnf == null) |
57 | { | 54 | { |
@@ -59,39 +56,53 @@ namespace OpenSim.Region.CoreModules.Avatar.MuteList | |||
59 | return; | 56 | return; |
60 | } | 57 | } |
61 | 58 | ||
62 | if (cnf != null && cnf.GetString( | 59 | if (cnf != null && cnf.GetString("MuteListModule", "None") != |
63 | "MuteListModule", "None") != | ||
64 | "MuteListModule") | 60 | "MuteListModule") |
65 | { | 61 | { |
66 | enabled = false; | 62 | enabled = false; |
67 | return; | 63 | return; |
68 | } | 64 | } |
69 | 65 | ||
66 | m_RestURL = cnf.GetString("MuteListURL", ""); | ||
67 | if (m_RestURL == "") | ||
68 | { | ||
69 | m_log.Error("[MUTE LIST] Module was enabled, but no URL is given, disabling"); | ||
70 | enabled = false; | ||
71 | return; | ||
72 | } | ||
73 | } | ||
74 | |||
75 | public void AddRegion(Scene scene) | ||
76 | { | ||
77 | if (!enabled) | ||
78 | return; | ||
79 | |||
70 | lock (m_SceneList) | 80 | lock (m_SceneList) |
71 | { | 81 | { |
72 | if (m_SceneList.Count == 0) | 82 | m_SceneList.Add(scene); |
73 | { | ||
74 | m_RestURL = cnf.GetString("MuteListURL", ""); | ||
75 | if (m_RestURL == "") | ||
76 | { | ||
77 | m_log.Error("[MUTE LIST] Module was enabled, but no URL is given, disabling"); | ||
78 | enabled = false; | ||
79 | return; | ||
80 | } | ||
81 | } | ||
82 | if (!m_SceneList.Contains(scene)) | ||
83 | m_SceneList.Add(scene); | ||
84 | 83 | ||
85 | scene.EventManager.OnNewClient += OnNewClient; | 84 | scene.EventManager.OnNewClient += OnNewClient; |
86 | } | 85 | } |
87 | } | 86 | } |
88 | 87 | ||
89 | public void PostInitialise() | 88 | public void RegionLoaded(Scene scene) |
89 | { | ||
90 | } | ||
91 | |||
92 | public void RemoveRegion(Scene scene) | ||
90 | { | 93 | { |
91 | if (!enabled) | 94 | if (!enabled) |
92 | return; | 95 | return; |
93 | 96 | ||
94 | if (m_SceneList.Count == 0) | 97 | lock (m_SceneList) |
98 | { | ||
99 | m_SceneList.Remove(scene); | ||
100 | } | ||
101 | } | ||
102 | |||
103 | public void PostInitialise() | ||
104 | { | ||
105 | if (!enabled) | ||
95 | return; | 106 | return; |
96 | 107 | ||
97 | m_log.Debug("[MUTE LIST] Mute list enabled"); | 108 | m_log.Debug("[MUTE LIST] Mute list enabled"); |
@@ -102,26 +113,15 @@ namespace OpenSim.Region.CoreModules.Avatar.MuteList | |||
102 | get { return "MuteListModule"; } | 113 | get { return "MuteListModule"; } |
103 | } | 114 | } |
104 | 115 | ||
105 | public bool IsSharedModule | 116 | public Type ReplaceableInterface |
106 | { | 117 | { |
107 | get { return true; } | 118 | get { return null; } |
108 | } | 119 | } |
109 | 120 | ||
110 | public void Close() | 121 | public void Close() |
111 | { | 122 | { |
112 | } | 123 | } |
113 | 124 | ||
114 | // private IClientAPI FindClient(UUID agentID) | ||
115 | // { | ||
116 | // foreach (Scene s in m_SceneList) | ||
117 | // { | ||
118 | // ScenePresence presence = s.GetScenePresence(agentID); | ||
119 | // if (presence != null && !presence.IsChildAgent) | ||
120 | // return presence.ControllingClient; | ||
121 | // } | ||
122 | // return null; | ||
123 | // } | ||
124 | |||
125 | private void OnNewClient(IClientAPI client) | 125 | private void OnNewClient(IClientAPI client) |
126 | { | 126 | { |
127 | client.OnMuteListRequest += OnMuteListRequest; | 127 | client.OnMuteListRequest += OnMuteListRequest; |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs index 1614b70..a835c52 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs | |||
@@ -40,78 +40,88 @@ using OpenSim.Region.Framework.Scenes; | |||
40 | 40 | ||
41 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | 41 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
42 | { | 42 | { |
43 | public class OfflineMessageModule : IRegionModule | 43 | public class OfflineMessageModule : ISharedRegionModule |
44 | { | 44 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | private bool enabled = true; | 47 | private bool enabled = true; |
48 | private List<Scene> m_SceneList = new List<Scene>(); | 48 | private List<Scene> m_SceneList = new List<Scene>(); |
49 | private string m_RestURL = String.Empty; | 49 | private string m_RestURL = String.Empty; |
50 | IMessageTransferModule m_TransferModule = null; | ||
50 | 51 | ||
51 | public void Initialise(Scene scene, IConfigSource config) | 52 | public void Initialise(IConfigSource config) |
52 | { | 53 | { |
53 | if (!enabled) | ||
54 | return; | ||
55 | |||
56 | IConfig cnf = config.Configs["Messaging"]; | 54 | IConfig cnf = config.Configs["Messaging"]; |
57 | if (cnf == null) | 55 | if (cnf == null) |
58 | { | 56 | { |
59 | enabled = false; | 57 | enabled = false; |
60 | return; | 58 | return; |
61 | } | 59 | } |
62 | if (cnf != null && cnf.GetString( | 60 | if (cnf != null && cnf.GetString("OfflineMessageModule", "None") != |
63 | "OfflineMessageModule", "None") != | ||
64 | "OfflineMessageModule") | 61 | "OfflineMessageModule") |
65 | { | 62 | { |
66 | enabled = false; | 63 | enabled = false; |
67 | return; | 64 | return; |
68 | } | 65 | } |
69 | 66 | ||
67 | m_RestURL = cnf.GetString("OfflineMessageURL", ""); | ||
68 | if (m_RestURL == "") | ||
69 | { | ||
70 | m_log.Error("[OFFLINE MESSAGING] Module was enabled, but no URL is given, disabling"); | ||
71 | enabled = false; | ||
72 | return; | ||
73 | } | ||
74 | } | ||
75 | |||
76 | public void AddRegion(Scene scene) | ||
77 | { | ||
78 | if (!enabled) | ||
79 | return; | ||
80 | |||
70 | lock (m_SceneList) | 81 | lock (m_SceneList) |
71 | { | 82 | { |
72 | if (m_SceneList.Count == 0) | 83 | m_SceneList.Add(scene); |
73 | { | ||
74 | m_RestURL = cnf.GetString("OfflineMessageURL", ""); | ||
75 | if (m_RestURL == "") | ||
76 | { | ||
77 | m_log.Error("[OFFLINE MESSAGING] Module was enabled, but no URL is given, disabling"); | ||
78 | enabled = false; | ||
79 | return; | ||
80 | } | ||
81 | } | ||
82 | if (!m_SceneList.Contains(scene)) | ||
83 | m_SceneList.Add(scene); | ||
84 | 84 | ||
85 | scene.EventManager.OnNewClient += OnNewClient; | 85 | scene.EventManager.OnNewClient += OnNewClient; |
86 | } | 86 | } |
87 | } | 87 | } |
88 | 88 | ||
89 | public void PostInitialise() | 89 | public void RegionLoaded(Scene scene) |
90 | { | 90 | { |
91 | if (!enabled) | 91 | if (!enabled) |
92 | return; | 92 | return; |
93 | 93 | ||
94 | if (m_SceneList.Count == 0) | 94 | if (m_TransferModule == null) |
95 | return; | ||
96 | |||
97 | IMessageTransferModule trans = m_SceneList[0].RequestModuleInterface<IMessageTransferModule>(); | ||
98 | if (trans == null) | ||
99 | { | 95 | { |
100 | enabled = false; | 96 | m_TransferModule = scene.RequestModuleInterface<IMessageTransferModule>(); |
101 | 97 | if (m_TransferModule == null) | |
102 | lock (m_SceneList) | ||
103 | { | 98 | { |
104 | foreach (Scene s in m_SceneList) | 99 | scene.EventManager.OnNewClient -= OnNewClient; |
105 | s.EventManager.OnNewClient -= OnNewClient; | ||
106 | 100 | ||
101 | enabled = false; | ||
107 | m_SceneList.Clear(); | 102 | m_SceneList.Clear(); |
103 | |||
104 | m_log.Error("[OFFLINE MESSAGING] No message transfer module is enabled. Diabling offline messages"); | ||
108 | } | 105 | } |
106 | m_TransferModule.OnUndeliveredMessage += UndeliveredMessage; | ||
107 | } | ||
108 | } | ||
109 | 109 | ||
110 | m_log.Error("[OFFLINE MESSAGING] No message transfer module is enabled. Diabling offline messages"); | 110 | public void RemoveRegion(Scene scene) |
111 | { | ||
112 | if (!enabled) | ||
111 | return; | 113 | return; |
114 | |||
115 | lock (m_SceneList) | ||
116 | { | ||
117 | m_SceneList.Remove(scene); | ||
112 | } | 118 | } |
119 | } | ||
113 | 120 | ||
114 | trans.OnUndeliveredMessage += UndeliveredMessage; | 121 | public void PostInitialise() |
122 | { | ||
123 | if (!enabled) | ||
124 | return; | ||
115 | 125 | ||
116 | m_log.Debug("[OFFLINE MESSAGING] Offline messages enabled"); | 126 | m_log.Debug("[OFFLINE MESSAGING] Offline messages enabled"); |
117 | } | 127 | } |
@@ -121,9 +131,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
121 | get { return "OfflineMessageModule"; } | 131 | get { return "OfflineMessageModule"; } |
122 | } | 132 | } |
123 | 133 | ||
124 | public bool IsSharedModule | 134 | public Type ReplaceableInterface |
125 | { | 135 | { |
126 | get { return true; } | 136 | get { return null; } |
127 | } | 137 | } |
128 | 138 | ||
129 | public void Close() | 139 | public void Close() |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs index f5ab454..267a90a 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs | |||
@@ -24,6 +24,7 @@ | |||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using System; | ||
27 | using System.Collections; | 28 | using System.Collections; |
28 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using System.Net; | 30 | using System.Net; |
@@ -39,404 +40,54 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
39 | 40 | ||
40 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | 41 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
41 | { | 42 | { |
42 | public class PresenceModule : IRegionModule, IPresenceModule | 43 | public class PresenceModule : ISharedRegionModule, IPresenceModule |
43 | { | 44 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger( |
45 | 46 | MethodBase.GetCurrentMethod().DeclaringType); | |
46 | private bool m_Enabled = false; | ||
47 | private bool m_Gridmode = false; | ||
48 | |||
49 | // some default scene for doing things that aren't connected to a specific scene. Avoids locking. | ||
50 | private Scene m_initialScene; | ||
51 | |||
52 | private List<Scene> m_Scenes = new List<Scene>(); | ||
53 | |||
54 | // we currently are only interested in root-agents. If the root isn't here, we don't know the region the | ||
55 | // user is in, so we have to ask the messaging server anyway. | ||
56 | private Dictionary<UUID, Scene> m_RootAgents = | ||
57 | new Dictionary<UUID, Scene>(); | ||
58 | 47 | ||
59 | public event PresenceChange OnPresenceChange; | 48 | public event PresenceChange OnPresenceChange; |
60 | public event BulkPresenceData OnBulkPresenceData; | 49 | public event BulkPresenceData OnBulkPresenceData; |
61 | 50 | ||
62 | public void Initialise(Scene scene, IConfigSource config) | 51 | public void Initialise(IConfigSource config) |
63 | { | 52 | { |
64 | lock (m_Scenes) | ||
65 | { | ||
66 | // This is a shared module; Initialise will be called for every region on this server. | ||
67 | // Only check config once for the first region. | ||
68 | if (m_Scenes.Count == 0) | ||
69 | { | ||
70 | IConfig cnf = config.Configs["Messaging"]; | ||
71 | if (cnf != null && cnf.GetString( | ||
72 | "PresenceModule", "PresenceModule") != | ||
73 | "PresenceModule") | ||
74 | return; | ||
75 | |||
76 | cnf = config.Configs["Startup"]; | ||
77 | if (cnf != null) | ||
78 | m_Gridmode = cnf.GetBoolean("gridmode", false); | ||
79 | |||
80 | m_Enabled = true; | ||
81 | |||
82 | m_initialScene = scene; | ||
83 | } | ||
84 | |||
85 | if (m_Gridmode) | ||
86 | NotifyMessageServerOfStartup(scene); | ||
87 | |||
88 | m_Scenes.Add(scene); | ||
89 | } | ||
90 | |||
91 | scene.RegisterModuleInterface<IPresenceModule>(this); | ||
92 | |||
93 | scene.EventManager.OnNewClient += OnNewClient; | ||
94 | scene.EventManager.OnSetRootAgentScene += OnSetRootAgentScene; | ||
95 | scene.EventManager.OnMakeChildAgent += OnMakeChildAgent; | ||
96 | } | 53 | } |
97 | 54 | ||
98 | public void PostInitialise() | 55 | public void AddRegion(Scene scene) |
99 | { | 56 | { |
100 | } | 57 | } |
101 | 58 | ||
102 | public void Close() | 59 | public void RegionLoaded(Scene scene) |
103 | { | 60 | { |
104 | if (!m_Gridmode || !m_Enabled) | ||
105 | return; | ||
106 | |||
107 | if (OnPresenceChange != null) | ||
108 | { | ||
109 | lock (m_RootAgents) | ||
110 | { | ||
111 | // on shutdown, users are kicked, too | ||
112 | foreach (KeyValuePair<UUID, Scene> pair in m_RootAgents) | ||
113 | { | ||
114 | OnPresenceChange(new PresenceInfo(pair.Key, UUID.Zero)); | ||
115 | } | ||
116 | } | ||
117 | } | ||
118 | |||
119 | lock (m_Scenes) | ||
120 | { | ||
121 | foreach (Scene scene in m_Scenes) | ||
122 | NotifyMessageServerOfShutdown(scene); | ||
123 | } | ||
124 | } | 61 | } |
125 | 62 | ||
126 | public string Name | 63 | public void RemoveRegion(Scene scene) |
127 | { | 64 | { |
128 | get { return "PresenceModule"; } | ||
129 | } | ||
130 | |||
131 | public bool IsSharedModule | ||
132 | { | ||
133 | get { return true; } | ||
134 | } | ||
135 | |||
136 | public void RequestBulkPresenceData(UUID[] users) | ||
137 | { | ||
138 | if (OnBulkPresenceData != null) | ||
139 | { | ||
140 | PresenceInfo[] result = new PresenceInfo[users.Length]; | ||
141 | if (m_Gridmode) | ||
142 | { | ||
143 | // first check the local information | ||
144 | List<UUID> uuids = new List<UUID>(); // the uuids to check remotely | ||
145 | List<int> indices = new List<int>(); // just for performance. | ||
146 | lock (m_RootAgents) | ||
147 | { | ||
148 | for (int i = 0; i < uuids.Count; ++i) | ||
149 | { | ||
150 | Scene scene; | ||
151 | if (m_RootAgents.TryGetValue(users[i], out scene)) | ||
152 | { | ||
153 | result[i] = new PresenceInfo(users[i], scene.RegionInfo.RegionID); | ||
154 | } | ||
155 | else | ||
156 | { | ||
157 | uuids.Add(users[i]); | ||
158 | indices.Add(i); | ||
159 | } | ||
160 | } | ||
161 | } | ||
162 | |||
163 | // now we have filtered out all the local root agents. The rest we have to request info about | ||
164 | Dictionary<UUID, FriendRegionInfo> infos = m_initialScene.GetFriendRegionInfos(uuids); | ||
165 | for (int i = 0; i < uuids.Count; ++i) | ||
166 | { | ||
167 | FriendRegionInfo info; | ||
168 | if (infos.TryGetValue(uuids[i], out info) && info.isOnline) | ||
169 | { | ||
170 | UUID regionID = info.regionID; | ||
171 | if (regionID == UUID.Zero) | ||
172 | { | ||
173 | // TODO this is the old messaging-server protocol; only the regionHandle is available. | ||
174 | // Fetch region-info to get the id | ||
175 | uint x = 0, y = 0; | ||
176 | Utils.LongToUInts(info.regionHandle, out x, out y); | ||
177 | GridRegion regionInfo = m_initialScene.GridService.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, | ||
178 | (int)x, (int)y); | ||
179 | regionID = regionInfo.RegionID; | ||
180 | } | ||
181 | result[indices[i]] = new PresenceInfo(uuids[i], regionID); | ||
182 | } | ||
183 | else result[indices[i]] = new PresenceInfo(uuids[i], UUID.Zero); | ||
184 | } | ||
185 | } | ||
186 | else | ||
187 | { | ||
188 | // in standalone mode, we have all the info locally available. | ||
189 | lock (m_RootAgents) | ||
190 | { | ||
191 | for (int i = 0; i < users.Length; ++i) | ||
192 | { | ||
193 | Scene scene; | ||
194 | if (m_RootAgents.TryGetValue(users[i], out scene)) | ||
195 | { | ||
196 | result[i] = new PresenceInfo(users[i], scene.RegionInfo.RegionID); | ||
197 | } | ||
198 | else | ||
199 | { | ||
200 | result[i] = new PresenceInfo(users[i], UUID.Zero); | ||
201 | } | ||
202 | } | ||
203 | } | ||
204 | } | ||
205 | |||
206 | // tell everyone | ||
207 | OnBulkPresenceData(result); | ||
208 | } | ||
209 | } | ||
210 | |||
211 | // new client doesn't mean necessarily that user logged in, it just means it entered one of the | ||
212 | // the regions on this server | ||
213 | public void OnNewClient(IClientAPI client) | ||
214 | { | ||
215 | client.OnConnectionClosed += OnConnectionClosed; | ||
216 | client.OnLogout += OnLogout; | ||
217 | |||
218 | // KLUDGE: See handler for details. | ||
219 | client.OnEconomyDataRequest += OnEconomyDataRequest; | ||
220 | } | 65 | } |
221 | 66 | ||
222 | // connection closed just means *one* client connection has been closed. It doesn't mean that the | 67 | public void PostInitialise() |
223 | // user has logged off; it might have just TPed away. | ||
224 | public void OnConnectionClosed(IClientAPI client) | ||
225 | { | ||
226 | // TODO: Have to think what we have to do here... | ||
227 | // Should we just remove the root from the list (if scene matches)? | ||
228 | if (!(client.Scene is Scene)) | ||
229 | return; | ||
230 | Scene scene = (Scene)client.Scene; | ||
231 | |||
232 | lock (m_RootAgents) | ||
233 | { | ||
234 | Scene rootScene; | ||
235 | if (!(m_RootAgents.TryGetValue(client.AgentId, out rootScene)) || scene != rootScene) | ||
236 | return; | ||
237 | |||
238 | m_RootAgents.Remove(client.AgentId); | ||
239 | } | ||
240 | |||
241 | // Should it have logged off, we'll do the logout part in OnLogout, even if no root is stored | ||
242 | // anymore. It logged off, after all... | ||
243 | } | ||
244 | |||
245 | // Triggered when the user logs off. | ||
246 | public void OnLogout(IClientAPI client) | ||
247 | { | ||
248 | if (!(client.Scene is Scene)) | ||
249 | return; | ||
250 | Scene scene = (Scene)client.Scene; | ||
251 | |||
252 | // On logout, we really remove the client from rootAgents, even if the scene doesn't match | ||
253 | lock (m_RootAgents) | ||
254 | { | ||
255 | if (m_RootAgents.ContainsKey(client.AgentId)) m_RootAgents.Remove(client.AgentId); | ||
256 | } | ||
257 | |||
258 | // now inform the messaging server and anyone who is interested | ||
259 | NotifyMessageServerOfAgentLeaving(client.AgentId, scene.RegionInfo.RegionID, scene.RegionInfo.RegionHandle); | ||
260 | if (OnPresenceChange != null) OnPresenceChange(new PresenceInfo(client.AgentId, UUID.Zero)); | ||
261 | } | ||
262 | |||
263 | public void OnSetRootAgentScene(UUID agentID, Scene scene) | ||
264 | { | ||
265 | // OnSetRootAgentScene can be called from several threads at once (with different agentID). | ||
266 | // Concurrent access to m_RootAgents is prone to failure on multi-core/-processor systems without | ||
267 | // correct locking). | ||
268 | lock (m_RootAgents) | ||
269 | { | ||
270 | Scene rootScene; | ||
271 | if (m_RootAgents.TryGetValue(agentID, out rootScene) && scene == rootScene) | ||
272 | { | ||
273 | return; | ||
274 | } | ||
275 | m_RootAgents[agentID] = scene; | ||
276 | } | ||
277 | |||
278 | // inform messaging server that agent changed the region | ||
279 | Util.FireAndForget( | ||
280 | delegate(object o) | ||
281 | { | ||
282 | NotifyMessageServerOfAgentLocation(agentID, scene.RegionInfo.RegionID, scene.RegionInfo.RegionHandle); | ||
283 | } | ||
284 | ); | ||
285 | } | ||
286 | |||
287 | private void OnEconomyDataRequest(UUID agentID) | ||
288 | { | 68 | { |
289 | // KLUDGE: This is the only way I found to get a message (only) after login was completed and the | ||
290 | // client is connected enough to receive UDP packets. | ||
291 | // This packet seems to be sent only once, just after connection was established to the first | ||
292 | // region after login. | ||
293 | // We use it here to trigger a presence update; the old update-on-login was never be heard by | ||
294 | // the freshly logged in viewer, as it wasn't connected to the region at that time. | ||
295 | // TODO: Feel free to replace this by a better solution if you find one. | ||
296 | |||
297 | // get the agent. This should work every time, as we just got a packet from it | ||
298 | ScenePresence agent = null; | ||
299 | lock (m_Scenes) | ||
300 | { | ||
301 | foreach (Scene scene in m_Scenes) | ||
302 | { | ||
303 | agent = scene.GetScenePresence(agentID); | ||
304 | if (agent != null) break; | ||
305 | } | ||
306 | } | ||
307 | |||
308 | // just to be paranoid... | ||
309 | if (agent == null) | ||
310 | { | ||
311 | m_log.ErrorFormat("[PRESENCE]: Got a packet from agent {0} who can't be found anymore!?", agentID); | ||
312 | return; | ||
313 | } | ||
314 | |||
315 | // we are a bit premature here, but the next packet will switch this child agent to root. | ||
316 | if (OnPresenceChange != null) OnPresenceChange(new PresenceInfo(agentID, agent.Scene.RegionInfo.RegionID)); | ||
317 | } | 69 | } |
318 | 70 | ||
319 | public void OnMakeChildAgent(ScenePresence agent) | 71 | public void Close() |
320 | { | 72 | { |
321 | // OnMakeChildAgent can be called from several threads at once (with different agent). | ||
322 | // Concurrent access to m_RootAgents is prone to failure on multi-core/-processor systems without | ||
323 | // correct locking). | ||
324 | lock (m_RootAgents) | ||
325 | { | ||
326 | Scene rootScene; | ||
327 | if (m_RootAgents.TryGetValue(agent.UUID, out rootScene) && agent.Scene == rootScene) | ||
328 | { | ||
329 | m_RootAgents.Remove(agent.UUID); | ||
330 | } | ||
331 | } | ||
332 | // don't notify the messaging-server; either this agent just had been downgraded and another one will be upgraded | ||
333 | // to root momentarily (which will notify the messaging-server), or possibly it will be closed in a moment, | ||
334 | // which will update the messaging-server, too. | ||
335 | } | 73 | } |
336 | 74 | ||
337 | private void NotifyMessageServerOfStartup(Scene scene) | 75 | public string Name |
338 | { | 76 | { |
339 | Hashtable xmlrpcdata = new Hashtable(); | 77 | get { return "PresenceModule"; } |
340 | xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString(); | ||
341 | ArrayList SendParams = new ArrayList(); | ||
342 | SendParams.Add(xmlrpcdata); | ||
343 | try | ||
344 | { | ||
345 | XmlRpcRequest UpRequest = new XmlRpcRequest("region_startup", SendParams); | ||
346 | XmlRpcResponse resp = UpRequest.Send(scene.CommsManager.NetworkServersInfo.MessagingURL, 5000); | ||
347 | |||
348 | Hashtable responseData = (Hashtable)resp.Value; | ||
349 | if (responseData == null || (!responseData.ContainsKey("success")) || (string)responseData["success"] != "TRUE") | ||
350 | { | ||
351 | m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of region startup for region {0}", scene.RegionInfo.RegionName); | ||
352 | } | ||
353 | } | ||
354 | catch (WebException) | ||
355 | { | ||
356 | m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of region startup for region {0}", scene.RegionInfo.RegionName); | ||
357 | } | ||
358 | } | 78 | } |
359 | 79 | ||
360 | private void NotifyMessageServerOfShutdown(Scene scene) | 80 | public Type ReplaceableInterface |
361 | { | 81 | { |
362 | if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty) | 82 | get { return null; } |
363 | return; | ||
364 | |||
365 | Hashtable xmlrpcdata = new Hashtable(); | ||
366 | xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString(); | ||
367 | ArrayList SendParams = new ArrayList(); | ||
368 | SendParams.Add(xmlrpcdata); | ||
369 | try | ||
370 | { | ||
371 | XmlRpcRequest DownRequest = new XmlRpcRequest("region_shutdown", SendParams); | ||
372 | XmlRpcResponse resp = DownRequest.Send(scene.CommsManager.NetworkServersInfo.MessagingURL, 5000); | ||
373 | |||
374 | Hashtable responseData = (Hashtable)resp.Value; | ||
375 | if ((!responseData.ContainsKey("success")) || (string)responseData["success"] != "TRUE") | ||
376 | { | ||
377 | m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of region shutdown for region {0}", scene.RegionInfo.RegionName); | ||
378 | } | ||
379 | } | ||
380 | catch (WebException) | ||
381 | { | ||
382 | m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of region shutdown for region {0}", scene.RegionInfo.RegionName); | ||
383 | } | ||
384 | } | 83 | } |
385 | 84 | ||
386 | private void NotifyMessageServerOfAgentLocation(UUID agentID, UUID region, ulong regionHandle) | 85 | public void RequestBulkPresenceData(UUID[] users) |
387 | { | 86 | { |
388 | if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty) | ||
389 | return; | ||
390 | |||
391 | Hashtable xmlrpcdata = new Hashtable(); | ||
392 | xmlrpcdata["AgentID"] = agentID.ToString(); | ||
393 | xmlrpcdata["RegionUUID"] = region.ToString(); | ||
394 | xmlrpcdata["RegionHandle"] = regionHandle.ToString(); | ||
395 | ArrayList SendParams = new ArrayList(); | ||
396 | SendParams.Add(xmlrpcdata); | ||
397 | try | ||
398 | { | ||
399 | XmlRpcRequest LocationRequest = new XmlRpcRequest("agent_location", SendParams); | ||
400 | XmlRpcResponse resp = LocationRequest.Send(m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL, 5000); | ||
401 | |||
402 | Hashtable responseData = (Hashtable)resp.Value; | ||
403 | if ((!responseData.ContainsKey("success")) || (string)responseData["success"] != "TRUE") | ||
404 | { | ||
405 | m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of agent location for {0}", agentID.ToString()); | ||
406 | } | ||
407 | } | ||
408 | catch (WebException) | ||
409 | { | ||
410 | m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of agent location for {0}", agentID.ToString()); | ||
411 | } | ||
412 | } | 87 | } |
413 | 88 | ||
414 | private void NotifyMessageServerOfAgentLeaving(UUID agentID, UUID region, ulong regionHandle) | 89 | public void OnNewClient(IClientAPI client) |
415 | { | 90 | { |
416 | if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty) | ||
417 | return; | ||
418 | |||
419 | Hashtable xmlrpcdata = new Hashtable(); | ||
420 | xmlrpcdata["AgentID"] = agentID.ToString(); | ||
421 | xmlrpcdata["RegionUUID"] = region.ToString(); | ||
422 | xmlrpcdata["RegionHandle"] = regionHandle.ToString(); | ||
423 | ArrayList SendParams = new ArrayList(); | ||
424 | SendParams.Add(xmlrpcdata); | ||
425 | try | ||
426 | { | ||
427 | XmlRpcRequest LeavingRequest = new XmlRpcRequest("agent_leaving", SendParams); | ||
428 | XmlRpcResponse resp = LeavingRequest.Send(m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL, 5000); | ||
429 | |||
430 | Hashtable responseData = (Hashtable)resp.Value; | ||
431 | if ((!responseData.ContainsKey("success")) || (string)responseData["success"] != "TRUE") | ||
432 | { | ||
433 | m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of agent leaving for {0}", agentID.ToString()); | ||
434 | } | ||
435 | } | ||
436 | catch (WebException) | ||
437 | { | ||
438 | m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of agent leaving for {0}", agentID.ToString()); | ||
439 | } | ||
440 | } | 91 | } |
441 | } | 92 | } |
442 | } | 93 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index d9a021f..55d4f14 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | |||
@@ -39,7 +39,7 @@ using OpenSim.Services.Interfaces; | |||
39 | 39 | ||
40 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | 40 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer |
41 | { | 41 | { |
42 | public class InventoryTransferModule : IInventoryTransferModule, IRegionModule | 42 | public class InventoryTransferModule : IInventoryTransferModule, ISharedRegionModule |
43 | { | 43 | { |
44 | private static readonly ILog m_log | 44 | private static readonly ILog m_log |
45 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -50,10 +50,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
50 | new Dictionary<UUID, Scene>(); | 50 | new Dictionary<UUID, Scene>(); |
51 | 51 | ||
52 | private IMessageTransferModule m_TransferModule = null; | 52 | private IMessageTransferModule m_TransferModule = null; |
53 | private bool m_Enabled = true; | ||
53 | 54 | ||
54 | #region IRegionModule Members | 55 | #region IRegionModule Members |
55 | 56 | ||
56 | public void Initialise(Scene scene, IConfigSource config) | 57 | public void Initialise(IConfigSource config) |
57 | { | 58 | { |
58 | if (config.Configs["Messaging"] != null) | 59 | if (config.Configs["Messaging"] != null) |
59 | { | 60 | { |
@@ -62,29 +63,56 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
62 | if (config.Configs["Messaging"].GetString( | 63 | if (config.Configs["Messaging"].GetString( |
63 | "InventoryTransferModule", "InventoryTransferModule") != | 64 | "InventoryTransferModule", "InventoryTransferModule") != |
64 | "InventoryTransferModule") | 65 | "InventoryTransferModule") |
66 | { | ||
67 | m_Enabled = false; | ||
65 | return; | 68 | return; |
69 | } | ||
66 | } | 70 | } |
71 | } | ||
67 | 72 | ||
68 | if (!m_Scenelist.Contains(scene)) | 73 | public void AddRegion(Scene scene) |
69 | { | 74 | { |
70 | m_Scenelist.Add(scene); | 75 | if (!m_Enabled) |
76 | return; | ||
71 | 77 | ||
72 | scene.RegisterModuleInterface<IInventoryTransferModule>(this); | 78 | m_Scenelist.Add(scene); |
73 | 79 | ||
74 | scene.EventManager.OnNewClient += OnNewClient; | 80 | scene.RegisterModuleInterface<IInventoryTransferModule>(this); |
75 | scene.EventManager.OnClientClosed += ClientLoggedOut; | 81 | |
76 | scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; | 82 | scene.EventManager.OnNewClient += OnNewClient; |
77 | } | 83 | scene.EventManager.OnClientClosed += ClientLoggedOut; |
84 | scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; | ||
78 | } | 85 | } |
79 | 86 | ||
80 | public void PostInitialise() | 87 | public void RegionLoaded(Scene scene) |
81 | { | 88 | { |
82 | if (m_Scenelist.Count > 0) | 89 | if (m_TransferModule == null) |
83 | { | 90 | { |
84 | m_TransferModule = m_Scenelist[0].RequestModuleInterface<IMessageTransferModule>(); | 91 | m_TransferModule = m_Scenelist[0].RequestModuleInterface<IMessageTransferModule>(); |
85 | if (m_TransferModule == null) | 92 | if (m_TransferModule == null) |
93 | { | ||
86 | m_log.Error("[INVENTORY TRANSFER] No Message transfer module found, transfers will be local only"); | 94 | m_log.Error("[INVENTORY TRANSFER] No Message transfer module found, transfers will be local only"); |
95 | m_Enabled = false; | ||
96 | |||
97 | m_Scenelist.Clear(); | ||
98 | scene.EventManager.OnNewClient -= OnNewClient; | ||
99 | scene.EventManager.OnClientClosed -= ClientLoggedOut; | ||
100 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; | ||
101 | } | ||
87 | } | 102 | } |
103 | |||
104 | } | ||
105 | |||
106 | public void RemoveRegion(Scene scene) | ||
107 | { | ||
108 | scene.EventManager.OnNewClient -= OnNewClient; | ||
109 | scene.EventManager.OnClientClosed -= ClientLoggedOut; | ||
110 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; | ||
111 | m_Scenelist.Remove(scene); | ||
112 | } | ||
113 | |||
114 | public void PostInitialise() | ||
115 | { | ||
88 | } | 116 | } |
89 | 117 | ||
90 | public void Close() | 118 | public void Close() |
@@ -96,9 +124,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
96 | get { return "InventoryModule"; } | 124 | get { return "InventoryModule"; } |
97 | } | 125 | } |
98 | 126 | ||
99 | public bool IsSharedModule | 127 | public Type ReplaceableInterface |
100 | { | 128 | { |
101 | get { return true; } | 129 | get { return null; } |
102 | } | 130 | } |
103 | 131 | ||
104 | #endregion | 132 | #endregion |
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs index 261bd6c..d1d7df2 100644 --- a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs | |||
@@ -37,34 +37,72 @@ using OpenSim.Region.Framework.Scenes; | |||
37 | 37 | ||
38 | namespace OpenSim.Region.CoreModules.Avatar.Lure | 38 | namespace OpenSim.Region.CoreModules.Avatar.Lure |
39 | { | 39 | { |
40 | public class LureModule : IRegionModule | 40 | public class LureModule : ISharedRegionModule |
41 | { | 41 | { |
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 42 | private static readonly ILog m_log = LogManager.GetLogger( |
43 | MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | 44 | ||
44 | private readonly List<Scene> m_scenes = new List<Scene>(); | 45 | private readonly List<Scene> m_scenes = new List<Scene>(); |
45 | 46 | ||
46 | private IMessageTransferModule m_TransferModule = null; | 47 | private IMessageTransferModule m_TransferModule = null; |
48 | private bool m_Enabled = true; | ||
47 | 49 | ||
48 | public void Initialise(Scene scene, IConfigSource config) | 50 | public void Initialise(IConfigSource config) |
49 | { | 51 | { |
50 | if (config.Configs["Messaging"] != null) | 52 | if (config.Configs["Messaging"] != null) |
51 | { | 53 | { |
52 | if (config.Configs["Messaging"].GetString( | 54 | if (config.Configs["Messaging"].GetString( |
53 | "LureModule", "LureModule") != | 55 | "LureModule", "LureModule") != |
54 | "LureModule") | 56 | "LureModule") |
55 | return; | 57 | m_Enabled = false; |
56 | } | 58 | } |
59 | } | ||
60 | |||
61 | public void AddRegion(Scene scene) | ||
62 | { | ||
63 | if (!m_Enabled) | ||
64 | return; | ||
57 | 65 | ||
58 | lock (m_scenes) | 66 | lock (m_scenes) |
59 | { | 67 | { |
60 | if (!m_scenes.Contains(scene)) | 68 | m_scenes.Add(scene); |
69 | scene.EventManager.OnNewClient += OnNewClient; | ||
70 | scene.EventManager.OnIncomingInstantMessage += | ||
71 | OnGridInstantMessage; | ||
72 | } | ||
73 | } | ||
74 | |||
75 | public void RegionLoaded(Scene scene) | ||
76 | { | ||
77 | if (m_TransferModule == null) | ||
78 | { | ||
79 | m_TransferModule = | ||
80 | scene.RequestModuleInterface<IMessageTransferModule>(); | ||
81 | |||
82 | if (m_TransferModule == null) | ||
61 | { | 83 | { |
62 | m_scenes.Add(scene); | 84 | m_log.Error("[INSTANT MESSAGE]: No message transfer module, "+ |
63 | scene.EventManager.OnNewClient += OnNewClient; | 85 | "lures will not work!"); |
64 | scene.EventManager.OnIncomingInstantMessage += | 86 | |
87 | m_Enabled = false; | ||
88 | m_scenes.Clear(); | ||
89 | scene.EventManager.OnNewClient -= OnNewClient; | ||
90 | scene.EventManager.OnIncomingInstantMessage -= | ||
65 | OnGridInstantMessage; | 91 | OnGridInstantMessage; |
66 | } | 92 | } |
67 | } | 93 | } |
94 | |||
95 | } | ||
96 | |||
97 | public void RemoveRegion(Scene scene) | ||
98 | { | ||
99 | lock (m_scenes) | ||
100 | { | ||
101 | m_scenes.Remove(scene); | ||
102 | scene.EventManager.OnNewClient -= OnNewClient; | ||
103 | scene.EventManager.OnIncomingInstantMessage -= | ||
104 | OnGridInstantMessage; | ||
105 | } | ||
68 | } | 106 | } |
69 | 107 | ||
70 | void OnNewClient(IClientAPI client) | 108 | void OnNewClient(IClientAPI client) |
@@ -76,12 +114,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
76 | 114 | ||
77 | public void PostInitialise() | 115 | public void PostInitialise() |
78 | { | 116 | { |
79 | m_TransferModule = | ||
80 | m_scenes[0].RequestModuleInterface<IMessageTransferModule>(); | ||
81 | |||
82 | if (m_TransferModule == null) | ||
83 | m_log.Error("[INSTANT MESSAGE]: No message transfer module, "+ | ||
84 | "lures will not work!"); | ||
85 | } | 117 | } |
86 | 118 | ||
87 | public void Close() | 119 | public void Close() |
@@ -93,9 +125,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
93 | get { return "LureModule"; } | 125 | get { return "LureModule"; } |
94 | } | 126 | } |
95 | 127 | ||
96 | public bool IsSharedModule | 128 | public Type ReplaceableInterface |
97 | { | 129 | { |
98 | get { return true; } | 130 | get { return null; } |
99 | } | 131 | } |
100 | 132 | ||
101 | public void OnInstantMessage(IClientAPI client, GridInstantMessage im) | 133 | public void OnInstantMessage(IClientAPI client, GridInstantMessage im) |
diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs index 6941e00..f1022fd 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs | |||
@@ -37,6 +37,7 @@ using OpenSim.Region.Framework; | |||
37 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
38 | using OpenSim.Region.Framework.Scenes; | 38 | using OpenSim.Region.Framework.Scenes; |
39 | using OpenSim.Services.Interfaces; | 39 | using OpenSim.Services.Interfaces; |
40 | using OpenSim.Server.Base; | ||
40 | 41 | ||
41 | using OpenMetaverse; | 42 | using OpenMetaverse; |
42 | using log4net; | 43 | using log4net; |
@@ -53,6 +54,8 @@ namespace OpenSim.Region.CoreModules.Framework.Library | |||
53 | private string m_LibraryName = "OpenSim Library"; | 54 | private string m_LibraryName = "OpenSim Library"; |
54 | private Scene m_Scene; | 55 | private Scene m_Scene; |
55 | 56 | ||
57 | private ILibraryService m_Library; | ||
58 | |||
56 | #region ISharedRegionModule | 59 | #region ISharedRegionModule |
57 | 60 | ||
58 | public void Initialise(IConfigSource config) | 61 | public void Initialise(IConfigSource config) |
@@ -60,9 +63,22 @@ namespace OpenSim.Region.CoreModules.Framework.Library | |||
60 | m_Enabled = config.Configs["Modules"].GetBoolean("LibraryModule", m_Enabled); | 63 | m_Enabled = config.Configs["Modules"].GetBoolean("LibraryModule", m_Enabled); |
61 | if (m_Enabled) | 64 | if (m_Enabled) |
62 | { | 65 | { |
63 | IConfig libConfig = config.Configs["LibraryModule"]; | 66 | IConfig libConfig = config.Configs["LibraryService"]; |
64 | if (libConfig != null) | 67 | if (libConfig != null) |
65 | m_LibraryName = libConfig.GetString("LibraryName", m_LibraryName); | 68 | { |
69 | string dllName = libConfig.GetString("LocalServiceModule", string.Empty); | ||
70 | m_log.Debug("[LIBRARY MODULE]: Library service dll is " + dllName); | ||
71 | if (dllName != string.Empty) | ||
72 | { | ||
73 | Object[] args = new Object[] { config }; | ||
74 | m_Library = ServerUtils.LoadPlugin<ILibraryService>(dllName, args); | ||
75 | } | ||
76 | } | ||
77 | } | ||
78 | if (m_Library == null) | ||
79 | { | ||
80 | m_log.Warn("[LIBRARY MODULE]: No local library service. Module will be disabled."); | ||
81 | m_Enabled = false; | ||
66 | } | 82 | } |
67 | } | 83 | } |
68 | 84 | ||
@@ -91,10 +107,15 @@ namespace OpenSim.Region.CoreModules.Framework.Library | |||
91 | { | 107 | { |
92 | m_Scene = scene; | 108 | m_Scene = scene; |
93 | } | 109 | } |
110 | scene.RegisterModuleInterface<ILibraryService>(m_Library); | ||
94 | } | 111 | } |
95 | 112 | ||
96 | public void RemoveRegion(Scene scene) | 113 | public void RemoveRegion(Scene scene) |
97 | { | 114 | { |
115 | if (!m_Enabled) | ||
116 | return; | ||
117 | |||
118 | scene.UnregisterModuleInterface<ILibraryService>(m_Library); | ||
98 | } | 119 | } |
99 | 120 | ||
100 | public void RegionLoaded(Scene scene) | 121 | public void RegionLoaded(Scene scene) |
@@ -127,19 +148,17 @@ namespace OpenSim.Region.CoreModules.Framework.Library | |||
127 | 148 | ||
128 | protected void LoadLibrariesFromArchives() | 149 | protected void LoadLibrariesFromArchives() |
129 | { | 150 | { |
130 | InventoryFolderImpl lib = m_Scene.CommsManager.UserProfileCacheService.LibraryRoot; | 151 | InventoryFolderImpl lib = m_Library.LibraryRootFolder; |
131 | if (lib == null) | 152 | if (lib == null) |
132 | { | 153 | { |
133 | m_log.Debug("[LIBRARY MODULE]: No library. Ignoring Library Module"); | 154 | m_log.Debug("[LIBRARY MODULE]: No library. Ignoring Library Module"); |
134 | return; | 155 | return; |
135 | } | 156 | } |
136 | 157 | ||
137 | lib.Name = m_LibraryName; | ||
138 | |||
139 | RegionInfo regInfo = new RegionInfo(); | 158 | RegionInfo regInfo = new RegionInfo(); |
140 | Scene m_MockScene = new Scene(regInfo); | 159 | Scene m_MockScene = new Scene(regInfo); |
141 | m_MockScene.CommsManager = m_Scene.CommsManager; | 160 | m_MockScene.CommsManager = m_Scene.CommsManager; |
142 | LocalInventoryService invService = new LocalInventoryService((LibraryRootFolder)lib); | 161 | LocalInventoryService invService = new LocalInventoryService(lib); |
143 | m_MockScene.RegisterModuleInterface<IInventoryService>(invService); | 162 | m_MockScene.RegisterModuleInterface<IInventoryService>(invService); |
144 | m_MockScene.RegisterModuleInterface<IAssetService>(m_Scene.AssetService); | 163 | m_MockScene.RegisterModuleInterface<IAssetService>(m_Scene.AssetService); |
145 | 164 | ||
@@ -181,7 +200,7 @@ namespace OpenSim.Region.CoreModules.Framework.Library | |||
181 | 200 | ||
182 | private void DumpLibrary() | 201 | private void DumpLibrary() |
183 | { | 202 | { |
184 | InventoryFolderImpl lib = m_Scene.CommsManager.UserProfileCacheService.LibraryRoot; | 203 | InventoryFolderImpl lib = m_Library.LibraryRootFolder; |
185 | 204 | ||
186 | m_log.DebugFormat(" - folder {0}", lib.Name); | 205 | m_log.DebugFormat(" - folder {0}", lib.Name); |
187 | DumpFolder(lib); | 206 | DumpFolder(lib); |
diff --git a/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs b/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs index 2c95b5a..685c031 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs | |||
@@ -41,9 +41,9 @@ namespace OpenSim.Region.CoreModules.Framework.Library | |||
41 | { | 41 | { |
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
43 | 43 | ||
44 | private LibraryRootFolder m_Library; | 44 | private InventoryFolderImpl m_Library; |
45 | 45 | ||
46 | public LocalInventoryService(LibraryRootFolder lib) | 46 | public LocalInventoryService(InventoryFolderImpl lib) |
47 | { | 47 | { |
48 | m_Library = lib; | 48 | m_Library = lib; |
49 | } | 49 | } |
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index beb2307..7b9fdee 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml | |||
@@ -17,15 +17,25 @@ | |||
17 | <RegionModule id="HGWorldMapModule" type="OpenSim.Region.CoreModules.Hypergrid.HGWorldMapModule" /> | 17 | <RegionModule id="HGWorldMapModule" type="OpenSim.Region.CoreModules.Hypergrid.HGWorldMapModule" /> |
18 | <RegionModule id="UrlModule" type="OpenSim.Region.CoreModules.Scripting.LSLHttp.UrlModule" /> | 18 | <RegionModule id="UrlModule" type="OpenSim.Region.CoreModules.Scripting.LSLHttp.UrlModule" /> |
19 | <RegionModule id="Chat" type="OpenSim.Region.CoreModules.Avatar.Chat.ChatModule" /> | 19 | <RegionModule id="Chat" type="OpenSim.Region.CoreModules.Avatar.Chat.ChatModule" /> |
20 | <RegionModule id="FriendsModule" type="OpenSim.Region.CoreModules.Avatar.Friends.FriendsModule" /> | ||
21 | <RegionModule id="PresenceModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.PresenceModule" /> | ||
22 | <RegionModule id="MuteListModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.MuteListModule" /> | ||
23 | <RegionModule id="OfflineMessageModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.OfflineMessageModule" /> | ||
24 | <RegionModule id="InstantMessageModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.InstantMessageModule" /> | ||
25 | <RegionModule id="MessageTransferModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.MessageTransferModule" /> | ||
26 | <RegionModule id="LureModule" type="OpenSim.Region.CoreModules.Avatar.Lure.LureModule" /> | ||
27 | <RegionModule id="InventoryTransferModule" type="OpenSim.Region.CoreModules.Avatar.Inventory.Transfer.InventoryTransferModule" /> | ||
20 | <RegionModule id="CoreAssetCache" type="OpenSim.Region.CoreModules.Asset.CoreAssetCache" /> | 28 | <RegionModule id="CoreAssetCache" type="OpenSim.Region.CoreModules.Asset.CoreAssetCache" /> |
21 | <RegionModule id="GlynnTuckerAssetCache" type="OpenSim.Region.CoreModules.Asset.GlynnTuckerAssetCache" /> | 29 | <RegionModule id="GlynnTuckerAssetCache" type="OpenSim.Region.CoreModules.Asset.GlynnTuckerAssetCache" /> |
22 | <RegionModule id="CenomeMemoryAssetCache" type="OpenSim.Region.CoreModules.Asset.CenomeMemoryAssetCache"/> | 30 | <RegionModule id="CenomeMemoryAssetCache" type="OpenSim.Region.CoreModules.Asset.CenomeMemoryAssetCache"/> |
23 | <RegionModule id="LibraryModule" type="OpenSim.Region.CoreModules.Framework.Library.LibraryModule"/> | 31 | <RegionModule id="LibraryModule" type="OpenSim.Region.CoreModules.Framework.Library.LibraryModule"/> |
24 | <!-- Service connectors OUT modules --> | 32 | <!-- Service connectors OUT modules --> |
25 | <RegionModule id="LocalUserServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.User.LocalUserServicesConnector" /> | ||
26 | <RegionModule id="RemoteUserServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.User.RemoteUserServicesConnector" /> | ||
27 | <RegionModule id="LocalAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.LocalAssetServicesConnector" /> | 33 | <RegionModule id="LocalAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.LocalAssetServicesConnector" /> |
28 | <RegionModule id="RemoteAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.RemoteAssetServicesConnector" /> | 34 | <RegionModule id="RemoteAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.RemoteAssetServicesConnector" /> |
35 | <RegionModule id="LocalAvatarServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar.LocalAvatarServicesConnector" /> | ||
36 | <RegionModule id="RemoteAvatarServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar.RemoteAvatarServicesConnector" /> | ||
37 | <RegionModule id="LocalAuthenticationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication.LocalAuthenticationServicesConnector" /> | ||
38 | <RegionModule id="RemoteAuthenticationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication.RemoteAuthenticationServicesConnector" /> | ||
29 | <RegionModule id="LocalAuthorizationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization.LocalAuthorizationServicesConnector" /> | 39 | <RegionModule id="LocalAuthorizationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization.LocalAuthorizationServicesConnector" /> |
30 | <RegionModule id="RemoteAuthorizationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization.RemoteAuthorizationServicesConnector" /> | 40 | <RegionModule id="RemoteAuthorizationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization.RemoteAuthorizationServicesConnector" /> |
31 | <RegionModule id="HGAssetBroker" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.HGAssetBroker" /> | 41 | <RegionModule id="HGAssetBroker" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.HGAssetBroker" /> |
@@ -41,12 +51,20 @@ | |||
41 | <RegionModule id="LocalGridServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.LocalGridServicesConnector" /> | 51 | <RegionModule id="LocalGridServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.LocalGridServicesConnector" /> |
42 | <RegionModule id="RemoteGridServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.RemoteGridServicesConnector" /> | 52 | <RegionModule id="RemoteGridServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.RemoteGridServicesConnector" /> |
43 | <RegionModule id="HGGridConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.HGGridConnector" /> | 53 | <RegionModule id="HGGridConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.HGGridConnector" /> |
54 | <RegionModule id="LocalPresenceServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.LocalPresenceServicesConnector" /> | ||
55 | <RegionModule id="RemotePresenceServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.RemotePresenceServicesConnector" /> | ||
56 | <RegionModule id="LocalUserAccountServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts.LocalUserAccountServicesConnector" /> | ||
57 | <RegionModule id="RemoteUserAccountServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts.RemoteUserAccountServicesConnector" /> | ||
58 | <RegionModule id="LocalSimulationConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation.LocalSimulationConnectorModule" /> | ||
59 | <RegionModule id="RemoteSimulationConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation.RemoteSimulationConnectorModule" /> | ||
44 | <!-- Service connectors IN modules --> | 60 | <!-- Service connectors IN modules --> |
45 | <RegionModule id="AssetServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset.AssetServiceInConnectorModule" /> | 61 | <RegionModule id="AssetServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset.AssetServiceInConnectorModule" /> |
46 | <RegionModule id="InventoryServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory.InventoryServiceInConnectorModule" /> | 62 | <RegionModule id="InventoryServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory.InventoryServiceInConnectorModule" /> |
47 | <RegionModule id="LandServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Land.LandServiceInConnectorModule" /> | 63 | <RegionModule id="LandServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Land.LandServiceInConnectorModule" /> |
48 | <RegionModule id="NeighbourServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour.NeighbourServiceInConnectorModule" /> \ | 64 | <RegionModule id="NeighbourServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour.NeighbourServiceInConnectorModule" /> \ |
49 | <RegionModule id="HypergridServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid.HypergridServiceInConnectorModule" /> \ | 65 | <RegionModule id="HypergridServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid.HypergridServiceInConnectorModule" /> \ |
66 | <RegionModule id="LLLoginServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Login.LLLoginServiceInConnectorModule" /> \ | ||
67 | <RegionModule id="SimulationServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation.SimulationServiceInConnectorModule" /> \ | ||
50 | 68 | ||
51 | </Extension> | 69 | </Extension> |
52 | 70 | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs new file mode 100644 index 0000000..2a9366c --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs | |||
@@ -0,0 +1,128 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using System.Collections.Generic; | ||
31 | using log4net; | ||
32 | using Nini.Config; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Servers.HttpServer; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | using OpenSim.Region.Framework.Interfaces; | ||
37 | using OpenSim.Server.Base; | ||
38 | using OpenSim.Server.Handlers.Base; | ||
39 | using OpenSim.Server.Handlers.Login; | ||
40 | using OpenSim.Services.Interfaces; | ||
41 | |||
42 | |||
43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Login | ||
44 | { | ||
45 | public class LLLoginServiceInConnectorModule : ISharedRegionModule | ||
46 | { | ||
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | private static bool m_Enabled = false; | ||
49 | private static bool m_Registered = false; | ||
50 | |||
51 | private IConfigSource m_Config; | ||
52 | private List<Scene> m_Scenes = new List<Scene>(); | ||
53 | |||
54 | #region IRegionModule interface | ||
55 | |||
56 | public void Initialise(IConfigSource config) | ||
57 | { | ||
58 | m_Config = config; | ||
59 | |||
60 | IConfig moduleConfig = config.Configs["Modules"]; | ||
61 | if (moduleConfig != null) | ||
62 | { | ||
63 | m_Enabled = moduleConfig.GetBoolean("LLLoginServiceInConnector", false); | ||
64 | if (m_Enabled) | ||
65 | { | ||
66 | m_log.Info("[LLLOGIN IN CONNECTOR]: LLLoginerviceInConnector enabled"); | ||
67 | } | ||
68 | |||
69 | } | ||
70 | |||
71 | } | ||
72 | |||
73 | public void PostInitialise() | ||
74 | { | ||
75 | if (!m_Enabled) | ||
76 | return; | ||
77 | |||
78 | m_log.Info("[LLLOGIN IN CONNECTOR]: Starting..."); | ||
79 | } | ||
80 | |||
81 | public void Close() | ||
82 | { | ||
83 | } | ||
84 | |||
85 | public Type ReplaceableInterface | ||
86 | { | ||
87 | get { return null; } | ||
88 | } | ||
89 | |||
90 | public string Name | ||
91 | { | ||
92 | get { return "LLLoginServiceInConnectorModule"; } | ||
93 | } | ||
94 | |||
95 | public void AddRegion(Scene scene) | ||
96 | { | ||
97 | if (!m_Enabled) | ||
98 | return; | ||
99 | |||
100 | m_Scenes.Add(scene); | ||
101 | |||
102 | } | ||
103 | |||
104 | public void RemoveRegion(Scene scene) | ||
105 | { | ||
106 | if (m_Enabled && m_Scenes.Contains(scene)) | ||
107 | m_Scenes.Remove(scene); | ||
108 | } | ||
109 | |||
110 | public void RegionLoaded(Scene scene) | ||
111 | { | ||
112 | if (!m_Enabled) | ||
113 | return; | ||
114 | |||
115 | if (!m_Registered) | ||
116 | { | ||
117 | m_Registered = true; | ||
118 | new LLLoginServiceInConnector(m_Config, MainServer.Instance, scene); | ||
119 | //Object[] args = new Object[] { m_Config, MainServer.Instance, this, scene }; | ||
120 | //ServerUtils.LoadPlugin<IServiceConnector>("OpenSim.Server.Handlers.dll:LLLoginServiceInConnector", args); | ||
121 | } | ||
122 | |||
123 | } | ||
124 | |||
125 | #endregion | ||
126 | |||
127 | } | ||
128 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs index f28a318..5ee1c97 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs | |||
@@ -58,11 +58,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation | |||
58 | IConfig moduleConfig = config.Configs["Modules"]; | 58 | IConfig moduleConfig = config.Configs["Modules"]; |
59 | if (moduleConfig != null) | 59 | if (moduleConfig != null) |
60 | { | 60 | { |
61 | string name = moduleConfig.GetString("SimulationService", ""); | 61 | m_Enabled = moduleConfig.GetBoolean("SimulationServiceInConnector", false); |
62 | if (name == Name) | 62 | if (m_Enabled) |
63 | { | 63 | { |
64 | m_Enabled = true; | 64 | m_log.Info("[SIM SERVICE]: SimulationService IN connector enabled"); |
65 | m_log.Info("[SIM SERVICE]: SimulationService enabled"); | ||
66 | 65 | ||
67 | } | 66 | } |
68 | } | 67 | } |
@@ -84,7 +83,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation | |||
84 | 83 | ||
85 | public string Name | 84 | public string Name |
86 | { | 85 | { |
87 | get { return "SimulationService"; } | 86 | get { return "SimulationServiceInConnectorModule"; } |
88 | } | 87 | } |
89 | 88 | ||
90 | public void AddRegion(Scene scene) | 89 | public void AddRegion(Scene scene) |
@@ -92,6 +91,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation | |||
92 | if (!m_Enabled) | 91 | if (!m_Enabled) |
93 | return; | 92 | return; |
94 | 93 | ||
94 | } | ||
95 | |||
96 | public void RemoveRegion(Scene scene) | ||
97 | { | ||
98 | } | ||
99 | |||
100 | public void RegionLoaded(Scene scene) | ||
101 | { | ||
102 | if (!m_Enabled) | ||
103 | return; | ||
104 | |||
95 | if (!m_Registered) | 105 | if (!m_Registered) |
96 | { | 106 | { |
97 | m_Registered = true; | 107 | m_Registered = true; |
@@ -104,14 +114,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation | |||
104 | } | 114 | } |
105 | } | 115 | } |
106 | 116 | ||
107 | public void RemoveRegion(Scene scene) | ||
108 | { | ||
109 | } | ||
110 | |||
111 | public void RegionLoaded(Scene scene) | ||
112 | { | ||
113 | } | ||
114 | |||
115 | #endregion | 117 | #endregion |
116 | 118 | ||
117 | } | 119 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs new file mode 100644 index 0000000..4c65722 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs | |||
@@ -0,0 +1,159 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using Nini.Config; | ||
33 | using OpenSim.Region.Framework.Interfaces; | ||
34 | using OpenSim.Region.Framework.Scenes; | ||
35 | using OpenSim.Server.Base; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | |||
38 | using OpenMetaverse; | ||
39 | |||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication | ||
41 | { | ||
42 | public class LocalAuthenticationServicesConnector : ISharedRegionModule, IAuthenticationService | ||
43 | { | ||
44 | private static readonly ILog m_log = | ||
45 | LogManager.GetLogger( | ||
46 | MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | private IAuthenticationService m_AuthenticationService; | ||
49 | |||
50 | private bool m_Enabled = false; | ||
51 | |||
52 | #region ISharedRegionModule | ||
53 | |||
54 | public Type ReplaceableInterface | ||
55 | { | ||
56 | get { return null; } | ||
57 | } | ||
58 | |||
59 | public string Name | ||
60 | { | ||
61 | get { return "LocalAuthenticationServicesConnector"; } | ||
62 | } | ||
63 | |||
64 | public void Initialise(IConfigSource source) | ||
65 | { | ||
66 | IConfig moduleConfig = source.Configs["Modules"]; | ||
67 | if (moduleConfig != null) | ||
68 | { | ||
69 | string name = moduleConfig.GetString("AuthenticationServices", ""); | ||
70 | if (name == Name) | ||
71 | { | ||
72 | IConfig userConfig = source.Configs["AuthenticationService"]; | ||
73 | if (userConfig == null) | ||
74 | { | ||
75 | m_log.Error("[AUTH CONNECTOR]: AuthenticationService missing from OpenSim.ini"); | ||
76 | return; | ||
77 | } | ||
78 | |||
79 | string serviceDll = userConfig.GetString("LocalServiceModule", | ||
80 | String.Empty); | ||
81 | |||
82 | if (serviceDll == String.Empty) | ||
83 | { | ||
84 | m_log.Error("[AUTH CONNECTOR]: No LocalServiceModule named in section AuthenticationService"); | ||
85 | return; | ||
86 | } | ||
87 | |||
88 | Object[] args = new Object[] { source }; | ||
89 | m_AuthenticationService = | ||
90 | ServerUtils.LoadPlugin<IAuthenticationService>(serviceDll, | ||
91 | args); | ||
92 | |||
93 | if (m_AuthenticationService == null) | ||
94 | { | ||
95 | m_log.Error("[AUTH CONNECTOR]: Can't load Authentication service"); | ||
96 | return; | ||
97 | } | ||
98 | m_Enabled = true; | ||
99 | m_log.Info("[AUTH CONNECTOR]: Local Authentication connector enabled"); | ||
100 | } | ||
101 | } | ||
102 | } | ||
103 | |||
104 | public void PostInitialise() | ||
105 | { | ||
106 | if (!m_Enabled) | ||
107 | return; | ||
108 | } | ||
109 | |||
110 | public void Close() | ||
111 | { | ||
112 | if (!m_Enabled) | ||
113 | return; | ||
114 | } | ||
115 | |||
116 | public void AddRegion(Scene scene) | ||
117 | { | ||
118 | if (!m_Enabled) | ||
119 | return; | ||
120 | |||
121 | scene.RegisterModuleInterface<IAuthenticationService>(m_AuthenticationService); | ||
122 | } | ||
123 | |||
124 | public void RemoveRegion(Scene scene) | ||
125 | { | ||
126 | if (!m_Enabled) | ||
127 | return; | ||
128 | } | ||
129 | |||
130 | public void RegionLoaded(Scene scene) | ||
131 | { | ||
132 | if (!m_Enabled) | ||
133 | return; | ||
134 | } | ||
135 | |||
136 | #endregion | ||
137 | |||
138 | #region IAuthenticationService | ||
139 | |||
140 | public string Authenticate(UUID principalID, string password, int lifetime) | ||
141 | { | ||
142 | // Not implemented at the regions | ||
143 | return string.Empty; | ||
144 | } | ||
145 | |||
146 | public bool Verify(UUID principalID, string token, int lifetime) | ||
147 | { | ||
148 | return m_AuthenticationService.Verify(principalID, token, lifetime); | ||
149 | } | ||
150 | |||
151 | public bool Release(UUID principalID, string token) | ||
152 | { | ||
153 | return m_AuthenticationService.Release(principalID, token); | ||
154 | } | ||
155 | |||
156 | #endregion | ||
157 | |||
158 | } | ||
159 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/RemoteAuthenticationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/RemoteAuthenticationServiceConnector.cs new file mode 100644 index 0000000..a053bc2 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/RemoteAuthenticationServiceConnector.cs | |||
@@ -0,0 +1,114 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using Nini.Config; | ||
30 | using log4net; | ||
31 | using System.Reflection; | ||
32 | using OpenSim.Region.Framework.Interfaces; | ||
33 | using OpenSim.Region.Framework.Scenes; | ||
34 | using OpenSim.Services.Interfaces; | ||
35 | using OpenSim.Services.Connectors; | ||
36 | |||
37 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication | ||
38 | { | ||
39 | public class RemoteAuthenticationServicesConnector : AuthenticationServicesConnector, | ||
40 | ISharedRegionModule, IAuthenticationService | ||
41 | { | ||
42 | private static readonly ILog m_log = | ||
43 | LogManager.GetLogger( | ||
44 | MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | |||
46 | private bool m_Enabled = false; | ||
47 | |||
48 | public Type ReplaceableInterface | ||
49 | { | ||
50 | get { return null; } | ||
51 | } | ||
52 | |||
53 | public string Name | ||
54 | { | ||
55 | get { return "RemoteAuthenticationServicesConnector"; } | ||
56 | } | ||
57 | |||
58 | public override void Initialise(IConfigSource source) | ||
59 | { | ||
60 | IConfig moduleConfig = source.Configs["Modules"]; | ||
61 | if (moduleConfig != null) | ||
62 | { | ||
63 | string name = moduleConfig.GetString("AuthenticationServices", ""); | ||
64 | if (name == Name) | ||
65 | { | ||
66 | IConfig userConfig = source.Configs["AuthenticationService"]; | ||
67 | if (userConfig == null) | ||
68 | { | ||
69 | m_log.Error("[AUTH CONNECTOR]: AuthenticationService missing from OpenSim.ini"); | ||
70 | return; | ||
71 | } | ||
72 | |||
73 | m_Enabled = true; | ||
74 | |||
75 | base.Initialise(source); | ||
76 | |||
77 | m_log.Info("[AUTH CONNECTOR]: Remote Authentication enabled"); | ||
78 | } | ||
79 | } | ||
80 | } | ||
81 | |||
82 | public void PostInitialise() | ||
83 | { | ||
84 | if (!m_Enabled) | ||
85 | return; | ||
86 | } | ||
87 | |||
88 | public void Close() | ||
89 | { | ||
90 | if (!m_Enabled) | ||
91 | return; | ||
92 | } | ||
93 | |||
94 | public void AddRegion(Scene scene) | ||
95 | { | ||
96 | if (!m_Enabled) | ||
97 | return; | ||
98 | |||
99 | scene.RegisterModuleInterface<IAuthenticationService>(this); | ||
100 | } | ||
101 | |||
102 | public void RemoveRegion(Scene scene) | ||
103 | { | ||
104 | if (!m_Enabled) | ||
105 | return; | ||
106 | } | ||
107 | |||
108 | public void RegionLoaded(Scene scene) | ||
109 | { | ||
110 | if (!m_Enabled) | ||
111 | return; | ||
112 | } | ||
113 | } | ||
114 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs new file mode 100644 index 0000000..0c8ee61 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs | |||
@@ -0,0 +1,168 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using Nini.Config; | ||
33 | using OpenSim.Region.Framework.Interfaces; | ||
34 | using OpenSim.Region.Framework.Scenes; | ||
35 | using OpenSim.Server.Base; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | |||
38 | using OpenMetaverse; | ||
39 | |||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar | ||
41 | { | ||
42 | public class LocalAvatarServicesConnector : ISharedRegionModule, IAvatarService | ||
43 | { | ||
44 | private static readonly ILog m_log = | ||
45 | LogManager.GetLogger( | ||
46 | MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | private IAvatarService m_AvatarService; | ||
49 | |||
50 | private bool m_Enabled = false; | ||
51 | |||
52 | #region ISharedRegionModule | ||
53 | |||
54 | public Type ReplaceableInterface | ||
55 | { | ||
56 | get { return null; } | ||
57 | } | ||
58 | |||
59 | public string Name | ||
60 | { | ||
61 | get { return "LocalAvatarServicesConnector"; } | ||
62 | } | ||
63 | |||
64 | public void Initialise(IConfigSource source) | ||
65 | { | ||
66 | IConfig moduleConfig = source.Configs["Modules"]; | ||
67 | if (moduleConfig != null) | ||
68 | { | ||
69 | string name = moduleConfig.GetString("AvatarServices", ""); | ||
70 | if (name == Name) | ||
71 | { | ||
72 | IConfig userConfig = source.Configs["AvatarService"]; | ||
73 | if (userConfig == null) | ||
74 | { | ||
75 | m_log.Error("[USER CONNECTOR]: AvatarService missing from OpenSim.ini"); | ||
76 | return; | ||
77 | } | ||
78 | |||
79 | string serviceDll = userConfig.GetString("LocalServiceModule", | ||
80 | String.Empty); | ||
81 | |||
82 | if (serviceDll == String.Empty) | ||
83 | { | ||
84 | m_log.Error("[USER CONNECTOR]: No LocalServiceModule named in section AvatarService"); | ||
85 | return; | ||
86 | } | ||
87 | |||
88 | Object[] args = new Object[] { source }; | ||
89 | m_AvatarService = | ||
90 | ServerUtils.LoadPlugin<IAvatarService>(serviceDll, | ||
91 | args); | ||
92 | |||
93 | if (m_AvatarService == null) | ||
94 | { | ||
95 | m_log.Error("[USER CONNECTOR]: Can't load user account service"); | ||
96 | return; | ||
97 | } | ||
98 | m_Enabled = true; | ||
99 | m_log.Info("[USER CONNECTOR]: Local avatar connector enabled"); | ||
100 | } | ||
101 | } | ||
102 | } | ||
103 | |||
104 | public void PostInitialise() | ||
105 | { | ||
106 | if (!m_Enabled) | ||
107 | return; | ||
108 | } | ||
109 | |||
110 | public void Close() | ||
111 | { | ||
112 | if (!m_Enabled) | ||
113 | return; | ||
114 | } | ||
115 | |||
116 | public void AddRegion(Scene scene) | ||
117 | { | ||
118 | if (!m_Enabled) | ||
119 | return; | ||
120 | |||
121 | scene.RegisterModuleInterface<IAvatarService>(m_AvatarService); | ||
122 | } | ||
123 | |||
124 | public void RemoveRegion(Scene scene) | ||
125 | { | ||
126 | if (!m_Enabled) | ||
127 | return; | ||
128 | } | ||
129 | |||
130 | public void RegionLoaded(Scene scene) | ||
131 | { | ||
132 | if (!m_Enabled) | ||
133 | return; | ||
134 | } | ||
135 | |||
136 | #endregion | ||
137 | |||
138 | #region IAvatarService | ||
139 | |||
140 | public AvatarData GetAvatar(UUID userID) | ||
141 | { | ||
142 | return m_AvatarService.GetAvatar(userID); | ||
143 | } | ||
144 | |||
145 | public bool SetAvatar(UUID userID, AvatarData avatar) | ||
146 | { | ||
147 | return m_AvatarService.SetAvatar(userID, avatar); | ||
148 | } | ||
149 | |||
150 | public bool ResetAvatar(UUID userID) | ||
151 | { | ||
152 | return m_AvatarService.ResetAvatar(userID); | ||
153 | } | ||
154 | |||
155 | public bool SetItems(UUID userID, string[] names, string[] values) | ||
156 | { | ||
157 | return m_AvatarService.SetItems(userID, names, values); | ||
158 | } | ||
159 | |||
160 | public bool RemoveItems(UUID userID, string[] names) | ||
161 | { | ||
162 | return m_AvatarService.RemoveItems(userID, names); | ||
163 | } | ||
164 | |||
165 | #endregion | ||
166 | |||
167 | } | ||
168 | } | ||
diff --git a/OpenSim/Services/Connectors/User/UserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs index 683990f..48759b5 100644 --- a/OpenSim/Services/Connectors/User/UserServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs | |||
@@ -25,90 +25,90 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using log4net; | ||
29 | using System; | 28 | using System; |
30 | using System.Collections.Generic; | ||
31 | using System.IO; | ||
32 | using System.Reflection; | ||
33 | using Nini.Config; | 29 | using Nini.Config; |
34 | using OpenSim.Framework; | 30 | using log4net; |
35 | using OpenSim.Framework.Communications; | 31 | using System.Reflection; |
36 | using OpenSim.Framework.Servers.HttpServer; | 32 | using OpenSim.Region.Framework.Interfaces; |
33 | using OpenSim.Region.Framework.Scenes; | ||
37 | using OpenSim.Services.Interfaces; | 34 | using OpenSim.Services.Interfaces; |
38 | using OpenMetaverse; | 35 | using OpenSim.Services.Connectors; |
39 | 36 | ||
40 | namespace OpenSim.Services.Connectors | 37 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar |
41 | { | 38 | { |
42 | public class UserServicesConnector : IUserAccountService | 39 | public class RemoteAvatarServicesConnector : AvatarServicesConnector, |
40 | ISharedRegionModule, IAvatarService | ||
43 | { | 41 | { |
44 | private static readonly ILog m_log = | 42 | private static readonly ILog m_log = |
45 | LogManager.GetLogger( | 43 | LogManager.GetLogger( |
46 | MethodBase.GetCurrentMethod().DeclaringType); | 44 | MethodBase.GetCurrentMethod().DeclaringType); |
47 | 45 | ||
48 | // private string m_ServerURI = String.Empty; | 46 | private bool m_Enabled = false; |
49 | |||
50 | public UserServicesConnector() | ||
51 | { | ||
52 | } | ||
53 | 47 | ||
54 | public UserServicesConnector(string serverURI) | 48 | public Type ReplaceableInterface |
55 | { | 49 | { |
56 | // m_ServerURI = serverURI.TrimEnd('/'); | 50 | get { return null; } |
57 | } | 51 | } |
58 | 52 | ||
59 | public UserServicesConnector(IConfigSource source) | 53 | public string Name |
60 | { | 54 | { |
61 | Initialise(source); | 55 | get { return "RemoteAvatarServicesConnector"; } |
62 | } | 56 | } |
63 | 57 | ||
64 | public virtual void Initialise(IConfigSource source) | 58 | public override void Initialise(IConfigSource source) |
65 | { | 59 | { |
66 | IConfig assetConfig = source.Configs["UserService"]; | 60 | IConfig moduleConfig = source.Configs["Modules"]; |
67 | if (assetConfig == null) | 61 | if (moduleConfig != null) |
68 | { | 62 | { |
69 | m_log.Error("[USER CONNECTOR]: UserService missing from OpanSim.ini"); | 63 | string name = moduleConfig.GetString("AvatarServices", ""); |
70 | throw new Exception("User connector init error"); | 64 | if (name == Name) |
71 | } | 65 | { |
66 | IConfig userConfig = source.Configs["AvatarService"]; | ||
67 | if (userConfig == null) | ||
68 | { | ||
69 | m_log.Error("[AVATAR CONNECTOR]: AvatarService missing from OpanSim.ini"); | ||
70 | return; | ||
71 | } | ||
72 | 72 | ||
73 | string serviceURI = assetConfig.GetString("UserServerURI", | 73 | m_Enabled = true; |
74 | String.Empty); | ||
75 | 74 | ||
76 | if (serviceURI == String.Empty) | 75 | base.Initialise(source); |
77 | { | 76 | |
78 | m_log.Error("[USER CONNECTOR]: No Server URI named in section UserService"); | 77 | m_log.Info("[AVATAR CONNECTOR]: Remote avatars enabled"); |
79 | throw new Exception("User connector init error"); | 78 | } |
80 | } | 79 | } |
81 | //m_ServerURI = serviceURI; | ||
82 | } | 80 | } |
83 | 81 | ||
84 | public UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) | 82 | public void PostInitialise() |
85 | { | 83 | { |
86 | return null; | 84 | if (!m_Enabled) |
85 | return; | ||
87 | } | 86 | } |
88 | 87 | ||
89 | public UserAccount GetUserAccount(UUID scopeID, UUID userID) | 88 | public void Close() |
90 | { | 89 | { |
91 | return null; | 90 | if (!m_Enabled) |
91 | return; | ||
92 | } | 92 | } |
93 | 93 | ||
94 | public bool SetHomePosition(UserAccount data, UUID regionID, UUID regionSecret) | 94 | public void AddRegion(Scene scene) |
95 | { | 95 | { |
96 | return false; | 96 | if (!m_Enabled) |
97 | } | 97 | return; |
98 | 98 | ||
99 | public bool SetUserAccount(UserAccount data, UUID principalID, string token) | 99 | scene.RegisterModuleInterface<IAvatarService>(this); |
100 | { | ||
101 | return false; | ||
102 | } | 100 | } |
103 | 101 | ||
104 | public bool CreateUserAccount(UserAccount data, UUID principalID, string token) | 102 | public void RemoveRegion(Scene scene) |
105 | { | 103 | { |
106 | return false; | 104 | if (!m_Enabled) |
105 | return; | ||
107 | } | 106 | } |
108 | 107 | ||
109 | public List<UserAccount> GetUserAccount(UUID scopeID, string query) | 108 | public void RegionLoaded(Scene scene) |
110 | { | 109 | { |
111 | return null; | 110 | if (!m_Enabled) |
111 | return; | ||
112 | } | 112 | } |
113 | } | 113 | } |
114 | } | 114 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs index 44458d1..fa3681a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs | |||
@@ -436,12 +436,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
436 | } | 436 | } |
437 | 437 | ||
438 | OSDMap resp = new OSDMap(2); | 438 | OSDMap resp = new OSDMap(2); |
439 | string reason = String.Empty; | 439 | string reason = String.Empty; |
440 | uint teleportFlags = 0; | 440 | uint teleportFlags = 0; |
441 | if (args.ContainsKey("teleport_flags")) | 441 | if (args.ContainsKey("teleport_flags")) |
442 | { | 442 | { |
443 | teleportFlags = args["teleport_flags"].AsUInteger(); | 443 | teleportFlags = args["teleport_flags"].AsUInteger(); |
444 | } | 444 | } |
445 | 445 | ||
446 | // This is the meaning of POST agent | 446 | // This is the meaning of POST agent |
447 | m_regionClient.AdjustUserInformation(aCircuit); | 447 | m_regionClient.AdjustUserInformation(aCircuit); |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs new file mode 100644 index 0000000..2cb18c7 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs | |||
@@ -0,0 +1,200 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | |||
31 | using OpenSim.Region.Framework.Interfaces; | ||
32 | using OpenSim.Region.Framework.Scenes; | ||
33 | using OpenSim.Server.Base; | ||
34 | using OpenSim.Services.Interfaces; | ||
35 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | ||
36 | |||
37 | using OpenMetaverse; | ||
38 | using log4net; | ||
39 | using Nini.Config; | ||
40 | |||
41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | ||
42 | { | ||
43 | public class LocalPresenceServicesConnector : ISharedRegionModule, IPresenceService | ||
44 | { | ||
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | private bool m_Enabled = false; | ||
48 | |||
49 | private PresenceDetector m_PresenceDetector; | ||
50 | private IPresenceService m_PresenceService; | ||
51 | |||
52 | public LocalPresenceServicesConnector() | ||
53 | { | ||
54 | } | ||
55 | |||
56 | public LocalPresenceServicesConnector(IConfigSource source) | ||
57 | { | ||
58 | Initialise(source); | ||
59 | } | ||
60 | |||
61 | #region ISharedRegionModule | ||
62 | |||
63 | public Type ReplaceableInterface | ||
64 | { | ||
65 | get { return null; } | ||
66 | } | ||
67 | |||
68 | public string Name | ||
69 | { | ||
70 | get { return "LocalPresenceServicesConnector"; } | ||
71 | } | ||
72 | |||
73 | public void Initialise(IConfigSource source) | ||
74 | { | ||
75 | IConfig moduleConfig = source.Configs["Modules"]; | ||
76 | if (moduleConfig != null) | ||
77 | { | ||
78 | string name = moduleConfig.GetString("PresenceServices", ""); | ||
79 | if (name == Name) | ||
80 | { | ||
81 | IConfig inventoryConfig = source.Configs["PresenceService"]; | ||
82 | if (inventoryConfig == null) | ||
83 | { | ||
84 | m_log.Error("[LOCAL PRESENCE CONNECTOR]: PresenceService missing from OpenSim.ini"); | ||
85 | return; | ||
86 | } | ||
87 | |||
88 | string serviceDll = inventoryConfig.GetString("LocalServiceModule", String.Empty); | ||
89 | |||
90 | if (serviceDll == String.Empty) | ||
91 | { | ||
92 | m_log.Error("[LOCAL PRESENCE CONNECTOR]: No LocalServiceModule named in section PresenceService"); | ||
93 | return; | ||
94 | } | ||
95 | |||
96 | Object[] args = new Object[] { source }; | ||
97 | m_log.DebugFormat("[LOCAL PRESENCE CONNECTOR]: Service dll = {0}", serviceDll); | ||
98 | |||
99 | m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(serviceDll, args); | ||
100 | |||
101 | if (m_PresenceService == null) | ||
102 | { | ||
103 | m_log.Error("[LOCAL PRESENCE CONNECTOR]: Can't load presence service"); | ||
104 | //return; | ||
105 | throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); | ||
106 | } | ||
107 | |||
108 | //Init(source); | ||
109 | |||
110 | m_PresenceDetector = new PresenceDetector(this); | ||
111 | |||
112 | m_Enabled = true; | ||
113 | m_log.Info("[LOCAL PRESENCE CONNECTOR]: Local presence connector enabled"); | ||
114 | } | ||
115 | } | ||
116 | } | ||
117 | |||
118 | public void PostInitialise() | ||
119 | { | ||
120 | } | ||
121 | |||
122 | public void Close() | ||
123 | { | ||
124 | } | ||
125 | |||
126 | public void AddRegion(Scene scene) | ||
127 | { | ||
128 | if (!m_Enabled) | ||
129 | return; | ||
130 | |||
131 | // m_log.DebugFormat( | ||
132 | // "[LOCAL PRESENCE CONNECTOR]: Registering IPresenceService to scene {0}", scene.RegionInfo.RegionName); | ||
133 | |||
134 | scene.RegisterModuleInterface<IPresenceService>(this); | ||
135 | m_PresenceDetector.AddRegion(scene); | ||
136 | |||
137 | m_log.InfoFormat("[LOCAL PRESENCE CONNECTOR]: Enabled local presence for region {0}", scene.RegionInfo.RegionName); | ||
138 | |||
139 | } | ||
140 | |||
141 | public void RemoveRegion(Scene scene) | ||
142 | { | ||
143 | if (!m_Enabled) | ||
144 | return; | ||
145 | |||
146 | m_PresenceDetector.RemoveRegion(scene); | ||
147 | } | ||
148 | |||
149 | public void RegionLoaded(Scene scene) | ||
150 | { | ||
151 | if (!m_Enabled) | ||
152 | return; | ||
153 | |||
154 | } | ||
155 | |||
156 | #endregion | ||
157 | |||
158 | #region IPresenceService | ||
159 | |||
160 | public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) | ||
161 | { | ||
162 | m_log.Warn("[LOCAL PRESENCE CONNECTOR]: LoginAgent connector not implemented at the simulators"); | ||
163 | return false; | ||
164 | } | ||
165 | |||
166 | public bool LogoutAgent(UUID sessionID) | ||
167 | { | ||
168 | return m_PresenceService.LogoutAgent(sessionID); | ||
169 | } | ||
170 | |||
171 | |||
172 | public bool LogoutRegionAgents(UUID regionID) | ||
173 | { | ||
174 | return m_PresenceService.LogoutRegionAgents(regionID); | ||
175 | } | ||
176 | |||
177 | public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
178 | { | ||
179 | return m_PresenceService.ReportAgent(sessionID, regionID, position, lookAt); | ||
180 | } | ||
181 | |||
182 | public PresenceInfo GetAgent(UUID sessionID) | ||
183 | { | ||
184 | return m_PresenceService.GetAgent(sessionID); | ||
185 | } | ||
186 | |||
187 | public PresenceInfo[] GetAgents(string[] userIDs) | ||
188 | { | ||
189 | return m_PresenceService.GetAgents(userIDs); | ||
190 | } | ||
191 | |||
192 | public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
193 | { | ||
194 | return m_PresenceService.SetHomeLocation(userID, regionID, position, lookAt); | ||
195 | } | ||
196 | |||
197 | #endregion | ||
198 | |||
199 | } | ||
200 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs new file mode 100644 index 0000000..3ca5560 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs | |||
@@ -0,0 +1,84 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | |||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Framework.Scenes; | ||
33 | using OpenSim.Services.Interfaces; | ||
34 | |||
35 | using OpenMetaverse; | ||
36 | using log4net; | ||
37 | |||
38 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | ||
39 | { | ||
40 | public class PresenceDetector | ||
41 | { | ||
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | private IPresenceService m_PresenceService; | ||
45 | |||
46 | public PresenceDetector(IPresenceService presenceservice) | ||
47 | { | ||
48 | m_PresenceService = presenceservice; | ||
49 | } | ||
50 | |||
51 | public void AddRegion(Scene scene) | ||
52 | { | ||
53 | scene.EventManager.OnMakeRootAgent += OnMakeRootAgent; | ||
54 | scene.EventManager.OnNewClient += OnNewClient; | ||
55 | |||
56 | m_PresenceService.LogoutRegionAgents(scene.RegionInfo.RegionID); | ||
57 | } | ||
58 | |||
59 | public void RemoveRegion(Scene scene) | ||
60 | { | ||
61 | scene.EventManager.OnMakeRootAgent -= OnMakeRootAgent; | ||
62 | scene.EventManager.OnNewClient -= OnNewClient; | ||
63 | |||
64 | m_PresenceService.LogoutRegionAgents(scene.RegionInfo.RegionID); | ||
65 | } | ||
66 | |||
67 | public void OnMakeRootAgent(ScenePresence sp) | ||
68 | { | ||
69 | m_log.DebugFormat("[PRESENCE DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName); | ||
70 | m_PresenceService.ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); | ||
71 | } | ||
72 | |||
73 | public void OnNewClient(IClientAPI client) | ||
74 | { | ||
75 | client.OnLogout += OnLogout; | ||
76 | } | ||
77 | |||
78 | public void OnLogout(IClientAPI client) | ||
79 | { | ||
80 | client.OnLogout -= OnLogout; | ||
81 | m_PresenceService.LogoutAgent(client.SessionId); | ||
82 | } | ||
83 | } | ||
84 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs new file mode 100644 index 0000000..e8e140a --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs | |||
@@ -0,0 +1,164 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | |||
31 | using OpenSim.Region.Framework.Interfaces; | ||
32 | using OpenSim.Region.Framework.Scenes; | ||
33 | using OpenSim.Server.Base; | ||
34 | using OpenSim.Services.Interfaces; | ||
35 | using OpenSim.Services.Connectors; | ||
36 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | ||
37 | |||
38 | using OpenMetaverse; | ||
39 | using log4net; | ||
40 | using Nini.Config; | ||
41 | |||
42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | ||
43 | { | ||
44 | public class RemotePresenceServicesConnector : ISharedRegionModule, IPresenceService | ||
45 | { | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | #region ISharedRegionModule | ||
49 | |||
50 | private bool m_Enabled = false; | ||
51 | |||
52 | private PresenceDetector m_PresenceDetector; | ||
53 | private IPresenceService m_RemoteConnector; | ||
54 | |||
55 | public Type ReplaceableInterface | ||
56 | { | ||
57 | get { return null; } | ||
58 | } | ||
59 | |||
60 | public string Name | ||
61 | { | ||
62 | get { return "RemotePresenceServiceConnector"; } | ||
63 | } | ||
64 | |||
65 | public void Initialise(IConfigSource source) | ||
66 | { | ||
67 | IConfig moduleConfig = source.Configs["Modules"]; | ||
68 | if (moduleConfig != null) | ||
69 | { | ||
70 | string name = moduleConfig.GetString("PresenceServices", ""); | ||
71 | if (name == Name) | ||
72 | { | ||
73 | m_RemoteConnector = new PresenceServicesConnector(source); | ||
74 | |||
75 | m_Enabled = true; | ||
76 | |||
77 | m_PresenceDetector = new PresenceDetector(this); | ||
78 | |||
79 | m_log.Info("[INVENTORY CONNECTOR]: Remote presence enabled"); | ||
80 | } | ||
81 | } | ||
82 | |||
83 | } | ||
84 | |||
85 | public void PostInitialise() | ||
86 | { | ||
87 | } | ||
88 | |||
89 | public void Close() | ||
90 | { | ||
91 | } | ||
92 | |||
93 | public void AddRegion(Scene scene) | ||
94 | { | ||
95 | if (!m_Enabled) | ||
96 | return; | ||
97 | |||
98 | scene.RegisterModuleInterface<IPresenceService>(this); | ||
99 | m_PresenceDetector.AddRegion(scene); | ||
100 | |||
101 | m_log.InfoFormat("[REMOTE PRESENCE CONNECTOR]: Enabled remote presence for region {0}", scene.RegionInfo.RegionName); | ||
102 | |||
103 | } | ||
104 | |||
105 | public void RemoveRegion(Scene scene) | ||
106 | { | ||
107 | if (!m_Enabled) | ||
108 | return; | ||
109 | |||
110 | m_PresenceDetector.RemoveRegion(scene); | ||
111 | } | ||
112 | |||
113 | public void RegionLoaded(Scene scene) | ||
114 | { | ||
115 | if (!m_Enabled) | ||
116 | return; | ||
117 | |||
118 | } | ||
119 | |||
120 | #endregion | ||
121 | |||
122 | #region IPresenceService | ||
123 | |||
124 | public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) | ||
125 | { | ||
126 | m_log.Warn("[REMOTE PRESENCE CONNECTOR]: LoginAgent connector not implemented at the simulators"); | ||
127 | return false; | ||
128 | } | ||
129 | |||
130 | public bool LogoutAgent(UUID sessionID) | ||
131 | { | ||
132 | return m_RemoteConnector.LogoutAgent(sessionID); | ||
133 | } | ||
134 | |||
135 | |||
136 | public bool LogoutRegionAgents(UUID regionID) | ||
137 | { | ||
138 | return m_RemoteConnector.LogoutRegionAgents(regionID); | ||
139 | } | ||
140 | |||
141 | public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
142 | { | ||
143 | return m_RemoteConnector.ReportAgent(sessionID, regionID, position, lookAt); | ||
144 | } | ||
145 | |||
146 | public PresenceInfo GetAgent(UUID sessionID) | ||
147 | { | ||
148 | return m_RemoteConnector.GetAgent(sessionID); | ||
149 | } | ||
150 | |||
151 | public PresenceInfo[] GetAgents(string[] userIDs) | ||
152 | { | ||
153 | return m_RemoteConnector.GetAgents(userIDs); | ||
154 | } | ||
155 | |||
156 | public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
157 | { | ||
158 | return m_RemoteConnector.SetHomeLocation(userID, regionID, position, lookAt); | ||
159 | } | ||
160 | |||
161 | #endregion | ||
162 | |||
163 | } | ||
164 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs new file mode 100644 index 0000000..ebb2c3e --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs | |||
@@ -0,0 +1,104 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using log4net.Config; | ||
34 | using NUnit.Framework; | ||
35 | using NUnit.Framework.SyntaxHelpers; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Framework; | ||
38 | using Nini.Config; | ||
39 | |||
40 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | ||
43 | using OpenSim.Tests.Common; | ||
44 | using OpenSim.Tests.Common.Setup; | ||
45 | |||
46 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests | ||
47 | { | ||
48 | [TestFixture] | ||
49 | public class PresenceConnectorsTests | ||
50 | { | ||
51 | LocalPresenceServicesConnector m_LocalConnector; | ||
52 | private void SetUp() | ||
53 | { | ||
54 | IConfigSource config = new IniConfigSource(); | ||
55 | config.AddConfig("Modules"); | ||
56 | config.AddConfig("PresenceService"); | ||
57 | config.Configs["Modules"].Set("PresenceServices", "LocalPresenceServicesConnector"); | ||
58 | config.Configs["PresenceService"].Set("LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService"); | ||
59 | config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullPresenceData"); | ||
60 | |||
61 | m_LocalConnector = new LocalPresenceServicesConnector(config); | ||
62 | } | ||
63 | |||
64 | /// <summary> | ||
65 | /// Test OpenSim Presence. | ||
66 | /// </summary> | ||
67 | [Test] | ||
68 | public void TestPresenceV0_1() | ||
69 | { | ||
70 | SetUp(); | ||
71 | |||
72 | string user1 = UUID.Zero.ToString(); | ||
73 | UUID session1 = UUID.Zero; | ||
74 | |||
75 | // this is not implemented by this connector | ||
76 | //m_LocalConnector.LoginAgent(user1, session1, UUID.Zero); | ||
77 | PresenceInfo result = m_LocalConnector.GetAgent(session1); | ||
78 | Assert.IsNotNull(result, "Retrieved GetAgent is null"); | ||
79 | Assert.That(result.UserID, Is.EqualTo(user1), "Retrieved userID does not match"); | ||
80 | Assert.IsTrue(result.Online, "Agent just logged in but is offline"); | ||
81 | |||
82 | UUID region1 = UUID.Random(); | ||
83 | bool r = m_LocalConnector.ReportAgent(session1, region1, Vector3.Zero, Vector3.Zero); | ||
84 | Assert.IsTrue(r, "First ReportAgent returned false"); | ||
85 | result = m_LocalConnector.GetAgent(session1); | ||
86 | Assert.That(result.RegionID, Is.EqualTo(region1), "Agent is not in the right region (region1)"); | ||
87 | |||
88 | UUID region2 = UUID.Random(); | ||
89 | r = m_LocalConnector.ReportAgent(session1, region2, Vector3.Zero, Vector3.Zero); | ||
90 | Assert.IsTrue(r, "Second ReportAgent returned false"); | ||
91 | result = m_LocalConnector.GetAgent(session1); | ||
92 | Assert.That(result.RegionID, Is.EqualTo(region2), "Agent is not in the right region (region2)"); | ||
93 | |||
94 | r = m_LocalConnector.LogoutAgent(session1); | ||
95 | Assert.IsTrue(r, "LogoutAgent returned false"); | ||
96 | result = m_LocalConnector.GetAgent(session1); | ||
97 | Assert.IsNotNull(result, "Agent session disappeared from storage after logout"); | ||
98 | Assert.IsFalse(result.Online, "Agent is reported to be Online after logout"); | ||
99 | |||
100 | r = m_LocalConnector.ReportAgent(session1, region1, Vector3.Zero, Vector3.Zero); | ||
101 | Assert.IsFalse(r, "ReportAgent of non-logged in user returned true"); | ||
102 | } | ||
103 | } | ||
104 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs new file mode 100644 index 0000000..074bfb5 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs | |||
@@ -0,0 +1,339 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | using log4net; | ||
31 | using Nini.Config; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Region.Framework.Interfaces; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
38 | |||
39 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | ||
40 | { | ||
41 | public class LocalSimulationConnectorModule : ISharedRegionModule, ISimulationService | ||
42 | { | ||
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | private List<Scene> m_sceneList = new List<Scene>(); | ||
45 | |||
46 | private bool m_ModuleEnabled = false; | ||
47 | |||
48 | #region IRegionModule | ||
49 | |||
50 | public void Initialise(IConfigSource config) | ||
51 | { | ||
52 | IConfig moduleConfig = config.Configs["Modules"]; | ||
53 | if (moduleConfig != null) | ||
54 | { | ||
55 | string name = moduleConfig.GetString("SimulationServices", ""); | ||
56 | if (name == Name) | ||
57 | { | ||
58 | //IConfig userConfig = config.Configs["SimulationService"]; | ||
59 | //if (userConfig == null) | ||
60 | //{ | ||
61 | // m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpanSim.ini"); | ||
62 | // return; | ||
63 | //} | ||
64 | |||
65 | m_ModuleEnabled = true; | ||
66 | |||
67 | m_log.Info("[SIMULATION CONNECTOR]: Local simulation enabled"); | ||
68 | } | ||
69 | } | ||
70 | } | ||
71 | |||
72 | public void PostInitialise() | ||
73 | { | ||
74 | } | ||
75 | |||
76 | public void AddRegion(Scene scene) | ||
77 | { | ||
78 | if (!m_ModuleEnabled) | ||
79 | return; | ||
80 | |||
81 | Init(scene); | ||
82 | scene.RegisterModuleInterface<ISimulationService>(this); | ||
83 | } | ||
84 | |||
85 | public void RemoveRegion(Scene scene) | ||
86 | { | ||
87 | if (!m_ModuleEnabled) | ||
88 | return; | ||
89 | |||
90 | RemoveScene(scene); | ||
91 | scene.UnregisterModuleInterface<ISimulationService>(this); | ||
92 | } | ||
93 | |||
94 | public void RegionLoaded(Scene scene) | ||
95 | { | ||
96 | } | ||
97 | |||
98 | public void Close() | ||
99 | { | ||
100 | } | ||
101 | |||
102 | public Type ReplaceableInterface | ||
103 | { | ||
104 | get { return null; } | ||
105 | } | ||
106 | |||
107 | public string Name | ||
108 | { | ||
109 | get { return "LocalSimulationConnectorModule"; } | ||
110 | } | ||
111 | |||
112 | /// <summary> | ||
113 | /// Can be called from other modules. | ||
114 | /// </summary> | ||
115 | /// <param name="scene"></param> | ||
116 | public void RemoveScene(Scene scene) | ||
117 | { | ||
118 | lock (m_sceneList) | ||
119 | { | ||
120 | if (m_sceneList.Contains(scene)) | ||
121 | { | ||
122 | m_sceneList.Remove(scene); | ||
123 | } | ||
124 | } | ||
125 | } | ||
126 | |||
127 | /// <summary> | ||
128 | /// Can be called from other modules. | ||
129 | /// </summary> | ||
130 | /// <param name="scene"></param> | ||
131 | public void Init(Scene scene) | ||
132 | { | ||
133 | if (!m_sceneList.Contains(scene)) | ||
134 | { | ||
135 | lock (m_sceneList) | ||
136 | { | ||
137 | m_sceneList.Add(scene); | ||
138 | } | ||
139 | |||
140 | } | ||
141 | } | ||
142 | |||
143 | #endregion /* IRegionModule */ | ||
144 | |||
145 | #region ISimulation | ||
146 | |||
147 | public IScene GetScene(ulong regionhandle) | ||
148 | { | ||
149 | foreach (Scene s in m_sceneList) | ||
150 | { | ||
151 | if (s.RegionInfo.RegionHandle == regionhandle) | ||
152 | return s; | ||
153 | } | ||
154 | // ? weird. should not happen | ||
155 | return m_sceneList[0]; | ||
156 | } | ||
157 | |||
158 | /** | ||
159 | * Agent-related communications | ||
160 | */ | ||
161 | |||
162 | public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason) | ||
163 | { | ||
164 | if (destination == null) | ||
165 | { | ||
166 | reason = "Given destination was null"; | ||
167 | m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: CreateAgent was given a null destination"); | ||
168 | return false; | ||
169 | } | ||
170 | |||
171 | foreach (Scene s in m_sceneList) | ||
172 | { | ||
173 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
174 | { | ||
175 | // m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle); | ||
176 | return s.NewUserConnection(aCircuit, teleportFlags, out reason); | ||
177 | } | ||
178 | } | ||
179 | |||
180 | // m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle); | ||
181 | reason = "Did not find region " + destination.RegionName; | ||
182 | return false; | ||
183 | } | ||
184 | |||
185 | public bool UpdateAgent(GridRegion destination, AgentData cAgentData) | ||
186 | { | ||
187 | if (destination == null) | ||
188 | return false; | ||
189 | |||
190 | foreach (Scene s in m_sceneList) | ||
191 | { | ||
192 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
193 | { | ||
194 | //m_log.DebugFormat( | ||
195 | // "[LOCAL COMMS]: Found region {0} {1} to send ChildAgentUpdate", | ||
196 | // s.RegionInfo.RegionName, regionHandle); | ||
197 | |||
198 | s.IncomingChildAgentDataUpdate(cAgentData); | ||
199 | return true; | ||
200 | } | ||
201 | } | ||
202 | |||
203 | // m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for ChildAgentUpdate", regionHandle); | ||
204 | return false; | ||
205 | } | ||
206 | |||
207 | public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData) | ||
208 | { | ||
209 | if (destination == null) | ||
210 | return false; | ||
211 | |||
212 | foreach (Scene s in m_sceneList) | ||
213 | { | ||
214 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
215 | { | ||
216 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); | ||
217 | s.IncomingChildAgentDataUpdate(cAgentData); | ||
218 | return true; | ||
219 | } | ||
220 | } | ||
221 | //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); | ||
222 | return false; | ||
223 | } | ||
224 | |||
225 | public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) | ||
226 | { | ||
227 | agent = null; | ||
228 | |||
229 | if (destination == null) | ||
230 | return false; | ||
231 | |||
232 | foreach (Scene s in m_sceneList) | ||
233 | { | ||
234 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
235 | { | ||
236 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); | ||
237 | return s.IncomingRetrieveRootAgent(id, out agent); | ||
238 | } | ||
239 | } | ||
240 | //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); | ||
241 | return false; | ||
242 | } | ||
243 | |||
244 | public bool ReleaseAgent(GridRegion destination, UUID id, string uri) | ||
245 | { | ||
246 | if (destination == null) | ||
247 | return false; | ||
248 | |||
249 | foreach (Scene s in m_sceneList) | ||
250 | { | ||
251 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
252 | { | ||
253 | //m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); | ||
254 | return s.IncomingReleaseAgent(id); | ||
255 | } | ||
256 | } | ||
257 | //m_log.Debug("[LOCAL COMMS]: region not found in SendReleaseAgent"); | ||
258 | return false; | ||
259 | } | ||
260 | |||
261 | public bool CloseAgent(GridRegion destination, UUID id) | ||
262 | { | ||
263 | if (destination == null) | ||
264 | return false; | ||
265 | |||
266 | foreach (Scene s in m_sceneList) | ||
267 | { | ||
268 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
269 | { | ||
270 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent"); | ||
271 | return s.IncomingCloseAgent(id); | ||
272 | } | ||
273 | } | ||
274 | //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent"); | ||
275 | return false; | ||
276 | } | ||
277 | |||
278 | /** | ||
279 | * Object-related communications | ||
280 | */ | ||
281 | |||
282 | public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) | ||
283 | { | ||
284 | if (destination == null) | ||
285 | return false; | ||
286 | |||
287 | foreach (Scene s in m_sceneList) | ||
288 | { | ||
289 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
290 | { | ||
291 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); | ||
292 | if (isLocalCall) | ||
293 | { | ||
294 | // We need to make a local copy of the object | ||
295 | ISceneObject sogClone = sog.CloneForNewScene(); | ||
296 | sogClone.SetState(sog.GetStateSnapshot(), s); | ||
297 | return s.IncomingCreateObject(sogClone); | ||
298 | } | ||
299 | else | ||
300 | { | ||
301 | // Use the object as it came through the wire | ||
302 | return s.IncomingCreateObject(sog); | ||
303 | } | ||
304 | } | ||
305 | } | ||
306 | return false; | ||
307 | } | ||
308 | |||
309 | public bool CreateObject(GridRegion destination, UUID userID, UUID itemID) | ||
310 | { | ||
311 | if (destination == null) | ||
312 | return false; | ||
313 | |||
314 | foreach (Scene s in m_sceneList) | ||
315 | { | ||
316 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
317 | { | ||
318 | return s.IncomingCreateObject(userID, itemID); | ||
319 | } | ||
320 | } | ||
321 | return false; | ||
322 | } | ||
323 | |||
324 | |||
325 | #endregion /* IInterregionComms */ | ||
326 | |||
327 | #region Misc | ||
328 | |||
329 | public bool IsLocalRegion(ulong regionhandle) | ||
330 | { | ||
331 | foreach (Scene s in m_sceneList) | ||
332 | if (s.RegionInfo.RegionHandle == regionhandle) | ||
333 | return true; | ||
334 | return false; | ||
335 | } | ||
336 | |||
337 | #endregion | ||
338 | } | ||
339 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs new file mode 100644 index 0000000..c9cc368 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs | |||
@@ -0,0 +1,360 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.IO; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Text; | ||
34 | using log4net; | ||
35 | using Nini.Config; | ||
36 | using OpenMetaverse; | ||
37 | using OpenMetaverse.StructuredData; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Framework.Communications; | ||
40 | using OpenSim.Framework.Communications.Clients; | ||
41 | using OpenSim.Region.Framework.Interfaces; | ||
42 | using OpenSim.Region.Framework.Scenes; | ||
43 | using OpenSim.Region.Framework.Scenes.Hypergrid; | ||
44 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
45 | using OpenSim.Services.Interfaces; | ||
46 | using OpenSim.Services.Connectors.Simulation; | ||
47 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
48 | |||
49 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | ||
50 | { | ||
51 | public class RemoteSimulationConnectorModule : ISharedRegionModule, ISimulationService | ||
52 | { | ||
53 | private bool initialized = false; | ||
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
55 | |||
56 | protected bool m_enabled = false; | ||
57 | protected Scene m_aScene; | ||
58 | // RemoteSimulationConnector does not care about local regions; it delegates that to the Local module | ||
59 | protected LocalSimulationConnectorModule m_localBackend; | ||
60 | protected SimulationServiceConnector m_remoteConnector; | ||
61 | |||
62 | protected CommunicationsManager m_commsManager; | ||
63 | |||
64 | protected IHyperlinkService m_hyperlinkService; | ||
65 | |||
66 | protected bool m_safemode; | ||
67 | protected IPAddress m_thisIP; | ||
68 | |||
69 | #region IRegionModule | ||
70 | |||
71 | public virtual void Initialise(IConfigSource config) | ||
72 | { | ||
73 | |||
74 | IConfig moduleConfig = config.Configs["Modules"]; | ||
75 | if (moduleConfig != null) | ||
76 | { | ||
77 | string name = moduleConfig.GetString("SimulationServices", ""); | ||
78 | if (name == Name) | ||
79 | { | ||
80 | //IConfig userConfig = config.Configs["SimulationService"]; | ||
81 | //if (userConfig == null) | ||
82 | //{ | ||
83 | // m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpanSim.ini"); | ||
84 | // return; | ||
85 | //} | ||
86 | |||
87 | m_remoteConnector = new SimulationServiceConnector(); | ||
88 | |||
89 | m_enabled = true; | ||
90 | |||
91 | m_log.Info("[SIMULATION CONNECTOR]: Remote simulation enabled"); | ||
92 | } | ||
93 | } | ||
94 | } | ||
95 | |||
96 | public virtual void PostInitialise() | ||
97 | { | ||
98 | } | ||
99 | |||
100 | public virtual void Close() | ||
101 | { | ||
102 | } | ||
103 | |||
104 | public void AddRegion(Scene scene) | ||
105 | { | ||
106 | if (!m_enabled) | ||
107 | return; | ||
108 | |||
109 | if (!initialized) | ||
110 | { | ||
111 | InitOnce(scene); | ||
112 | initialized = true; | ||
113 | } | ||
114 | InitEach(scene); | ||
115 | } | ||
116 | |||
117 | public void RemoveRegion(Scene scene) | ||
118 | { | ||
119 | if (m_enabled) | ||
120 | { | ||
121 | m_localBackend.RemoveScene(scene); | ||
122 | scene.UnregisterModuleInterface<ISimulationService>(this); | ||
123 | } | ||
124 | } | ||
125 | |||
126 | public void RegionLoaded(Scene scene) | ||
127 | { | ||
128 | if (!m_enabled) | ||
129 | return; | ||
130 | |||
131 | m_hyperlinkService = m_aScene.RequestModuleInterface<IHyperlinkService>(); | ||
132 | |||
133 | } | ||
134 | |||
135 | public Type ReplaceableInterface | ||
136 | { | ||
137 | get { return null; } | ||
138 | } | ||
139 | |||
140 | public virtual string Name | ||
141 | { | ||
142 | get { return "RemoteSimulationConnectorModule"; } | ||
143 | } | ||
144 | |||
145 | protected virtual void InitEach(Scene scene) | ||
146 | { | ||
147 | m_localBackend.Init(scene); | ||
148 | scene.RegisterModuleInterface<ISimulationService>(this); | ||
149 | } | ||
150 | |||
151 | protected virtual void InitOnce(Scene scene) | ||
152 | { | ||
153 | m_localBackend = new LocalSimulationConnectorModule(); | ||
154 | m_commsManager = scene.CommsManager; | ||
155 | m_aScene = scene; | ||
156 | //m_regionClient = new RegionToRegionClient(m_aScene, m_hyperlinkService); | ||
157 | m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName); | ||
158 | } | ||
159 | |||
160 | #endregion /* IRegionModule */ | ||
161 | |||
162 | #region IInterregionComms | ||
163 | |||
164 | public IScene GetScene(ulong handle) | ||
165 | { | ||
166 | return m_localBackend.GetScene(handle); | ||
167 | } | ||
168 | |||
169 | /** | ||
170 | * Agent-related communications | ||
171 | */ | ||
172 | |||
173 | public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason) | ||
174 | { | ||
175 | if (destination == null) | ||
176 | { | ||
177 | reason = "Given destination was null"; | ||
178 | m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CreateAgent was given a null destination"); | ||
179 | return false; | ||
180 | } | ||
181 | |||
182 | // Try local first | ||
183 | if (m_localBackend.CreateAgent(destination, aCircuit, teleportFlags, out reason)) | ||
184 | return true; | ||
185 | |||
186 | // else do the remote thing | ||
187 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
188 | { | ||
189 | //m_regionClient.SendUserInformation(regInfo, aCircuit); | ||
190 | return m_remoteConnector.CreateAgent(destination, aCircuit, teleportFlags, out reason); | ||
191 | } | ||
192 | return false; | ||
193 | } | ||
194 | |||
195 | public bool UpdateAgent(GridRegion destination, AgentData cAgentData) | ||
196 | { | ||
197 | if (destination == null) | ||
198 | return false; | ||
199 | |||
200 | // Try local first | ||
201 | if (m_localBackend.UpdateAgent(destination, cAgentData)) | ||
202 | return true; | ||
203 | |||
204 | // else do the remote thing | ||
205 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
206 | return m_remoteConnector.UpdateAgent(destination, cAgentData); | ||
207 | |||
208 | return false; | ||
209 | |||
210 | } | ||
211 | |||
212 | public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData) | ||
213 | { | ||
214 | if (destination == null) | ||
215 | return false; | ||
216 | |||
217 | // Try local first | ||
218 | if (m_localBackend.UpdateAgent(destination, cAgentData)) | ||
219 | return true; | ||
220 | |||
221 | // else do the remote thing | ||
222 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
223 | return m_remoteConnector.UpdateAgent(destination, cAgentData); | ||
224 | |||
225 | return false; | ||
226 | |||
227 | } | ||
228 | |||
229 | public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) | ||
230 | { | ||
231 | agent = null; | ||
232 | |||
233 | if (destination == null) | ||
234 | return false; | ||
235 | |||
236 | // Try local first | ||
237 | if (m_localBackend.RetrieveAgent(destination, id, out agent)) | ||
238 | return true; | ||
239 | |||
240 | // else do the remote thing | ||
241 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
242 | return m_remoteConnector.RetrieveAgent(destination, id, out agent); | ||
243 | |||
244 | return false; | ||
245 | |||
246 | } | ||
247 | |||
248 | public bool ReleaseAgent(GridRegion destination, UUID id, string uri) | ||
249 | { | ||
250 | if (destination == null) | ||
251 | return false; | ||
252 | |||
253 | // Try local first | ||
254 | if (m_localBackend.ReleaseAgent(destination, id, uri)) | ||
255 | return true; | ||
256 | |||
257 | // else do the remote thing | ||
258 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
259 | return m_remoteConnector.ReleaseAgent(destination, id, uri); | ||
260 | |||
261 | return false; | ||
262 | } | ||
263 | |||
264 | |||
265 | public bool CloseAgent(GridRegion destination, UUID id) | ||
266 | { | ||
267 | if (destination == null) | ||
268 | return false; | ||
269 | |||
270 | // Try local first | ||
271 | if (m_localBackend.CloseAgent(destination, id)) | ||
272 | return true; | ||
273 | |||
274 | // else do the remote thing | ||
275 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
276 | return m_remoteConnector.CloseAgent(destination, id); | ||
277 | |||
278 | return false; | ||
279 | } | ||
280 | |||
281 | /** | ||
282 | * Object-related communications | ||
283 | */ | ||
284 | |||
285 | public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) | ||
286 | { | ||
287 | if (destination == null) | ||
288 | return false; | ||
289 | |||
290 | // Try local first | ||
291 | if (m_localBackend.CreateObject(destination, sog, true)) | ||
292 | { | ||
293 | //m_log.Debug("[REST COMMS]: LocalBackEnd SendCreateObject succeeded"); | ||
294 | return true; | ||
295 | } | ||
296 | |||
297 | // else do the remote thing | ||
298 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
299 | return m_remoteConnector.CreateObject(destination, sog, isLocalCall); | ||
300 | |||
301 | return false; | ||
302 | } | ||
303 | |||
304 | public bool CreateObject(GridRegion destination, UUID userID, UUID itemID) | ||
305 | { | ||
306 | // Not Implemented | ||
307 | return false; | ||
308 | } | ||
309 | |||
310 | #endregion /* IInterregionComms */ | ||
311 | |||
312 | |||
313 | protected class RegionToRegionClient : RegionClient | ||
314 | { | ||
315 | Scene m_aScene = null; | ||
316 | IHyperlinkService m_hyperlinkService; | ||
317 | |||
318 | public RegionToRegionClient(Scene s, IHyperlinkService hyperService) | ||
319 | { | ||
320 | m_aScene = s; | ||
321 | m_hyperlinkService = hyperService; | ||
322 | } | ||
323 | |||
324 | public override ulong GetRegionHandle(ulong handle) | ||
325 | { | ||
326 | if (m_aScene.SceneGridService is HGSceneCommunicationService) | ||
327 | { | ||
328 | if (m_hyperlinkService != null) | ||
329 | return m_hyperlinkService.FindRegionHandle(handle); | ||
330 | } | ||
331 | |||
332 | return handle; | ||
333 | } | ||
334 | |||
335 | public override bool IsHyperlink(ulong handle) | ||
336 | { | ||
337 | if (m_aScene.SceneGridService is HGSceneCommunicationService) | ||
338 | { | ||
339 | if ((m_hyperlinkService != null) && (m_hyperlinkService.GetHyperlinkRegion(handle) != null)) | ||
340 | return true; | ||
341 | } | ||
342 | return false; | ||
343 | } | ||
344 | |||
345 | public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit) | ||
346 | { | ||
347 | if (m_hyperlinkService != null) | ||
348 | m_hyperlinkService.SendUserInformation(regInfo, aCircuit); | ||
349 | |||
350 | } | ||
351 | |||
352 | public override void AdjustUserInformation(AgentCircuitData aCircuit) | ||
353 | { | ||
354 | if (m_hyperlinkService != null) | ||
355 | m_hyperlinkService.AdjustUserInformation(aCircuit); | ||
356 | } | ||
357 | } | ||
358 | |||
359 | } | ||
360 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs index cca5bb4..f55de5a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | using log4net; | 31 | using log4net; |
31 | using Nini.Config; | 32 | using Nini.Config; |
@@ -34,9 +35,11 @@ using OpenSim.Region.Framework.Scenes; | |||
34 | using OpenSim.Server.Base; | 35 | using OpenSim.Server.Base; |
35 | using OpenSim.Services.Interfaces; | 36 | using OpenSim.Services.Interfaces; |
36 | 37 | ||
37 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | 38 | using OpenMetaverse; |
39 | |||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | ||
38 | { | 41 | { |
39 | public class LocalUserServicesConnector : ISharedRegionModule | 42 | public class LocalUserAccountServicesConnector : ISharedRegionModule, IUserAccountService |
40 | { | 43 | { |
41 | private static readonly ILog m_log = | 44 | private static readonly ILog m_log = |
42 | LogManager.GetLogger( | 45 | LogManager.GetLogger( |
@@ -46,6 +49,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
46 | 49 | ||
47 | private bool m_Enabled = false; | 50 | private bool m_Enabled = false; |
48 | 51 | ||
52 | #region ISharedRegionModule | ||
53 | |||
49 | public Type ReplaceableInterface | 54 | public Type ReplaceableInterface |
50 | { | 55 | { |
51 | get { return null; } | 56 | get { return null; } |
@@ -53,7 +58,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
53 | 58 | ||
54 | public string Name | 59 | public string Name |
55 | { | 60 | { |
56 | get { return "LocalUserServicesConnector"; } | 61 | get { return "LocalUserAccountServicesConnector"; } |
57 | } | 62 | } |
58 | 63 | ||
59 | public void Initialise(IConfigSource source) | 64 | public void Initialise(IConfigSource source) |
@@ -61,13 +66,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
61 | IConfig moduleConfig = source.Configs["Modules"]; | 66 | IConfig moduleConfig = source.Configs["Modules"]; |
62 | if (moduleConfig != null) | 67 | if (moduleConfig != null) |
63 | { | 68 | { |
64 | string name = moduleConfig.GetString("UserServices", ""); | 69 | string name = moduleConfig.GetString("UserAccountServices", ""); |
65 | if (name == Name) | 70 | if (name == Name) |
66 | { | 71 | { |
67 | IConfig userConfig = source.Configs["UserService"]; | 72 | IConfig userConfig = source.Configs["UserAccountService"]; |
68 | if (userConfig == null) | 73 | if (userConfig == null) |
69 | { | 74 | { |
70 | m_log.Error("[USER CONNECTOR]: UserService missing from OpenSim.ini"); | 75 | m_log.Error("[USER CONNECTOR]: UserAccountService missing from OpenSim.ini"); |
71 | return; | 76 | return; |
72 | } | 77 | } |
73 | 78 | ||
@@ -87,7 +92,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
87 | 92 | ||
88 | if (m_UserService == null) | 93 | if (m_UserService == null) |
89 | { | 94 | { |
90 | m_log.Error("[USER CONNECTOR]: Can't load user service"); | 95 | m_log.Error("[USER CONNECTOR]: Can't load user account service"); |
91 | return; | 96 | return; |
92 | } | 97 | } |
93 | m_Enabled = true; | 98 | m_Enabled = true; |
@@ -127,5 +132,39 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
127 | if (!m_Enabled) | 132 | if (!m_Enabled) |
128 | return; | 133 | return; |
129 | } | 134 | } |
135 | |||
136 | #endregion | ||
137 | |||
138 | #region IUserAccountService | ||
139 | |||
140 | public UserAccount GetUserAccount(UUID scopeID, UUID userID) | ||
141 | { | ||
142 | return m_UserService.GetUserAccount(scopeID, userID); | ||
143 | } | ||
144 | |||
145 | public UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName) | ||
146 | { | ||
147 | return m_UserService.GetUserAccount(scopeID, FirstName, LastName); | ||
148 | } | ||
149 | |||
150 | public UserAccount GetUserAccount(UUID scopeID, string Email) | ||
151 | { | ||
152 | return m_UserService.GetUserAccount(scopeID, Email); | ||
153 | } | ||
154 | |||
155 | public List<UserAccount> GetUserAccounts(UUID scopeID, string query) | ||
156 | { | ||
157 | return m_UserService.GetUserAccounts(scopeID, query); | ||
158 | } | ||
159 | |||
160 | // Update all updatable fields | ||
161 | // | ||
162 | public bool StoreUserAccount(UserAccount data) | ||
163 | { | ||
164 | return m_UserService.StoreUserAccount(data); | ||
165 | } | ||
166 | |||
167 | #endregion | ||
168 | |||
130 | } | 169 | } |
131 | } | 170 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs index cef9129..7d61b20 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs | |||
@@ -34,9 +34,9 @@ using OpenSim.Region.Framework.Scenes; | |||
34 | using OpenSim.Services.Interfaces; | 34 | using OpenSim.Services.Interfaces; |
35 | using OpenSim.Services.Connectors; | 35 | using OpenSim.Services.Connectors; |
36 | 36 | ||
37 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | 37 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts |
38 | { | 38 | { |
39 | public class RemoteUserServicesConnector : UserServicesConnector, | 39 | public class RemoteUserAccountServicesConnector : UserAccountServicesConnector, |
40 | ISharedRegionModule, IUserAccountService | 40 | ISharedRegionModule, IUserAccountService |
41 | { | 41 | { |
42 | private static readonly ILog m_log = | 42 | private static readonly ILog m_log = |
@@ -52,7 +52,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
52 | 52 | ||
53 | public string Name | 53 | public string Name |
54 | { | 54 | { |
55 | get { return "RemoteUserServicesConnector"; } | 55 | get { return "RemoteUserAccountServicesConnector"; } |
56 | } | 56 | } |
57 | 57 | ||
58 | public override void Initialise(IConfigSource source) | 58 | public override void Initialise(IConfigSource source) |
@@ -60,13 +60,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
60 | IConfig moduleConfig = source.Configs["Modules"]; | 60 | IConfig moduleConfig = source.Configs["Modules"]; |
61 | if (moduleConfig != null) | 61 | if (moduleConfig != null) |
62 | { | 62 | { |
63 | string name = moduleConfig.GetString("UserServices", ""); | 63 | string name = moduleConfig.GetString("UserAccountServices", ""); |
64 | if (name == Name) | 64 | if (name == Name) |
65 | { | 65 | { |
66 | IConfig userConfig = source.Configs["UserService"]; | 66 | IConfig userConfig = source.Configs["UserAccountService"]; |
67 | if (userConfig == null) | 67 | if (userConfig == null) |
68 | { | 68 | { |
69 | m_log.Error("[USER CONNECTOR]: UserService missing from OpanSim.ini"); | 69 | m_log.Error("[USER CONNECTOR]: UserAccountService missing from OpanSim.ini"); |
70 | return; | 70 | return; |
71 | } | 71 | } |
72 | 72 | ||
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index e837e9a..ae3dc2e 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | |||
@@ -95,6 +95,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
95 | 95 | ||
96 | protected Scene m_scene; | 96 | protected Scene m_scene; |
97 | 97 | ||
98 | private InventoryFolderImpl m_libraryRootFolder; | ||
99 | protected InventoryFolderImpl LibraryRootFolder | ||
100 | { | ||
101 | get | ||
102 | { | ||
103 | if (m_libraryRootFolder != null) | ||
104 | return m_libraryRootFolder; | ||
105 | |||
106 | ILibraryService lib = m_scene.RequestModuleInterface<ILibraryService>(); | ||
107 | if (lib != null) | ||
108 | { | ||
109 | m_libraryRootFolder = lib.LibraryRootFolder; | ||
110 | } | ||
111 | return m_libraryRootFolder; | ||
112 | } | ||
113 | } | ||
114 | |||
98 | #region Constants | 115 | #region Constants |
99 | // These are here for testing. They will be taken out | 116 | // These are here for testing. They will be taken out |
100 | 117 | ||
@@ -1005,9 +1022,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1005 | IInventoryService invService = m_scene.InventoryService; | 1022 | IInventoryService invService = m_scene.InventoryService; |
1006 | InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user); | 1023 | InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user); |
1007 | assetRequestItem = invService.GetItem(assetRequestItem); | 1024 | assetRequestItem = invService.GetItem(assetRequestItem); |
1008 | if (assetRequestItem == null) // Library item | 1025 | if (assetRequestItem == null && LibraryRootFolder != null) // Library item |
1009 | { | 1026 | { |
1010 | assetRequestItem = scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard); | 1027 | assetRequestItem = LibraryRootFolder.FindItem(notecard); |
1011 | 1028 | ||
1012 | if (assetRequestItem != null) // Implicitly readable | 1029 | if (assetRequestItem != null) // Implicitly readable |
1013 | return true; | 1030 | return true; |
@@ -1425,9 +1442,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1425 | IInventoryService invService = m_scene.InventoryService; | 1442 | IInventoryService invService = m_scene.InventoryService; |
1426 | InventoryItemBase assetRequestItem = new InventoryItemBase(script, user); | 1443 | InventoryItemBase assetRequestItem = new InventoryItemBase(script, user); |
1427 | assetRequestItem = invService.GetItem(assetRequestItem); | 1444 | assetRequestItem = invService.GetItem(assetRequestItem); |
1428 | if (assetRequestItem == null) // Library item | 1445 | if (assetRequestItem == null && LibraryRootFolder != null) // Library item |
1429 | { | 1446 | { |
1430 | assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(script); | 1447 | assetRequestItem = LibraryRootFolder.FindItem(script); |
1431 | 1448 | ||
1432 | if (assetRequestItem != null) // Implicitly readable | 1449 | if (assetRequestItem != null) // Implicitly readable |
1433 | return true; | 1450 | return true; |
@@ -1520,9 +1537,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1520 | IInventoryService invService = m_scene.InventoryService; | 1537 | IInventoryService invService = m_scene.InventoryService; |
1521 | InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user); | 1538 | InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user); |
1522 | assetRequestItem = invService.GetItem(assetRequestItem); | 1539 | assetRequestItem = invService.GetItem(assetRequestItem); |
1523 | if (assetRequestItem == null) // Library item | 1540 | if (assetRequestItem == null && LibraryRootFolder != null) // Library item |
1524 | { | 1541 | { |
1525 | assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard); | 1542 | assetRequestItem = LibraryRootFolder.FindItem(notecard); |
1526 | 1543 | ||
1527 | if (assetRequestItem != null) // Implicitly readable | 1544 | if (assetRequestItem != null) // Implicitly readable |
1528 | return true; | 1545 | return true; |
diff --git a/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs b/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs index 630c6a3..d44c1e1 100644 --- a/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs | |||
@@ -31,13 +31,13 @@ namespace OpenSim.Region.Framework.Interfaces | |||
31 | { | 31 | { |
32 | public struct PresenceInfo | 32 | public struct PresenceInfo |
33 | { | 33 | { |
34 | public UUID userID; | 34 | public string UserID; |
35 | public UUID regionID; | 35 | public UUID RegionID; |
36 | 36 | ||
37 | public PresenceInfo(UUID userID, UUID regionID) | 37 | public PresenceInfo(string userID, UUID regionID) |
38 | { | 38 | { |
39 | this.userID = userID; | 39 | UserID = userID; |
40 | this.regionID = regionID; | 40 | RegionID = regionID; |
41 | } | 41 | } |
42 | } | 42 | } |
43 | 43 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 3044017..a14c853 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -573,7 +573,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
573 | "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}", | 573 | "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}", |
574 | remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName); | 574 | remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName); |
575 | 575 | ||
576 | InventoryItemBase item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(oldItemID); | 576 | InventoryItemBase item = null; |
577 | if (LibraryService != null && LibraryService.LibraryRootFolder != null) | ||
578 | item = LibraryService.LibraryRootFolder.FindItem(oldItemID); | ||
577 | 579 | ||
578 | if (item == null) | 580 | if (item == null) |
579 | { | 581 | { |
@@ -1211,9 +1213,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1211 | item = InventoryService.GetItem(item); | 1213 | item = InventoryService.GetItem(item); |
1212 | 1214 | ||
1213 | // Try library | 1215 | // Try library |
1214 | if (null == item) | 1216 | if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) |
1215 | { | 1217 | { |
1216 | item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); | 1218 | item = LibraryService.LibraryRootFolder.FindItem(itemID); |
1217 | } | 1219 | } |
1218 | 1220 | ||
1219 | if (item != null) | 1221 | if (item != null) |
@@ -1280,9 +1282,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1280 | 1282 | ||
1281 | // Try library | 1283 | // Try library |
1282 | // XXX clumsy, possibly should be one call | 1284 | // XXX clumsy, possibly should be one call |
1283 | if (null == item) | 1285 | if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) |
1284 | { | 1286 | { |
1285 | item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); | 1287 | item = LibraryService.LibraryRootFolder.FindItem(itemID); |
1286 | } | 1288 | } |
1287 | 1289 | ||
1288 | if (item != null) | 1290 | if (item != null) |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 47fbeb4..022d79d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | |||
@@ -424,7 +424,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
424 | /// <param name="ownerID"></param> | 424 | /// <param name="ownerID"></param> |
425 | public void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID) | 425 | public void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID) |
426 | { | 426 | { |
427 | if (ownerID == CommsManager.UserProfileCacheService.LibraryRoot.Owner) | 427 | if (LibraryService != null && LibraryService.LibraryRootFolder != null && ownerID == LibraryService.LibraryRootFolder.Owner) |
428 | { | 428 | { |
429 | //m_log.Debug("request info for library item"); | 429 | //m_log.Debug("request info for library item"); |
430 | return; | 430 | return; |
@@ -458,13 +458,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
458 | // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. | 458 | // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. |
459 | // can be handled transparently). | 459 | // can be handled transparently). |
460 | InventoryFolderImpl fold = null; | 460 | InventoryFolderImpl fold = null; |
461 | if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null) | 461 | if (LibraryService != null && LibraryService.LibraryRootFolder != null) |
462 | { | 462 | if ((fold = LibraryService.LibraryRootFolder.FindFolder(folderID)) != null) |
463 | remoteClient.SendInventoryFolderDetails( | 463 | { |
464 | fold.Owner, folderID, fold.RequestListOfItems(), | 464 | remoteClient.SendInventoryFolderDetails( |
465 | fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems); | 465 | fold.Owner, folderID, fold.RequestListOfItems(), |
466 | return; | 466 | fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems); |
467 | } | 467 | return; |
468 | } | ||
468 | 469 | ||
469 | // We're going to send the reply async, because there may be | 470 | // We're going to send the reply async, because there may be |
470 | // an enormous quantity of packets -- basically the entire inventory! | 471 | // an enormous quantity of packets -- basically the entire inventory! |
@@ -512,15 +513,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
512 | // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. | 513 | // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. |
513 | // can be handled transparently). | 514 | // can be handled transparently). |
514 | InventoryFolderImpl fold; | 515 | InventoryFolderImpl fold; |
515 | if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null) | 516 | if (LibraryService != null && LibraryService.LibraryRootFolder != null) |
516 | { | 517 | if ((fold = LibraryService.LibraryRootFolder.FindFolder(folderID)) != null) |
517 | version = 0; | 518 | { |
518 | InventoryCollection ret = new InventoryCollection(); | 519 | version = 0; |
519 | ret.Folders = new List<InventoryFolderBase>(); | 520 | InventoryCollection ret = new InventoryCollection(); |
520 | ret.Items = fold.RequestListOfItems(); | 521 | ret.Folders = new List<InventoryFolderBase>(); |
522 | ret.Items = fold.RequestListOfItems(); | ||
521 | 523 | ||
522 | return ret; | 524 | return ret; |
523 | } | 525 | } |
524 | 526 | ||
525 | InventoryCollection contents = new InventoryCollection(); | 527 | InventoryCollection contents = new InventoryCollection(); |
526 | 528 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 764ac60..20c0622 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -240,6 +240,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
240 | } | 240 | } |
241 | } | 241 | } |
242 | 242 | ||
243 | protected ILibraryService m_LibraryService; | ||
244 | |||
245 | public ILibraryService LibraryService | ||
246 | { | ||
247 | get | ||
248 | { | ||
249 | if (m_LibraryService == null) | ||
250 | m_LibraryService = RequestModuleInterface<ILibraryService>(); | ||
251 | |||
252 | return m_LibraryService; | ||
253 | } | ||
254 | } | ||
255 | |||
243 | protected IXMLRPC m_xmlrpcModule; | 256 | protected IXMLRPC m_xmlrpcModule; |
244 | protected IWorldComm m_worldCommModule; | 257 | protected IWorldComm m_worldCommModule; |
245 | protected IAvatarFactory m_AvatarFactory; | 258 | protected IAvatarFactory m_AvatarFactory; |
@@ -3483,10 +3496,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
3483 | { | 3496 | { |
3484 | reason = String.Empty; | 3497 | reason = String.Empty; |
3485 | 3498 | ||
3486 | bool result = CommsManager.UserService.VerifySession(agent.AgentID, agent.SessionID); | 3499 | IAuthenticationService auth = RequestModuleInterface<IAuthenticationService>(); |
3487 | m_log.Debug("[CONNECTION BEGIN]: User authentication returned " + result); | 3500 | if (auth == null) |
3501 | { | ||
3502 | reason = String.Format("Failed to authenticate user {0} {1} in region {2}. Authentication service does not exist.", agent.firstname, agent.lastname, RegionInfo.RegionName); | ||
3503 | return false; | ||
3504 | } | ||
3505 | |||
3506 | bool result = auth.Verify(agent.AgentID, agent.SecureSessionID.ToString(), 30); | ||
3507 | |||
3508 | m_log.Debug("[CONNECTION BEGIN]: Session authentication returned " + result); | ||
3488 | if (!result) | 3509 | if (!result) |
3489 | reason = String.Format("Failed to authenticate user {0} {1}, access denied.", agent.firstname, agent.lastname); | 3510 | reason = String.Format("Failed to authenticate user {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName); |
3490 | 3511 | ||
3491 | return result; | 3512 | return result; |
3492 | } | 3513 | } |
@@ -4889,5 +4910,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
4889 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4910 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) |
4890 | StartTimer(); | 4911 | StartTimer(); |
4891 | } | 4912 | } |
4913 | |||
4914 | public override ISceneObject DeserializeObject(string representation) | ||
4915 | { | ||
4916 | return SceneObjectSerializer.FromXml2Format(representation); | ||
4917 | } | ||
4918 | |||
4919 | public override bool AllowScriptCrossings | ||
4920 | { | ||
4921 | get { return m_allowScriptCrossings; } | ||
4922 | } | ||
4892 | } | 4923 | } |
4893 | } | 4924 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index 1547f9a..19eea1e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs | |||
@@ -510,5 +510,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
510 | 510 | ||
511 | MainConsole.Instance.Commands.AddCommand(modulename, shared, command, shorthelp, longhelp, callback); | 511 | MainConsole.Instance.Commands.AddCommand(modulename, shared, command, shorthelp, longhelp, callback); |
512 | } | 512 | } |
513 | |||
514 | public virtual ISceneObject DeserializeObject(string representation) | ||
515 | { | ||
516 | return null; | ||
517 | } | ||
518 | |||
519 | public virtual bool AllowScriptCrossings | ||
520 | { | ||
521 | get { return false; } | ||
522 | } | ||
523 | |||
513 | } | 524 | } |
514 | } | 525 | } |
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 0964caa..a5d28a4 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs | |||
@@ -160,9 +160,9 @@ namespace OpenSim.Server.Base | |||
160 | } | 160 | } |
161 | } | 161 | } |
162 | 162 | ||
163 | public static Dictionary<string, string> ParseQueryString(string query) | 163 | public static Dictionary<string, object> ParseQueryString(string query) |
164 | { | 164 | { |
165 | Dictionary<string, string> result = new Dictionary<string, string>(); | 165 | Dictionary<string, object> result = new Dictionary<string, object>(); |
166 | string[] terms = query.Split(new char[] {'&'}); | 166 | string[] terms = query.Split(new char[] {'&'}); |
167 | 167 | ||
168 | if (terms.Length == 0) | 168 | if (terms.Length == 0) |
@@ -180,33 +180,76 @@ namespace OpenSim.Server.Base | |||
180 | if (elems.Length > 1) | 180 | if (elems.Length > 1) |
181 | value = System.Web.HttpUtility.UrlDecode(elems[1]); | 181 | value = System.Web.HttpUtility.UrlDecode(elems[1]); |
182 | 182 | ||
183 | result[name] = value; | 183 | if (name.EndsWith("[]")) |
184 | { | ||
185 | if (result.ContainsKey(name)) | ||
186 | { | ||
187 | if (!(result[name] is List<string>)) | ||
188 | continue; | ||
189 | |||
190 | List<string> l = (List<string>)result[name]; | ||
191 | |||
192 | l.Add(value); | ||
193 | } | ||
194 | else | ||
195 | { | ||
196 | List<string> newList = new List<string>(); | ||
197 | |||
198 | newList.Add(value); | ||
199 | |||
200 | result[name] = newList; | ||
201 | } | ||
202 | } | ||
203 | else | ||
204 | { | ||
205 | if (!result.ContainsKey(name)) | ||
206 | result[name] = value; | ||
207 | } | ||
184 | } | 208 | } |
185 | 209 | ||
186 | return result; | 210 | return result; |
187 | } | 211 | } |
188 | 212 | ||
189 | public static string BuildQueryString(Dictionary<string, string> data) | 213 | public static string BuildQueryString(Dictionary<string, object> data) |
190 | { | 214 | { |
191 | string qstring = String.Empty; | 215 | string qstring = String.Empty; |
192 | 216 | ||
193 | foreach (KeyValuePair<string, string> kvp in data) | 217 | string part; |
218 | |||
219 | foreach (KeyValuePair<string, object> kvp in data) | ||
194 | { | 220 | { |
195 | string part; | 221 | if (kvp.Value is List<string>) |
196 | if (kvp.Value != String.Empty) | ||
197 | { | 222 | { |
198 | part = System.Web.HttpUtility.UrlEncode(kvp.Key) + | 223 | List<string> l = (List<String>)kvp.Value; |
199 | "=" + System.Web.HttpUtility.UrlEncode(kvp.Value); | 224 | |
225 | foreach (string s in l) | ||
226 | { | ||
227 | part = System.Web.HttpUtility.UrlEncode(kvp.Key) + | ||
228 | "[]=" + System.Web.HttpUtility.UrlEncode(s); | ||
229 | |||
230 | if (qstring != String.Empty) | ||
231 | qstring += "&"; | ||
232 | |||
233 | qstring += part; | ||
234 | } | ||
200 | } | 235 | } |
201 | else | 236 | else |
202 | { | 237 | { |
203 | part = System.Web.HttpUtility.UrlEncode(kvp.Key); | 238 | if (kvp.Value.ToString() != String.Empty) |
204 | } | 239 | { |
240 | part = System.Web.HttpUtility.UrlEncode(kvp.Key) + | ||
241 | "=" + System.Web.HttpUtility.UrlEncode(kvp.Value.ToString()); | ||
242 | } | ||
243 | else | ||
244 | { | ||
245 | part = System.Web.HttpUtility.UrlEncode(kvp.Key); | ||
246 | } | ||
205 | 247 | ||
206 | if (qstring != String.Empty) | 248 | if (qstring != String.Empty) |
207 | qstring += "&"; | 249 | qstring += "&"; |
208 | 250 | ||
209 | qstring += part; | 251 | qstring += part; |
252 | } | ||
210 | } | 253 | } |
211 | 254 | ||
212 | return qstring; | 255 | return qstring; |
diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs index 490a13a..47bc860 100644 --- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs | |||
@@ -86,14 +86,14 @@ namespace OpenSim.Server.Handlers.Authentication | |||
86 | 86 | ||
87 | private byte[] DoPlainMethods(string body) | 87 | private byte[] DoPlainMethods(string body) |
88 | { | 88 | { |
89 | Dictionary<string, string> request = | 89 | Dictionary<string, object> request = |
90 | ServerUtils.ParseQueryString(body); | 90 | ServerUtils.ParseQueryString(body); |
91 | 91 | ||
92 | int lifetime = 30; | 92 | int lifetime = 30; |
93 | 93 | ||
94 | if (request.ContainsKey("LIFETIME")) | 94 | if (request.ContainsKey("LIFETIME")) |
95 | { | 95 | { |
96 | lifetime = Convert.ToInt32(request["LIFETIME"]); | 96 | lifetime = Convert.ToInt32(request["LIFETIME"].ToString()); |
97 | if (lifetime > 30) | 97 | if (lifetime > 30) |
98 | lifetime = 30; | 98 | lifetime = 30; |
99 | } | 99 | } |
@@ -103,12 +103,12 @@ namespace OpenSim.Server.Handlers.Authentication | |||
103 | if (!request.ContainsKey("PRINCIPAL")) | 103 | if (!request.ContainsKey("PRINCIPAL")) |
104 | return FailureResult(); | 104 | return FailureResult(); |
105 | 105 | ||
106 | string method = request["METHOD"]; | 106 | string method = request["METHOD"].ToString(); |
107 | 107 | ||
108 | UUID principalID; | 108 | UUID principalID; |
109 | string token; | 109 | string token; |
110 | 110 | ||
111 | if (!UUID.TryParse(request["PRINCIPAL"], out principalID)) | 111 | if (!UUID.TryParse(request["PRINCIPAL"].ToString(), out principalID)) |
112 | return FailureResult(); | 112 | return FailureResult(); |
113 | 113 | ||
114 | switch (method) | 114 | switch (method) |
@@ -117,7 +117,7 @@ namespace OpenSim.Server.Handlers.Authentication | |||
117 | if (!request.ContainsKey("PASSWORD")) | 117 | if (!request.ContainsKey("PASSWORD")) |
118 | return FailureResult(); | 118 | return FailureResult(); |
119 | 119 | ||
120 | token = m_AuthenticationService.Authenticate(principalID, request["PASSWORD"], lifetime); | 120 | token = m_AuthenticationService.Authenticate(principalID, request["PASSWORD"].ToString(), lifetime); |
121 | 121 | ||
122 | if (token != String.Empty) | 122 | if (token != String.Empty) |
123 | return SuccessResult(token); | 123 | return SuccessResult(token); |
@@ -126,7 +126,7 @@ namespace OpenSim.Server.Handlers.Authentication | |||
126 | if (!request.ContainsKey("TOKEN")) | 126 | if (!request.ContainsKey("TOKEN")) |
127 | return FailureResult(); | 127 | return FailureResult(); |
128 | 128 | ||
129 | if (m_AuthenticationService.Verify(principalID, request["TOKEN"], lifetime)) | 129 | if (m_AuthenticationService.Verify(principalID, request["TOKEN"].ToString(), lifetime)) |
130 | return SuccessResult(); | 130 | return SuccessResult(); |
131 | 131 | ||
132 | return FailureResult(); | 132 | return FailureResult(); |
@@ -134,7 +134,7 @@ namespace OpenSim.Server.Handlers.Authentication | |||
134 | if (!request.ContainsKey("TOKEN")) | 134 | if (!request.ContainsKey("TOKEN")) |
135 | return FailureResult(); | 135 | return FailureResult(); |
136 | 136 | ||
137 | if (m_AuthenticationService.Release(principalID, request["TOKEN"])) | 137 | if (m_AuthenticationService.Release(principalID, request["TOKEN"].ToString())) |
138 | return SuccessResult(); | 138 | return SuccessResult(); |
139 | 139 | ||
140 | return FailureResult(); | 140 | return FailureResult(); |
diff --git a/OpenSim/Server/Handlers/Avatar/AvatarServerConnector.cs b/OpenSim/Server/Handlers/Avatar/AvatarServerConnector.cs new file mode 100644 index 0000000..9a57cd9 --- /dev/null +++ b/OpenSim/Server/Handlers/Avatar/AvatarServerConnector.cs | |||
@@ -0,0 +1,61 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using Nini.Config; | ||
30 | using OpenSim.Server.Base; | ||
31 | using OpenSim.Services.Interfaces; | ||
32 | using OpenSim.Framework.Servers.HttpServer; | ||
33 | using OpenSim.Server.Handlers.Base; | ||
34 | |||
35 | namespace OpenSim.Server.Handlers.Avatar | ||
36 | { | ||
37 | public class AvatarServiceConnector : ServiceConnector | ||
38 | { | ||
39 | private IAvatarService m_AvatarService; | ||
40 | private string m_ConfigName = "AvatarService"; | ||
41 | |||
42 | public AvatarServiceConnector(IConfigSource config, IHttpServer server, string configName) : | ||
43 | base(config, server, configName) | ||
44 | { | ||
45 | IConfig serverConfig = config.Configs[m_ConfigName]; | ||
46 | if (serverConfig == null) | ||
47 | throw new Exception(String.Format("No section {0} in config file", m_ConfigName)); | ||
48 | |||
49 | string avatarService = serverConfig.GetString("LocalServiceModule", | ||
50 | String.Empty); | ||
51 | |||
52 | if (avatarService == String.Empty) | ||
53 | throw new Exception("No LocalServiceModule in config file"); | ||
54 | |||
55 | Object[] args = new Object[] { config }; | ||
56 | m_AvatarService = ServerUtils.LoadPlugin<IAvatarService>(avatarService, args); | ||
57 | |||
58 | server.AddStreamHandler(new AvatarServerPostHandler(m_AvatarService)); | ||
59 | } | ||
60 | } | ||
61 | } | ||
diff --git a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs new file mode 100644 index 0000000..49c2e43 --- /dev/null +++ b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs | |||
@@ -0,0 +1,269 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using Nini.Config; | ||
29 | using log4net; | ||
30 | using System; | ||
31 | using System.Reflection; | ||
32 | using System.IO; | ||
33 | using System.Net; | ||
34 | using System.Text; | ||
35 | using System.Text.RegularExpressions; | ||
36 | using System.Xml; | ||
37 | using System.Xml.Serialization; | ||
38 | using System.Collections.Generic; | ||
39 | using OpenSim.Server.Base; | ||
40 | using OpenSim.Services.Interfaces; | ||
41 | using OpenSim.Framework; | ||
42 | using OpenSim.Framework.Servers.HttpServer; | ||
43 | using OpenMetaverse; | ||
44 | |||
45 | namespace OpenSim.Server.Handlers.Avatar | ||
46 | { | ||
47 | public class AvatarServerPostHandler : BaseStreamHandler | ||
48 | { | ||
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
51 | private IAvatarService m_AvatarService; | ||
52 | |||
53 | public AvatarServerPostHandler(IAvatarService service) : | ||
54 | base("POST", "/avatar") | ||
55 | { | ||
56 | m_AvatarService = service; | ||
57 | } | ||
58 | |||
59 | public override byte[] Handle(string path, Stream requestData, | ||
60 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
61 | { | ||
62 | StreamReader sr = new StreamReader(requestData); | ||
63 | string body = sr.ReadToEnd(); | ||
64 | sr.Close(); | ||
65 | body = body.Trim(); | ||
66 | |||
67 | //m_log.DebugFormat("[XXX]: query String: {0}", body); | ||
68 | |||
69 | try | ||
70 | { | ||
71 | Dictionary<string, object> request = | ||
72 | ServerUtils.ParseQueryString(body); | ||
73 | |||
74 | if (!request.ContainsKey("METHOD")) | ||
75 | return FailureResult(); | ||
76 | |||
77 | string method = request["METHOD"].ToString(); | ||
78 | |||
79 | switch (method) | ||
80 | { | ||
81 | case "getavatar": | ||
82 | return GetAvatar(request); | ||
83 | case "setavatar": | ||
84 | return SetAvatar(request); | ||
85 | case "resetavatar": | ||
86 | return ResetAvatar(request); | ||
87 | case "setitems": | ||
88 | return SetItems(request); | ||
89 | case "removeitems": | ||
90 | return RemoveItems(request); | ||
91 | } | ||
92 | m_log.DebugFormat("[AVATAR HANDLER]: unknown method request: {0}", method); | ||
93 | } | ||
94 | catch (Exception e) | ||
95 | { | ||
96 | m_log.Debug("[AVATAR HANDLER]: Exception {0}" + e); | ||
97 | } | ||
98 | |||
99 | return FailureResult(); | ||
100 | |||
101 | } | ||
102 | |||
103 | byte[] GetAvatar(Dictionary<string, object> request) | ||
104 | { | ||
105 | UUID user = UUID.Zero; | ||
106 | |||
107 | if (!request.ContainsKey("UserID")) | ||
108 | return FailureResult(); | ||
109 | |||
110 | if (UUID.TryParse(request["UserID"].ToString(), out user)) | ||
111 | { | ||
112 | AvatarData avatar = m_AvatarService.GetAvatar(user); | ||
113 | if (avatar == null) | ||
114 | return FailureResult(); | ||
115 | |||
116 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
117 | if (avatar == null) | ||
118 | result["result"] = "null"; | ||
119 | else | ||
120 | result["result"] = avatar.ToKeyValuePairs(); | ||
121 | |||
122 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
123 | |||
124 | UTF8Encoding encoding = new UTF8Encoding(); | ||
125 | return encoding.GetBytes(xmlString); | ||
126 | } | ||
127 | |||
128 | return FailureResult(); | ||
129 | } | ||
130 | |||
131 | byte[] SetAvatar(Dictionary<string, object> request) | ||
132 | { | ||
133 | UUID user = UUID.Zero; | ||
134 | |||
135 | if (!request.ContainsKey("UserID")) | ||
136 | return FailureResult(); | ||
137 | |||
138 | if (!UUID.TryParse(request["UserID"].ToString(), out user)) | ||
139 | return FailureResult(); | ||
140 | |||
141 | AvatarData avatar = new AvatarData(request); | ||
142 | if (m_AvatarService.SetAvatar(user, avatar)) | ||
143 | return SuccessResult(); | ||
144 | |||
145 | return FailureResult(); | ||
146 | } | ||
147 | |||
148 | byte[] ResetAvatar(Dictionary<string, object> request) | ||
149 | { | ||
150 | UUID user = UUID.Zero; | ||
151 | if (!request.ContainsKey("UserID")) | ||
152 | return FailureResult(); | ||
153 | |||
154 | if (!UUID.TryParse(request["UserID"].ToString(), out user)) | ||
155 | return FailureResult(); | ||
156 | |||
157 | if (m_AvatarService.ResetAvatar(user)) | ||
158 | return SuccessResult(); | ||
159 | |||
160 | return FailureResult(); | ||
161 | } | ||
162 | |||
163 | byte[] SetItems(Dictionary<string, object> request) | ||
164 | { | ||
165 | UUID user = UUID.Zero; | ||
166 | string[] names, values; | ||
167 | |||
168 | if (!request.ContainsKey("UserID") || !request.ContainsKey("Names") || !request.ContainsKey("Values")) | ||
169 | return FailureResult(); | ||
170 | |||
171 | if (!UUID.TryParse(request["UserID"].ToString(), out user)) | ||
172 | return FailureResult(); | ||
173 | |||
174 | if (!(request["Names"] is List<string> || request["Values"] is List<string>)) | ||
175 | return FailureResult(); | ||
176 | |||
177 | List<string> _names = (List<string>)request["Names"]; | ||
178 | names = _names.ToArray(); | ||
179 | List<string> _values = (List<string>)request["Values"]; | ||
180 | values = _values.ToArray(); | ||
181 | |||
182 | if (m_AvatarService.SetItems(user, names, values)) | ||
183 | return SuccessResult(); | ||
184 | |||
185 | return FailureResult(); | ||
186 | } | ||
187 | |||
188 | byte[] RemoveItems(Dictionary<string, object> request) | ||
189 | { | ||
190 | UUID user = UUID.Zero; | ||
191 | string[] names; | ||
192 | |||
193 | if (!request.ContainsKey("UserID") || !request.ContainsKey("Names")) | ||
194 | return FailureResult(); | ||
195 | |||
196 | if (!UUID.TryParse(request["UserID"].ToString(), out user)) | ||
197 | return FailureResult(); | ||
198 | |||
199 | if (!(request["Names"] is List<string>)) | ||
200 | return FailureResult(); | ||
201 | |||
202 | List<string> _names = (List<string>)request["Names"]; | ||
203 | names = _names.ToArray(); | ||
204 | |||
205 | if (m_AvatarService.RemoveItems(user, names)) | ||
206 | return SuccessResult(); | ||
207 | |||
208 | return FailureResult(); | ||
209 | } | ||
210 | |||
211 | |||
212 | |||
213 | private byte[] SuccessResult() | ||
214 | { | ||
215 | XmlDocument doc = new XmlDocument(); | ||
216 | |||
217 | XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, | ||
218 | "", ""); | ||
219 | |||
220 | doc.AppendChild(xmlnode); | ||
221 | |||
222 | XmlElement rootElement = doc.CreateElement("", "ServerResponse", | ||
223 | ""); | ||
224 | |||
225 | doc.AppendChild(rootElement); | ||
226 | |||
227 | XmlElement result = doc.CreateElement("", "result", ""); | ||
228 | result.AppendChild(doc.CreateTextNode("Success")); | ||
229 | |||
230 | rootElement.AppendChild(result); | ||
231 | |||
232 | return DocToBytes(doc); | ||
233 | } | ||
234 | |||
235 | private byte[] FailureResult() | ||
236 | { | ||
237 | XmlDocument doc = new XmlDocument(); | ||
238 | |||
239 | XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, | ||
240 | "", ""); | ||
241 | |||
242 | doc.AppendChild(xmlnode); | ||
243 | |||
244 | XmlElement rootElement = doc.CreateElement("", "ServerResponse", | ||
245 | ""); | ||
246 | |||
247 | doc.AppendChild(rootElement); | ||
248 | |||
249 | XmlElement result = doc.CreateElement("", "result", ""); | ||
250 | result.AppendChild(doc.CreateTextNode("Failure")); | ||
251 | |||
252 | rootElement.AppendChild(result); | ||
253 | |||
254 | return DocToBytes(doc); | ||
255 | } | ||
256 | |||
257 | private byte[] DocToBytes(XmlDocument doc) | ||
258 | { | ||
259 | MemoryStream ms = new MemoryStream(); | ||
260 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
261 | xw.Formatting = Formatting.Indented; | ||
262 | doc.WriteTo(xw); | ||
263 | xw.Flush(); | ||
264 | |||
265 | return ms.ToArray(); | ||
266 | } | ||
267 | |||
268 | } | ||
269 | } | ||
diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index 433ed0b..d99b791 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs | |||
@@ -69,13 +69,13 @@ namespace OpenSim.Server.Handlers.Grid | |||
69 | 69 | ||
70 | try | 70 | try |
71 | { | 71 | { |
72 | Dictionary<string, string> request = | 72 | Dictionary<string, object> request = |
73 | ServerUtils.ParseQueryString(body); | 73 | ServerUtils.ParseQueryString(body); |
74 | 74 | ||
75 | if (!request.ContainsKey("METHOD")) | 75 | if (!request.ContainsKey("METHOD")) |
76 | return FailureResult(); | 76 | return FailureResult(); |
77 | 77 | ||
78 | string method = request["METHOD"]; | 78 | string method = request["METHOD"].ToString(); |
79 | 79 | ||
80 | switch (method) | 80 | switch (method) |
81 | { | 81 | { |
@@ -117,22 +117,22 @@ namespace OpenSim.Server.Handlers.Grid | |||
117 | 117 | ||
118 | #region Method-specific handlers | 118 | #region Method-specific handlers |
119 | 119 | ||
120 | byte[] Register(Dictionary<string, string> request) | 120 | byte[] Register(Dictionary<string, object> request) |
121 | { | 121 | { |
122 | UUID scopeID = UUID.Zero; | 122 | UUID scopeID = UUID.Zero; |
123 | if (request.ContainsKey("SCOPEID")) | 123 | if (request.ContainsKey("SCOPEID")) |
124 | UUID.TryParse(request["SCOPEID"], out scopeID); | 124 | UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); |
125 | else | 125 | else |
126 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to register region"); | 126 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to register region"); |
127 | 127 | ||
128 | int versionNumberMin = 0, versionNumberMax = 0; | 128 | int versionNumberMin = 0, versionNumberMax = 0; |
129 | if (request.ContainsKey("VERSIONMIN")) | 129 | if (request.ContainsKey("VERSIONMIN")) |
130 | Int32.TryParse(request["VERSIONMIN"], out versionNumberMin); | 130 | Int32.TryParse(request["VERSIONMIN"].ToString(), out versionNumberMin); |
131 | else | 131 | else |
132 | m_log.WarnFormat("[GRID HANDLER]: no minimum protocol version in request to register region"); | 132 | m_log.WarnFormat("[GRID HANDLER]: no minimum protocol version in request to register region"); |
133 | 133 | ||
134 | if (request.ContainsKey("VERSIONMAX")) | 134 | if (request.ContainsKey("VERSIONMAX")) |
135 | Int32.TryParse(request["VERSIONMAX"], out versionNumberMax); | 135 | Int32.TryParse(request["VERSIONMAX"].ToString(), out versionNumberMax); |
136 | else | 136 | else |
137 | m_log.WarnFormat("[GRID HANDLER]: no maximum protocol version in request to register region"); | 137 | m_log.WarnFormat("[GRID HANDLER]: no maximum protocol version in request to register region"); |
138 | 138 | ||
@@ -147,8 +147,8 @@ namespace OpenSim.Server.Handlers.Grid | |||
147 | GridRegion rinfo = null; | 147 | GridRegion rinfo = null; |
148 | try | 148 | try |
149 | { | 149 | { |
150 | foreach (KeyValuePair<string, string> kvp in request) | 150 | foreach (KeyValuePair<string, object> kvp in request) |
151 | rinfoData[kvp.Key] = kvp.Value; | 151 | rinfoData[kvp.Key] = kvp.Value.ToString(); |
152 | rinfo = new GridRegion(rinfoData); | 152 | rinfo = new GridRegion(rinfoData); |
153 | } | 153 | } |
154 | catch (Exception e) | 154 | catch (Exception e) |
@@ -166,11 +166,11 @@ namespace OpenSim.Server.Handlers.Grid | |||
166 | return FailureResult(); | 166 | return FailureResult(); |
167 | } | 167 | } |
168 | 168 | ||
169 | byte[] Deregister(Dictionary<string, string> request) | 169 | byte[] Deregister(Dictionary<string, object> request) |
170 | { | 170 | { |
171 | UUID regionID = UUID.Zero; | 171 | UUID regionID = UUID.Zero; |
172 | if (request["REGIONID"] != null) | 172 | if (request.ContainsKey("REGIONID")) |
173 | UUID.TryParse(request["REGIONID"], out regionID); | 173 | UUID.TryParse(request["REGIONID"].ToString(), out regionID); |
174 | else | 174 | else |
175 | m_log.WarnFormat("[GRID HANDLER]: no regionID in request to deregister region"); | 175 | m_log.WarnFormat("[GRID HANDLER]: no regionID in request to deregister region"); |
176 | 176 | ||
@@ -183,17 +183,17 @@ namespace OpenSim.Server.Handlers.Grid | |||
183 | 183 | ||
184 | } | 184 | } |
185 | 185 | ||
186 | byte[] GetNeighbours(Dictionary<string, string> request) | 186 | byte[] GetNeighbours(Dictionary<string, object> request) |
187 | { | 187 | { |
188 | UUID scopeID = UUID.Zero; | 188 | UUID scopeID = UUID.Zero; |
189 | if (request["SCOPEID"] != null) | 189 | if (request.ContainsKey("SCOPEID")) |
190 | UUID.TryParse(request["SCOPEID"], out scopeID); | 190 | UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); |
191 | else | 191 | else |
192 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours"); | 192 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours"); |
193 | 193 | ||
194 | UUID regionID = UUID.Zero; | 194 | UUID regionID = UUID.Zero; |
195 | if (request["REGIONID"] != null) | 195 | if (request.ContainsKey("REGIONID")) |
196 | UUID.TryParse(request["REGIONID"], out regionID); | 196 | UUID.TryParse(request["REGIONID"].ToString(), out regionID); |
197 | else | 197 | else |
198 | m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); | 198 | m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); |
199 | 199 | ||
@@ -221,17 +221,17 @@ namespace OpenSim.Server.Handlers.Grid | |||
221 | 221 | ||
222 | } | 222 | } |
223 | 223 | ||
224 | byte[] GetRegionByUUID(Dictionary<string, string> request) | 224 | byte[] GetRegionByUUID(Dictionary<string, object> request) |
225 | { | 225 | { |
226 | UUID scopeID = UUID.Zero; | 226 | UUID scopeID = UUID.Zero; |
227 | if (request["SCOPEID"] != null) | 227 | if (request.ContainsKey("SCOPEID")) |
228 | UUID.TryParse(request["SCOPEID"], out scopeID); | 228 | UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); |
229 | else | 229 | else |
230 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours"); | 230 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours"); |
231 | 231 | ||
232 | UUID regionID = UUID.Zero; | 232 | UUID regionID = UUID.Zero; |
233 | if (request["REGIONID"] != null) | 233 | if (request.ContainsKey("REGIONID")) |
234 | UUID.TryParse(request["REGIONID"], out regionID); | 234 | UUID.TryParse(request["REGIONID"].ToString(), out regionID); |
235 | else | 235 | else |
236 | m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); | 236 | m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); |
237 | 237 | ||
@@ -250,21 +250,21 @@ namespace OpenSim.Server.Handlers.Grid | |||
250 | return encoding.GetBytes(xmlString); | 250 | return encoding.GetBytes(xmlString); |
251 | } | 251 | } |
252 | 252 | ||
253 | byte[] GetRegionByPosition(Dictionary<string, string> request) | 253 | byte[] GetRegionByPosition(Dictionary<string, object> request) |
254 | { | 254 | { |
255 | UUID scopeID = UUID.Zero; | 255 | UUID scopeID = UUID.Zero; |
256 | if (request["SCOPEID"] != null) | 256 | if (request.ContainsKey("SCOPEID")) |
257 | UUID.TryParse(request["SCOPEID"], out scopeID); | 257 | UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); |
258 | else | 258 | else |
259 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by position"); | 259 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by position"); |
260 | 260 | ||
261 | int x = 0, y = 0; | 261 | int x = 0, y = 0; |
262 | if (request["X"] != null) | 262 | if (request.ContainsKey("X")) |
263 | Int32.TryParse(request["X"], out x); | 263 | Int32.TryParse(request["X"].ToString(), out x); |
264 | else | 264 | else |
265 | m_log.WarnFormat("[GRID HANDLER]: no X in request to get region by position"); | 265 | m_log.WarnFormat("[GRID HANDLER]: no X in request to get region by position"); |
266 | if (request["Y"] != null) | 266 | if (request.ContainsKey("Y")) |
267 | Int32.TryParse(request["Y"], out y); | 267 | Int32.TryParse(request["Y"].ToString(), out y); |
268 | else | 268 | else |
269 | m_log.WarnFormat("[GRID HANDLER]: no Y in request to get region by position"); | 269 | m_log.WarnFormat("[GRID HANDLER]: no Y in request to get region by position"); |
270 | 270 | ||
@@ -283,17 +283,17 @@ namespace OpenSim.Server.Handlers.Grid | |||
283 | return encoding.GetBytes(xmlString); | 283 | return encoding.GetBytes(xmlString); |
284 | } | 284 | } |
285 | 285 | ||
286 | byte[] GetRegionByName(Dictionary<string, string> request) | 286 | byte[] GetRegionByName(Dictionary<string, object> request) |
287 | { | 287 | { |
288 | UUID scopeID = UUID.Zero; | 288 | UUID scopeID = UUID.Zero; |
289 | if (request["SCOPEID"] != null) | 289 | if (request.ContainsKey("SCOPEID")) |
290 | UUID.TryParse(request["SCOPEID"], out scopeID); | 290 | UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); |
291 | else | 291 | else |
292 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by name"); | 292 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by name"); |
293 | 293 | ||
294 | string regionName = string.Empty; | 294 | string regionName = string.Empty; |
295 | if (request["NAME"] != null) | 295 | if (request.ContainsKey("NAME")) |
296 | regionName = request["NAME"]; | 296 | regionName = request["NAME"].ToString(); |
297 | else | 297 | else |
298 | m_log.WarnFormat("[GRID HANDLER]: no name in request to get region by name"); | 298 | m_log.WarnFormat("[GRID HANDLER]: no name in request to get region by name"); |
299 | 299 | ||
@@ -312,23 +312,23 @@ namespace OpenSim.Server.Handlers.Grid | |||
312 | return encoding.GetBytes(xmlString); | 312 | return encoding.GetBytes(xmlString); |
313 | } | 313 | } |
314 | 314 | ||
315 | byte[] GetRegionsByName(Dictionary<string, string> request) | 315 | byte[] GetRegionsByName(Dictionary<string, object> request) |
316 | { | 316 | { |
317 | UUID scopeID = UUID.Zero; | 317 | UUID scopeID = UUID.Zero; |
318 | if (request["SCOPEID"] != null) | 318 | if (request.ContainsKey("SCOPEID")) |
319 | UUID.TryParse(request["SCOPEID"], out scopeID); | 319 | UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); |
320 | else | 320 | else |
321 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get regions by name"); | 321 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get regions by name"); |
322 | 322 | ||
323 | string regionName = string.Empty; | 323 | string regionName = string.Empty; |
324 | if (request["NAME"] != null) | 324 | if (request.ContainsKey("NAME")) |
325 | regionName = request["NAME"]; | 325 | regionName = request["NAME"].ToString(); |
326 | else | 326 | else |
327 | m_log.WarnFormat("[GRID HANDLER]: no NAME in request to get regions by name"); | 327 | m_log.WarnFormat("[GRID HANDLER]: no NAME in request to get regions by name"); |
328 | 328 | ||
329 | int max = 0; | 329 | int max = 0; |
330 | if (request["MAX"] != null) | 330 | if (request.ContainsKey("MAX")) |
331 | Int32.TryParse(request["MAX"], out max); | 331 | Int32.TryParse(request["MAX"].ToString(), out max); |
332 | else | 332 | else |
333 | m_log.WarnFormat("[GRID HANDLER]: no MAX in request to get regions by name"); | 333 | m_log.WarnFormat("[GRID HANDLER]: no MAX in request to get regions by name"); |
334 | 334 | ||
@@ -355,30 +355,30 @@ namespace OpenSim.Server.Handlers.Grid | |||
355 | return encoding.GetBytes(xmlString); | 355 | return encoding.GetBytes(xmlString); |
356 | } | 356 | } |
357 | 357 | ||
358 | byte[] GetRegionRange(Dictionary<string, string> request) | 358 | byte[] GetRegionRange(Dictionary<string, object> request) |
359 | { | 359 | { |
360 | //m_log.DebugFormat("[GRID HANDLER]: GetRegionRange"); | 360 | //m_log.DebugFormat("[GRID HANDLER]: GetRegionRange"); |
361 | UUID scopeID = UUID.Zero; | 361 | UUID scopeID = UUID.Zero; |
362 | if (request.ContainsKey("SCOPEID")) | 362 | if (request.ContainsKey("SCOPEID")) |
363 | UUID.TryParse(request["SCOPEID"], out scopeID); | 363 | UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); |
364 | else | 364 | else |
365 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range"); | 365 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range"); |
366 | 366 | ||
367 | int xmin = 0, xmax = 0, ymin = 0, ymax = 0; | 367 | int xmin = 0, xmax = 0, ymin = 0, ymax = 0; |
368 | if (request.ContainsKey("XMIN")) | 368 | if (request.ContainsKey("XMIN")) |
369 | Int32.TryParse(request["XMIN"], out xmin); | 369 | Int32.TryParse(request["XMIN"].ToString(), out xmin); |
370 | else | 370 | else |
371 | m_log.WarnFormat("[GRID HANDLER]: no XMIN in request to get region range"); | 371 | m_log.WarnFormat("[GRID HANDLER]: no XMIN in request to get region range"); |
372 | if (request.ContainsKey("XMAX")) | 372 | if (request.ContainsKey("XMAX")) |
373 | Int32.TryParse(request["XMAX"], out xmax); | 373 | Int32.TryParse(request["XMAX"].ToString(), out xmax); |
374 | else | 374 | else |
375 | m_log.WarnFormat("[GRID HANDLER]: no XMAX in request to get region range"); | 375 | m_log.WarnFormat("[GRID HANDLER]: no XMAX in request to get region range"); |
376 | if (request.ContainsKey("YMIN")) | 376 | if (request.ContainsKey("YMIN")) |
377 | Int32.TryParse(request["YMIN"], out ymin); | 377 | Int32.TryParse(request["YMIN"].ToString(), out ymin); |
378 | else | 378 | else |
379 | m_log.WarnFormat("[GRID HANDLER]: no YMIN in request to get region range"); | 379 | m_log.WarnFormat("[GRID HANDLER]: no YMIN in request to get region range"); |
380 | if (request.ContainsKey("YMAX")) | 380 | if (request.ContainsKey("YMAX")) |
381 | Int32.TryParse(request["YMAX"], out ymax); | 381 | Int32.TryParse(request["YMAX"].ToString(), out ymax); |
382 | else | 382 | else |
383 | m_log.WarnFormat("[GRID HANDLER]: no YMAX in request to get region range"); | 383 | m_log.WarnFormat("[GRID HANDLER]: no YMAX in request to get region range"); |
384 | 384 | ||
diff --git a/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs new file mode 100644 index 0000000..aaa958b --- /dev/null +++ b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs | |||
@@ -0,0 +1,149 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using System.Net; | ||
33 | using System.Text; | ||
34 | |||
35 | using OpenSim.Server.Base; | ||
36 | using OpenSim.Server.Handlers.Base; | ||
37 | using OpenSim.Services.Interfaces; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Framework.Servers.HttpServer; | ||
40 | |||
41 | using OpenMetaverse; | ||
42 | using OpenMetaverse.StructuredData; | ||
43 | using Nwc.XmlRpc; | ||
44 | using Nini.Config; | ||
45 | using log4net; | ||
46 | |||
47 | |||
48 | namespace OpenSim.Server.Handlers.Login | ||
49 | { | ||
50 | public class LLLoginHandlers | ||
51 | { | ||
52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
53 | |||
54 | private ILoginService m_LocalService; | ||
55 | |||
56 | public LLLoginHandlers(ILoginService service) | ||
57 | { | ||
58 | m_LocalService = service; | ||
59 | } | ||
60 | |||
61 | public XmlRpcResponse HandleXMLRPCLogin(XmlRpcRequest request, IPEndPoint remoteClient) | ||
62 | { | ||
63 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
64 | |||
65 | if (requestData != null) | ||
66 | { | ||
67 | if (requestData.ContainsKey("first") && requestData["first"] != null && | ||
68 | requestData.ContainsKey("last") && requestData["last"] != null && | ||
69 | requestData.ContainsKey("passwd") && requestData["passwd"] != null) | ||
70 | { | ||
71 | string first = requestData["first"].ToString(); | ||
72 | string last = requestData["last"].ToString(); | ||
73 | string passwd = requestData["passwd"].ToString(); | ||
74 | string startLocation = string.Empty; | ||
75 | if (requestData.ContainsKey("start")) | ||
76 | startLocation = requestData["start"].ToString(); | ||
77 | |||
78 | string clientVersion = "Unknown"; | ||
79 | if (requestData.Contains("version")) | ||
80 | clientVersion = requestData["version"].ToString(); | ||
81 | // We should do something interesting with the client version... | ||
82 | |||
83 | m_log.InfoFormat("[LOGIN]: XMLRPC Login Requested for {0} {1}, starting in {2}, using {3}", first, last, startLocation, clientVersion); | ||
84 | |||
85 | LoginResponse reply = null; | ||
86 | reply = m_LocalService.Login(first, last, passwd, startLocation, remoteClient); | ||
87 | |||
88 | XmlRpcResponse response = new XmlRpcResponse(); | ||
89 | response.Value = reply.ToHashtable(); | ||
90 | return response; | ||
91 | |||
92 | } | ||
93 | } | ||
94 | |||
95 | return FailedXMLRPCResponse(); | ||
96 | |||
97 | } | ||
98 | |||
99 | public OSD HandleLLSDLogin(OSD request, IPEndPoint remoteClient) | ||
100 | { | ||
101 | if (request.Type == OSDType.Map) | ||
102 | { | ||
103 | OSDMap map = (OSDMap)request; | ||
104 | |||
105 | if (map.ContainsKey("first") && map.ContainsKey("last") && map.ContainsKey("passwd")) | ||
106 | { | ||
107 | string startLocation = string.Empty; | ||
108 | |||
109 | if (map.ContainsKey("start")) | ||
110 | startLocation = map["start"].AsString(); | ||
111 | |||
112 | m_log.Info("[LOGIN]: LLSD Login Requested for: '" + map["first"].AsString() + "' '" + map["last"].AsString() + "' / " + startLocation); | ||
113 | |||
114 | LoginResponse reply = null; | ||
115 | reply = m_LocalService.Login(map["first"].AsString(), map["last"].AsString(), map["passwd"].AsString(), startLocation, remoteClient); | ||
116 | return reply.ToOSDMap(); | ||
117 | |||
118 | } | ||
119 | } | ||
120 | |||
121 | return FailedOSDResponse(); | ||
122 | } | ||
123 | |||
124 | private XmlRpcResponse FailedXMLRPCResponse() | ||
125 | { | ||
126 | Hashtable hash = new Hashtable(); | ||
127 | hash["reason"] = "key"; | ||
128 | hash["message"] = "Incomplete login credentials. Check your username and password."; | ||
129 | hash["login"] = "false"; | ||
130 | |||
131 | XmlRpcResponse response = new XmlRpcResponse(); | ||
132 | response.Value = hash; | ||
133 | |||
134 | return response; | ||
135 | } | ||
136 | |||
137 | private OSD FailedOSDResponse() | ||
138 | { | ||
139 | OSDMap map = new OSDMap(); | ||
140 | |||
141 | map["reason"] = OSD.FromString("key"); | ||
142 | map["message"] = OSD.FromString("Invalid login credentials. Check your username and passwd."); | ||
143 | map["login"] = OSD.FromString("false"); | ||
144 | |||
145 | return map; | ||
146 | } | ||
147 | } | ||
148 | |||
149 | } | ||
diff --git a/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs b/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs new file mode 100644 index 0000000..e24055b --- /dev/null +++ b/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs | |||
@@ -0,0 +1,95 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using Nini.Config; | ||
33 | using OpenSim.Server.Base; | ||
34 | using OpenSim.Services.Interfaces; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Framework.Servers.HttpServer; | ||
37 | using OpenSim.Server.Handlers.Base; | ||
38 | |||
39 | namespace OpenSim.Server.Handlers.Login | ||
40 | { | ||
41 | public class LLLoginServiceInConnector : ServiceConnector | ||
42 | { | ||
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | |||
45 | private ILoginService m_LoginService; | ||
46 | |||
47 | public LLLoginServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) : | ||
48 | base(config, server, String.Empty) | ||
49 | { | ||
50 | m_log.Debug("[LLLOGIN IN CONNECTOR]: Starting..."); | ||
51 | string loginService = ReadLocalServiceFromConfig(config); | ||
52 | |||
53 | ISimulationService simService = scene.RequestModuleInterface<ISimulationService>(); | ||
54 | ILibraryService libService = scene.RequestModuleInterface<ILibraryService>(); | ||
55 | |||
56 | Object[] args = new Object[] { config, simService, libService }; | ||
57 | m_LoginService = ServerUtils.LoadPlugin<ILoginService>(loginService, args); | ||
58 | |||
59 | InitializeHandlers(server); | ||
60 | } | ||
61 | |||
62 | public LLLoginServiceInConnector(IConfigSource config, IHttpServer server) : | ||
63 | base(config, server, String.Empty) | ||
64 | { | ||
65 | string loginService = ReadLocalServiceFromConfig(config); | ||
66 | |||
67 | Object[] args = new Object[] { config }; | ||
68 | |||
69 | m_LoginService = ServerUtils.LoadPlugin<ILoginService>(loginService, args); | ||
70 | |||
71 | InitializeHandlers(server); | ||
72 | } | ||
73 | |||
74 | private string ReadLocalServiceFromConfig(IConfigSource config) | ||
75 | { | ||
76 | IConfig serverConfig = config.Configs["LoginService"]; | ||
77 | if (serverConfig == null) | ||
78 | throw new Exception(String.Format("No section LoginService in config file")); | ||
79 | |||
80 | string loginService = serverConfig.GetString("LocalServiceModule", String.Empty); | ||
81 | if (loginService == string.Empty) | ||
82 | throw new Exception(String.Format("No LocalServiceModule for LoginService in config file")); | ||
83 | |||
84 | return loginService; | ||
85 | } | ||
86 | |||
87 | private void InitializeHandlers(IHttpServer server) | ||
88 | { | ||
89 | LLLoginHandlers loginHandlers = new LLLoginHandlers(m_LoginService); | ||
90 | server.AddXmlRPCHandler("login_to_simulator", loginHandlers.HandleXMLRPCLogin, false); | ||
91 | server.SetDefaultLLSDHandler(loginHandlers.HandleLLSDLogin); | ||
92 | } | ||
93 | |||
94 | } | ||
95 | } | ||
diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs index 2558fa0..6e47b22 100644 --- a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs | |||
@@ -68,18 +68,30 @@ namespace OpenSim.Server.Handlers.Presence | |||
68 | 68 | ||
69 | try | 69 | try |
70 | { | 70 | { |
71 | Dictionary<string, string> request = | 71 | Dictionary<string, object> request = |
72 | ServerUtils.ParseQueryString(body); | 72 | ServerUtils.ParseQueryString(body); |
73 | 73 | ||
74 | if (!request.ContainsKey("METHOD")) | 74 | if (!request.ContainsKey("METHOD")) |
75 | return FailureResult(); | 75 | return FailureResult(); |
76 | 76 | ||
77 | string method = request["METHOD"]; | 77 | string method = request["METHOD"].ToString(); |
78 | 78 | ||
79 | switch (method) | 79 | switch (method) |
80 | { | 80 | { |
81 | case "login": | ||
82 | return LoginAgent(request); | ||
83 | case "logout": | ||
84 | return LogoutAgent(request); | ||
85 | case "logoutregion": | ||
86 | return LogoutRegionAgents(request); | ||
81 | case "report": | 87 | case "report": |
82 | return Report(request); | 88 | return Report(request); |
89 | case "getagent": | ||
90 | return GetAgent(request); | ||
91 | case "getagents": | ||
92 | return GetAgents(request); | ||
93 | case "sethome": | ||
94 | return SetHome(request); | ||
83 | } | 95 | } |
84 | m_log.DebugFormat("[PRESENCE HANDLER]: unknown method request: {0}", method); | 96 | m_log.DebugFormat("[PRESENCE HANDLER]: unknown method request: {0}", method); |
85 | } | 97 | } |
@@ -92,38 +104,153 @@ namespace OpenSim.Server.Handlers.Presence | |||
92 | 104 | ||
93 | } | 105 | } |
94 | 106 | ||
95 | byte[] Report(Dictionary<string, string> request) | 107 | byte[] LoginAgent(Dictionary<string, object> request) |
96 | { | 108 | { |
97 | PresenceInfo info = new PresenceInfo(); | 109 | string user = String.Empty; |
98 | info.Data = new Dictionary<string, string>(); | 110 | UUID session = UUID.Zero; |
111 | UUID ssession = UUID.Zero; | ||
99 | 112 | ||
100 | if (request["PrincipalID"] == null || request["RegionID"] == null) | 113 | if (!request.ContainsKey("UserID") || !request.ContainsKey("SessionID")) |
101 | return FailureResult(); | 114 | return FailureResult(); |
102 | 115 | ||
103 | if (!UUID.TryParse(request["PrincipalID"].ToString(), | 116 | user = request["UserID"].ToString(); |
104 | out info.PrincipalID)) | 117 | |
118 | if (!UUID.TryParse(request["SessionID"].ToString(), out session)) | ||
105 | return FailureResult(); | 119 | return FailureResult(); |
106 | 120 | ||
107 | if (!UUID.TryParse(request["RegionID"].ToString(), | 121 | if (request.ContainsKey("SecureSessionID")) |
108 | out info.RegionID)) | 122 | // If it's malformed, we go on with a Zero on it |
123 | UUID.TryParse(request["SecureSessionID"].ToString(), out ssession); | ||
124 | |||
125 | if (m_PresenceService.LoginAgent(user, session, ssession)) | ||
126 | return SuccessResult(); | ||
127 | |||
128 | return FailureResult(); | ||
129 | } | ||
130 | |||
131 | byte[] LogoutAgent(Dictionary<string, object> request) | ||
132 | { | ||
133 | UUID session = UUID.Zero; | ||
134 | |||
135 | if (!request.ContainsKey("SessionID")) | ||
109 | return FailureResult(); | 136 | return FailureResult(); |
110 | 137 | ||
111 | foreach (KeyValuePair<string, string> kvp in request) | 138 | if (!UUID.TryParse(request["SessionID"].ToString(), out session)) |
112 | { | 139 | return FailureResult(); |
113 | if (kvp.Key == "METHOD" || | ||
114 | kvp.Key == "PrincipalID" || | ||
115 | kvp.Key == "RegionID") | ||
116 | continue; | ||
117 | 140 | ||
118 | info.Data[kvp.Key] = kvp.Value; | 141 | if (m_PresenceService.LogoutAgent(session)) |
119 | } | 142 | return SuccessResult(); |
143 | |||
144 | return FailureResult(); | ||
145 | } | ||
146 | |||
147 | byte[] LogoutRegionAgents(Dictionary<string, object> request) | ||
148 | { | ||
149 | UUID region = UUID.Zero; | ||
150 | |||
151 | if (!request.ContainsKey("RegionID")) | ||
152 | return FailureResult(); | ||
120 | 153 | ||
121 | if (m_PresenceService.Report(info)) | 154 | if (!UUID.TryParse(request["RegionID"].ToString(), out region)) |
155 | return FailureResult(); | ||
156 | |||
157 | if (m_PresenceService.LogoutRegionAgents(region)) | ||
122 | return SuccessResult(); | 158 | return SuccessResult(); |
123 | 159 | ||
124 | return FailureResult(); | 160 | return FailureResult(); |
125 | } | 161 | } |
162 | |||
163 | byte[] Report(Dictionary<string, object> request) | ||
164 | { | ||
165 | UUID session = UUID.Zero; | ||
166 | UUID region = UUID.Zero; | ||
167 | Vector3 position = new Vector3(128, 128, 70); | ||
168 | Vector3 look = Vector3.Zero; | ||
169 | |||
170 | if (!request.ContainsKey("SessionID") || !request.ContainsKey("RegionID")) | ||
171 | return FailureResult(); | ||
172 | |||
173 | if (!UUID.TryParse(request["SessionID"].ToString(), out session)) | ||
174 | return FailureResult(); | ||
175 | |||
176 | if (!UUID.TryParse(request["RegionID"].ToString(), out region)) | ||
177 | return FailureResult(); | ||
178 | |||
179 | if (request.ContainsKey("position")) | ||
180 | Vector3.TryParse(request["position"].ToString(), out position); | ||
181 | |||
182 | if (request.ContainsKey("lookAt")) | ||
183 | Vector3.TryParse(request["lookAt"].ToString(), out look); | ||
184 | |||
185 | if (m_PresenceService.ReportAgent(session, region, position, look)) | ||
186 | return SuccessResult(); | ||
187 | |||
188 | return FailureResult(); | ||
189 | } | ||
190 | |||
191 | byte[] GetAgent(Dictionary<string, object> request) | ||
192 | { | ||
193 | UUID session = UUID.Zero; | ||
194 | |||
195 | if (!request.ContainsKey("SessionID")) | ||
196 | return FailureResult(); | ||
126 | 197 | ||
198 | if (!UUID.TryParse(request["SessionID"].ToString(), out session)) | ||
199 | return FailureResult(); | ||
200 | |||
201 | PresenceInfo pinfo = m_PresenceService.GetAgent(session); | ||
202 | |||
203 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
204 | if (pinfo == null) | ||
205 | result["result"] = "null"; | ||
206 | else | ||
207 | result["result"] = pinfo.ToKeyValuePairs(); | ||
208 | |||
209 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
210 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
211 | UTF8Encoding encoding = new UTF8Encoding(); | ||
212 | return encoding.GetBytes(xmlString); | ||
213 | } | ||
214 | |||
215 | byte[] GetAgents(Dictionary<string, object> request) | ||
216 | { | ||
217 | |||
218 | string[] userIDs; | ||
219 | |||
220 | if (!request.ContainsKey("uuids")) | ||
221 | return FailureResult(); | ||
222 | |||
223 | if (!(request["uuids"] is List<string>)) | ||
224 | { | ||
225 | m_log.DebugFormat("[PRESENCE HANDLER]: GetAgents input argument was of unexpected type {0}", request["uuids"].GetType().ToString()); | ||
226 | return FailureResult(); | ||
227 | } | ||
228 | |||
229 | userIDs = ((List<string>)request["uuids"]).ToArray(); | ||
230 | |||
231 | PresenceInfo[] pinfos = m_PresenceService.GetAgents(userIDs); | ||
232 | |||
233 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
234 | if ((pinfos == null) || ((pinfos != null) && (pinfos.Length == 0))) | ||
235 | result["result"] = "null"; | ||
236 | else | ||
237 | { | ||
238 | int i = 0; | ||
239 | foreach (PresenceInfo pinfo in pinfos) | ||
240 | { | ||
241 | Dictionary<string, object> rinfoDict = pinfo.ToKeyValuePairs(); | ||
242 | result["presence" + i] = rinfoDict; | ||
243 | i++; | ||
244 | } | ||
245 | } | ||
246 | |||
247 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
248 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
249 | UTF8Encoding encoding = new UTF8Encoding(); | ||
250 | return encoding.GetBytes(xmlString); | ||
251 | } | ||
252 | |||
253 | |||
127 | private byte[] SuccessResult() | 254 | private byte[] SuccessResult() |
128 | { | 255 | { |
129 | XmlDocument doc = new XmlDocument(); | 256 | XmlDocument doc = new XmlDocument(); |
@@ -138,7 +265,7 @@ namespace OpenSim.Server.Handlers.Presence | |||
138 | 265 | ||
139 | doc.AppendChild(rootElement); | 266 | doc.AppendChild(rootElement); |
140 | 267 | ||
141 | XmlElement result = doc.CreateElement("", "Result", ""); | 268 | XmlElement result = doc.CreateElement("", "result", ""); |
142 | result.AppendChild(doc.CreateTextNode("Success")); | 269 | result.AppendChild(doc.CreateTextNode("Success")); |
143 | 270 | ||
144 | rootElement.AppendChild(result); | 271 | rootElement.AppendChild(result); |
@@ -160,7 +287,7 @@ namespace OpenSim.Server.Handlers.Presence | |||
160 | 287 | ||
161 | doc.AppendChild(rootElement); | 288 | doc.AppendChild(rootElement); |
162 | 289 | ||
163 | XmlElement result = doc.CreateElement("", "Result", ""); | 290 | XmlElement result = doc.CreateElement("", "result", ""); |
164 | result.AppendChild(doc.CreateTextNode("Failure")); | 291 | result.AppendChild(doc.CreateTextNode("Failure")); |
165 | 292 | ||
166 | rootElement.AppendChild(result); | 293 | rootElement.AppendChild(result); |
@@ -178,5 +305,32 @@ namespace OpenSim.Server.Handlers.Presence | |||
178 | 305 | ||
179 | return ms.ToArray(); | 306 | return ms.ToArray(); |
180 | } | 307 | } |
308 | |||
309 | byte[] SetHome(Dictionary<string, object> request) | ||
310 | { | ||
311 | UUID region = UUID.Zero; | ||
312 | Vector3 position = new Vector3(128, 128, 70); | ||
313 | Vector3 look = Vector3.Zero; | ||
314 | |||
315 | if (!request.ContainsKey("UserID") || !request.ContainsKey("RegionID")) | ||
316 | return FailureResult(); | ||
317 | |||
318 | string user = request["UserID"].ToString(); | ||
319 | |||
320 | if (!UUID.TryParse(request["RegionID"].ToString(), out region)) | ||
321 | return FailureResult(); | ||
322 | |||
323 | if (request.ContainsKey("position")) | ||
324 | Vector3.TryParse(request["position"].ToString(), out position); | ||
325 | |||
326 | if (request.ContainsKey("lookAt")) | ||
327 | Vector3.TryParse(request["lookAt"].ToString(), out look); | ||
328 | |||
329 | if (m_PresenceService.SetHomeLocation(user, region, position, look)) | ||
330 | return SuccessResult(); | ||
331 | |||
332 | return FailureResult(); | ||
333 | } | ||
334 | |||
181 | } | 335 | } |
182 | } | 336 | } |
diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 3da72c7..ccb4c70 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | ||
29 | using System.IO; | 30 | using System.IO; |
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Net; | 32 | using System.Net; |
@@ -34,6 +35,7 @@ using System.Text; | |||
34 | using OpenSim.Server.Base; | 35 | using OpenSim.Server.Base; |
35 | using OpenSim.Server.Handlers.Base; | 36 | using OpenSim.Server.Handlers.Base; |
36 | using OpenSim.Services.Interfaces; | 37 | using OpenSim.Services.Interfaces; |
38 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
37 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Servers.HttpServer; | 40 | using OpenSim.Framework.Servers.HttpServer; |
39 | 41 | ||
@@ -45,93 +47,111 @@ using log4net; | |||
45 | 47 | ||
46 | namespace OpenSim.Server.Handlers.Simulation | 48 | namespace OpenSim.Server.Handlers.Simulation |
47 | { | 49 | { |
48 | public class AgentGetHandler : BaseStreamHandler | 50 | public class AgentHandler |
49 | { | 51 | { |
50 | // TODO: unused: private ISimulationService m_SimulationService; | 52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
51 | // TODO: unused: private IAuthenticationService m_AuthenticationService; | 53 | private ISimulationService m_SimulationService; |
52 | 54 | ||
53 | public AgentGetHandler(ISimulationService service, IAuthenticationService authentication) : | 55 | public AgentHandler(ISimulationService sim) |
54 | base("GET", "/agent") | ||
55 | { | 56 | { |
56 | // TODO: unused: m_SimulationService = service; | 57 | m_SimulationService = sim; |
57 | // TODO: unused: m_AuthenticationService = authentication; | ||
58 | } | 58 | } |
59 | 59 | ||
60 | public override byte[] Handle(string path, Stream request, | 60 | public Hashtable Handler(Hashtable request) |
61 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
62 | { | 61 | { |
63 | // Not implemented yet | 62 | //m_log.Debug("[CONNECTION DEBUGGING]: AgentHandler Called"); |
64 | httpResponse.StatusCode = (int)HttpStatusCode.NotImplemented; | ||
65 | return new byte[] { }; | ||
66 | } | ||
67 | } | ||
68 | 63 | ||
69 | public class AgentPostHandler : BaseStreamHandler | 64 | m_log.Debug("---------------------------"); |
70 | { | 65 | m_log.Debug(" >> uri=" + request["uri"]); |
71 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 66 | m_log.Debug(" >> content-type=" + request["content-type"]); |
72 | private ISimulationService m_SimulationService; | 67 | m_log.Debug(" >> http-method=" + request["http-method"]); |
73 | private IAuthenticationService m_AuthenticationService; | 68 | m_log.Debug("---------------------------\n"); |
74 | // TODO: unused: private bool m_AllowForeignGuests; | ||
75 | 69 | ||
76 | public AgentPostHandler(ISimulationService service, IAuthenticationService authentication, bool foreignGuests) : | 70 | Hashtable responsedata = new Hashtable(); |
77 | base("POST", "/agent") | 71 | responsedata["content_type"] = "text/html"; |
78 | { | 72 | responsedata["keepalive"] = false; |
79 | m_SimulationService = service; | ||
80 | m_AuthenticationService = authentication; | ||
81 | // TODO: unused: m_AllowForeignGuests = foreignGuests; | ||
82 | } | ||
83 | 73 | ||
84 | public override byte[] Handle(string path, Stream request, | ||
85 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
86 | { | ||
87 | byte[] result = new byte[0]; | ||
88 | 74 | ||
89 | UUID agentID; | 75 | UUID agentID; |
76 | UUID regionID; | ||
90 | string action; | 77 | string action; |
91 | ulong regionHandle; | 78 | if (!Utils.GetParams((string)request["uri"], out agentID, out regionID, out action)) |
92 | if (!RestHandlerUtils.GetParams(path, out agentID, out regionHandle, out action)) | ||
93 | { | 79 | { |
94 | m_log.InfoFormat("[AgentPostHandler]: Invalid parameters for agent message {0}", path); | 80 | m_log.InfoFormat("[AGENT HANDLER]: Invalid parameters for agent message {0}", request["uri"]); |
95 | httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; | 81 | responsedata["int_response_code"] = 404; |
96 | httpResponse.StatusDescription = "Invalid parameters for agent message " + path; | 82 | responsedata["str_response_string"] = "false"; |
97 | 83 | ||
98 | return result; | 84 | return responsedata; |
99 | } | 85 | } |
100 | 86 | ||
101 | if (m_AuthenticationService != null) | 87 | // Next, let's parse the verb |
88 | string method = (string)request["http-method"]; | ||
89 | if (method.Equals("PUT")) | ||
102 | { | 90 | { |
103 | // Authentication | 91 | DoAgentPut(request, responsedata); |
104 | string authority = string.Empty; | 92 | return responsedata; |
105 | string authToken = string.Empty; | 93 | } |
106 | if (!RestHandlerUtils.GetAuthentication(httpRequest, out authority, out authToken)) | 94 | else if (method.Equals("POST")) |
107 | { | 95 | { |
108 | m_log.InfoFormat("[AgentPostHandler]: Authentication failed for agent message {0}", path); | 96 | DoAgentPost(request, responsedata, agentID); |
109 | httpResponse.StatusCode = (int)HttpStatusCode.Unauthorized; | 97 | return responsedata; |
110 | return result; | 98 | } |
111 | } | 99 | else if (method.Equals("GET")) |
112 | // TODO: Rethink this | 100 | { |
113 | //if (!m_AuthenticationService.VerifyKey(agentID, authToken)) | 101 | DoAgentGet(request, responsedata, agentID, regionID); |
114 | //{ | 102 | return responsedata; |
115 | // m_log.InfoFormat("[AgentPostHandler]: Authentication failed for agent message {0}", path); | 103 | } |
116 | // httpResponse.StatusCode = (int)HttpStatusCode.Forbidden; | 104 | else if (method.Equals("DELETE")) |
117 | // return result; | 105 | { |
118 | //} | 106 | DoAgentDelete(request, responsedata, agentID, action, regionID); |
119 | m_log.DebugFormat("[AgentPostHandler]: Authentication succeeded for {0}", agentID); | 107 | return responsedata; |
120 | } | 108 | } |
109 | else | ||
110 | { | ||
111 | m_log.InfoFormat("[AGENT HANDLER]: method {0} not supported in agent message", method); | ||
112 | responsedata["int_response_code"] = HttpStatusCode.MethodNotAllowed; | ||
113 | responsedata["str_response_string"] = "Method not allowed"; | ||
114 | |||
115 | return responsedata; | ||
116 | } | ||
117 | |||
118 | } | ||
121 | 119 | ||
122 | OSDMap args = Util.GetOSDMap(request, (int)httpRequest.ContentLength); | 120 | protected virtual void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id) |
121 | { | ||
122 | OSDMap args = Utils.GetOSDMap((string)request["body"]); | ||
123 | if (args == null) | 123 | if (args == null) |
124 | { | 124 | { |
125 | httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; | 125 | responsedata["int_response_code"] = HttpStatusCode.BadRequest; |
126 | httpResponse.StatusDescription = "Unable to retrieve data"; | 126 | responsedata["str_response_string"] = "Bad request"; |
127 | m_log.DebugFormat("[AgentPostHandler]: Unable to retrieve data for post {0}", path); | 127 | return; |
128 | return result; | ||
129 | } | 128 | } |
130 | 129 | ||
131 | // retrieve the regionhandle | 130 | // retrieve the input arguments |
132 | ulong regionhandle = 0; | 131 | int x = 0, y = 0; |
133 | if (args["destination_handle"] != null) | 132 | UUID uuid = UUID.Zero; |
134 | UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle); | 133 | string regionname = string.Empty; |
134 | uint teleportFlags = 0; | ||
135 | if (args.ContainsKey("destination_x") && args["destination_x"] != null) | ||
136 | Int32.TryParse(args["destination_x"].AsString(), out x); | ||
137 | else | ||
138 | m_log.WarnFormat(" -- request didn't have destination_x"); | ||
139 | if (args.ContainsKey("destination_y") && args["destination_y"] != null) | ||
140 | Int32.TryParse(args["destination_y"].AsString(), out y); | ||
141 | else | ||
142 | m_log.WarnFormat(" -- request didn't have destination_y"); | ||
143 | if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null) | ||
144 | UUID.TryParse(args["destination_uuid"].AsString(), out uuid); | ||
145 | if (args.ContainsKey("destination_name") && args["destination_name"] != null) | ||
146 | regionname = args["destination_name"].ToString(); | ||
147 | if (args.ContainsKey("teleport_flags") && args["teleport_flags"] != null) | ||
148 | teleportFlags = args["teleport_flags"].AsUInteger(); | ||
149 | |||
150 | GridRegion destination = new GridRegion(); | ||
151 | destination.RegionID = uuid; | ||
152 | destination.RegionLocX = x; | ||
153 | destination.RegionLocY = y; | ||
154 | destination.RegionName = regionname; | ||
135 | 155 | ||
136 | AgentCircuitData aCircuit = new AgentCircuitData(); | 156 | AgentCircuitData aCircuit = new AgentCircuitData(); |
137 | try | 157 | try |
@@ -140,70 +160,168 @@ namespace OpenSim.Server.Handlers.Simulation | |||
140 | } | 160 | } |
141 | catch (Exception ex) | 161 | catch (Exception ex) |
142 | { | 162 | { |
143 | m_log.InfoFormat("[AgentPostHandler]: exception on unpacking CreateAgent message {0}", ex.Message); | 163 | m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildCreate message {0}", ex.Message); |
144 | httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; | 164 | responsedata["int_response_code"] = HttpStatusCode.BadRequest; |
145 | httpResponse.StatusDescription = "Problems with data deserialization"; | 165 | responsedata["str_response_string"] = "Bad request"; |
146 | return result; | 166 | return; |
147 | } | 167 | } |
148 | 168 | ||
149 | string reason = string.Empty; | 169 | OSDMap resp = new OSDMap(2); |
170 | string reason = String.Empty; | ||
150 | 171 | ||
151 | // We need to clean up a few things in the user service before I can do this | 172 | // This is the meaning of POST agent |
152 | //if (m_AllowForeignGuests) | 173 | //m_regionClient.AdjustUserInformation(aCircuit); |
153 | // m_regionClient.AdjustUserInformation(aCircuit); | 174 | bool result = m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out reason); |
154 | 175 | ||
155 | // Finally! | 176 | resp["reason"] = OSD.FromString(reason); |
156 | bool success = m_SimulationService.CreateAgent(regionhandle, aCircuit, out reason); | 177 | resp["success"] = OSD.FromBoolean(result); |
157 | 178 | ||
158 | OSDMap resp = new OSDMap(1); | 179 | // TODO: add reason if not String.Empty? |
180 | responsedata["int_response_code"] = HttpStatusCode.OK; | ||
181 | responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); | ||
182 | } | ||
159 | 183 | ||
160 | resp["success"] = OSD.FromBoolean(success); | 184 | protected virtual void DoAgentPut(Hashtable request, Hashtable responsedata) |
185 | { | ||
186 | OSDMap args = Utils.GetOSDMap((string)request["body"]); | ||
187 | if (args == null) | ||
188 | { | ||
189 | responsedata["int_response_code"] = HttpStatusCode.BadRequest; | ||
190 | responsedata["str_response_string"] = "Bad request"; | ||
191 | return; | ||
192 | } | ||
161 | 193 | ||
162 | httpResponse.StatusCode = (int)HttpStatusCode.OK; | 194 | // retrieve the input arguments |
195 | int x = 0, y = 0; | ||
196 | UUID uuid = UUID.Zero; | ||
197 | string regionname = string.Empty; | ||
198 | if (args.ContainsKey("destination_x") && args["destination_x"] != null) | ||
199 | Int32.TryParse(args["destination_x"].AsString(), out x); | ||
200 | if (args.ContainsKey("destination_y") && args["destination_y"] != null) | ||
201 | Int32.TryParse(args["destination_y"].AsString(), out y); | ||
202 | if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null) | ||
203 | UUID.TryParse(args["destination_uuid"].AsString(), out uuid); | ||
204 | if (args.ContainsKey("destination_name") && args["destination_name"] != null) | ||
205 | regionname = args["destination_name"].ToString(); | ||
163 | 206 | ||
164 | return Util.UTF8.GetBytes(OSDParser.SerializeJsonString(resp)); | 207 | GridRegion destination = new GridRegion(); |
165 | } | 208 | destination.RegionID = uuid; |
166 | } | 209 | destination.RegionLocX = x; |
210 | destination.RegionLocY = y; | ||
211 | destination.RegionName = regionname; | ||
167 | 212 | ||
168 | public class AgentPutHandler : BaseStreamHandler | 213 | string messageType; |
169 | { | 214 | if (args["message_type"] != null) |
170 | // TODO: unused: private ISimulationService m_SimulationService; | 215 | messageType = args["message_type"].AsString(); |
171 | // TODO: unused: private IAuthenticationService m_AuthenticationService; | 216 | else |
217 | { | ||
218 | m_log.Warn("[AGENT HANDLER]: Agent Put Message Type not found. "); | ||
219 | messageType = "AgentData"; | ||
220 | } | ||
172 | 221 | ||
173 | public AgentPutHandler(ISimulationService service, IAuthenticationService authentication) : | 222 | bool result = true; |
174 | base("PUT", "/agent") | 223 | if ("AgentData".Equals(messageType)) |
175 | { | 224 | { |
176 | // TODO: unused: m_SimulationService = service; | 225 | AgentData agent = new AgentData(); |
177 | // TODO: unused: m_AuthenticationService = authentication; | 226 | try |
227 | { | ||
228 | agent.Unpack(args); | ||
229 | } | ||
230 | catch (Exception ex) | ||
231 | { | ||
232 | m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildAgentUpdate message {0}", ex.Message); | ||
233 | responsedata["int_response_code"] = HttpStatusCode.BadRequest; | ||
234 | responsedata["str_response_string"] = "Bad request"; | ||
235 | return; | ||
236 | } | ||
237 | |||
238 | //agent.Dump(); | ||
239 | // This is one of the meanings of PUT agent | ||
240 | result = m_SimulationService.UpdateAgent(destination, agent); | ||
241 | |||
242 | } | ||
243 | else if ("AgentPosition".Equals(messageType)) | ||
244 | { | ||
245 | AgentPosition agent = new AgentPosition(); | ||
246 | try | ||
247 | { | ||
248 | agent.Unpack(args); | ||
249 | } | ||
250 | catch (Exception ex) | ||
251 | { | ||
252 | m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildAgentUpdate message {0}", ex.Message); | ||
253 | return; | ||
254 | } | ||
255 | //agent.Dump(); | ||
256 | // This is one of the meanings of PUT agent | ||
257 | result = m_SimulationService.UpdateAgent(destination, agent); | ||
258 | |||
259 | } | ||
260 | |||
261 | responsedata["int_response_code"] = HttpStatusCode.OK; | ||
262 | responsedata["str_response_string"] = result.ToString(); | ||
263 | //responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); ??? instead | ||
178 | } | 264 | } |
179 | 265 | ||
180 | public override byte[] Handle(string path, Stream request, | 266 | protected virtual void DoAgentGet(Hashtable request, Hashtable responsedata, UUID id, UUID regionID) |
181 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
182 | { | 267 | { |
183 | // Not implemented yet | 268 | GridRegion destination = new GridRegion(); |
184 | httpResponse.StatusCode = (int)HttpStatusCode.NotImplemented; | 269 | destination.RegionID = regionID; |
185 | return new byte[] { }; | ||
186 | } | ||
187 | } | ||
188 | 270 | ||
189 | public class AgentDeleteHandler : BaseStreamHandler | 271 | IAgentData agent = null; |
190 | { | 272 | bool result = m_SimulationService.RetrieveAgent(destination, id, out agent); |
191 | // TODO: unused: private ISimulationService m_SimulationService; | 273 | OSDMap map = null; |
192 | // TODO: unused: private IAuthenticationService m_AuthenticationService; | 274 | if (result) |
275 | { | ||
276 | if (agent != null) // just to make sure | ||
277 | { | ||
278 | map = agent.Pack(); | ||
279 | string strBuffer = ""; | ||
280 | try | ||
281 | { | ||
282 | strBuffer = OSDParser.SerializeJsonString(map); | ||
283 | } | ||
284 | catch (Exception e) | ||
285 | { | ||
286 | m_log.WarnFormat("[AGENT HANDLER]: Exception thrown on serialization of DoAgentGet: {0}", e.Message); | ||
287 | responsedata["int_response_code"] = HttpStatusCode.InternalServerError; | ||
288 | // ignore. buffer will be empty, caller should check. | ||
289 | } | ||
193 | 290 | ||
194 | public AgentDeleteHandler(ISimulationService service, IAuthenticationService authentication) : | 291 | responsedata["content_type"] = "application/json"; |
195 | base("DELETE", "/agent") | 292 | responsedata["int_response_code"] = HttpStatusCode.OK; |
196 | { | 293 | responsedata["str_response_string"] = strBuffer; |
197 | // TODO: unused: m_SimulationService = service; | 294 | } |
198 | // TODO: unused: m_AuthenticationService = authentication; | 295 | else |
296 | { | ||
297 | responsedata["int_response_code"] = HttpStatusCode.InternalServerError; | ||
298 | responsedata["str_response_string"] = "Internal error"; | ||
299 | } | ||
300 | } | ||
301 | else | ||
302 | { | ||
303 | responsedata["int_response_code"] = HttpStatusCode.NotFound; | ||
304 | responsedata["str_response_string"] = "Not Found"; | ||
305 | } | ||
199 | } | 306 | } |
200 | 307 | ||
201 | public override byte[] Handle(string path, Stream request, | 308 | protected virtual void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, UUID regionID) |
202 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
203 | { | 309 | { |
204 | // Not implemented yet | 310 | //m_log.Debug(" >>> DoDelete action:" + action + "; regionHandle:" + regionHandle); |
205 | httpResponse.StatusCode = (int)HttpStatusCode.NotImplemented; | 311 | |
206 | return new byte[] { }; | 312 | GridRegion destination = new GridRegion(); |
313 | destination.RegionID = regionID; | ||
314 | |||
315 | if (action.Equals("release")) | ||
316 | m_SimulationService.ReleaseAgent(destination, id, ""); | ||
317 | else | ||
318 | m_SimulationService.CloseAgent(destination, id); | ||
319 | |||
320 | responsedata["int_response_code"] = HttpStatusCode.OK; | ||
321 | responsedata["str_response_string"] = "OpenSim agent " + id.ToString(); | ||
322 | |||
323 | m_log.Debug("[AGENT HANDLER]: Agent Deleted."); | ||
207 | } | 324 | } |
208 | } | 325 | } |
326 | |||
209 | } | 327 | } |
diff --git a/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs b/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs new file mode 100644 index 0000000..995a3c4 --- /dev/null +++ b/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs | |||
@@ -0,0 +1,229 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using System.Net; | ||
33 | using System.Text; | ||
34 | |||
35 | using OpenSim.Server.Base; | ||
36 | using OpenSim.Server.Handlers.Base; | ||
37 | using OpenSim.Services.Interfaces; | ||
38 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Framework.Servers.HttpServer; | ||
41 | |||
42 | using OpenMetaverse; | ||
43 | using OpenMetaverse.StructuredData; | ||
44 | using Nini.Config; | ||
45 | using log4net; | ||
46 | |||
47 | |||
48 | namespace OpenSim.Server.Handlers.Simulation | ||
49 | { | ||
50 | public class ObjectHandler | ||
51 | { | ||
52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
53 | private ISimulationService m_SimulationService; | ||
54 | |||
55 | public ObjectHandler(ISimulationService sim) | ||
56 | { | ||
57 | m_SimulationService = sim; | ||
58 | } | ||
59 | |||
60 | public Hashtable Handler(Hashtable request) | ||
61 | { | ||
62 | m_log.Debug("[CONNECTION DEBUGGING]: ObjectHandler Called"); | ||
63 | |||
64 | m_log.Debug("---------------------------"); | ||
65 | m_log.Debug(" >> uri=" + request["uri"]); | ||
66 | m_log.Debug(" >> content-type=" + request["content-type"]); | ||
67 | m_log.Debug(" >> http-method=" + request["http-method"]); | ||
68 | m_log.Debug("---------------------------\n"); | ||
69 | |||
70 | Hashtable responsedata = new Hashtable(); | ||
71 | responsedata["content_type"] = "text/html"; | ||
72 | |||
73 | UUID objectID; | ||
74 | UUID regionID; | ||
75 | string action; | ||
76 | if (!Utils.GetParams((string)request["uri"], out objectID, out regionID, out action)) | ||
77 | { | ||
78 | m_log.InfoFormat("[REST COMMS]: Invalid parameters for object message {0}", request["uri"]); | ||
79 | responsedata["int_response_code"] = 404; | ||
80 | responsedata["str_response_string"] = "false"; | ||
81 | |||
82 | return responsedata; | ||
83 | } | ||
84 | |||
85 | // Next, let's parse the verb | ||
86 | string method = (string)request["http-method"]; | ||
87 | if (method.Equals("POST")) | ||
88 | { | ||
89 | DoObjectPost(request, responsedata, regionID); | ||
90 | return responsedata; | ||
91 | } | ||
92 | else if (method.Equals("PUT")) | ||
93 | { | ||
94 | DoObjectPut(request, responsedata, regionID); | ||
95 | return responsedata; | ||
96 | } | ||
97 | //else if (method.Equals("DELETE")) | ||
98 | //{ | ||
99 | // DoObjectDelete(request, responsedata, agentID, action, regionHandle); | ||
100 | // return responsedata; | ||
101 | //} | ||
102 | else | ||
103 | { | ||
104 | m_log.InfoFormat("[REST COMMS]: method {0} not supported in object message", method); | ||
105 | responsedata["int_response_code"] = HttpStatusCode.MethodNotAllowed; | ||
106 | responsedata["str_response_string"] = "Mthod not allowed"; | ||
107 | |||
108 | return responsedata; | ||
109 | } | ||
110 | |||
111 | } | ||
112 | |||
113 | protected virtual void DoObjectPost(Hashtable request, Hashtable responsedata, UUID regionID) | ||
114 | { | ||
115 | OSDMap args = Utils.GetOSDMap((string)request["body"]); | ||
116 | if (args == null) | ||
117 | { | ||
118 | responsedata["int_response_code"] = 400; | ||
119 | responsedata["str_response_string"] = "false"; | ||
120 | return; | ||
121 | } | ||
122 | // retrieve the input arguments | ||
123 | int x = 0, y = 0; | ||
124 | UUID uuid = UUID.Zero; | ||
125 | string regionname = string.Empty; | ||
126 | if (args.ContainsKey("destination_x") && args["destination_x"] != null) | ||
127 | Int32.TryParse(args["destination_x"].AsString(), out x); | ||
128 | if (args.ContainsKey("destination_y") && args["destination_y"] != null) | ||
129 | Int32.TryParse(args["destination_y"].AsString(), out y); | ||
130 | if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null) | ||
131 | UUID.TryParse(args["destination_uuid"].AsString(), out uuid); | ||
132 | if (args.ContainsKey("destination_name") && args["destination_name"] != null) | ||
133 | regionname = args["destination_name"].ToString(); | ||
134 | |||
135 | GridRegion destination = new GridRegion(); | ||
136 | destination.RegionID = uuid; | ||
137 | destination.RegionLocX = x; | ||
138 | destination.RegionLocY = y; | ||
139 | destination.RegionName = regionname; | ||
140 | |||
141 | string sogXmlStr = "", extraStr = "", stateXmlStr = ""; | ||
142 | if (args.ContainsKey("sog") && args["sog"] != null) | ||
143 | sogXmlStr = args["sog"].AsString(); | ||
144 | if (args.ContainsKey("extra") && args["extra"] != null) | ||
145 | extraStr = args["extra"].AsString(); | ||
146 | |||
147 | IScene s = m_SimulationService.GetScene(destination.RegionHandle); | ||
148 | ISceneObject sog = null; | ||
149 | try | ||
150 | { | ||
151 | //sog = SceneObjectSerializer.FromXml2Format(sogXmlStr); | ||
152 | sog = s.DeserializeObject(sogXmlStr); | ||
153 | sog.ExtraFromXmlString(extraStr); | ||
154 | } | ||
155 | catch (Exception ex) | ||
156 | { | ||
157 | m_log.InfoFormat("[REST COMMS]: exception on deserializing scene object {0}", ex.Message); | ||
158 | responsedata["int_response_code"] = HttpStatusCode.BadRequest; | ||
159 | responsedata["str_response_string"] = "Bad request"; | ||
160 | return; | ||
161 | } | ||
162 | |||
163 | if ((args["state"] != null) && s.AllowScriptCrossings) | ||
164 | { | ||
165 | stateXmlStr = args["state"].AsString(); | ||
166 | if (stateXmlStr != "") | ||
167 | { | ||
168 | try | ||
169 | { | ||
170 | sog.SetState(stateXmlStr, s); | ||
171 | } | ||
172 | catch (Exception ex) | ||
173 | { | ||
174 | m_log.InfoFormat("[REST COMMS]: exception on setting state for scene object {0}", ex.Message); | ||
175 | // ignore and continue | ||
176 | } | ||
177 | } | ||
178 | } | ||
179 | // This is the meaning of POST object | ||
180 | bool result = m_SimulationService.CreateObject(destination, sog, false); | ||
181 | |||
182 | responsedata["int_response_code"] = HttpStatusCode.OK; | ||
183 | responsedata["str_response_string"] = result.ToString(); | ||
184 | } | ||
185 | |||
186 | protected virtual void DoObjectPut(Hashtable request, Hashtable responsedata, UUID regionID) | ||
187 | { | ||
188 | OSDMap args = Utils.GetOSDMap((string)request["body"]); | ||
189 | if (args == null) | ||
190 | { | ||
191 | responsedata["int_response_code"] = 400; | ||
192 | responsedata["str_response_string"] = "false"; | ||
193 | return; | ||
194 | } | ||
195 | |||
196 | // retrieve the input arguments | ||
197 | int x = 0, y = 0; | ||
198 | UUID uuid = UUID.Zero; | ||
199 | string regionname = string.Empty; | ||
200 | if (args.ContainsKey("destination_x") && args["destination_x"] != null) | ||
201 | Int32.TryParse(args["destination_x"].AsString(), out x); | ||
202 | if (args.ContainsKey("destination_y") && args["destination_y"] != null) | ||
203 | Int32.TryParse(args["destination_y"].AsString(), out y); | ||
204 | if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null) | ||
205 | UUID.TryParse(args["destination_uuid"].AsString(), out uuid); | ||
206 | if (args.ContainsKey("destination_name") && args["destination_name"] != null) | ||
207 | regionname = args["destination_name"].ToString(); | ||
208 | |||
209 | GridRegion destination = new GridRegion(); | ||
210 | destination.RegionID = uuid; | ||
211 | destination.RegionLocX = x; | ||
212 | destination.RegionLocY = y; | ||
213 | destination.RegionName = regionname; | ||
214 | |||
215 | UUID userID = UUID.Zero, itemID = UUID.Zero; | ||
216 | if (args.ContainsKey("userid") && args["userid"] != null) | ||
217 | userID = args["userid"].AsUUID(); | ||
218 | if (args.ContainsKey("itemid") && args["itemid"] != null) | ||
219 | itemID = args["itemid"].AsUUID(); | ||
220 | |||
221 | // This is the meaning of PUT object | ||
222 | bool result = m_SimulationService.CreateObject(destination, userID, itemID); | ||
223 | |||
224 | responsedata["int_response_code"] = 200; | ||
225 | responsedata["str_response_string"] = result.ToString(); | ||
226 | } | ||
227 | |||
228 | } | ||
229 | } \ No newline at end of file | ||
diff --git a/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs b/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs index fe93fa5..55a575c 100644 --- a/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs +++ b/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs | |||
@@ -37,22 +37,15 @@ namespace OpenSim.Server.Handlers.Simulation | |||
37 | { | 37 | { |
38 | public class SimulationServiceInConnector : ServiceConnector | 38 | public class SimulationServiceInConnector : ServiceConnector |
39 | { | 39 | { |
40 | private ISimulationService m_SimulationService; | 40 | private ISimulationService m_LocalSimulationService; |
41 | private IAuthenticationService m_AuthenticationService; | 41 | private IAuthenticationService m_AuthenticationService; |
42 | 42 | ||
43 | public SimulationServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) : | 43 | public SimulationServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) : |
44 | base(config, server, String.Empty) | 44 | base(config, server, String.Empty) |
45 | { | 45 | { |
46 | IConfig serverConfig = config.Configs["SimulationService"]; | 46 | //IConfig serverConfig = config.Configs["SimulationService"]; |
47 | if (serverConfig == null) | 47 | //if (serverConfig == null) |
48 | throw new Exception("No section 'SimulationService' in config file"); | 48 | // throw new Exception("No section 'SimulationService' in config file"); |
49 | |||
50 | bool authentication = serverConfig.GetBoolean("RequireAuthentication", false); | ||
51 | |||
52 | if (authentication) | ||
53 | m_AuthenticationService = scene.RequestModuleInterface<IAuthenticationService>(); | ||
54 | |||
55 | bool foreignGuests = serverConfig.GetBoolean("AllowForeignGuests", false); | ||
56 | 49 | ||
57 | //string simService = serverConfig.GetString("LocalServiceModule", | 50 | //string simService = serverConfig.GetString("LocalServiceModule", |
58 | // String.Empty); | 51 | // String.Empty); |
@@ -61,20 +54,18 @@ namespace OpenSim.Server.Handlers.Simulation | |||
61 | // throw new Exception("No SimulationService in config file"); | 54 | // throw new Exception("No SimulationService in config file"); |
62 | 55 | ||
63 | //Object[] args = new Object[] { config }; | 56 | //Object[] args = new Object[] { config }; |
64 | m_SimulationService = scene.RequestModuleInterface<ISimulationService>(); | 57 | m_LocalSimulationService = scene.RequestModuleInterface<ISimulationService>(); |
65 | //ServerUtils.LoadPlugin<ISimulationService>(simService, args); | 58 | //ServerUtils.LoadPlugin<ISimulationService>(simService, args); |
66 | if (m_SimulationService == null) | ||
67 | throw new Exception("No Local ISimulationService Module"); | ||
68 | |||
69 | |||
70 | 59 | ||
71 | //System.Console.WriteLine("XXXXXXXXXXXXXXXXXXX m_AssetSetvice == null? " + ((m_AssetService == null) ? "yes" : "no")); | 60 | //System.Console.WriteLine("XXXXXXXXXXXXXXXXXXX m_AssetSetvice == null? " + ((m_AssetService == null) ? "yes" : "no")); |
72 | server.AddStreamHandler(new AgentGetHandler(m_SimulationService, m_AuthenticationService)); | 61 | //server.AddStreamHandler(new AgentGetHandler(m_SimulationService, m_AuthenticationService)); |
73 | server.AddStreamHandler(new AgentPostHandler(m_SimulationService, m_AuthenticationService, foreignGuests)); | 62 | //server.AddStreamHandler(new AgentPostHandler(m_SimulationService, m_AuthenticationService)); |
74 | server.AddStreamHandler(new AgentPutHandler(m_SimulationService, m_AuthenticationService)); | 63 | //server.AddStreamHandler(new AgentPutHandler(m_SimulationService, m_AuthenticationService)); |
75 | server.AddStreamHandler(new AgentDeleteHandler(m_SimulationService, m_AuthenticationService)); | 64 | //server.AddStreamHandler(new AgentDeleteHandler(m_SimulationService, m_AuthenticationService)); |
65 | server.AddHTTPHandler("/agent/", new AgentHandler(m_LocalSimulationService).Handler); | ||
66 | server.AddHTTPHandler("/object/", new ObjectHandler(m_LocalSimulationService).Handler); | ||
67 | |||
76 | //server.AddStreamHandler(new ObjectPostHandler(m_SimulationService, authentication)); | 68 | //server.AddStreamHandler(new ObjectPostHandler(m_SimulationService, authentication)); |
77 | //server.AddStreamHandler(new NeighborPostHandler(m_SimulationService, authentication)); | ||
78 | } | 69 | } |
79 | } | 70 | } |
80 | } | 71 | } |
diff --git a/OpenSim/Server/Handlers/Simulation/Utils.cs b/OpenSim/Server/Handlers/Simulation/Utils.cs new file mode 100644 index 0000000..ed379da --- /dev/null +++ b/OpenSim/Server/Handlers/Simulation/Utils.cs | |||
@@ -0,0 +1,103 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | |||
32 | using OpenMetaverse; | ||
33 | using OpenMetaverse.StructuredData; | ||
34 | |||
35 | using log4net; | ||
36 | |||
37 | namespace OpenSim.Server.Handlers.Simulation | ||
38 | { | ||
39 | public class Utils | ||
40 | { | ||
41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
42 | |||
43 | /// <summary> | ||
44 | /// Extract the param from an uri. | ||
45 | /// </summary> | ||
46 | /// <param name="uri">Something like this: /agent/uuid/ or /agent/uuid/handle/release</param> | ||
47 | /// <param name="uri">uuid on uuid field</param> | ||
48 | /// <param name="action">optional action</param> | ||
49 | public static bool GetParams(string uri, out UUID uuid, out UUID regionID, out string action) | ||
50 | { | ||
51 | uuid = UUID.Zero; | ||
52 | regionID = UUID.Zero; | ||
53 | action = ""; | ||
54 | |||
55 | uri = uri.Trim(new char[] { '/' }); | ||
56 | string[] parts = uri.Split('/'); | ||
57 | if (parts.Length <= 1) | ||
58 | { | ||
59 | return false; | ||
60 | } | ||
61 | else | ||
62 | { | ||
63 | if (!UUID.TryParse(parts[1], out uuid)) | ||
64 | return false; | ||
65 | |||
66 | if (parts.Length >= 3) | ||
67 | UUID.TryParse(parts[2], out regionID); | ||
68 | if (parts.Length >= 4) | ||
69 | action = parts[3]; | ||
70 | |||
71 | return true; | ||
72 | } | ||
73 | } | ||
74 | |||
75 | public static OSDMap GetOSDMap(string data) | ||
76 | { | ||
77 | OSDMap args = null; | ||
78 | try | ||
79 | { | ||
80 | OSD buffer; | ||
81 | // We should pay attention to the content-type, but let's assume we know it's Json | ||
82 | buffer = OSDParser.DeserializeJson(data); | ||
83 | if (buffer.Type == OSDType.Map) | ||
84 | { | ||
85 | args = (OSDMap)buffer; | ||
86 | return args; | ||
87 | } | ||
88 | else | ||
89 | { | ||
90 | // uh? | ||
91 | m_log.Debug(("[REST COMMS]: Got OSD of unexpected type " + buffer.Type.ToString())); | ||
92 | return null; | ||
93 | } | ||
94 | } | ||
95 | catch (Exception ex) | ||
96 | { | ||
97 | m_log.Debug("[REST COMMS]: exception on parse of REST message " + ex.Message); | ||
98 | return null; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | } | ||
103 | } | ||
diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerConnector.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerConnector.cs new file mode 100644 index 0000000..f17a8de --- /dev/null +++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerConnector.cs | |||
@@ -0,0 +1,61 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using Nini.Config; | ||
30 | using OpenSim.Server.Base; | ||
31 | using OpenSim.Services.Interfaces; | ||
32 | using OpenSim.Framework.Servers.HttpServer; | ||
33 | using OpenSim.Server.Handlers.Base; | ||
34 | |||
35 | namespace OpenSim.Server.Handlers.UserAccounts | ||
36 | { | ||
37 | public class UserAccountServiceConnector : ServiceConnector | ||
38 | { | ||
39 | private IUserAccountService m_UserAccountService; | ||
40 | private string m_ConfigName = "UserAccountService"; | ||
41 | |||
42 | public UserAccountServiceConnector(IConfigSource config, IHttpServer server, string configName) : | ||
43 | base(config, server, configName) | ||
44 | { | ||
45 | IConfig serverConfig = config.Configs[m_ConfigName]; | ||
46 | if (serverConfig == null) | ||
47 | throw new Exception(String.Format("No section {0} in config file", m_ConfigName)); | ||
48 | |||
49 | string service = serverConfig.GetString("LocalServiceModule", | ||
50 | String.Empty); | ||
51 | |||
52 | if (service == String.Empty) | ||
53 | throw new Exception("No LocalServiceModule in config file"); | ||
54 | |||
55 | Object[] args = new Object[] { config }; | ||
56 | m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(service, args); | ||
57 | |||
58 | server.AddStreamHandler(new UserAccountServerPostHandler(m_UserAccountService)); | ||
59 | } | ||
60 | } | ||
61 | } | ||
diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs new file mode 100644 index 0000000..b54b63e --- /dev/null +++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs | |||
@@ -0,0 +1,257 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using Nini.Config; | ||
29 | using log4net; | ||
30 | using System; | ||
31 | using System.Reflection; | ||
32 | using System.IO; | ||
33 | using System.Net; | ||
34 | using System.Text; | ||
35 | using System.Text.RegularExpressions; | ||
36 | using System.Xml; | ||
37 | using System.Xml.Serialization; | ||
38 | using System.Collections.Generic; | ||
39 | using OpenSim.Server.Base; | ||
40 | using OpenSim.Services.Interfaces; | ||
41 | using OpenSim.Framework; | ||
42 | using OpenSim.Framework.Servers.HttpServer; | ||
43 | using OpenMetaverse; | ||
44 | |||
45 | namespace OpenSim.Server.Handlers.UserAccounts | ||
46 | { | ||
47 | public class UserAccountServerPostHandler : BaseStreamHandler | ||
48 | { | ||
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
51 | private IUserAccountService m_UserAccountService; | ||
52 | |||
53 | public UserAccountServerPostHandler(IUserAccountService service) : | ||
54 | base("POST", "/accounts") | ||
55 | { | ||
56 | m_UserAccountService = service; | ||
57 | } | ||
58 | |||
59 | public override byte[] Handle(string path, Stream requestData, | ||
60 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
61 | { | ||
62 | StreamReader sr = new StreamReader(requestData); | ||
63 | string body = sr.ReadToEnd(); | ||
64 | sr.Close(); | ||
65 | body = body.Trim(); | ||
66 | |||
67 | // We need to check the authorization header | ||
68 | //httpRequest.Headers["authorization"] ... | ||
69 | |||
70 | //m_log.DebugFormat("[XXX]: query String: {0}", body); | ||
71 | |||
72 | try | ||
73 | { | ||
74 | Dictionary<string, object> request = | ||
75 | ServerUtils.ParseQueryString(body); | ||
76 | |||
77 | if (!request.ContainsKey("METHOD")) | ||
78 | return FailureResult(); | ||
79 | |||
80 | string method = request["METHOD"].ToString(); | ||
81 | |||
82 | switch (method) | ||
83 | { | ||
84 | case "getaccount": | ||
85 | return GetAccount(request); | ||
86 | case "getaccounts": | ||
87 | return GetAccounts(request); | ||
88 | case "setaccount": | ||
89 | return StoreAccount(request); | ||
90 | } | ||
91 | m_log.DebugFormat("[PRESENCE HANDLER]: unknown method request: {0}", method); | ||
92 | } | ||
93 | catch (Exception e) | ||
94 | { | ||
95 | m_log.Debug("[PRESENCE HANDLER]: Exception {0}" + e); | ||
96 | } | ||
97 | |||
98 | return FailureResult(); | ||
99 | |||
100 | } | ||
101 | |||
102 | byte[] GetAccount(Dictionary<string, object> request) | ||
103 | { | ||
104 | UserAccount account = null; | ||
105 | UUID scopeID = UUID.Zero; | ||
106 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
107 | |||
108 | if (!request.ContainsKey("ScopeID")) | ||
109 | { | ||
110 | result["result"] = "null"; | ||
111 | return ResultToBytes(result); | ||
112 | } | ||
113 | |||
114 | if (!UUID.TryParse(request["ScopeID"].ToString(), out scopeID)) | ||
115 | { | ||
116 | result["result"] = "null"; | ||
117 | return ResultToBytes(result); | ||
118 | } | ||
119 | |||
120 | if (request.ContainsKey("UserID") && request["UserID"] != null) | ||
121 | { | ||
122 | UUID userID; | ||
123 | if (UUID.TryParse(request["UserID"].ToString(), out userID)) | ||
124 | account = m_UserAccountService.GetUserAccount(scopeID, userID); | ||
125 | } | ||
126 | |||
127 | else if (request.ContainsKey("Email") && request["Email"] != null) | ||
128 | account = m_UserAccountService.GetUserAccount(scopeID, request["Email"].ToString()); | ||
129 | |||
130 | else if (request.ContainsKey("FirstName") && request.ContainsKey("LastName") && | ||
131 | request["FirstName"] != null && request["LastName"] != null) | ||
132 | account = m_UserAccountService.GetUserAccount(scopeID, request["FirstName"].ToString(), request["LastName"].ToString()); | ||
133 | |||
134 | if (account == null) | ||
135 | result["result"] = "null"; | ||
136 | else | ||
137 | result["result"] = account.ToKeyValuePairs(); | ||
138 | |||
139 | return ResultToBytes(result); | ||
140 | } | ||
141 | |||
142 | byte[] GetAccounts(Dictionary<string, object> request) | ||
143 | { | ||
144 | if (!request.ContainsKey("ScopeID") || !request.ContainsKey("query")) | ||
145 | return FailureResult(); | ||
146 | |||
147 | UUID scopeID = UUID.Zero; | ||
148 | if (!UUID.TryParse(request["ScopeID"].ToString(), out scopeID)) | ||
149 | return FailureResult(); | ||
150 | |||
151 | string query = request["query"].ToString(); | ||
152 | |||
153 | List<UserAccount> accounts = m_UserAccountService.GetUserAccounts(scopeID, query); | ||
154 | |||
155 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
156 | if ((accounts == null) || ((accounts != null) && (accounts.Count == 0))) | ||
157 | result["result"] = "null"; | ||
158 | else | ||
159 | { | ||
160 | int i = 0; | ||
161 | foreach (UserAccount acc in accounts) | ||
162 | { | ||
163 | Dictionary<string, object> rinfoDict = acc.ToKeyValuePairs(); | ||
164 | result["account" + i] = rinfoDict; | ||
165 | i++; | ||
166 | } | ||
167 | } | ||
168 | |||
169 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
170 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
171 | UTF8Encoding encoding = new UTF8Encoding(); | ||
172 | return encoding.GetBytes(xmlString); | ||
173 | } | ||
174 | |||
175 | byte[] StoreAccount(Dictionary<string, object> request) | ||
176 | { | ||
177 | //if (!request.ContainsKey("account")) | ||
178 | // return FailureResult(); | ||
179 | //if (request["account"] == null) | ||
180 | // return FailureResult(); | ||
181 | //if (!(request["account"] is Dictionary<string, object>)) | ||
182 | // return FailureResult(); | ||
183 | |||
184 | UserAccount account = new UserAccount(request); | ||
185 | |||
186 | if (m_UserAccountService.StoreUserAccount(account)) | ||
187 | return SuccessResult(); | ||
188 | |||
189 | return FailureResult(); | ||
190 | } | ||
191 | |||
192 | private byte[] SuccessResult() | ||
193 | { | ||
194 | XmlDocument doc = new XmlDocument(); | ||
195 | |||
196 | XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, | ||
197 | "", ""); | ||
198 | |||
199 | doc.AppendChild(xmlnode); | ||
200 | |||
201 | XmlElement rootElement = doc.CreateElement("", "ServerResponse", | ||
202 | ""); | ||
203 | |||
204 | doc.AppendChild(rootElement); | ||
205 | |||
206 | XmlElement result = doc.CreateElement("", "result", ""); | ||
207 | result.AppendChild(doc.CreateTextNode("Success")); | ||
208 | |||
209 | rootElement.AppendChild(result); | ||
210 | |||
211 | return DocToBytes(doc); | ||
212 | } | ||
213 | |||
214 | private byte[] FailureResult() | ||
215 | { | ||
216 | XmlDocument doc = new XmlDocument(); | ||
217 | |||
218 | XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, | ||
219 | "", ""); | ||
220 | |||
221 | doc.AppendChild(xmlnode); | ||
222 | |||
223 | XmlElement rootElement = doc.CreateElement("", "ServerResponse", | ||
224 | ""); | ||
225 | |||
226 | doc.AppendChild(rootElement); | ||
227 | |||
228 | XmlElement result = doc.CreateElement("", "result", ""); | ||
229 | result.AppendChild(doc.CreateTextNode("Failure")); | ||
230 | |||
231 | rootElement.AppendChild(result); | ||
232 | |||
233 | return DocToBytes(doc); | ||
234 | } | ||
235 | |||
236 | private byte[] DocToBytes(XmlDocument doc) | ||
237 | { | ||
238 | MemoryStream ms = new MemoryStream(); | ||
239 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
240 | xw.Formatting = Formatting.Indented; | ||
241 | doc.WriteTo(xw); | ||
242 | xw.Flush(); | ||
243 | |||
244 | return ms.ToArray(); | ||
245 | } | ||
246 | |||
247 | private byte[] ResultToBytes(Dictionary<string, object> result) | ||
248 | { | ||
249 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
250 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
251 | UTF8Encoding encoding = new UTF8Encoding(); | ||
252 | return encoding.GetBytes(xmlString); | ||
253 | } | ||
254 | |||
255 | |||
256 | } | ||
257 | } | ||
diff --git a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs index d65665a..021dcf3 100644 --- a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs | |||
@@ -47,9 +47,9 @@ namespace OpenSim.Services.AuthenticationService | |||
47 | public class PasswordAuthenticationService : | 47 | public class PasswordAuthenticationService : |
48 | AuthenticationServiceBase, IAuthenticationService | 48 | AuthenticationServiceBase, IAuthenticationService |
49 | { | 49 | { |
50 | // private static readonly ILog m_log = | 50 | //private static readonly ILog m_log = |
51 | // LogManager.GetLogger( | 51 | // LogManager.GetLogger( |
52 | // MethodBase.GetCurrentMethod().DeclaringType); | 52 | // MethodBase.GetCurrentMethod().DeclaringType); |
53 | 53 | ||
54 | public PasswordAuthenticationService(IConfigSource config) : | 54 | public PasswordAuthenticationService(IConfigSource config) : |
55 | base(config) | 55 | base(config) |
@@ -66,9 +66,11 @@ namespace OpenSim.Services.AuthenticationService | |||
66 | return String.Empty; | 66 | return String.Empty; |
67 | } | 67 | } |
68 | 68 | ||
69 | string hashed = Util.Md5Hash(Util.Md5Hash(password) + ":" + | 69 | string hashed = Util.Md5Hash(password + ":" + |
70 | data.Data["passwordSalt"].ToString()); | 70 | data.Data["passwordSalt"].ToString()); |
71 | 71 | ||
72 | //m_log.DebugFormat("[PASS AUTH]: got {0}; hashed = {1}; stored = {2}", password, hashed, data.Data["passwordHash"].ToString()); | ||
73 | |||
72 | if (data.Data["passwordHash"].ToString() == hashed) | 74 | if (data.Data["passwordHash"].ToString() == hashed) |
73 | { | 75 | { |
74 | return GetToken(principalID, lifetime); | 76 | return GetToken(principalID, lifetime); |
diff --git a/OpenSim/Services/AvatarService/AvatarService.cs b/OpenSim/Services/AvatarService/AvatarService.cs new file mode 100644 index 0000000..0b351a2 --- /dev/null +++ b/OpenSim/Services/AvatarService/AvatarService.cs | |||
@@ -0,0 +1,138 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Net; | ||
31 | using System.Reflection; | ||
32 | using Nini.Config; | ||
33 | using log4net; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Console; | ||
36 | using OpenSim.Data; | ||
37 | using OpenSim.Services.Interfaces; | ||
38 | using OpenMetaverse; | ||
39 | |||
40 | namespace OpenSim.Services.AvatarService | ||
41 | { | ||
42 | public class AvatarService : AvatarServiceBase, IAvatarService | ||
43 | { | ||
44 | private static readonly ILog m_log = | ||
45 | LogManager.GetLogger( | ||
46 | MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | public AvatarService(IConfigSource config) | ||
49 | : base(config) | ||
50 | { | ||
51 | m_log.Debug("[AVATAR SERVICE]: Starting avatar service"); | ||
52 | } | ||
53 | |||
54 | public AvatarData GetAvatar(UUID principalID) | ||
55 | { | ||
56 | AvatarBaseData[] av = m_Database.Get("PrincipalID", principalID.ToString()); | ||
57 | if (av.Length == 0) | ||
58 | return null; | ||
59 | |||
60 | AvatarData ret = new AvatarData(); | ||
61 | ret.Data = new Dictionary<string,string>(); | ||
62 | |||
63 | foreach (AvatarBaseData b in av) | ||
64 | { | ||
65 | if (b.Data["Name"] == "AvatarType") | ||
66 | ret.AvatarType = Convert.ToInt32(b.Data["Value"]); | ||
67 | else | ||
68 | ret.Data[b.Data["Name"]] = b.Data["Value"]; | ||
69 | } | ||
70 | |||
71 | return ret; | ||
72 | } | ||
73 | |||
74 | public bool SetAvatar(UUID principalID, AvatarData avatar) | ||
75 | { | ||
76 | m_Database.Delete("PrincipalID", principalID.ToString()); | ||
77 | |||
78 | AvatarBaseData av = new AvatarBaseData(); | ||
79 | av.Data = new Dictionary<string,string>(); | ||
80 | |||
81 | av.PrincipalID = principalID; | ||
82 | av.Data["Name"] = "AvatarType"; | ||
83 | av.Data["Value"] = avatar.AvatarType.ToString(); | ||
84 | |||
85 | if (!m_Database.Store(av)) | ||
86 | return false; | ||
87 | |||
88 | foreach (KeyValuePair<string,string> kvp in avatar.Data) | ||
89 | { | ||
90 | av.Data["Name"] = kvp.Key; | ||
91 | av.Data["Value"] = kvp.Value; | ||
92 | |||
93 | if (!m_Database.Store(av)) | ||
94 | { | ||
95 | m_Database.Delete("PrincipalID", principalID.ToString()); | ||
96 | return false; | ||
97 | } | ||
98 | } | ||
99 | |||
100 | return true; | ||
101 | } | ||
102 | |||
103 | public bool ResetAvatar(UUID principalID) | ||
104 | { | ||
105 | return m_Database.Delete("PrincipalID", principalID.ToString()); | ||
106 | } | ||
107 | |||
108 | public bool SetItems(UUID principalID, string[] names, string[] values) | ||
109 | { | ||
110 | AvatarBaseData av = new AvatarBaseData(); | ||
111 | av.Data = new Dictionary<string,string>(); | ||
112 | av.PrincipalID = principalID; | ||
113 | |||
114 | if (names.Length != values.Length) | ||
115 | return false; | ||
116 | |||
117 | for (int i = 0 ; i < names.Length ; i++) | ||
118 | { | ||
119 | av.Data["Name"] = names[i]; | ||
120 | av.Data["Value"] = values[i]; | ||
121 | |||
122 | if (!m_Database.Store(av)) | ||
123 | return false; | ||
124 | } | ||
125 | |||
126 | return true; | ||
127 | } | ||
128 | |||
129 | public bool RemoveItems(UUID principalID, string[] names) | ||
130 | { | ||
131 | foreach (string name in names) | ||
132 | { | ||
133 | m_Database.Delete(principalID, name); | ||
134 | } | ||
135 | return true; | ||
136 | } | ||
137 | } | ||
138 | } | ||
diff --git a/OpenSim/Services/AvatarService/AvatarServiceBase.cs b/OpenSim/Services/AvatarService/AvatarServiceBase.cs new file mode 100644 index 0000000..ab9d7cd --- /dev/null +++ b/OpenSim/Services/AvatarService/AvatarServiceBase.cs | |||
@@ -0,0 +1,84 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using Nini.Config; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Data; | ||
33 | using OpenSim.Services.Interfaces; | ||
34 | using OpenSim.Services.Base; | ||
35 | |||
36 | namespace OpenSim.Services.AvatarService | ||
37 | { | ||
38 | public class AvatarServiceBase : ServiceBase | ||
39 | { | ||
40 | protected IAvatarData m_Database = null; | ||
41 | |||
42 | public AvatarServiceBase(IConfigSource config) | ||
43 | : base(config) | ||
44 | { | ||
45 | string dllName = String.Empty; | ||
46 | string connString = String.Empty; | ||
47 | string realm = "Avatars"; | ||
48 | |||
49 | // | ||
50 | // Try reading the [DatabaseService] section, if it exists | ||
51 | // | ||
52 | IConfig dbConfig = config.Configs["DatabaseService"]; | ||
53 | if (dbConfig != null) | ||
54 | { | ||
55 | if (dllName == String.Empty) | ||
56 | dllName = dbConfig.GetString("StorageProvider", String.Empty); | ||
57 | if (connString == String.Empty) | ||
58 | connString = dbConfig.GetString("ConnectionString", String.Empty); | ||
59 | } | ||
60 | |||
61 | // | ||
62 | // [AvatarService] section overrides [DatabaseService], if it exists | ||
63 | // | ||
64 | IConfig presenceConfig = config.Configs["AvatarService"]; | ||
65 | if (presenceConfig != null) | ||
66 | { | ||
67 | dllName = presenceConfig.GetString("StorageProvider", dllName); | ||
68 | connString = presenceConfig.GetString("ConnectionString", connString); | ||
69 | realm = presenceConfig.GetString("Realm", realm); | ||
70 | } | ||
71 | |||
72 | // | ||
73 | // We tried, but this doesn't exist. We can't proceed. | ||
74 | // | ||
75 | if (dllName.Equals(String.Empty)) | ||
76 | throw new Exception("No StorageProvider configured"); | ||
77 | |||
78 | m_Database = LoadPlugin<IAvatarData>(dllName, new Object[] { connString, realm }); | ||
79 | if (m_Database == null) | ||
80 | throw new Exception("Could not find a storage interface in the given module " + dllName); | ||
81 | |||
82 | } | ||
83 | } | ||
84 | } | ||
diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs index 50e817e..1250658 100644 --- a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs | |||
@@ -67,7 +67,7 @@ namespace OpenSim.Services.Connectors | |||
67 | IConfig assetConfig = source.Configs["AuthenticationService"]; | 67 | IConfig assetConfig = source.Configs["AuthenticationService"]; |
68 | if (assetConfig == null) | 68 | if (assetConfig == null) |
69 | { | 69 | { |
70 | m_log.Error("[USER CONNECTOR]: AuthenticationService missing from OpanSim.ini"); | 70 | m_log.Error("[AUTH CONNECTOR]: AuthenticationService missing from OpanSim.ini"); |
71 | throw new Exception("Authentication connector init error"); | 71 | throw new Exception("Authentication connector init error"); |
72 | } | 72 | } |
73 | 73 | ||
@@ -76,7 +76,7 @@ namespace OpenSim.Services.Connectors | |||
76 | 76 | ||
77 | if (serviceURI == String.Empty) | 77 | if (serviceURI == String.Empty) |
78 | { | 78 | { |
79 | m_log.Error("[USER CONNECTOR]: No Server URI named in section AuthenticationService"); | 79 | m_log.Error("[AUTH CONNECTOR]: No Server URI named in section AuthenticationService"); |
80 | throw new Exception("Authentication connector init error"); | 80 | throw new Exception("Authentication connector init error"); |
81 | } | 81 | } |
82 | m_ServerURI = serviceURI; | 82 | m_ServerURI = serviceURI; |
@@ -84,7 +84,7 @@ namespace OpenSim.Services.Connectors | |||
84 | 84 | ||
85 | public string Authenticate(UUID principalID, string password, int lifetime) | 85 | public string Authenticate(UUID principalID, string password, int lifetime) |
86 | { | 86 | { |
87 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | 87 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
88 | sendData["LIFETIME"] = lifetime.ToString(); | 88 | sendData["LIFETIME"] = lifetime.ToString(); |
89 | sendData["PRINCIPAL"] = principalID.ToString(); | 89 | sendData["PRINCIPAL"] = principalID.ToString(); |
90 | sendData["PASSWORD"] = password; | 90 | sendData["PASSWORD"] = password; |
@@ -106,7 +106,7 @@ namespace OpenSim.Services.Connectors | |||
106 | 106 | ||
107 | public bool Verify(UUID principalID, string token, int lifetime) | 107 | public bool Verify(UUID principalID, string token, int lifetime) |
108 | { | 108 | { |
109 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | 109 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
110 | sendData["LIFETIME"] = lifetime.ToString(); | 110 | sendData["LIFETIME"] = lifetime.ToString(); |
111 | sendData["PRINCIPAL"] = principalID.ToString(); | 111 | sendData["PRINCIPAL"] = principalID.ToString(); |
112 | sendData["TOKEN"] = token; | 112 | sendData["TOKEN"] = token; |
@@ -128,7 +128,7 @@ namespace OpenSim.Services.Connectors | |||
128 | 128 | ||
129 | public bool Release(UUID principalID, string token) | 129 | public bool Release(UUID principalID, string token) |
130 | { | 130 | { |
131 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | 131 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
132 | sendData["PRINCIPAL"] = principalID.ToString(); | 132 | sendData["PRINCIPAL"] = principalID.ToString(); |
133 | sendData["TOKEN"] = token; | 133 | sendData["TOKEN"] = token; |
134 | 134 | ||
diff --git a/OpenSim/Services/Connectors/Avatar/AvatarServiceConnector.cs b/OpenSim/Services/Connectors/Avatar/AvatarServiceConnector.cs new file mode 100644 index 0000000..6d9fc60 --- /dev/null +++ b/OpenSim/Services/Connectors/Avatar/AvatarServiceConnector.cs | |||
@@ -0,0 +1,317 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using log4net; | ||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.IO; | ||
32 | using System.Reflection; | ||
33 | using Nini.Config; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Communications; | ||
36 | using OpenSim.Framework.Servers.HttpServer; | ||
37 | using OpenSim.Services.Interfaces; | ||
38 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
39 | using IAvatarService = OpenSim.Services.Interfaces.IAvatarService; | ||
40 | using OpenSim.Server.Base; | ||
41 | using OpenMetaverse; | ||
42 | |||
43 | namespace OpenSim.Services.Connectors | ||
44 | { | ||
45 | public class AvatarServicesConnector : IAvatarService | ||
46 | { | ||
47 | private static readonly ILog m_log = | ||
48 | LogManager.GetLogger( | ||
49 | MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
51 | private string m_ServerURI = String.Empty; | ||
52 | |||
53 | public AvatarServicesConnector() | ||
54 | { | ||
55 | } | ||
56 | |||
57 | public AvatarServicesConnector(string serverURI) | ||
58 | { | ||
59 | m_ServerURI = serverURI.TrimEnd('/'); | ||
60 | } | ||
61 | |||
62 | public AvatarServicesConnector(IConfigSource source) | ||
63 | { | ||
64 | Initialise(source); | ||
65 | } | ||
66 | |||
67 | public virtual void Initialise(IConfigSource source) | ||
68 | { | ||
69 | IConfig gridConfig = source.Configs["AvatarService"]; | ||
70 | if (gridConfig == null) | ||
71 | { | ||
72 | m_log.Error("[AVATAR CONNECTOR]: AvatarService missing from OpenSim.ini"); | ||
73 | throw new Exception("Avatar connector init error"); | ||
74 | } | ||
75 | |||
76 | string serviceURI = gridConfig.GetString("AvatarServerURI", | ||
77 | String.Empty); | ||
78 | |||
79 | if (serviceURI == String.Empty) | ||
80 | { | ||
81 | m_log.Error("[AVATAR CONNECTOR]: No Server URI named in section AvatarService"); | ||
82 | throw new Exception("Avatar connector init error"); | ||
83 | } | ||
84 | m_ServerURI = serviceURI; | ||
85 | } | ||
86 | |||
87 | |||
88 | #region IAvatarService | ||
89 | |||
90 | public AvatarData GetAvatar(UUID userID) | ||
91 | { | ||
92 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
93 | //sendData["SCOPEID"] = scopeID.ToString(); | ||
94 | sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
95 | sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
96 | sendData["METHOD"] = "getavatar"; | ||
97 | |||
98 | sendData["UserID"] = userID; | ||
99 | |||
100 | string reply = string.Empty; | ||
101 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
102 | // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString); | ||
103 | try | ||
104 | { | ||
105 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
106 | m_ServerURI + "/avatar", | ||
107 | reqString); | ||
108 | if (reply == null || (reply != null && reply == string.Empty)) | ||
109 | { | ||
110 | m_log.DebugFormat("[AVATAR CONNECTOR]: GetAgent received null or empty reply"); | ||
111 | return null; | ||
112 | } | ||
113 | } | ||
114 | catch (Exception e) | ||
115 | { | ||
116 | m_log.DebugFormat("[AVATAR CONNECTOR]: Exception when contacting presence server: {0}", e.Message); | ||
117 | } | ||
118 | |||
119 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
120 | AvatarData avatar = null; | ||
121 | |||
122 | if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null)) | ||
123 | { | ||
124 | if (replyData["result"] is Dictionary<string, object>) | ||
125 | { | ||
126 | avatar = new AvatarData((Dictionary<string, object>)replyData["result"]); | ||
127 | } | ||
128 | } | ||
129 | |||
130 | return avatar; | ||
131 | |||
132 | } | ||
133 | |||
134 | public bool SetAvatar(UUID userID, AvatarData avatar) | ||
135 | { | ||
136 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
137 | //sendData["SCOPEID"] = scopeID.ToString(); | ||
138 | sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
139 | sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
140 | sendData["METHOD"] = "setavatar"; | ||
141 | |||
142 | sendData["UserID"] = userID.ToString(); | ||
143 | |||
144 | Dictionary<string, object> structData = avatar.ToKeyValuePairs(); | ||
145 | |||
146 | foreach (KeyValuePair<string, object> kvp in structData) | ||
147 | sendData[kvp.Key] = kvp.Value.ToString(); | ||
148 | |||
149 | |||
150 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
151 | // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString); | ||
152 | try | ||
153 | { | ||
154 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
155 | m_ServerURI + "/avatar", | ||
156 | reqString); | ||
157 | if (reply != string.Empty) | ||
158 | { | ||
159 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
160 | |||
161 | if (replyData.ContainsKey("result")) | ||
162 | { | ||
163 | if (replyData["result"].ToString().ToLower() == "success") | ||
164 | return true; | ||
165 | else | ||
166 | return false; | ||
167 | } | ||
168 | else | ||
169 | m_log.DebugFormat("[AVATAR CONNECTOR]: SetAvatar reply data does not contain result field"); | ||
170 | |||
171 | } | ||
172 | else | ||
173 | m_log.DebugFormat("[AVATAR CONNECTOR]: SetAvatar received empty reply"); | ||
174 | } | ||
175 | catch (Exception e) | ||
176 | { | ||
177 | m_log.DebugFormat("[AVATAR CONNECTOR]: Exception when contacting avatar server: {0}", e.Message); | ||
178 | } | ||
179 | |||
180 | return false; | ||
181 | } | ||
182 | |||
183 | public bool ResetAvatar(UUID userID) | ||
184 | { | ||
185 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
186 | //sendData["SCOPEID"] = scopeID.ToString(); | ||
187 | sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
188 | sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
189 | sendData["METHOD"] = "resetavatar"; | ||
190 | |||
191 | sendData["UserID"] = userID.ToString(); | ||
192 | |||
193 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
194 | // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString); | ||
195 | try | ||
196 | { | ||
197 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
198 | m_ServerURI + "/avatar", | ||
199 | reqString); | ||
200 | if (reply != string.Empty) | ||
201 | { | ||
202 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
203 | |||
204 | if (replyData.ContainsKey("result")) | ||
205 | { | ||
206 | if (replyData["result"].ToString().ToLower() == "success") | ||
207 | return true; | ||
208 | else | ||
209 | return false; | ||
210 | } | ||
211 | else | ||
212 | m_log.DebugFormat("[AVATAR CONNECTOR]: SetItems reply data does not contain result field"); | ||
213 | |||
214 | } | ||
215 | else | ||
216 | m_log.DebugFormat("[AVATAR CONNECTOR]: SetItems received empty reply"); | ||
217 | } | ||
218 | catch (Exception e) | ||
219 | { | ||
220 | m_log.DebugFormat("[AVATAR CONNECTOR]: Exception when contacting avatar server: {0}", e.Message); | ||
221 | } | ||
222 | |||
223 | return false; | ||
224 | } | ||
225 | |||
226 | public bool SetItems(UUID userID, string[] names, string[] values) | ||
227 | { | ||
228 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
229 | sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
230 | sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
231 | sendData["METHOD"] = "setitems"; | ||
232 | |||
233 | sendData["UserID"] = userID.ToString(); | ||
234 | sendData["Names"] = new List<string>(names); | ||
235 | sendData["Values"] = new List<string>(values); | ||
236 | |||
237 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
238 | // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString); | ||
239 | try | ||
240 | { | ||
241 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
242 | m_ServerURI + "/avatar", | ||
243 | reqString); | ||
244 | if (reply != string.Empty) | ||
245 | { | ||
246 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
247 | |||
248 | if (replyData.ContainsKey("result")) | ||
249 | { | ||
250 | if (replyData["result"].ToString().ToLower() == "success") | ||
251 | return true; | ||
252 | else | ||
253 | return false; | ||
254 | } | ||
255 | else | ||
256 | m_log.DebugFormat("[AVATAR CONNECTOR]: SetItems reply data does not contain result field"); | ||
257 | |||
258 | } | ||
259 | else | ||
260 | m_log.DebugFormat("[AVATAR CONNECTOR]: SetItems received empty reply"); | ||
261 | } | ||
262 | catch (Exception e) | ||
263 | { | ||
264 | m_log.DebugFormat("[AVATAR CONNECTOR]: Exception when contacting avatar server: {0}", e.Message); | ||
265 | } | ||
266 | |||
267 | return false; | ||
268 | } | ||
269 | |||
270 | public bool RemoveItems(UUID userID, string[] names) | ||
271 | { | ||
272 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
273 | //sendData["SCOPEID"] = scopeID.ToString(); | ||
274 | sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
275 | sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
276 | sendData["METHOD"] = "removeitems"; | ||
277 | |||
278 | sendData["UserID"] = userID.ToString(); | ||
279 | sendData["Names"] = new List<string>(names); | ||
280 | |||
281 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
282 | // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString); | ||
283 | try | ||
284 | { | ||
285 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
286 | m_ServerURI + "/avatar", | ||
287 | reqString); | ||
288 | if (reply != string.Empty) | ||
289 | { | ||
290 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
291 | |||
292 | if (replyData.ContainsKey("result")) | ||
293 | { | ||
294 | if (replyData["result"].ToString().ToLower() == "success") | ||
295 | return true; | ||
296 | else | ||
297 | return false; | ||
298 | } | ||
299 | else | ||
300 | m_log.DebugFormat("[AVATAR CONNECTOR]: RemoveItems reply data does not contain result field"); | ||
301 | |||
302 | } | ||
303 | else | ||
304 | m_log.DebugFormat("[AVATAR CONNECTOR]: RemoveItems received empty reply"); | ||
305 | } | ||
306 | catch (Exception e) | ||
307 | { | ||
308 | m_log.DebugFormat("[AVATAR CONNECTOR]: Exception when contacting avatar server: {0}", e.Message); | ||
309 | } | ||
310 | |||
311 | return false; | ||
312 | } | ||
313 | |||
314 | #endregion | ||
315 | |||
316 | } | ||
317 | } | ||
diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index 02f2b79..99aa3fb 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs | |||
@@ -89,7 +89,7 @@ namespace OpenSim.Services.Connectors | |||
89 | public virtual bool RegisterRegion(UUID scopeID, GridRegion regionInfo) | 89 | public virtual bool RegisterRegion(UUID scopeID, GridRegion regionInfo) |
90 | { | 90 | { |
91 | Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs(); | 91 | Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs(); |
92 | Dictionary<string, string> sendData = new Dictionary<string,string>(); | 92 | Dictionary<string, object> sendData = new Dictionary<string,object>(); |
93 | foreach (KeyValuePair<string, object> kvp in rinfo) | 93 | foreach (KeyValuePair<string, object> kvp in rinfo) |
94 | sendData[kvp.Key] = (string)kvp.Value; | 94 | sendData[kvp.Key] = (string)kvp.Value; |
95 | 95 | ||
@@ -130,7 +130,7 @@ namespace OpenSim.Services.Connectors | |||
130 | 130 | ||
131 | public virtual bool DeregisterRegion(UUID regionID) | 131 | public virtual bool DeregisterRegion(UUID regionID) |
132 | { | 132 | { |
133 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | 133 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
134 | 134 | ||
135 | sendData["REGIONID"] = regionID.ToString(); | 135 | sendData["REGIONID"] = regionID.ToString(); |
136 | 136 | ||
@@ -162,7 +162,7 @@ namespace OpenSim.Services.Connectors | |||
162 | 162 | ||
163 | public virtual List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID) | 163 | public virtual List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID) |
164 | { | 164 | { |
165 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | 165 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
166 | 166 | ||
167 | sendData["SCOPEID"] = scopeID.ToString(); | 167 | sendData["SCOPEID"] = scopeID.ToString(); |
168 | sendData["REGIONID"] = regionID.ToString(); | 168 | sendData["REGIONID"] = regionID.ToString(); |
@@ -212,7 +212,7 @@ namespace OpenSim.Services.Connectors | |||
212 | 212 | ||
213 | public virtual GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) | 213 | public virtual GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) |
214 | { | 214 | { |
215 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | 215 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
216 | 216 | ||
217 | sendData["SCOPEID"] = scopeID.ToString(); | 217 | sendData["SCOPEID"] = scopeID.ToString(); |
218 | sendData["REGIONID"] = regionID.ToString(); | 218 | sendData["REGIONID"] = regionID.ToString(); |
@@ -258,7 +258,7 @@ namespace OpenSim.Services.Connectors | |||
258 | 258 | ||
259 | public virtual GridRegion GetRegionByPosition(UUID scopeID, int x, int y) | 259 | public virtual GridRegion GetRegionByPosition(UUID scopeID, int x, int y) |
260 | { | 260 | { |
261 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | 261 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
262 | 262 | ||
263 | sendData["SCOPEID"] = scopeID.ToString(); | 263 | sendData["SCOPEID"] = scopeID.ToString(); |
264 | sendData["X"] = x.ToString(); | 264 | sendData["X"] = x.ToString(); |
@@ -303,7 +303,7 @@ namespace OpenSim.Services.Connectors | |||
303 | 303 | ||
304 | public virtual GridRegion GetRegionByName(UUID scopeID, string regionName) | 304 | public virtual GridRegion GetRegionByName(UUID scopeID, string regionName) |
305 | { | 305 | { |
306 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | 306 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
307 | 307 | ||
308 | sendData["SCOPEID"] = scopeID.ToString(); | 308 | sendData["SCOPEID"] = scopeID.ToString(); |
309 | sendData["NAME"] = regionName; | 309 | sendData["NAME"] = regionName; |
@@ -344,7 +344,7 @@ namespace OpenSim.Services.Connectors | |||
344 | 344 | ||
345 | public virtual List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber) | 345 | public virtual List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber) |
346 | { | 346 | { |
347 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | 347 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
348 | 348 | ||
349 | sendData["SCOPEID"] = scopeID.ToString(); | 349 | sendData["SCOPEID"] = scopeID.ToString(); |
350 | sendData["NAME"] = name; | 350 | sendData["NAME"] = name; |
@@ -396,7 +396,7 @@ namespace OpenSim.Services.Connectors | |||
396 | 396 | ||
397 | public virtual List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) | 397 | public virtual List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) |
398 | { | 398 | { |
399 | Dictionary<string, string> sendData = new Dictionary<string, string>(); | 399 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
400 | 400 | ||
401 | sendData["SCOPEID"] = scopeID.ToString(); | 401 | sendData["SCOPEID"] = scopeID.ToString(); |
402 | sendData["XMIN"] = xmin.ToString(); | 402 | sendData["XMIN"] = xmin.ToString(); |
diff --git a/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs new file mode 100644 index 0000000..29cfd6e --- /dev/null +++ b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs | |||
@@ -0,0 +1,421 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using log4net; | ||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.IO; | ||
32 | using System.Reflection; | ||
33 | using Nini.Config; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Communications; | ||
36 | using OpenSim.Framework.Servers.HttpServer; | ||
37 | using OpenSim.Services.Interfaces; | ||
38 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
39 | using OpenSim.Server.Base; | ||
40 | using OpenMetaverse; | ||
41 | |||
42 | namespace OpenSim.Services.Connectors | ||
43 | { | ||
44 | public class PresenceServicesConnector : IPresenceService | ||
45 | { | ||
46 | private static readonly ILog m_log = | ||
47 | LogManager.GetLogger( | ||
48 | MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | private string m_ServerURI = String.Empty; | ||
51 | |||
52 | public PresenceServicesConnector() | ||
53 | { | ||
54 | } | ||
55 | |||
56 | public PresenceServicesConnector(string serverURI) | ||
57 | { | ||
58 | m_ServerURI = serverURI.TrimEnd('/'); | ||
59 | } | ||
60 | |||
61 | public PresenceServicesConnector(IConfigSource source) | ||
62 | { | ||
63 | Initialise(source); | ||
64 | } | ||
65 | |||
66 | public virtual void Initialise(IConfigSource source) | ||
67 | { | ||
68 | IConfig gridConfig = source.Configs["PresenceService"]; | ||
69 | if (gridConfig == null) | ||
70 | { | ||
71 | m_log.Error("[PRESENCE CONNECTOR]: PresenceService missing from OpenSim.ini"); | ||
72 | throw new Exception("Presence connector init error"); | ||
73 | } | ||
74 | |||
75 | string serviceURI = gridConfig.GetString("PresenceServerURI", | ||
76 | String.Empty); | ||
77 | |||
78 | if (serviceURI == String.Empty) | ||
79 | { | ||
80 | m_log.Error("[PRESENCE CONNECTOR]: No Server URI named in section PresenceService"); | ||
81 | throw new Exception("Presence connector init error"); | ||
82 | } | ||
83 | m_ServerURI = serviceURI; | ||
84 | } | ||
85 | |||
86 | |||
87 | #region IPresenceService | ||
88 | |||
89 | public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) | ||
90 | { | ||
91 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
92 | //sendData["SCOPEID"] = scopeID.ToString(); | ||
93 | sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
94 | sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
95 | sendData["METHOD"] = "login"; | ||
96 | |||
97 | sendData["UserID"] = userID; | ||
98 | sendData["SessionID"] = sessionID.ToString(); | ||
99 | sendData["SecureSessionID"] = secureSessionID.ToString(); | ||
100 | |||
101 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
102 | // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString); | ||
103 | try | ||
104 | { | ||
105 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
106 | m_ServerURI + "/presence", | ||
107 | reqString); | ||
108 | if (reply != string.Empty) | ||
109 | { | ||
110 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
111 | |||
112 | if (replyData.ContainsKey("result")) | ||
113 | { | ||
114 | if (replyData["result"].ToString().ToLower() == "success") | ||
115 | return true; | ||
116 | else | ||
117 | return false; | ||
118 | } | ||
119 | else | ||
120 | m_log.DebugFormat("[PRESENCE CONNECTOR]: LoginAgent reply data does not contain result field"); | ||
121 | |||
122 | } | ||
123 | else | ||
124 | m_log.DebugFormat("[PRESENCE CONNECTOR]: LoginAgent received empty reply"); | ||
125 | } | ||
126 | catch (Exception e) | ||
127 | { | ||
128 | m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server: {0}", e.Message); | ||
129 | } | ||
130 | |||
131 | return false; | ||
132 | |||
133 | } | ||
134 | |||
135 | public bool LogoutAgent(UUID sessionID) | ||
136 | { | ||
137 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
138 | //sendData["SCOPEID"] = scopeID.ToString(); | ||
139 | sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
140 | sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
141 | sendData["METHOD"] = "logout"; | ||
142 | |||
143 | sendData["SessionID"] = sessionID.ToString(); | ||
144 | |||
145 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
146 | // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString); | ||
147 | try | ||
148 | { | ||
149 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
150 | m_ServerURI + "/presence", | ||
151 | reqString); | ||
152 | if (reply != string.Empty) | ||
153 | { | ||
154 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
155 | |||
156 | if (replyData.ContainsKey("result")) | ||
157 | { | ||
158 | if (replyData["result"].ToString().ToLower() == "success") | ||
159 | return true; | ||
160 | else | ||
161 | return false; | ||
162 | } | ||
163 | else | ||
164 | m_log.DebugFormat("[PRESENCE CONNECTOR]: LogoutAgent reply data does not contain result field"); | ||
165 | |||
166 | } | ||
167 | else | ||
168 | m_log.DebugFormat("[PRESENCE CONNECTOR]: LogoutAgent received empty reply"); | ||
169 | } | ||
170 | catch (Exception e) | ||
171 | { | ||
172 | m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server: {0}", e.Message); | ||
173 | } | ||
174 | |||
175 | return false; | ||
176 | } | ||
177 | |||
178 | public bool LogoutRegionAgents(UUID regionID) | ||
179 | { | ||
180 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
181 | //sendData["SCOPEID"] = scopeID.ToString(); | ||
182 | sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
183 | sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
184 | sendData["METHOD"] = "logoutregion"; | ||
185 | |||
186 | sendData["RegionID"] = regionID.ToString(); | ||
187 | |||
188 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
189 | // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString); | ||
190 | try | ||
191 | { | ||
192 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
193 | m_ServerURI + "/presence", | ||
194 | reqString); | ||
195 | if (reply != string.Empty) | ||
196 | { | ||
197 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
198 | |||
199 | if (replyData.ContainsKey("result")) | ||
200 | { | ||
201 | if (replyData["result"].ToString().ToLower() == "success") | ||
202 | return true; | ||
203 | else | ||
204 | return false; | ||
205 | } | ||
206 | else | ||
207 | m_log.DebugFormat("[PRESENCE CONNECTOR]: LogoutRegionAgents reply data does not contain result field"); | ||
208 | |||
209 | } | ||
210 | else | ||
211 | m_log.DebugFormat("[PRESENCE CONNECTOR]: LogoutRegionAgents received empty reply"); | ||
212 | } | ||
213 | catch (Exception e) | ||
214 | { | ||
215 | m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server: {0}", e.Message); | ||
216 | } | ||
217 | |||
218 | return false; | ||
219 | } | ||
220 | |||
221 | public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
222 | { | ||
223 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
224 | //sendData["SCOPEID"] = scopeID.ToString(); | ||
225 | sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
226 | sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
227 | sendData["METHOD"] = "report"; | ||
228 | |||
229 | sendData["SessionID"] = sessionID.ToString(); | ||
230 | sendData["RegionID"] = regionID.ToString(); | ||
231 | sendData["position"] = position.ToString(); | ||
232 | sendData["lookAt"] = lookAt.ToString(); | ||
233 | |||
234 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
235 | // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString); | ||
236 | try | ||
237 | { | ||
238 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
239 | m_ServerURI + "/presence", | ||
240 | reqString); | ||
241 | if (reply != string.Empty) | ||
242 | { | ||
243 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
244 | |||
245 | if (replyData.ContainsKey("result")) | ||
246 | { | ||
247 | if (replyData["result"].ToString().ToLower() == "success") | ||
248 | return true; | ||
249 | else | ||
250 | return false; | ||
251 | } | ||
252 | else | ||
253 | m_log.DebugFormat("[PRESENCE CONNECTOR]: ReportAgent reply data does not contain result field"); | ||
254 | |||
255 | } | ||
256 | else | ||
257 | m_log.DebugFormat("[PRESENCE CONNECTOR]: ReportAgent received empty reply"); | ||
258 | } | ||
259 | catch (Exception e) | ||
260 | { | ||
261 | m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server: {0}", e.Message); | ||
262 | } | ||
263 | |||
264 | return false; | ||
265 | } | ||
266 | |||
267 | public PresenceInfo GetAgent(UUID sessionID) | ||
268 | { | ||
269 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
270 | //sendData["SCOPEID"] = scopeID.ToString(); | ||
271 | sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
272 | sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
273 | sendData["METHOD"] = "getagent"; | ||
274 | |||
275 | sendData["SessionID"] = sessionID.ToString(); | ||
276 | |||
277 | string reply = string.Empty; | ||
278 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
279 | // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString); | ||
280 | try | ||
281 | { | ||
282 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
283 | m_ServerURI + "/presence", | ||
284 | reqString); | ||
285 | if (reply == null || (reply != null && reply == string.Empty)) | ||
286 | { | ||
287 | m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgent received null or empty reply"); | ||
288 | return null; | ||
289 | } | ||
290 | } | ||
291 | catch (Exception e) | ||
292 | { | ||
293 | m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server: {0}", e.Message); | ||
294 | } | ||
295 | |||
296 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
297 | PresenceInfo pinfo = null; | ||
298 | |||
299 | if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null)) | ||
300 | { | ||
301 | if (replyData["result"] is Dictionary<string, object>) | ||
302 | { | ||
303 | pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]); | ||
304 | } | ||
305 | } | ||
306 | |||
307 | return pinfo; | ||
308 | } | ||
309 | |||
310 | public PresenceInfo[] GetAgents(string[] userIDs) | ||
311 | { | ||
312 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
313 | //sendData["SCOPEID"] = scopeID.ToString(); | ||
314 | sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
315 | sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
316 | sendData["METHOD"] = "getagents"; | ||
317 | |||
318 | sendData["uuids"] = new List<string>(userIDs); | ||
319 | |||
320 | string reply = string.Empty; | ||
321 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
322 | // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString); | ||
323 | try | ||
324 | { | ||
325 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
326 | m_ServerURI + "/presence", | ||
327 | reqString); | ||
328 | if (reply == null || (reply != null && reply == string.Empty)) | ||
329 | { | ||
330 | m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgent received null or empty reply"); | ||
331 | return null; | ||
332 | } | ||
333 | } | ||
334 | catch (Exception e) | ||
335 | { | ||
336 | m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server: {0}", e.Message); | ||
337 | } | ||
338 | |||
339 | List<PresenceInfo> rinfos = new List<PresenceInfo>(); | ||
340 | |||
341 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
342 | |||
343 | if (replyData != null) | ||
344 | { | ||
345 | if (replyData.ContainsKey("result") && | ||
346 | (replyData["result"].ToString() == "null" || replyData["result"].ToString() == "Failure")) | ||
347 | { | ||
348 | return new PresenceInfo[0]; | ||
349 | } | ||
350 | |||
351 | Dictionary<string, object>.ValueCollection pinfosList = replyData.Values; | ||
352 | //m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgents returned {0} elements", pinfosList.Count); | ||
353 | foreach (object presence in pinfosList) | ||
354 | { | ||
355 | if (presence is Dictionary<string, object>) | ||
356 | { | ||
357 | PresenceInfo pinfo = new PresenceInfo((Dictionary<string, object>)presence); | ||
358 | rinfos.Add(pinfo); | ||
359 | } | ||
360 | else | ||
361 | m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgents received invalid response type {0}", | ||
362 | presence.GetType()); | ||
363 | } | ||
364 | } | ||
365 | else | ||
366 | m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgents received null response"); | ||
367 | |||
368 | return rinfos.ToArray(); | ||
369 | } | ||
370 | |||
371 | |||
372 | public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
373 | { | ||
374 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
375 | //sendData["SCOPEID"] = scopeID.ToString(); | ||
376 | sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
377 | sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
378 | sendData["METHOD"] = "sethome"; | ||
379 | |||
380 | sendData["UserID"] = userID; | ||
381 | sendData["RegionID"] = regionID.ToString(); | ||
382 | sendData["position"] = position.ToString(); | ||
383 | sendData["lookAt"] = lookAt.ToString(); | ||
384 | |||
385 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
386 | // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString); | ||
387 | try | ||
388 | { | ||
389 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
390 | m_ServerURI + "/presence", | ||
391 | reqString); | ||
392 | if (reply != string.Empty) | ||
393 | { | ||
394 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
395 | |||
396 | if (replyData.ContainsKey("result")) | ||
397 | { | ||
398 | if (replyData["result"].ToString().ToLower() == "success") | ||
399 | return true; | ||
400 | else | ||
401 | return false; | ||
402 | } | ||
403 | else | ||
404 | m_log.DebugFormat("[PRESENCE CONNECTOR]: SetHomeLocation reply data does not contain result field"); | ||
405 | |||
406 | } | ||
407 | else | ||
408 | m_log.DebugFormat("[PRESENCE CONNECTOR]: SetHomeLocation received empty reply"); | ||
409 | } | ||
410 | catch (Exception e) | ||
411 | { | ||
412 | m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server: {0}", e.Message); | ||
413 | } | ||
414 | |||
415 | return false; | ||
416 | } | ||
417 | |||
418 | #endregion | ||
419 | |||
420 | } | ||
421 | } | ||
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs new file mode 100644 index 0000000..dc532d0 --- /dev/null +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs | |||
@@ -0,0 +1,414 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Text; | ||
34 | |||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
38 | |||
39 | using OpenMetaverse; | ||
40 | using OpenMetaverse.StructuredData; | ||
41 | using log4net; | ||
42 | using Nini.Config; | ||
43 | |||
44 | namespace OpenSim.Services.Connectors.Simulation | ||
45 | { | ||
46 | public class SimulationServiceConnector : ISimulationService | ||
47 | { | ||
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | //private GridRegion m_Region; | ||
51 | |||
52 | public SimulationServiceConnector() | ||
53 | { | ||
54 | } | ||
55 | |||
56 | public SimulationServiceConnector(IConfigSource config) | ||
57 | { | ||
58 | //m_Region = region; | ||
59 | } | ||
60 | |||
61 | public IScene GetScene(ulong regionHandle) | ||
62 | { | ||
63 | return null; | ||
64 | } | ||
65 | |||
66 | #region Agents | ||
67 | |||
68 | public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason) | ||
69 | { | ||
70 | reason = String.Empty; | ||
71 | |||
72 | if (destination == null) | ||
73 | { | ||
74 | reason = "Destination is null"; | ||
75 | m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Given destination is null"); | ||
76 | return false; | ||
77 | } | ||
78 | |||
79 | // Eventually, we want to use a caps url instead of the agentID | ||
80 | string uri = string.Empty; | ||
81 | try | ||
82 | { | ||
83 | uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + aCircuit.AgentID + "/"; | ||
84 | } | ||
85 | catch (Exception e) | ||
86 | { | ||
87 | m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Unable to resolve external endpoint on agent create. Reason: " + e.Message); | ||
88 | reason = e.Message; | ||
89 | return false; | ||
90 | } | ||
91 | |||
92 | //Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri); | ||
93 | |||
94 | HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri); | ||
95 | AgentCreateRequest.Method = "POST"; | ||
96 | AgentCreateRequest.ContentType = "application/json"; | ||
97 | AgentCreateRequest.Timeout = 10000; | ||
98 | //AgentCreateRequest.KeepAlive = false; | ||
99 | //AgentCreateRequest.Headers.Add("Authorization", authKey); | ||
100 | |||
101 | // Fill it in | ||
102 | OSDMap args = null; | ||
103 | try | ||
104 | { | ||
105 | args = aCircuit.PackAgentCircuitData(); | ||
106 | } | ||
107 | catch (Exception e) | ||
108 | { | ||
109 | m_log.Debug("[REMOTE SIMULATION CONNECTOR]: PackAgentCircuitData failed with exception: " + e.Message); | ||
110 | } | ||
111 | // Add the input arguments | ||
112 | args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); | ||
113 | args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); | ||
114 | args["destination_name"] = OSD.FromString(destination.RegionName); | ||
115 | args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); | ||
116 | args["teleport_flags"] = OSD.FromString(flags.ToString()); | ||
117 | |||
118 | string strBuffer = ""; | ||
119 | byte[] buffer = new byte[1]; | ||
120 | try | ||
121 | { | ||
122 | strBuffer = OSDParser.SerializeJsonString(args); | ||
123 | Encoding str = Util.UTF8; | ||
124 | buffer = str.GetBytes(strBuffer); | ||
125 | |||
126 | } | ||
127 | catch (Exception e) | ||
128 | { | ||
129 | m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR]: Exception thrown on serialization of ChildCreate: {0}", e.Message); | ||
130 | // ignore. buffer will be empty, caller should check. | ||
131 | } | ||
132 | |||
133 | Stream os = null; | ||
134 | try | ||
135 | { // send the Post | ||
136 | AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send | ||
137 | os = AgentCreateRequest.GetRequestStream(); | ||
138 | os.Write(buffer, 0, strBuffer.Length); //Send it | ||
139 | m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Posted CreateAgent request to remote sim {0}, region {1}, x={2} y={3}", | ||
140 | uri, destination.RegionName, destination.RegionLocX, destination.RegionLocY); | ||
141 | } | ||
142 | //catch (WebException ex) | ||
143 | catch | ||
144 | { | ||
145 | //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Bad send on ChildAgentUpdate {0}", ex.Message); | ||
146 | reason = "cannot contact remote region"; | ||
147 | return false; | ||
148 | } | ||
149 | finally | ||
150 | { | ||
151 | if (os != null) | ||
152 | os.Close(); | ||
153 | } | ||
154 | |||
155 | // Let's wait for the response | ||
156 | //m_log.Info("[REMOTE SIMULATION CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall"); | ||
157 | |||
158 | WebResponse webResponse = null; | ||
159 | StreamReader sr = null; | ||
160 | try | ||
161 | { | ||
162 | webResponse = AgentCreateRequest.GetResponse(); | ||
163 | if (webResponse == null) | ||
164 | { | ||
165 | m_log.Info("[REMOTE SIMULATION CONNECTOR]: Null reply on DoCreateChildAgentCall post"); | ||
166 | } | ||
167 | else | ||
168 | { | ||
169 | |||
170 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
171 | string response = sr.ReadToEnd().Trim(); | ||
172 | m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response); | ||
173 | |||
174 | if (!String.IsNullOrEmpty(response)) | ||
175 | { | ||
176 | try | ||
177 | { | ||
178 | // we assume we got an OSDMap back | ||
179 | OSDMap r = Util.GetOSDMap(response); | ||
180 | bool success = r["success"].AsBoolean(); | ||
181 | reason = r["reason"].AsString(); | ||
182 | return success; | ||
183 | } | ||
184 | catch (NullReferenceException e) | ||
185 | { | ||
186 | m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message); | ||
187 | |||
188 | // check for old style response | ||
189 | if (response.ToLower().StartsWith("true")) | ||
190 | return true; | ||
191 | |||
192 | return false; | ||
193 | } | ||
194 | } | ||
195 | } | ||
196 | } | ||
197 | catch (WebException ex) | ||
198 | { | ||
199 | m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); | ||
200 | // ignore, really | ||
201 | } | ||
202 | finally | ||
203 | { | ||
204 | if (sr != null) | ||
205 | sr.Close(); | ||
206 | } | ||
207 | |||
208 | return true; | ||
209 | } | ||
210 | |||
211 | public bool UpdateAgent(GridRegion destination, AgentData data) | ||
212 | { | ||
213 | return UpdateAgent(destination, data); | ||
214 | } | ||
215 | |||
216 | public bool UpdateAgent(GridRegion destination, AgentPosition data) | ||
217 | { | ||
218 | return UpdateAgent(destination, data); | ||
219 | } | ||
220 | |||
221 | private bool UpdateAgent(GridRegion destination, IAgentData cAgentData) | ||
222 | { | ||
223 | // Eventually, we want to use a caps url instead of the agentID | ||
224 | string uri = string.Empty; | ||
225 | try | ||
226 | { | ||
227 | uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + cAgentData.AgentID + "/"; | ||
228 | } | ||
229 | catch (Exception e) | ||
230 | { | ||
231 | m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Unable to resolve external endpoint on agent update. Reason: " + e.Message); | ||
232 | return false; | ||
233 | } | ||
234 | //Console.WriteLine(" >>> DoChildAgentUpdateCall <<< " + uri); | ||
235 | |||
236 | HttpWebRequest ChildUpdateRequest = (HttpWebRequest)WebRequest.Create(uri); | ||
237 | ChildUpdateRequest.Method = "PUT"; | ||
238 | ChildUpdateRequest.ContentType = "application/json"; | ||
239 | ChildUpdateRequest.Timeout = 10000; | ||
240 | //ChildUpdateRequest.KeepAlive = false; | ||
241 | |||
242 | // Fill it in | ||
243 | OSDMap args = null; | ||
244 | try | ||
245 | { | ||
246 | args = cAgentData.Pack(); | ||
247 | } | ||
248 | catch (Exception e) | ||
249 | { | ||
250 | m_log.Debug("[REMOTE SIMULATION CONNECTOR]: PackUpdateMessage failed with exception: " + e.Message); | ||
251 | } | ||
252 | // Add the input arguments | ||
253 | args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); | ||
254 | args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); | ||
255 | args["destination_name"] = OSD.FromString(destination.RegionName); | ||
256 | args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); | ||
257 | |||
258 | string strBuffer = ""; | ||
259 | byte[] buffer = new byte[1]; | ||
260 | try | ||
261 | { | ||
262 | strBuffer = OSDParser.SerializeJsonString(args); | ||
263 | Encoding str = Util.UTF8; | ||
264 | buffer = str.GetBytes(strBuffer); | ||
265 | |||
266 | } | ||
267 | catch (Exception e) | ||
268 | { | ||
269 | m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR]: Exception thrown on serialization of ChildUpdate: {0}", e.Message); | ||
270 | // ignore. buffer will be empty, caller should check. | ||
271 | } | ||
272 | |||
273 | Stream os = null; | ||
274 | try | ||
275 | { // send the Post | ||
276 | ChildUpdateRequest.ContentLength = buffer.Length; //Count bytes to send | ||
277 | os = ChildUpdateRequest.GetRequestStream(); | ||
278 | os.Write(buffer, 0, strBuffer.Length); //Send it | ||
279 | //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Posted ChildAgentUpdate request to remote sim {0}", uri); | ||
280 | } | ||
281 | //catch (WebException ex) | ||
282 | catch | ||
283 | { | ||
284 | //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Bad send on ChildAgentUpdate {0}", ex.Message); | ||
285 | |||
286 | return false; | ||
287 | } | ||
288 | finally | ||
289 | { | ||
290 | if (os != null) | ||
291 | os.Close(); | ||
292 | } | ||
293 | |||
294 | // Let's wait for the response | ||
295 | //m_log.Info("[REMOTE SIMULATION CONNECTOR]: Waiting for a reply after ChildAgentUpdate"); | ||
296 | |||
297 | WebResponse webResponse = null; | ||
298 | StreamReader sr = null; | ||
299 | try | ||
300 | { | ||
301 | webResponse = ChildUpdateRequest.GetResponse(); | ||
302 | if (webResponse == null) | ||
303 | { | ||
304 | m_log.Info("[REMOTE SIMULATION CONNECTOR]: Null reply on ChilAgentUpdate post"); | ||
305 | } | ||
306 | |||
307 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
308 | //reply = sr.ReadToEnd().Trim(); | ||
309 | sr.ReadToEnd().Trim(); | ||
310 | sr.Close(); | ||
311 | //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: ChilAgentUpdate reply was {0} ", reply); | ||
312 | |||
313 | } | ||
314 | catch (WebException ex) | ||
315 | { | ||
316 | m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of ChilAgentUpdate {0}", ex.Message); | ||
317 | // ignore, really | ||
318 | } | ||
319 | finally | ||
320 | { | ||
321 | if (sr != null) | ||
322 | sr.Close(); | ||
323 | } | ||
324 | |||
325 | return true; | ||
326 | } | ||
327 | |||
328 | public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) | ||
329 | { | ||
330 | agent = null; | ||
331 | // Eventually, we want to use a caps url instead of the agentID | ||
332 | string uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + id + "/" + destination.RegionID.ToString() + "/"; | ||
333 | //Console.WriteLine(" >>> DoRetrieveRootAgentCall <<< " + uri); | ||
334 | |||
335 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); | ||
336 | request.Method = "GET"; | ||
337 | request.Timeout = 10000; | ||
338 | //request.Headers.Add("authorization", ""); // coming soon | ||
339 | |||
340 | HttpWebResponse webResponse = null; | ||
341 | string reply = string.Empty; | ||
342 | StreamReader sr = null; | ||
343 | try | ||
344 | { | ||
345 | webResponse = (HttpWebResponse)request.GetResponse(); | ||
346 | if (webResponse == null) | ||
347 | { | ||
348 | m_log.Info("[REMOTE SIMULATION CONNECTOR]: Null reply on agent get "); | ||
349 | } | ||
350 | |||
351 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
352 | reply = sr.ReadToEnd().Trim(); | ||
353 | |||
354 | //Console.WriteLine("[REMOTE SIMULATION CONNECTOR]: ChilAgentUpdate reply was " + reply); | ||
355 | |||
356 | } | ||
357 | catch (WebException ex) | ||
358 | { | ||
359 | m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of agent get {0}", ex.Message); | ||
360 | // ignore, really | ||
361 | return false; | ||
362 | } | ||
363 | finally | ||
364 | { | ||
365 | if (sr != null) | ||
366 | sr.Close(); | ||
367 | } | ||
368 | |||
369 | if (webResponse.StatusCode == HttpStatusCode.OK) | ||
370 | { | ||
371 | // we know it's jason | ||
372 | OSDMap args = Util.GetOSDMap(reply); | ||
373 | if (args == null) | ||
374 | { | ||
375 | //Console.WriteLine("[REMOTE SIMULATION CONNECTOR]: Error getting OSDMap from reply"); | ||
376 | return false; | ||
377 | } | ||
378 | |||
379 | agent = new CompleteAgentData(); | ||
380 | agent.Unpack(args); | ||
381 | return true; | ||
382 | } | ||
383 | |||
384 | //Console.WriteLine("[REMOTE SIMULATION CONNECTOR]: DoRetrieveRootAgentCall returned status " + webResponse.StatusCode); | ||
385 | return false; | ||
386 | } | ||
387 | |||
388 | public bool ReleaseAgent(GridRegion destination, UUID id, string uri) | ||
389 | { | ||
390 | return false; | ||
391 | } | ||
392 | |||
393 | public bool CloseAgent(GridRegion destination, UUID id) | ||
394 | { | ||
395 | return false; | ||
396 | } | ||
397 | |||
398 | #endregion Agents | ||
399 | |||
400 | #region Objects | ||
401 | |||
402 | public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) | ||
403 | { | ||
404 | return false; | ||
405 | } | ||
406 | |||
407 | public bool CreateObject(GridRegion destination, UUID userID, UUID itemID) | ||
408 | { | ||
409 | return false; | ||
410 | } | ||
411 | |||
412 | #endregion Objects | ||
413 | } | ||
414 | } | ||
diff --git a/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs new file mode 100644 index 0000000..076993e --- /dev/null +++ b/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs | |||
@@ -0,0 +1,277 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using log4net; | ||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.IO; | ||
32 | using System.Reflection; | ||
33 | using Nini.Config; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Communications; | ||
36 | using OpenSim.Framework.Servers.HttpServer; | ||
37 | using OpenSim.Server.Base; | ||
38 | using OpenSim.Services.Interfaces; | ||
39 | using OpenMetaverse; | ||
40 | |||
41 | namespace OpenSim.Services.Connectors | ||
42 | { | ||
43 | public class UserAccountServicesConnector : IUserAccountService | ||
44 | { | ||
45 | private static readonly ILog m_log = | ||
46 | LogManager.GetLogger( | ||
47 | MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | private string m_ServerURI = String.Empty; | ||
50 | |||
51 | public UserAccountServicesConnector() | ||
52 | { | ||
53 | } | ||
54 | |||
55 | public UserAccountServicesConnector(string serverURI) | ||
56 | { | ||
57 | m_ServerURI = serverURI.TrimEnd('/'); | ||
58 | } | ||
59 | |||
60 | public UserAccountServicesConnector(IConfigSource source) | ||
61 | { | ||
62 | Initialise(source); | ||
63 | } | ||
64 | |||
65 | public virtual void Initialise(IConfigSource source) | ||
66 | { | ||
67 | IConfig assetConfig = source.Configs["UserAccountService"]; | ||
68 | if (assetConfig == null) | ||
69 | { | ||
70 | m_log.Error("[ACCOUNT CONNECTOR]: UserAccountService missing from OpenSim.ini"); | ||
71 | throw new Exception("User account connector init error"); | ||
72 | } | ||
73 | |||
74 | string serviceURI = assetConfig.GetString("UserAccountServerURI", | ||
75 | String.Empty); | ||
76 | |||
77 | if (serviceURI == String.Empty) | ||
78 | { | ||
79 | m_log.Error("[ACCOUNT CONNECTOR]: No Server URI named in section UserAccountService"); | ||
80 | throw new Exception("User account connector init error"); | ||
81 | } | ||
82 | m_ServerURI = serviceURI; | ||
83 | } | ||
84 | |||
85 | public UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) | ||
86 | { | ||
87 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
88 | //sendData["SCOPEID"] = scopeID.ToString(); | ||
89 | sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
90 | sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
91 | sendData["METHOD"] = "getaccount"; | ||
92 | |||
93 | sendData["ScopeID"] = scopeID; | ||
94 | sendData["FirstName"] = firstName.ToString(); | ||
95 | sendData["LastName"] = lastName.ToString(); | ||
96 | |||
97 | return SendAndGetReply(sendData); | ||
98 | } | ||
99 | |||
100 | public UserAccount GetUserAccount(UUID scopeID, string email) | ||
101 | { | ||
102 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
103 | //sendData["SCOPEID"] = scopeID.ToString(); | ||
104 | sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
105 | sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
106 | sendData["METHOD"] = "getaccount"; | ||
107 | |||
108 | sendData["ScopeID"] = scopeID; | ||
109 | sendData["Email"] = email; | ||
110 | |||
111 | return SendAndGetReply(sendData); | ||
112 | } | ||
113 | |||
114 | public UserAccount GetUserAccount(UUID scopeID, UUID userID) | ||
115 | { | ||
116 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
117 | //sendData["SCOPEID"] = scopeID.ToString(); | ||
118 | sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
119 | sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
120 | sendData["METHOD"] = "getaccount"; | ||
121 | |||
122 | sendData["ScopeID"] = scopeID; | ||
123 | sendData["UserID"] = userID.ToString(); | ||
124 | |||
125 | return SendAndGetReply(sendData); | ||
126 | } | ||
127 | |||
128 | public List<UserAccount> GetUserAccounts(UUID scopeID, string query) | ||
129 | { | ||
130 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
131 | //sendData["SCOPEID"] = scopeID.ToString(); | ||
132 | sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
133 | sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
134 | sendData["METHOD"] = "getagents"; | ||
135 | |||
136 | sendData["ScopeID"] = scopeID.ToString(); | ||
137 | sendData["query"] = query; | ||
138 | |||
139 | string reply = string.Empty; | ||
140 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
141 | // m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString); | ||
142 | try | ||
143 | { | ||
144 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
145 | m_ServerURI + "/accounts", | ||
146 | reqString); | ||
147 | if (reply == null || (reply != null && reply == string.Empty)) | ||
148 | { | ||
149 | m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccounts received null or empty reply"); | ||
150 | return null; | ||
151 | } | ||
152 | } | ||
153 | catch (Exception e) | ||
154 | { | ||
155 | m_log.DebugFormat("[ACCOUNT CONNECTOR]: Exception when contacting accounts server: {0}", e.Message); | ||
156 | } | ||
157 | |||
158 | List<UserAccount> accounts = new List<UserAccount>(); | ||
159 | |||
160 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
161 | |||
162 | if (replyData != null) | ||
163 | { | ||
164 | if (replyData.ContainsKey("result") && replyData.ContainsKey("result").ToString() == "null") | ||
165 | { | ||
166 | return accounts; | ||
167 | } | ||
168 | |||
169 | Dictionary<string, object>.ValueCollection accountList = replyData.Values; | ||
170 | //m_log.DebugFormat("[ACCOUNTS CONNECTOR]: GetAgents returned {0} elements", pinfosList.Count); | ||
171 | foreach (object acc in accountList) | ||
172 | { | ||
173 | if (acc is Dictionary<string, object>) | ||
174 | { | ||
175 | UserAccount pinfo = new UserAccount((Dictionary<string, object>)acc); | ||
176 | accounts.Add(pinfo); | ||
177 | } | ||
178 | else | ||
179 | m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccounts received invalid response type {0}", | ||
180 | acc.GetType()); | ||
181 | } | ||
182 | } | ||
183 | else | ||
184 | m_log.DebugFormat("[ACCOUNTS CONNECTOR]: GetUserAccounts received null response"); | ||
185 | |||
186 | return accounts; | ||
187 | } | ||
188 | |||
189 | public bool StoreUserAccount(UserAccount data) | ||
190 | { | ||
191 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
192 | //sendData["SCOPEID"] = scopeID.ToString(); | ||
193 | sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
194 | sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
195 | sendData["METHOD"] = "setaccount"; | ||
196 | |||
197 | Dictionary<string, object> structData = data.ToKeyValuePairs(); | ||
198 | |||
199 | foreach (KeyValuePair<string,object> kvp in structData) | ||
200 | sendData[kvp.Key] = kvp.Value.ToString(); | ||
201 | |||
202 | return SendAndGetBoolReply(sendData); | ||
203 | } | ||
204 | |||
205 | private UserAccount SendAndGetReply(Dictionary<string, object> sendData) | ||
206 | { | ||
207 | string reply = string.Empty; | ||
208 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
209 | // m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString); | ||
210 | try | ||
211 | { | ||
212 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
213 | m_ServerURI + "/accounts", | ||
214 | reqString); | ||
215 | if (reply == null || (reply != null && reply == string.Empty)) | ||
216 | { | ||
217 | m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccount received null or empty reply"); | ||
218 | return null; | ||
219 | } | ||
220 | } | ||
221 | catch (Exception e) | ||
222 | { | ||
223 | m_log.DebugFormat("[ACCOUNT CONNECTOR]: Exception when contacting user account server: {0}", e.Message); | ||
224 | } | ||
225 | |||
226 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
227 | UserAccount account = null; | ||
228 | |||
229 | if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null)) | ||
230 | { | ||
231 | if (replyData["result"] is Dictionary<string, object>) | ||
232 | { | ||
233 | account = new UserAccount((Dictionary<string, object>)replyData["result"]); | ||
234 | } | ||
235 | } | ||
236 | |||
237 | return account; | ||
238 | |||
239 | } | ||
240 | |||
241 | private bool SendAndGetBoolReply(Dictionary<string, object> sendData) | ||
242 | { | ||
243 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
244 | // m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString); | ||
245 | try | ||
246 | { | ||
247 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
248 | m_ServerURI + "/accounts", | ||
249 | reqString); | ||
250 | if (reply != string.Empty) | ||
251 | { | ||
252 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
253 | |||
254 | if (replyData.ContainsKey("result")) | ||
255 | { | ||
256 | if (replyData["result"].ToString().ToLower() == "success") | ||
257 | return true; | ||
258 | else | ||
259 | return false; | ||
260 | } | ||
261 | else | ||
262 | m_log.DebugFormat("[ACCOUNTS CONNECTOR]: Set or Create UserAccount reply data does not contain result field"); | ||
263 | |||
264 | } | ||
265 | else | ||
266 | m_log.DebugFormat("[ACCOUNTS CONNECTOR]: Set or Create UserAccount received empty reply"); | ||
267 | } | ||
268 | catch (Exception e) | ||
269 | { | ||
270 | m_log.DebugFormat("[ACCOUNTS CONNECTOR]: Exception when contacting user account server: {0}", e.Message); | ||
271 | } | ||
272 | |||
273 | return false; | ||
274 | } | ||
275 | |||
276 | } | ||
277 | } | ||
diff --git a/OpenSim/Services/Interfaces/IAvatarService.cs b/OpenSim/Services/Interfaces/IAvatarService.cs new file mode 100644 index 0000000..ea08ea5 --- /dev/null +++ b/OpenSim/Services/Interfaces/IAvatarService.cs | |||
@@ -0,0 +1,204 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | |||
32 | using OpenSim.Framework; | ||
33 | |||
34 | using OpenMetaverse; | ||
35 | |||
36 | namespace OpenSim.Services.Interfaces | ||
37 | { | ||
38 | public interface IAvatarService | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// Called by the login service | ||
42 | /// </summary> | ||
43 | /// <param name="userID"></param> | ||
44 | /// <returns></returns> | ||
45 | AvatarData GetAvatar(UUID userID); | ||
46 | |||
47 | /// <summary> | ||
48 | /// Called by everyone who can change the avatar data (so, regions) | ||
49 | /// </summary> | ||
50 | /// <param name="userID"></param> | ||
51 | /// <param name="avatar"></param> | ||
52 | /// <returns></returns> | ||
53 | bool SetAvatar(UUID userID, AvatarData avatar); | ||
54 | |||
55 | /// <summary> | ||
56 | /// Not sure if it's needed | ||
57 | /// </summary> | ||
58 | /// <param name="userID"></param> | ||
59 | /// <returns></returns> | ||
60 | bool ResetAvatar(UUID userID); | ||
61 | |||
62 | /// <summary> | ||
63 | /// These methods raison d'etre: | ||
64 | /// No need to send the entire avatar data (SetAvatar) for changing attachments | ||
65 | /// </summary> | ||
66 | /// <param name="userID"></param> | ||
67 | /// <param name="attach"></param> | ||
68 | /// <returns></returns> | ||
69 | bool SetItems(UUID userID, string[] names, string[] values); | ||
70 | bool RemoveItems(UUID userID, string[] names); | ||
71 | } | ||
72 | |||
73 | /// <summary> | ||
74 | /// Each region/client that uses avatars will have a data structure | ||
75 | /// of this type representing the avatars. | ||
76 | /// </summary> | ||
77 | public class AvatarData | ||
78 | { | ||
79 | // This pretty much determines which name/value pairs will be | ||
80 | // present below. The name/value pair describe a part of | ||
81 | // the avatar. For SL avatars, these would be "shape", "texture1", | ||
82 | // etc. For other avatars, they might be "mesh", "skin", etc. | ||
83 | // The value portion is a URL that is expected to resolve to an | ||
84 | // asset of the type required by the handler for that field. | ||
85 | // It is required that regions can access these URLs. Allowing | ||
86 | // direct access by a viewer is not required, and, if provided, | ||
87 | // may be read-only. A "naked" UUID can be used to refer to an | ||
88 | // asset int he current region's asset service, which is not | ||
89 | // portable, but allows legacy appearance to continue to | ||
90 | // function. Closed, LL-based grids will never need URLs here. | ||
91 | |||
92 | public int AvatarType; | ||
93 | public Dictionary<string,string> Data; | ||
94 | |||
95 | public AvatarData() | ||
96 | { | ||
97 | } | ||
98 | |||
99 | public AvatarData(Dictionary<string, object> kvp) | ||
100 | { | ||
101 | Data = new Dictionary<string, string>(); | ||
102 | |||
103 | if (kvp.ContainsKey("AvatarType")) | ||
104 | Int32.TryParse(kvp["AvatarType"].ToString(), out AvatarType); | ||
105 | |||
106 | foreach (KeyValuePair<string, object> _kvp in kvp) | ||
107 | { | ||
108 | if (_kvp.Value != null) | ||
109 | Data[_kvp.Key] = _kvp.Value.ToString(); | ||
110 | } | ||
111 | } | ||
112 | |||
113 | /// <summary> | ||
114 | /// </summary> | ||
115 | /// <returns></returns> | ||
116 | public Dictionary<string, object> ToKeyValuePairs() | ||
117 | { | ||
118 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
119 | |||
120 | result["AvatarType"] = AvatarType.ToString(); | ||
121 | foreach (KeyValuePair<string, string> _kvp in Data) | ||
122 | { | ||
123 | if (_kvp.Value != null) | ||
124 | result[_kvp.Key] = _kvp.Value; | ||
125 | } | ||
126 | return null; | ||
127 | } | ||
128 | |||
129 | public AvatarData(AvatarAppearance appearance) | ||
130 | { | ||
131 | AvatarType = 1; // SL avatars | ||
132 | Data = new Dictionary<string, string>(); | ||
133 | |||
134 | // Wearables | ||
135 | Data["AvatarHeight"] = appearance.AvatarHeight.ToString(); | ||
136 | Data["BodyItem"] = appearance.BodyItem.ToString(); | ||
137 | Data["EyesItem"] = appearance.EyesItem.ToString(); | ||
138 | Data["GlovesItem"] = appearance.GlovesItem.ToString(); | ||
139 | Data["HairItem"] = appearance.HairItem.ToString(); | ||
140 | //Data["HipOffset"] = appearance.HipOffset.ToString(); | ||
141 | Data["JacketItem"] = appearance.JacketItem.ToString(); | ||
142 | Data["Owner"] = appearance.Owner.ToString(); | ||
143 | Data["PantsItem"] = appearance.PantsItem.ToString(); | ||
144 | Data["Serial"] = appearance.Serial.ToString(); | ||
145 | Data["ShirtItem"] = appearance.ShirtItem.ToString(); | ||
146 | Data["ShoesItem"] = appearance.ShoesItem.ToString(); | ||
147 | Data["SkinItem"] = appearance.SkinItem.ToString(); | ||
148 | Data["SkirtItem"] = appearance.SkirtItem.ToString(); | ||
149 | Data["SocksItem"] = appearance.SocksItem.ToString(); | ||
150 | Data["UnderPantsItem"] = appearance.UnderPantsItem.ToString(); | ||
151 | Data["UnderShirtItem"] = appearance.UnderShirtItem.ToString(); | ||
152 | |||
153 | // Attachments | ||
154 | Hashtable attachs = appearance.GetAttachments(); | ||
155 | foreach (KeyValuePair<int, Hashtable> kvp in attachs) | ||
156 | { | ||
157 | Data["_ap_" + kvp.Key] = kvp.Value["item"].ToString(); | ||
158 | } | ||
159 | } | ||
160 | |||
161 | public AvatarAppearance ToAvatarAppearance() | ||
162 | { | ||
163 | AvatarAppearance appearance = new AvatarAppearance(); | ||
164 | // Wearables | ||
165 | appearance.AvatarHeight = float.Parse(Data["AvatarHeight"]); | ||
166 | appearance.BodyItem = UUID.Parse(Data["BodyItem"]); | ||
167 | appearance.EyesItem = UUID.Parse(Data["EyesItem"]); | ||
168 | appearance.GlovesItem = UUID.Parse(Data["GlovesItem"]); | ||
169 | appearance.HairItem = UUID.Parse(Data["HairItem"]); | ||
170 | //appearance.HipOffset = float.Parse(Data["HipOffset"]); | ||
171 | appearance.JacketItem = UUID.Parse(Data["JacketItem"]); | ||
172 | appearance.Owner = UUID.Parse(Data["Owner"]); | ||
173 | appearance.PantsItem = UUID.Parse(Data["PantsItem"]); | ||
174 | appearance.Serial = Int32.Parse(Data["Serial"]); | ||
175 | appearance.ShirtItem = UUID.Parse(Data["ShirtItem"]); | ||
176 | appearance.ShoesItem = UUID.Parse(Data["ShoesItem"]); | ||
177 | appearance.SkinItem = UUID.Parse(Data["SkinItem"]); | ||
178 | appearance.SkirtItem = UUID.Parse(Data["SkirtItem"]); | ||
179 | appearance.SocksItem = UUID.Parse(Data["SocksItem"]); | ||
180 | appearance.UnderPantsItem = UUID.Parse(Data["UnderPantsItem"]); | ||
181 | appearance.UnderShirtItem = UUID.Parse(Data["UnderShirtItem"]); | ||
182 | |||
183 | // Attachments | ||
184 | Dictionary<string, string> attchs = new Dictionary<string, string>(); | ||
185 | foreach (KeyValuePair<string, string> _kvp in Data) | ||
186 | if (_kvp.Key.StartsWith("_ap_")) | ||
187 | attchs[_kvp.Key] = _kvp.Value; | ||
188 | Hashtable aaAttachs = new Hashtable(); | ||
189 | foreach (KeyValuePair<string, string> _kvp in attchs) | ||
190 | { | ||
191 | string pointStr = _kvp.Key.Substring(4); | ||
192 | int point = 0; | ||
193 | if (!Int32.TryParse(pointStr, out point)) | ||
194 | continue; | ||
195 | Hashtable tmp = new Hashtable(); | ||
196 | tmp["item"] = _kvp.Value; | ||
197 | tmp["asset"] = UUID.Zero.ToString(); | ||
198 | aaAttachs[point] = tmp; | ||
199 | } | ||
200 | |||
201 | return appearance; | ||
202 | } | ||
203 | } | ||
204 | } | ||
diff --git a/OpenSim/Services/Interfaces/ILibraryService.cs b/OpenSim/Services/Interfaces/ILibraryService.cs new file mode 100644 index 0000000..861cf0e --- /dev/null +++ b/OpenSim/Services/Interfaces/ILibraryService.cs | |||
@@ -0,0 +1,43 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | |||
31 | using OpenSim.Framework; | ||
32 | using OpenMetaverse; | ||
33 | |||
34 | namespace OpenSim.Services.Interfaces | ||
35 | { | ||
36 | public interface ILibraryService | ||
37 | { | ||
38 | InventoryFolderImpl LibraryRootFolder { get; } | ||
39 | |||
40 | Dictionary<UUID, InventoryFolderImpl> GetAllFolders(); | ||
41 | } | ||
42 | |||
43 | } | ||
diff --git a/OpenSim/Services/Interfaces/ILoginService.cs b/OpenSim/Services/Interfaces/ILoginService.cs new file mode 100644 index 0000000..24bf342 --- /dev/null +++ b/OpenSim/Services/Interfaces/ILoginService.cs | |||
@@ -0,0 +1,53 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | |||
33 | using OpenMetaverse.StructuredData; | ||
34 | |||
35 | namespace OpenSim.Services.Interfaces | ||
36 | { | ||
37 | public abstract class LoginResponse | ||
38 | { | ||
39 | public abstract Hashtable ToHashtable(); | ||
40 | public abstract OSD ToOSDMap(); | ||
41 | } | ||
42 | |||
43 | public abstract class FailedLoginResponse : LoginResponse | ||
44 | { | ||
45 | } | ||
46 | |||
47 | public interface ILoginService | ||
48 | { | ||
49 | LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, IPEndPoint clientIP); | ||
50 | } | ||
51 | |||
52 | |||
53 | } | ||
diff --git a/OpenSim/Services/Interfaces/IPresenceService.cs b/OpenSim/Services/Interfaces/IPresenceService.cs index aa1c5bf..2dad7e6 100644 --- a/OpenSim/Services/Interfaces/IPresenceService.cs +++ b/OpenSim/Services/Interfaces/IPresenceService.cs | |||
@@ -25,6 +25,7 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | ||
28 | using OpenSim.Framework; | 29 | using OpenSim.Framework; |
29 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
30 | using OpenMetaverse; | 31 | using OpenMetaverse; |
@@ -33,13 +34,74 @@ namespace OpenSim.Services.Interfaces | |||
33 | { | 34 | { |
34 | public class PresenceInfo | 35 | public class PresenceInfo |
35 | { | 36 | { |
36 | public UUID PrincipalID; | 37 | public string UserID; |
37 | public UUID RegionID; | 38 | public UUID RegionID; |
38 | public Dictionary<string, string> Data; | 39 | public bool Online; |
40 | public DateTime Login; | ||
41 | public DateTime Logout; | ||
42 | public Vector3 Position; | ||
43 | public Vector3 LookAt; | ||
44 | public UUID HomeRegionID; | ||
45 | public Vector3 HomePosition; | ||
46 | public Vector3 HomeLookAt; | ||
47 | |||
48 | public PresenceInfo() | ||
49 | { | ||
50 | } | ||
51 | |||
52 | public PresenceInfo(Dictionary<string, object> kvp) | ||
53 | { | ||
54 | if (kvp.ContainsKey("UserID")) | ||
55 | UserID = kvp["UserID"].ToString(); | ||
56 | if (kvp.ContainsKey("RegionID")) | ||
57 | UUID.TryParse(kvp["RegionID"].ToString(), out RegionID); | ||
58 | if (kvp.ContainsKey("login")) | ||
59 | DateTime.TryParse(kvp["login"].ToString(), out Login); | ||
60 | if (kvp.ContainsKey("logout")) | ||
61 | DateTime.TryParse(kvp["logout"].ToString(), out Logout); | ||
62 | if (kvp.ContainsKey("lookAt")) | ||
63 | Vector3.TryParse(kvp["lookAt"].ToString(), out LookAt); | ||
64 | if (kvp.ContainsKey("online")) | ||
65 | Boolean.TryParse(kvp["online"].ToString(), out Online); | ||
66 | if (kvp.ContainsKey("position")) | ||
67 | Vector3.TryParse(kvp["position"].ToString(), out Position); | ||
68 | if (kvp.ContainsKey("HomeRegionID")) | ||
69 | UUID.TryParse(kvp["HomeRegionID"].ToString(), out HomeRegionID); | ||
70 | if (kvp.ContainsKey("HomePosition")) | ||
71 | Vector3.TryParse(kvp["HomePosition"].ToString(), out HomePosition); | ||
72 | if (kvp.ContainsKey("HomeLookAt")) | ||
73 | Vector3.TryParse(kvp["HomeLookAt"].ToString(), out HomeLookAt); | ||
74 | |||
75 | } | ||
76 | |||
77 | public Dictionary<string, object> ToKeyValuePairs() | ||
78 | { | ||
79 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
80 | result["UserID"] = UserID; | ||
81 | result["RegionID"] = RegionID.ToString(); | ||
82 | result["online"] = Online.ToString(); | ||
83 | result["login"] = Login.ToString(); | ||
84 | result["logout"] = Logout.ToString(); | ||
85 | result["position"] = Position.ToString(); | ||
86 | result["lookAt"] = LookAt.ToString(); | ||
87 | result["HomeRegionID"] = HomeRegionID.ToString(); | ||
88 | result["HomePosition"] = HomePosition.ToString(); | ||
89 | result["HomeLookAt"] = HomeLookAt.ToString(); | ||
90 | |||
91 | return result; | ||
92 | } | ||
39 | } | 93 | } |
40 | 94 | ||
41 | public interface IPresenceService | 95 | public interface IPresenceService |
42 | { | 96 | { |
43 | bool Report(PresenceInfo presence); | 97 | bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID); |
98 | bool LogoutAgent(UUID sessionID); | ||
99 | bool LogoutRegionAgents(UUID regionID); | ||
100 | |||
101 | bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt); | ||
102 | bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt); | ||
103 | |||
104 | PresenceInfo GetAgent(UUID sessionID); | ||
105 | PresenceInfo[] GetAgents(string[] userIDs); | ||
44 | } | 106 | } |
45 | } | 107 | } |
diff --git a/OpenSim/Services/Interfaces/ISimulationService.cs b/OpenSim/Services/Interfaces/ISimulationService.cs index a169ab7..14f462c 100644 --- a/OpenSim/Services/Interfaces/ISimulationService.cs +++ b/OpenSim/Services/Interfaces/ISimulationService.cs | |||
@@ -29,13 +29,17 @@ using System; | |||
29 | using OpenSim.Framework; | 29 | using OpenSim.Framework; |
30 | using OpenMetaverse; | 30 | using OpenMetaverse; |
31 | 31 | ||
32 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
33 | |||
32 | namespace OpenSim.Services.Interfaces | 34 | namespace OpenSim.Services.Interfaces |
33 | { | 35 | { |
34 | public interface ISimulationService | 36 | public interface ISimulationService |
35 | { | 37 | { |
38 | IScene GetScene(ulong regionHandle); | ||
39 | |||
36 | #region Agents | 40 | #region Agents |
37 | 41 | ||
38 | bool CreateAgent(ulong regionHandle, AgentCircuitData aCircuit, out string reason); | 42 | bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason); |
39 | 43 | ||
40 | /// <summary> | 44 | /// <summary> |
41 | /// Full child agent update. | 45 | /// Full child agent update. |
@@ -43,7 +47,7 @@ namespace OpenSim.Services.Interfaces | |||
43 | /// <param name="regionHandle"></param> | 47 | /// <param name="regionHandle"></param> |
44 | /// <param name="data"></param> | 48 | /// <param name="data"></param> |
45 | /// <returns></returns> | 49 | /// <returns></returns> |
46 | bool UpdateAgent(ulong regionHandle, AgentData data); | 50 | bool UpdateAgent(GridRegion destination, AgentData data); |
47 | 51 | ||
48 | /// <summary> | 52 | /// <summary> |
49 | /// Short child agent update, mostly for position. | 53 | /// Short child agent update, mostly for position. |
@@ -51,9 +55,9 @@ namespace OpenSim.Services.Interfaces | |||
51 | /// <param name="regionHandle"></param> | 55 | /// <param name="regionHandle"></param> |
52 | /// <param name="data"></param> | 56 | /// <param name="data"></param> |
53 | /// <returns></returns> | 57 | /// <returns></returns> |
54 | bool UpdateAgent(ulong regionHandle, AgentPosition data); | 58 | bool UpdateAgent(GridRegion destination, AgentPosition data); |
55 | 59 | ||
56 | bool RetrieveAgent(ulong regionHandle, UUID id, out IAgentData agent); | 60 | bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent); |
57 | 61 | ||
58 | /// <summary> | 62 | /// <summary> |
59 | /// Message from receiving region to departing region, telling it got contacted by the client. | 63 | /// Message from receiving region to departing region, telling it got contacted by the client. |
@@ -63,7 +67,7 @@ namespace OpenSim.Services.Interfaces | |||
63 | /// <param name="id"></param> | 67 | /// <param name="id"></param> |
64 | /// <param name="uri"></param> | 68 | /// <param name="uri"></param> |
65 | /// <returns></returns> | 69 | /// <returns></returns> |
66 | bool ReleaseAgent(ulong regionHandle, UUID id, string uri); | 70 | bool ReleaseAgent(GridRegion destination, UUID id, string uri); |
67 | 71 | ||
68 | /// <summary> | 72 | /// <summary> |
69 | /// Close agent. | 73 | /// Close agent. |
@@ -71,7 +75,7 @@ namespace OpenSim.Services.Interfaces | |||
71 | /// <param name="regionHandle"></param> | 75 | /// <param name="regionHandle"></param> |
72 | /// <param name="id"></param> | 76 | /// <param name="id"></param> |
73 | /// <returns></returns> | 77 | /// <returns></returns> |
74 | bool CloseAgent(ulong regionHandle, UUID id); | 78 | bool CloseAgent(GridRegion destination, UUID id); |
75 | 79 | ||
76 | #endregion Agents | 80 | #endregion Agents |
77 | 81 | ||
@@ -84,7 +88,7 @@ namespace OpenSim.Services.Interfaces | |||
84 | /// <param name="sog"></param> | 88 | /// <param name="sog"></param> |
85 | /// <param name="isLocalCall"></param> | 89 | /// <param name="isLocalCall"></param> |
86 | /// <returns></returns> | 90 | /// <returns></returns> |
87 | bool CreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall); | 91 | bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall); |
88 | 92 | ||
89 | /// <summary> | 93 | /// <summary> |
90 | /// Create an object from the user's inventory in the destination region. | 94 | /// Create an object from the user's inventory in the destination region. |
@@ -94,15 +98,9 @@ namespace OpenSim.Services.Interfaces | |||
94 | /// <param name="userID"></param> | 98 | /// <param name="userID"></param> |
95 | /// <param name="itemID"></param> | 99 | /// <param name="itemID"></param> |
96 | /// <returns></returns> | 100 | /// <returns></returns> |
97 | bool CreateObject(ulong regionHandle, UUID userID, UUID itemID); | 101 | bool CreateObject(GridRegion destination, UUID userID, UUID itemID); |
98 | 102 | ||
99 | #endregion Objects | 103 | #endregion Objects |
100 | 104 | ||
101 | #region Regions | ||
102 | |||
103 | bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion); | ||
104 | |||
105 | #endregion Regions | ||
106 | |||
107 | } | 105 | } |
108 | } | 106 | } |
diff --git a/OpenSim/Services/Interfaces/IUserAccountService.cs b/OpenSim/Services/Interfaces/IUserAccountService.cs new file mode 100644 index 0000000..87f0e6c --- /dev/null +++ b/OpenSim/Services/Interfaces/IUserAccountService.cs | |||
@@ -0,0 +1,123 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenMetaverse; | ||
31 | |||
32 | namespace OpenSim.Services.Interfaces | ||
33 | { | ||
34 | public class UserAccount | ||
35 | { | ||
36 | public UserAccount() | ||
37 | { | ||
38 | } | ||
39 | |||
40 | public UserAccount(UUID principalID) | ||
41 | { | ||
42 | PrincipalID = principalID; | ||
43 | } | ||
44 | |||
45 | public string FirstName; | ||
46 | public string LastName; | ||
47 | public string Email; | ||
48 | public UUID PrincipalID; | ||
49 | public UUID ScopeID; | ||
50 | |||
51 | public Dictionary<string, object> ServiceURLs; | ||
52 | |||
53 | public int Created; | ||
54 | |||
55 | public UserAccount(Dictionary<string, object> kvp) | ||
56 | { | ||
57 | if (kvp.ContainsKey("FirstName")) | ||
58 | FirstName = kvp["FirstName"].ToString(); | ||
59 | if (kvp.ContainsKey("LastName")) | ||
60 | LastName = kvp["LastName"].ToString(); | ||
61 | if (kvp.ContainsKey("Email")) | ||
62 | Email = kvp["Email"].ToString(); | ||
63 | if (kvp.ContainsKey("PrincipalID")) | ||
64 | UUID.TryParse(kvp["PrincipalID"].ToString(), out PrincipalID); | ||
65 | if (kvp.ContainsKey("ScopeID")) | ||
66 | UUID.TryParse(kvp["ScopeID"].ToString(), out ScopeID); | ||
67 | if (kvp.ContainsKey("Created")) | ||
68 | Convert.ToInt32(kvp["Created"].ToString()); | ||
69 | if (kvp.ContainsKey("ServiceURLs") && kvp["ServiceURLs"] != null) | ||
70 | { | ||
71 | ServiceURLs = new Dictionary<string, object>(); | ||
72 | string str = kvp["ServiceURLs"].ToString(); | ||
73 | if (str != string.Empty) | ||
74 | { | ||
75 | string[] parts = str.Split(new char[] { '#' }); | ||
76 | Dictionary<string, object> dic = new Dictionary<string, object>(); | ||
77 | foreach (string s in parts) | ||
78 | { | ||
79 | string[] parts2 = s.Split(new char[] { '=' }); | ||
80 | if (parts2.Length == 2) | ||
81 | ServiceURLs[parts2[0]] = parts2[1]; | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | } | ||
86 | |||
87 | public Dictionary<string, object> ToKeyValuePairs() | ||
88 | { | ||
89 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
90 | result["FirstName"] = FirstName; | ||
91 | result["LastName"] = LastName; | ||
92 | result["Email"] = Email; | ||
93 | result["PrincipalID"] = PrincipalID.ToString(); | ||
94 | result["ScopeID"] = ScopeID.ToString(); | ||
95 | result["Created"] = Created.ToString(); | ||
96 | string str = string.Empty; | ||
97 | foreach (KeyValuePair<string, object> kvp in ServiceURLs) | ||
98 | { | ||
99 | str += kvp.Key + "=" + kvp.Value + "#"; | ||
100 | } | ||
101 | result["ServiceURLs"] = str; | ||
102 | |||
103 | return result; | ||
104 | } | ||
105 | |||
106 | }; | ||
107 | |||
108 | public interface IUserAccountService | ||
109 | { | ||
110 | UserAccount GetUserAccount(UUID scopeID, UUID userID); | ||
111 | UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName); | ||
112 | UserAccount GetUserAccount(UUID scopeID, string Email); | ||
113 | // Returns the list of avatars that matches both the search | ||
114 | // criterion and the scope ID passed | ||
115 | // | ||
116 | List<UserAccount> GetUserAccounts(UUID scopeID, string query); | ||
117 | |||
118 | // Store the data given, wich replaces the sotred data, therefore | ||
119 | // must be complete. | ||
120 | // | ||
121 | bool StoreUserAccount(UserAccount data); | ||
122 | } | ||
123 | } | ||
diff --git a/OpenSim/Services/Interfaces/IUserService.cs b/OpenSim/Services/Interfaces/IUserService.cs deleted file mode 100644 index 92bd8ef..0000000 --- a/OpenSim/Services/Interfaces/IUserService.cs +++ /dev/null | |||
@@ -1,103 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System.Collections.Generic; | ||
29 | using OpenMetaverse; | ||
30 | |||
31 | namespace OpenSim.Services.Interfaces | ||
32 | { | ||
33 | public class UserAccount | ||
34 | { | ||
35 | public UserAccount() | ||
36 | { | ||
37 | } | ||
38 | |||
39 | public UserAccount(UUID userID, UUID homeRegionID, float homePositionX, | ||
40 | float homePositionY, float homePositionZ, float homeLookAtX, | ||
41 | float homeLookAtY, float homeLookAtZ) | ||
42 | { | ||
43 | UserID = userID; | ||
44 | HomeRegionID = homeRegionID; | ||
45 | HomePositionX = homePositionX; | ||
46 | HomePositionY = homePositionY; | ||
47 | HomePositionZ = homePositionZ; | ||
48 | HomeLookAtX = homeLookAtX; | ||
49 | HomeLookAtY = homeLookAtY; | ||
50 | HomeLookAtZ = homeLookAtZ; | ||
51 | } | ||
52 | |||
53 | public string FirstName; | ||
54 | public string LastName; | ||
55 | public UUID UserID; | ||
56 | public UUID ScopeID; | ||
57 | |||
58 | // For informational purposes only! | ||
59 | // | ||
60 | public string HomeRegionName; | ||
61 | |||
62 | public UUID HomeRegionID; | ||
63 | public float HomePositionX; | ||
64 | public float HomePositionY; | ||
65 | public float HomePositionZ; | ||
66 | public float HomeLookAtX; | ||
67 | public float HomeLookAtY; | ||
68 | public float HomeLookAtZ; | ||
69 | |||
70 | // These are here because they | ||
71 | // concern the account rather than | ||
72 | // the profile. They just happen to | ||
73 | // be used in the Linden profile as well | ||
74 | // | ||
75 | public int GodLevel; | ||
76 | public int UserFlags; | ||
77 | public string AccountType; | ||
78 | |||
79 | }; | ||
80 | |||
81 | public interface IUserAccountService | ||
82 | { | ||
83 | UserAccount GetUserAccount(UUID scopeID, UUID userID); | ||
84 | UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName); | ||
85 | // Returns the list of avatars that matches both the search | ||
86 | // criterion and the scope ID passed | ||
87 | // | ||
88 | List<UserAccount> GetUserAccount(UUID scopeID, string query); | ||
89 | |||
90 | |||
91 | // This will set only the home region portion of the data! | ||
92 | // Can't be used to set god level, flags, type or change the name! | ||
93 | // | ||
94 | bool SetHomePosition(UserAccount data, UUID RegionID, UUID RegionSecret); | ||
95 | |||
96 | // Update all updatable fields | ||
97 | // | ||
98 | bool SetUserAccount(UserAccount data, UUID PrincipalID, string token); | ||
99 | |||
100 | // Creates a user data record | ||
101 | bool CreateUserAccount(UserAccount data, UUID PrincipalID, string token); | ||
102 | } | ||
103 | } | ||
diff --git a/OpenSim/Services/InventoryService/LibraryService.cs b/OpenSim/Services/InventoryService/LibraryService.cs new file mode 100644 index 0000000..383f311 --- /dev/null +++ b/OpenSim/Services/InventoryService/LibraryService.cs | |||
@@ -0,0 +1,283 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using System.Xml; | ||
33 | |||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Services.Base; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | |||
38 | using log4net; | ||
39 | using Nini.Config; | ||
40 | using OpenMetaverse; | ||
41 | |||
42 | namespace OpenSim.Services.InventoryService | ||
43 | { | ||
44 | /// <summary> | ||
45 | /// Basically a hack to give us a Inventory library while we don't have a inventory server | ||
46 | /// once the server is fully implemented then should read the data from that | ||
47 | /// </summary> | ||
48 | public class LibraryService : ServiceBase, ILibraryService | ||
49 | { | ||
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | |||
52 | private InventoryFolderImpl m_LibraryRootFolder; | ||
53 | |||
54 | public InventoryFolderImpl LibraryRootFolder | ||
55 | { | ||
56 | get { return m_LibraryRootFolder; } | ||
57 | } | ||
58 | |||
59 | private UUID libOwner = new UUID("11111111-1111-0000-0000-000100bba000"); | ||
60 | |||
61 | /// <summary> | ||
62 | /// Holds the root library folder and all its descendents. This is really only used during inventory | ||
63 | /// setup so that we don't have to repeatedly search the tree of library folders. | ||
64 | /// </summary> | ||
65 | protected Dictionary<UUID, InventoryFolderImpl> libraryFolders | ||
66 | = new Dictionary<UUID, InventoryFolderImpl>(); | ||
67 | |||
68 | public LibraryService(IConfigSource config) | ||
69 | : base(config) | ||
70 | { | ||
71 | string pLibrariesLocation = Path.Combine("inventory", "Libraries.xml"); | ||
72 | string pLibName = "OpenSim Library"; | ||
73 | |||
74 | IConfig libConfig = config.Configs["LibraryService"]; | ||
75 | if (libConfig != null) | ||
76 | { | ||
77 | pLibrariesLocation = libConfig.GetString("DefaultLibrary", pLibrariesLocation); | ||
78 | pLibName = libConfig.GetString("LibraryName", pLibName); | ||
79 | } | ||
80 | |||
81 | m_log.Debug("[LIBRARY]: Starting library service..."); | ||
82 | |||
83 | m_LibraryRootFolder = new InventoryFolderImpl(); | ||
84 | m_LibraryRootFolder.Owner = libOwner; | ||
85 | m_LibraryRootFolder.ID = new UUID("00000112-000f-0000-0000-000100bba000"); | ||
86 | m_LibraryRootFolder.Name = pLibName; | ||
87 | m_LibraryRootFolder.ParentID = UUID.Zero; | ||
88 | m_LibraryRootFolder.Type = (short)8; | ||
89 | m_LibraryRootFolder.Version = (ushort)1; | ||
90 | |||
91 | libraryFolders.Add(m_LibraryRootFolder.ID, m_LibraryRootFolder); | ||
92 | |||
93 | LoadLibraries(pLibrariesLocation); | ||
94 | } | ||
95 | |||
96 | public InventoryItemBase CreateItem(UUID inventoryID, UUID assetID, string name, string description, | ||
97 | int assetType, int invType, UUID parentFolderID) | ||
98 | { | ||
99 | InventoryItemBase item = new InventoryItemBase(); | ||
100 | item.Owner = libOwner; | ||
101 | item.CreatorId = libOwner.ToString(); | ||
102 | item.ID = inventoryID; | ||
103 | item.AssetID = assetID; | ||
104 | item.Description = description; | ||
105 | item.Name = name; | ||
106 | item.AssetType = assetType; | ||
107 | item.InvType = invType; | ||
108 | item.Folder = parentFolderID; | ||
109 | item.BasePermissions = 0x7FFFFFFF; | ||
110 | item.EveryOnePermissions = 0x7FFFFFFF; | ||
111 | item.CurrentPermissions = 0x7FFFFFFF; | ||
112 | item.NextPermissions = 0x7FFFFFFF; | ||
113 | return item; | ||
114 | } | ||
115 | |||
116 | /// <summary> | ||
117 | /// Use the asset set information at path to load assets | ||
118 | /// </summary> | ||
119 | /// <param name="path"></param> | ||
120 | /// <param name="assets"></param> | ||
121 | protected void LoadLibraries(string librariesControlPath) | ||
122 | { | ||
123 | m_log.InfoFormat("[LIBRARY INVENTORY]: Loading library control file {0}", librariesControlPath); | ||
124 | LoadFromFile(librariesControlPath, "Libraries control", ReadLibraryFromConfig); | ||
125 | } | ||
126 | |||
127 | /// <summary> | ||
128 | /// Read a library set from config | ||
129 | /// </summary> | ||
130 | /// <param name="config"></param> | ||
131 | protected void ReadLibraryFromConfig(IConfig config, string path) | ||
132 | { | ||
133 | string basePath = Path.GetDirectoryName(path); | ||
134 | string foldersPath | ||
135 | = Path.Combine( | ||
136 | basePath, config.GetString("foldersFile", String.Empty)); | ||
137 | |||
138 | LoadFromFile(foldersPath, "Library folders", ReadFolderFromConfig); | ||
139 | |||
140 | string itemsPath | ||
141 | = Path.Combine( | ||
142 | basePath, config.GetString("itemsFile", String.Empty)); | ||
143 | |||
144 | LoadFromFile(itemsPath, "Library items", ReadItemFromConfig); | ||
145 | } | ||
146 | |||
147 | /// <summary> | ||
148 | /// Read a library inventory folder from a loaded configuration | ||
149 | /// </summary> | ||
150 | /// <param name="source"></param> | ||
151 | private void ReadFolderFromConfig(IConfig config, string path) | ||
152 | { | ||
153 | InventoryFolderImpl folderInfo = new InventoryFolderImpl(); | ||
154 | |||
155 | folderInfo.ID = new UUID(config.GetString("folderID", m_LibraryRootFolder.ID.ToString())); | ||
156 | folderInfo.Name = config.GetString("name", "unknown"); | ||
157 | folderInfo.ParentID = new UUID(config.GetString("parentFolderID", m_LibraryRootFolder.ID.ToString())); | ||
158 | folderInfo.Type = (short)config.GetInt("type", 8); | ||
159 | |||
160 | folderInfo.Owner = libOwner; | ||
161 | folderInfo.Version = 1; | ||
162 | |||
163 | if (libraryFolders.ContainsKey(folderInfo.ParentID)) | ||
164 | { | ||
165 | InventoryFolderImpl parentFolder = libraryFolders[folderInfo.ParentID]; | ||
166 | |||
167 | libraryFolders.Add(folderInfo.ID, folderInfo); | ||
168 | parentFolder.AddChildFolder(folderInfo); | ||
169 | |||
170 | // m_log.InfoFormat("[LIBRARY INVENTORY]: Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID); | ||
171 | } | ||
172 | else | ||
173 | { | ||
174 | m_log.WarnFormat( | ||
175 | "[LIBRARY INVENTORY]: Couldn't add folder {0} ({1}) since parent folder with ID {2} does not exist!", | ||
176 | folderInfo.Name, folderInfo.ID, folderInfo.ParentID); | ||
177 | } | ||
178 | } | ||
179 | |||
180 | /// <summary> | ||
181 | /// Read a library inventory item metadata from a loaded configuration | ||
182 | /// </summary> | ||
183 | /// <param name="source"></param> | ||
184 | private void ReadItemFromConfig(IConfig config, string path) | ||
185 | { | ||
186 | InventoryItemBase item = new InventoryItemBase(); | ||
187 | item.Owner = libOwner; | ||
188 | item.CreatorId = libOwner.ToString(); | ||
189 | item.ID = new UUID(config.GetString("inventoryID", m_LibraryRootFolder.ID.ToString())); | ||
190 | item.AssetID = new UUID(config.GetString("assetID", item.ID.ToString())); | ||
191 | item.Folder = new UUID(config.GetString("folderID", m_LibraryRootFolder.ID.ToString())); | ||
192 | item.Name = config.GetString("name", String.Empty); | ||
193 | item.Description = config.GetString("description", item.Name); | ||
194 | item.InvType = config.GetInt("inventoryType", 0); | ||
195 | item.AssetType = config.GetInt("assetType", item.InvType); | ||
196 | item.CurrentPermissions = (uint)config.GetLong("currentPermissions", 0x7FFFFFFF); | ||
197 | item.NextPermissions = (uint)config.GetLong("nextPermissions", 0x7FFFFFFF); | ||
198 | item.EveryOnePermissions = (uint)config.GetLong("everyonePermissions", 0x7FFFFFFF); | ||
199 | item.BasePermissions = (uint)config.GetLong("basePermissions", 0x7FFFFFFF); | ||
200 | item.Flags = (uint)config.GetInt("flags", 0); | ||
201 | |||
202 | if (libraryFolders.ContainsKey(item.Folder)) | ||
203 | { | ||
204 | InventoryFolderImpl parentFolder = libraryFolders[item.Folder]; | ||
205 | try | ||
206 | { | ||
207 | parentFolder.Items.Add(item.ID, item); | ||
208 | } | ||
209 | catch (Exception) | ||
210 | { | ||
211 | m_log.WarnFormat("[LIBRARY INVENTORY] Item {1} [{0}] not added, duplicate item", item.ID, item.Name); | ||
212 | } | ||
213 | } | ||
214 | else | ||
215 | { | ||
216 | m_log.WarnFormat( | ||
217 | "[LIBRARY INVENTORY]: Couldn't add item {0} ({1}) since parent folder with ID {2} does not exist!", | ||
218 | item.Name, item.ID, item.Folder); | ||
219 | } | ||
220 | } | ||
221 | |||
222 | private delegate void ConfigAction(IConfig config, string path); | ||
223 | |||
224 | /// <summary> | ||
225 | /// Load the given configuration at a path and perform an action on each Config contained within it | ||
226 | /// </summary> | ||
227 | /// <param name="path"></param> | ||
228 | /// <param name="fileDescription"></param> | ||
229 | /// <param name="action"></param> | ||
230 | private static void LoadFromFile(string path, string fileDescription, ConfigAction action) | ||
231 | { | ||
232 | if (File.Exists(path)) | ||
233 | { | ||
234 | try | ||
235 | { | ||
236 | XmlConfigSource source = new XmlConfigSource(path); | ||
237 | |||
238 | for (int i = 0; i < source.Configs.Count; i++) | ||
239 | { | ||
240 | action(source.Configs[i], path); | ||
241 | } | ||
242 | } | ||
243 | catch (XmlException e) | ||
244 | { | ||
245 | m_log.ErrorFormat("[LIBRARY INVENTORY]: Error loading {0} : {1}", path, e); | ||
246 | } | ||
247 | } | ||
248 | else | ||
249 | { | ||
250 | m_log.ErrorFormat("[LIBRARY INVENTORY]: {0} file {1} does not exist!", fileDescription, path); | ||
251 | } | ||
252 | } | ||
253 | |||
254 | /// <summary> | ||
255 | /// Looks like a simple getter, but is written like this for some consistency with the other Request | ||
256 | /// methods in the superclass | ||
257 | /// </summary> | ||
258 | /// <returns></returns> | ||
259 | public Dictionary<UUID, InventoryFolderImpl> GetAllFolders() | ||
260 | { | ||
261 | Dictionary<UUID, InventoryFolderImpl> fs = new Dictionary<UUID, InventoryFolderImpl>(); | ||
262 | fs.Add(m_LibraryRootFolder.ID, m_LibraryRootFolder); | ||
263 | List<InventoryFolderImpl> fis = TraverseFolder(m_LibraryRootFolder); | ||
264 | foreach (InventoryFolderImpl f in fis) | ||
265 | { | ||
266 | fs.Add(f.ID, f); | ||
267 | } | ||
268 | //return libraryFolders; | ||
269 | return fs; | ||
270 | } | ||
271 | |||
272 | private List<InventoryFolderImpl> TraverseFolder(InventoryFolderImpl node) | ||
273 | { | ||
274 | List<InventoryFolderImpl> folders = node.RequestListOfFolderImpls(); | ||
275 | List<InventoryFolderImpl> subs = new List<InventoryFolderImpl>(); | ||
276 | foreach (InventoryFolderImpl f in folders) | ||
277 | subs.AddRange(TraverseFolder(f)); | ||
278 | |||
279 | folders.AddRange(subs); | ||
280 | return folders; | ||
281 | } | ||
282 | } | ||
283 | } | ||
diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs new file mode 100644 index 0000000..4db6a05 --- /dev/null +++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs | |||
@@ -0,0 +1,971 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | |||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Capabilities; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
38 | |||
39 | using log4net; | ||
40 | using OpenMetaverse; | ||
41 | using OpenMetaverse.StructuredData; | ||
42 | using OSDArray = OpenMetaverse.StructuredData.OSDArray; | ||
43 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; | ||
44 | |||
45 | namespace OpenSim.Services.LLLoginService | ||
46 | { | ||
47 | public class LLFailedLoginResponse : OpenSim.Services.Interfaces.FailedLoginResponse | ||
48 | { | ||
49 | string m_key; | ||
50 | string m_value; | ||
51 | string m_login; | ||
52 | |||
53 | public static LLFailedLoginResponse UserProblem; | ||
54 | public static LLFailedLoginResponse AuthorizationProblem; | ||
55 | public static LLFailedLoginResponse GridProblem; | ||
56 | public static LLFailedLoginResponse InventoryProblem; | ||
57 | public static LLFailedLoginResponse DeadRegionProblem; | ||
58 | public static LLFailedLoginResponse LoginBlockedProblem; | ||
59 | public static LLFailedLoginResponse AlreadyLoggedInProblem; | ||
60 | public static LLFailedLoginResponse InternalError; | ||
61 | |||
62 | static LLFailedLoginResponse() | ||
63 | { | ||
64 | UserProblem = new LLFailedLoginResponse("key", | ||
65 | "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", | ||
66 | "false"); | ||
67 | AuthorizationProblem = new LLFailedLoginResponse("key", | ||
68 | "Error connecting to grid. Unable to authorize your session into the region.", | ||
69 | "false"); | ||
70 | GridProblem = new LLFailedLoginResponse("key", | ||
71 | "Error connecting to the desired location. Try connecting to another region.", | ||
72 | "false"); | ||
73 | InventoryProblem = new LLFailedLoginResponse("key", | ||
74 | "The inventory service is not responding. Please notify your login region operator.", | ||
75 | "false"); | ||
76 | DeadRegionProblem = new LLFailedLoginResponse("key", | ||
77 | "The region you are attempting to log into is not responding. Please select another region and try again.", | ||
78 | "false"); | ||
79 | LoginBlockedProblem = new LLFailedLoginResponse("presence", | ||
80 | "Logins are currently restricted. Please try again later.", | ||
81 | "false"); | ||
82 | AlreadyLoggedInProblem = new LLFailedLoginResponse("presence", | ||
83 | "You appear to be already logged in. " + | ||
84 | "If this is not the case please wait for your session to timeout. " + | ||
85 | "If this takes longer than a few minutes please contact the grid owner. " + | ||
86 | "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.", | ||
87 | "false"); | ||
88 | InternalError = new LLFailedLoginResponse("Internal Error", "Error generating Login Response", "false"); | ||
89 | } | ||
90 | |||
91 | public LLFailedLoginResponse(string key, string value, string login) | ||
92 | { | ||
93 | m_key = key; | ||
94 | m_value = value; | ||
95 | m_login = login; | ||
96 | } | ||
97 | |||
98 | public override Hashtable ToHashtable() | ||
99 | { | ||
100 | Hashtable loginError = new Hashtable(); | ||
101 | loginError["reason"] = m_key; | ||
102 | loginError["message"] = m_value; | ||
103 | loginError["login"] = m_login; | ||
104 | return loginError; | ||
105 | } | ||
106 | |||
107 | public override OSD ToOSDMap() | ||
108 | { | ||
109 | OSDMap map = new OSDMap(); | ||
110 | |||
111 | map["reason"] = OSD.FromString(m_key); | ||
112 | map["message"] = OSD.FromString(m_value); | ||
113 | map["login"] = OSD.FromString(m_login); | ||
114 | |||
115 | return map; | ||
116 | } | ||
117 | } | ||
118 | |||
119 | /// <summary> | ||
120 | /// A class to handle LL login response. | ||
121 | /// </summary> | ||
122 | public class LLLoginResponse : OpenSim.Services.Interfaces.LoginResponse | ||
123 | { | ||
124 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
125 | private static Hashtable globalTexturesHash; | ||
126 | // Global Textures | ||
127 | private static string sunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271"; | ||
128 | private static string cloudTexture = "dc4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
129 | private static string moonTexture = "ec4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
130 | |||
131 | private Hashtable loginFlagsHash; | ||
132 | private Hashtable uiConfigHash; | ||
133 | |||
134 | private ArrayList loginFlags; | ||
135 | private ArrayList globalTextures; | ||
136 | private ArrayList eventCategories; | ||
137 | private ArrayList uiConfig; | ||
138 | private ArrayList classifiedCategories; | ||
139 | private ArrayList inventoryRoot; | ||
140 | private ArrayList initialOutfit; | ||
141 | private ArrayList agentInventory; | ||
142 | private ArrayList inventoryLibraryOwner; | ||
143 | private ArrayList inventoryLibRoot; | ||
144 | private ArrayList inventoryLibrary; | ||
145 | private ArrayList activeGestures; | ||
146 | |||
147 | private UserInfo userProfile; | ||
148 | |||
149 | private UUID agentID; | ||
150 | private UUID sessionID; | ||
151 | private UUID secureSessionID; | ||
152 | |||
153 | // Login Flags | ||
154 | private string dst; | ||
155 | private string stipendSinceLogin; | ||
156 | private string gendered; | ||
157 | private string everLoggedIn; | ||
158 | private string login; | ||
159 | private uint simPort; | ||
160 | private uint simHttpPort; | ||
161 | private string simAddress; | ||
162 | private string agentAccess; | ||
163 | private string agentAccessMax; | ||
164 | private Int32 circuitCode; | ||
165 | private uint regionX; | ||
166 | private uint regionY; | ||
167 | |||
168 | // Login | ||
169 | private string firstname; | ||
170 | private string lastname; | ||
171 | |||
172 | // Error Flags | ||
173 | private string errorReason; | ||
174 | private string errorMessage; | ||
175 | |||
176 | private string welcomeMessage; | ||
177 | private string startLocation; | ||
178 | private string allowFirstLife; | ||
179 | private string home; | ||
180 | private string seedCapability; | ||
181 | private string lookAt; | ||
182 | |||
183 | private BuddyList m_buddyList = null; | ||
184 | |||
185 | static LLLoginResponse() | ||
186 | { | ||
187 | // This is being set, but it's not used | ||
188 | // not sure why. | ||
189 | globalTexturesHash = new Hashtable(); | ||
190 | globalTexturesHash["sun_texture_id"] = sunTexture; | ||
191 | globalTexturesHash["cloud_texture_id"] = cloudTexture; | ||
192 | globalTexturesHash["moon_texture_id"] = moonTexture; | ||
193 | } | ||
194 | |||
195 | public LLLoginResponse() | ||
196 | { | ||
197 | loginFlags = new ArrayList(); | ||
198 | globalTextures = new ArrayList(); | ||
199 | eventCategories = new ArrayList(); | ||
200 | uiConfig = new ArrayList(); | ||
201 | classifiedCategories = new ArrayList(); | ||
202 | |||
203 | uiConfigHash = new Hashtable(); | ||
204 | |||
205 | // defaultXmlRpcResponse = new XmlRpcResponse(); | ||
206 | userProfile = new UserInfo(); | ||
207 | inventoryRoot = new ArrayList(); | ||
208 | initialOutfit = new ArrayList(); | ||
209 | agentInventory = new ArrayList(); | ||
210 | inventoryLibrary = new ArrayList(); | ||
211 | inventoryLibraryOwner = new ArrayList(); | ||
212 | activeGestures = new ArrayList(); | ||
213 | |||
214 | SetDefaultValues(); | ||
215 | } | ||
216 | |||
217 | public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, PresenceInfo pinfo, | ||
218 | GridRegion destination, List<InventoryFolderBase> invSkel, ILibraryService libService, | ||
219 | string where, string startlocation, Vector3 position, Vector3 lookAt, string message, | ||
220 | GridRegion home, IPEndPoint clientIP) | ||
221 | : this() | ||
222 | { | ||
223 | FillOutInventoryData(invSkel, libService); | ||
224 | |||
225 | CircuitCode = (int)aCircuit.circuitcode; | ||
226 | Lastname = account.LastName; | ||
227 | Firstname = account.FirstName; | ||
228 | AgentID = account.PrincipalID; | ||
229 | SessionID = aCircuit.SessionID; | ||
230 | SecureSessionID = aCircuit.SecureSessionID; | ||
231 | Message = message; | ||
232 | // While we don't have friends... | ||
233 | //BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); | ||
234 | BuddList = new LLLoginResponse.BuddyList(); | ||
235 | StartLocation = where; | ||
236 | |||
237 | FillOutHomeData(pinfo, home); | ||
238 | LookAt = String.Format("[r{0},r{1},r{2}]", lookAt.X, lookAt.Y, lookAt.Z); | ||
239 | |||
240 | FillOutRegionData(destination); | ||
241 | |||
242 | FillOutSeedCap(aCircuit, destination, clientIP); | ||
243 | |||
244 | } | ||
245 | |||
246 | private void FillOutInventoryData(List<InventoryFolderBase> invSkel, ILibraryService libService) | ||
247 | { | ||
248 | InventoryData inventData = null; | ||
249 | |||
250 | try | ||
251 | { | ||
252 | inventData = GetInventorySkeleton(invSkel); | ||
253 | } | ||
254 | catch (Exception e) | ||
255 | { | ||
256 | m_log.WarnFormat( | ||
257 | "[LLLOGIN SERVICE]: Error processing inventory skeleton of agent {0} - {1}", | ||
258 | agentID, e); | ||
259 | |||
260 | // ignore and continue | ||
261 | } | ||
262 | |||
263 | if (inventData != null) | ||
264 | { | ||
265 | ArrayList AgentInventoryArray = inventData.InventoryArray; | ||
266 | |||
267 | Hashtable InventoryRootHash = new Hashtable(); | ||
268 | InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); | ||
269 | InventoryRoot = new ArrayList(); | ||
270 | InventoryRoot.Add(InventoryRootHash); | ||
271 | InventorySkeleton = AgentInventoryArray; | ||
272 | } | ||
273 | |||
274 | // Inventory Library Section | ||
275 | if (libService != null && libService.LibraryRootFolder != null) | ||
276 | { | ||
277 | Hashtable InventoryLibRootHash = new Hashtable(); | ||
278 | InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; | ||
279 | InventoryLibRoot = new ArrayList(); | ||
280 | InventoryLibRoot.Add(InventoryLibRootHash); | ||
281 | |||
282 | InventoryLibraryOwner = GetLibraryOwner(libService.LibraryRootFolder); | ||
283 | InventoryLibrary = GetInventoryLibrary(libService); | ||
284 | } | ||
285 | } | ||
286 | |||
287 | private void FillOutHomeData(PresenceInfo pinfo, GridRegion home) | ||
288 | { | ||
289 | int x = 1000 * (int)Constants.RegionSize, y = 1000 * (int)Constants.RegionSize; | ||
290 | if (home != null) | ||
291 | { | ||
292 | x = home.RegionLocX; | ||
293 | y = home.RegionLocY; | ||
294 | } | ||
295 | |||
296 | Home = string.Format( | ||
297 | "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", | ||
298 | x, | ||
299 | y, | ||
300 | pinfo.HomePosition.X, pinfo.HomePosition.Y, pinfo.HomePosition.Z, | ||
301 | pinfo.HomeLookAt.X, pinfo.HomeLookAt.Y, pinfo.HomeLookAt.Z); | ||
302 | |||
303 | } | ||
304 | |||
305 | private void FillOutRegionData(GridRegion destination) | ||
306 | { | ||
307 | IPEndPoint endPoint = destination.ExternalEndPoint; | ||
308 | SimAddress = endPoint.Address.ToString(); | ||
309 | SimPort = (uint)endPoint.Port; | ||
310 | RegionX = (uint)destination.RegionLocX; | ||
311 | RegionY = (uint)destination.RegionLocY; | ||
312 | } | ||
313 | |||
314 | private void FillOutSeedCap(AgentCircuitData aCircuit, GridRegion destination, IPEndPoint ipepClient) | ||
315 | { | ||
316 | string capsSeedPath = String.Empty; | ||
317 | |||
318 | // Don't use the following! It Fails for logging into any region not on the same port as the http server! | ||
319 | // Kept here so it doesn't happen again! | ||
320 | // response.SeedCapability = regionInfo.ServerURI + capsSeedPath; | ||
321 | |||
322 | #region IP Translation for NAT | ||
323 | if (ipepClient != null) | ||
324 | { | ||
325 | capsSeedPath | ||
326 | = "http://" | ||
327 | + NetworkUtil.GetHostFor(ipepClient.Address, destination.ExternalHostName) | ||
328 | + ":" | ||
329 | + destination.HttpPort | ||
330 | + CapsUtil.GetCapsSeedPath(aCircuit.CapsPath); | ||
331 | } | ||
332 | else | ||
333 | { | ||
334 | capsSeedPath | ||
335 | = "http://" | ||
336 | + destination.ExternalHostName | ||
337 | + ":" | ||
338 | + destination.HttpPort | ||
339 | + CapsUtil.GetCapsSeedPath(aCircuit.CapsPath); | ||
340 | } | ||
341 | #endregion | ||
342 | |||
343 | SeedCapability = capsSeedPath; | ||
344 | } | ||
345 | |||
346 | private void SetDefaultValues() | ||
347 | { | ||
348 | DST = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; | ||
349 | StipendSinceLogin = "N"; | ||
350 | Gendered = "Y"; | ||
351 | EverLoggedIn = "Y"; | ||
352 | login = "false"; | ||
353 | firstname = "Test"; | ||
354 | lastname = "User"; | ||
355 | agentAccess = "M"; | ||
356 | agentAccessMax = "A"; | ||
357 | startLocation = "last"; | ||
358 | allowFirstLife = "Y"; | ||
359 | |||
360 | ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock."; | ||
361 | ErrorReason = "key"; | ||
362 | welcomeMessage = "Welcome to OpenSim!"; | ||
363 | seedCapability = String.Empty; | ||
364 | home = "{'region_handle':[r" + (1000*Constants.RegionSize).ToString() + ",r" + (1000*Constants.RegionSize).ToString() + "], 'position':[r" + | ||
365 | userProfile.homepos.X.ToString() + ",r" + userProfile.homepos.Y.ToString() + ",r" + | ||
366 | userProfile.homepos.Z.ToString() + "], 'look_at':[r" + userProfile.homelookat.X.ToString() + ",r" + | ||
367 | userProfile.homelookat.Y.ToString() + ",r" + userProfile.homelookat.Z.ToString() + "]}"; | ||
368 | lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]"; | ||
369 | RegionX = (uint) 255232; | ||
370 | RegionY = (uint) 254976; | ||
371 | |||
372 | // Classifieds; | ||
373 | AddClassifiedCategory((Int32) 1, "Shopping"); | ||
374 | AddClassifiedCategory((Int32) 2, "Land Rental"); | ||
375 | AddClassifiedCategory((Int32) 3, "Property Rental"); | ||
376 | AddClassifiedCategory((Int32) 4, "Special Attraction"); | ||
377 | AddClassifiedCategory((Int32) 5, "New Products"); | ||
378 | AddClassifiedCategory((Int32) 6, "Employment"); | ||
379 | AddClassifiedCategory((Int32) 7, "Wanted"); | ||
380 | AddClassifiedCategory((Int32) 8, "Service"); | ||
381 | AddClassifiedCategory((Int32) 9, "Personal"); | ||
382 | |||
383 | SessionID = UUID.Random(); | ||
384 | SecureSessionID = UUID.Random(); | ||
385 | AgentID = UUID.Random(); | ||
386 | |||
387 | Hashtable InitialOutfitHash = new Hashtable(); | ||
388 | InitialOutfitHash["folder_name"] = "Nightclub Female"; | ||
389 | InitialOutfitHash["gender"] = "female"; | ||
390 | initialOutfit.Add(InitialOutfitHash); | ||
391 | } | ||
392 | |||
393 | |||
394 | public override Hashtable ToHashtable() | ||
395 | { | ||
396 | try | ||
397 | { | ||
398 | Hashtable responseData = new Hashtable(); | ||
399 | |||
400 | loginFlagsHash = new Hashtable(); | ||
401 | loginFlagsHash["daylight_savings"] = DST; | ||
402 | loginFlagsHash["stipend_since_login"] = StipendSinceLogin; | ||
403 | loginFlagsHash["gendered"] = Gendered; | ||
404 | loginFlagsHash["ever_logged_in"] = EverLoggedIn; | ||
405 | loginFlags.Add(loginFlagsHash); | ||
406 | |||
407 | responseData["first_name"] = Firstname; | ||
408 | responseData["last_name"] = Lastname; | ||
409 | responseData["agent_access"] = agentAccess; | ||
410 | responseData["agent_access_max"] = agentAccessMax; | ||
411 | |||
412 | globalTextures.Add(globalTexturesHash); | ||
413 | // this.eventCategories.Add(this.eventCategoriesHash); | ||
414 | |||
415 | AddToUIConfig("allow_first_life", allowFirstLife); | ||
416 | uiConfig.Add(uiConfigHash); | ||
417 | |||
418 | responseData["sim_port"] = (Int32) SimPort; | ||
419 | responseData["sim_ip"] = SimAddress; | ||
420 | responseData["http_port"] = (Int32)SimHttpPort; | ||
421 | |||
422 | responseData["agent_id"] = AgentID.ToString(); | ||
423 | responseData["session_id"] = SessionID.ToString(); | ||
424 | responseData["secure_session_id"] = SecureSessionID.ToString(); | ||
425 | responseData["circuit_code"] = CircuitCode; | ||
426 | responseData["seconds_since_epoch"] = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; | ||
427 | responseData["login-flags"] = loginFlags; | ||
428 | responseData["global-textures"] = globalTextures; | ||
429 | responseData["seed_capability"] = seedCapability; | ||
430 | |||
431 | responseData["event_categories"] = eventCategories; | ||
432 | responseData["event_notifications"] = new ArrayList(); // todo | ||
433 | responseData["classified_categories"] = classifiedCategories; | ||
434 | responseData["ui-config"] = uiConfig; | ||
435 | |||
436 | if (agentInventory != null) | ||
437 | { | ||
438 | responseData["inventory-skeleton"] = agentInventory; | ||
439 | responseData["inventory-root"] = inventoryRoot; | ||
440 | } | ||
441 | responseData["inventory-skel-lib"] = inventoryLibrary; | ||
442 | responseData["inventory-lib-root"] = inventoryLibRoot; | ||
443 | responseData["gestures"] = activeGestures; | ||
444 | responseData["inventory-lib-owner"] = inventoryLibraryOwner; | ||
445 | responseData["initial-outfit"] = initialOutfit; | ||
446 | responseData["start_location"] = startLocation; | ||
447 | responseData["seed_capability"] = seedCapability; | ||
448 | responseData["home"] = home; | ||
449 | responseData["look_at"] = lookAt; | ||
450 | responseData["message"] = welcomeMessage; | ||
451 | responseData["region_x"] = (Int32)(RegionX); | ||
452 | responseData["region_y"] = (Int32)(RegionY); | ||
453 | |||
454 | if (m_buddyList != null) | ||
455 | { | ||
456 | responseData["buddy-list"] = m_buddyList.ToArray(); | ||
457 | } | ||
458 | |||
459 | responseData["login"] = "true"; | ||
460 | |||
461 | return responseData; | ||
462 | } | ||
463 | catch (Exception e) | ||
464 | { | ||
465 | m_log.Warn("[CLIENT]: LoginResponse: Error creating Hashtable Response: " + e.Message); | ||
466 | |||
467 | return LLFailedLoginResponse.InternalError.ToHashtable(); | ||
468 | } | ||
469 | } | ||
470 | |||
471 | public override OSD ToOSDMap() | ||
472 | { | ||
473 | try | ||
474 | { | ||
475 | OSDMap map = new OSDMap(); | ||
476 | |||
477 | map["first_name"] = OSD.FromString(Firstname); | ||
478 | map["last_name"] = OSD.FromString(Lastname); | ||
479 | map["agent_access"] = OSD.FromString(agentAccess); | ||
480 | map["agent_access_max"] = OSD.FromString(agentAccessMax); | ||
481 | |||
482 | map["sim_port"] = OSD.FromInteger(SimPort); | ||
483 | map["sim_ip"] = OSD.FromString(SimAddress); | ||
484 | |||
485 | map["agent_id"] = OSD.FromUUID(AgentID); | ||
486 | map["session_id"] = OSD.FromUUID(SessionID); | ||
487 | map["secure_session_id"] = OSD.FromUUID(SecureSessionID); | ||
488 | map["circuit_code"] = OSD.FromInteger(CircuitCode); | ||
489 | map["seconds_since_epoch"] = OSD.FromInteger((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds); | ||
490 | |||
491 | #region Login Flags | ||
492 | |||
493 | OSDMap loginFlagsLLSD = new OSDMap(); | ||
494 | loginFlagsLLSD["daylight_savings"] = OSD.FromString(DST); | ||
495 | loginFlagsLLSD["stipend_since_login"] = OSD.FromString(StipendSinceLogin); | ||
496 | loginFlagsLLSD["gendered"] = OSD.FromString(Gendered); | ||
497 | loginFlagsLLSD["ever_logged_in"] = OSD.FromString(EverLoggedIn); | ||
498 | map["login-flags"] = WrapOSDMap(loginFlagsLLSD); | ||
499 | |||
500 | #endregion Login Flags | ||
501 | |||
502 | #region Global Textures | ||
503 | |||
504 | OSDMap globalTexturesLLSD = new OSDMap(); | ||
505 | globalTexturesLLSD["sun_texture_id"] = OSD.FromString(SunTexture); | ||
506 | globalTexturesLLSD["cloud_texture_id"] = OSD.FromString(CloudTexture); | ||
507 | globalTexturesLLSD["moon_texture_id"] = OSD.FromString(MoonTexture); | ||
508 | |||
509 | map["global-textures"] = WrapOSDMap(globalTexturesLLSD); | ||
510 | |||
511 | #endregion Global Textures | ||
512 | |||
513 | map["seed_capability"] = OSD.FromString(seedCapability); | ||
514 | |||
515 | map["event_categories"] = ArrayListToOSDArray(eventCategories); | ||
516 | //map["event_notifications"] = new OSDArray(); // todo | ||
517 | map["classified_categories"] = ArrayListToOSDArray(classifiedCategories); | ||
518 | |||
519 | #region UI Config | ||
520 | |||
521 | OSDMap uiConfigLLSD = new OSDMap(); | ||
522 | uiConfigLLSD["allow_first_life"] = OSD.FromString(allowFirstLife); | ||
523 | map["ui-config"] = WrapOSDMap(uiConfigLLSD); | ||
524 | |||
525 | #endregion UI Config | ||
526 | |||
527 | #region Inventory | ||
528 | |||
529 | map["inventory-skeleton"] = ArrayListToOSDArray(agentInventory); | ||
530 | |||
531 | map["inventory-skel-lib"] = ArrayListToOSDArray(inventoryLibrary); | ||
532 | map["inventory-root"] = ArrayListToOSDArray(inventoryRoot); ; | ||
533 | map["inventory-lib-root"] = ArrayListToOSDArray(inventoryLibRoot); | ||
534 | map["inventory-lib-owner"] = ArrayListToOSDArray(inventoryLibraryOwner); | ||
535 | |||
536 | #endregion Inventory | ||
537 | |||
538 | map["gestures"] = ArrayListToOSDArray(activeGestures); | ||
539 | |||
540 | map["initial-outfit"] = ArrayListToOSDArray(initialOutfit); | ||
541 | map["start_location"] = OSD.FromString(startLocation); | ||
542 | |||
543 | map["seed_capability"] = OSD.FromString(seedCapability); | ||
544 | map["home"] = OSD.FromString(home); | ||
545 | map["look_at"] = OSD.FromString(lookAt); | ||
546 | map["message"] = OSD.FromString(welcomeMessage); | ||
547 | map["region_x"] = OSD.FromInteger(RegionX); | ||
548 | map["region_y"] = OSD.FromInteger(RegionY); | ||
549 | |||
550 | if (m_buddyList != null) | ||
551 | { | ||
552 | map["buddy-list"] = ArrayListToOSDArray(m_buddyList.ToArray()); | ||
553 | } | ||
554 | |||
555 | map["login"] = OSD.FromString("true"); | ||
556 | |||
557 | return map; | ||
558 | } | ||
559 | catch (Exception e) | ||
560 | { | ||
561 | m_log.Warn("[CLIENT]: LoginResponse: Error creating LLSD Response: " + e.Message); | ||
562 | |||
563 | return LLFailedLoginResponse.InternalError.ToOSDMap(); | ||
564 | } | ||
565 | } | ||
566 | |||
567 | public OSDArray ArrayListToOSDArray(ArrayList arrlst) | ||
568 | { | ||
569 | OSDArray llsdBack = new OSDArray(); | ||
570 | foreach (Hashtable ht in arrlst) | ||
571 | { | ||
572 | OSDMap mp = new OSDMap(); | ||
573 | foreach (DictionaryEntry deHt in ht) | ||
574 | { | ||
575 | mp.Add((string)deHt.Key, OSDString.FromObject(deHt.Value)); | ||
576 | } | ||
577 | llsdBack.Add(mp); | ||
578 | } | ||
579 | return llsdBack; | ||
580 | } | ||
581 | |||
582 | private static OSDArray WrapOSDMap(OSDMap wrapMe) | ||
583 | { | ||
584 | OSDArray array = new OSDArray(); | ||
585 | array.Add(wrapMe); | ||
586 | return array; | ||
587 | } | ||
588 | |||
589 | public void SetEventCategories(string category, string value) | ||
590 | { | ||
591 | // this.eventCategoriesHash[category] = value; | ||
592 | //TODO | ||
593 | } | ||
594 | |||
595 | public void AddToUIConfig(string itemName, string item) | ||
596 | { | ||
597 | uiConfigHash[itemName] = item; | ||
598 | } | ||
599 | |||
600 | public void AddClassifiedCategory(Int32 ID, string categoryName) | ||
601 | { | ||
602 | Hashtable hash = new Hashtable(); | ||
603 | hash["category_name"] = categoryName; | ||
604 | hash["category_id"] = ID; | ||
605 | classifiedCategories.Add(hash); | ||
606 | // this.classifiedCategoriesHash.Clear(); | ||
607 | } | ||
608 | |||
609 | |||
610 | private static LLLoginResponse.BuddyList ConvertFriendListItem(List<FriendListItem> LFL) | ||
611 | { | ||
612 | LLLoginResponse.BuddyList buddylistreturn = new LLLoginResponse.BuddyList(); | ||
613 | foreach (FriendListItem fl in LFL) | ||
614 | { | ||
615 | LLLoginResponse.BuddyList.BuddyInfo buddyitem = new LLLoginResponse.BuddyList.BuddyInfo(fl.Friend); | ||
616 | buddyitem.BuddyID = fl.Friend; | ||
617 | buddyitem.BuddyRightsHave = (int)fl.FriendListOwnerPerms; | ||
618 | buddyitem.BuddyRightsGiven = (int)fl.FriendPerms; | ||
619 | buddylistreturn.AddNewBuddy(buddyitem); | ||
620 | } | ||
621 | return buddylistreturn; | ||
622 | } | ||
623 | |||
624 | private InventoryData GetInventorySkeleton(List<InventoryFolderBase> folders) | ||
625 | { | ||
626 | UUID rootID = UUID.Zero; | ||
627 | ArrayList AgentInventoryArray = new ArrayList(); | ||
628 | Hashtable TempHash; | ||
629 | foreach (InventoryFolderBase InvFolder in folders) | ||
630 | { | ||
631 | if (InvFolder.ParentID == UUID.Zero) | ||
632 | { | ||
633 | rootID = InvFolder.ID; | ||
634 | } | ||
635 | TempHash = new Hashtable(); | ||
636 | TempHash["name"] = InvFolder.Name; | ||
637 | TempHash["parent_id"] = InvFolder.ParentID.ToString(); | ||
638 | TempHash["version"] = (Int32)InvFolder.Version; | ||
639 | TempHash["type_default"] = (Int32)InvFolder.Type; | ||
640 | TempHash["folder_id"] = InvFolder.ID.ToString(); | ||
641 | AgentInventoryArray.Add(TempHash); | ||
642 | } | ||
643 | |||
644 | return new InventoryData(AgentInventoryArray, rootID); | ||
645 | |||
646 | } | ||
647 | |||
648 | /// <summary> | ||
649 | /// Converts the inventory library skeleton into the form required by the rpc request. | ||
650 | /// </summary> | ||
651 | /// <returns></returns> | ||
652 | protected virtual ArrayList GetInventoryLibrary(ILibraryService library) | ||
653 | { | ||
654 | Dictionary<UUID, InventoryFolderImpl> rootFolders = library.GetAllFolders(); | ||
655 | m_log.DebugFormat("[LLOGIN]: Library has {0} folders", rootFolders.Count); | ||
656 | //Dictionary<UUID, InventoryFolderImpl> rootFolders = new Dictionary<UUID,InventoryFolderImpl>(); | ||
657 | ArrayList folderHashes = new ArrayList(); | ||
658 | |||
659 | foreach (InventoryFolderBase folder in rootFolders.Values) | ||
660 | { | ||
661 | Hashtable TempHash = new Hashtable(); | ||
662 | TempHash["name"] = folder.Name; | ||
663 | TempHash["parent_id"] = folder.ParentID.ToString(); | ||
664 | TempHash["version"] = (Int32)folder.Version; | ||
665 | TempHash["type_default"] = (Int32)folder.Type; | ||
666 | TempHash["folder_id"] = folder.ID.ToString(); | ||
667 | folderHashes.Add(TempHash); | ||
668 | } | ||
669 | |||
670 | return folderHashes; | ||
671 | } | ||
672 | |||
673 | /// <summary> | ||
674 | /// | ||
675 | /// </summary> | ||
676 | /// <returns></returns> | ||
677 | protected virtual ArrayList GetLibraryOwner(InventoryFolderImpl libFolder) | ||
678 | { | ||
679 | //for now create random inventory library owner | ||
680 | Hashtable TempHash = new Hashtable(); | ||
681 | TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; // libFolder.Owner | ||
682 | ArrayList inventoryLibOwner = new ArrayList(); | ||
683 | inventoryLibOwner.Add(TempHash); | ||
684 | return inventoryLibOwner; | ||
685 | } | ||
686 | |||
687 | public class InventoryData | ||
688 | { | ||
689 | public ArrayList InventoryArray = null; | ||
690 | public UUID RootFolderID = UUID.Zero; | ||
691 | |||
692 | public InventoryData(ArrayList invList, UUID rootID) | ||
693 | { | ||
694 | InventoryArray = invList; | ||
695 | RootFolderID = rootID; | ||
696 | } | ||
697 | } | ||
698 | |||
699 | #region Properties | ||
700 | |||
701 | public string Login | ||
702 | { | ||
703 | get { return login; } | ||
704 | set { login = value; } | ||
705 | } | ||
706 | |||
707 | public string DST | ||
708 | { | ||
709 | get { return dst; } | ||
710 | set { dst = value; } | ||
711 | } | ||
712 | |||
713 | public string StipendSinceLogin | ||
714 | { | ||
715 | get { return stipendSinceLogin; } | ||
716 | set { stipendSinceLogin = value; } | ||
717 | } | ||
718 | |||
719 | public string Gendered | ||
720 | { | ||
721 | get { return gendered; } | ||
722 | set { gendered = value; } | ||
723 | } | ||
724 | |||
725 | public string EverLoggedIn | ||
726 | { | ||
727 | get { return everLoggedIn; } | ||
728 | set { everLoggedIn = value; } | ||
729 | } | ||
730 | |||
731 | public uint SimPort | ||
732 | { | ||
733 | get { return simPort; } | ||
734 | set { simPort = value; } | ||
735 | } | ||
736 | |||
737 | public uint SimHttpPort | ||
738 | { | ||
739 | get { return simHttpPort; } | ||
740 | set { simHttpPort = value; } | ||
741 | } | ||
742 | |||
743 | public string SimAddress | ||
744 | { | ||
745 | get { return simAddress; } | ||
746 | set { simAddress = value; } | ||
747 | } | ||
748 | |||
749 | public UUID AgentID | ||
750 | { | ||
751 | get { return agentID; } | ||
752 | set { agentID = value; } | ||
753 | } | ||
754 | |||
755 | public UUID SessionID | ||
756 | { | ||
757 | get { return sessionID; } | ||
758 | set { sessionID = value; } | ||
759 | } | ||
760 | |||
761 | public UUID SecureSessionID | ||
762 | { | ||
763 | get { return secureSessionID; } | ||
764 | set { secureSessionID = value; } | ||
765 | } | ||
766 | |||
767 | public Int32 CircuitCode | ||
768 | { | ||
769 | get { return circuitCode; } | ||
770 | set { circuitCode = value; } | ||
771 | } | ||
772 | |||
773 | public uint RegionX | ||
774 | { | ||
775 | get { return regionX; } | ||
776 | set { regionX = value; } | ||
777 | } | ||
778 | |||
779 | public uint RegionY | ||
780 | { | ||
781 | get { return regionY; } | ||
782 | set { regionY = value; } | ||
783 | } | ||
784 | |||
785 | public string SunTexture | ||
786 | { | ||
787 | get { return sunTexture; } | ||
788 | set { sunTexture = value; } | ||
789 | } | ||
790 | |||
791 | public string CloudTexture | ||
792 | { | ||
793 | get { return cloudTexture; } | ||
794 | set { cloudTexture = value; } | ||
795 | } | ||
796 | |||
797 | public string MoonTexture | ||
798 | { | ||
799 | get { return moonTexture; } | ||
800 | set { moonTexture = value; } | ||
801 | } | ||
802 | |||
803 | public string Firstname | ||
804 | { | ||
805 | get { return firstname; } | ||
806 | set { firstname = value; } | ||
807 | } | ||
808 | |||
809 | public string Lastname | ||
810 | { | ||
811 | get { return lastname; } | ||
812 | set { lastname = value; } | ||
813 | } | ||
814 | |||
815 | public string AgentAccess | ||
816 | { | ||
817 | get { return agentAccess; } | ||
818 | set { agentAccess = value; } | ||
819 | } | ||
820 | |||
821 | public string AgentAccessMax | ||
822 | { | ||
823 | get { return agentAccessMax; } | ||
824 | set { agentAccessMax = value; } | ||
825 | } | ||
826 | |||
827 | public string StartLocation | ||
828 | { | ||
829 | get { return startLocation; } | ||
830 | set { startLocation = value; } | ||
831 | } | ||
832 | |||
833 | public string LookAt | ||
834 | { | ||
835 | get { return lookAt; } | ||
836 | set { lookAt = value; } | ||
837 | } | ||
838 | |||
839 | public string SeedCapability | ||
840 | { | ||
841 | get { return seedCapability; } | ||
842 | set { seedCapability = value; } | ||
843 | } | ||
844 | |||
845 | public string ErrorReason | ||
846 | { | ||
847 | get { return errorReason; } | ||
848 | set { errorReason = value; } | ||
849 | } | ||
850 | |||
851 | public string ErrorMessage | ||
852 | { | ||
853 | get { return errorMessage; } | ||
854 | set { errorMessage = value; } | ||
855 | } | ||
856 | |||
857 | public ArrayList InventoryRoot | ||
858 | { | ||
859 | get { return inventoryRoot; } | ||
860 | set { inventoryRoot = value; } | ||
861 | } | ||
862 | |||
863 | public ArrayList InventorySkeleton | ||
864 | { | ||
865 | get { return agentInventory; } | ||
866 | set { agentInventory = value; } | ||
867 | } | ||
868 | |||
869 | public ArrayList InventoryLibrary | ||
870 | { | ||
871 | get { return inventoryLibrary; } | ||
872 | set { inventoryLibrary = value; } | ||
873 | } | ||
874 | |||
875 | public ArrayList InventoryLibraryOwner | ||
876 | { | ||
877 | get { return inventoryLibraryOwner; } | ||
878 | set { inventoryLibraryOwner = value; } | ||
879 | } | ||
880 | |||
881 | public ArrayList InventoryLibRoot | ||
882 | { | ||
883 | get { return inventoryLibRoot; } | ||
884 | set { inventoryLibRoot = value; } | ||
885 | } | ||
886 | |||
887 | public ArrayList ActiveGestures | ||
888 | { | ||
889 | get { return activeGestures; } | ||
890 | set { activeGestures = value; } | ||
891 | } | ||
892 | |||
893 | public string Home | ||
894 | { | ||
895 | get { return home; } | ||
896 | set { home = value; } | ||
897 | } | ||
898 | |||
899 | public string Message | ||
900 | { | ||
901 | get { return welcomeMessage; } | ||
902 | set { welcomeMessage = value; } | ||
903 | } | ||
904 | |||
905 | public BuddyList BuddList | ||
906 | { | ||
907 | get { return m_buddyList; } | ||
908 | set { m_buddyList = value; } | ||
909 | } | ||
910 | |||
911 | #endregion | ||
912 | |||
913 | public class UserInfo | ||
914 | { | ||
915 | public string firstname; | ||
916 | public string lastname; | ||
917 | public ulong homeregionhandle; | ||
918 | public Vector3 homepos; | ||
919 | public Vector3 homelookat; | ||
920 | } | ||
921 | |||
922 | public class BuddyList | ||
923 | { | ||
924 | public List<BuddyInfo> Buddies = new List<BuddyInfo>(); | ||
925 | |||
926 | public void AddNewBuddy(BuddyInfo buddy) | ||
927 | { | ||
928 | if (!Buddies.Contains(buddy)) | ||
929 | { | ||
930 | Buddies.Add(buddy); | ||
931 | } | ||
932 | } | ||
933 | |||
934 | public ArrayList ToArray() | ||
935 | { | ||
936 | ArrayList buddyArray = new ArrayList(); | ||
937 | foreach (BuddyInfo buddy in Buddies) | ||
938 | { | ||
939 | buddyArray.Add(buddy.ToHashTable()); | ||
940 | } | ||
941 | return buddyArray; | ||
942 | } | ||
943 | |||
944 | public class BuddyInfo | ||
945 | { | ||
946 | public int BuddyRightsHave = 1; | ||
947 | public int BuddyRightsGiven = 1; | ||
948 | public UUID BuddyID; | ||
949 | |||
950 | public BuddyInfo(string buddyID) | ||
951 | { | ||
952 | BuddyID = new UUID(buddyID); | ||
953 | } | ||
954 | |||
955 | public BuddyInfo(UUID buddyID) | ||
956 | { | ||
957 | BuddyID = buddyID; | ||
958 | } | ||
959 | |||
960 | public Hashtable ToHashTable() | ||
961 | { | ||
962 | Hashtable hTable = new Hashtable(); | ||
963 | hTable["buddy_rights_has"] = BuddyRightsHave; | ||
964 | hTable["buddy_rights_given"] = BuddyRightsGiven; | ||
965 | hTable["buddy_id"] = BuddyID.ToString(); | ||
966 | return hTable; | ||
967 | } | ||
968 | } | ||
969 | } | ||
970 | } | ||
971 | } | ||
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs new file mode 100644 index 0000000..2ae552f --- /dev/null +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs | |||
@@ -0,0 +1,383 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Net; | ||
4 | using System.Reflection; | ||
5 | using System.Text.RegularExpressions; | ||
6 | |||
7 | using log4net; | ||
8 | using Nini.Config; | ||
9 | using OpenMetaverse; | ||
10 | |||
11 | using OpenSim.Framework; | ||
12 | using OpenSim.Framework.Capabilities; | ||
13 | using OpenSim.Server.Base; | ||
14 | using OpenSim.Services.Interfaces; | ||
15 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
16 | |||
17 | namespace OpenSim.Services.LLLoginService | ||
18 | { | ||
19 | public class LLLoginService : ILoginService | ||
20 | { | ||
21 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
22 | |||
23 | private IUserAccountService m_UserAccountService; | ||
24 | private IAuthenticationService m_AuthenticationService; | ||
25 | private IInventoryService m_InventoryService; | ||
26 | private IGridService m_GridService; | ||
27 | private IPresenceService m_PresenceService; | ||
28 | private ISimulationService m_LocalSimulationService; | ||
29 | private ISimulationService m_RemoteSimulationService; | ||
30 | private ILibraryService m_LibraryService; | ||
31 | private IAvatarService m_AvatarService; | ||
32 | |||
33 | private string m_DefaultRegionName; | ||
34 | private string m_WelcomeMessage; | ||
35 | private bool m_RequireInventory; | ||
36 | |||
37 | public LLLoginService(IConfigSource config, ISimulationService simService, ILibraryService libraryService) | ||
38 | { | ||
39 | IConfig serverConfig = config.Configs["LoginService"]; | ||
40 | if (serverConfig == null) | ||
41 | throw new Exception(String.Format("No section LoginService in config file")); | ||
42 | |||
43 | string accountService = serverConfig.GetString("UserAccountService", String.Empty); | ||
44 | string authService = serverConfig.GetString("AuthenticationService", String.Empty); | ||
45 | string invService = serverConfig.GetString("InventoryService", String.Empty); | ||
46 | string gridService = serverConfig.GetString("GridService", String.Empty); | ||
47 | string presenceService = serverConfig.GetString("PresenceService", String.Empty); | ||
48 | string libService = serverConfig.GetString("LibraryService", String.Empty); | ||
49 | string avatarService = serverConfig.GetString("AvatarService", String.Empty); | ||
50 | string simulationService = serverConfig.GetString("SimulationService", String.Empty); | ||
51 | |||
52 | m_DefaultRegionName = serverConfig.GetString("DefaultRegion", String.Empty); | ||
53 | m_WelcomeMessage = serverConfig.GetString("WelcomeMessage", "Welcome to OpenSim!"); | ||
54 | m_RequireInventory = serverConfig.GetBoolean("RequireInventory", true); | ||
55 | |||
56 | // These are required; the others aren't | ||
57 | if (accountService == string.Empty || authService == string.Empty) | ||
58 | throw new Exception("LoginService is missing service specifications"); | ||
59 | |||
60 | Object[] args = new Object[] { config }; | ||
61 | m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args); | ||
62 | m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args); | ||
63 | m_InventoryService = ServerUtils.LoadPlugin<IInventoryService>(invService, args); | ||
64 | if (gridService != string.Empty) | ||
65 | m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args); | ||
66 | if (presenceService != string.Empty) | ||
67 | m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args); | ||
68 | if (avatarService != string.Empty) | ||
69 | m_AvatarService = ServerUtils.LoadPlugin<IAvatarService>(avatarService, args); | ||
70 | if (simulationService != string.Empty) | ||
71 | m_RemoteSimulationService = ServerUtils.LoadPlugin<ISimulationService>(simulationService, args); | ||
72 | // | ||
73 | // deal with the services given as argument | ||
74 | // | ||
75 | m_LocalSimulationService = simService; | ||
76 | if (libraryService != null) | ||
77 | { | ||
78 | m_log.DebugFormat("[LLOGIN SERVICE]: Using LibraryService given as argument"); | ||
79 | m_LibraryService = libraryService; | ||
80 | } | ||
81 | else if (libService != string.Empty) | ||
82 | { | ||
83 | m_log.DebugFormat("[LLOGIN SERVICE]: Using instantiated LibraryService"); | ||
84 | m_LibraryService = ServerUtils.LoadPlugin<ILibraryService>(libService, args); | ||
85 | } | ||
86 | |||
87 | m_log.DebugFormat("[LLOGIN SERVICE]: Starting..."); | ||
88 | |||
89 | } | ||
90 | |||
91 | public LLLoginService(IConfigSource config) : this(config, null, null) | ||
92 | { | ||
93 | } | ||
94 | |||
95 | public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, IPEndPoint clientIP) | ||
96 | { | ||
97 | bool success = false; | ||
98 | UUID session = UUID.Random(); | ||
99 | |||
100 | try | ||
101 | { | ||
102 | // Get the account and check that it exists | ||
103 | UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName); | ||
104 | if (account == null) | ||
105 | { | ||
106 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: user not found"); | ||
107 | return LLFailedLoginResponse.UserProblem; | ||
108 | } | ||
109 | |||
110 | // Authenticate this user | ||
111 | if (!passwd.StartsWith("$1$")) | ||
112 | passwd = "$1$" + Util.Md5Hash(passwd); | ||
113 | passwd = passwd.Remove(0, 3); //remove $1$ | ||
114 | string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30); | ||
115 | UUID secureSession = UUID.Zero; | ||
116 | if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession))) | ||
117 | { | ||
118 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: authentication failed"); | ||
119 | return LLFailedLoginResponse.UserProblem; | ||
120 | } | ||
121 | |||
122 | // Get the user's inventory | ||
123 | if (m_RequireInventory && m_InventoryService == null) | ||
124 | { | ||
125 | m_log.WarnFormat("[LLOGIN SERVICE]: Login failed, reason: inventory service not set up"); | ||
126 | return LLFailedLoginResponse.InventoryProblem; | ||
127 | } | ||
128 | List<InventoryFolderBase> inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID); | ||
129 | if (m_RequireInventory && ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0))) | ||
130 | { | ||
131 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: unable to retrieve user inventory"); | ||
132 | return LLFailedLoginResponse.InventoryProblem; | ||
133 | } | ||
134 | |||
135 | // Login the presence | ||
136 | // We may want to check for user already logged in, to | ||
137 | // stay compatible with what people expect... | ||
138 | PresenceInfo presence = null; | ||
139 | GridRegion home = null; | ||
140 | if (m_PresenceService != null) | ||
141 | { | ||
142 | success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession); | ||
143 | if (!success) | ||
144 | { | ||
145 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: could not login presence"); | ||
146 | return LLFailedLoginResponse.GridProblem; | ||
147 | } | ||
148 | |||
149 | // Get the updated presence info | ||
150 | presence = m_PresenceService.GetAgent(session); | ||
151 | |||
152 | // Get the home region | ||
153 | if ((presence.HomeRegionID != UUID.Zero) && m_GridService != null) | ||
154 | { | ||
155 | home = m_GridService.GetRegionByUUID(account.ScopeID, presence.HomeRegionID); | ||
156 | } | ||
157 | } | ||
158 | |||
159 | // Find the destination region/grid | ||
160 | string where = string.Empty; | ||
161 | Vector3 position = Vector3.Zero; | ||
162 | Vector3 lookAt = Vector3.Zero; | ||
163 | GridRegion destination = FindDestination(account, presence, session, startLocation, out where, out position, out lookAt); | ||
164 | if (destination == null) | ||
165 | { | ||
166 | m_PresenceService.LogoutAgent(session); | ||
167 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: destination not found"); | ||
168 | return LLFailedLoginResponse.GridProblem; | ||
169 | } | ||
170 | |||
171 | // Get the avatar | ||
172 | AvatarData avatar = null; | ||
173 | if (m_AvatarService != null) | ||
174 | { | ||
175 | avatar = m_AvatarService.GetAvatar(account.PrincipalID); | ||
176 | } | ||
177 | |||
178 | // Instantiate/get the simulation interface and launch an agent at the destination | ||
179 | ISimulationService simConnector = null; | ||
180 | string reason = string.Empty; | ||
181 | uint circuitCode = 0; | ||
182 | AgentCircuitData aCircuit = null; | ||
183 | Object[] args = new Object[] { destination }; | ||
184 | // HG standalones have both a localSimulatonDll and a remoteSimulationDll | ||
185 | // non-HG standalones have just a localSimulationDll | ||
186 | // independent login servers have just a remoteSimulationDll | ||
187 | if (!startLocation.Contains("@") && (m_LocalSimulationService != null)) | ||
188 | simConnector = m_LocalSimulationService; | ||
189 | else if (m_RemoteSimulationService != null) | ||
190 | simConnector = m_RemoteSimulationService; | ||
191 | if (simConnector != null) | ||
192 | { | ||
193 | circuitCode = (uint)Util.RandomClass.Next(); ; | ||
194 | aCircuit = LaunchAgent(simConnector, destination, account, avatar, session, secureSession, circuitCode, position, out reason); | ||
195 | } | ||
196 | if (aCircuit == null) | ||
197 | { | ||
198 | m_PresenceService.LogoutAgent(session); | ||
199 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: {0}", reason); | ||
200 | return LLFailedLoginResponse.AuthorizationProblem; | ||
201 | } | ||
202 | |||
203 | // TODO: Get Friends list... | ||
204 | |||
205 | // Finally, fill out the response and return it | ||
206 | LLLoginResponse response = new LLLoginResponse(account, aCircuit, presence, destination, inventorySkel, m_LibraryService, | ||
207 | where, startLocation, position, lookAt, m_WelcomeMessage, home, clientIP); | ||
208 | |||
209 | return response; | ||
210 | } | ||
211 | catch (Exception e) | ||
212 | { | ||
213 | m_log.WarnFormat("[LLOGIN SERVICE]: Exception processing login for {0} {1}: {2}", firstName, lastName, e.StackTrace); | ||
214 | if (m_PresenceService != null) | ||
215 | m_PresenceService.LogoutAgent(session); | ||
216 | return LLFailedLoginResponse.InternalError; | ||
217 | } | ||
218 | } | ||
219 | |||
220 | private GridRegion FindDestination(UserAccount account, PresenceInfo pinfo, UUID sessionID, string startLocation, out string where, out Vector3 position, out Vector3 lookAt) | ||
221 | { | ||
222 | m_log.DebugFormat("[LLOGIN SERVICE]: FindDestination for start location {0}", startLocation); | ||
223 | |||
224 | where = "home"; | ||
225 | position = new Vector3(128, 128, 0); | ||
226 | lookAt = new Vector3(0, 1, 0); | ||
227 | if (startLocation.Equals("home")) | ||
228 | { | ||
229 | // logging into home region | ||
230 | if (m_PresenceService == null || m_GridService == null) | ||
231 | return null; | ||
232 | |||
233 | if (pinfo == null) | ||
234 | return null; | ||
235 | |||
236 | GridRegion region = null; | ||
237 | |||
238 | if (pinfo.HomeRegionID.Equals(UUID.Zero)) | ||
239 | { | ||
240 | if (m_DefaultRegionName != string.Empty) | ||
241 | { | ||
242 | region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName); | ||
243 | where = "safe"; | ||
244 | } | ||
245 | else | ||
246 | m_log.WarnFormat("[LLOGIN SERVICE]: User {0} {1} does not have a home set and this grid does not have a default location." + | ||
247 | "Please specify DefaultRegion in [LoginService]", account.FirstName, account.LastName); | ||
248 | } | ||
249 | else | ||
250 | region = m_GridService.GetRegionByUUID(account.ScopeID, pinfo.HomeRegionID); | ||
251 | |||
252 | return region; | ||
253 | } | ||
254 | else if (startLocation.Equals("last")) | ||
255 | { | ||
256 | // logging into last visited region | ||
257 | where = "last"; | ||
258 | if (m_PresenceService == null || m_GridService == null) | ||
259 | return null; | ||
260 | |||
261 | if (pinfo == null) | ||
262 | return null; | ||
263 | |||
264 | GridRegion region = null; | ||
265 | |||
266 | if (pinfo.RegionID.Equals(UUID.Zero)) | ||
267 | { | ||
268 | region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName); | ||
269 | where = "safe"; | ||
270 | } | ||
271 | else | ||
272 | { | ||
273 | region = m_GridService.GetRegionByUUID(account.ScopeID, pinfo.RegionID); | ||
274 | position = pinfo.Position; | ||
275 | lookAt = pinfo.LookAt; | ||
276 | } | ||
277 | return region; | ||
278 | |||
279 | } | ||
280 | else | ||
281 | { | ||
282 | // free uri form | ||
283 | // e.g. New Moon&135&46 New Moon@osgrid.org:8002&153&34 | ||
284 | where = "url"; | ||
285 | Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$"); | ||
286 | Match uriMatch = reURI.Match(startLocation); | ||
287 | if (uriMatch == null) | ||
288 | { | ||
289 | m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, but can't process it", startLocation); | ||
290 | return null; | ||
291 | } | ||
292 | else | ||
293 | { | ||
294 | position = new Vector3(float.Parse(uriMatch.Groups["x"].Value), | ||
295 | float.Parse(uriMatch.Groups["y"].Value), | ||
296 | float.Parse(uriMatch.Groups["z"].Value)); | ||
297 | |||
298 | string regionName = uriMatch.Groups["region"].ToString(); | ||
299 | if (regionName != null) | ||
300 | { | ||
301 | if (!regionName.Contains("@")) | ||
302 | { | ||
303 | if (m_GridService == null) | ||
304 | return null; | ||
305 | |||
306 | List<GridRegion> regions = m_GridService.GetRegionsByName(account.ScopeID, regionName, 1); | ||
307 | if ((regions == null) || (regions != null && regions.Count == 0)) | ||
308 | { | ||
309 | m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}", startLocation, regionName); | ||
310 | return null; | ||
311 | } | ||
312 | return regions[0]; | ||
313 | } | ||
314 | else | ||
315 | { | ||
316 | string[] parts = regionName.Split(new char[] { '@' }); | ||
317 | if (parts.Length < 2) | ||
318 | { | ||
319 | m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}", startLocation, regionName); | ||
320 | return null; | ||
321 | } | ||
322 | // Valid specification of a remote grid | ||
323 | regionName = parts[0]; | ||
324 | string domainLocator = parts[1]; | ||
325 | parts = domainLocator.Split(new char[] {':'}); | ||
326 | string domainName = parts[0]; | ||
327 | uint port = 0; | ||
328 | if (parts.Length > 1) | ||
329 | UInt32.TryParse(parts[1], out port); | ||
330 | GridRegion region = new GridRegion(); | ||
331 | region.ExternalHostName = domainName; | ||
332 | region.HttpPort = port; | ||
333 | region.RegionName = regionName; | ||
334 | return region; | ||
335 | } | ||
336 | |||
337 | } | ||
338 | else | ||
339 | { | ||
340 | if (m_PresenceService == null || m_GridService == null) | ||
341 | return null; | ||
342 | |||
343 | return m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName); | ||
344 | |||
345 | } | ||
346 | } | ||
347 | //response.LookAt = "[r0,r1,r0]"; | ||
348 | //// can be: last, home, safe, url | ||
349 | //response.StartLocation = "url"; | ||
350 | |||
351 | } | ||
352 | |||
353 | } | ||
354 | |||
355 | private AgentCircuitData LaunchAgent(ISimulationService simConnector, GridRegion region, UserAccount account, | ||
356 | AvatarData avatar, UUID session, UUID secureSession, uint circuit, Vector3 position, out string reason) | ||
357 | { | ||
358 | reason = string.Empty; | ||
359 | AgentCircuitData aCircuit = new AgentCircuitData(); | ||
360 | |||
361 | aCircuit.AgentID = account.PrincipalID; | ||
362 | if (avatar != null) | ||
363 | aCircuit.Appearance = avatar.ToAvatarAppearance(); | ||
364 | //aCircuit.BaseFolder = irrelevant | ||
365 | aCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); | ||
366 | aCircuit.child = false; // the first login agent is root | ||
367 | aCircuit.ChildrenCapSeeds = new Dictionary<ulong, string>(); | ||
368 | aCircuit.circuitcode = circuit; | ||
369 | aCircuit.firstname = account.FirstName; | ||
370 | //aCircuit.InventoryFolder = irrelevant | ||
371 | aCircuit.lastname = account.LastName; | ||
372 | aCircuit.SecureSessionID = secureSession; | ||
373 | aCircuit.SessionID = session; | ||
374 | aCircuit.startpos = position; | ||
375 | |||
376 | if (simConnector.CreateAgent(region, aCircuit, 0, out reason)) | ||
377 | return aCircuit; | ||
378 | |||
379 | return null; | ||
380 | |||
381 | } | ||
382 | } | ||
383 | } | ||
diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 2157462..2884199 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs | |||
@@ -41,27 +41,175 @@ namespace OpenSim.Services.PresenceService | |||
41 | { | 41 | { |
42 | public class PresenceService : PresenceServiceBase, IPresenceService | 42 | public class PresenceService : PresenceServiceBase, IPresenceService |
43 | { | 43 | { |
44 | // private static readonly ILog m_log = | 44 | private static readonly ILog m_log = |
45 | // LogManager.GetLogger( | 45 | LogManager.GetLogger( |
46 | // MethodBase.GetCurrentMethod().DeclaringType); | 46 | MethodBase.GetCurrentMethod().DeclaringType); |
47 | 47 | ||
48 | public PresenceService(IConfigSource config) | 48 | public PresenceService(IConfigSource config) |
49 | : base(config) | 49 | : base(config) |
50 | { | 50 | { |
51 | m_log.Debug("[PRESENCE SERVICE]: Starting presence service"); | ||
51 | } | 52 | } |
52 | 53 | ||
53 | public bool Report(PresenceInfo presence) | 54 | public bool LoginAgent(string userID, UUID sessionID, |
55 | UUID secureSessionID) | ||
54 | { | 56 | { |
55 | PresenceData p = new PresenceData(); | 57 | m_Database.Prune(userID); |
56 | p.Data = new Dictionary<string, string>(); | ||
57 | 58 | ||
58 | p.UUID = presence.PrincipalID; | 59 | PresenceData[] d = m_Database.Get("UserID", userID); |
59 | p.currentRegion = presence.RegionID; | ||
60 | 60 | ||
61 | foreach (KeyValuePair<string, string> kvp in presence.Data) | 61 | PresenceData data = new PresenceData(); |
62 | p.Data[kvp.Key] = kvp.Value; | ||
63 | 62 | ||
64 | return false; | 63 | data.UserID = userID; |
64 | data.RegionID = UUID.Zero; | ||
65 | data.SessionID = sessionID; | ||
66 | data.Data = new Dictionary<string, string>(); | ||
67 | data.Data["SecureSessionID"] = secureSessionID.ToString(); | ||
68 | data.Data["Online"] = "true"; | ||
69 | data.Data["Login"] = Util.UnixTimeSinceEpoch().ToString(); | ||
70 | if (d != null && d.Length > 0) | ||
71 | { | ||
72 | data.Data["HomeRegionID"] = d[0].Data["HomeRegionID"]; | ||
73 | data.Data["HomePosition"] = d[0].Data["HomePosition"]; | ||
74 | data.Data["HomeLookAt"] = d[0].Data["HomeLookAt"]; | ||
75 | } | ||
76 | else | ||
77 | { | ||
78 | data.Data["HomeRegionID"] = UUID.Zero.ToString(); | ||
79 | data.Data["HomePosition"] = new Vector3(128, 128, 0).ToString(); | ||
80 | data.Data["HomeLookAt"] = new Vector3(0, 1, 0).ToString(); | ||
81 | } | ||
82 | |||
83 | m_Database.Store(data); | ||
84 | |||
85 | m_log.DebugFormat("[PRESENCE SERVICE]: LoginAgent {0} with session {1} and ssession {2}", | ||
86 | userID, sessionID, secureSessionID); | ||
87 | return true; | ||
88 | } | ||
89 | |||
90 | public bool LogoutAgent(UUID sessionID) | ||
91 | { | ||
92 | PresenceData data = m_Database.Get(sessionID); | ||
93 | if (data == null) | ||
94 | return false; | ||
95 | |||
96 | PresenceData[] d = m_Database.Get("UserID", data.UserID); | ||
97 | |||
98 | m_log.DebugFormat("[PRESENCE SERVICE]: LogoutAgent {0} with {1} sessions currently present", data.UserID, d.Length); | ||
99 | if (d.Length > 1) | ||
100 | { | ||
101 | m_Database.Delete("UserID", data.UserID); | ||
102 | } | ||
103 | |||
104 | data.Data["Online"] = "false"; | ||
105 | data.Data["Logout"] = Util.UnixTimeSinceEpoch().ToString(); | ||
106 | |||
107 | m_Database.Store(data); | ||
108 | |||
109 | return true; | ||
110 | } | ||
111 | |||
112 | public bool LogoutRegionAgents(UUID regionID) | ||
113 | { | ||
114 | m_Database.LogoutRegionAgents(regionID); | ||
115 | |||
116 | return true; | ||
117 | } | ||
118 | |||
119 | |||
120 | public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
121 | { | ||
122 | //m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent with session {0} in region {1}", sessionID, regionID); | ||
123 | try | ||
124 | { | ||
125 | PresenceData pdata = m_Database.Get(sessionID); | ||
126 | if (pdata == null) | ||
127 | return false; | ||
128 | if (pdata.Data == null) | ||
129 | return false; | ||
130 | |||
131 | if (!pdata.Data.ContainsKey("Online") || (pdata.Data.ContainsKey("Online") && pdata.Data["Online"] == "false")) | ||
132 | { | ||
133 | m_log.WarnFormat("[PRESENCE SERVICE]: Someone tried to report presence of an agent who's not online"); | ||
134 | return false; | ||
135 | } | ||
136 | |||
137 | return m_Database.ReportAgent(sessionID, regionID, | ||
138 | position.ToString(), lookAt.ToString()); | ||
139 | } | ||
140 | catch (Exception e) | ||
141 | { | ||
142 | m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent threw exception {0}", e.StackTrace); | ||
143 | return false; | ||
144 | } | ||
145 | } | ||
146 | |||
147 | public PresenceInfo GetAgent(UUID sessionID) | ||
148 | { | ||
149 | PresenceInfo ret = new PresenceInfo(); | ||
150 | |||
151 | PresenceData data = m_Database.Get(sessionID); | ||
152 | if (data == null) | ||
153 | return null; | ||
154 | |||
155 | ret.UserID = data.UserID; | ||
156 | ret.RegionID = data.RegionID; | ||
157 | if (data.Data.ContainsKey("Online")) | ||
158 | ret.Online = bool.Parse(data.Data["Online"]); | ||
159 | if (data.Data.ContainsKey("Login")) | ||
160 | ret.Login = Util.ToDateTime(Convert.ToInt32(data.Data["Login"])); | ||
161 | if (data.Data.ContainsKey("Logout")) | ||
162 | ret.Logout = Util.ToDateTime(Convert.ToInt32(data.Data["Logout"])); | ||
163 | if (data.Data.ContainsKey("Position")) | ||
164 | ret.Position = Vector3.Parse(data.Data["Position"]); | ||
165 | if (data.Data.ContainsKey("LookAt")) | ||
166 | ret.LookAt = Vector3.Parse(data.Data["LookAt"]); | ||
167 | if (data.Data.ContainsKey("HomeRegionID")) | ||
168 | ret.HomeRegionID = new UUID(data.Data["HomeRegionID"]); | ||
169 | if (data.Data.ContainsKey("HomePosition")) | ||
170 | ret.HomePosition = Vector3.Parse(data.Data["HomePosition"]); | ||
171 | if (data.Data.ContainsKey("HomeLookAt")) | ||
172 | ret.HomeLookAt = Vector3.Parse(data.Data["HomeLookAt"]); | ||
173 | |||
174 | return ret; | ||
175 | } | ||
176 | |||
177 | public PresenceInfo[] GetAgents(string[] userIDs) | ||
178 | { | ||
179 | List<PresenceInfo> info = new List<PresenceInfo>(); | ||
180 | |||
181 | foreach (string userIDStr in userIDs) | ||
182 | { | ||
183 | PresenceData[] data = m_Database.Get("UserID", | ||
184 | userIDStr); | ||
185 | |||
186 | foreach (PresenceData d in data) | ||
187 | { | ||
188 | PresenceInfo ret = new PresenceInfo(); | ||
189 | |||
190 | ret.UserID = d.UserID; | ||
191 | ret.RegionID = d.RegionID; | ||
192 | ret.Online = bool.Parse(d.Data["Online"]); | ||
193 | ret.Login = Util.ToDateTime(Convert.ToInt32( | ||
194 | d.Data["Login"])); | ||
195 | ret.Logout = Util.ToDateTime(Convert.ToInt32( | ||
196 | d.Data["Logout"])); | ||
197 | ret.Position = Vector3.Parse(d.Data["Position"]); | ||
198 | ret.LookAt = Vector3.Parse(d.Data["LookAt"]); | ||
199 | ret.HomeRegionID = new UUID(d.Data["HomeRegionID"]); | ||
200 | ret.HomePosition = Vector3.Parse(d.Data["HomePosition"]); | ||
201 | ret.HomeLookAt = Vector3.Parse(d.Data["HomeLookAt"]); | ||
202 | |||
203 | info.Add(ret); | ||
204 | } | ||
205 | } | ||
206 | |||
207 | return info.ToArray(); | ||
208 | } | ||
209 | |||
210 | public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
211 | { | ||
212 | return m_Database.SetHomeLocation(userID, regionID, position, lookAt); | ||
65 | } | 213 | } |
66 | } | 214 | } |
67 | } | 215 | } |
diff --git a/OpenSim/Services/PresenceService/PresenceServiceBase.cs b/OpenSim/Services/PresenceService/PresenceServiceBase.cs index 60a246b..a4adb2f 100644 --- a/OpenSim/Services/PresenceService/PresenceServiceBase.cs +++ b/OpenSim/Services/PresenceService/PresenceServiceBase.cs | |||
@@ -44,7 +44,7 @@ namespace OpenSim.Services.PresenceService | |||
44 | { | 44 | { |
45 | string dllName = String.Empty; | 45 | string dllName = String.Empty; |
46 | string connString = String.Empty; | 46 | string connString = String.Empty; |
47 | string realm = "agents"; | 47 | string realm = "Presence"; |
48 | 48 | ||
49 | // | 49 | // |
50 | // Try reading the [DatabaseService] section, if it exists | 50 | // Try reading the [DatabaseService] section, if it exists |
@@ -77,7 +77,7 @@ namespace OpenSim.Services.PresenceService | |||
77 | 77 | ||
78 | m_Database = LoadPlugin<IPresenceData>(dllName, new Object[] { connString, realm }); | 78 | m_Database = LoadPlugin<IPresenceData>(dllName, new Object[] { connString, realm }); |
79 | if (m_Database == null) | 79 | if (m_Database == null) |
80 | throw new Exception("Could not find a storage interface in the given module"); | 80 | throw new Exception("Could not find a storage interface in the given module " + dllName); |
81 | 81 | ||
82 | } | 82 | } |
83 | } | 83 | } |
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs new file mode 100644 index 0000000..c14651d --- /dev/null +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs | |||
@@ -0,0 +1,184 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using Nini.Config; | ||
31 | using OpenSim.Data; | ||
32 | using OpenSim.Services.Interfaces; | ||
33 | using System.Collections.Generic; | ||
34 | using OpenMetaverse; | ||
35 | |||
36 | namespace OpenSim.Services.UserAccountService | ||
37 | { | ||
38 | public class UserAccountService : UserAccountServiceBase, IUserAccountService | ||
39 | { | ||
40 | public UserAccountService(IConfigSource config) : base(config) | ||
41 | { | ||
42 | } | ||
43 | |||
44 | public UserAccount GetUserAccount(UUID scopeID, string firstName, | ||
45 | string lastName) | ||
46 | { | ||
47 | UserAccountData[] d; | ||
48 | |||
49 | if (scopeID != UUID.Zero) | ||
50 | { | ||
51 | d = m_Database.Get( | ||
52 | new string[] {"ScopeID", "FirstName", "LastName"}, | ||
53 | new string[] {scopeID.ToString(), firstName, lastName}); | ||
54 | } | ||
55 | else | ||
56 | { | ||
57 | d = m_Database.Get( | ||
58 | new string[] {"FirstName", "LastName"}, | ||
59 | new string[] {firstName, lastName}); | ||
60 | } | ||
61 | |||
62 | if (d.Length < 1) | ||
63 | return null; | ||
64 | |||
65 | return MakeUserAccount(d[0]); | ||
66 | } | ||
67 | |||
68 | private UserAccount MakeUserAccount(UserAccountData d) | ||
69 | { | ||
70 | UserAccount u = new UserAccount(); | ||
71 | u.FirstName = d.FirstName; | ||
72 | u.LastName = d.LastName; | ||
73 | u.PrincipalID = d.PrincipalID; | ||
74 | u.ScopeID = d.ScopeID; | ||
75 | u.Email = d.Data["Email"].ToString(); | ||
76 | u.Created = Convert.ToInt32(d.Data["Created"].ToString()); | ||
77 | |||
78 | string[] URLs = d.Data["ServiceURLs"].ToString().Split(new char[] {' '}); | ||
79 | u.ServiceURLs = new Dictionary<string, object>(); | ||
80 | |||
81 | foreach(string url in URLs) | ||
82 | { | ||
83 | string[] parts = url.Split(new char[] {'='}); | ||
84 | |||
85 | if (parts.Length != 2) | ||
86 | continue; | ||
87 | |||
88 | string name = System.Web.HttpUtility.UrlDecode(parts[0]); | ||
89 | string val = System.Web.HttpUtility.UrlDecode(parts[1]); | ||
90 | |||
91 | u.ServiceURLs[name] = val; | ||
92 | } | ||
93 | |||
94 | return u; | ||
95 | } | ||
96 | |||
97 | public UserAccount GetUserAccount(UUID scopeID, string email) | ||
98 | { | ||
99 | UserAccountData[] d; | ||
100 | |||
101 | if (scopeID != UUID.Zero) | ||
102 | { | ||
103 | d = m_Database.Get( | ||
104 | new string[] {"ScopeID", "Email"}, | ||
105 | new string[] {scopeID.ToString(), email}); | ||
106 | } | ||
107 | else | ||
108 | { | ||
109 | d = m_Database.Get( | ||
110 | new string[] {"Email"}, | ||
111 | new string[] {email}); | ||
112 | } | ||
113 | |||
114 | if (d.Length < 1) | ||
115 | return null; | ||
116 | |||
117 | return MakeUserAccount(d[0]); | ||
118 | } | ||
119 | |||
120 | public UserAccount GetUserAccount(UUID scopeID, UUID principalID) | ||
121 | { | ||
122 | UserAccountData[] d; | ||
123 | |||
124 | if (scopeID != UUID.Zero) | ||
125 | { | ||
126 | d = m_Database.Get( | ||
127 | new string[] {"ScopeID", "PrincipalID"}, | ||
128 | new string[] {scopeID.ToString(), principalID.ToString()}); | ||
129 | } | ||
130 | else | ||
131 | { | ||
132 | d = m_Database.Get( | ||
133 | new string[] {"PrincipalID"}, | ||
134 | new string[] {principalID.ToString()}); | ||
135 | } | ||
136 | |||
137 | if (d.Length < 1) | ||
138 | return null; | ||
139 | |||
140 | return MakeUserAccount(d[0]); | ||
141 | } | ||
142 | |||
143 | public bool StoreUserAccount(UserAccount data) | ||
144 | { | ||
145 | UserAccountData d = new UserAccountData(); | ||
146 | |||
147 | d.FirstName = data.FirstName; | ||
148 | d.LastName = data.LastName; | ||
149 | d.PrincipalID = data.PrincipalID; | ||
150 | d.ScopeID = data.ScopeID; | ||
151 | d.Data = new Dictionary<string,string>(); | ||
152 | d.Data["Email"] = data.Email; | ||
153 | d.Data["Created"] = data.Created.ToString(); | ||
154 | |||
155 | List<string> parts = new List<string>(); | ||
156 | |||
157 | foreach (KeyValuePair<string,object> kvp in data.ServiceURLs) | ||
158 | { | ||
159 | string key = System.Web.HttpUtility.UrlEncode(kvp.Key); | ||
160 | string val = System.Web.HttpUtility.UrlEncode(kvp.Value.ToString()); | ||
161 | parts.Add(key + "=" + val); | ||
162 | } | ||
163 | |||
164 | d.Data["ServiceURLs"] = string.Join(" ", parts.ToArray()); | ||
165 | |||
166 | return m_Database.Store(d); | ||
167 | } | ||
168 | |||
169 | public List<UserAccount> GetUserAccounts(UUID scopeID, string query) | ||
170 | { | ||
171 | UserAccountData[] d = m_Database.GetUsers(scopeID, query); | ||
172 | |||
173 | if (d == null) | ||
174 | return new List<UserAccount>(); | ||
175 | |||
176 | List<UserAccount> ret = new List<UserAccount>(); | ||
177 | |||
178 | foreach (UserAccountData data in d) | ||
179 | ret.Add(MakeUserAccount(data)); | ||
180 | |||
181 | return ret; | ||
182 | } | ||
183 | } | ||
184 | } | ||
diff --git a/OpenSim/Services/UserService/UserServiceBase.cs b/OpenSim/Services/UserAccountService/UserAccountServiceBase.cs index fea8b01..70ed594 100644 --- a/OpenSim/Services/UserService/UserServiceBase.cs +++ b/OpenSim/Services/UserAccountService/UserAccountServiceBase.cs | |||
@@ -40,20 +40,29 @@ namespace OpenSim.Services.UserAccountService | |||
40 | 40 | ||
41 | public UserAccountServiceBase(IConfigSource config) : base(config) | 41 | public UserAccountServiceBase(IConfigSource config) : base(config) |
42 | { | 42 | { |
43 | string dllName = String.Empty; | ||
44 | string connString = String.Empty; | ||
45 | string realm = "useraccounts"; | ||
46 | |||
47 | IConfig dbConfig = config.Configs["DatabaseService"]; | ||
48 | if (dbConfig != null) | ||
49 | { | ||
50 | dllName = dbConfig.GetString("StorageProvider", String.Empty); | ||
51 | connString = dbConfig.GetString("ConnectionString", String.Empty); | ||
52 | } | ||
53 | |||
43 | IConfig userConfig = config.Configs["UserAccountService"]; | 54 | IConfig userConfig = config.Configs["UserAccountService"]; |
44 | if (userConfig == null) | 55 | if (userConfig == null) |
45 | throw new Exception("No UserAccountService configuration"); | 56 | throw new Exception("No UserAccountService configuration"); |
46 | 57 | ||
47 | string dllName = userConfig.GetString("StorageProvider", | 58 | dllName = userConfig.GetString("StorageProvider", dllName); |
48 | String.Empty); | ||
49 | 59 | ||
50 | if (dllName == String.Empty) | 60 | if (dllName == String.Empty) |
51 | throw new Exception("No StorageProvider configured"); | 61 | throw new Exception("No StorageProvider configured"); |
52 | 62 | ||
53 | string connString = userConfig.GetString("ConnectionString", | 63 | connString = userConfig.GetString("ConnectionString", connString); |
54 | String.Empty); | ||
55 | 64 | ||
56 | string realm = userConfig.GetString("Realm", "users"); | 65 | realm = userConfig.GetString("Realm", realm); |
57 | 66 | ||
58 | m_Database = LoadPlugin<IUserAccountData>(dllName, new Object[] {connString, realm}); | 67 | m_Database = LoadPlugin<IUserAccountData>(dllName, new Object[] {connString, realm}); |
59 | 68 | ||
diff --git a/OpenSim/Tests/Clients/Presence/OpenSim.Server.ini b/OpenSim/Tests/Clients/Presence/OpenSim.Server.ini new file mode 100644 index 0000000..47e73f9 --- /dev/null +++ b/OpenSim/Tests/Clients/Presence/OpenSim.Server.ini | |||
@@ -0,0 +1,33 @@ | |||
1 | ; * Run a ROBUST server shell like this, from bin: | ||
2 | ; * $ OpenSim.Server.exe -inifile ../OpenSim/Tests/Clients/Presence/OpenSim.Server.ini | ||
3 | ; * | ||
4 | ; * Then run this client like this, from bin: | ||
5 | ; * $ OpenSim.Tests.Clients.PresenceClient.exe | ||
6 | ; * | ||
7 | ; * | ||
8 | |||
9 | [Startup] | ||
10 | ServiceConnectors = "OpenSim.Server.Handlers.dll:PresenceServiceConnector" | ||
11 | |||
12 | ; * This is common for all services, it's the network setup for the entire | ||
13 | ; * server instance | ||
14 | ; * | ||
15 | [Network] | ||
16 | port = 8003 | ||
17 | |||
18 | ; * The following are for the remote console | ||
19 | ; * They have no effect for the local or basic console types | ||
20 | ; * Leave commented to diable logins to the console | ||
21 | ;ConsoleUser = Test | ||
22 | ;ConsolePass = secret | ||
23 | |||
24 | ; * As an example, the below configuration precisely mimicks the legacy | ||
25 | ; * asset server. It is read by the asset IN connector (defined above) | ||
26 | ; * and it then loads the OUT connector (a local database module). That, | ||
27 | ; * in turn, reads the asset loader and database connection information | ||
28 | ; * | ||
29 | [PresenceService] | ||
30 | LocalServiceModule = "OpenSim.Services.PresenceService.dll:PresenceService" | ||
31 | StorageProvider = "OpenSim.Data.MySQL.dll" | ||
32 | ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=opensim123;" | ||
33 | |||
diff --git a/OpenSim/Tests/Clients/Presence/PresenceClient.cs b/OpenSim/Tests/Clients/Presence/PresenceClient.cs new file mode 100644 index 0000000..3416804 --- /dev/null +++ b/OpenSim/Tests/Clients/Presence/PresenceClient.cs | |||
@@ -0,0 +1,128 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using System.Reflection; | ||
32 | |||
33 | using OpenMetaverse; | ||
34 | using log4net; | ||
35 | using log4net.Appender; | ||
36 | using log4net.Layout; | ||
37 | |||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Services.Interfaces; | ||
40 | using OpenSim.Services.Connectors; | ||
41 | |||
42 | namespace OpenSim.Tests.Clients.PresenceClient | ||
43 | { | ||
44 | public class PresenceClient | ||
45 | { | ||
46 | private static readonly ILog m_log = | ||
47 | LogManager.GetLogger( | ||
48 | MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | public static void Main(string[] args) | ||
51 | { | ||
52 | ConsoleAppender consoleAppender = new ConsoleAppender(); | ||
53 | consoleAppender.Layout = | ||
54 | new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"); | ||
55 | log4net.Config.BasicConfigurator.Configure(consoleAppender); | ||
56 | |||
57 | string serverURI = "http://127.0.0.1:8003"; | ||
58 | PresenceServicesConnector m_Connector = new PresenceServicesConnector(serverURI); | ||
59 | |||
60 | UUID user1 = UUID.Random(); | ||
61 | UUID session1 = UUID.Random(); | ||
62 | UUID region1 = UUID.Random(); | ||
63 | |||
64 | bool success = m_Connector.LoginAgent(user1.ToString(), session1, UUID.Zero); | ||
65 | if (success) | ||
66 | m_log.InfoFormat("[PRESENCE CLIENT]: Successfully logged in user {0} with session {1}", user1, session1); | ||
67 | else | ||
68 | m_log.InfoFormat("[PRESENCE CLIENT]: failed to login user {0}", user1); | ||
69 | |||
70 | System.Console.WriteLine("\n"); | ||
71 | |||
72 | PresenceInfo pinfo = m_Connector.GetAgent(session1); | ||
73 | if (pinfo == null) | ||
74 | m_log.InfoFormat("[PRESENCE CLIENT]: Unable to retrieve presence for {0}", user1); | ||
75 | else | ||
76 | m_log.InfoFormat("[PRESENCE CLIENT]: Presence retrieved correctly: userID={0}; Online={1}; regionID={2}; homeRegion={3}", | ||
77 | pinfo.UserID, pinfo.Online, pinfo.RegionID, pinfo.HomeRegionID); | ||
78 | |||
79 | System.Console.WriteLine("\n"); | ||
80 | success = m_Connector.ReportAgent(session1, region1, new Vector3(128, 128, 128), new Vector3(4, 5, 6)); | ||
81 | if (success) | ||
82 | m_log.InfoFormat("[PRESENCE CLIENT]: Successfully reported session {0} in region {1}", user1, region1); | ||
83 | else | ||
84 | m_log.InfoFormat("[PRESENCE CLIENT]: failed to report session {0}", session1); | ||
85 | pinfo = m_Connector.GetAgent(session1); | ||
86 | if (pinfo == null) | ||
87 | m_log.InfoFormat("[PRESENCE CLIENT]: Unable to retrieve presence for {0} for second time", user1); | ||
88 | else | ||
89 | m_log.InfoFormat("[PRESENCE CLIENT]: Presence retrieved correctly: userID={0}; Online={1}; regionID={2}; homeRegion={3}", | ||
90 | pinfo.UserID, pinfo.Online, pinfo.RegionID, pinfo.HomeRegionID); | ||
91 | |||
92 | System.Console.WriteLine("\n"); | ||
93 | success = m_Connector.SetHomeLocation(user1.ToString(), region1, new Vector3(128, 128, 128), new Vector3(4, 5, 6)); | ||
94 | if (success) | ||
95 | m_log.InfoFormat("[PRESENCE CLIENT]: Successfully set home for user {0} in region {1}", user1, region1); | ||
96 | else | ||
97 | m_log.InfoFormat("[PRESENCE CLIENT]: failed to set home for user {0}", user1); | ||
98 | pinfo = m_Connector.GetAgent(session1); | ||
99 | if (pinfo == null) | ||
100 | m_log.InfoFormat("[PRESENCE CLIENT]: Unable to retrieve presence for {0} for third time", user1); | ||
101 | else | ||
102 | m_log.InfoFormat("[PRESENCE CLIENT]: Presence retrieved correctly: userID={0}; Online={1}; regionID={2}; homeRegion={3}", | ||
103 | pinfo.UserID, pinfo.Online, pinfo.RegionID, pinfo.HomeRegionID); | ||
104 | |||
105 | System.Console.WriteLine("\n"); | ||
106 | success = m_Connector.LogoutAgent(session1); | ||
107 | if (success) | ||
108 | m_log.InfoFormat("[PRESENCE CLIENT]: Successfully logged out user {0}", user1); | ||
109 | else | ||
110 | m_log.InfoFormat("[PRESENCE CLIENT]: failed to logout user {0}", user1); | ||
111 | pinfo = m_Connector.GetAgent(session1); | ||
112 | if (pinfo == null) | ||
113 | m_log.InfoFormat("[PRESENCE CLIENT]: Unable to retrieve presence for {0} for fourth time", user1); | ||
114 | else | ||
115 | m_log.InfoFormat("[PRESENCE CLIENT]: Presence retrieved correctly: userID={0}; Online={1}; regionID={2}; homeRegion={3}", | ||
116 | pinfo.UserID, pinfo.Online, pinfo.RegionID, pinfo.HomeRegionID); | ||
117 | |||
118 | System.Console.WriteLine("\n"); | ||
119 | success = m_Connector.ReportAgent(session1, UUID.Random(), Vector3.Zero, Vector3.Zero); | ||
120 | if (success) | ||
121 | m_log.InfoFormat("[PRESENCE CLIENT]: Report agent succeeded, but this is wrong"); | ||
122 | else | ||
123 | m_log.InfoFormat("[PRESENCE CLIENT]: failed to report agent, as it should because user is not logged in"); | ||
124 | |||
125 | } | ||
126 | |||
127 | } | ||
128 | } | ||
diff --git a/OpenSim/Tests/Clients/UserAccounts/OpenSim.Server.ini b/OpenSim/Tests/Clients/UserAccounts/OpenSim.Server.ini new file mode 100644 index 0000000..eb1f473 --- /dev/null +++ b/OpenSim/Tests/Clients/UserAccounts/OpenSim.Server.ini | |||
@@ -0,0 +1,33 @@ | |||
1 | ; * Run a ROBUST server shell like this, from bin: | ||
2 | ; * $ OpenSim.Server.exe -inifile ../OpenSim/Tests/Clients/Presence/OpenSim.Server.ini | ||
3 | ; * | ||
4 | ; * Then run this client like this, from bin: | ||
5 | ; * $ OpenSim.Tests.Clients.UserAccountClient.exe | ||
6 | ; * | ||
7 | ; * | ||
8 | |||
9 | [Startup] | ||
10 | ServiceConnectors = "OpenSim.Server.Handlers.dll:UserAccountServiceConnector" | ||
11 | |||
12 | ; * This is common for all services, it's the network setup for the entire | ||
13 | ; * server instance | ||
14 | ; * | ||
15 | [Network] | ||
16 | port = 8003 | ||
17 | |||
18 | ; * The following are for the remote console | ||
19 | ; * They have no effect for the local or basic console types | ||
20 | ; * Leave commented to diable logins to the console | ||
21 | ;ConsoleUser = Test | ||
22 | ;ConsolePass = secret | ||
23 | |||
24 | ; * As an example, the below configuration precisely mimicks the legacy | ||
25 | ; * asset server. It is read by the asset IN connector (defined above) | ||
26 | ; * and it then loads the OUT connector (a local database module). That, | ||
27 | ; * in turn, reads the asset loader and database connection information | ||
28 | ; * | ||
29 | [UserAccountService] | ||
30 | LocalServiceModule = "OpenSim.Services.UserAccountService.dll:UserAccountService" | ||
31 | StorageProvider = "OpenSim.Data.MySQL.dll" | ||
32 | ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=opensim123;" | ||
33 | |||
diff --git a/OpenSim/Tests/Clients/UserAccounts/UserAccountsClient.cs b/OpenSim/Tests/Clients/UserAccounts/UserAccountsClient.cs new file mode 100644 index 0000000..56195b1 --- /dev/null +++ b/OpenSim/Tests/Clients/UserAccounts/UserAccountsClient.cs | |||
@@ -0,0 +1,120 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using System.Reflection; | ||
32 | |||
33 | using OpenMetaverse; | ||
34 | using log4net; | ||
35 | using log4net.Appender; | ||
36 | using log4net.Layout; | ||
37 | |||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Services.Interfaces; | ||
40 | using OpenSim.Services.Connectors; | ||
41 | |||
42 | namespace OpenSim.Tests.Clients.PresenceClient | ||
43 | { | ||
44 | public class UserAccountsClient | ||
45 | { | ||
46 | private static readonly ILog m_log = | ||
47 | LogManager.GetLogger( | ||
48 | MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | public static void Main(string[] args) | ||
51 | { | ||
52 | ConsoleAppender consoleAppender = new ConsoleAppender(); | ||
53 | consoleAppender.Layout = | ||
54 | new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"); | ||
55 | log4net.Config.BasicConfigurator.Configure(consoleAppender); | ||
56 | |||
57 | string serverURI = "http://127.0.0.1:8003"; | ||
58 | UserAccountServicesConnector m_Connector = new UserAccountServicesConnector(serverURI); | ||
59 | |||
60 | UUID user1 = UUID.Random(); | ||
61 | string first = "Completely"; | ||
62 | string last = "Clueless"; | ||
63 | string email = "foo@bar.com"; | ||
64 | |||
65 | UserAccount account = new UserAccount(user1); | ||
66 | account.FirstName = first; | ||
67 | account.LastName = last; | ||
68 | account.Email = email; | ||
69 | account.ServiceURLs = new Dictionary<string, object>(); | ||
70 | account.ServiceURLs.Add("InventoryServerURI", "http://cnn.com"); | ||
71 | account.ServiceURLs.Add("AssetServerURI", "http://cnn.com"); | ||
72 | |||
73 | bool success = m_Connector.StoreUserAccount(account); | ||
74 | if (success) | ||
75 | m_log.InfoFormat("[USER CLIENT]: Successfully created account for user {0} {1}", account.FirstName, account.LastName); | ||
76 | else | ||
77 | m_log.InfoFormat("[USER CLIENT]: failed to create user {0} {1}", account.FirstName, account.LastName); | ||
78 | |||
79 | System.Console.WriteLine("\n"); | ||
80 | |||
81 | account = m_Connector.GetUserAccount(UUID.Zero, user1); | ||
82 | if (account == null) | ||
83 | m_log.InfoFormat("[USER CLIENT]: Unable to retrieve accouny by UUID for {0}", user1); | ||
84 | else | ||
85 | { | ||
86 | m_log.InfoFormat("[USER CLIENT]: Account retrieved correctly: userID={0}; FirstName={1}; LastName={2}; Email={3}", | ||
87 | account.PrincipalID, account.FirstName, account.LastName, account.Email); | ||
88 | foreach (KeyValuePair<string, object> kvp in account.ServiceURLs) | ||
89 | m_log.DebugFormat("\t {0} -> {1}", kvp.Key, kvp.Value); | ||
90 | } | ||
91 | |||
92 | System.Console.WriteLine("\n"); | ||
93 | |||
94 | account = m_Connector.GetUserAccount(UUID.Zero, first, last); | ||
95 | if (account == null) | ||
96 | m_log.InfoFormat("[USER CLIENT]: Unable to retrieve accouny by name for {0}", user1); | ||
97 | else | ||
98 | { | ||
99 | m_log.InfoFormat("[USER CLIENT]: Account retrieved correctly: userID={0}; FirstName={1}; LastName={2}; Email={3}", | ||
100 | account.PrincipalID, account.FirstName, account.LastName, account.Email); | ||
101 | foreach (KeyValuePair<string, object> kvp in account.ServiceURLs) | ||
102 | m_log.DebugFormat("\t {0} -> {1}", kvp.Key, kvp.Value); | ||
103 | } | ||
104 | |||
105 | System.Console.WriteLine("\n"); | ||
106 | account = m_Connector.GetUserAccount(UUID.Zero, email); | ||
107 | if (account == null) | ||
108 | m_log.InfoFormat("[USER CLIENT]: Unable to retrieve accouny by email for {0}", user1); | ||
109 | else | ||
110 | { | ||
111 | m_log.InfoFormat("[USER CLIENT]: Account retrieved correctly: userID={0}; FirstName={1}; LastName={2}; Email={3}", | ||
112 | account.PrincipalID, account.FirstName, account.LastName, account.Email); | ||
113 | foreach (KeyValuePair<string, object> kvp in account.ServiceURLs) | ||
114 | m_log.DebugFormat("\t {0} -> {1}", kvp.Key, kvp.Value); | ||
115 | } | ||
116 | |||
117 | } | ||
118 | |||
119 | } | ||
120 | } | ||
diff --git a/bin/OpenSim.Server.ini.example b/bin/OpenSim.Server.ini.example index f3d222f..b93bbd6 100644 --- a/bin/OpenSim.Server.ini.example +++ b/bin/OpenSim.Server.ini.example | |||
@@ -1,21 +1,22 @@ | |||
1 | ; * The startup section lists all the connectors to start up in this server | 1 | ; * The startup section lists all the connectors to start up in this server |
2 | ; * instance. This may be only one, or it may be the entire server suite. | 2 | ; * instance. This may be only one, or it may be the entire server suite. |
3 | ; * Multiple connectors should be seaprated by commas. | 3 | ; * Multiple connectors should be seaprated by commas. |
4 | ; * The startup section lists all the connectors to start up in this server | ||
5 | ; * instance. This may be only one, or it may be the entire server suite. | ||
6 | ; * Multiple connectors should be seaprated by commas. | ||
4 | ; * | 7 | ; * |
5 | ; * These are the IN connectors the server uses, the in connectors | 8 | ; * These are the IN connectors the server uses, the in connectors |
6 | ; * read this config file and load the needed OUT and database connectors | 9 | ; * read this config file and load the needed service and database connectors |
7 | ; * | 10 | ; * |
8 | ; * Add "OpenSim.Server.Handlers.dll:AuthenticationServiceConnector" to | ||
9 | ; * enable the experimental authentication service | ||
10 | ; * | 11 | ; * |
11 | [Startup] | 12 | [Startup] |
12 | ServiceConnectors = "OpenSim.Server.Handlers.dll:AssetServiceConnector,OpenSim.Server.Handlers.dll:InventoryServiceInConnector,OpenSim.Server.Handlers.dll:FreeswitchServerConnector,OpenSim.Server.Handlers.dll:GridServiceConnector" | 13 | ServiceConnectors = "OpenSim.Server.Handlers.dll:AssetServiceConnector,OpenSim.Server.Handlers.dll:InventoryServiceInConnector,OpenSim.Server.Handlers.dll:FreeswitchServerConnector,OpenSim.Server.Handlers.dll:GridServiceConnector,OpenSim.Server.Handlers.dll:AuthenticationServiceConnector,OpenSim.Server.Handlers.dll:AvatarServiceConnector,OpenSim.Server.Handlers.dll:LLLoginServiceInConnector,OpenSim.Server.Handlers.dll:PresenceServiceConnector,,OpenSim.Server.Handlers.dll:UserAccountServiceConnector" |
13 | 14 | ||
14 | ; * This is common for all services, it's the network setup for the entire | 15 | ; * This is common for all services, it's the network setup for the entire |
15 | ; * server instance | 16 | ; * server instance |
16 | ; * | 17 | ; * |
17 | [Network] | 18 | [Network] |
18 | port = 8003 | 19 | port = 8003 |
19 | 20 | ||
20 | ; * The following are for the remote console | 21 | ; * The following are for the remote console |
21 | ; * They have no effect for the local or basic console types | 22 | ; * They have no effect for the local or basic console types |
@@ -29,25 +30,35 @@ port = 8003 | |||
29 | ; * in turn, reads the asset loader and database connection information | 30 | ; * in turn, reads the asset loader and database connection information |
30 | ; * | 31 | ; * |
31 | [AssetService] | 32 | [AssetService] |
32 | LocalServiceModule = "OpenSim.Services.AssetService.dll:AssetService" | 33 | LocalServiceModule = "OpenSim.Services.AssetService.dll:AssetService" |
33 | DefaultAssetLoader = "OpenSim.Framework.AssetLoader.Filesystem.dll" | 34 | DefaultAssetLoader = "OpenSim.Framework.AssetLoader.Filesystem.dll" |
34 | AssetLoaderArgs = "assets/AssetSets.xml" | 35 | AssetLoaderArgs = "assets/AssetSets.xml" |
35 | StorageProvider = "OpenSim.Data.MySQL.dll" | 36 | StorageProvider = "OpenSim.Data.MySQL.dll" |
36 | ConnectionString = "Data Source=localhost;Database=grid;User ID=grid;Password=grid;" | 37 | ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=opensim123;" |
37 | 38 | ||
38 | ; * This configuration loads the inventory server modules. It duplicates | 39 | ; * This configuration loads the inventory server modules. It duplicates |
39 | ; * the function of the legacy inventory server | 40 | ; * the function of the legacy inventory server |
40 | ; * | 41 | ; * |
41 | [InventoryService] | 42 | [InventoryService] |
42 | LocalServiceModule = "OpenSim.Services.InventoryService.dll:InventoryService" | 43 | LocalServiceModule = "OpenSim.Services.InventoryService.dll:InventoryService" |
43 | UserServerURI = "http://127.0.0.1:8002" | 44 | UserServerURI = "http://127.0.0.1:8002" |
44 | SessionAuthentication = "false" | 45 | SessionAuthentication = "false" |
45 | StorageProvider = "OpenSim.Data.MySQL.dll" | 46 | StorageProvider = "OpenSim.Data.MySQL.dll" |
46 | ConnectionString = "Data Source=localhost;Database=grid;User ID=grid;Password=grid;" | 47 | ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=opensim123;" |
48 | |||
49 | ; * This is the new style grid service. | ||
50 | ; * "Realm" is the table that is used for user lookup. | ||
51 | ; * It defaults to "regions", which uses the legacy tables | ||
52 | ; * | ||
53 | [GridService] | ||
54 | LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" | ||
55 | StorageProvider = "OpenSim.Data.MySQL.dll:MySqlRegionData" | ||
56 | ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=opensim123;" | ||
57 | Realm = "regions" | ||
47 | 58 | ||
48 | ; * This is the configuration for the freeswitch server in grid mode | 59 | ; * This is the configuration for the freeswitch server in grid mode |
49 | [FreeswitchService] | 60 | [FreeswitchService] |
50 | LocalServiceModule = "OpenSim.Services.FreeswitchService.dll:FreeswitchService" | 61 | LocalServiceModule = "OpenSim.Services.FreeswitchService.dll:FreeswitchService" |
51 | 62 | ||
52 | ; * This is the new style authentication service. Currently, only MySQL | 63 | ; * This is the new style authentication service. Currently, only MySQL |
53 | ; * is implemented. "Realm" is the table that is used for user lookup. | 64 | ; * is implemented. "Realm" is the table that is used for user lookup. |
@@ -55,27 +66,39 @@ LocalServiceModule = "OpenSim.Services.FreeswitchService.dll:FreeswitchService" | |||
55 | ; * as an authentication source. | 66 | ; * as an authentication source. |
56 | ; * | 67 | ; * |
57 | [AuthenticationService] | 68 | [AuthenticationService] |
58 | AuthenticationServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" | 69 | AuthenticationServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" |
59 | StorageProvider = "OpenSim.Data.MySQL.dll" | 70 | StorageProvider = "OpenSim.Data.MySQL.dll" |
60 | ConnectionString = "Data Source=localhost;Database=grid;User ID=grid;Password=grid;" | 71 | ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=opensim123;" |
61 | ; Realm = "users" | ||
62 | 72 | ||
63 | ; * This is the new style user service. | 73 | ; * This is the new style user service. |
64 | ; * "Realm" is the table that is used for user lookup. | 74 | ; * "Realm" is the table that is used for user lookup. |
65 | ; * It defaults to "users", which uses the legacy tables | 75 | ; * It defaults to "users", which uses the legacy tables |
66 | ; * | 76 | ; * |
67 | [UserAccountService] | 77 | [UserAccountService] |
68 | AuthenticationServiceModule = "OpenSim.Services.UserService.dll:UserAccountService" | 78 | AuthenticationServiceModule = "OpenSim.Services.UserService.dll:UserAccountService" |
69 | StorageProvider = "OpenSim.Data.MySQL.dll" | 79 | LocalServiceModule = "OpenSim.Services.UserAccountService.dll:UserAccountService" |
70 | ConnectionString = "Data Source=localhost;Database=grid;User ID=grid;Password=grid;" | 80 | StorageProvider = "OpenSim.Data.MySQL.dll" |
71 | ; Realm = "users" | 81 | ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=opensim123;" |
82 | ; Realm = "useraccounts" | ||
72 | 83 | ||
73 | ; * This is the new style grid service. | 84 | [PresenceService] |
74 | ; * "Realm" is the table that is used for user lookup. | 85 | LocalServiceModule = "OpenSim.Services.PresenceService.dll:PresenceService" |
75 | ; * It defaults to "regions", which uses the legacy tables | 86 | StorageProvider = "OpenSim.Data.MySQL.dll" |
76 | ; * | 87 | ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=opensim123;" |
77 | [GridService] | 88 | |
78 | LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" | 89 | [LibraryService] |
79 | StorageProvider = "OpenSim.Data.MySQL.dll:MySqlRegionData" | 90 | LibraryName = "OpenSim Library" |
80 | ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=grid;" | 91 | DefaultLibrary = "./inventory/Libraries.xml" |
81 | Realm = "regions" | 92 | |
93 | [LoginService] | ||
94 | LocalServiceModule = "OpenSim.Services.LLLoginService.dll:LLLoginService" | ||
95 | UserAccountService = "OpenSim.Services.UserAccountService.dll:UserAccountService" | ||
96 | AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" | ||
97 | InventoryService = "OpenSim.Services.InventoryService.dll:InventoryService" | ||
98 | PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService" | ||
99 | GridService = "OpenSim.Services.GridService.dll:GridService" | ||
100 | SimulationService ="OpenSim.Services.Connectors.dll:SimulationServiceConnector" | ||
101 | LibraryService = "OpenSim.Services.InventoryService.dll:LibraryService" | ||
102 | |||
103 | DefaultRegion = "OpenSim Test" | ||
104 | WelcomeMessage = "Welcome, Avatar!" | ||
diff --git a/bin/config-include/Grid.ini b/bin/config-include/Grid.ini index 5b19130..ef8008c 100644 --- a/bin/config-include/Grid.ini +++ b/bin/config-include/Grid.ini | |||
@@ -10,15 +10,21 @@ | |||
10 | [Modules] | 10 | [Modules] |
11 | AssetServices = "RemoteAssetServicesConnector" | 11 | AssetServices = "RemoteAssetServicesConnector" |
12 | InventoryServices = "RemoteInventoryServicesConnector" | 12 | InventoryServices = "RemoteInventoryServicesConnector" |
13 | AuthorizationServices = "RemoteAuthorizationServicesConnector" | ||
14 | NeighbourServices = "RemoteNeighbourServicesConnector" | ||
15 | GridServices = "RemoteGridServicesConnector" | 13 | GridServices = "RemoteGridServicesConnector" |
16 | NeighbourServiceInConnector = true | 14 | NeighbourServices = "RemoteNeighbourServicesConnector" |
15 | AuthorizationServices = "RemoteAuthorizationServicesConnector" | ||
16 | PresenceServices = "RemotePresenceServicesConnector" | ||
17 | UserAccountServices = "RemoteUserAccountServicesConnector" | ||
18 | SimulationServices = "RemoteSimulationConnectorModule" | ||
17 | LandServiceInConnector = true | 19 | LandServiceInConnector = true |
18 | LLProxyLoginModule = true | 20 | NeighbourServiceInConnector = true |
21 | SimulationServiceInConnector = true | ||
19 | 22 | ||
20 | [GridService] | 23 | [GridService] |
21 | LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" | 24 | LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" |
22 | ; for the LocalGridServicesConnector which is used by the Remote one | 25 | ; for the LocalGridServicesConnector which is used by the Remote one |
23 | StorageProvider = "OpenSim.Data.Null.dll:NullRegionData" | 26 | StorageProvider = "OpenSim.Data.Null.dll:NullRegionData" |
24 | \ No newline at end of file | 27 | |
28 | ; Temporary... | ||
29 | [Communications] | ||
30 | InterregionComms = "LocalComms" \ No newline at end of file | ||
diff --git a/bin/config-include/GridCommon.ini.example b/bin/config-include/GridCommon.ini.example index 6da0f1e..6a65523 100644 --- a/bin/config-include/GridCommon.ini.example +++ b/bin/config-include/GridCommon.ini.example | |||
@@ -21,6 +21,24 @@ | |||
21 | ; | 21 | ; |
22 | GridServerURI = "http://mygridserver.com:8003" | 22 | GridServerURI = "http://mygridserver.com:8003" |
23 | 23 | ||
24 | [PresenceService] | ||
25 | ; | ||
26 | ; change this to your grid-wide presence server | ||
27 | ; | ||
28 | PresenceServerURI = "http://mygridserver.com:8003" | ||
29 | |||
30 | [UserAccountService] | ||
31 | ; | ||
32 | ; change this to your grid-wide user accounts server | ||
33 | ; | ||
34 | UserAccountServerURI = "http://mygridserver.com:8003" | ||
35 | |||
36 | [AuthenticationService] | ||
37 | ; | ||
38 | ; change this to your grid-wide authentication server | ||
39 | ; | ||
40 | AuthenticationServerURI = "http://mygridserver.com:8003" | ||
41 | |||
24 | [Modules] | 42 | [Modules] |
25 | ;; Choose 0 or 1 cache modules, and the corresponding config file, if it exists. | 43 | ;; Choose 0 or 1 cache modules, and the corresponding config file, if it exists. |
26 | ;; Copy the config .example file into your own .ini file and change configs there | 44 | ;; Copy the config .example file into your own .ini file and change configs there |
diff --git a/bin/config-include/GridHypergrid.ini b/bin/config-include/GridHypergrid.ini index a5fe6e9..512e88f 100644 --- a/bin/config-include/GridHypergrid.ini +++ b/bin/config-include/GridHypergrid.ini | |||
@@ -13,12 +13,21 @@ | |||
13 | [Modules] | 13 | [Modules] |
14 | AssetServices = "HGAssetBroker" | 14 | AssetServices = "HGAssetBroker" |
15 | InventoryServices = "HGInventoryBroker" | 15 | InventoryServices = "HGInventoryBroker" |
16 | NeighbourServices = "RemoteNeighbourServicesConnector" | ||
17 | GridServices = "HGGridServicesConnector" | 16 | GridServices = "HGGridServicesConnector" |
18 | NeighbourServiceInConnector = true | 17 | NeighbourServices = "RemoteNeighbourServicesConnector" |
18 | AuthenticationServices = "RemoteAuthenticationServicesConnector" | ||
19 | AuthorizationServices = "LocalAuthorizationServicesConnector" | ||
20 | PresenceServices = "RemotePresenceServicesConnector" | ||
21 | UserAccountServices = "RemoteUserAccountServicesConnector" | ||
22 | SimulationServices = "RemoteSimulationConnectorModule" | ||
19 | LandServiceInConnector = true | 23 | LandServiceInConnector = true |
24 | NeighbourServiceInConnector = true | ||
20 | HypergridServiceInConnector = true | 25 | HypergridServiceInConnector = true |
21 | LLProxyLoginModule = true | 26 | SimulationServiceInConnector = true |
27 | InventoryServiceInConnector = false | ||
28 | AssetServiceInConnector = false | ||
29 | LibraryModule = false | ||
30 | LLLoginServiceInConnector = false | ||
22 | 31 | ||
23 | [AssetService] | 32 | [AssetService] |
24 | LocalGridAssetService = "OpenSim.Services.Connectors.dll:AssetServicesConnector" | 33 | LocalGridAssetService = "OpenSim.Services.Connectors.dll:AssetServicesConnector" |
@@ -30,8 +39,12 @@ | |||
30 | 39 | ||
31 | [GridService] | 40 | [GridService] |
32 | ; for the HGGridServicesConnector to instantiate | 41 | ; for the HGGridServicesConnector to instantiate |
33 | GridServiceConnectorModule = "OpenSim.Region.CoreModules.dll:RemoteGridServicesConnector" | 42 | GridServiceConnectorModule = "OpenSim.Region.CoreModules.dll:RemoteGridServicesConnector" |
34 | ; RemoteGridServicesConnector instantiates a LocalGridServicesConnector, | 43 | ; RemoteGridServicesConnector instantiates a LocalGridServicesConnector, |
35 | ; which in turn uses this | 44 | ; which in turn uses this |
36 | LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" | 45 | LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" |
37 | StorageProvider = "OpenSim.Data.Null.dll:NullRegionData" | 46 | StorageProvider = "OpenSim.Data.Null.dll:NullRegionData" |
47 | |||
48 | ; Temporary... | ||
49 | [Communications] | ||
50 | InterregionComms = "LocalComms" \ No newline at end of file | ||
diff --git a/bin/config-include/Standalone.ini b/bin/config-include/Standalone.ini index cdfdf4b..e881e30 100644 --- a/bin/config-include/Standalone.ini +++ b/bin/config-include/Standalone.ini | |||
@@ -13,6 +13,8 @@ | |||
13 | NeighbourServices = "LocalNeighbourServicesConnector" | 13 | NeighbourServices = "LocalNeighbourServicesConnector" |
14 | AuthorizationServices = "LocalAuthorizationServicesConnector" | 14 | AuthorizationServices = "LocalAuthorizationServicesConnector" |
15 | GridServices = "LocalGridServicesConnector" | 15 | GridServices = "LocalGridServicesConnector" |
16 | PresenceServices = "LocalPresenceServicesConnector" | ||
17 | UserAccountServices = "LocalUserAccountServicesConnector" | ||
16 | LibraryModule = true | 18 | LibraryModule = true |
17 | 19 | ||
18 | [AssetService] | 20 | [AssetService] |
@@ -28,3 +30,8 @@ | |||
28 | LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" | 30 | LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" |
29 | Realm = "regions" | 31 | Realm = "regions" |
30 | 32 | ||
33 | [PresenceService] | ||
34 | LocalServiceModule = "OpenSim.Services.PresenceService.dll:PresenceService" | ||
35 | |||
36 | [UserAccountService] | ||
37 | LocalServiceModule = "OpenSim.Services.UserAccountService.dll:UserAccountService" | ||
diff --git a/bin/config-include/StandaloneHypergrid.ini b/bin/config-include/StandaloneHypergrid.ini index 909286c..5e54cde 100644 --- a/bin/config-include/StandaloneHypergrid.ini +++ b/bin/config-include/StandaloneHypergrid.ini | |||
@@ -14,14 +14,19 @@ | |||
14 | AssetServices = "HGAssetBroker" | 14 | AssetServices = "HGAssetBroker" |
15 | InventoryServices = "HGInventoryBroker" | 15 | InventoryServices = "HGInventoryBroker" |
16 | NeighbourServices = "RemoteNeighbourServicesConnector" | 16 | NeighbourServices = "RemoteNeighbourServicesConnector" |
17 | AuthenticationServices = "LocalAuthenticationServicesConnector" | ||
17 | AuthorizationServices = "LocalAuthorizationServicesConnector" | 18 | AuthorizationServices = "LocalAuthorizationServicesConnector" |
18 | GridServices = "HGGridServicesConnector" | 19 | GridServices = "HGGridServicesConnector" |
20 | PresenceServices = "LocalPresenceServicesConnector" | ||
21 | UserAccountServices = "LocalUserAccountServicesConnector" | ||
22 | SimulationServices = "RemoteSimulationConnectorModule" | ||
19 | InventoryServiceInConnector = true | 23 | InventoryServiceInConnector = true |
20 | AssetServiceInConnector = true | 24 | AssetServiceInConnector = true |
21 | HGAuthServiceInConnector = true | 25 | HGAuthServiceInConnector = true |
22 | HypergridServiceInConnector = true | 26 | HypergridServiceInConnector = true |
23 | NeighbourServiceInConnector = true | 27 | NeighbourServiceInConnector = true |
24 | LibraryModule = true | 28 | LibraryModule = true |
29 | LLLoginServiceInConnector = true | ||
25 | 30 | ||
26 | [AssetService] | 31 | [AssetService] |
27 | ; For the AssetServiceInConnector | 32 | ; For the AssetServiceInConnector |
@@ -39,12 +44,16 @@ | |||
39 | LocalGridInventoryService = "OpenSim.Services.InventoryService.dll:InventoryService" | 44 | LocalGridInventoryService = "OpenSim.Services.InventoryService.dll:InventoryService" |
40 | HypergridInventoryService = "OpenSim.Services.Connectors.dll:HGInventoryServiceConnector" | 45 | HypergridInventoryService = "OpenSim.Services.Connectors.dll:HGInventoryServiceConnector" |
41 | 46 | ||
47 | [LibraryService] | ||
48 | LocalServiceModule = "OpenSim.Services.InventoryService.dll:LibraryService" | ||
49 | LibraryName = "OpenSim Library" | ||
50 | DefaultLibrary = "./inventory/Libraries.xml" | ||
51 | |||
42 | [AuthorizationService] | 52 | [AuthorizationService] |
43 | LocalServiceModule = "OpenSim.Services.AuthorizationService.dll:AuthorizationService" | 53 | LocalServiceModule = "OpenSim.Services.AuthorizationService.dll:AuthorizationService" |
44 | 54 | ||
45 | [AuthenticationService] | 55 | [AuthenticationService] |
46 | ; For the HGAuthServiceInConnector | 56 | LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" |
47 | LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:HGAuthenticationService" | ||
48 | 57 | ||
49 | [GridService] | 58 | [GridService] |
50 | ; for the HGGridServicesConnector to instantiate | 59 | ; for the HGGridServicesConnector to instantiate |
@@ -52,3 +61,21 @@ | |||
52 | ; LocalGridServicesConnector needs this | 61 | ; LocalGridServicesConnector needs this |
53 | LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" | 62 | LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" |
54 | Realm = "regions" | 63 | Realm = "regions" |
64 | |||
65 | [PresenceService] | ||
66 | LocalServiceModule = "OpenSim.Services.PresenceService.dll:PresenceService" | ||
67 | |||
68 | [UserAccountService] | ||
69 | LocalServiceModule = "OpenSim.Services.UserAccountService.dll:UserAccountService" | ||
70 | |||
71 | [LoginService] | ||
72 | LocalServiceModule = "OpenSim.Services.LLLoginService.dll:LLLoginService" | ||
73 | UserAccountService = "OpenSim.Services.UserAccountService.dll:UserAccountService" | ||
74 | AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" | ||
75 | InventoryService = "OpenSim.Services.InventoryService.dll:InventoryService" | ||
76 | PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService" | ||
77 | GridService = "OpenSim.Services.GridService.dll:GridService" | ||
78 | |||
79 | DefaultRegion = "OpenSim Test" | ||
80 | WelcomeMessage = "Welcome, Avatar!" | ||
81 | |||
diff --git a/prebuild.xml b/prebuild.xml index 7881cd7..52177e1 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -646,6 +646,7 @@ | |||
646 | <Reference name="System"/> | 646 | <Reference name="System"/> |
647 | <Reference name="OpenMetaverseTypes.dll"/> | 647 | <Reference name="OpenMetaverseTypes.dll"/> |
648 | <Reference name="OpenMetaverse.dll"/> | 648 | <Reference name="OpenMetaverse.dll"/> |
649 | <Reference name="OpenMetaverse.StructuredData.dll"/> | ||
649 | <Reference name="OpenSim.Framework"/> | 650 | <Reference name="OpenSim.Framework"/> |
650 | <Reference name="OpenSim.Framework.Console"/> | 651 | <Reference name="OpenSim.Framework.Console"/> |
651 | <Reference name="OpenSim.Framework.Servers.HttpServer"/> | 652 | <Reference name="OpenSim.Framework.Servers.HttpServer"/> |
@@ -1038,7 +1039,7 @@ | |||
1038 | </Files> | 1039 | </Files> |
1039 | </Project> | 1040 | </Project> |
1040 | 1041 | ||
1041 | <Project frameworkVersion="v3_5" name="OpenSim.Services.UserService" path="OpenSim/Services/UserService" type="Library"> | 1042 | <Project frameworkVersion="v3_5" name="OpenSim.Services.UserAccountService" path="OpenSim/Services/UserAccountService" type="Library"> |
1042 | <Configuration name="Debug"> | 1043 | <Configuration name="Debug"> |
1043 | <Options> | 1044 | <Options> |
1044 | <OutputPath>../../../bin/</OutputPath> | 1045 | <OutputPath>../../../bin/</OutputPath> |
@@ -1052,6 +1053,7 @@ | |||
1052 | 1053 | ||
1053 | <ReferencePath>../../../bin/</ReferencePath> | 1054 | <ReferencePath>../../../bin/</ReferencePath> |
1054 | <Reference name="System"/> | 1055 | <Reference name="System"/> |
1056 | <Reference name="System.Web"/> | ||
1055 | <Reference name="OpenMetaverseTypes.dll"/> | 1057 | <Reference name="OpenMetaverseTypes.dll"/> |
1056 | <Reference name="OpenMetaverse.dll"/> | 1058 | <Reference name="OpenMetaverse.dll"/> |
1057 | <Reference name="OpenSim.Framework"/> | 1059 | <Reference name="OpenSim.Framework"/> |
@@ -1444,6 +1446,37 @@ | |||
1444 | </Files> | 1446 | </Files> |
1445 | </Project> | 1447 | </Project> |
1446 | 1448 | ||
1449 | <Project frameworkVersion="v3_5" name="OpenSim.Services.AvatarService" path="OpenSim/Services/AvatarService" type="Library"> | ||
1450 | <Configuration name="Debug"> | ||
1451 | <Options> | ||
1452 | <OutputPath>../../../bin/</OutputPath> | ||
1453 | </Options> | ||
1454 | </Configuration> | ||
1455 | <Configuration name="Release"> | ||
1456 | <Options> | ||
1457 | <OutputPath>../../../bin/</OutputPath> | ||
1458 | </Options> | ||
1459 | </Configuration> | ||
1460 | |||
1461 | <ReferencePath>../../../bin/</ReferencePath> | ||
1462 | <Reference name="System"/> | ||
1463 | <Reference name="OpenMetaverseTypes.dll"/> | ||
1464 | <Reference name="OpenMetaverse.dll"/> | ||
1465 | <Reference name="OpenSim.Framework"/> | ||
1466 | <Reference name="OpenSim.Framework.Console"/> | ||
1467 | <Reference name="OpenSim.Framework.Servers.HttpServer"/> | ||
1468 | <Reference name="OpenSim.Services.Interfaces"/> | ||
1469 | <Reference name="OpenSim.Services.Base"/> | ||
1470 | <Reference name="OpenSim.Services.Connectors"/> | ||
1471 | <Reference name="OpenSim.Data"/> | ||
1472 | <Reference name="Nini.dll" /> | ||
1473 | <Reference name="log4net.dll"/> | ||
1474 | |||
1475 | <Files> | ||
1476 | <Match pattern="*.cs" recurse="true"/> | ||
1477 | </Files> | ||
1478 | </Project> | ||
1479 | |||
1447 | <Project frameworkVersion="v3_5" name="OpenSim.Services.InventoryService" path="OpenSim/Services/InventoryService" type="Library"> | 1480 | <Project frameworkVersion="v3_5" name="OpenSim.Services.InventoryService" path="OpenSim/Services/InventoryService" type="Library"> |
1448 | <Configuration name="Debug"> | 1481 | <Configuration name="Debug"> |
1449 | <Options> | 1482 | <Options> |
@@ -1458,6 +1491,7 @@ | |||
1458 | 1491 | ||
1459 | <ReferencePath>../../../bin/</ReferencePath> | 1492 | <ReferencePath>../../../bin/</ReferencePath> |
1460 | <Reference name="System"/> | 1493 | <Reference name="System"/> |
1494 | <Reference name="System.Xml"/> | ||
1461 | <Reference name="OpenMetaverseTypes.dll"/> | 1495 | <Reference name="OpenMetaverseTypes.dll"/> |
1462 | <Reference name="OpenMetaverse.dll"/> | 1496 | <Reference name="OpenMetaverse.dll"/> |
1463 | <Reference name="OpenSim.Framework"/> | 1497 | <Reference name="OpenSim.Framework"/> |
@@ -1475,6 +1509,39 @@ | |||
1475 | <Match pattern="*.cs" recurse="true"/> | 1509 | <Match pattern="*.cs" recurse="true"/> |
1476 | </Files> | 1510 | </Files> |
1477 | </Project> | 1511 | </Project> |
1512 | |||
1513 | |||
1514 | <Project frameworkVersion="v3_5" name="OpenSim.Services.LLLoginService" path="OpenSim/Services/LLLoginService" type="Library"> | ||
1515 | <Configuration name="Debug"> | ||
1516 | <Options> | ||
1517 | <OutputPath>../../../bin/</OutputPath> | ||
1518 | </Options> | ||
1519 | </Configuration> | ||
1520 | <Configuration name="Release"> | ||
1521 | <Options> | ||
1522 | <OutputPath>../../../bin/</OutputPath> | ||
1523 | </Options> | ||
1524 | </Configuration> | ||
1525 | |||
1526 | <ReferencePath>../../../bin/</ReferencePath> | ||
1527 | <Reference name="System"/> | ||
1528 | <Reference name="OpenSim.Framework"/> | ||
1529 | <Reference name="OpenSim.Framework.Capabilities"/> | ||
1530 | <Reference name="OpenSim.Framework.Servers.HttpServer"/> | ||
1531 | <Reference name="OpenSim.Services.Interfaces"/> | ||
1532 | <Reference name="OpenSim.Services.Base"/> | ||
1533 | <Reference name="OpenSim.Server.Base"/> | ||
1534 | <Reference name="OpenMetaverseTypes.dll"/> | ||
1535 | <Reference name="OpenMetaverse.dll"/> | ||
1536 | <Reference name="OpenMetaverse.StructuredData.dll"/> | ||
1537 | <Reference name="Nini.dll" /> | ||
1538 | <Reference name="log4net.dll"/> | ||
1539 | |||
1540 | <Files> | ||
1541 | <Match pattern="*.cs" recurse="true"/> | ||
1542 | </Files> | ||
1543 | </Project> | ||
1544 | |||
1478 | 1545 | ||
1479 | 1546 | ||
1480 | <Project frameworkVersion="v3_5" name="OpenSim.Server.Handlers" path="OpenSim/Server/Handlers" type="Library"> | 1547 | <Project frameworkVersion="v3_5" name="OpenSim.Server.Handlers" path="OpenSim/Server/Handlers" type="Library"> |
@@ -2939,6 +3006,60 @@ | |||
2939 | </Files> | 3006 | </Files> |
2940 | </Project> | 3007 | </Project> |
2941 | 3008 | ||
3009 | <Project frameworkVersion="v3_5" name="OpenSim.Tests.Clients.PresenceClient" path="OpenSim/Tests/Clients/Presence" type="Exe"> | ||
3010 | <Configuration name="Debug"> | ||
3011 | <Options> | ||
3012 | <OutputPath>../../../../bin/</OutputPath> | ||
3013 | </Options> | ||
3014 | </Configuration> | ||
3015 | <Configuration name="Release"> | ||
3016 | <Options> | ||
3017 | <OutputPath>../../../../bin/</OutputPath> | ||
3018 | </Options> | ||
3019 | </Configuration> | ||
3020 | |||
3021 | <ReferencePath>../../../../bin/</ReferencePath> | ||
3022 | <Reference name="System"/> | ||
3023 | <Reference name="OpenMetaverseTypes.dll"/> | ||
3024 | <Reference name="OpenMetaverse.dll"/> | ||
3025 | <Reference name="OpenSim.Framework"/> | ||
3026 | <Reference name="OpenSim.Services.Interfaces" /> | ||
3027 | <Reference name="OpenSim.Services.Connectors" /> | ||
3028 | <Reference name="Nini.dll" /> | ||
3029 | <Reference name="log4net.dll"/> | ||
3030 | |||
3031 | <Files> | ||
3032 | <Match pattern="*.cs" recurse="true"/> | ||
3033 | </Files> | ||
3034 | </Project> | ||
3035 | |||
3036 | <Project frameworkVersion="v3_5" name="OpenSim.Tests.Clients.UserAccountClient" path="OpenSim/Tests/Clients/UserAccounts" type="Exe"> | ||
3037 | <Configuration name="Debug"> | ||
3038 | <Options> | ||
3039 | <OutputPath>../../../../bin/</OutputPath> | ||
3040 | </Options> | ||
3041 | </Configuration> | ||
3042 | <Configuration name="Release"> | ||
3043 | <Options> | ||
3044 | <OutputPath>../../../../bin/</OutputPath> | ||
3045 | </Options> | ||
3046 | </Configuration> | ||
3047 | |||
3048 | <ReferencePath>../../../../bin/</ReferencePath> | ||
3049 | <Reference name="System"/> | ||
3050 | <Reference name="OpenMetaverseTypes.dll"/> | ||
3051 | <Reference name="OpenMetaverse.dll"/> | ||
3052 | <Reference name="OpenSim.Framework"/> | ||
3053 | <Reference name="OpenSim.Services.Interfaces" /> | ||
3054 | <Reference name="OpenSim.Services.Connectors" /> | ||
3055 | <Reference name="Nini.dll" /> | ||
3056 | <Reference name="log4net.dll"/> | ||
3057 | |||
3058 | <Files> | ||
3059 | <Match pattern="*.cs" recurse="true"/> | ||
3060 | </Files> | ||
3061 | </Project> | ||
3062 | |||
2942 | 3063 | ||
2943 | <!-- Test assemblies --> | 3064 | <!-- Test assemblies --> |
2944 | <Project frameworkVersion="v3_5" name="OpenSim.Tests.Common" path="OpenSim/Tests/Common" type="Library"> | 3065 | <Project frameworkVersion="v3_5" name="OpenSim.Tests.Common" path="OpenSim/Tests/Common" type="Library"> |
@@ -3274,6 +3395,7 @@ | |||
3274 | <Match path="World/Serialiser/Tests" pattern="*.cs" recurse="true" /> | 3395 | <Match path="World/Serialiser/Tests" pattern="*.cs" recurse="true" /> |
3275 | <Match path="World/Terrain/Tests" pattern="*.cs" recurse="true" /> | 3396 | <Match path="World/Terrain/Tests" pattern="*.cs" recurse="true" /> |
3276 | <Match path="ServiceConnectorsOut/Grid/Tests" pattern="*.cs" recurse="true" /> | 3397 | <Match path="ServiceConnectorsOut/Grid/Tests" pattern="*.cs" recurse="true" /> |
3398 | <Match path="ServiceConnectorsOut/Presence/Tests" pattern="*.cs" recurse="true" /> | ||
3277 | </Files> | 3399 | </Files> |
3278 | </Project> | 3400 | </Project> |
3279 | 3401 | ||