aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MySQL/MySQLAvatarData.cs (renamed from OpenSim/Services/UserService/UserService.cs)53
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs (renamed from OpenSim/Services/Connectors/User/UserServiceConnector.cs)92
-rw-r--r--OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs10
-rw-r--r--OpenSim/Services/AvatarService/AvatarService.cs138
-rw-r--r--OpenSim/Services/AvatarService/AvatarServiceBase.cs84
-rw-r--r--OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs10
-rw-r--r--OpenSim/Services/Connectors/Avatar/AvatarServiceConnector.cs317
-rw-r--r--OpenSim/Services/Connectors/Grid/GridServiceConnector.cs16
-rw-r--r--OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs421
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs414
-rw-r--r--OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs277
-rw-r--r--OpenSim/Services/Interfaces/IAvatarService.cs204
-rw-r--r--OpenSim/Services/Interfaces/ILibraryService.cs43
-rw-r--r--OpenSim/Services/Interfaces/ILoginService.cs53
-rw-r--r--OpenSim/Services/Interfaces/IPresenceService.cs68
-rw-r--r--OpenSim/Services/Interfaces/ISimulationService.cs26
-rw-r--r--OpenSim/Services/Interfaces/IUserAccountService.cs123
-rw-r--r--OpenSim/Services/Interfaces/IUserService.cs103
-rw-r--r--OpenSim/Services/InventoryService/LibraryService.cs283
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginResponse.cs971
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs383
-rw-r--r--OpenSim/Services/PresenceService/PresenceService.cs170
-rw-r--r--OpenSim/Services/PresenceService/PresenceServiceBase.cs4
-rw-r--r--OpenSim/Services/UserAccountService/UserAccountService.cs184
-rw-r--r--OpenSim/Services/UserAccountService/UserAccountServiceBase.cs (renamed from OpenSim/Services/UserService/UserServiceBase.cs)19
25 files changed, 4234 insertions, 232 deletions
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
28using System; 28using System;
29using System.Reflection;
30using Nini.Config;
31using OpenSim.Data;
32using OpenSim.Services.Interfaces;
33using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Data;
31using System.Reflection;
32using System.Threading;
33using log4net;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenSim.Framework;
36using MySql.Data.MySqlClient;
35 37
36namespace OpenSim.Services.UserAccountService 38namespace 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/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
28using log4net;
29using System; 28using System;
30using System.Collections.Generic;
31using System.IO;
32using System.Reflection;
33using Nini.Config; 29using Nini.Config;
34using OpenSim.Framework; 30using log4net;
35using OpenSim.Framework.Communications; 31using System.Reflection;
36using OpenSim.Framework.Servers.HttpServer; 32using OpenSim.Region.Framework.Interfaces;
33using OpenSim.Region.Framework.Scenes;
37using OpenSim.Services.Interfaces; 34using OpenSim.Services.Interfaces;
38using OpenMetaverse; 35using OpenSim.Services.Connectors;
39 36
40namespace OpenSim.Services.Connectors 37namespace 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/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
28using System;
29using System.Collections.Generic;
30using System.Net;
31using System.Reflection;
32using Nini.Config;
33using log4net;
34using OpenSim.Framework;
35using OpenSim.Framework.Console;
36using OpenSim.Data;
37using OpenSim.Services.Interfaces;
38using OpenMetaverse;
39
40namespace 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
28using System;
29using System.Reflection;
30using Nini.Config;
31using OpenSim.Framework;
32using OpenSim.Data;
33using OpenSim.Services.Interfaces;
34using OpenSim.Services.Base;
35
36namespace 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
28using log4net;
29using System;
30using System.Collections.Generic;
31using System.IO;
32using System.Reflection;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Servers.HttpServer;
37using OpenSim.Services.Interfaces;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39using IAvatarService = OpenSim.Services.Interfaces.IAvatarService;
40using OpenSim.Server.Base;
41using OpenMetaverse;
42
43namespace 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
28using log4net;
29using System;
30using System.Collections.Generic;
31using System.IO;
32using System.Reflection;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Servers.HttpServer;
37using OpenSim.Services.Interfaces;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39using OpenSim.Server.Base;
40using OpenMetaverse;
41
42namespace 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
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Net;
32using System.Reflection;
33using System.Text;
34
35using OpenSim.Framework;
36using OpenSim.Services.Interfaces;
37using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38
39using OpenMetaverse;
40using OpenMetaverse.StructuredData;
41using log4net;
42using Nini.Config;
43
44namespace 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
28using log4net;
29using System;
30using System.Collections.Generic;
31using System.IO;
32using System.Reflection;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Servers.HttpServer;
37using OpenSim.Server.Base;
38using OpenSim.Services.Interfaces;
39using OpenMetaverse;
40
41namespace 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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31
32using OpenSim.Framework;
33
34using OpenMetaverse;
35
36namespace 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
28using System;
29using System.Collections.Generic;
30
31using OpenSim.Framework;
32using OpenMetaverse;
33
34namespace 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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Net;
32
33using OpenMetaverse.StructuredData;
34
35namespace 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
28using System;
28using OpenSim.Framework; 29using OpenSim.Framework;
29using System.Collections.Generic; 30using System.Collections.Generic;
30using OpenMetaverse; 31using 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;
29using OpenSim.Framework; 29using OpenSim.Framework;
30using OpenMetaverse; 30using OpenMetaverse;
31 31
32using GridRegion = OpenSim.Services.Interfaces.GridRegion;
33
32namespace OpenSim.Services.Interfaces 34namespace 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
28using System;
29using System.Collections.Generic;
30using OpenMetaverse;
31
32namespace 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
28using System.Collections.Generic;
29using OpenMetaverse;
30
31namespace 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
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using System.Xml;
33
34using OpenSim.Framework;
35using OpenSim.Services.Base;
36using OpenSim.Services.Interfaces;
37
38using log4net;
39using Nini.Config;
40using OpenMetaverse;
41
42namespace 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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection;
33
34using OpenSim.Framework;
35using OpenSim.Framework.Capabilities;
36using OpenSim.Services.Interfaces;
37using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38
39using log4net;
40using OpenMetaverse;
41using OpenMetaverse.StructuredData;
42using OSDArray = OpenMetaverse.StructuredData.OSDArray;
43using OSDMap = OpenMetaverse.StructuredData.OSDMap;
44
45namespace 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 @@
1using System;
2using System.Collections.Generic;
3using System.Net;
4using System.Reflection;
5using System.Text.RegularExpressions;
6
7using log4net;
8using Nini.Config;
9using OpenMetaverse;
10
11using OpenSim.Framework;
12using OpenSim.Framework.Capabilities;
13using OpenSim.Server.Base;
14using OpenSim.Services.Interfaces;
15using GridRegion = OpenSim.Services.Interfaces.GridRegion;
16
17namespace 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
28using System;
29using System.Reflection;
30using Nini.Config;
31using OpenSim.Data;
32using OpenSim.Services.Interfaces;
33using System.Collections.Generic;
34using OpenMetaverse;
35
36namespace 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