aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/AssetService/AssetService.cs11
-rw-r--r--OpenSim/Services/AssetService/Properties/AssemblyInfo.cs10
-rw-r--r--OpenSim/Services/AssetService/XAssetService.cs10
-rw-r--r--OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs15
-rw-r--r--OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs98
-rw-r--r--OpenSim/Services/AuthenticationService/Properties/AssemblyInfo.cs10
-rw-r--r--OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs15
-rw-r--r--OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs23
-rw-r--r--OpenSim/Services/AuthorizationService/AuthorizationService.cs3
-rw-r--r--OpenSim/Services/AuthorizationService/Properties/AssemblyInfo.cs10
-rw-r--r--OpenSim/Services/AvatarService/AvatarService.cs4
-rw-r--r--OpenSim/Services/AvatarService/AvatarServiceBase.cs2
-rw-r--r--OpenSim/Services/AvatarService/Properties/AssemblyInfo.cs10
-rw-r--r--OpenSim/Services/Base/Properties/AssemblyInfo.cs10
-rw-r--r--OpenSim/Services/Base/ServiceBase.cs11
-rw-r--r--OpenSim/Services/Connectors/AgentPreferences/AgentPreferencesConnector.cs4
-rw-r--r--OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs458
-rw-r--r--OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs7
-rw-r--r--OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs16
-rw-r--r--OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs4
-rw-r--r--OpenSim/Services/Connectors/Estate/EstateDataConnector.cs8
-rw-r--r--OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs2
-rw-r--r--OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs68
-rw-r--r--OpenSim/Services/Connectors/Grid/GridServicesConnector.cs17
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs23
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs5
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs2
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs30
-rw-r--r--OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs62
-rw-r--r--OpenSim/Services/Connectors/Land/LandServicesConnector.cs29
-rw-r--r--OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs66
-rw-r--r--OpenSim/Services/Connectors/MuteList/MuteListServicesConnector.cs183
-rw-r--r--OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs10
-rw-r--r--OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs72
-rw-r--r--OpenSim/Services/Connectors/Properties/AssemblyInfo.cs10
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs52
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs6
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs11
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs16
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs18
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs16
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs21
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs37
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs22
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs14
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs16
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs71
-rw-r--r--OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs99
-rw-r--r--OpenSim/Services/EstateService/EstateDataService.cs8
-rw-r--r--OpenSim/Services/FSAssetService/FSAssetService.cs211
-rw-r--r--OpenSim/Services/FreeswitchService/FreeswitchService.cs58
-rw-r--r--OpenSim/Services/FreeswitchService/Properties/AssemblyInfo.cs10
-rw-r--r--OpenSim/Services/Friends/Properties/AssemblyInfo.cs10
-rw-r--r--OpenSim/Services/GridService/GridService.cs295
-rw-r--r--OpenSim/Services/GridService/GridServiceBase.cs2
-rw-r--r--OpenSim/Services/GridService/HypergridLinker.cs113
-rw-r--r--OpenSim/Services/GridService/Properties/AssemblyInfo.cs10
-rw-r--r--OpenSim/Services/HypergridService/GatekeeperService.cs177
-rw-r--r--OpenSim/Services/HypergridService/HGAssetService.cs2
-rw-r--r--OpenSim/Services/HypergridService/HGFSAssetService.cs2
-rw-r--r--OpenSim/Services/HypergridService/HGFriendsService.cs2
-rw-r--r--OpenSim/Services/HypergridService/HGInstantMessageService.cs2
-rw-r--r--OpenSim/Services/HypergridService/HGInventoryService.cs12
-rw-r--r--OpenSim/Services/HypergridService/HGRemoteAssetService.cs240
-rw-r--r--OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs20
-rw-r--r--OpenSim/Services/HypergridService/Properties/AssemblyInfo.cs10
-rw-r--r--OpenSim/Services/HypergridService/UserAccountCache.cs12
-rw-r--r--OpenSim/Services/HypergridService/UserAgentService.cs25
-rw-r--r--OpenSim/Services/Interfaces/IAgentPreferencesService.cs4
-rw-r--r--OpenSim/Services/Interfaces/IAssetService.cs6
-rw-r--r--OpenSim/Services/Interfaces/IAttachmentsService.cs38
-rw-r--r--OpenSim/Services/Interfaces/IAuthenticationService.cs3
-rw-r--r--OpenSim/Services/Interfaces/IAuthorizationService.cs26
-rw-r--r--OpenSim/Services/Interfaces/IAvatarService.cs15
-rw-r--r--OpenSim/Services/Interfaces/IEstateDataService.cs34
-rw-r--r--OpenSim/Services/Interfaces/IGridService.cs102
-rw-r--r--OpenSim/Services/Interfaces/IGridUserService.cs14
-rw-r--r--OpenSim/Services/Interfaces/IHypergridServices.cs8
-rw-r--r--OpenSim/Services/Interfaces/IInventoryService.cs10
-rw-r--r--OpenSim/Services/Interfaces/ILoginService.cs4
-rw-r--r--OpenSim/Services/Interfaces/IMapImageService.cs6
-rw-r--r--OpenSim/Services/Interfaces/IMuteLIstService.cs41
-rw-r--r--OpenSim/Services/Interfaces/IOfflineIMService.cs4
-rw-r--r--OpenSim/Services/Interfaces/IPresenceService.cs11
-rw-r--r--OpenSim/Services/Interfaces/ISimulationService.cs21
-rw-r--r--OpenSim/Services/Interfaces/IUserAccountService.cs6
-rw-r--r--OpenSim/Services/Interfaces/IUserManagement.cs3
-rw-r--r--OpenSim/Services/Interfaces/IUserProfilesService.cs8
-rw-r--r--OpenSim/Services/Interfaces/OpenProfileClient.cs4
-rw-r--r--OpenSim/Services/Interfaces/Properties/AssemblyInfo.cs10
-rw-r--r--OpenSim/Services/InventoryService/Properties/AssemblyInfo.cs10
-rw-r--r--OpenSim/Services/InventoryService/Tests/XInventoryServiceTests.cs54
-rw-r--r--OpenSim/Services/InventoryService/XInventoryService.cs62
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginResponse.cs39
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs254
-rw-r--r--OpenSim/Services/LLLoginService/Properties/AssemblyInfo.cs10
-rw-r--r--OpenSim/Services/MapImageService/MapImageService.cs129
-rw-r--r--OpenSim/Services/MapImageService/Properties/AssemblyInfo.cs10
-rw-r--r--OpenSim/Services/MuteListService/MuteListService.cs127
-rw-r--r--OpenSim/Services/PresenceService/PresenceService.cs25
-rw-r--r--OpenSim/Services/PresenceService/PresenceServiceBase.cs2
-rw-r--r--OpenSim/Services/PresenceService/Properties/AssemblyInfo.cs10
-rw-r--r--OpenSim/Services/SimulationService/SimulationDataService.cs15
-rw-r--r--OpenSim/Services/UserAccountService/AgentPreferencesService.cs4
-rw-r--r--OpenSim/Services/UserAccountService/GridUserService.cs4
-rw-r--r--OpenSim/Services/UserAccountService/GridUserServiceBase.cs2
-rw-r--r--OpenSim/Services/UserAccountService/Properties/AssemblyInfo.cs10
-rw-r--r--OpenSim/Services/UserAccountService/UserAccountService.cs383
-rw-r--r--OpenSim/Services/UserProfilesService/UserProfilesService.cs44
-rw-r--r--OpenSim/Services/UserProfilesService/UserProfilesServiceBase.cs4
110 files changed, 3264 insertions, 1250 deletions
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs
index 0aefa16..5c37c33 100644
--- a/OpenSim/Services/AssetService/AssetService.cs
+++ b/OpenSim/Services/AssetService/AssetService.cs
@@ -95,7 +95,7 @@ namespace OpenSim.Services.AssetService
95 public virtual AssetBase Get(string id) 95 public virtual AssetBase Get(string id)
96 { 96 {
97// m_log.DebugFormat("[ASSET SERVICE]: Get asset for {0}", id); 97// m_log.DebugFormat("[ASSET SERVICE]: Get asset for {0}", id);
98 98
99 UUID assetID; 99 UUID assetID;
100 100
101 if (!UUID.TryParse(id, out assetID)) 101 if (!UUID.TryParse(id, out assetID))
@@ -166,7 +166,7 @@ namespace OpenSim.Services.AssetService
166 return new bool[ids.Length]; 166 return new bool[ids.Length];
167 } 167 }
168 } 168 }
169 169
170 public virtual string Store(AssetBase asset) 170 public virtual string Store(AssetBase asset)
171 { 171 {
172 bool exists = m_Database.AssetsExist(new[] { asset.FullID })[0]; 172 bool exists = m_Database.AssetsExist(new[] { asset.FullID })[0];
@@ -174,12 +174,15 @@ namespace OpenSim.Services.AssetService
174 { 174 {
175// m_log.DebugFormat( 175// m_log.DebugFormat(
176// "[ASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.FullID, asset.Data.Length); 176// "[ASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.FullID, asset.Data.Length);
177 m_Database.StoreAsset(asset); 177 if (!m_Database.StoreAsset(asset))
178 {
179 return UUID.Zero.ToString();
180 }
178 } 181 }
179// else 182// else
180// { 183// {
181// m_log.DebugFormat( 184// m_log.DebugFormat(
182// "[ASSET SERVICE]: Not storing asset {0} {1}, bytes {2} as it already exists", asset.Name, asset.FullID, asset.Data.Length); 185// "[ASSET SERVICE]: Not storing asset {0} {1}, bytes {2} as it already exists", asset.Name, asset.FullID, asset.Data.Length);
183// } 186// }
184 187
185 return asset.ID; 188 return asset.ID;
diff --git a/OpenSim/Services/AssetService/Properties/AssemblyInfo.cs b/OpenSim/Services/AssetService/Properties/AssemblyInfo.cs
index 63654a6..8da7100 100644
--- a/OpenSim/Services/AssetService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/AssetService/Properties/AssemblyInfo.cs
@@ -2,7 +2,7 @@
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4 4
5// General Information about an assembly is controlled through the following 5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly. 7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Services.AssetService")] 8[assembly: AssemblyTitle("OpenSim.Services.AssetService")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
14[assembly: AssemblyTrademark("")] 14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")] 15[assembly: AssemblyCulture("")]
16 16
17// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)] 20[assembly: ComVisible(false)]
21 21
@@ -25,9 +25,9 @@ using System.Runtime.InteropServices;
25// Version information for an assembly consists of the following four values: 25// Version information for an assembly consists of the following four values:
26// 26//
27// Major Version 27// Major Version
28// Minor Version 28// Minor Version
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.8.3.*")] 32[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
33 33
diff --git a/OpenSim/Services/AssetService/XAssetService.cs b/OpenSim/Services/AssetService/XAssetService.cs
index b1e5184..9490d55 100644
--- a/OpenSim/Services/AssetService/XAssetService.cs
+++ b/OpenSim/Services/AssetService/XAssetService.cs
@@ -94,7 +94,7 @@ namespace OpenSim.Services.AssetService
94 public virtual AssetBase Get(string id) 94 public virtual AssetBase Get(string id)
95 { 95 {
96// m_log.DebugFormat("[ASSET SERVICE]: Get asset for {0}", id); 96// m_log.DebugFormat("[ASSET SERVICE]: Get asset for {0}", id);
97 97
98 UUID assetID; 98 UUID assetID;
99 99
100 if (!UUID.TryParse(id, out assetID)) 100 if (!UUID.TryParse(id, out assetID))
@@ -162,7 +162,7 @@ namespace OpenSim.Services.AssetService
162 public virtual bool Get(string id, Object sender, AssetRetrieved handler) 162 public virtual bool Get(string id, Object sender, AssetRetrieved handler)
163 { 163 {
164 //m_log.DebugFormat("[XASSET SERVICE]: Get asset async {0}", id); 164 //m_log.DebugFormat("[XASSET SERVICE]: Get asset async {0}", id);
165 165
166 UUID assetID; 166 UUID assetID;
167 167
168 if (!UUID.TryParse(id, out assetID)) 168 if (!UUID.TryParse(id, out assetID))
@@ -171,7 +171,7 @@ namespace OpenSim.Services.AssetService
171 AssetBase asset = Get(id); 171 AssetBase asset = Get(id);
172 172
173 //m_log.DebugFormat("[XASSET SERVICE]: Got asset {0}", asset); 173 //m_log.DebugFormat("[XASSET SERVICE]: Got asset {0}", asset);
174 174
175 handler(id, sender, asset); 175 handler(id, sender, asset);
176 176
177 return true; 177 return true;
@@ -182,7 +182,7 @@ namespace OpenSim.Services.AssetService
182 UUID[] uuid = Array.ConvertAll(ids, id => UUID.Parse(id)); 182 UUID[] uuid = Array.ConvertAll(ids, id => UUID.Parse(id));
183 return m_Database.AssetsExist(uuid); 183 return m_Database.AssetsExist(uuid);
184 } 184 }
185 185
186 public virtual string Store(AssetBase asset) 186 public virtual string Store(AssetBase asset)
187 { 187 {
188 bool exists = m_Database.AssetsExist(new[] { asset.FullID })[0]; 188 bool exists = m_Database.AssetsExist(new[] { asset.FullID })[0];
@@ -222,7 +222,7 @@ namespace OpenSim.Services.AssetService
222 222
223 private void MigrateFromChainedService(AssetBase asset) 223 private void MigrateFromChainedService(AssetBase asset)
224 { 224 {
225 Store(asset); 225 Store(asset);
226 m_ChainedAssetService.Delete(asset.ID); 226 m_ChainedAssetService.Delete(asset.ID);
227 } 227 }
228 } 228 }
diff --git a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
index 229f557..f66b4e2 100644
--- a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
+++ b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
@@ -30,17 +30,18 @@ using OpenMetaverse;
30using log4net; 30using log4net;
31using Nini.Config; 31using Nini.Config;
32using System.Reflection; 32using System.Reflection;
33using OpenSim.Server.Base;
34using OpenSim.Services.Interfaces;
33using OpenSim.Data; 35using OpenSim.Data;
34using OpenSim.Framework; 36using OpenSim.Framework;
35using OpenSim.Services.Base; 37using OpenSim.Services.Base;
36using OpenSim.Services.Interfaces;
37 38
38namespace OpenSim.Services.AuthenticationService 39namespace OpenSim.Services.AuthenticationService
39{ 40{
40 // Generic Authentication service used for identifying 41 // Generic Authentication service used for identifying
41 // and authenticating principals. 42 // and authenticating principals.
42 // Principals may be clients acting on users' behalf, 43 // Principals may be clients acting on users' behalf,
43 // or any other components that need 44 // or any other components that need
44 // verifiable identification. 45 // verifiable identification.
45 // 46 //
46 public class AuthenticationServiceBase : ServiceBase 47 public class AuthenticationServiceBase : ServiceBase
@@ -48,8 +49,14 @@ namespace OpenSim.Services.AuthenticationService
48 private static readonly ILog m_log = 49 private static readonly ILog m_log =
49 LogManager.GetLogger( 50 LogManager.GetLogger(
50 MethodBase.GetCurrentMethod().DeclaringType); 51 MethodBase.GetCurrentMethod().DeclaringType);
51 52
52 protected IAuthenticationData m_Database; 53 protected IAuthenticationData m_Database;
54 protected IUserAccountService m_UserAccountService = null;
55
56 public AuthenticationServiceBase(IConfigSource config, IUserAccountService acct) : this(config)
57 {
58 m_UserAccountService = acct;
59 }
53 60
54 public AuthenticationServiceBase(IConfigSource config) : base(config) 61 public AuthenticationServiceBase(IConfigSource config) : base(config)
55 { 62 {
@@ -171,7 +178,7 @@ namespace OpenSim.Services.AuthenticationService
171 m_log.DebugFormat("[AUTHENTICATION DB]: Set authentication info for principalID {0}", info.PrincipalID); 178 m_log.DebugFormat("[AUTHENTICATION DB]: Set authentication info for principalID {0}", info.PrincipalID);
172 return true; 179 return true;
173 } 180 }
174 181
175 protected string GetToken(UUID principalID, int lifetime) 182 protected string GetToken(UUID principalID, int lifetime)
176 { 183 {
177 UUID token = UUID.Random(); 184 UUID token = UUID.Random();
diff --git a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
index 5f1bde1..aef3e9f 100644
--- a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
+++ b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
@@ -41,7 +41,7 @@ namespace OpenSim.Services.AuthenticationService
41 // Generic Authentication service used for identifying 41 // Generic Authentication service used for identifying
42 // and authenticating principals. 42 // and authenticating principals.
43 // Principals may be clients acting on users' behalf, 43 // Principals may be clients acting on users' behalf,
44 // or any other components that need 44 // or any other components that need
45 // verifiable identification. 45 // verifiable identification.
46 // 46 //
47 public class PasswordAuthenticationService : 47 public class PasswordAuthenticationService :
@@ -50,7 +50,13 @@ namespace OpenSim.Services.AuthenticationService
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, IUserAccountService userService) :
55 base(config, userService)
56 {
57 m_log.Debug("[AUTH SERVICE]: Started with User Account access");
58 }
59
54 public PasswordAuthenticationService(IConfigSource config) : 60 public PasswordAuthenticationService(IConfigSource config) :
55 base(config) 61 base(config)
56 { 62 {
@@ -58,42 +64,94 @@ namespace OpenSim.Services.AuthenticationService
58 64
59 public string Authenticate(UUID principalID, string password, int lifetime) 65 public string Authenticate(UUID principalID, string password, int lifetime)
60 { 66 {
67 UUID realID;
68 return Authenticate(principalID, password, lifetime, out realID);
69 }
70
71 public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID)
72 {
73 realID = UUID.Zero;
74
75 m_log.DebugFormat("[AUTH SERVICE]: Authenticating for {0}, user account service present: {1}", principalID, m_UserAccountService != null);
61 AuthenticationData data = m_Database.Get(principalID); 76 AuthenticationData data = m_Database.Get(principalID);
77 UserAccount user = null;
78 if (m_UserAccountService != null)
79 user = m_UserAccountService.GetUserAccount(UUID.Zero, principalID);
62 80
63 if (data == null) 81 if (data == null || data.Data == null)
64 { 82 {
65 m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} not found", principalID); 83 m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} or its data not found", principalID);
66 return String.Empty; 84 return String.Empty;
67 } 85 }
68 else if (data.Data == null) 86
87 if (!data.Data.ContainsKey("passwordHash") ||
88 !data.Data.ContainsKey("passwordSalt"))
89 {
90 m_log.DebugFormat("[AUTH SERVICE]: No credentials.");
91 return String.Empty;
92 }
93
94 string hashed = Util.Md5Hash(password + ":" +
95 data.Data["passwordSalt"].ToString());
96
97// m_log.DebugFormat("[PASS AUTH]: got {0}; hashed = {1}; stored = {2}", password, hashed, data.Data["passwordHash"].ToString());
98
99 if (data.Data["passwordHash"].ToString() == hashed)
100 {
101 return GetToken(principalID, lifetime);
102 }
103
104 if (user == null)
69 { 105 {
70 m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} data not found", principalID); 106 m_log.DebugFormat("[PASS AUTH]: No user record for {0}", principalID);
71 return String.Empty; 107 return String.Empty;
72 } 108 }
73 else if (!data.Data.ContainsKey("passwordHash") || !data.Data.ContainsKey("passwordSalt")) 109
110 int impersonateFlag = 1 << 6;
111
112 if ((user.UserFlags & impersonateFlag) == 0)
74 { 113 {
75 m_log.DebugFormat( 114 m_log.DebugFormat("[AUTH SERVICE]: Not trying impersonation {0} {1}.", user.UserFlags, impersonateFlag);
76 "[AUTH SERVICE]: PrincipalID {0} data didn't contain either passwordHash or passwordSalt", principalID);
77 return String.Empty; 115 return String.Empty;
78 } 116 }
79 else 117
118 m_log.DebugFormat("[PASS AUTH]: Attempting impersonation.");
119
120 List<UserAccount> accounts = m_UserAccountService.GetUserAccountsWhere(UUID.Zero, "UserLevel >= 200");
121 if (accounts == null || accounts.Count == 0)
122 return String.Empty;
123
124 foreach (UserAccount a in accounts)
80 { 125 {
81 string hashed = Util.Md5Hash(password + ":" + data.Data["passwordSalt"].ToString()); 126 data = m_Database.Get(a.PrincipalID);
127 if (data == null || data.Data == null ||
128 !data.Data.ContainsKey("passwordHash") ||
129 !data.Data.ContainsKey("passwordSalt"))
130 {
131 continue;
132 }
133
134// m_log.DebugFormat("[PASS AUTH]: Trying {0}", data.PrincipalID);
82 135
83 m_log.DebugFormat("[PASS AUTH]: got {0}; hashed = {1}; stored = {2}", password, hashed, data.Data["passwordHash"].ToString()); 136 hashed = Util.Md5Hash(password + ":" +
137 data.Data["passwordSalt"].ToString());
84 138
85 if (data.Data["passwordHash"].ToString() == hashed) 139 if (data.Data["passwordHash"].ToString() == hashed)
86 { 140 {
141 m_log.InfoFormat("[PASS AUTH]: {0} {1} impersonating {2}, proceeding with login", a.FirstName, a.LastName, principalID);
142 realID = a.PrincipalID;
87 return GetToken(principalID, lifetime); 143 return GetToken(principalID, lifetime);
88 } 144 }
89 else 145// else
90 { 146// {
91 m_log.DebugFormat( 147// m_log.DebugFormat(
92 "[AUTH SERVICE]: Salted hash {0} of given password did not match salted hash of {1} for PrincipalID {2}. Authentication failure.", 148// "[AUTH SERVICE]: Salted hash {0} of given password did not match salted hash of {1} for PrincipalID {2}. Authentication failure.",
93 hashed, data.Data["passwordHash"], principalID); 149// hashed, data.Data["passwordHash"], data.PrincipalID);
94 return String.Empty; 150// }
95 }
96 } 151 }
152
153 m_log.InfoFormat("[PASS AUTH]: Impersonation of {0} failed", principalID);
154 return String.Empty;
97 } 155 }
98 } 156 }
99} \ No newline at end of file 157}
diff --git a/OpenSim/Services/AuthenticationService/Properties/AssemblyInfo.cs b/OpenSim/Services/AuthenticationService/Properties/AssemblyInfo.cs
index f25accc..c946b04 100644
--- a/OpenSim/Services/AuthenticationService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/AuthenticationService/Properties/AssemblyInfo.cs
@@ -2,7 +2,7 @@
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4 4
5// General Information about an assembly is controlled through the following 5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly. 7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Services.AuthenticationService")] 8[assembly: AssemblyTitle("OpenSim.Services.AuthenticationService")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
14[assembly: AssemblyTrademark("")] 14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")] 15[assembly: AssemblyCulture("")]
16 16
17// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)] 20[assembly: ComVisible(false)]
21 21
@@ -25,9 +25,9 @@ using System.Runtime.InteropServices;
25// Version information for an assembly consists of the following four values: 25// Version information for an assembly consists of the following four values:
26// 26//
27// Major Version 27// Major Version
28// Minor Version 28// Minor Version
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.8.3.*")] 32[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
33 33
diff --git a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs
index 2344c0e..0bd5b1f 100644
--- a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs
+++ b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs
@@ -40,7 +40,7 @@ namespace OpenSim.Services.AuthenticationService
40 // Generic Authentication service used for identifying 40 // Generic Authentication service used for identifying
41 // and authenticating principals. 41 // and authenticating principals.
42 // Principals may be clients acting on users' behalf, 42 // Principals may be clients acting on users' behalf,
43 // or any other components that need 43 // or any other components that need
44 // verifiable identification. 44 // verifiable identification.
45 // 45 //
46 public class WebkeyAuthenticationService : 46 public class WebkeyAuthenticationService :
@@ -50,11 +50,22 @@ namespace OpenSim.Services.AuthenticationService
50 LogManager.GetLogger( 50 LogManager.GetLogger(
51 MethodBase.GetCurrentMethod().DeclaringType); 51 MethodBase.GetCurrentMethod().DeclaringType);
52 52
53 public WebkeyAuthenticationService(IConfigSource config, IUserAccountService userService) :
54 base(config, userService)
55 {
56 }
57
53 public WebkeyAuthenticationService(IConfigSource config) : 58 public WebkeyAuthenticationService(IConfigSource config) :
54 base(config) 59 base(config)
55 { 60 {
56 } 61 }
57 62
63 public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID)
64 {
65 realID = UUID.Zero;
66 return Authenticate(principalID, password, lifetime);
67 }
68
58 public string Authenticate(UUID principalID, string password, int lifetime) 69 public string Authenticate(UUID principalID, string password, int lifetime)
59 { 70 {
60 if (new UUID(password) == UUID.Zero) 71 if (new UUID(password) == UUID.Zero)
@@ -68,7 +79,7 @@ namespace OpenSim.Services.AuthenticationService
68 { 79 {
69 if (data.Data.ContainsKey("webLoginKey")) 80 if (data.Data.ContainsKey("webLoginKey"))
70 { 81 {
71 string key = data.Data["webLoginKey"].ToString(); 82 string key = data.Data["webLoginKey"].ToString();
72 if (key == password) 83 if (key == password)
73 { 84 {
74 data.Data["webLoginKey"] = UUID.Zero.ToString(); 85 data.Data["webLoginKey"] = UUID.Zero.ToString();
diff --git a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs
index 2c6cebd..4203c7b 100644
--- a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs
+++ b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs
@@ -43,9 +43,9 @@ namespace OpenSim.Services.AuthenticationService
43 { 43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 private Dictionary<string, IAuthenticationService> m_svcChecks 46 private Dictionary<string, IAuthenticationService> m_svcChecks
47 = new Dictionary<string, IAuthenticationService>(); 47 = new Dictionary<string, IAuthenticationService>();
48 48
49 public WebkeyOrPasswordAuthenticationService(IConfigSource config) 49 public WebkeyOrPasswordAuthenticationService(IConfigSource config)
50 : base(config) 50 : base(config)
51 { 51 {
@@ -55,14 +55,22 @@ namespace OpenSim.Services.AuthenticationService
55 55
56 public string Authenticate(UUID principalID, string password, int lifetime) 56 public string Authenticate(UUID principalID, string password, int lifetime)
57 { 57 {
58 UUID realID;
59
60 return Authenticate(principalID, password, lifetime, out realID);
61 }
62
63 public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID)
64 {
58 AuthenticationData data = m_Database.Get(principalID); 65 AuthenticationData data = m_Database.Get(principalID);
59 string result = String.Empty; 66 string result = String.Empty;
67 realID = UUID.Zero;
60 if (data != null && data.Data != null) 68 if (data != null && data.Data != null)
61 { 69 {
62 if (data.Data.ContainsKey("webLoginKey")) 70 if (data.Data.ContainsKey("webLoginKey"))
63 { 71 {
64 m_log.DebugFormat("[AUTH SERVICE]: Attempting web key authentication for PrincipalID {0}", principalID); 72 m_log.DebugFormat("[AUTH SERVICE]: Attempting web key authentication for PrincipalID {0}", principalID);
65 result = m_svcChecks["web_login_key"].Authenticate(principalID, password, lifetime); 73 result = m_svcChecks["web_login_key"].Authenticate(principalID, password, lifetime, out realID);
66 if (result == String.Empty) 74 if (result == String.Empty)
67 { 75 {
68 m_log.DebugFormat("[AUTH SERVICE]: Web Login failed for PrincipalID {0}", principalID); 76 m_log.DebugFormat("[AUTH SERVICE]: Web Login failed for PrincipalID {0}", principalID);
@@ -71,12 +79,15 @@ namespace OpenSim.Services.AuthenticationService
71 if (result == string.Empty && data.Data.ContainsKey("passwordHash") && data.Data.ContainsKey("passwordSalt")) 79 if (result == string.Empty && data.Data.ContainsKey("passwordHash") && data.Data.ContainsKey("passwordSalt"))
72 { 80 {
73 m_log.DebugFormat("[AUTH SERVICE]: Attempting password authentication for PrincipalID {0}", principalID); 81 m_log.DebugFormat("[AUTH SERVICE]: Attempting password authentication for PrincipalID {0}", principalID);
74 result = m_svcChecks["password"].Authenticate(principalID, password, lifetime); 82 result = m_svcChecks["password"].Authenticate(principalID, password, lifetime, out realID);
75 if (result == String.Empty) 83 if (result == String.Empty)
76 { 84 {
77 m_log.DebugFormat("[AUTH SERVICE]: Password login failed for PrincipalID {0}", principalID); 85 m_log.DebugFormat("[AUTH SERVICE]: Password login failed for PrincipalID {0}", principalID);
78 } 86 }
79 } 87 }
88
89
90
80 if (result == string.Empty) 91 if (result == string.Empty)
81 { 92 {
82 m_log.DebugFormat("[AUTH SERVICE]: Both password and webLoginKey-based authentication failed for PrincipalID {0}", principalID); 93 m_log.DebugFormat("[AUTH SERVICE]: Both password and webLoginKey-based authentication failed for PrincipalID {0}", principalID);
@@ -86,7 +97,9 @@ namespace OpenSim.Services.AuthenticationService
86 { 97 {
87 m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} or its data not found", principalID); 98 m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} or its data not found", principalID);
88 } 99 }
100
101
89 return result; 102 return result;
90 } 103 }
91 } 104 }
92} \ No newline at end of file 105}
diff --git a/OpenSim/Services/AuthorizationService/AuthorizationService.cs b/OpenSim/Services/AuthorizationService/AuthorizationService.cs
index 03da6e1..2fe43e7 100644
--- a/OpenSim/Services/AuthorizationService/AuthorizationService.cs
+++ b/OpenSim/Services/AuthorizationService/AuthorizationService.cs
@@ -49,9 +49,10 @@ namespace OpenSim.Services.AuthorizationService
49 } 49 }
50 50
51 public bool IsAuthorizedForRegion( 51 public bool IsAuthorizedForRegion(
52 string userID, string firstName, string lastName, string regionID, out string message) 52 string userID, string firstName, string lastName, string regionID, out string message, out bool isLocal)
53 { 53 {
54 message = "Authorized"; 54 message = "Authorized";
55 isLocal = true;
55 return true; 56 return true;
56 } 57 }
57 } 58 }
diff --git a/OpenSim/Services/AuthorizationService/Properties/AssemblyInfo.cs b/OpenSim/Services/AuthorizationService/Properties/AssemblyInfo.cs
index 47d47ab..f87095a 100644
--- a/OpenSim/Services/AuthorizationService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/AuthorizationService/Properties/AssemblyInfo.cs
@@ -2,7 +2,7 @@
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4 4
5// General Information about an assembly is controlled through the following 5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly. 7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Services.AuthorizationService")] 8[assembly: AssemblyTitle("OpenSim.Services.AuthorizationService")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
14[assembly: AssemblyTrademark("")] 14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")] 15[assembly: AssemblyCulture("")]
16 16
17// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)] 20[assembly: ComVisible(false)]
21 21
@@ -25,9 +25,9 @@ using System.Runtime.InteropServices;
25// Version information for an assembly consists of the following four values: 25// Version information for an assembly consists of the following four values:
26// 26//
27// Major Version 27// Major Version
28// Minor Version 28// Minor Version
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.8.3.*")] 32[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
33 33
diff --git a/OpenSim/Services/AvatarService/AvatarService.cs b/OpenSim/Services/AvatarService/AvatarService.cs
index 423c781..222944c 100644
--- a/OpenSim/Services/AvatarService/AvatarService.cs
+++ b/OpenSim/Services/AvatarService/AvatarService.cs
@@ -56,7 +56,7 @@ namespace OpenSim.Services.AvatarService
56 AvatarData avatar = GetAvatar(principalID); 56 AvatarData avatar = GetAvatar(principalID);
57 return avatar.ToAvatarAppearance(); 57 return avatar.ToAvatarAppearance();
58 } 58 }
59 59
60 public bool SetAppearance(UUID principalID, AvatarAppearance appearance) 60 public bool SetAppearance(UUID principalID, AvatarAppearance appearance)
61 { 61 {
62 AvatarData avatar = new AvatarData(appearance); 62 AvatarData avatar = new AvatarData(appearance);
@@ -136,7 +136,7 @@ namespace OpenSim.Services.AvatarService
136 { 136 {
137 av.Data["Value"] = kvp.Value; 137 av.Data["Value"] = kvp.Value;
138 } 138 }
139 139
140 if (!m_Database.Store(av)) 140 if (!m_Database.Store(av))
141 { 141 {
142 m_Database.Delete("PrincipalID", principalID.ToString()); 142 m_Database.Delete("PrincipalID", principalID.ToString());
diff --git a/OpenSim/Services/AvatarService/AvatarServiceBase.cs b/OpenSim/Services/AvatarService/AvatarServiceBase.cs
index ab9d7cd..c1c4fb7 100644
--- a/OpenSim/Services/AvatarService/AvatarServiceBase.cs
+++ b/OpenSim/Services/AvatarService/AvatarServiceBase.cs
@@ -68,7 +68,7 @@ namespace OpenSim.Services.AvatarService
68 connString = presenceConfig.GetString("ConnectionString", connString); 68 connString = presenceConfig.GetString("ConnectionString", connString);
69 realm = presenceConfig.GetString("Realm", realm); 69 realm = presenceConfig.GetString("Realm", realm);
70 } 70 }
71 71
72 // 72 //
73 // We tried, but this doesn't exist. We can't proceed. 73 // We tried, but this doesn't exist. We can't proceed.
74 // 74 //
diff --git a/OpenSim/Services/AvatarService/Properties/AssemblyInfo.cs b/OpenSim/Services/AvatarService/Properties/AssemblyInfo.cs
index a233d8a..816ab0b 100644
--- a/OpenSim/Services/AvatarService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/AvatarService/Properties/AssemblyInfo.cs
@@ -2,7 +2,7 @@
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4 4
5// General Information about an assembly is controlled through the following 5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly. 7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Services.AvatarService")] 8[assembly: AssemblyTitle("OpenSim.Services.AvatarService")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
14[assembly: AssemblyTrademark("")] 14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")] 15[assembly: AssemblyCulture("")]
16 16
17// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)] 20[assembly: ComVisible(false)]
21 21
@@ -25,9 +25,9 @@ using System.Runtime.InteropServices;
25// Version information for an assembly consists of the following four values: 25// Version information for an assembly consists of the following four values:
26// 26//
27// Major Version 27// Major Version
28// Minor Version 28// Minor Version
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.8.3.*")] 32[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
33 33
diff --git a/OpenSim/Services/Base/Properties/AssemblyInfo.cs b/OpenSim/Services/Base/Properties/AssemblyInfo.cs
index b113c42..90c14d7 100644
--- a/OpenSim/Services/Base/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/Base/Properties/AssemblyInfo.cs
@@ -2,7 +2,7 @@
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4 4
5// General Information about an assembly is controlled through the following 5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly. 7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Services.Base")] 8[assembly: AssemblyTitle("OpenSim.Services.Base")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
14[assembly: AssemblyTrademark("")] 14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")] 15[assembly: AssemblyCulture("")]
16 16
17// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)] 20[assembly: ComVisible(false)]
21 21
@@ -25,9 +25,9 @@ using System.Runtime.InteropServices;
25// Version information for an assembly consists of the following four values: 25// Version information for an assembly consists of the following four values:
26// 26//
27// Major Version 27// Major Version
28// Minor Version 28// Minor Version
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.8.3.*")] 32[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
33 33
diff --git a/OpenSim/Services/Base/ServiceBase.cs b/OpenSim/Services/Base/ServiceBase.cs
index a7eb2be..2017f50 100644
--- a/OpenSim/Services/Base/ServiceBase.cs
+++ b/OpenSim/Services/Base/ServiceBase.cs
@@ -26,8 +26,8 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
30using System.IO; 29using System.IO;
30using System.Collections.Generic;
31using System.Reflection; 31using System.Reflection;
32using log4net; 32using log4net;
33using Nini.Config; 33using Nini.Config;
@@ -38,7 +38,7 @@ namespace OpenSim.Services.Base
38 public class ServiceBase 38 public class ServiceBase
39 { 39 {
40 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 40 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
41 41
42 public T LoadPlugin<T>(string dllName) where T:class 42 public T LoadPlugin<T>(string dllName) where T:class
43 { 43 {
44 return LoadPlugin<T>(dllName, new Object[0]); 44 return LoadPlugin<T>(dllName, new Object[0]);
@@ -54,6 +54,7 @@ namespace OpenSim.Services.Base
54 string noRoot = dllName.Substring(pathRoot.Length); 54 string noRoot = dllName.Substring(pathRoot.Length);
55 string[] parts = noRoot.Split(new char[] {':'}); 55 string[] parts = noRoot.Split(new char[] {':'});
56 56
57
57 dllName = pathRoot + parts[0]; 58 dllName = pathRoot + parts[0];
58 59
59 string className = String.Empty; 60 string className = String.Empty;
@@ -104,12 +105,12 @@ namespace OpenSim.Services.Base
104 List<string> strArgs = new List<string>(); 105 List<string> strArgs = new List<string>();
105 foreach (Object arg in args) 106 foreach (Object arg in args)
106 strArgs.Add(arg.ToString()); 107 strArgs.Add(arg.ToString());
107 108
108 m_log.Error( 109 m_log.Error(
109 string.Format( 110 string.Format(
110 "[SERVICE BASE]: Failed to load plugin {0} from {1} with args {2}", 111 "[SERVICE BASE]: Failed to load plugin {0} from {1} with args {2}",
111 interfaceName, dllName, string.Join(", ", strArgs.ToArray())), e); 112 interfaceName, dllName, string.Join(", ", strArgs.ToArray())), e);
112 113
113 return null; 114 return null;
114 } 115 }
115 } 116 }
diff --git a/OpenSim/Services/Connectors/AgentPreferences/AgentPreferencesConnector.cs b/OpenSim/Services/Connectors/AgentPreferences/AgentPreferencesConnector.cs
index 1dbc0c8..bd342fa 100644
--- a/OpenSim/Services/Connectors/AgentPreferences/AgentPreferencesConnector.cs
+++ b/OpenSim/Services/Connectors/AgentPreferences/AgentPreferencesConnector.cs
@@ -62,7 +62,7 @@ namespace OpenSim.Services.Connectors
62 Initialise(source); 62 Initialise(source);
63 } 63 }
64 64
65 public virtual void Initialise(IConfigSource source) 65 public void Initialise(IConfigSource source)
66 { 66 {
67 IConfig gridConfig = source.Configs["AgentPreferencesService"]; 67 IConfig gridConfig = source.Configs["AgentPreferencesService"];
68 if (gridConfig == null) 68 if (gridConfig == null)
@@ -110,7 +110,7 @@ namespace OpenSim.Services.Connectors
110 { 110 {
111 m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: Exception when contacting agent preferences server at {0}: {1}", uri, e.Message); 111 m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: Exception when contacting agent preferences server at {0}: {1}", uri, e.Message);
112 } 112 }
113 113
114 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 114 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
115 if (replyData != null) 115 if (replyData != null)
116 { 116 {
diff --git a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
index bd43552..7e81be7 100644
--- a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
@@ -27,12 +27,14 @@
27 27
28using log4net; 28using log4net;
29using System; 29using System;
30using System.Threading;
30using System.Collections.Generic; 31using System.Collections.Generic;
31using System.IO; 32using System.IO;
32using System.Reflection; 33using System.Reflection;
34using System.Timers;
33using Nini.Config; 35using Nini.Config;
34using OpenSim.Framework; 36using OpenSim.Framework;
35using OpenSim.Framework.Console; 37using OpenSim.Framework.Monitoring;
36using OpenSim.Services.Interfaces; 38using OpenSim.Services.Interfaces;
37using OpenMetaverse; 39using OpenMetaverse;
38 40
@@ -44,15 +46,27 @@ namespace OpenSim.Services.Connectors
44 LogManager.GetLogger( 46 LogManager.GetLogger(
45 MethodBase.GetCurrentMethod().DeclaringType); 47 MethodBase.GetCurrentMethod().DeclaringType);
46 48
49 const int MAXSENDRETRIESLEN = 30;
50
47 private string m_ServerURI = String.Empty; 51 private string m_ServerURI = String.Empty;
48 private IImprovedAssetCache m_Cache = null; 52 private IAssetCache m_Cache = null;
53 private int m_retryCounter;
54 private bool m_inRetries;
55 private List<AssetBase>[] m_sendRetries = new List<AssetBase>[MAXSENDRETRIESLEN];
56 private System.Timers.Timer m_retryTimer;
49 private int m_maxAssetRequestConcurrency = 30; 57 private int m_maxAssetRequestConcurrency = 30;
50 58
51 private delegate void AssetRetrievedEx(AssetBase asset); 59 private delegate void AssetRetrievedEx(AssetBase asset);
52 60
53 // Keeps track of concurrent requests for the same asset, so that it's only loaded once. 61 // Keeps track of concurrent requests for the same asset, so that it's only loaded once.
54 // Maps: Asset ID -> Handlers which will be called when the asset has been loaded 62 // Maps: Asset ID -> Handlers which will be called when the asset has been loaded
55 private Dictionary<string, AssetRetrievedEx> m_AssetHandlers = new Dictionary<string, AssetRetrievedEx>(); 63// private Dictionary<string, AssetRetrievedEx> m_AssetHandlers = new Dictionary<string, AssetRetrievedEx>();
64
65 private Dictionary<string, List<AssetRetrievedEx>> m_AssetHandlers = new Dictionary<string, List<AssetRetrievedEx>>();
66
67 private Dictionary<string, string> m_UriMap = new Dictionary<string, string>();
68
69 private Thread[] m_fetchThreads;
56 70
57 public int MaxAssetRequestConcurrency 71 public int MaxAssetRequestConcurrency
58 { 72 {
@@ -91,31 +105,155 @@ namespace OpenSim.Services.Connectors
91 string serviceURI = assetConfig.GetString("AssetServerURI", 105 string serviceURI = assetConfig.GetString("AssetServerURI",
92 String.Empty); 106 String.Empty);
93 107
108 m_ServerURI = serviceURI;
109
94 if (serviceURI == String.Empty) 110 if (serviceURI == String.Empty)
95 { 111 {
96 m_log.Error("[ASSET CONNECTOR]: No Server URI named in section AssetService"); 112 m_log.Error("[ASSET CONNECTOR]: No Server URI named in section AssetService");
97 throw new Exception("Asset connector init error"); 113 throw new Exception("Asset connector init error");
98 } 114 }
99 115
100 m_ServerURI = serviceURI; 116 m_retryTimer = new System.Timers.Timer();
117 m_retryTimer.Elapsed += new ElapsedEventHandler(retryCheck);
118 m_retryTimer.AutoReset = true;
119 m_retryTimer.Interval = 60000;
120
121 Uri serverUri = new Uri(m_ServerURI);
122
123 string groupHost = serverUri.Host;
124
125 for (int i = 0 ; i < 256 ; i++)
126 {
127 string prefix = i.ToString("x2");
128 groupHost = assetConfig.GetString("AssetServerHost_"+prefix, groupHost);
129
130 m_UriMap[prefix] = groupHost;
131 //m_log.DebugFormat("[ASSET]: Using {0} for prefix {1}", groupHost, prefix);
132 }
133
134 m_fetchThreads = new Thread[2];
135
136 for (int i = 0 ; i < 2 ; i++)
137 {
138 m_fetchThreads[i] = WorkManager.StartThread(AssetRequestProcessor,
139 String.Format("GetTextureWorker{0}", i),
140 ThreadPriority.Normal,
141 true,
142 false);
143 }
144 }
145
146 private string MapServer(string id)
147 {
148 if (m_UriMap.Count == 0)
149 return m_ServerURI;
150
151 UriBuilder serverUri = new UriBuilder(m_ServerURI);
152
153 string prefix = id.Substring(0, 2).ToLower();
154
155 string host;
156
157 // HG URLs will not be valid UUIDS
158 if (m_UriMap.ContainsKey(prefix))
159 host = m_UriMap[prefix];
160 else
161 host = m_UriMap["00"];
162
163 serverUri.Host = host;
164
165 // m_log.DebugFormat("[ASSET]: Using {0} for host name for prefix {1}", host, prefix);
166
167 string ret = serverUri.Uri.AbsoluteUri;
168 if (ret.EndsWith("/"))
169 ret = ret.Substring(0, ret.Length - 1);
170 return ret;
101 } 171 }
102 172
103 protected void SetCache(IImprovedAssetCache cache) 173 protected void retryCheck(object source, ElapsedEventArgs e)
174 {
175 lock(m_sendRetries)
176 {
177 if(m_inRetries)
178 return;
179 m_inRetries = true;
180 }
181
182 m_retryCounter++;
183 if(m_retryCounter >= 61 ) // avoid overflow 60 is max in use below
184 m_retryCounter = 1;
185
186 int inUse = 0;
187 int nextlevel;
188 int timefactor;
189 List<AssetBase> retrylist;
190 // we need to go down
191 for(int i = MAXSENDRETRIESLEN - 1; i >= 0; i--)
192 {
193 lock(m_sendRetries)
194 retrylist = m_sendRetries[i];
195
196 if(retrylist == null)
197 continue;
198
199 inUse++;
200 nextlevel = i + 1;
201
202 //We exponentially fall back on frequency until we reach one attempt per hour
203 //The net result is that we end up in the queue for roughly 24 hours..
204 //24 hours worth of assets could be a lot, so the hope is that the region admin
205 //will have gotten the asset connector back online quickly!
206 if(i == 0)
207 timefactor = 1;
208 else
209 {
210 timefactor = 1 << nextlevel;
211 if (timefactor > 60)
212 timefactor = 60;
213 }
214
215 if(m_retryCounter < timefactor)
216 continue; // to update inUse;
217
218 if (m_retryCounter % timefactor != 0)
219 continue;
220
221 // a list to retry
222 lock(m_sendRetries)
223 m_sendRetries[i] = null;
224
225 // we are the only ones with a copy of this retrylist now
226 foreach(AssetBase ass in retrylist)
227 retryStore(ass, nextlevel);
228 }
229
230 lock(m_sendRetries)
231 {
232 if(inUse == 0 )
233 m_retryTimer.Stop();
234
235 m_inRetries = false;
236 }
237 }
238
239 protected void SetCache(IAssetCache cache)
104 { 240 {
105 m_Cache = cache; 241 m_Cache = cache;
106 } 242 }
107 243
108 public AssetBase Get(string id) 244 public AssetBase Get(string id)
109 { 245 {
110// m_log.DebugFormat("[ASSET SERVICE CONNECTOR]: Synchronous get request for {0}", id); 246 string uri = MapServer(id) + "/assets/" + id;
111
112 string uri = m_ServerURI + "/assets/" + id;
113 247
114 AssetBase asset = null; 248 AssetBase asset = null;
249
115 if (m_Cache != null) 250 if (m_Cache != null)
116 asset = m_Cache.Get(id); 251 {
252 if (!m_Cache.Get(id, out asset))
253 return null;
254 }
117 255
118 if (asset == null) 256 if (asset == null || asset.Data == null || asset.Data.Length == 0)
119 { 257 {
120 // XXX: Commented out for now since this has either never been properly operational or not for some time 258 // XXX: Commented out for now since this has either never been properly operational or not for some time
121 // as m_maxAssetRequestConcurrency was being passed as the timeout, not a concurrency limiting option. 259 // as m_maxAssetRequestConcurrency was being passed as the timeout, not a concurrency limiting option.
@@ -128,8 +266,14 @@ namespace OpenSim.Services.Connectors
128 266
129 asset = SynchronousRestObjectRequester.MakeRequest<int, AssetBase>("GET", uri, 0, m_Auth); 267 asset = SynchronousRestObjectRequester.MakeRequest<int, AssetBase>("GET", uri, 0, m_Auth);
130 268
269
131 if (m_Cache != null) 270 if (m_Cache != null)
132 m_Cache.Cache(asset); 271 {
272 if (asset != null)
273 m_Cache.Cache(asset);
274 else
275 m_Cache.CacheNegative(id);
276 }
133 } 277 }
134 return asset; 278 return asset;
135 } 279 }
@@ -138,23 +282,28 @@ namespace OpenSim.Services.Connectors
138 { 282 {
139// m_log.DebugFormat("[ASSET SERVICE CONNECTOR]: Cache request for {0}", id); 283// m_log.DebugFormat("[ASSET SERVICE CONNECTOR]: Cache request for {0}", id);
140 284
285 AssetBase asset = null;
141 if (m_Cache != null) 286 if (m_Cache != null)
142 return m_Cache.Get(id); 287 {
288 m_Cache.Get(id, out asset);
289 }
143 290
144 return null; 291 return asset;
145 } 292 }
146 293
147 public AssetMetadata GetMetadata(string id) 294 public AssetMetadata GetMetadata(string id)
148 { 295 {
149 if (m_Cache != null) 296 if (m_Cache != null)
150 { 297 {
151 AssetBase fullAsset = m_Cache.Get(id); 298 AssetBase fullAsset;
299 if (!m_Cache.Get(id, out fullAsset))
300 return null;
152 301
153 if (fullAsset != null) 302 if (fullAsset != null)
154 return fullAsset.Metadata; 303 return fullAsset.Metadata;
155 } 304 }
156 305
157 string uri = m_ServerURI + "/assets/" + id + "/metadata"; 306 string uri = MapServer(id) + "/assets/" + id + "/metadata";
158 307
159 AssetMetadata asset = SynchronousRestObjectRequester.MakeRequest<int, AssetMetadata>("GET", uri, 0, m_Auth); 308 AssetMetadata asset = SynchronousRestObjectRequester.MakeRequest<int, AssetMetadata>("GET", uri, 0, m_Auth);
160 return asset; 309 return asset;
@@ -164,13 +313,15 @@ namespace OpenSim.Services.Connectors
164 { 313 {
165 if (m_Cache != null) 314 if (m_Cache != null)
166 { 315 {
167 AssetBase fullAsset = m_Cache.Get(id); 316 AssetBase fullAsset;
317 if (!m_Cache.Get(id, out fullAsset))
318 return null;
168 319
169 if (fullAsset != null) 320 if (fullAsset != null)
170 return fullAsset.Data; 321 return fullAsset.Data;
171 } 322 }
172 323
173 using (RestClient rc = new RestClient(m_ServerURI)) 324 using (RestClient rc = new RestClient(MapServer(id)))
174 { 325 {
175 rc.AddResourcePath("assets"); 326 rc.AddResourcePath("assets");
176 rc.AddResourcePath(id); 327 rc.AddResourcePath(id);
@@ -178,81 +329,110 @@ namespace OpenSim.Services.Connectors
178 329
179 rc.RequestMethod = "GET"; 330 rc.RequestMethod = "GET";
180 331
181 Stream s = rc.Request(m_Auth); 332 using (Stream s = rc.Request(m_Auth))
333 {
334 if (s == null)
335 return null;
182 336
183 if (s == null) 337 if (s.Length > 0)
184 return null; 338 {
339 byte[] ret = new byte[s.Length];
340 s.Read(ret, 0, (int)s.Length);
341
342 return ret;
343 }
344 }
345 return null;
346 }
347 }
185 348
186 if (s.Length > 0) 349 private class QueuedAssetRequest
350 {
351 public string uri;
352 public string id;
353 }
354
355 private OpenSim.Framework.BlockingQueue<QueuedAssetRequest> m_requestQueue =
356 new OpenSim.Framework.BlockingQueue<QueuedAssetRequest>();
357
358 private void AssetRequestProcessor()
359 {
360 QueuedAssetRequest r;
361
362 while (true)
363 {
364 r = m_requestQueue.Dequeue(4500);
365 Watchdog.UpdateThread();
366 if(r== null)
367 continue;
368 string uri = r.uri;
369 string id = r.id;
370
371 try
187 { 372 {
188 byte[] ret = new byte[s.Length]; 373 AssetBase a = SynchronousRestObjectRequester.MakeRequest<int, AssetBase>("GET", uri, 0, 30000, m_Auth);
189 s.Read(ret, 0, (int)s.Length);
190 374
191 return ret; 375 if (a != null && m_Cache != null)
192 } 376 m_Cache.Cache(a);
193 377
194 return null; 378 List<AssetRetrievedEx> handlers;
379 lock (m_AssetHandlers)
380 {
381 handlers = m_AssetHandlers[id];
382 m_AssetHandlers.Remove(id);
383 }
384
385 if(handlers != null)
386 {
387 Util.FireAndForget(x =>
388 {
389 foreach (AssetRetrievedEx h in handlers)
390 {
391 try { h.Invoke(a); }
392 catch { }
393 }
394 handlers.Clear();
395 });
396 }
397 }
398 catch { }
195 } 399 }
196 } 400 }
197 401
198 public bool Get(string id, Object sender, AssetRetrieved handler) 402 public bool Get(string id, Object sender, AssetRetrieved handler)
199 { 403 {
200// m_log.DebugFormat("[ASSET SERVICE CONNECTOR]: Potentially asynchronous get request for {0}", id); 404 string uri = MapServer(id) + "/assets/" + id;
201
202 string uri = m_ServerURI + "/assets/" + id;
203 405
204 AssetBase asset = null; 406 AssetBase asset = null;
205 if (m_Cache != null) 407 if (m_Cache != null)
206 asset = m_Cache.Get(id); 408 {
409 if (!m_Cache.Get(id, out asset))
410 return false;
411 }
207 412
208 if (asset == null) 413 if (asset == null || asset.Data == null || asset.Data.Length == 0)
209 { 414 {
210 lock (m_AssetHandlers) 415 lock (m_AssetHandlers)
211 { 416 {
212 AssetRetrievedEx handlerEx = new AssetRetrievedEx(delegate(AssetBase _asset) { handler(id, sender, _asset); }); 417 AssetRetrievedEx handlerEx = new AssetRetrievedEx(delegate(AssetBase _asset) { handler(id, sender, _asset); });
213 418
214 AssetRetrievedEx handlers; 419 List<AssetRetrievedEx> handlers;
215 if (m_AssetHandlers.TryGetValue(id, out handlers)) 420 if (m_AssetHandlers.TryGetValue(id, out handlers))
216 { 421 {
217 // Someone else is already loading this asset. It will notify our handler when done. 422 // Someone else is already loading this asset. It will notify our handler when done.
218 handlers += handlerEx; 423 handlers.Add(handlerEx);
219 return true; 424 return true;
220 } 425 }
221 426
222 // Load the asset ourselves 427 handlers = new List<AssetRetrievedEx>();
223 handlers += handlerEx; 428 handlers.Add(handlerEx);
224 m_AssetHandlers.Add(id, handlers);
225 }
226 429
227 bool success = false; 430 m_AssetHandlers.Add(id, handlers);
228 try
229 {
230 AsynchronousRestObjectRequester.MakeRequest<int, AssetBase>("GET", uri, 0,
231 delegate(AssetBase a)
232 {
233 if (a != null && m_Cache != null)
234 m_Cache.Cache(a);
235 431
236 AssetRetrievedEx handlers; 432 QueuedAssetRequest request = new QueuedAssetRequest();
237 lock (m_AssetHandlers) 433 request.id = id;
238 { 434 request.uri = uri;
239 handlers = m_AssetHandlers[id]; 435 m_requestQueue.Enqueue(request);
240 m_AssetHandlers.Remove(id);
241 }
242 handlers.Invoke(a);
243 }, m_maxAssetRequestConcurrency, m_Auth);
244
245 success = true;
246 }
247 finally
248 {
249 if (!success)
250 {
251 lock (m_AssetHandlers)
252 {
253 m_AssetHandlers.Remove(id);
254 }
255 }
256 } 436 }
257 } 437 }
258 else 438 else
@@ -277,52 +457,151 @@ namespace OpenSim.Services.Connectors
277 // This is most likely to happen because the server doesn't support this function, 457 // This is most likely to happen because the server doesn't support this function,
278 // so just silently return "doesn't exist" for all the assets. 458 // so just silently return "doesn't exist" for all the assets.
279 } 459 }
280 460
281 if (exist == null) 461 if (exist == null)
282 exist = new bool[ids.Length]; 462 exist = new bool[ids.Length];
283 463
284 return exist; 464 return exist;
285 } 465 }
286 466
467 string stringUUIDZero = UUID.Zero.ToString();
468
287 public string Store(AssetBase asset) 469 public string Store(AssetBase asset)
288 { 470 {
289 if (asset.Local) 471 // Have to assign the asset ID here. This isn't likely to
472 // trigger since current callers don't pass emtpy IDs
473 // We need the asset ID to route the request to the proper
474 // cluster member, so we can't have the server assign one.
475 if (asset.ID == string.Empty || asset.ID == stringUUIDZero)
290 { 476 {
291 if (m_Cache != null) 477 if (asset.FullID == UUID.Zero)
292 m_Cache.Cache(asset); 478 {
479 asset.FullID = UUID.Random();
480 }
481 m_log.WarnFormat("[Assets] Zero ID: {0}",asset.Name);
482 asset.ID = asset.FullID.ToString();
483 }
484
485 if (asset.FullID == UUID.Zero)
486 {
487 UUID uuid = UUID.Zero;
488 if (UUID.TryParse(asset.ID, out uuid))
489 {
490 asset.FullID = uuid;
491 }
492 if(asset.FullID == UUID.Zero)
493 {
494 m_log.WarnFormat("[Assets] Zero IDs: {0}",asset.Name);
495 asset.FullID = UUID.Random();
496 asset.ID = asset.FullID.ToString();
497 }
498 }
499
500 if (m_Cache != null)
501 m_Cache.Cache(asset);
293 502
503 if (asset.Temporary || asset.Local)
504 {
294 return asset.ID; 505 return asset.ID;
295 } 506 }
296 507
297 string uri = m_ServerURI + "/assets/"; 508 string uri = MapServer(asset.FullID.ToString()) + "/assets/";
298 509
299 string newID; 510 string newID = null;
300 try 511 try
301 { 512 {
302 newID = SynchronousRestObjectRequester.MakeRequest<AssetBase, string>("POST", uri, asset, m_Auth); 513 newID = SynchronousRestObjectRequester.
514 MakeRequest<AssetBase, string>("POST", uri, asset, 100000, m_Auth);
303 } 515 }
304 catch (Exception e) 516 catch
305 { 517 {
306 m_log.Warn(string.Format("[ASSET CONNECTOR]: Unable to send asset {0} to asset server. Reason: {1} ", asset.ID, e.Message), e); 518 newID = null;
307 return string.Empty;
308 } 519 }
309 520
310 // TEMPORARY: SRAS returns 'null' when it's asked to store existing assets 521 if (newID == null || newID == String.Empty || newID == stringUUIDZero)
311 if (newID == null)
312 { 522 {
313 m_log.DebugFormat("[ASSET CONNECTOR]: Storing of asset {0} returned null; assuming the asset already exists", asset.ID); 523 //The asset upload failed, try later
314 return asset.ID; 524 lock(m_sendRetries)
525 {
526 if (m_sendRetries[0] == null)
527 m_sendRetries[0] = new List<AssetBase>();
528 List<AssetBase> m_queue = m_sendRetries[0];
529 m_queue.Add(asset);
530 m_log.WarnFormat("[Assets] Upload failed: {0} type {1} will retry later",
531 asset.ID.ToString(), asset.Type.ToString());
532 m_retryTimer.Start();
533 }
315 } 534 }
535 else
536 {
537 if (newID != asset.ID)
538 {
539 // Placing this here, so that this work with old asset servers that don't send any reply back
540 // SynchronousRestObjectRequester returns somethins that is not an empty string
316 541
317 if (string.IsNullOrEmpty(newID)) 542 asset.ID = newID;
318 return string.Empty;
319 543
320 asset.ID = newID; 544 if (m_Cache != null)
545 m_Cache.Cache(asset);
546 }
547 }
548 return asset.ID;
549 }
321 550
322 if (m_Cache != null) 551 public void retryStore(AssetBase asset, int nextRetryLevel)
323 m_Cache.Cache(asset); 552 {
553/* this may be bad, so excluding
554 if (m_Cache != null && !m_Cache.Check(asset.ID))
555 {
556 m_log.WarnFormat("[Assets] Upload giveup asset bc no longer in local cache: {0}",
557 asset.ID.ToString();
558 return; // if no longer in cache, it was deleted or expired
559 }
560*/
561 string uri = MapServer(asset.FullID.ToString()) + "/assets/";
324 562
325 return newID; 563 string newID = null;
564 try
565 {
566 newID = SynchronousRestObjectRequester.
567 MakeRequest<AssetBase, string>("POST", uri, asset, 100000, m_Auth);
568 }
569 catch
570 {
571 newID = null;
572 }
573
574 if (newID == null || newID == String.Empty || newID == stringUUIDZero)
575 {
576 if(nextRetryLevel >= MAXSENDRETRIESLEN)
577 m_log.WarnFormat("[Assets] Upload giveup after several retries id: {0} type {1}",
578 asset.ID.ToString(), asset.Type.ToString());
579 else
580 {
581 lock(m_sendRetries)
582 {
583 if (m_sendRetries[nextRetryLevel] == null)
584 {
585 m_sendRetries[nextRetryLevel] = new List<AssetBase>();
586 }
587 List<AssetBase> m_queue = m_sendRetries[nextRetryLevel];
588 m_queue.Add(asset);
589 m_log.WarnFormat("[Assets] Upload failed: {0} type {1} will retry later",
590 asset.ID.ToString(), asset.Type.ToString());
591 }
592 }
593 }
594 else
595 {
596 m_log.InfoFormat("[Assets] Upload of {0} succeeded after {1} failed attempts", asset.ID.ToString(), nextRetryLevel.ToString());
597 if (newID != asset.ID)
598 {
599 asset.ID = newID;
600
601 if (m_Cache != null)
602 m_Cache.Cache(asset);
603 }
604 }
326 } 605 }
327 606
328 public bool UpdateContent(string id, byte[] data) 607 public bool UpdateContent(string id, byte[] data)
@@ -330,7 +609,7 @@ namespace OpenSim.Services.Connectors
330 AssetBase asset = null; 609 AssetBase asset = null;
331 610
332 if (m_Cache != null) 611 if (m_Cache != null)
333 asset = m_Cache.Get(id); 612 m_Cache.Get(id, out asset);
334 613
335 if (asset == null) 614 if (asset == null)
336 { 615 {
@@ -343,7 +622,7 @@ namespace OpenSim.Services.Connectors
343 } 622 }
344 asset.Data = data; 623 asset.Data = data;
345 624
346 string uri = m_ServerURI + "/assets/" + id; 625 string uri = MapServer(id) + "/assets/" + id;
347 626
348 if (SynchronousRestObjectRequester.MakeRequest<AssetBase, bool>("POST", uri, asset, m_Auth)) 627 if (SynchronousRestObjectRequester.MakeRequest<AssetBase, bool>("POST", uri, asset, m_Auth))
349 { 628 {
@@ -355,9 +634,10 @@ namespace OpenSim.Services.Connectors
355 return false; 634 return false;
356 } 635 }
357 636
637
358 public bool Delete(string id) 638 public bool Delete(string id)
359 { 639 {
360 string uri = m_ServerURI + "/assets/" + id; 640 string uri = MapServer(id) + "/assets/" + id;
361 641
362 if (SynchronousRestObjectRequester.MakeRequest<int, bool>("DELETE", uri, 0, m_Auth)) 642 if (SynchronousRestObjectRequester.MakeRequest<int, bool>("DELETE", uri, 0, m_Auth))
363 { 643 {
diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs
index c8a4912..0443f5a 100644
--- a/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs
@@ -84,6 +84,13 @@ namespace OpenSim.Services.Connectors
84 base.Initialise(source, "AuthenticationService"); 84 base.Initialise(source, "AuthenticationService");
85 } 85 }
86 86
87 public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID)
88 {
89 realID = UUID.Zero;
90
91 return Authenticate(principalID, password, lifetime);
92 }
93
87 public string Authenticate(UUID principalID, string password, int lifetime) 94 public string Authenticate(UUID principalID, string password, int lifetime)
88 { 95 {
89 Dictionary<string, object> sendData = new Dictionary<string, object>(); 96 Dictionary<string, object> sendData = new Dictionary<string, object>();
diff --git a/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs b/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs
index d2da85f..a130f71 100644
--- a/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs
@@ -37,7 +37,7 @@ using OpenMetaverse;
37 37
38namespace OpenSim.Services.Connectors 38namespace OpenSim.Services.Connectors
39{ 39{
40 public class AuthorizationServicesConnector 40 public class AuthorizationServicesConnector
41 { 41 {
42 private static readonly ILog m_log = 42 private static readonly ILog m_log =
43 LogManager.GetLogger( 43 LogManager.GetLogger(
@@ -45,7 +45,7 @@ namespace OpenSim.Services.Connectors
45 45
46 private string m_ServerURI = String.Empty; 46 private string m_ServerURI = String.Empty;
47 private bool m_ResponseOnFailure = true; 47 private bool m_ResponseOnFailure = true;
48 48
49 public AuthorizationServicesConnector() 49 public AuthorizationServicesConnector()
50 { 50 {
51 } 51 }
@@ -78,11 +78,11 @@ namespace OpenSim.Services.Connectors
78 throw new Exception("Authorization connector init error"); 78 throw new Exception("Authorization connector init error");
79 } 79 }
80 m_ServerURI = serviceURI; 80 m_ServerURI = serviceURI;
81 81
82 // this dictates what happens if the remote service fails, if the service fails and the value is true 82 // this dictates what happens if the remote service fails, if the service fails and the value is true
83 // the user is authorized for the region. 83 // the user is authorized for the region.
84 bool responseOnFailure = authorizationConfig.GetBoolean("ResponseOnFailure",true); 84 bool responseOnFailure = authorizationConfig.GetBoolean("ResponseOnFailure",true);
85 85
86 m_ResponseOnFailure = responseOnFailure; 86 m_ResponseOnFailure = responseOnFailure;
87 m_log.Info("[AUTHORIZATION CONNECTOR]: AuthorizationService initialized"); 87 m_log.Info("[AUTHORIZATION CONNECTOR]: AuthorizationService initialized");
88 } 88 }
@@ -91,11 +91,11 @@ namespace OpenSim.Services.Connectors
91 { 91 {
92 // do a remote call to the authorization server specified in the AuthorizationServerURI 92 // do a remote call to the authorization server specified in the AuthorizationServerURI
93 m_log.InfoFormat("[AUTHORIZATION CONNECTOR]: IsAuthorizedForRegion checking {0} at remote server {1}", userID, m_ServerURI); 93 m_log.InfoFormat("[AUTHORIZATION CONNECTOR]: IsAuthorizedForRegion checking {0} at remote server {1}", userID, m_ServerURI);
94 94
95 string uri = m_ServerURI; 95 string uri = m_ServerURI;
96 96
97 AuthorizationRequest req = new AuthorizationRequest(userID, firstname, surname, email, regionName, regionID); 97 AuthorizationRequest req = new AuthorizationRequest(userID, firstname, surname, email, regionName, regionID);
98 98
99 AuthorizationResponse response; 99 AuthorizationResponse response;
100 try 100 try
101 { 101 {
@@ -114,7 +114,7 @@ namespace OpenSim.Services.Connectors
114 } 114 }
115 m_log.DebugFormat("[AUTHORIZATION CONNECTOR] response from remote service was {0}", response.Message); 115 m_log.DebugFormat("[AUTHORIZATION CONNECTOR] response from remote service was {0}", response.Message);
116 message = response.Message; 116 message = response.Message;
117 117
118 return response.IsAuthorized; 118 return response.IsAuthorized;
119 } 119 }
120 120
diff --git a/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs b/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs
index 3f44efa..424e95a 100644
--- a/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs
@@ -94,13 +94,13 @@ namespace OpenSim.Services.Connectors
94 AvatarData avatar = GetAvatar(userID); 94 AvatarData avatar = GetAvatar(userID);
95 return avatar.ToAvatarAppearance(); 95 return avatar.ToAvatarAppearance();
96 } 96 }
97 97
98 public bool SetAppearance(UUID userID, AvatarAppearance appearance) 98 public bool SetAppearance(UUID userID, AvatarAppearance appearance)
99 { 99 {
100 AvatarData avatar = new AvatarData(appearance); 100 AvatarData avatar = new AvatarData(appearance);
101 return SetAvatar(userID,avatar); 101 return SetAvatar(userID,avatar);
102 } 102 }
103 103
104 public AvatarData GetAvatar(UUID userID) 104 public AvatarData GetAvatar(UUID userID)
105 { 105 {
106 Dictionary<string, object> sendData = new Dictionary<string, object>(); 106 Dictionary<string, object> sendData = new Dictionary<string, object>();
diff --git a/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs b/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs
index 6412bcd..b9a6281 100644
--- a/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs
+++ b/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs
@@ -120,7 +120,7 @@ namespace OpenSim.Services.Connectors
120 // If we don't have them, load them from the server 120 // If we don't have them, load them from the server
121 List<EstateSettings> estates = null; 121 List<EstateSettings> estates = null;
122 if (!m_EstateCache.TryGetValue("estates", out estates)) 122 if (!m_EstateCache.TryGetValue("estates", out estates))
123 LoadEstateSettingsAll(); 123 estates = LoadEstateSettingsAll();
124 124
125 foreach (EstateSettings es in estates) 125 foreach (EstateSettings es in estates)
126 eids.Add((int)es.EstateID); 126 eids.Add((int)es.EstateID);
@@ -133,7 +133,7 @@ namespace OpenSim.Services.Connectors
133 // If we don't have them, load them from the server 133 // If we don't have them, load them from the server
134 List<EstateSettings> estates = null; 134 List<EstateSettings> estates = null;
135 if (!m_EstateCache.TryGetValue("estates", out estates)) 135 if (!m_EstateCache.TryGetValue("estates", out estates))
136 LoadEstateSettingsAll(); 136 estates = LoadEstateSettingsAll();
137 137
138 List<int> eids = new List<int>(); 138 List<int> eids = new List<int>();
139 foreach (EstateSettings es in estates) 139 foreach (EstateSettings es in estates)
@@ -148,7 +148,7 @@ namespace OpenSim.Services.Connectors
148 // If we don't have them, load them from the server 148 // If we don't have them, load them from the server
149 List<EstateSettings> estates = null; 149 List<EstateSettings> estates = null;
150 if (!m_EstateCache.TryGetValue("estates", out estates)) 150 if (!m_EstateCache.TryGetValue("estates", out estates))
151 LoadEstateSettingsAll(); 151 estates = LoadEstateSettingsAll();
152 152
153 List<int> eids = new List<int>(); 153 List<int> eids = new List<int>();
154 foreach (EstateSettings es in estates) 154 foreach (EstateSettings es in estates)
@@ -323,7 +323,7 @@ namespace OpenSim.Services.Connectors
323 } 323 }
324 else 324 else
325 m_log.Error(string.Format( 325 m_log.Error(string.Format(
326 "[ESTATE CONNECTOR]: WebException for {0} {1} {2} ", 326 "[ESTATE CONNECTOR]: WebException for {0} {1} {2} {3}",
327 verb, uri, formdata, e)); 327 verb, uri, formdata, e));
328 } 328 }
329 } 329 }
diff --git a/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs
index b7702a8..873b554 100644
--- a/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs
@@ -86,7 +86,7 @@ namespace OpenSim.Services.Connectors.Friends
86 86
87 87
88 #region IFriendsService 88 #region IFriendsService
89 89
90 public FriendInfo[] GetFriends(UUID PrincipalID) 90 public FriendInfo[] GetFriends(UUID PrincipalID)
91 { 91 {
92 Dictionary<string, object> sendData = new Dictionary<string, object>(); 92 Dictionary<string, object> sendData = new Dictionary<string, object>();
diff --git a/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs
index 6d5ce4b..74cd703 100644
--- a/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs
+++ b/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs
@@ -144,44 +144,48 @@ namespace OpenSim.Services.Connectors.Friends
144 144
145 private bool Call(GridRegion region, Dictionary<string, object> sendData) 145 private bool Call(GridRegion region, Dictionary<string, object> sendData)
146 { 146 {
147 string reqString = ServerUtils.BuildQueryString(sendData); 147 Util.FireAndForget(x => {
148 //m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: queryString = {0}", reqString); 148 string reqString = ServerUtils.BuildQueryString(sendData);
149 if (region == null) 149 //m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: queryString = {0}", reqString);
150 return false; 150 if (region == null)
151 151 return;
152 string path = ServicePath(); 152
153 if (!region.ServerURI.EndsWith("/")) 153 string path = ServicePath();
154 path = "/" + path; 154 if (!region.ServerURI.EndsWith("/"))
155 string uri = region.ServerURI + path; 155 path = "/" + path;
156// m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: calling {0}", uri); 156 string uri = region.ServerURI + path;
157 157 // m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: calling {0}", uri);
158 try 158
159 { 159 try
160 string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
161 if (reply != string.Empty)
162 { 160 {
163 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 161 string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, 15, null, false);
164 162 if (reply != string.Empty)
165 if (replyData.ContainsKey("RESULT"))
166 { 163 {
167 if (replyData["RESULT"].ToString().ToLower() == "true") 164 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
168 return true; 165
166 if (replyData.ContainsKey("RESULT"))
167 {
168// if (replyData["RESULT"].ToString().ToLower() == "true")
169// return;
170// else
171 return;
172 }
169 else 173 else
170 return false; 174 m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: reply data does not contain result field");
175
171 } 176 }
172 else 177 else
173 m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: reply data does not contain result field"); 178 m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: received empty reply");
174 179 }
180 catch (Exception e)
181 {
182 m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: Exception when contacting remote sim at {0}: {1}", uri, e.Message);
175 } 183 }
176 else 184
177 m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: received empty reply"); 185 return;
178 } 186 });
179 catch (Exception e) 187
180 { 188 return true;
181 m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: Exception when contacting remote sim at {0}: {1}", uri, e.Message);
182 }
183
184 return false;
185 } 189 }
186 } 190 }
187} 191}
diff --git a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs
index 596f867..ded7806 100644
--- a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs
@@ -49,6 +49,9 @@ namespace OpenSim.Services.Connectors
49 49
50 private string m_ServerURI = String.Empty; 50 private string m_ServerURI = String.Empty;
51 51
52 private ExpiringCache<ulong, GridRegion> m_regionCache =
53 new ExpiringCache<ulong, GridRegion>();
54
52 public GridServicesConnector() 55 public GridServicesConnector()
53 { 56 {
54 } 57 }
@@ -275,6 +278,13 @@ namespace OpenSim.Services.Connectors
275 278
276 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) 279 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
277 { 280 {
281 GridRegion rinfo = null;
282 ulong regionHandle = Util.UIntsToLong((uint)x, (uint)y);
283
284 // this cache includes NULL regions
285 if (m_regionCache.TryGetValue(regionHandle, out rinfo))
286 return rinfo;
287
278 Dictionary<string, object> sendData = new Dictionary<string, object>(); 288 Dictionary<string, object> sendData = new Dictionary<string, object>();
279 289
280 sendData["SCOPEID"] = scopeID.ToString(); 290 sendData["SCOPEID"] = scopeID.ToString();
@@ -296,7 +306,6 @@ namespace OpenSim.Services.Connectors
296 return null; 306 return null;
297 } 307 }
298 308
299 GridRegion rinfo = null;
300 if (reply != string.Empty) 309 if (reply != string.Empty)
301 { 310 {
302 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 311 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
@@ -316,6 +325,8 @@ namespace OpenSim.Services.Connectors
316 else 325 else
317 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply"); 326 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply");
318 327
328 m_regionCache.Add(regionHandle, rinfo, TimeSpan.FromSeconds(600));
329
319 return rinfo; 330 return rinfo;
320 } 331 }
321 332
@@ -672,7 +683,7 @@ namespace OpenSim.Services.Connectors
672 683
673 return rinfos; 684 return rinfos;
674 } 685 }
675 686
676 public int GetRegionFlags(UUID scopeID, UUID regionID) 687 public int GetRegionFlags(UUID scopeID, UUID regionID)
677 { 688 {
678 Dictionary<string, object> sendData = new Dictionary<string, object>(); 689 Dictionary<string, object> sendData = new Dictionary<string, object>();
@@ -744,7 +755,7 @@ namespace OpenSim.Services.Connectors
744 if (reply != string.Empty) 755 if (reply != string.Empty)
745 { 756 {
746 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 757 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
747 758
748 if ((replyData != null) && replyData.Count > 0) 759 if ((replyData != null) && replyData.Count > 0)
749 { 760 {
750 foreach (string key in replyData.Keys) 761 foreach (string key in replyData.Keys)
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
index b1663ee..e814c45 100644
--- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
@@ -73,13 +73,15 @@ namespace OpenSim.Services.Connectors.Hypergrid
73 return "foreignobject/"; 73 return "foreignobject/";
74 } 74 }
75 75
76 public bool LinkRegion(GridRegion info, out UUID regionID, out ulong realHandle, out string externalName, out string imageURL, out string reason) 76 public bool LinkRegion(GridRegion info, out UUID regionID, out ulong realHandle, out string externalName, out string imageURL, out string reason, out int sizeX, out int sizeY)
77 { 77 {
78 regionID = UUID.Zero; 78 regionID = UUID.Zero;
79 imageURL = string.Empty; 79 imageURL = string.Empty;
80 realHandle = 0; 80 realHandle = 0;
81 externalName = string.Empty; 81 externalName = string.Empty;
82 reason = string.Empty; 82 reason = string.Empty;
83 sizeX = (int)Constants.RegionSize;
84 sizeY = (int)Constants.RegionSize;
83 85
84 Hashtable hash = new Hashtable(); 86 Hashtable hash = new Hashtable();
85 hash["region_name"] = info.RegionName; 87 hash["region_name"] = info.RegionName;
@@ -134,8 +136,15 @@ namespace OpenSim.Services.Connectors.Hypergrid
134 externalName = (string)hash["external_name"]; 136 externalName = (string)hash["external_name"];
135 //m_log.Debug(">> HERE, externalName: " + externalName); 137 //m_log.Debug(">> HERE, externalName: " + externalName);
136 } 138 }
139 if (hash["size_x"] != null)
140 {
141 Int32.TryParse((string)hash["size_x"], out sizeX);
142 }
143 if (hash["size_y"] != null)
144 {
145 Int32.TryParse((string)hash["size_y"], out sizeY);
146 }
137 } 147 }
138
139 } 148 }
140 catch (Exception e) 149 catch (Exception e)
141 { 150 {
@@ -160,14 +169,15 @@ namespace OpenSim.Services.Connectors.Hypergrid
160 169
161 try 170 try
162 { 171 {
163 WebClient c = new WebClient(); 172 //m_log.Debug("JPEG: " + imageURL);
164 string name = regionID.ToString(); 173 string name = regionID.ToString();
165 filename = Path.Combine(storagePath, name + ".jpg"); 174 filename = Path.Combine(storagePath, name + ".jpg");
166 m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: Map image at {0}, cached at {1}", imageURL, filename); 175 m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: Map image at {0}, cached at {1}", imageURL, filename);
167 if (!File.Exists(filename)) 176 if (!File.Exists(filename))
168 { 177 {
169 m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: downloading..."); 178 m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: downloading...");
170 c.DownloadFile(imageURL, filename); 179 using(WebClient c = new WebClient())
180 c.DownloadFile(imageURL, filename);
171 } 181 }
172 else 182 else
173 { 183 {
@@ -189,11 +199,10 @@ namespace OpenSim.Services.Connectors.Hypergrid
189 199
190 ass.Data = imageData; 200 ass.Data = imageData;
191 201
192 mapTile = ass.FullID;
193
194 // finally
195 m_AssetService.Store(ass); 202 m_AssetService.Store(ass);
196 203
204 // finally
205 mapTile = ass.FullID;
197 } 206 }
198 catch // LEGIT: Catching problems caused by OpenJPEG p/invoke 207 catch // LEGIT: Catching problems caused by OpenJPEG p/invoke
199 { 208 {
diff --git a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs
index 622d4e1..8b31fa2 100644
--- a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs
@@ -277,7 +277,10 @@ namespace OpenSim.Services.Connectors.Hypergrid
277 { 277 {
278 reply = SynchronousRestFormsRequester.MakeRequest("POST", 278 reply = SynchronousRestFormsRequester.MakeRequest("POST",
279 uri, 279 uri,
280 ServerUtils.BuildQueryString(sendData), 15); 280 ServerUtils.BuildQueryString(sendData),
281 15,
282 null,
283 false);
281 } 284 }
282 catch (Exception e) 285 catch (Exception e)
283 { 286 {
diff --git a/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs
index b5e6d69..91e1740 100644
--- a/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs
@@ -33,7 +33,7 @@ using Nini.Config;
33 33
34namespace OpenSim.Services.Connectors 34namespace OpenSim.Services.Connectors
35{ 35{
36 public class HeloServicesConnector 36 public class HeloServicesConnector
37 { 37 {
38 private static readonly ILog m_log = 38 private static readonly ILog m_log =
39 LogManager.GetLogger( 39 LogManager.GetLogger(
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
index 8abd046..f2bb52a 100644
--- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
@@ -70,9 +70,14 @@ namespace OpenSim.Services.Connectors.Hypergrid
70 { 70 {
71 Uri m_Uri = new Uri(m_ServerURL); 71 Uri m_Uri = new Uri(m_ServerURL);
72 IPAddress ip = Util.GetHostFromDNS(m_Uri.Host); 72 IPAddress ip = Util.GetHostFromDNS(m_Uri.Host);
73 m_ServerURL = m_ServerURL.Replace(m_Uri.Host, ip.ToString()); 73 if(ip != null)
74 if (!m_ServerURL.EndsWith("/")) 74 {
75 m_ServerURL += "/"; 75 m_ServerURL = m_ServerURL.Replace(m_Uri.Host, ip.ToString());
76 if (!m_ServerURL.EndsWith("/"))
77 m_ServerURL += "/";
78 }
79 else
80 m_log.DebugFormat("[USER AGENT CONNECTOR]: Failed to resolv address of {0}", url);
76 } 81 }
77 catch (Exception e) 82 catch (Exception e)
78 { 83 {
@@ -113,7 +118,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
113 return "homeagent/"; 118 return "homeagent/";
114 } 119 }
115 120
116 // The Login service calls this interface with fromLogin=true 121 // The Login service calls this interface with fromLogin=true
117 // Sims call it with fromLogin=false 122 // Sims call it with fromLogin=false
118 // Either way, this is verified by the handler 123 // Either way, this is verified by the handler
119 public bool LoginAgentToGrid(GridRegion source, AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, bool fromLogin, out string reason) 124 public bool LoginAgentToGrid(GridRegion source, AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, bool fromLogin, out string reason)
@@ -138,7 +143,8 @@ namespace OpenSim.Services.Connectors.Hypergrid
138 Console.WriteLine(" >>> LoginAgentToGrid <<< " + home.ServerURI); 143 Console.WriteLine(" >>> LoginAgentToGrid <<< " + home.ServerURI);
139 144
140 uint flags = fromLogin ? (uint)TeleportFlags.ViaLogin : (uint)TeleportFlags.ViaHome; 145 uint flags = fromLogin ? (uint)TeleportFlags.ViaLogin : (uint)TeleportFlags.ViaHome;
141 return CreateAgent(source, home, aCircuit, flags, out reason); 146 EntityTransferContext ctx = new EntityTransferContext();
147 return CreateAgent(source, home, aCircuit, flags, ctx, out reason);
142 } 148 }
143 149
144 150
@@ -158,7 +164,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
158 } 164 }
159 165
160 public void SetClientToken(UUID sessionID, string token) 166 public void SetClientToken(UUID sessionID, string token)
161 { 167 {
162 // no-op 168 // no-op
163 } 169 }
164 170
@@ -415,7 +421,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
415 421
416 XmlRpcRequest request = new XmlRpcRequest("get_online_friends", paramList); 422 XmlRpcRequest request = new XmlRpcRequest("get_online_friends", paramList);
417// string reason = string.Empty; 423// string reason = string.Empty;
418 424
419 // Send and get reply 425 // Send and get reply
420 List<UUID> online = new List<UUID>(); 426 List<UUID> online = new List<UUID>();
421 XmlRpcResponse response = null; 427 XmlRpcResponse response = null;
@@ -496,7 +502,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
496 hash["userID"] = userID.ToString(); 502 hash["userID"] = userID.ToString();
497 503
498 hash = CallServer("get_server_urls", hash); 504 hash = CallServer("get_server_urls", hash);
499 505
500 Dictionary<string, object> serverURLs = new Dictionary<string, object>(); 506 Dictionary<string, object> serverURLs = new Dictionary<string, object>();
501 foreach (object key in hash.Keys) 507 foreach (object key in hash.Keys)
502 { 508 {
@@ -515,7 +521,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
515 Hashtable hash = new Hashtable(); 521 Hashtable hash = new Hashtable();
516 hash["userID"] = userID.ToString(); 522 hash["userID"] = userID.ToString();
517 523
518 hash = CallServer("locate_user", hash); 524 hash = CallServer("locate_user", hash);
519 525
520 string url = string.Empty; 526 string url = string.Empty;
521 527
@@ -571,7 +577,11 @@ namespace OpenSim.Services.Connectors.Hypergrid
571 XmlRpcResponse response = null; 577 XmlRpcResponse response = null;
572 try 578 try
573 { 579 {
574 response = request.Send(m_ServerURL, 10000); 580 // We can not use m_ServerURL here anymore because it causes
581 // the HTTP request to be built without a host name. This messes
582 // with OSGrid's NGINX and can make OSGrid avatars unable to TP
583 // to other grids running recent mono.
584 response = request.Send(m_ServerURLHost, 10000);
575 } 585 }
576 catch (Exception e) 586 catch (Exception e)
577 { 587 {
diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
index 7cecd93..dcf25ad 100644
--- a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
@@ -54,6 +54,8 @@ namespace OpenSim.Services.Connectors
54 54
55 private string m_ServerURI = String.Empty; 55 private string m_ServerURI = String.Empty;
56 56
57 private int m_maxRetries = 0;
58
57 /// <summary> 59 /// <summary>
58 /// Timeout for remote requests. 60 /// Timeout for remote requests.
59 /// </summary> 61 /// </summary>
@@ -61,6 +63,7 @@ namespace OpenSim.Services.Connectors
61 /// In this case, -1 is default timeout (100 seconds), not infinite. 63 /// In this case, -1 is default timeout (100 seconds), not infinite.
62 /// </remarks> 64 /// </remarks>
63 private int m_requestTimeoutSecs = -1; 65 private int m_requestTimeoutSecs = -1;
66 private string m_configName = "InventoryService";
64 67
65 private const double CACHE_EXPIRATION_SECONDS = 20.0; 68 private const double CACHE_EXPIRATION_SECONDS = 20.0;
66 private static ExpiringCache<UUID, InventoryItemBase> m_ItemCache = new ExpiringCache<UUID,InventoryItemBase>(); 69 private static ExpiringCache<UUID, InventoryItemBase> m_ItemCache = new ExpiringCache<UUID,InventoryItemBase>();
@@ -74,6 +77,13 @@ namespace OpenSim.Services.Connectors
74 m_ServerURI = serverURI.TrimEnd('/'); 77 m_ServerURI = serverURI.TrimEnd('/');
75 } 78 }
76 79
80 public XInventoryServicesConnector(IConfigSource source, string configName)
81 : base(source, configName)
82 {
83 m_configName = configName;
84 Initialise(source);
85 }
86
77 public XInventoryServicesConnector(IConfigSource source) 87 public XInventoryServicesConnector(IConfigSource source)
78 : base(source, "InventoryService") 88 : base(source, "InventoryService")
79 { 89 {
@@ -82,10 +92,10 @@ namespace OpenSim.Services.Connectors
82 92
83 public virtual void Initialise(IConfigSource source) 93 public virtual void Initialise(IConfigSource source)
84 { 94 {
85 IConfig config = source.Configs["InventoryService"]; 95 IConfig config = source.Configs[m_configName];
86 if (config == null) 96 if (config == null)
87 { 97 {
88 m_log.Error("[INVENTORY CONNECTOR]: InventoryService missing from OpenSim.ini"); 98 m_log.ErrorFormat("[INVENTORY CONNECTOR]: {0} missing from OpenSim.ini", m_configName);
89 throw new Exception("Inventory connector init error"); 99 throw new Exception("Inventory connector init error");
90 } 100 }
91 101
@@ -100,16 +110,17 @@ namespace OpenSim.Services.Connectors
100 m_ServerURI = serviceURI; 110 m_ServerURI = serviceURI;
101 111
102 m_requestTimeoutSecs = config.GetInt("RemoteRequestTimeout", m_requestTimeoutSecs); 112 m_requestTimeoutSecs = config.GetInt("RemoteRequestTimeout", m_requestTimeoutSecs);
113 m_maxRetries = config.GetInt("MaxRetries", m_maxRetries);
103 114
104 StatsManager.RegisterStat( 115 StatsManager.RegisterStat(
105 new Stat( 116 new Stat(
106 "RequestsMade", 117 "RequestsMade",
107 "Requests made", 118 "Requests made",
108 "Number of requests made to the remove inventory service", 119 "Number of requests made to the remove inventory service",
109 "requests", 120 "requests",
110 "inventory", 121 "inventory",
111 serviceURI, 122 serviceURI,
112 StatType.Pull, 123 StatType.Pull,
113 MeasuresOfInterest.AverageChangeOverTime, 124 MeasuresOfInterest.AverageChangeOverTime,
114 s => s.Value = RequestsMade, 125 s => s.Value = RequestsMade,
115 StatVerbosity.Debug)); 126 StatVerbosity.Debug));
@@ -240,7 +251,7 @@ namespace OpenSim.Services.Connectors
240 251
241 return inventory; 252 return inventory;
242 } 253 }
243 254
244 public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs) 255 public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs)
245 { 256 {
246 InventoryCollection[] inventoryArr = new InventoryCollection[folderIDs.Length]; 257 InventoryCollection[] inventoryArr = new InventoryCollection[folderIDs.Length];
@@ -520,10 +531,10 @@ namespace OpenSim.Services.Connectors
520 return CheckReturn(ret); 531 return CheckReturn(ret);
521 } 532 }
522 533
523 public InventoryItemBase GetItem(InventoryItemBase item) 534 public InventoryItemBase GetItem(UUID principalID, UUID itemID)
524 { 535 {
525 InventoryItemBase retrieved = null; 536 InventoryItemBase retrieved = null;
526 if (m_ItemCache.TryGetValue(item.ID, out retrieved)) 537 if (m_ItemCache.TryGetValue(itemID, out retrieved))
527 { 538 {
528 return retrieved; 539 return retrieved;
529 } 540 }
@@ -532,7 +543,8 @@ namespace OpenSim.Services.Connectors
532 { 543 {
533 Dictionary<string, object> ret = MakeRequest("GETITEM", 544 Dictionary<string, object> ret = MakeRequest("GETITEM",
534 new Dictionary<string, object> { 545 new Dictionary<string, object> {
535 { "ID", item.ID.ToString() } 546 { "ID", itemID.ToString() },
547 { "PRINCIPAL", principalID.ToString() }
536 }); 548 });
537 549
538 if (!CheckReturn(ret)) 550 if (!CheckReturn(ret))
@@ -545,7 +557,7 @@ namespace OpenSim.Services.Connectors
545 m_log.Error("[XINVENTORY SERVICES CONNECTOR]: Exception in GetItem: ", e); 557 m_log.Error("[XINVENTORY SERVICES CONNECTOR]: Exception in GetItem: ", e);
546 } 558 }
547 559
548 m_ItemCache.AddOrUpdate(item.ID, retrieved, CACHE_EXPIRATION_SECONDS); 560 m_ItemCache.AddOrUpdate(itemID, retrieved, CACHE_EXPIRATION_SECONDS);
549 561
550 return retrieved; 562 return retrieved;
551 } 563 }
@@ -559,6 +571,7 @@ namespace OpenSim.Services.Connectors
559 List<UUID> pending = new List<UUID>(); 571 List<UUID> pending = new List<UUID>();
560 InventoryItemBase item = null; 572 InventoryItemBase item = null;
561 int i = 0; 573 int i = 0;
574
562 foreach (UUID id in itemIDs) 575 foreach (UUID id in itemIDs)
563 { 576 {
564 if (m_ItemCache.TryGetValue(id, out item)) 577 if (m_ItemCache.TryGetValue(id, out item))
@@ -612,13 +625,14 @@ namespace OpenSim.Services.Connectors
612 return itemArr; 625 return itemArr;
613 } 626 }
614 627
615 public InventoryFolderBase GetFolder(InventoryFolderBase folder) 628 public InventoryFolderBase GetFolder(UUID principalID, UUID folderID)
616 { 629 {
617 try 630 try
618 { 631 {
619 Dictionary<string, object> ret = MakeRequest("GETFOLDER", 632 Dictionary<string, object> ret = MakeRequest("GETFOLDER",
620 new Dictionary<string, object> { 633 new Dictionary<string, object> {
621 { "ID", folder.ID.ToString() } 634 { "ID", folderID.ToString() },
635 { "PRINCIPAL", principalID.ToString() }
622 }); 636 });
623 637
624 if (!CheckReturn(ret)) 638 if (!CheckReturn(ret))
@@ -660,7 +674,7 @@ namespace OpenSim.Services.Connectors
660 { "ASSET", assetID.ToString() } 674 { "ASSET", assetID.ToString() }
661 }); 675 });
662 676
663 // We cannot use CheckReturn() here because valid values for RESULT are "false" (in the case of request failure) or an int 677 // We cannot use CheckReturn() here because valid values for RESULT are "false" (in the case of request failure) or an int
664 if (ret == null) 678 if (ret == null)
665 return 0; 679 return 0;
666 680
@@ -697,11 +711,21 @@ namespace OpenSim.Services.Connectors
697 711
698 RequestsMade++; 712 RequestsMade++;
699 713
700 string reply 714 string reply = String.Empty;
701 = SynchronousRestFormsRequester.MakeRequest( 715 int retries = 0;
716
717 do
718 {
719 reply = SynchronousRestFormsRequester.MakeRequest(
702 "POST", m_ServerURI + "/xinventory", 720 "POST", m_ServerURI + "/xinventory",
703 ServerUtils.BuildQueryString(sendData), m_requestTimeoutSecs, m_Auth); 721 ServerUtils.BuildQueryString(sendData), m_requestTimeoutSecs, m_Auth);
704 722
723 if (reply != String.Empty)
724 break;
725
726 retries++;
727 } while (retries <= m_maxRetries);
728
705 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse( 729 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(
706 reply); 730 reply);
707 731
diff --git a/OpenSim/Services/Connectors/Land/LandServicesConnector.cs b/OpenSim/Services/Connectors/Land/LandServicesConnector.cs
index 034c42e..5492e83 100644
--- a/OpenSim/Services/Connectors/Land/LandServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Land/LandServicesConnector.cs
@@ -66,22 +66,31 @@ namespace OpenSim.Services.Connectors
66 public virtual LandData GetLandData(UUID scopeID, ulong regionHandle, uint x, uint y, out byte regionAccess) 66 public virtual LandData GetLandData(UUID scopeID, ulong regionHandle, uint x, uint y, out byte regionAccess)
67 { 67 {
68 LandData landData = null; 68 LandData landData = null;
69 Hashtable hash = new Hashtable();
70 hash["region_handle"] = regionHandle.ToString();
71 hash["x"] = x.ToString();
72 hash["y"] = y.ToString();
73 69
74 IList paramList = new ArrayList(); 70 IList paramList = new ArrayList();
75 paramList.Add(hash);
76 regionAccess = 42; // Default to adult. Better safe... 71 regionAccess = 42; // Default to adult. Better safe...
77 72
78 try 73 try
79 { 74 {
80 uint xpos = 0, ypos = 0; 75 uint xpos = 0, ypos = 0;
81 Util.RegionHandleToWorldLoc(regionHandle, out xpos, out ypos); 76 Util.RegionHandleToWorldLoc(regionHandle, out xpos, out ypos);
77
82 GridRegion info = m_GridService.GetRegionByPosition(scopeID, (int)xpos, (int)ypos); 78 GridRegion info = m_GridService.GetRegionByPosition(scopeID, (int)xpos, (int)ypos);
83 if (info != null) // just to be sure 79 if (info != null) // just to be sure
84 { 80 {
81 string targetHandlestr = info.RegionHandle.ToString();
82 if( ypos == 0 ) //HG proxy?
83 {
84 // this is real region handle on hg proxies hack
85 targetHandlestr = info.RegionSecret;
86 }
87
88 Hashtable hash = new Hashtable();
89 hash["region_handle"] = targetHandlestr;
90 hash["x"] = x.ToString();
91 hash["y"] = y.ToString();
92 paramList.Add(hash);
93
85 XmlRpcRequest request = new XmlRpcRequest("land_data", paramList); 94 XmlRpcRequest request = new XmlRpcRequest("land_data", paramList);
86 XmlRpcResponse response = request.Send(info.ServerURI, 10000); 95 XmlRpcResponse response = request.Send(info.ServerURI, 10000);
87 if (response.IsFault) 96 if (response.IsFault)
@@ -108,17 +117,19 @@ namespace OpenSim.Services.Connectors
108 landData.UserLocation = Vector3.Parse((string)hash["UserLocation"]); 117 landData.UserLocation = Vector3.Parse((string)hash["UserLocation"]);
109 if (hash["RegionAccess"] != null) 118 if (hash["RegionAccess"] != null)
110 regionAccess = (byte)Convert.ToInt32((string)hash["RegionAccess"]); 119 regionAccess = (byte)Convert.ToInt32((string)hash["RegionAccess"]);
120 if(hash["Dwell"] != null)
121 landData.Dwell = Convert.ToSingle((string)hash["Dwell"]);
111 m_log.DebugFormat("[LAND CONNECTOR]: Got land data for parcel {0}", landData.Name); 122 m_log.DebugFormat("[LAND CONNECTOR]: Got land data for parcel {0}", landData.Name);
112 } 123 }
113 catch (Exception e) 124 catch (Exception e)
114 { 125 {
115 m_log.ErrorFormat( 126 m_log.ErrorFormat(
116 "[LAND CONNECTOR]: Got exception while parsing land-data: {0} {1}", 127 "[LAND CONNECTOR]: Got exception while parsing land-data: {0} {1}",
117 e.Message, e.StackTrace); 128 e.Message, e.StackTrace);
118 } 129 }
119 } 130 }
120 } 131 }
121 else 132 else
122 m_log.WarnFormat("[LAND CONNECTOR]: Couldn't find region with handle {0}", regionHandle); 133 m_log.WarnFormat("[LAND CONNECTOR]: Couldn't find region with handle {0}", regionHandle);
123 } 134 }
124 catch (Exception e) 135 catch (Exception e)
@@ -126,8 +137,8 @@ namespace OpenSim.Services.Connectors
126 m_log.ErrorFormat( 137 m_log.ErrorFormat(
127 "[LAND CONNECTOR]: Couldn't contact region {0}: {1} {2}", regionHandle, e.Message, e.StackTrace); 138 "[LAND CONNECTOR]: Couldn't contact region {0}: {1} {2}", regionHandle, e.Message, e.StackTrace);
128 } 139 }
129 140
130 return landData; 141 return landData;
131 } 142 }
132 } 143 }
133} \ No newline at end of file 144}
diff --git a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs
index c91ed84..84c4efe 100644
--- a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs
+++ b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs
@@ -149,13 +149,75 @@ namespace OpenSim.Services.Connectors
149 return false; 149 return false;
150 } 150 }
151 151
152 public bool AddMapTile(int x, int y, byte[] jpgData, out string reason) 152 public bool RemoveMapTile(int x, int y, UUID scopeID, out string reason)
153 { 153 {
154 reason = string.Empty; 154 reason = string.Empty;
155 int tickstart = Util.EnvironmentTickCount(); 155 int tickstart = Util.EnvironmentTickCount();
156 Dictionary<string, object> sendData = new Dictionary<string, object>(); 156 Dictionary<string, object> sendData = new Dictionary<string, object>();
157 sendData["X"] = x.ToString(); 157 sendData["X"] = x.ToString();
158 sendData["Y"] = y.ToString(); 158 sendData["Y"] = y.ToString();
159 sendData["SCOPE"] = scopeID.ToString();
160
161 string reqString = ServerUtils.BuildQueryString(sendData);
162 string uri = m_ServerURI + "/removemap";
163
164 try
165 {
166 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
167 uri,
168 reqString);
169 if (reply != string.Empty)
170 {
171 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
172
173 if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "success"))
174 {
175 return true;
176 }
177 else if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "failure"))
178 {
179 m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Delete failed: {0}", replyData["Message"].ToString());
180 reason = replyData["Message"].ToString();
181 return false;
182 }
183 else if (!replyData.ContainsKey("Result"))
184 {
185 m_log.DebugFormat("[MAP IMAGE CONNECTOR]: reply data does not contain result field");
186 }
187 else
188 {
189 m_log.DebugFormat("[MAP IMAGE CONNECTOR]: unexpected result {0}", replyData["Result"].ToString());
190 reason = "Unexpected result " + replyData["Result"].ToString();
191 }
192
193 }
194 else
195 {
196 m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Map post received null reply");
197 }
198 }
199 catch (Exception e)
200 {
201 m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Exception when contacting map server at {0}: {1}", uri, e.Message);
202 }
203 finally
204 {
205 // This just dumps a warning for any operation that takes more than 100 ms
206 int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
207 m_log.DebugFormat("[MAP IMAGE CONNECTOR]: map tile deleted in {0}ms", tickdiff);
208 }
209
210 return false;
211 }
212
213 public bool AddMapTile(int x, int y, byte[] jpgData, UUID scopeID, out string reason)
214 {
215 reason = string.Empty;
216 int tickstart = Util.EnvironmentTickCount();
217 Dictionary<string, object> sendData = new Dictionary<string, object>();
218 sendData["X"] = x.ToString();
219 sendData["Y"] = y.ToString();
220 sendData["SCOPE"] = scopeID.ToString();
159 sendData["TYPE"] = "image/jpeg"; 221 sendData["TYPE"] = "image/jpeg";
160 sendData["DATA"] = Convert.ToBase64String(jpgData); 222 sendData["DATA"] = Convert.ToBase64String(jpgData);
161 223
@@ -216,7 +278,7 @@ namespace OpenSim.Services.Connectors
216 278
217 } 279 }
218 280
219 public byte[] GetMapTile(string fileName, out string format) 281 public byte[] GetMapTile(string fileName, UUID scopeID, out string format)
220 { 282 {
221 format = string.Empty; 283 format = string.Empty;
222 new Exception("GetMapTile method not Implemented"); 284 new Exception("GetMapTile method not Implemented");
diff --git a/OpenSim/Services/Connectors/MuteList/MuteListServicesConnector.cs b/OpenSim/Services/Connectors/MuteList/MuteListServicesConnector.cs
new file mode 100644
index 0000000..e574c1d
--- /dev/null
+++ b/OpenSim/Services/Connectors/MuteList/MuteListServicesConnector.cs
@@ -0,0 +1,183 @@
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;
35
36using OpenSim.Framework.ServiceAuth;
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 MuteListServicesConnector : BaseServiceConnector, IMuteListService
45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47
48 private string m_ServerURI = String.Empty;
49
50 public MuteListServicesConnector()
51 {
52 }
53
54 public MuteListServicesConnector(string serverURI)
55 {
56 m_ServerURI = serverURI.TrimEnd('/') + "/mutelist";
57 }
58
59 public MuteListServicesConnector(IConfigSource source)
60 {
61 Initialise(source);
62 }
63
64 public virtual void Initialise(IConfigSource source)
65 {
66 IConfig gridConfig = source.Configs["MuteListService"];
67 if (gridConfig == null)
68 {
69 m_log.Error("[MUTELIST CONNECTOR]: MuteListService missing from configuration");
70 throw new Exception("MuteList connector init error");
71 }
72
73 string serviceURI = gridConfig.GetString("MuteListServerURI",
74 String.Empty);
75
76 if (serviceURI == String.Empty)
77 {
78 m_log.Error("[GRID USER CONNECTOR]: No Server URI named in section GridUserService");
79 throw new Exception("GridUser connector init error");
80 }
81 m_ServerURI = serviceURI + "/mutelist";;
82 base.Initialise(source, "MuteListService");
83 }
84
85 #region IMuteListService
86 public Byte[] MuteListRequest(UUID agentID, uint crc)
87 {
88 Dictionary<string, object> sendData = new Dictionary<string, object>();
89 sendData["METHOD"] = "get";
90 sendData["agentid"] = agentID.ToString();
91 sendData["mutecrc"] = crc.ToString();
92
93 try
94 {
95 string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI,
96 ServerUtils.BuildQueryString(sendData), m_Auth);
97 if (reply != string.Empty)
98 {
99 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
100
101 if (replyData.ContainsKey("result"))
102 {
103 string datastr = replyData["result"].ToString();
104 if(String.IsNullOrWhiteSpace(datastr))
105 return null;
106 return Convert.FromBase64String(datastr);
107 }
108 else
109 m_log.DebugFormat("[MUTELIST CONNECTOR]: get reply data does not contain result field");
110 }
111 else
112 m_log.DebugFormat("[MUTELIST CONNECTOR]: get received empty reply");
113 }
114 catch (Exception e)
115 {
116 m_log.DebugFormat("[MUTELIST CONNECTOR]: Exception when contacting server at {0}: {1}", m_ServerURI, e.Message);
117 }
118
119 return null;
120 }
121
122 public bool UpdateMute(MuteData mute)
123 {
124 Dictionary<string, object> sendData = new Dictionary<string, object>();
125 sendData["METHOD"] = "update";
126 sendData["agentid"] = mute.AgentID.ToString();
127 sendData["muteid"] = mute.MuteID.ToString();
128 if(mute.MuteType != 0)
129 sendData["mutetype"] = mute.MuteType.ToString();
130 if(mute.MuteFlags != 0)
131 sendData["muteflags"] = mute.MuteFlags.ToString();
132 sendData["mutestamp"] = mute.Stamp.ToString();
133 if(!String.IsNullOrEmpty(mute.MuteName))
134 sendData["mutename"] = mute.MuteName;
135
136 return doSimplePost(ServerUtils.BuildQueryString(sendData), "update");
137 }
138
139 public bool RemoveMute(UUID agentID, UUID muteID, string muteName)
140 {
141 Dictionary<string, object> sendData = new Dictionary<string, object>();
142 sendData["METHOD"] = "delete";
143 sendData["agentid"] = agentID.ToString();
144 sendData["muteid"] = muteID.ToString();
145 if(!String.IsNullOrEmpty(muteName))
146 sendData["mutename"] = muteName;
147
148 return doSimplePost(ServerUtils.BuildQueryString(sendData), "remove");
149 }
150
151 #endregion IMuteListService
152
153 private bool doSimplePost(string reqString, string meth)
154 {
155 try
156 {
157 string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI, reqString, m_Auth);
158 if (reply != string.Empty)
159 {
160 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
161
162 if (replyData.ContainsKey("result"))
163 {
164 if (replyData["result"].ToString().ToLower() == "success")
165 return true;
166 else
167 return false;
168 }
169 else
170 m_log.DebugFormat("[MUTELIST CONNECTOR]: {0} reply data does not contain result field", meth);
171 }
172 else
173 m_log.DebugFormat("[MUTELIST CONNECTOR]: {0} received empty reply", meth);
174 }
175 catch (Exception e)
176 {
177 m_log.DebugFormat("[MUTELIST CONNECTOR]: Exception when contacting server at {0}: {1}", m_ServerURI, e.Message);
178 }
179
180 return false;
181 }
182 }
183}
diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
index 925364a..33b3866 100644
--- a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
@@ -151,11 +151,11 @@ namespace OpenSim.Services.Connectors
151 os.Write(buffer, 0, strBuffer.Length); //Send it 151 os.Write(buffer, 0, strBuffer.Length); //Send it
152 //m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri); 152 //m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri);
153 } 153 }
154 catch (Exception e) 154 catch (Exception /*e*/)
155 { 155 {
156 m_log.Warn(string.Format( 156// m_log.WarnFormat(
157 "[NEIGHBOUR SERVICES CONNECTOR]: Unable to send HelloNeighbour from {0} to {1} (uri {2}). Exception {3} ", 157// "[NEIGHBOUR SERVICE CONNCTOR]: Unable to send HelloNeighbour from {0} to {1}. Exception {2}{3}",
158 thisRegion.RegionName, region.RegionName, uri, e.Message), e); 158// thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace);
159 159
160 return false; 160 return false;
161 } 161 }
@@ -183,8 +183,8 @@ namespace OpenSim.Services.Connectors
183 { 183 {
184 using (StreamReader sr = new StreamReader(s)) 184 using (StreamReader sr = new StreamReader(s))
185 { 185 {
186 sr.ReadToEnd(); // just try to read
186 //reply = sr.ReadToEnd().Trim(); 187 //reply = sr.ReadToEnd().Trim();
187 sr.ReadToEnd().Trim();
188 //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); 188 //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply);
189 } 189 }
190 } 190 }
diff --git a/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs
index b7e95c4..04a0c5e 100644
--- a/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs
@@ -107,7 +107,7 @@ namespace OpenSim.Services.Connectors
107 { 107 {
108 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 108 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
109 uri, 109 uri,
110 reqString, 110 reqString,
111 m_Auth); 111 m_Auth);
112 if (reply != string.Empty) 112 if (reply != string.Empty)
113 { 113 {
@@ -313,6 +313,74 @@ namespace OpenSim.Services.Connectors
313 { 313 {
314 pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]); 314 pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]);
315 } 315 }
316 else
317 {
318 if (replyData["result"].ToString() == "null")
319 return null;
320
321 m_log.DebugFormat("[PRESENCE CONNECTOR]: Invalid reply (result not dictionary) received from presence server when querying for sessionID {0}", sessionID.ToString());
322 }
323 }
324 else
325 {
326 m_log.DebugFormat("[PRESENCE CONNECTOR]: Invalid reply received from presence server when querying for sessionID {0}", sessionID.ToString());
327 }
328
329 return pinfo;
330 }
331
332 public PresenceInfo GetAgentByUser(UUID userID)
333 {
334 Dictionary<string, object> sendData = new Dictionary<string, object>();
335 //sendData["SCOPEID"] = scopeID.ToString();
336 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
337 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
338 sendData["METHOD"] = "getagentbyuser";
339
340 sendData["UserID"] = userID.ToString();
341
342 string reply = string.Empty;
343 string reqString = ServerUtils.BuildQueryString(sendData);
344 string uri = m_ServerURI + "/presence";
345 // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString);
346 try
347 {
348 reply = SynchronousRestFormsRequester.MakeRequest("POST",
349 uri,
350 reqString,
351 m_Auth);
352 if (reply == null || (reply != null && reply == string.Empty))
353 {
354 m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgentByUser received null or empty reply");
355 return null;
356 }
357 }
358 catch (Exception e)
359 {
360 m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message);
361 return null;
362 }
363
364 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
365 PresenceInfo pinfo = null;
366
367 if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null))
368 {
369 if (replyData["result"] is Dictionary<string, object>)
370 {
371 pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]);
372 }
373 else
374 {
375 if (replyData["result"].ToString() == "null")
376 return null;
377
378 m_log.DebugFormat("[PRESENCE CONNECTOR]: Invalid reply (result not dictionary) received from presence server when querying for userID {0}", userID.ToString());
379 }
380 }
381 else
382 {
383 m_log.DebugFormat("[PRESENCE CONNECTOR]: Invalid reply received from presence server when querying for userID {0}", userID.ToString());
316 } 384 }
317 385
318 return pinfo; 386 return pinfo;
@@ -355,7 +423,7 @@ namespace OpenSim.Services.Connectors
355 423
356 if (replyData != null) 424 if (replyData != null)
357 { 425 {
358 if (replyData.ContainsKey("result") && 426 if (replyData.ContainsKey("result") &&
359 (replyData["result"].ToString() == "null" || replyData["result"].ToString() == "Failure")) 427 (replyData["result"].ToString() == "null" || replyData["result"].ToString() == "Failure"))
360 { 428 {
361 return new PresenceInfo[0]; 429 return new PresenceInfo[0];
diff --git a/OpenSim/Services/Connectors/Properties/AssemblyInfo.cs b/OpenSim/Services/Connectors/Properties/AssemblyInfo.cs
index c581a59..76d26d6 100644
--- a/OpenSim/Services/Connectors/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/Connectors/Properties/AssemblyInfo.cs
@@ -2,7 +2,7 @@
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4 4
5// General Information about an assembly is controlled through the following 5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly. 7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Services.Connectors")] 8[assembly: AssemblyTitle("OpenSim.Services.Connectors")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
14[assembly: AssemblyTrademark("")] 14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")] 15[assembly: AssemblyCulture("")]
16 16
17// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)] 20[assembly: ComVisible(false)]
21 21
@@ -25,9 +25,9 @@ using System.Runtime.InteropServices;
25// Version information for an assembly consists of the following four values: 25// Version information for an assembly consists of the following four values:
26// 26//
27// Major Version 27// Major Version
28// Minor Version 28// Minor Version
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.8.3.*")] 32[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
33 33
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs
index 9ad4a7a..953bc2a 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs
@@ -55,7 +55,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
55 private static string ZeroID = UUID.Zero.ToString(); 55 private static string ZeroID = UUID.Zero.ToString();
56 56
57 private string m_serverUrl = String.Empty; 57 private string m_serverUrl = String.Empty;
58 private IImprovedAssetCache m_cache; 58 private IAssetCache m_cache;
59 private bool m_Enabled = false; 59 private bool m_Enabled = false;
60 60
61 #region ISharedRegionModule 61 #region ISharedRegionModule
@@ -65,7 +65,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
65 { 65 {
66 if (m_cache == null) 66 if (m_cache == null)
67 { 67 {
68 IImprovedAssetCache cache = scene.RequestModuleInterface<IImprovedAssetCache>(); 68 IAssetCache cache = scene.RequestModuleInterface<IAssetCache>();
69 if (cache is ISharedRegionModule) 69 if (cache is ISharedRegionModule)
70 m_cache = cache; 70 m_cache = cache;
71 } 71 }
@@ -77,7 +77,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
77 public string Name { get { return "SimianAssetServiceConnector"; } } 77 public string Name { get { return "SimianAssetServiceConnector"; } }
78 public void AddRegion(Scene scene) { if (m_Enabled) { scene.RegisterModuleInterface<IAssetService>(this); } } 78 public void AddRegion(Scene scene) { if (m_Enabled) { scene.RegisterModuleInterface<IAssetService>(this); } }
79 public void RemoveRegion(Scene scene) { if (m_Enabled) { scene.UnregisterModuleInterface<IAssetService>(this); } } 79 public void RemoveRegion(Scene scene) { if (m_Enabled) { scene.UnregisterModuleInterface<IAssetService>(this); } }
80 80
81 #endregion ISharedRegionModule 81 #endregion ISharedRegionModule
82 82
83 public SimianAssetServiceConnector(IConfigSource source) 83 public SimianAssetServiceConnector(IConfigSource source)
@@ -136,19 +136,22 @@ namespace OpenSim.Services.Connectors.SimianGrid
136 // Cache fetch 136 // Cache fetch
137 if (m_cache != null) 137 if (m_cache != null)
138 { 138 {
139 AssetBase asset = m_cache.Get(id); 139 AssetBase asset;
140 if (!m_cache.Get(id, out asset))
141 return null;
140 if (asset != null) 142 if (asset != null)
141 return asset; 143 return asset;
142 } 144 }
143 145
144 return SimianGetOperation(id); 146 return SimianGetOperation(id);
145 } 147 }
146 148
147 149
148 public AssetBase GetCached(string id) 150 public AssetBase GetCached(string id)
149 { 151 {
152 AssetBase asset;
150 if (m_cache != null) 153 if (m_cache != null)
151 return m_cache.Get(id); 154 m_cache.Get(id, out asset);
152 155
153 return null; 156 return null;
154 } 157 }
@@ -169,7 +172,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
169 // Cache fetch 172 // Cache fetch
170 if (m_cache != null) 173 if (m_cache != null)
171 { 174 {
172 AssetBase asset = m_cache.Get(id); 175 AssetBase asset;
176 if (!m_cache.Get(id, out asset))
177 return null;
173 if (asset != null) 178 if (asset != null)
174 return asset.Metadata; 179 return asset.Metadata;
175 } 180 }
@@ -177,7 +182,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
177 // return GetRemoteMetadata(id); 182 // return GetRemoteMetadata(id);
178 return SimianGetMetadataOperation(id); 183 return SimianGetMetadataOperation(id);
179 } 184 }
180 185
181 public byte[] GetData(string id) 186 public byte[] GetData(string id)
182 { 187 {
183 if (String.IsNullOrEmpty(m_serverUrl)) 188 if (String.IsNullOrEmpty(m_serverUrl))
@@ -212,7 +217,10 @@ namespace OpenSim.Services.Connectors.SimianGrid
212 // Cache fetch 217 // Cache fetch
213 if (m_cache != null) 218 if (m_cache != null)
214 { 219 {
215 AssetBase asset = m_cache.Get(id); 220 AssetBase asset;
221 if (!m_cache.Get(id, out asset))
222 return false;
223
216 if (asset != null) 224 if (asset != null)
217 { 225 {
218 handler(id, sender, asset); 226 handler(id, sender, asset);
@@ -296,7 +304,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
296 304
297 return SimianStoreOperation(asset); 305 return SimianStoreOperation(asset);
298 } 306 }
299 307
300 /// <summary> 308 /// <summary>
301 /// Update an asset's content 309 /// Update an asset's content
302 /// </summary> 310 /// </summary>
@@ -344,7 +352,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
344 352
345 return SimianDeleteOperation(id); 353 return SimianDeleteOperation(id);
346 } 354 }
347 355
348#endregion IAssetService 356#endregion IAssetService
349 357
350#region SimianOperations 358#region SimianOperations
@@ -369,9 +377,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
369 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to delete asset; {0}",response["Message"].AsString()); 377 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to delete asset; {0}",response["Message"].AsString());
370 return false; 378 return false;
371 } 379 }
372 380
373 return true; 381 return true;
374 382
375 } 383 }
376 catch (Exception ex) 384 catch (Exception ex)
377 { 385 {
@@ -400,7 +408,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
400 { "Temporary", asset.Temporary ? "1" : "0" }, 408 { "Temporary", asset.Temporary ? "1" : "0" },
401 { "Name", asset.Name } 409 { "Name", asset.Name }
402 }; 410 };
403 411
404 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); 412 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
405 if (! response["Success"].AsBoolean()) 413 if (! response["Success"].AsBoolean())
406 { 414 {
@@ -410,13 +418,13 @@ namespace OpenSim.Services.Connectors.SimianGrid
410 418
411 // asset.ID is always set before calling this function 419 // asset.ID is always set before calling this function
412 return asset.ID; 420 return asset.ID;
413 421
414 } 422 }
415 catch (Exception ex) 423 catch (Exception ex)
416 { 424 {
417 m_log.ErrorFormat("[SIMIAN ASSET CONNECTOR] failed to store asset; {0}",ex.Message); 425 m_log.ErrorFormat("[SIMIAN ASSET CONNECTOR] failed to store asset; {0}",ex.Message);
418 } 426 }
419 427
420 return null; 428 return null;
421 } 429 }
422 430
@@ -427,12 +435,12 @@ namespace OpenSim.Services.Connectors.SimianGrid
427 /// <returns></returns> 435 /// <returns></returns>
428 private AssetBase SimianGetOperation(string id) 436 private AssetBase SimianGetOperation(string id)
429 { 437 {
430 try 438 try
431 { 439 {
432 NameValueCollection requestArgs = new NameValueCollection 440 NameValueCollection requestArgs = new NameValueCollection
433 { 441 {
434 { "RequestMethod", "xGetAsset" }, 442 { "RequestMethod", "xGetAsset" },
435 { "ID", id } 443 { "ID", id }
436 }; 444 };
437 445
438 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); 446 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
@@ -441,7 +449,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
441 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset; {0}",response["Message"].AsString()); 449 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset; {0}",response["Message"].AsString());
442 return null; 450 return null;
443 } 451 }
444 452
445 AssetBase asset = new AssetBase(); 453 AssetBase asset = new AssetBase();
446 454
447 asset.ID = id; 455 asset.ID = id;
@@ -475,7 +483,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
475 NameValueCollection requestArgs = new NameValueCollection 483 NameValueCollection requestArgs = new NameValueCollection
476 { 484 {
477 { "RequestMethod", "xGetAssetMetadata" }, 485 { "RequestMethod", "xGetAssetMetadata" },
478 { "ID", id } 486 { "ID", id }
479 }; 487 };
480 488
481 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); 489 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
@@ -485,7 +493,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
485 // m_log.DebugFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset metadata; {0}",response["Message"].AsString()); 493 // m_log.DebugFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset metadata; {0}",response["Message"].AsString());
486 return null; 494 return null;
487 } 495 }
488 496
489 AssetMetadata metadata = new AssetMetadata(); 497 AssetMetadata metadata = new AssetMetadata();
490 metadata.ID = id; 498 metadata.ID = id;
491 metadata.ContentType = response["ContentType"].AsString(); 499 metadata.ContentType = response["ContentType"].AsString();
@@ -620,7 +628,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
620 // } 628 // }
621 629
622 // string errorMessage = null; 630 // string errorMessage = null;
623 631
624 // // Build the remote storage request 632 // // Build the remote storage request
625 // List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>() 633 // List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>()
626 // { 634 // {
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
index 3bd11d9..c402907 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
@@ -102,6 +102,12 @@ namespace OpenSim.Services.Connectors.SimianGrid
102 m_log.Info("[SIMIAN AUTH CONNECTOR]: No AuthenticationServerURI specified, disabling connector"); 102 m_log.Info("[SIMIAN AUTH CONNECTOR]: No AuthenticationServerURI specified, disabling connector");
103 } 103 }
104 104
105 public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID)
106 {
107 realID = UUID.Zero;
108 return Authenticate(principalID, password, lifetime);
109 }
110
105 public string Authenticate(UUID principalID, string password, int lifetime) 111 public string Authenticate(UUID principalID, string password, int lifetime)
106 { 112 {
107 NameValueCollection requestArgs = new NameValueCollection 113 NameValueCollection requestArgs = new NameValueCollection
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
index a397740..34bb274 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
@@ -146,13 +146,14 @@ namespace OpenSim.Services.Connectors.SimianGrid
146 userID,response["Message"].AsString()); 146 userID,response["Message"].AsString());
147 return null; 147 return null;
148 } 148 }
149 149
150 // <summary> 150 // <summary>
151 // </summary> 151 // </summary>
152 // <param name=""></param> 152 // <param name=""></param>
153 public bool SetAppearance(UUID userID, AvatarAppearance appearance) 153 public bool SetAppearance(UUID userID, AvatarAppearance appearance)
154 { 154 {
155 OSDMap map = appearance.Pack(); 155 EntityTransferContext ctx = new EntityTransferContext();
156 OSDMap map = appearance.Pack(ctx);
156 if (map == null) 157 if (map == null)
157 { 158 {
158 m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR]: Failed to encode appearance for {0}",userID); 159 m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR]: Failed to encode appearance for {0}",userID);
@@ -177,7 +178,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
177 178
178 return success; 179 return success;
179 } 180 }
180 181
181 // <summary> 182 // <summary>
182 // </summary> 183 // </summary>
183 // <param name=""></param> 184 // <param name=""></param>
@@ -218,7 +219,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
218 appearance.AvatarHeight = (float)map["Height"].AsReal(); 219 appearance.AvatarHeight = (float)map["Height"].AsReal();
219 220
220 AvatarData avatar = new AvatarData(appearance); 221 AvatarData avatar = new AvatarData(appearance);
221 222
222 // Get attachments 223 // Get attachments
223 map = null; 224 map = null;
224 try { map = OSDParser.DeserializeJson(response["LLAttachments"].AsString()) as OSDMap; } 225 try { map = OSDParser.DeserializeJson(response["LLAttachments"].AsString()) as OSDMap; }
@@ -229,7 +230,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
229 foreach (KeyValuePair<string, OSD> kvp in map) 230 foreach (KeyValuePair<string, OSD> kvp in map)
230 avatar.Data[kvp.Key] = kvp.Value.AsString(); 231 avatar.Data[kvp.Key] = kvp.Value.AsString();
231 } 232 }
232 233
233 return avatar; 234 return avatar;
234 } 235 }
235 else 236 else
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs b/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs
index 764e71f..49bd9a4 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs
@@ -55,7 +55,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
55 private bool m_enabled = true; 55 private bool m_enabled = true;
56 private Scene m_scene; 56 private Scene m_scene;
57 private String m_simianURL; 57 private String m_simianURL;
58 58
59#region IRegionModule Members 59#region IRegionModule Members
60 60
61 public string Name 61 public string Name
@@ -65,10 +65,10 @@ namespace OpenSim.Services.Connectors.SimianGrid
65 65
66 public void Initialise(IConfigSource config) 66 public void Initialise(IConfigSource config)
67 { 67 {
68 try 68 try
69 { 69 {
70 IConfig m_config; 70 IConfig m_config;
71 71
72 if ((m_config = config.Configs["SimianExternalCaps"]) != null) 72 if ((m_config = config.Configs["SimianExternalCaps"]) != null)
73 { 73 {
74 m_enabled = m_config.GetBoolean("Enabled", m_enabled); 74 m_enabled = m_config.GetBoolean("Enabled", m_enabled);
@@ -97,10 +97,10 @@ namespace OpenSim.Services.Connectors.SimianGrid
97 public void Close() { } 97 public void Close() { }
98 98
99 public void AddRegion(Scene scene) 99 public void AddRegion(Scene scene)
100 { 100 {
101 if (! m_enabled) 101 if (! m_enabled)
102 return; 102 return;
103 103
104 m_scene = scene; 104 m_scene = scene;
105 m_scene.RegisterModuleInterface<IExternalCapsModule>(this); 105 m_scene.RegisterModuleInterface<IExternalCapsModule>(this);
106 } 106 }
@@ -153,7 +153,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
153 subs["%USR%"] = agentID.ToString(); 153 subs["%USR%"] = agentID.ToString();
154 subs["%CAP%"] = cap.ToString(); 154 subs["%CAP%"] = cap.ToString();
155 subs["%SIM%"] = m_scene.RegionInfo.RegionID.ToString(); 155 subs["%SIM%"] = m_scene.RegionInfo.RegionID.ToString();
156 156
157 caps.RegisterHandler(capName,ExpandSkeletonURL(urlSkel,subs)); 157 caps.RegisterHandler(capName,ExpandSkeletonURL(urlSkel,subs));
158 return true; 158 return true;
159 } 159 }
@@ -168,12 +168,12 @@ namespace OpenSim.Services.Connectors.SimianGrid
168 private String ExpandSkeletonURL(String urlSkel, Dictionary<String,String> subs) 168 private String ExpandSkeletonURL(String urlSkel, Dictionary<String,String> subs)
169 { 169 {
170 String result = urlSkel; 170 String result = urlSkel;
171 171
172 foreach (KeyValuePair<String,String> kvp in subs) 172 foreach (KeyValuePair<String,String> kvp in subs)
173 { 173 {
174 result = result.Replace(kvp.Key,kvp.Value); 174 result = result.Replace(kvp.Key,kvp.Value);
175 } 175 }
176 176
177 return result; 177 return result;
178 } 178 }
179 } 179 }
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs
index a35d749..b29adb3 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs
@@ -52,20 +52,20 @@ namespace OpenSim.Services.Connectors.SimianGrid
52 private IConfig m_config = null; 52 private IConfig m_config = null;
53 53
54 private String m_simianURL; 54 private String m_simianURL;
55 55
56#region IRegionModule Members 56#region IRegionModule Members
57 57
58 public string Name 58 public string Name
59 { 59 {
60 get { return this.GetType().Name; } 60 get { return this.GetType().Name; }
61 } 61 }
62 62
63 public void Initialise(IConfigSource config) 63 public void Initialise(IConfigSource config)
64 { 64 {
65 try 65 try
66 { 66 {
67 m_config = config.Configs["SimianGrid"]; 67 m_config = config.Configs["SimianGrid"];
68 68
69 if (m_config != null) 69 if (m_config != null)
70 { 70 {
71 m_simianURL = m_config.GetString("SimianServiceURL"); 71 m_simianURL = m_config.GetString("SimianServiceURL");
@@ -74,7 +74,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
74 // m_log.DebugFormat("[SimianGrid] service URL is not defined"); 74 // m_log.DebugFormat("[SimianGrid] service URL is not defined");
75 return; 75 return;
76 } 76 }
77 77
78 InitialiseSimCap(); 78 InitialiseSimCap();
79 SimulatorCapability = SimulatorCapability.Trim(); 79 SimulatorCapability = SimulatorCapability.Trim();
80 m_log.InfoFormat("[SimianExternalCaps] using {0} as simulator capability",SimulatorCapability); 80 m_log.InfoFormat("[SimianExternalCaps] using {0} as simulator capability",SimulatorCapability);
@@ -100,7 +100,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
100 100
101 ///<summary> 101 ///<summary>
102 /// Try a variety of methods for finding the simian simulator capability; first check the 102 /// Try a variety of methods for finding the simian simulator capability; first check the
103 /// configuration itself, then look for a file that contains the cap, then finally look 103 /// configuration itself, then look for a file that contains the cap, then finally look
104 /// for an environment variable that contains it. 104 /// for an environment variable that contains it.
105 ///</summary> 105 ///</summary>
106 private void InitialiseSimCap() 106 private void InitialiseSimCap()
@@ -110,7 +110,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
110 SimulatorCapability = m_config.GetString("SimulatorCapability"); 110 SimulatorCapability = m_config.GetString("SimulatorCapability");
111 return; 111 return;
112 } 112 }
113 113
114 if (m_config.Contains("SimulatorCapabilityFile")) 114 if (m_config.Contains("SimulatorCapabilityFile"))
115 { 115 {
116 String filename = m_config.GetString("SimulatorCapabilityFile"); 116 String filename = m_config.GetString("SimulatorCapabilityFile");
@@ -120,7 +120,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
120 return; 120 return;
121 } 121 }
122 } 122 }
123 123
124 if (m_config.Contains("SimulatorCapabilityVariable")) 124 if (m_config.Contains("SimulatorCapabilityVariable"))
125 { 125 {
126 String envname = m_config.GetString("SimulatorCapabilityVariable"); 126 String envname = m_config.GetString("SimulatorCapabilityVariable");
@@ -134,7 +134,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
134 134
135 m_log.WarnFormat("[SimianExternalCaps] no method specified for simulator capability"); 135 m_log.WarnFormat("[SimianExternalCaps] no method specified for simulator capability");
136 } 136 }
137 137
138#endregion 138#endregion
139 139
140 public static String SimulatorCapability = UUID.Zero.ToString(); 140 public static String SimulatorCapability = UUID.Zero.ToString();
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs
index 8375c95..4896d09 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs
@@ -65,14 +65,14 @@ namespace OpenSim.Services.Connectors.SimianGrid
65 private int m_refreshtime = 0; 65 private int m_refreshtime = 0;
66 private int m_lastrefresh = 0; 66 private int m_lastrefresh = 0;
67 private System.Timers.Timer m_refreshTimer = new System.Timers.Timer(); 67 private System.Timers.Timer m_refreshTimer = new System.Timers.Timer();
68 68
69 #region ISharedRegionModule 69 #region ISharedRegionModule
70 70
71 public Type ReplaceableInterface { get { return null; } } 71 public Type ReplaceableInterface { get { return null; } }
72 public string Name { get { return "SimianGridMaptile"; } } 72 public string Name { get { return "SimianGridMaptile"; } }
73 public void RegionLoaded(Scene scene) { } 73 public void RegionLoaded(Scene scene) { }
74 public void Close() { } 74 public void Close() { }
75 75
76 ///<summary> 76 ///<summary>
77 /// 77 ///
78 ///</summary> 78 ///</summary>
@@ -81,7 +81,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
81 IConfig config = source.Configs["SimianGridMaptiles"]; 81 IConfig config = source.Configs["SimianGridMaptiles"];
82 if (config == null) 82 if (config == null)
83 return; 83 return;
84 84
85 if (! config.GetBoolean("Enabled", false)) 85 if (! config.GetBoolean("Enabled", false))
86 return; 86 return;
87 87
@@ -218,7 +218,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
218 { 218 {
219 uint locX = scene.RegionInfo.RegionLocX + (xx / Constants.RegionSize); 219 uint locX = scene.RegionInfo.RegionLocX + (xx / Constants.RegionSize);
220 uint locY = scene.RegionInfo.RegionLocY + (yy / Constants.RegionSize); 220 uint locY = scene.RegionInfo.RegionLocY + (yy / Constants.RegionSize);
221 221
222 ConvertAndUploadMaptile(subMapTile, locX, locY); 222 ConvertAndUploadMaptile(subMapTile, locX, locY);
223 } 223 }
224 } 224 }
@@ -232,7 +232,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
232 } 232 }
233 233
234 } 234 }
235 235
236 ///<summary> 236 ///<summary>
237 /// 237 ///
238 ///</summary> 238 ///</summary>
@@ -255,7 +255,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
255 { "ContentType", "image/png" }, 255 { "ContentType", "image/png" },
256 { "EncodedData", System.Convert.ToBase64String(pngData) } 256 { "EncodedData", System.Convert.ToBase64String(pngData) }
257 }; 257 };
258 258
259 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); 259 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
260 if (! response["Success"].AsBoolean()) 260 if (! response["Success"].AsBoolean())
261 { 261 {
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
index b031f21..f8eebbe 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
@@ -28,6 +28,8 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Collections.Specialized; 30using System.Collections.Specialized;
31using System.Drawing;
32using System.Drawing.Imaging;
31using System.IO; 33using System.IO;
32using System.Net; 34using System.Net;
33using System.Reflection; 35using System.Reflection;
@@ -89,7 +91,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
89 m_log.Error("[SIMIAN GRID CONNECTOR]: No Server URI named in section GridService"); 91 m_log.Error("[SIMIAN GRID CONNECTOR]: No Server URI named in section GridService");
90 throw new Exception("Grid connector init error"); 92 throw new Exception("Grid connector init error");
91 } 93 }
92 94
93 if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("=")) 95 if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("="))
94 serviceUrl = serviceUrl + '/'; 96 serviceUrl = serviceUrl + '/';
95 m_ServerURI = serviceUrl; 97 m_ServerURI = serviceUrl;
@@ -100,6 +102,15 @@ namespace OpenSim.Services.Connectors.SimianGrid
100 102
101 public string RegisterRegion(UUID scopeID, GridRegion regionInfo) 103 public string RegisterRegion(UUID scopeID, GridRegion regionInfo)
102 { 104 {
105 IPEndPoint ext = regionInfo.ExternalEndPoint;
106 if (ext == null) return "Region registration for " + regionInfo.RegionName + " failed: Could not resolve EndPoint";
107 // Generate and upload our map tile in PNG format to the SimianGrid AddMapTile service
108// Scene scene;
109// if (m_scenes.TryGetValue(regionInfo.RegionID, out scene))
110// UploadMapTile(scene);
111// else
112// m_log.Warn("Registering region " + regionInfo.RegionName + " (" + regionInfo.RegionID + ") that we are not tracking");
113
103 Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0); 114 Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0);
104 Vector3d maxPosition = minPosition + new Vector3d(regionInfo.RegionSizeX, regionInfo.RegionSizeY, Constants.RegionHeight); 115 Vector3d maxPosition = minPosition + new Vector3d(regionInfo.RegionSizeX, regionInfo.RegionSizeY, Constants.RegionHeight);
105 116
@@ -108,7 +119,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
108 { "ServerURI", OSD.FromString(regionInfo.ServerURI) }, 119 { "ServerURI", OSD.FromString(regionInfo.ServerURI) },
109 { "InternalAddress", OSD.FromString(regionInfo.InternalEndPoint.Address.ToString()) }, 120 { "InternalAddress", OSD.FromString(regionInfo.InternalEndPoint.Address.ToString()) },
110 { "InternalPort", OSD.FromInteger(regionInfo.InternalEndPoint.Port) }, 121 { "InternalPort", OSD.FromInteger(regionInfo.InternalEndPoint.Port) },
111 { "ExternalAddress", OSD.FromString(regionInfo.ExternalEndPoint.Address.ToString()) }, 122 { "ExternalAddress", OSD.FromString(ext.Address.ToString()) },
112 { "ExternalPort", OSD.FromInteger(regionInfo.ExternalEndPoint.Port) }, 123 { "ExternalPort", OSD.FromInteger(regionInfo.ExternalEndPoint.Port) },
113 { "MapTexture", OSD.FromUUID(regionInfo.TerrainImage) }, 124 { "MapTexture", OSD.FromUUID(regionInfo.TerrainImage) },
114 { "Access", OSD.FromInteger(regionInfo.Access) }, 125 { "Access", OSD.FromInteger(regionInfo.Access) },
@@ -219,7 +230,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
219 }; 230 };
220 231
221 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request grid at {0}",position.ToString()); 232 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request grid at {0}",position.ToString());
222 233
223 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); 234 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
224 if (response["Success"].AsBoolean()) 235 if (response["Success"].AsBoolean())
225 { 236 {
@@ -297,7 +308,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
297 }; 308 };
298 309
299 //m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions by range {0} to {1}",minPosition.ToString(),maxPosition.ToString()); 310 //m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions by range {0} to {1}",minPosition.ToString(),maxPosition.ToString());
300 311
301 312
302 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); 313 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
303 if (response["Success"].AsBoolean()) 314 if (response["Success"].AsBoolean())
@@ -402,7 +413,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
402 return -1; 413 return -1;
403 } 414 }
404 } 415 }
405 416
406 public Dictionary<string, object> GetExtraFeatures() 417 public Dictionary<string, object> GetExtraFeatures()
407 { 418 {
408 /// See SimulatorFeaturesModule - Need to get map, search and destination guide 419 /// See SimulatorFeaturesModule - Need to get map, search and destination guide
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
index e793420..9eefd16 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
@@ -277,17 +277,17 @@ namespace OpenSim.Services.Connectors.SimianGrid
277 /// </summary> 277 /// </summary>
278 /// <param name="item"></param> 278 /// <param name="item"></param>
279 /// <returns></returns> 279 /// <returns></returns>
280 public InventoryItemBase GetItem(InventoryItemBase item) 280 public InventoryItemBase GetItem(UUID principalID, UUID itemID)
281 { 281 {
282 InventoryItemBase retrieved = null; 282 InventoryItemBase retrieved = null;
283 if (m_ItemCache.TryGetValue(item.ID, out retrieved)) 283 if (m_ItemCache.TryGetValue(itemID, out retrieved))
284 return retrieved; 284 return retrieved;
285 285
286 NameValueCollection requestArgs = new NameValueCollection 286 NameValueCollection requestArgs = new NameValueCollection
287 { 287 {
288 { "RequestMethod", "GetInventoryNode" }, 288 { "RequestMethod", "GetInventoryNode" },
289 { "ItemID", item.ID.ToString() }, 289 { "ItemID", itemID.ToString() },
290 { "OwnerID", item.Owner.ToString() }, 290 { "OwnerID", principalID.ToString() },
291 { "IncludeFolders", "1" }, 291 { "IncludeFolders", "1" },
292 { "IncludeItems", "1" }, 292 { "IncludeItems", "1" },
293 { "ChildrenOnly", "1" } 293 { "ChildrenOnly", "1" }
@@ -303,17 +303,17 @@ namespace OpenSim.Services.Connectors.SimianGrid
303 // and sanity check just in case 303 // and sanity check just in case
304 for (int i = 0; i < items.Count; i++) 304 for (int i = 0; i < items.Count; i++)
305 { 305 {
306 if (items[i].ID == item.ID) 306 if (items[i].ID == itemID)
307 { 307 {
308 retrieved = items[i]; 308 retrieved = items[i];
309 m_ItemCache.AddOrUpdate(item.ID, retrieved, CACHE_EXPIRATION_SECONDS); 309 m_ItemCache.AddOrUpdate(itemID, retrieved, CACHE_EXPIRATION_SECONDS);
310 return retrieved; 310 return retrieved;
311 } 311 }
312 } 312 }
313 } 313 }
314 } 314 }
315 315
316 m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Item " + item.ID + " owned by " + item.Owner + " not found"); 316 m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Item " + itemID + " owned by " + principalID + " not found");
317 return null; 317 return null;
318 } 318 }
319 319
@@ -321,13 +321,8 @@ namespace OpenSim.Services.Connectors.SimianGrid
321 { 321 {
322 InventoryItemBase[] result = new InventoryItemBase[itemIDs.Length]; 322 InventoryItemBase[] result = new InventoryItemBase[itemIDs.Length];
323 int i = 0; 323 int i = 0;
324 InventoryItemBase item = new InventoryItemBase();
325 item.Owner = principalID;
326 foreach (UUID id in itemIDs) 324 foreach (UUID id in itemIDs)
327 { 325 result[i++] = GetItem(principalID, id);
328 item.ID = id;
329 result[i++] = GetItem(item);
330 }
331 326
332 return result; 327 return result;
333 } 328 }
@@ -337,13 +332,13 @@ namespace OpenSim.Services.Connectors.SimianGrid
337 /// </summary> 332 /// </summary>
338 /// <param name="folder"></param> 333 /// <param name="folder"></param>
339 /// <returns></returns> 334 /// <returns></returns>
340 public InventoryFolderBase GetFolder(InventoryFolderBase folder) 335 public InventoryFolderBase GetFolder(UUID principalID, UUID folderID)
341 { 336 {
342 NameValueCollection requestArgs = new NameValueCollection 337 NameValueCollection requestArgs = new NameValueCollection
343 { 338 {
344 { "RequestMethod", "GetInventoryNode" }, 339 { "RequestMethod", "GetInventoryNode" },
345 { "ItemID", folder.ID.ToString() }, 340 { "ItemID", folderID.ToString() },
346 { "OwnerID", folder.Owner.ToString() }, 341 { "OwnerID", principalID.ToString() },
347 { "IncludeFolders", "1" }, 342 { "IncludeFolders", "1" },
348 { "IncludeItems", "0" }, 343 { "IncludeItems", "0" },
349 { "ChildrenOnly", "1" } 344 { "ChildrenOnly", "1" }
@@ -353,7 +348,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
353 if (response["Success"].AsBoolean() && response["Items"] is OSDArray) 348 if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
354 { 349 {
355 OSDArray items = (OSDArray)response["Items"]; 350 OSDArray items = (OSDArray)response["Items"];
356 List<InventoryFolderBase> folders = GetFoldersFromResponse(items, folder.ID, true); 351 List<InventoryFolderBase> folders = GetFoldersFromResponse(items, folderID, true);
357 352
358 if (folders.Count > 0) 353 if (folders.Count > 0)
359 return folders[0]; 354 return folders[0];
@@ -540,7 +535,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
540 allSuccess = false; 535 allSuccess = false;
541 } 536 }
542 } 537 }
543 538
544 return allSuccess; 539 return allSuccess;
545 } 540 }
546 541
@@ -732,11 +727,11 @@ namespace OpenSim.Services.Connectors.SimianGrid
732 727
733 /// <summary> 728 /// <summary>
734 /// Get the union of permissions of all inventory items 729 /// Get the union of permissions of all inventory items
735 /// that hold the given assetID. 730 /// that hold the given assetID.
736 /// </summary> 731 /// </summary>
737 /// <param name="userID"></param> 732 /// <param name="userID"></param>
738 /// <param name="assetID"></param> 733 /// <param name="assetID"></param>
739 /// <returns>The permissions or 0 if no such asset is found in 734 /// <returns>The permissions or 0 if no such asset is found in
740 /// the user's inventory</returns> 735 /// the user's inventory</returns>
741 public int GetAssetPermissions(UUID userID, UUID assetID) 736 public int GetAssetPermissions(UUID userID, UUID assetID)
742 { 737 {
@@ -792,7 +787,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
792 if (item != null && item["Type"].AsString() == "Item") 787 if (item != null && item["Type"].AsString() == "Item")
793 { 788 {
794 InventoryItemBase invItem = new InventoryItemBase(); 789 InventoryItemBase invItem = new InventoryItemBase();
795 790
796 invItem.AssetID = item["AssetID"].AsUUID(); 791 invItem.AssetID = item["AssetID"].AsUUID();
797 invItem.AssetType = SLUtil.ContentTypeToSLAssetType(item["ContentType"].AsString()); 792 invItem.AssetType = SLUtil.ContentTypeToSLAssetType(item["ContentType"].AsString());
798 invItem.CreationDate = item["CreationDate"].AsInteger(); 793 invItem.CreationDate = item["CreationDate"].AsInteger();
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
index 211b775..2a34379 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
@@ -121,7 +121,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
121 if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("=")) 121 if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("="))
122 serviceUrl = serviceUrl + '/'; 122 serviceUrl = serviceUrl + '/';
123 m_serverUrl = serviceUrl; 123 m_serverUrl = serviceUrl;
124 m_activityDetector = new SimianActivityDetector(this); 124 m_activityDetector = new SimianActivityDetector(this);
125 m_Enabled = true; 125 m_Enabled = true;
126 } 126 }
127 } 127 }
@@ -210,7 +210,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
210 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve session {0}: {1}",sessionID.ToString(),sessionResponse["Message"].AsString()); 210 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve session {0}: {1}",sessionID.ToString(),sessionResponse["Message"].AsString());
211 return null; 211 return null;
212 } 212 }
213 213
214 UUID userID = sessionResponse["UserID"].AsUUID(); 214 UUID userID = sessionResponse["UserID"].AsUUID();
215 OSDMap userResponse = GetUserData(userID); 215 OSDMap userResponse = GetUserData(userID);
216 if (userResponse == null) 216 if (userResponse == null)
@@ -222,6 +222,18 @@ namespace OpenSim.Services.Connectors.SimianGrid
222 return ResponseToPresenceInfo(sessionResponse); 222 return ResponseToPresenceInfo(sessionResponse);
223 } 223 }
224 224
225 public PresenceInfo GetAgentByUser(UUID userID)
226 {
227 OSDMap userResponse = GetUserData(userID);
228 if (userResponse == null)
229 {
230 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}: {1}",userID.ToString(),userResponse["Message"].AsString());
231 return null;
232 }
233
234 return ResponseToPresenceInfo(userResponse);
235 }
236
225 public PresenceInfo[] GetAgents(string[] userIDs) 237 public PresenceInfo[] GetAgents(string[] userIDs)
226 { 238 {
227 List<PresenceInfo> presences = new List<PresenceInfo>(); 239 List<PresenceInfo> presences = new List<PresenceInfo>();
@@ -238,7 +250,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
238 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve sessions: {0}",sessionListResponse["Message"].AsString()); 250 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve sessions: {0}",sessionListResponse["Message"].AsString());
239 return null; 251 return null;
240 } 252 }
241 253
242 OSDArray sessionList = sessionListResponse["Sessions"] as OSDArray; 254 OSDArray sessionList = sessionListResponse["Sessions"] as OSDArray;
243 for (int i = 0; i < sessionList.Count; i++) 255 for (int i = 0; i < sessionList.Count; i++)
244 { 256 {
@@ -311,7 +323,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
311 323
312 public GridUserInfo GetGridUserInfo(string user) 324 public GridUserInfo GetGridUserInfo(string user)
313 { 325 {
314 // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent " + user); 326 // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent " + user);
315 327
316 UUID userID = new UUID(user); 328 UUID userID = new UUID(user);
317 OSDMap userResponse = GetUserData(userID); 329 OSDMap userResponse = GetUserData(userID);
@@ -421,7 +433,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
421 433
422 return null; 434 return null;
423 } 435 }
424 436
425 private string SerializeLocation(UUID regionID, Vector3 position, Vector3 lookAt) 437 private string SerializeLocation(UUID regionID, Vector3 position, Vector3 lookAt)
426 { 438 {
427 return "{" + String.Format("\"SceneID\":\"{0}\",\"Position\":\"{1}\",\"LookAt\":\"{2}\"", regionID, position, lookAt) + "}"; 439 return "{" + String.Format("\"SceneID\":\"{0}\",\"Position\":\"{1}\",\"LookAt\":\"{2}\"", regionID, position, lookAt) + "}";
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs b/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs
index 8fc766d..a388bcc 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs
@@ -70,7 +70,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
70 private bool m_Enabled = false; 70 private bool m_Enabled = false;
71 71
72 #region INonSharedRegionModule 72 #region INonSharedRegionModule
73 73
74 public Type ReplaceableInterface { get { return null; } } 74 public Type ReplaceableInterface { get { return null; } }
75 public void RegionLoaded(Scene scene) { } 75 public void RegionLoaded(Scene scene) { }
76 public void Close() { } 76 public void Close() { }
@@ -284,7 +284,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
284 private void RequestAvatarPropertiesHandler(IClientAPI client, UUID avatarID) 284 private void RequestAvatarPropertiesHandler(IClientAPI client, UUID avatarID)
285 { 285 {
286 m_log.DebugFormat("[SIMIAN PROFILES]: Request avatar properties for {0}",avatarID); 286 m_log.DebugFormat("[SIMIAN PROFILES]: Request avatar properties for {0}",avatarID);
287 287
288 OSDMap user = FetchUserData(avatarID); 288 OSDMap user = FetchUserData(avatarID);
289 289
290 ProfileFlags flags = ProfileFlags.AllowPublish | ProfileFlags.MaturePublish; 290 ProfileFlags flags = ProfileFlags.AllowPublish | ProfileFlags.MaturePublish;
@@ -308,11 +308,11 @@ namespace OpenSim.Services.Connectors.SimianGrid
308 about = new OSDMap(0); 308 about = new OSDMap(0);
309 309
310 // Check if this user is a grid operator 310 // Check if this user is a grid operator
311 byte[] charterMember; 311 byte[] membershipType;
312 if (user["AccessLevel"].AsInteger() >= 200) 312 if (user["AccessLevel"].AsInteger() >= 200)
313 charterMember = Utils.StringToBytes("Operator"); 313 membershipType = Utils.StringToBytes("Operator");
314 else 314 else
315 charterMember = Utils.EmptyBytes; 315 membershipType = Utils.EmptyBytes;
316 316
317 // Check if the user is online 317 // Check if the user is online
318 if (client.Scene is Scene) 318 if (client.Scene is Scene)
@@ -327,7 +327,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
327 flags |= ProfileFlags.Identified; 327 flags |= ProfileFlags.Identified;
328 328
329 client.SendAvatarProperties(avatarID, about["About"].AsString(), user["CreationDate"].AsDate().ToString("M/d/yyyy", 329 client.SendAvatarProperties(avatarID, about["About"].AsString(), user["CreationDate"].AsDate().ToString("M/d/yyyy",
330 System.Globalization.CultureInfo.InvariantCulture), charterMember, about["FLAbout"].AsString(), (uint)flags, 330 System.Globalization.CultureInfo.InvariantCulture), membershipType, about["FLAbout"].AsString(), (uint)flags,
331 about["FLImage"].AsUUID(), about["Image"].AsUUID(), about["URL"].AsString(), user["Partner"].AsUUID()); 331 about["FLImage"].AsUUID(), about["Image"].AsUUID(), about["URL"].AsString(), user["Partner"].AsUUID());
332 332
333 OSDMap interests = null; 333 OSDMap interests = null;
@@ -455,7 +455,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
455 private OSDMap FetchUserData(UUID userID) 455 private OSDMap FetchUserData(UUID userID)
456 { 456 {
457 m_log.DebugFormat("[SIMIAN PROFILES]: Fetch information about {0}",userID); 457 m_log.DebugFormat("[SIMIAN PROFILES]: Fetch information about {0}",userID);
458 458
459 NameValueCollection requestArgs = new NameValueCollection 459 NameValueCollection requestArgs = new NameValueCollection
460 { 460 {
461 { "RequestMethod", "GetUser" }, 461 { "RequestMethod", "GetUser" },
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
index 698c4c0..115ae36 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
@@ -42,7 +42,7 @@ using OpenMetaverse.StructuredData;
42namespace OpenSim.Services.Connectors.SimianGrid 42namespace OpenSim.Services.Connectors.SimianGrid
43{ 43{
44 /// <summary> 44 /// <summary>
45 /// Connects user account data (creating new users, looking up existing 45 /// Connects user account data (creating new users, looking up existing
46 /// users) to the SimianGrid backend 46 /// users) to the SimianGrid backend
47 /// </summary> 47 /// </summary>
48 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianUserAccountServiceConnector")] 48 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianUserAccountServiceConnector")]
@@ -196,6 +196,16 @@ namespace OpenSim.Services.Connectors.SimianGrid
196 m_accountCache.Remove(userID); 196 m_accountCache.Remove(userID);
197 } 197 }
198 198
199 public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string query)
200 {
201 return null;
202 }
203
204 public List<UserAccount> GetUserAccounts(UUID scopeID, List<string> IDs)
205 {
206 return null;
207 }
208
199 public bool StoreUserAccount(UserAccount data) 209 public bool StoreUserAccount(UserAccount data)
200 { 210 {
201// m_log.InfoFormat("[SIMIAN ACCOUNT CONNECTOR]: Storing user account for " + data.Name); 211// m_log.InfoFormat("[SIMIAN ACCOUNT CONNECTOR]: Storing user account for " + data.Name);
@@ -210,7 +220,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
210 }; 220 };
211 221
212 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); 222 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
213 223
214 if (response["Success"].AsBoolean()) 224 if (response["Success"].AsBoolean())
215 { 225 {
216 m_log.InfoFormat("[SIMIAN ACCOUNT CONNECTOR]: Storing user account data for " + data.Name); 226 m_log.InfoFormat("[SIMIAN ACCOUNT CONNECTOR]: Storing user account data for " + data.Name);
@@ -295,7 +305,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
295 account.LocalToGrid = true; 305 account.LocalToGrid = true;
296 if (response.ContainsKey("LocalToGrid")) 306 if (response.ContainsKey("LocalToGrid"))
297 account.LocalToGrid = (response["LocalToGrid"].AsString() == "true" ? true : false); 307 account.LocalToGrid = (response["LocalToGrid"].AsString() == "true" ? true : false);
298 308
299 GetFirstLastName(response["Name"].AsString(), out account.FirstName, out account.LastName); 309 GetFirstLastName(response["Name"].AsString(), out account.FirstName, out account.LastName);
300 310
301 // Cache the user account info 311 // Cache the user account info
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
index cea870b..a4ca2d3 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -50,7 +50,7 @@ namespace OpenSim.Services.Connectors.Simulation
50 50
51 // we use this dictionary to track the pending updateagent requests, maps URI --> position update 51 // we use this dictionary to track the pending updateagent requests, maps URI --> position update
52 private Dictionary<string,AgentPosition> m_updateAgentQueue = new Dictionary<string,AgentPosition>(); 52 private Dictionary<string,AgentPosition> m_updateAgentQueue = new Dictionary<string,AgentPosition>();
53 53
54 //private GridRegion m_Region; 54 //private GridRegion m_Region;
55 55
56 public SimulationServiceConnector() 56 public SimulationServiceConnector()
@@ -98,29 +98,32 @@ namespace OpenSim.Services.Connectors.Simulation
98 args["teleport_flags"] = OSD.FromString(flags.ToString()); 98 args["teleport_flags"] = OSD.FromString(flags.ToString());
99 } 99 }
100 100
101 public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason) 101 public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, EntityTransferContext ctx, out string reason)
102 { 102 {
103 string tmp = String.Empty; 103 string tmp = String.Empty;
104 return CreateAgent(source, destination, aCircuit, flags, out tmp, out reason); 104 return CreateAgent(source, destination, aCircuit, flags, ctx, out tmp, out reason);
105 } 105 }
106 106
107 public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason) 107 public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, EntityTransferContext ctx, out string myipaddress, out string reason)
108 { 108 {
109 m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: Creating agent at {0}", destination.ServerURI);
110 reason = String.Empty; 109 reason = String.Empty;
111 myipaddress = String.Empty; 110 myipaddress = String.Empty;
112 111
113 if (destination == null) 112 if (destination == null)
114 { 113 {
115 m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Given destination is null"); 114 reason = "Destination not found";
115 m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Create agent destination is null");
116 return false; 116 return false;
117 } 117 }
118 118
119 m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: Creating agent at {0}", destination.ServerURI);
120
119 string uri = destination.ServerURI + AgentPath() + aCircuit.AgentID + "/"; 121 string uri = destination.ServerURI + AgentPath() + aCircuit.AgentID + "/";
120 122
121 try 123 try
122 { 124 {
123 OSDMap args = aCircuit.PackAgentCircuitData(); 125 OSDMap args = aCircuit.PackAgentCircuitData(ctx);
126 args["context"] = ctx.Pack();
124 PackData(args, source, aCircuit, destination, flags); 127 PackData(args, source, aCircuit, destination, flags);
125 128
126 OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000); 129 OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000);
@@ -134,7 +137,7 @@ namespace OpenSim.Services.Connectors.Simulation
134 myipaddress = data["your_ip"].AsString(); 137 myipaddress = data["your_ip"].AsString();
135 return success; 138 return success;
136 } 139 }
137 140
138 // Try the old version, uncompressed 141 // Try the old version, uncompressed
139 result = WebUtil.PostToService(uri, args, 30000, false); 142 result = WebUtil.PostToService(uri, args, 30000, false);
140 143
@@ -152,10 +155,10 @@ namespace OpenSim.Services.Connectors.Simulation
152 return success; 155 return success;
153 } 156 }
154 } 157 }
155 158
156 m_log.WarnFormat( 159 m_log.WarnFormat(
157 "[REMOTE SIMULATION CONNECTOR]: Failed to create agent {0} {1} at remote simulator {2}", 160 "[REMOTE SIMULATION CONNECTOR]: Failed to create agent {0} {1} at remote simulator {2}",
158 aCircuit.firstname, aCircuit.lastname, destination.RegionName); 161 aCircuit.firstname, aCircuit.lastname, destination.RegionName);
159 reason = result["Message"] != null ? result["Message"].AsString() : "error"; 162 reason = result["Message"] != null ? result["Message"].AsString() : "error";
160 return false; 163 return false;
161 } 164 }
@@ -171,9 +174,9 @@ namespace OpenSim.Services.Connectors.Simulation
171 /// <summary> 174 /// <summary>
172 /// Send complete data about an agent in this region to a neighbor 175 /// Send complete data about an agent in this region to a neighbor
173 /// </summary> 176 /// </summary>
174 public bool UpdateAgent(GridRegion destination, AgentData data) 177 public bool UpdateAgent(GridRegion destination, AgentData data, EntityTransferContext ctx)
175 { 178 {
176 return UpdateAgent(destination, (IAgentData)data, 200000); // yes, 200 seconds 179 return UpdateAgent(destination, (IAgentData)data, ctx, 200000); // yes, 200 seconds
177 } 180 }
178 181
179 private ExpiringCache<string, bool> _failedSims = new ExpiringCache<string, bool>(); 182 private ExpiringCache<string, bool> _failedSims = new ExpiringCache<string, bool>();
@@ -199,8 +202,8 @@ namespace OpenSim.Services.Connectors.Simulation
199 { 202 {
200 if (m_updateAgentQueue.ContainsKey(uri)) 203 if (m_updateAgentQueue.ContainsKey(uri))
201 { 204 {
202 // Another thread is already handling 205 // Another thread is already handling
203 // updates for this simulator, just update 206 // updates for this simulator, just update
204 // the position and return, overwrites are 207 // the position and return, overwrites are
205 // not a problem since we only care about the 208 // not a problem since we only care about the
206 // last update anyway 209 // last update anyway
@@ -234,7 +237,8 @@ namespace OpenSim.Services.Connectors.Simulation
234 } 237 }
235 } 238 }
236 239
237 success = UpdateAgent(destination, (IAgentData)pos, 10000); 240 EntityTransferContext ctx = new EntityTransferContext(); // Dummy, not needed for position
241 success = UpdateAgent(destination, (IAgentData)pos, ctx, 10000);
238 } 242 }
239 // we get here iff success == false 243 // we get here iff success == false
240 // blacklist sim for 2 minutes 244 // blacklist sim for 2 minutes
@@ -249,7 +253,7 @@ namespace OpenSim.Services.Connectors.Simulation
249 /// <summary> 253 /// <summary>
250 /// This is the worker function to send AgentData to a neighbor region 254 /// This is the worker function to send AgentData to a neighbor region
251 /// </summary> 255 /// </summary>
252 private bool UpdateAgent(GridRegion destination, IAgentData cAgentData, int timeout) 256 private bool UpdateAgent(GridRegion destination, IAgentData cAgentData, EntityTransferContext ctx, int timeout)
253 { 257 {
254 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: UpdateAgent in {0}", destination.ServerURI); 258 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: UpdateAgent in {0}", destination.ServerURI);
255 259
@@ -258,12 +262,13 @@ namespace OpenSim.Services.Connectors.Simulation
258 262
259 try 263 try
260 { 264 {
261 OSDMap args = cAgentData.Pack(); 265 OSDMap args = cAgentData.Pack(ctx);
262 266
263 args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); 267 args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
264 args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); 268 args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
265 args["destination_name"] = OSD.FromString(destination.RegionName); 269 args["destination_name"] = OSD.FromString(destination.RegionName);
266 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); 270 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
271 args["context"] = ctx.Pack();
267 272
268 OSDMap result = WebUtil.PutToServiceCompressed(uri, args, timeout); 273 OSDMap result = WebUtil.PutToServiceCompressed(uri, args, timeout);
269 if (result["Success"].AsBoolean()) 274 if (result["Success"].AsBoolean())
@@ -284,20 +289,19 @@ namespace OpenSim.Services.Connectors.Simulation
284 289
285 public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, List<UUID> featuresAvailable, EntityTransferContext ctx, out string reason) 290 public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, List<UUID> featuresAvailable, EntityTransferContext ctx, out string reason)
286 { 291 {
292 Culture.SetCurrentCulture();
293
287 reason = "Failed to contact destination"; 294 reason = "Failed to contact destination";
288 295
289 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: QueryAccess start, position={0}", position); 296 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: QueryAccess start, position={0}", position);
290 297
291 IPEndPoint ext = destination.ExternalEndPoint;
292 if (ext == null) return false;
293
294 // Eventually, we want to use a caps url instead of the agentID 298 // Eventually, we want to use a caps url instead of the agentID
295 string uri = destination.ServerURI + AgentPath() + agentID + "/" + destination.RegionID.ToString() + "/"; 299 string uri = destination.ServerURI + AgentPath() + agentID + "/" + destination.RegionID.ToString() + "/";
296 300
297 OSDMap request = new OSDMap(); 301 OSDMap request = new OSDMap();
298 request.Add("viaTeleport", OSD.FromBoolean(viaTeleport)); 302 request.Add("viaTeleport", OSD.FromBoolean(viaTeleport));
299 request.Add("position", OSD.FromString(position.ToString())); 303 request.Add("position", OSD.FromString(position.ToString()));
300 // To those who still understad this field, we're telling them 304 // To those who still understad this field, we're telling them
301 // the lowest version just to be safe 305 // the lowest version just to be safe
302 request.Add("my_version", OSD.FromString(String.Format("SIMULATION/{0}", VersionInfo.SimulationServiceVersionSupportedMin))); 306 request.Add("my_version", OSD.FromString(String.Format("SIMULATION/{0}", VersionInfo.SimulationServiceVersionSupportedMin)));
303 // New simulation service negotiation 307 // New simulation service negotiation
@@ -306,6 +310,8 @@ namespace OpenSim.Services.Connectors.Simulation
306 request.Add("simulation_service_accepted_min", OSD.FromReal(VersionInfo.SimulationServiceVersionAcceptedMin)); 310 request.Add("simulation_service_accepted_min", OSD.FromReal(VersionInfo.SimulationServiceVersionAcceptedMin));
307 request.Add("simulation_service_accepted_max", OSD.FromReal(VersionInfo.SimulationServiceVersionAcceptedMax)); 311 request.Add("simulation_service_accepted_max", OSD.FromReal(VersionInfo.SimulationServiceVersionAcceptedMax));
308 312
313 request.Add("context", ctx.Pack());
314
309 OSDArray features = new OSDArray(); 315 OSDArray features = new OSDArray();
310 foreach (UUID feature in featuresAvailable) 316 foreach (UUID feature in featuresAvailable)
311 features.Add(OSD.FromString(feature.ToString())); 317 features.Add(OSD.FromString(feature.ToString()));
@@ -325,7 +331,7 @@ namespace OpenSim.Services.Connectors.Simulation
325 331
326 // FIXME: If there is a _Result map then it's the success key here that indicates the true success 332 // FIXME: If there is a _Result map then it's the success key here that indicates the true success
327 // or failure, not the sibling result node. 333 // or failure, not the sibling result node.
328 success = data["success"]; 334 success = data["success"].AsBoolean();
329 335
330 reason = data["reason"].AsString(); 336 reason = data["reason"].AsString();
331 // We will need to plumb this and start sing the outbound version as well 337 // We will need to plumb this and start sing the outbound version as well
@@ -345,8 +351,6 @@ namespace OpenSim.Services.Connectors.Simulation
345 ctx.OutboundVersion = float.Parse(parts[1]); 351 ctx.OutboundVersion = float.Parse(parts[1]);
346 } 352 }
347 } 353 }
348 if (data.ContainsKey("variable_wearables_count_supported"))
349 ctx.VariableWearablesSupported = true;
350 354
351 m_log.DebugFormat( 355 m_log.DebugFormat(
352 "[REMOTE SIMULATION CONNECTOR]: QueryAccess to {0} returned {1}, reason {2}, version {3}/{4}", 356 "[REMOTE SIMULATION CONNECTOR]: QueryAccess to {0} returned {1}, reason {2}, version {3}/{4}",
@@ -367,7 +371,7 @@ namespace OpenSim.Services.Connectors.Simulation
367 m_log.Info("[REMOTE SIMULATION CONNECTOR]: The above web util error was caused by a TP to a sim that doesn't support QUERYACCESS and can be ignored"); 371 m_log.Info("[REMOTE SIMULATION CONNECTOR]: The above web util error was caused by a TP to a sim that doesn't support QUERYACCESS and can be ignored");
368 return true; 372 return true;
369 } 373 }
370 374
371 reason = result["Message"]; 375 reason = result["Message"];
372 } 376 }
373 else 377 else
@@ -379,7 +383,6 @@ namespace OpenSim.Services.Connectors.Simulation
379 return false; 383 return false;
380 } 384 }
381 385
382
383 featuresAvailable.Clear(); 386 featuresAvailable.Clear();
384 387
385 if (result.ContainsKey("features")) 388 if (result.ContainsKey("features"))
@@ -390,13 +393,21 @@ namespace OpenSim.Services.Connectors.Simulation
390 featuresAvailable.Add(new UUID(o.AsString())); 393 featuresAvailable.Add(new UUID(o.AsString()));
391 } 394 }
392 395
396 // Version stuff
397 if (ctx.OutboundVersion < 0.5)
398 ctx.WearablesCount = AvatarWearable.LEGACY_VERSION_MAX_WEARABLES;
399 else if (ctx.OutboundVersion < 0.6)
400 ctx.WearablesCount = AvatarWearable.LEGACY_VERSION_MAX_WEARABLES + 1;
401 else
402 ctx.WearablesCount = -1; // send all (just in case..)
403
393 return success; 404 return success;
394 } 405 }
395 catch (Exception e) 406 catch (Exception e)
396 { 407 {
397 m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] QueryAcesss failed with exception; {0}",e.ToString()); 408 m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] QueryAcesss failed with exception; {0}",e.ToString());
398 } 409 }
399 410
400 return false; 411 return false;
401 } 412 }
402 413
@@ -414,7 +425,7 @@ namespace OpenSim.Services.Connectors.Simulation
414 { 425 {
415 m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] ReleaseAgent failed with exception; {0}",e.ToString()); 426 m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] ReleaseAgent failed with exception; {0}",e.ToString());
416 } 427 }
417 428
418 return true; 429 return true;
419 } 430 }
420 431
diff --git a/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs
index c21db54..68ae7bb 100644
--- a/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs
+++ b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs
@@ -191,10 +191,107 @@ namespace OpenSim.Services.Connectors
191 return accounts; 191 return accounts;
192 } 192 }
193 193
194 public virtual List<UserAccount> GetUserAccounts(UUID scopeID, List<string> IDs)
195 {
196 List<UserAccount> accs = new List<UserAccount>();
197 bool multisuported = true;
198 accs = doGetMultiUserAccounts(scopeID, IDs, out multisuported);
199 if(multisuported)
200 return accs;
201
202 // service does not do multi accounts so need to do it one by one
203
204 UUID uuid = UUID.Zero;
205 foreach(string id in IDs)
206 {
207 if(UUID.TryParse(id, out uuid) && uuid != UUID.Zero)
208 accs.Add(GetUserAccount(scopeID,uuid));
209 }
210
211 return accs;
212 }
213
214 private List<UserAccount> doGetMultiUserAccounts(UUID scopeID, List<string> IDs, out bool suported)
215 {
216 suported = true;
217 Dictionary<string, object> sendData = new Dictionary<string, object>();
218 //sendData["SCOPEID"] = scopeID.ToString();
219 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
220 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
221 sendData["METHOD"] = "getmultiaccounts";
222
223 sendData["ScopeID"] = scopeID.ToString();
224 sendData["IDS"] = new List<string>(IDs);
225
226 string reply = string.Empty;
227 string reqString = ServerUtils.BuildQueryString(sendData);
228 string uri = m_ServerURI + "/accounts";
229 // m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString);
230 try
231 {
232 reply = SynchronousRestFormsRequester.MakeRequest("POST",
233 uri,
234 reqString,
235 m_Auth);
236 if (reply == null || (reply != null && reply == string.Empty))
237 {
238 m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetMultiUserAccounts received null or empty reply");
239 return null;
240 }
241 }
242 catch (Exception e)
243 {
244 m_log.DebugFormat("[ACCOUNT CONNECTOR]: Exception when contacting user accounts server at {0}: {1}", uri, e.Message);
245 }
246
247 List<UserAccount> accounts = new List<UserAccount>();
248
249 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
250
251 if (replyData != null)
252 {
253 if (replyData.ContainsKey("result"))
254 {
255 if(replyData["result"].ToString() == "null")
256 return accounts;
257
258 if(replyData["result"].ToString() == "Failure")
259 {
260 suported = false;
261 return accounts;
262 }
263 }
264
265 Dictionary<string, object>.ValueCollection accountList = replyData.Values;
266 //m_log.DebugFormat("[ACCOUNTS CONNECTOR]: GetAgents returned {0} elements", pinfosList.Count);
267 foreach (object acc in accountList)
268 {
269 if (acc is Dictionary<string, object>)
270 {
271 UserAccount pinfo = new UserAccount((Dictionary<string, object>)acc);
272 accounts.Add(pinfo);
273 }
274 else
275 m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetMultiUserAccounts received invalid response type {0}",
276 acc.GetType());
277 }
278 }
279 else
280 m_log.DebugFormat("[ACCOUNTS CONNECTOR]: GetMultiUserAccounts received null response");
281
282 return accounts;
283 }
284
285
194 public void InvalidateCache(UUID userID) 286 public void InvalidateCache(UUID userID)
195 { 287 {
196 } 288 }
197 289
290 public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string where)
291 {
292 return null; // Not implemented for regions
293 }
294
198 public virtual bool StoreUserAccount(UserAccount data) 295 public virtual bool StoreUserAccount(UserAccount data)
199 { 296 {
200 Dictionary<string, object> sendData = new Dictionary<string, object>(); 297 Dictionary<string, object> sendData = new Dictionary<string, object>();
@@ -247,7 +344,7 @@ namespace OpenSim.Services.Connectors
247 344
248 return SendAndGetReply(sendData); 345 return SendAndGetReply(sendData);
249 } 346 }
250 347
251 private UserAccount SendAndGetReply(Dictionary<string, object> sendData) 348 private UserAccount SendAndGetReply(Dictionary<string, object> sendData)
252 { 349 {
253 string reply = string.Empty; 350 string reply = string.Empty;
diff --git a/OpenSim/Services/EstateService/EstateDataService.cs b/OpenSim/Services/EstateService/EstateDataService.cs
index f6a8654..f051ffb 100644
--- a/OpenSim/Services/EstateService/EstateDataService.cs
+++ b/OpenSim/Services/EstateService/EstateDataService.cs
@@ -92,11 +92,11 @@ namespace OpenSim.Services.EstateService
92 { 92 {
93 return m_database.CreateNewEstate(); 93 return m_database.CreateNewEstate();
94 } 94 }
95 95
96 public List<EstateSettings> LoadEstateSettingsAll() 96 public List<EstateSettings> LoadEstateSettingsAll()
97 { 97 {
98 return m_database.LoadEstateSettingsAll(); 98 return m_database.LoadEstateSettingsAll();
99 } 99 }
100 100
101 public void StoreEstateSettings(EstateSettings es) 101 public void StoreEstateSettings(EstateSettings es)
102 { 102 {
@@ -107,7 +107,7 @@ namespace OpenSim.Services.EstateService
107 { 107 {
108 return m_database.GetEstates(search); 108 return m_database.GetEstates(search);
109 } 109 }
110 110
111 public List<int> GetEstatesAll() 111 public List<int> GetEstatesAll()
112 { 112 {
113 return m_database.GetEstatesAll(); 113 return m_database.GetEstatesAll();
diff --git a/OpenSim/Services/FSAssetService/FSAssetService.cs b/OpenSim/Services/FSAssetService/FSAssetService.cs
index aba8b33..27b04f7 100644
--- a/OpenSim/Services/FSAssetService/FSAssetService.cs
+++ b/OpenSim/Services/FSAssetService/FSAssetService.cs
@@ -76,6 +76,8 @@ namespace OpenSim.Services.FSAssetService
76 protected int m_missingAssets = 0; 76 protected int m_missingAssets = 0;
77 protected int m_missingAssetsFS = 0; 77 protected int m_missingAssetsFS = 0;
78 protected string m_FSBase; 78 protected string m_FSBase;
79 protected bool m_useOsgridFormat = false;
80 protected bool m_showStats = true;
79 81
80 private static bool m_Initialized; 82 private static bool m_Initialized;
81 private bool m_MainInstance; 83 private bool m_MainInstance;
@@ -113,34 +115,34 @@ namespace OpenSim.Services.FSAssetService
113 } 115 }
114 116
115 IConfig assetConfig = config.Configs[configName]; 117 IConfig assetConfig = config.Configs[configName];
116 118
117 if (assetConfig == null) 119 if (assetConfig == null)
118 throw new Exception("No AssetService configuration"); 120 throw new Exception("No AssetService configuration");
119 121
120 // Get Database Connector from Asset Config (If present) 122 // Get Database Connector from Asset Config (If present)
121 string dllName = assetConfig.GetString("StorageProvider", string.Empty); 123 string dllName = assetConfig.GetString("StorageProvider", string.Empty);
122 string m_ConnectionString = assetConfig.GetString("ConnectionString", string.Empty); 124 string connectionString = assetConfig.GetString("ConnectionString", string.Empty);
123 string m_Realm = assetConfig.GetString("Realm", "fsassets"); 125 string realm = assetConfig.GetString("Realm", "fsassets");
124 126
125 int SkipAccessTimeDays = assetConfig.GetInt("DaysBetweenAccessTimeUpdates", 0); 127 int SkipAccessTimeDays = assetConfig.GetInt("DaysBetweenAccessTimeUpdates", 0);
126 128
127 // If not found above, fallback to Database defaults 129 // If not found above, fallback to Database defaults
128 IConfig dbConfig = config.Configs["DatabaseService"]; 130 IConfig dbConfig = config.Configs["DatabaseService"];
129 131
130 if (dbConfig != null) 132 if (dbConfig != null)
131 { 133 {
132 if (dllName == String.Empty) 134 if (dllName == String.Empty)
133 dllName = dbConfig.GetString("StorageProvider", String.Empty); 135 dllName = dbConfig.GetString("StorageProvider", String.Empty);
134 136
135 if (m_ConnectionString == String.Empty) 137 if (connectionString == String.Empty)
136 m_ConnectionString = dbConfig.GetString("ConnectionString", String.Empty); 138 connectionString = dbConfig.GetString("ConnectionString", String.Empty);
137 } 139 }
138 140
139 // No databse connection found in either config 141 // No databse connection found in either config
140 if (dllName.Equals(String.Empty)) 142 if (dllName.Equals(String.Empty))
141 throw new Exception("No StorageProvider configured"); 143 throw new Exception("No StorageProvider configured");
142 144
143 if (m_ConnectionString.Equals(String.Empty)) 145 if (connectionString.Equals(String.Empty))
144 throw new Exception("Missing database connection string"); 146 throw new Exception("Missing database connection string");
145 147
146 // Create Storage Provider 148 // Create Storage Provider
@@ -150,11 +152,11 @@ namespace OpenSim.Services.FSAssetService
150 throw new Exception(string.Format("Could not find a storage interface in the module {0}", dllName)); 152 throw new Exception(string.Format("Could not find a storage interface in the module {0}", dllName));
151 153
152 // Initialize DB And perform any migrations required 154 // Initialize DB And perform any migrations required
153 m_DataConnector.Initialise(m_ConnectionString, m_Realm, SkipAccessTimeDays); 155 m_DataConnector.Initialise(connectionString, realm, SkipAccessTimeDays);
154 156
155 // Setup Fallback Service 157 // Setup Fallback Service
156 string str = assetConfig.GetString("FallbackService", string.Empty); 158 string str = assetConfig.GetString("FallbackService", string.Empty);
157 159
158 if (str != string.Empty) 160 if (str != string.Empty)
159 { 161 {
160 object[] args = new object[] { config }; 162 object[] args = new object[] { config };
@@ -177,12 +179,29 @@ namespace OpenSim.Services.FSAssetService
177 Directory.CreateDirectory(spoolTmp); 179 Directory.CreateDirectory(spoolTmp);
178 180
179 m_FSBase = assetConfig.GetString("BaseDirectory", String.Empty); 181 m_FSBase = assetConfig.GetString("BaseDirectory", String.Empty);
182 m_log.InfoFormat("[FSASSETS]: Assets base and spool directory are {0} and {1}", m_FSBase, m_SpoolDirectory);
180 if (m_FSBase == String.Empty) 183 if (m_FSBase == String.Empty)
181 { 184 {
182 m_log.ErrorFormat("[FSASSETS]: BaseDirectory not specified"); 185 m_log.ErrorFormat("[FSASSETS]: BaseDirectory not specified");
183 throw new Exception("Configuration error"); 186 throw new Exception("Configuration error");
184 } 187 }
185 188
189 // OSGrid format is /3/3/, OpenSims default format is /2/2/2/4/. Try to figure out which we have.
190 List<string> dirs = new List<string>(Directory.EnumerateDirectories(m_FSBase));
191 foreach (var dir in dirs)
192 {
193 if (3 == dir.Substring(dir.LastIndexOf(Path.DirectorySeparatorChar) + 1).Length)
194 {
195 m_useOsgridFormat = true;
196 break;
197 }
198 }
199 m_useOsgridFormat = assetConfig.GetBoolean("UseOsgridFormat", m_useOsgridFormat);
200 m_log.InfoFormat("[FSASSETS]: UseOsgridFormat is {0}", m_useOsgridFormat);
201
202 // Default is to show stats to retain original behaviour
203 m_showStats = assetConfig.GetBoolean("ShowConsoleStats", m_showStats);
204
186 if (m_MainInstance) 205 if (m_MainInstance)
187 { 206 {
188 string loader = assetConfig.GetString("DefaultAssetLoader", string.Empty); 207 string loader = assetConfig.GetString("DefaultAssetLoader", string.Empty);
@@ -197,13 +216,17 @@ namespace OpenSim.Services.FSAssetService
197 Store(a, false); 216 Store(a, false);
198 }); 217 });
199 } 218 }
200 219
201 m_WriterThread = new Thread(Writer); 220 m_WriterThread = new Thread(Writer);
202 m_WriterThread.Start(); 221 m_WriterThread.Start();
203 m_StatsThread = new Thread(Stats); 222
204 m_StatsThread.Start(); 223 if (m_showStats)
224 {
225 m_StatsThread = new Thread(Stats);
226 m_StatsThread.Start();
227 }
205 } 228 }
206 229
207 m_log.Info("[FSASSETS]: FS asset service enabled"); 230 m_log.Info("[FSASSETS]: FS asset service enabled");
208 } 231 }
209 232
@@ -212,7 +235,7 @@ namespace OpenSim.Services.FSAssetService
212 while (true) 235 while (true)
213 { 236 {
214 Thread.Sleep(60000); 237 Thread.Sleep(60000);
215 238
216 lock (m_statsLock) 239 lock (m_statsLock)
217 { 240 {
218 if (m_readCount > 0) 241 if (m_readCount > 0)
@@ -220,6 +243,7 @@ namespace OpenSim.Services.FSAssetService
220 double avg = (double)m_readTicks / (double)m_readCount; 243 double avg = (double)m_readTicks / (double)m_readCount;
221// if (avg > 10000) 244// if (avg > 10000)
222// Environment.Exit(0); 245// Environment.Exit(0);
246//// m_log.InfoFormat("[FSASSETS]: Read stats: {0} files, {1} ticks, avg {2:F2}, missing {3}, FS {4}", m_readCount, m_readTicks, (double)m_readTicks / (double)m_readCount, m_missingAssets, m_missingAssetsFS);
223 } 247 }
224 m_readCount = 0; 248 m_readCount = 0;
225 m_readTicks = 0; 249 m_readTicks = 0;
@@ -231,7 +255,7 @@ namespace OpenSim.Services.FSAssetService
231 255
232 private void Writer() 256 private void Writer()
233 { 257 {
234 m_log.Info("[FSASSETS]: Writer started"); 258 m_log.Info("[ASSET]: Writer started");
235 259
236 while (true) 260 while (true)
237 { 261 {
@@ -245,33 +269,98 @@ namespace OpenSim.Services.FSAssetService
245 string hash = Path.GetFileNameWithoutExtension(files[i]); 269 string hash = Path.GetFileNameWithoutExtension(files[i]);
246 string s = HashToFile(hash); 270 string s = HashToFile(hash);
247 string diskFile = Path.Combine(m_FSBase, s); 271 string diskFile = Path.Combine(m_FSBase, s);
272 bool pathOk = false;
248 273
249 Directory.CreateDirectory(Path.GetDirectoryName(diskFile)); 274 // The cure for chicken bones!
250 try 275 while(true)
251 { 276 {
252 byte[] data = File.ReadAllBytes(files[i]); 277 try
253
254 using (GZipStream gz = new GZipStream(new FileStream(diskFile + ".gz", FileMode.Create), CompressionMode.Compress))
255 { 278 {
256 gz.Write(data, 0, data.Length); 279 // Try to make the directory we need for this file
257 gz.Close(); 280 Directory.CreateDirectory(Path.GetDirectoryName(diskFile));
281 pathOk = true;
282 break;
258 } 283 }
259 File.Delete(files[i]); 284 catch (System.IO.IOException)
260 285 {
261 //File.Move(files[i], diskFile); 286 // Creating the directory failed. This can't happen unless
287 // a part of the path already exists as a file. Sadly the
288 // SRAS data contains such files.
289 string d = Path.GetDirectoryName(diskFile);
290
291 // Test each path component in turn. If we can successfully
292 // make a directory, the level below must be the chicken bone.
293 while (d.Length > 0)
294 {
295 Console.WriteLine(d);
296 try
297 {
298 Directory.CreateDirectory(Path.GetDirectoryName(d));
299 }
300 catch (System.IO.IOException)
301 {
302 d = Path.GetDirectoryName(d);
303
304 // We failed making the directory and need to
305 // go up a bit more
306 continue;
307 }
308
309 // We succeeded in making the directory and (d) is
310 // the chicken bone
311 break;
312 }
313
314 // Is the chicken alive?
315 if (d.Length > 0)
316 {
317 Console.WriteLine(d);
318
319 FileAttributes attr = File.GetAttributes(d);
320
321 if ((attr & FileAttributes.Directory) == 0)
322 {
323 // The chicken bone should be resolved.
324 // Return to writing the file.
325 File.Delete(d);
326 continue;
327 }
328 }
329 }
330 // Could not resolve, skipping
331 m_log.ErrorFormat("[ASSET]: Could not resolve path creation error for {0}", diskFile);
332 break;
262 } 333 }
263 catch(System.IO.IOException e) 334
335 if (pathOk)
264 { 336 {
265 if (e.Message.StartsWith("Win32 IO returned ERROR_ALREADY_EXISTS")) 337 try
338 {
339 byte[] data = File.ReadAllBytes(files[i]);
340
341 using (GZipStream gz = new GZipStream(new FileStream(diskFile + ".gz", FileMode.Create), CompressionMode.Compress))
342 {
343 gz.Write(data, 0, data.Length);
344 gz.Close();
345 }
266 File.Delete(files[i]); 346 File.Delete(files[i]);
267 else 347
268 throw; 348 //File.Move(files[i], diskFile);
349 }
350 catch(System.IO.IOException e)
351 {
352 if (e.Message.StartsWith("Win32 IO returned ERROR_ALREADY_EXISTS"))
353 File.Delete(files[i]);
354 else
355 throw;
356 }
269 } 357 }
270 } 358 }
359
271 int totalTicks = System.Environment.TickCount - tickCount; 360 int totalTicks = System.Environment.TickCount - tickCount;
272 if (totalTicks > 0) // Wrap? 361 if (totalTicks > 0) // Wrap?
273 { 362 {
274 m_log.InfoFormat("[FSASSETS]: Write cycle complete, {0} files, {1} ticks, avg {2:F2}", files.Length, totalTicks, (double)totalTicks / (double)files.Length); 363 m_log.InfoFormat("[ASSET]: Write cycle complete, {0} files, {1} ticks, avg {2:F2}", files.Length, totalTicks, (double)totalTicks / (double)files.Length);
275 } 364 }
276 } 365 }
277 366
@@ -291,20 +380,27 @@ namespace OpenSim.Services.FSAssetService
291 if (hash == null || hash.Length < 10) 380 if (hash == null || hash.Length < 10)
292 return "junkyard"; 381 return "junkyard";
293 382
294 return Path.Combine(hash.Substring(0, 3), 383 if (m_useOsgridFormat)
295 Path.Combine(hash.Substring(3, 3))); 384 {
296 /* 385 /*
297 * The below is what core would normally use. 386 * The code below is the OSGrid code.
298 * This is modified to work in OSGrid, as seen 387 */
299 * above, because the SRAS data is structured 388 return Path.Combine(hash.Substring(0, 3),
300 * that way. 389 Path.Combine(hash.Substring(3, 3)));
301 */ 390 }
302 /* 391 else
303 return Path.Combine(hash.Substring(0, 2), 392 {
304 Path.Combine(hash.Substring(2, 2), 393 /*
305 Path.Combine(hash.Substring(4, 2), 394 * The below is what core would normally use.
306 hash.Substring(6, 4)))); 395 * This is modified to work in OSGrid, as seen
307 */ 396 * above, because the SRAS data is structured
397 * that way.
398 */
399 return Path.Combine(hash.Substring(0, 2),
400 Path.Combine(hash.Substring(2, 2),
401 Path.Combine(hash.Substring(4, 2),
402 hash.Substring(6, 4))));
403 }
308 } 404 }
309 405
310 private bool AssetExists(string hash) 406 private bool AssetExists(string hash)
@@ -365,7 +461,7 @@ namespace OpenSim.Services.FSAssetService
365 Store(asset); 461 Store(asset);
366 } 462 }
367 } 463 }
368 if (asset == null) 464 if (asset == null && m_showStats)
369 { 465 {
370 // m_log.InfoFormat("[FSASSETS]: Asset {0} not found", id); 466 // m_log.InfoFormat("[FSASSETS]: Asset {0} not found", id);
371 m_missingAssets++; 467 m_missingAssets++;
@@ -393,8 +489,11 @@ namespace OpenSim.Services.FSAssetService
393 } 489 }
394 } 490 }
395 if (asset == null) 491 if (asset == null)
396 m_missingAssetsFS++; 492 {
397 // m_log.InfoFormat("[FSASSETS]: Asset {0}, hash {1} not found in FS", id, hash); 493 if (m_showStats)
494 m_missingAssetsFS++;
495 // m_log.InfoFormat("[FSASSETS]: Asset {0}, hash {1} not found in FS", id, hash);
496 }
398 else 497 else
399 { 498 {
400 // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8) 499 // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8)
@@ -408,10 +507,13 @@ namespace OpenSim.Services.FSAssetService
408 } 507 }
409 } 508 }
410 509
411 lock (m_statsLock) 510 if (m_showStats)
412 { 511 {
413 m_readTicks += Environment.TickCount - startTime; 512 lock (m_statsLock)
414 m_readCount++; 513 {
514 m_readTicks += Environment.TickCount - startTime;
515 m_readCount++;
516 }
415 } 517 }
416 518
417 // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8) 519 // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8)
@@ -578,6 +680,9 @@ namespace OpenSim.Services.FSAssetService
578 680
579 if (!m_DataConnector.Store(asset.Metadata, hash)) 681 if (!m_DataConnector.Store(asset.Metadata, hash))
580 { 682 {
683 if (asset.Metadata.Type == -2)
684 return asset.ID;
685
581 return UUID.Zero.ToString(); 686 return UUID.Zero.ToString();
582 } 687 }
583 else 688 else
@@ -630,7 +735,7 @@ namespace OpenSim.Services.FSAssetService
630 AssetBase asset = Get(args[2], out hash); 735 AssetBase asset = Get(args[2], out hash);
631 736
632 if (asset == null || asset.Data.Length == 0) 737 if (asset == null || asset.Data.Length == 0)
633 { 738 {
634 MainConsole.Instance.Output("Asset not found"); 739 MainConsole.Instance.Output("Asset not found");
635 return; 740 return;
636 } 741 }
@@ -672,7 +777,7 @@ namespace OpenSim.Services.FSAssetService
672 AssetBase asset = Get(args[2]); 777 AssetBase asset = Get(args[2]);
673 778
674 if (asset == null || asset.Data.Length == 0) 779 if (asset == null || asset.Data.Length == 0)
675 { 780 {
676 MainConsole.Instance.Output("Asset not found"); 781 MainConsole.Instance.Output("Asset not found");
677 return; 782 return;
678 } 783 }
diff --git a/OpenSim/Services/FreeswitchService/FreeswitchService.cs b/OpenSim/Services/FreeswitchService/FreeswitchService.cs
index 201e72f..970d682 100644
--- a/OpenSim/Services/FreeswitchService/FreeswitchService.cs
+++ b/OpenSim/Services/FreeswitchService/FreeswitchService.cs
@@ -74,7 +74,7 @@ namespace OpenSim.Services.FreeswitchService
74 response["str_response_string"] = String.Format(@"<?xml version=""1.0"" encoding=""utf-8""?> 74 response["str_response_string"] = String.Format(@"<?xml version=""1.0"" encoding=""utf-8""?>
75 <document type=""freeswitch/xml""> 75 <document type=""freeswitch/xml"">
76 <section name=""dialplan""> 76 <section name=""dialplan"">
77 <context name=""{0}"">" + 77 <context name=""{0}"">" +
78 78
79/* <!-- dial via SIP uri --> 79/* <!-- dial via SIP uri -->
80 <extension name=""sip_uri""> 80 <extension name=""sip_uri"">
@@ -116,21 +116,21 @@ namespace OpenSim.Services.FreeswitchService
116 { 116 {
117 Hashtable response = new Hashtable(); 117 Hashtable response = new Hashtable();
118 string domain = (string) request["domain"]; 118 string domain = (string) request["domain"];
119 if (domain != m_freeSwitchRealm) 119 if (domain != m_freeSwitchRealm)
120 { 120 {
121 response["content_type"] = "text/xml"; 121 response["content_type"] = "text/xml";
122 response["keepalive"] = false; 122 response["keepalive"] = false;
123 response["int_response_code"] = 200; 123 response["int_response_code"] = 200;
124 response["str_response_string"] = ""; 124 response["str_response_string"] = "";
125 } 125 }
126 else 126 else
127 { 127 {
128// m_log.DebugFormat("[FreeSwitchDirectory]: HandleDirectoryRequest called with {0}",request.ToString()); 128// m_log.DebugFormat("[FreeSwitchDirectory]: HandleDirectoryRequest called with {0}",request.ToString());
129 129
130 // information in the request we might be interested in 130 // information in the request we might be interested in
131 131
132 // Request 1 sip_auth for users account 132 // Request 1 sip_auth for users account
133 133
134 //Event-Calling-Function=sofia_reg_parse_auth 134 //Event-Calling-Function=sofia_reg_parse_auth
135 //Event-Calling-Line-Number=1494 135 //Event-Calling-Line-Number=1494
136 //action=sip_auth 136 //action=sip_auth
@@ -145,10 +145,10 @@ namespace OpenSim.Services.FreeswitchService
145 //user=xhZuXKmRpECyr2AARJYyGgg%3D%3D 145 //user=xhZuXKmRpECyr2AARJYyGgg%3D%3D
146 //domain=9.20.151.43 146 //domain=9.20.151.43
147 //ip=9.167.220.137 // this is the correct IP rather than sip_contact_host above when through a vpn or NAT setup 147 //ip=9.167.220.137 // this is the correct IP rather than sip_contact_host above when through a vpn or NAT setup
148 148
149// foreach (DictionaryEntry item in request) 149// foreach (DictionaryEntry item in request)
150// m_log.DebugFormat("[FreeSwitchDirectory]: requestBody item {0} {1}", item.Key, item.Value); 150// m_log.DebugFormat("[FreeSwitchDirectory]: requestBody item {0} {1}", item.Key, item.Value);
151 151
152 string eventCallingFunction = (string) request["Event-Calling-Function"]; 152 string eventCallingFunction = (string) request["Event-Calling-Function"];
153 if (eventCallingFunction == null) 153 if (eventCallingFunction == null)
154 { 154 {
@@ -159,15 +159,15 @@ namespace OpenSim.Services.FreeswitchService
159 { 159 {
160 eventCallingFunction = "sofia_reg_parse_auth"; 160 eventCallingFunction = "sofia_reg_parse_auth";
161 } 161 }
162 162
163 if (eventCallingFunction == "sofia_reg_parse_auth") 163 if (eventCallingFunction == "sofia_reg_parse_auth")
164 { 164 {
165 string sipAuthMethod = (string)request["sip_auth_method"]; 165 string sipAuthMethod = (string)request["sip_auth_method"];
166 166
167 if (sipAuthMethod == "REGISTER") 167 if (sipAuthMethod == "REGISTER")
168 { 168 {
169 response = HandleRegister(m_freeSwitchContext, m_freeSwitchRealm, request); 169 response = HandleRegister(m_freeSwitchContext, m_freeSwitchRealm, request);
170 } 170 }
171 else if (sipAuthMethod == "INVITE") 171 else if (sipAuthMethod == "INVITE")
172 { 172 {
173 response = HandleInvite(m_freeSwitchContext, m_freeSwitchRealm, request); 173 response = HandleInvite(m_freeSwitchContext, m_freeSwitchRealm, request);
@@ -215,16 +215,16 @@ namespace OpenSim.Services.FreeswitchService
215 } 215 }
216 return response; 216 return response;
217 } 217 }
218 218
219 private Hashtable HandleRegister(string Context, string Realm, Hashtable request) 219 private Hashtable HandleRegister(string Context, string Realm, Hashtable request)
220 { 220 {
221 m_log.Info("[FreeSwitchDirectory]: HandleRegister called"); 221 m_log.Info("[FreeSwitchDirectory]: HandleRegister called");
222 222
223 // TODO the password we return needs to match that sent in the request, this is hard coded for now 223 // TODO the password we return needs to match that sent in the request, this is hard coded for now
224 string password = "1234"; 224 string password = "1234";
225 string domain = (string) request["domain"]; 225 string domain = (string) request["domain"];
226 string user = (string) request["user"]; 226 string user = (string) request["user"];
227 227
228 Hashtable response = new Hashtable(); 228 Hashtable response = new Hashtable();
229 response["content_type"] = "text/xml"; 229 response["content_type"] = "text/xml";
230 response["keepalive"] = false; 230 response["keepalive"] = false;
@@ -249,20 +249,20 @@ namespace OpenSim.Services.FreeswitchService
249 "</section>\r\n" + 249 "</section>\r\n" +
250 "</document>\r\n", 250 "</document>\r\n",
251 domain , user, password, Context); 251 domain , user, password, Context);
252 252
253 return response; 253 return response;
254 } 254 }
255 255
256 private Hashtable HandleInvite(string Context, string Realm, Hashtable request) 256 private Hashtable HandleInvite(string Context, string Realm, Hashtable request)
257 { 257 {
258 m_log.Info("[FreeSwitchDirectory]: HandleInvite called"); 258 m_log.Info("[FreeSwitchDirectory]: HandleInvite called");
259 259
260 // TODO the password we return needs to match that sent in the request, this is hard coded for now 260 // TODO the password we return needs to match that sent in the request, this is hard coded for now
261 string password = "1234"; 261 string password = "1234";
262 string domain = (string) request["domain"]; 262 string domain = (string) request["domain"];
263 string user = (string) request["user"]; 263 string user = (string) request["user"];
264 string sipRequestUser = (string) request["sip_request_user"]; 264 string sipRequestUser = (string) request["sip_request_user"];
265 265
266 Hashtable response = new Hashtable(); 266 Hashtable response = new Hashtable();
267 response["content_type"] = "text/xml"; 267 response["content_type"] = "text/xml";
268 response["keepalive"] = false; 268 response["keepalive"] = false;
@@ -296,18 +296,18 @@ namespace OpenSim.Services.FreeswitchService
296 "</section>\r\n" + 296 "</section>\r\n" +
297 "</document>\r\n", 297 "</document>\r\n",
298 domain , user, password,sipRequestUser, Context); 298 domain , user, password,sipRequestUser, Context);
299 299
300 return response; 300 return response;
301 } 301 }
302 302
303 private Hashtable HandleLocateUser(String Realm, Hashtable request) 303 private Hashtable HandleLocateUser(String Realm, Hashtable request)
304 { 304 {
305 m_log.Info("[FreeSwitchDirectory]: HandleLocateUser called"); 305 m_log.Info("[FreeSwitchDirectory]: HandleLocateUser called");
306 306
307 // TODO the password we return needs to match that sent in the request, this is hard coded for now 307 // TODO the password we return needs to match that sent in the request, this is hard coded for now
308 string domain = (string) request["domain"]; 308 string domain = (string) request["domain"];
309 string user = (string) request["user"]; 309 string user = (string) request["user"];
310 310
311 Hashtable response = new Hashtable(); 311 Hashtable response = new Hashtable();
312 response["content_type"] = "text/xml"; 312 response["content_type"] = "text/xml";
313 response["keepalive"] = false; 313 response["keepalive"] = false;
@@ -330,17 +330,17 @@ namespace OpenSim.Services.FreeswitchService
330 "</section>\r\n" + 330 "</section>\r\n" +
331 "</document>\r\n", 331 "</document>\r\n",
332 domain , user); 332 domain , user);
333 333
334 return response; 334 return response;
335 } 335 }
336 336
337 private Hashtable HandleConfigSofia(string Context, string Realm, Hashtable request) 337 private Hashtable HandleConfigSofia(string Context, string Realm, Hashtable request)
338 { 338 {
339 m_log.Info("[FreeSwitchDirectory]: HandleConfigSofia called."); 339 m_log.Info("[FreeSwitchDirectory]: HandleConfigSofia called.");
340 340
341 // TODO the password we return needs to match that sent in the request, this is hard coded for now 341 // TODO the password we return needs to match that sent in the request, this is hard coded for now
342 string domain = (string) request["domain"]; 342 string domain = (string) request["domain"];
343 343
344 Hashtable response = new Hashtable(); 344 Hashtable response = new Hashtable();
345 response["content_type"] = "text/xml"; 345 response["content_type"] = "text/xml";
346 response["keepalive"] = false; 346 response["keepalive"] = false;
@@ -381,9 +381,9 @@ namespace OpenSim.Services.FreeswitchService
381 "</variables>\r\n"+ 381 "</variables>\r\n"+
382 "</domain>\r\n" + 382 "</domain>\r\n" +
383 "</section>\r\n" + 383 "</section>\r\n" +
384 "</document>\r\n", 384 "</document>\r\n",
385 domain, Context); 385 domain, Context);
386 386
387 return response; 387 return response;
388 } 388 }
389 389
diff --git a/OpenSim/Services/FreeswitchService/Properties/AssemblyInfo.cs b/OpenSim/Services/FreeswitchService/Properties/AssemblyInfo.cs
index 1e3560b..bfeb388d 100644
--- a/OpenSim/Services/FreeswitchService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/FreeswitchService/Properties/AssemblyInfo.cs
@@ -2,7 +2,7 @@
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4 4
5// General Information about an assembly is controlled through the following 5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly. 7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Services.FreeswitchService")] 8[assembly: AssemblyTitle("OpenSim.Services.FreeswitchService")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
14[assembly: AssemblyTrademark("")] 14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")] 15[assembly: AssemblyCulture("")]
16 16
17// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)] 20[assembly: ComVisible(false)]
21 21
@@ -25,9 +25,9 @@ using System.Runtime.InteropServices;
25// Version information for an assembly consists of the following four values: 25// Version information for an assembly consists of the following four values:
26// 26//
27// Major Version 27// Major Version
28// Minor Version 28// Minor Version
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.8.3.*")] 32[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
33 33
diff --git a/OpenSim/Services/Friends/Properties/AssemblyInfo.cs b/OpenSim/Services/Friends/Properties/AssemblyInfo.cs
index 87fb6a9..3e6447a 100644
--- a/OpenSim/Services/Friends/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/Friends/Properties/AssemblyInfo.cs
@@ -2,7 +2,7 @@
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4 4
5// General Information about an assembly is controlled through the following 5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly. 7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Services.FriendsService")] 8[assembly: AssemblyTitle("OpenSim.Services.FriendsService")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
14[assembly: AssemblyTrademark("")] 14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")] 15[assembly: AssemblyCulture("")]
16 16
17// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)] 20[assembly: ComVisible(false)]
21 21
@@ -25,9 +25,9 @@ using System.Runtime.InteropServices;
25// Version information for an assembly consists of the following four values: 25// Version information for an assembly consists of the following four values:
26// 26//
27// Major Version 27// Major Version
28// Minor Version 28// Minor Version
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.8.3.*")] 32[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
33 33
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index 0c502a2..e0500a6 100644
--- a/OpenSim/Services/GridService/GridService.cs
+++ b/OpenSim/Services/GridService/GridService.cs
@@ -57,8 +57,6 @@ namespace OpenSim.Services.GridService
57 protected bool m_AllowDuplicateNames = false; 57 protected bool m_AllowDuplicateNames = false;
58 protected bool m_AllowHypergridMapSearch = false; 58 protected bool m_AllowHypergridMapSearch = false;
59 59
60 protected bool m_SuppressVarregionOverlapCheckOnRegistration = false;
61
62 private static Dictionary<string,object> m_ExtraFeatures = new Dictionary<string, object>(); 60 private static Dictionary<string,object> m_ExtraFeatures = new Dictionary<string, object>();
63 61
64 public GridService(IConfigSource config) 62 public GridService(IConfigSource config)
@@ -74,7 +72,7 @@ namespace OpenSim.Services.GridService
74 if (gridConfig != null) 72 if (gridConfig != null)
75 { 73 {
76 m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true); 74 m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true);
77 75
78 string authService = gridConfig.GetString("AuthenticationService", String.Empty); 76 string authService = gridConfig.GetString("AuthenticationService", String.Empty);
79 77
80 if (authService != String.Empty) 78 if (authService != String.Empty)
@@ -85,8 +83,6 @@ namespace OpenSim.Services.GridService
85 m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames); 83 m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames);
86 m_AllowHypergridMapSearch = gridConfig.GetBoolean("AllowHypergridMapSearch", m_AllowHypergridMapSearch); 84 m_AllowHypergridMapSearch = gridConfig.GetBoolean("AllowHypergridMapSearch", m_AllowHypergridMapSearch);
87 85
88 m_SuppressVarregionOverlapCheckOnRegistration = gridConfig.GetBoolean("SuppressVarregionOverlapCheckOnRegistration", m_SuppressVarregionOverlapCheckOnRegistration);
89
90 // This service is also used locally by a simulator running in grid mode. This switches prevents 86 // This service is also used locally by a simulator running in grid mode. This switches prevents
91 // inappropriate console commands from being registered 87 // inappropriate console commands from being registered
92 suppressConsoleCommands = gridConfig.GetBoolean("SuppressConsoleCommands", suppressConsoleCommands); 88 suppressConsoleCommands = gridConfig.GetBoolean("SuppressConsoleCommands", suppressConsoleCommands);
@@ -155,9 +151,9 @@ namespace OpenSim.Services.GridService
155 151
156 if (loginConfig == null || gridConfig == null) 152 if (loginConfig == null || gridConfig == null)
157 return; 153 return;
158 154
159 string configVal; 155 string configVal;
160 156
161 configVal = loginConfig.GetString("SearchURL", string.Empty); 157 configVal = loginConfig.GetString("SearchURL", string.Empty);
162 if (!string.IsNullOrEmpty(configVal)) 158 if (!string.IsNullOrEmpty(configVal))
163 m_ExtraFeatures["search-server-url"] = configVal; 159 m_ExtraFeatures["search-server-url"] = configVal;
@@ -201,15 +197,29 @@ namespace OpenSim.Services.GridService
201 if (regionInfos.RegionID == UUID.Zero) 197 if (regionInfos.RegionID == UUID.Zero)
202 return "Invalid RegionID - cannot be zero UUID"; 198 return "Invalid RegionID - cannot be zero UUID";
203 199
200 if (regionInfos.RegionLocY <= Constants.MaximumRegionSize)
201 m_log.WarnFormat("{0} Region location reserved for HG links coord Y should be higher than {1}.", LogHeader, (Constants.MaximumRegionSize/256).ToString());
202//// return "Region location reserved for HG links coord Y must be higher than " + (Constants.MaximumRegionSize/256).ToString();
203
204 String reason = "Region overlaps another region"; 204 String reason = "Region overlaps another region";
205 RegionData region = FindAnyConflictingRegion(regionInfos, scopeID, out reason); 205
206 // If there is a conflicting region, if it has the same ID and same coordinates 206 List<RegionData> rdatas = m_Database.Get(
207 // then it is a region re-registering (permissions and ownership checked later). 207 regionInfos.RegionLocX,
208 if ((region != null) 208 regionInfos.RegionLocY,
209 && ( (region.coordX != regionInfos.RegionCoordX) 209 regionInfos.RegionLocX + regionInfos.RegionSizeX - 1,
210 || (region.coordY != regionInfos.RegionCoordY) 210 regionInfos.RegionLocY + regionInfos.RegionSizeY - 1 ,
211 || (region.RegionID != regionInfos.RegionID) ) 211 scopeID);
212 ) 212
213 RegionData region = null;
214 if(rdatas.Count > 1)
215 {
216 m_log.WarnFormat("{0} Register region overlaps with {1} regions", LogHeader, scopeID, rdatas.Count);
217 return reason;
218 }
219 else if(rdatas.Count == 1)
220 region = rdatas[0];
221
222 if ((region != null) && (region.RegionID != regionInfos.RegionID))
213 { 223 {
214 // If not same ID and same coordinates, this new region has conflicts and can't be registered. 224 // If not same ID and same coordinates, this new region has conflicts and can't be registered.
215 m_log.WarnFormat("{0} Register region conflict in scope {1}. {2}", LogHeader, scopeID, reason); 225 m_log.WarnFormat("{0} Register region conflict in scope {1}. {2}", LogHeader, scopeID, reason);
@@ -263,7 +273,7 @@ namespace OpenSim.Services.GridService
263 { 273 {
264 if (d.RegionID != regionInfos.RegionID) 274 if (d.RegionID != regionInfos.RegionID)
265 { 275 {
266 m_log.WarnFormat("[GRID SERVICE]: Region tried to register using a duplicate name. New region: {0} ({1}), existing region: {2} ({3}).", 276 m_log.WarnFormat("[GRID SERVICE]: Region tried to register using a duplicate name. New region: {0} ({1}), existing region: {2} ({3}).",
267 regionInfos.RegionName, regionInfos.RegionID, d.RegionName, d.RegionID); 277 regionInfos.RegionName, regionInfos.RegionID, d.RegionName, d.RegionID);
268 return "Duplicate region name"; 278 return "Duplicate region name";
269 } 279 }
@@ -273,7 +283,7 @@ namespace OpenSim.Services.GridService
273 283
274 // If there is an old record for us, delete it if it is elsewhere. 284 // If there is an old record for us, delete it if it is elsewhere.
275 region = m_Database.Get(regionInfos.RegionID, scopeID); 285 region = m_Database.Get(regionInfos.RegionID, scopeID);
276 if ((region != null) && (region.RegionID == regionInfos.RegionID) && 286 if ((region != null) && (region.RegionID == regionInfos.RegionID) &&
277 ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) 287 ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY)))
278 { 288 {
279 if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Framework.RegionFlags.NoMove) != 0) 289 if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Framework.RegionFlags.NoMove) != 0)
@@ -284,7 +294,7 @@ namespace OpenSim.Services.GridService
284 294
285 // Region reregistering in other coordinates. Delete the old entry 295 // Region reregistering in other coordinates. Delete the old entry
286 m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.", 296 m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.",
287 regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); 297 regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionCoordX, regionInfos.RegionCoordY);
288 298
289 try 299 try
290 { 300 {
@@ -299,7 +309,7 @@ namespace OpenSim.Services.GridService
299 // Everything is ok, let's register 309 // Everything is ok, let's register
300 RegionData rdata = RegionInfo2RegionData(regionInfos); 310 RegionData rdata = RegionInfo2RegionData(regionInfos);
301 rdata.ScopeID = scopeID; 311 rdata.ScopeID = scopeID;
302 312
303 if (region != null) 313 if (region != null)
304 { 314 {
305 int oldFlags = Convert.ToInt32(region.Data["flags"]); 315 int oldFlags = Convert.ToInt32(region.Data["flags"]);
@@ -337,106 +347,14 @@ namespace OpenSim.Services.GridService
337 } 347 }
338 348
339 m_log.InfoFormat 349 m_log.InfoFormat
340 ("[GRID SERVICE]: Region {0} ({1}, {2}x{3}) registered at {4},{5} with flags {6}", 350 ("[GRID SERVICE]: Region {0} ({1}, {2}x{3}) registered at {4},{5} with flags {6}",
341 regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionSizeX, regionInfos.RegionSizeY, 351 regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionSizeX, regionInfos.RegionSizeY,
342 regionInfos.RegionCoordX, regionInfos.RegionCoordY, 352 regionInfos.RegionCoordX, regionInfos.RegionCoordY,
343 (OpenSim.Framework.RegionFlags)flags); 353 (OpenSim.Framework.RegionFlags)flags);
344 354
345 return String.Empty; 355 return String.Empty;
346 } 356 }
347 357
348 /// <summary>
349 /// Search the region map for regions conflicting with this region.
350 /// The region to be added is passed and we look for any existing regions that are
351 /// in the requested location, that are large varregions that overlap this region, or
352 /// are previously defined regions that would lie under this new region.
353 /// </summary>
354 /// <param name="regionInfos">Information on region requested to be added to the world map</param>
355 /// <param name="scopeID">Grid id for region</param>
356 /// <param name="reason">The reason the returned region conflicts with passed region</param>
357 /// <returns></returns>
358 private RegionData FindAnyConflictingRegion(GridRegion regionInfos, UUID scopeID, out string reason)
359 {
360 reason = "Reregistration";
361 // First see if there is an existing region right where this region is trying to go
362 // (We keep this result so it can be returned if suppressing errors)
363 RegionData noErrorRegion = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
364 RegionData region = noErrorRegion;
365 if (region != null
366 && region.RegionID == regionInfos.RegionID
367 && region.sizeX == regionInfos.RegionSizeX
368 && region.sizeY == regionInfos.RegionSizeY)
369 {
370 // If this seems to be exactly the same region, return this as it could be
371 // a re-registration (permissions checked by calling routine).
372 m_log.DebugFormat("{0} FindAnyConflictingRegion: re-register of {1}",
373 LogHeader, RegionString(regionInfos));
374 return region;
375 }
376
377 // No region exactly there or we're resizing an existing region.
378 // Fetch regions that could be varregions overlapping requested location.
379 int xmin = regionInfos.RegionLocX - (int)Constants.MaximumRegionSize + 10;
380 int xmax = regionInfos.RegionLocX;
381 int ymin = regionInfos.RegionLocY - (int)Constants.MaximumRegionSize + 10;
382 int ymax = regionInfos.RegionLocY;
383 List<RegionData> rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID);
384 foreach (RegionData rdata in rdatas)
385 {
386 // m_log.DebugFormat("{0} FindAnyConflictingRegion: find existing. Checking {1}", LogHeader, RegionString(rdata) );
387 if ( (rdata.posX + rdata.sizeX > regionInfos.RegionLocX)
388 && (rdata.posY + rdata.sizeY > regionInfos.RegionLocY) )
389 {
390 region = rdata;
391 m_log.WarnFormat("{0} FindAnyConflictingRegion: conflict of {1} by existing varregion {2}",
392 LogHeader, RegionString(regionInfos), RegionString(region));
393 reason = String.Format("Region location is overlapped by existing varregion {0}",
394 RegionString(region));
395
396 if (m_SuppressVarregionOverlapCheckOnRegistration)
397 region = noErrorRegion;
398 return region;
399 }
400 }
401
402 // There isn't a region that overlaps this potential region.
403 // See if this potential region overlaps an existing region.
404 // First, a shortcut of not looking for overlap if new region is legacy region sized
405 // and connot overlap anything.
406 if (regionInfos.RegionSizeX != Constants.RegionSize
407 || regionInfos.RegionSizeY != Constants.RegionSize)
408 {
409 // trim range looked for so we don't pick up neighbor regions just off the edges
410 xmin = regionInfos.RegionLocX;
411 xmax = regionInfos.RegionLocX + regionInfos.RegionSizeX - 10;
412 ymin = regionInfos.RegionLocY;
413 ymax = regionInfos.RegionLocY + regionInfos.RegionSizeY - 10;
414 rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID);
415
416 // If the region is being resized, the found region could be ourself.
417 foreach (RegionData rdata in rdatas)
418 {
419 // m_log.DebugFormat("{0} FindAnyConflictingRegion: see if overlap. Checking {1}", LogHeader, RegionString(rdata) );
420 if (region == null || region.RegionID != regionInfos.RegionID)
421 {
422 region = rdata;
423 m_log.WarnFormat("{0} FindAnyConflictingRegion: conflict of varregion {1} overlaps existing region {2}",
424 LogHeader, RegionString(regionInfos), RegionString(region));
425 reason = String.Format("Region {0} would overlap existing region {1}",
426 RegionString(regionInfos), RegionString(region));
427
428 if (m_SuppressVarregionOverlapCheckOnRegistration)
429 region = noErrorRegion;
430 return region;
431 }
432 }
433 }
434
435 // If we get here, region is either null (nothing found here) or
436 // is the non-conflicting region found at the location being requested.
437 return region;
438 }
439
440 // String describing name and region location of passed region 358 // String describing name and region location of passed region
441 private String RegionString(RegionData reg) 359 private String RegionString(RegionData reg)
442 { 360 {
@@ -457,13 +375,13 @@ namespace OpenSim.Services.GridService
457 if (region == null) 375 if (region == null)
458 return false; 376 return false;
459 377
460 m_log.DebugFormat( 378 m_log.InfoFormat(
461 "[GRID SERVICE]: Deregistering region {0} ({1}) at {2}-{3}", 379 "[GRID SERVICE]: Deregistering region {0} ({1}) at {2}-{3}",
462 region.RegionName, region.RegionID, region.coordX, region.coordY); 380 region.RegionName, region.RegionID, region.coordX, region.coordY);
463 381
464 int flags = Convert.ToInt32(region.Data["flags"]); 382 int flags = Convert.ToInt32(region.Data["flags"]);
465 383
466 if (!m_DeleteOnUnregister || (flags & (int)OpenSim.Framework.RegionFlags.Persistent) != 0) 384 if ((!m_DeleteOnUnregister) || ((flags & (int)OpenSim.Framework.RegionFlags.Persistent) != 0))
467 { 385 {
468 flags &= ~(int)OpenSim.Framework.RegionFlags.RegionOnline; 386 flags &= ~(int)OpenSim.Framework.RegionFlags.RegionOnline;
469 region.Data["flags"] = flags.ToString(); 387 region.Data["flags"] = flags.ToString();
@@ -478,7 +396,6 @@ namespace OpenSim.Services.GridService
478 } 396 }
479 397
480 return true; 398 return true;
481
482 } 399 }
483 400
484 return m_Database.Delete(regionID); 401 return m_Database.Delete(regionID);
@@ -488,13 +405,11 @@ namespace OpenSim.Services.GridService
488 { 405 {
489 List<GridRegion> rinfos = new List<GridRegion>(); 406 List<GridRegion> rinfos = new List<GridRegion>();
490 RegionData region = m_Database.Get(regionID, scopeID); 407 RegionData region = m_Database.Get(regionID, scopeID);
491 408
492 if (region != null) 409 if (region != null)
493 { 410 {
494 // Not really? Maybe?
495 // The adjacent regions are presumed to be the same size as the current region
496 List<RegionData> rdatas = m_Database.Get( 411 List<RegionData> rdatas = m_Database.Get(
497 region.posX - region.sizeX - 1, region.posY - region.sizeY - 1, 412 region.posX - 1, region.posY - 1,
498 region.posX + region.sizeX + 1, region.posY + region.sizeY + 1, scopeID); 413 region.posX + region.sizeX + 1, region.posY + region.sizeY + 1, scopeID);
499 414
500 foreach (RegionData rdata in rdatas) 415 foreach (RegionData rdata in rdatas)
@@ -516,10 +431,10 @@ namespace OpenSim.Services.GridService
516 else 431 else
517 { 432 {
518 m_log.WarnFormat( 433 m_log.WarnFormat(
519 "[GRID SERVICE]: GetNeighbours() called for scope {0}, region {1} but no such region found", 434 "[GRID SERVICE]: GetNeighbours() called for scope {0}, region {1} but no such region found",
520 scopeID, regionID); 435 scopeID, regionID);
521 } 436 }
522 437
523 return rinfos; 438 return rinfos;
524 } 439 }
525 440
@@ -537,6 +452,7 @@ namespace OpenSim.Services.GridService
537 // be the base coordinate of the region. 452 // be the base coordinate of the region.
538 // The snapping is technically unnecessary but is harmless because regions are always 453 // The snapping is technically unnecessary but is harmless because regions are always
539 // multiples of the legacy region size (256). 454 // multiples of the legacy region size (256).
455
540 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) 456 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
541 { 457 {
542 uint regionX = Util.WorldToRegionLoc((uint)x); 458 uint regionX = Util.WorldToRegionLoc((uint)x);
@@ -553,8 +469,8 @@ namespace OpenSim.Services.GridService
553 } 469 }
554 else 470 else
555 { 471 {
556 m_log.DebugFormat("{0} GetRegionByPosition. Did not find region in database. Pos=<{1},{2}>", 472// m_log.DebugFormat("{0} GetRegionByPosition. Did not find region in database. Pos=<{1},{2}>",
557 LogHeader, regionX, regionY); 473// LogHeader, regionX, regionY);
558 return null; 474 return null;
559 } 475 }
560 } 476 }
@@ -584,7 +500,78 @@ namespace OpenSim.Services.GridService
584 int count = 0; 500 int count = 0;
585 List<GridRegion> rinfos = new List<GridRegion>(); 501 List<GridRegion> rinfos = new List<GridRegion>();
586 502
587 if (rdatas != null) 503 if (count < maxNumber && m_AllowHypergridMapSearch && name.Contains("."))
504 {
505 string regionURI = "";
506 string regionName = "";
507 if(!Util.buildHGRegionURI(name, out regionURI, out regionName))
508 return null;
509
510 string mapname;
511 bool localGrid = m_HypergridLinker.IsLocalGrid(regionURI);
512 if(localGrid)
513 mapname = regionName;
514 else
515 mapname = regionURI + regionName;
516
517 bool haveMatch = false;
518
519 if (rdatas != null && (rdatas.Count > 0))
520 {
521// m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count);
522 foreach (RegionData rdata in rdatas)
523 {
524 if (count++ < maxNumber)
525 rinfos.Add(RegionData2RegionInfo(rdata));
526 if(rdata.RegionName == mapname)
527 {
528 haveMatch = true;
529 if(count == maxNumber)
530 {
531 rinfos.RemoveAt(count - 1);
532 rinfos.Add(RegionData2RegionInfo(rdata));
533 }
534 }
535 }
536 if(haveMatch)
537 return rinfos;
538 }
539
540 rdatas = m_Database.Get(Util.EscapeForLike(mapname)+ "%", scopeID);
541 if (rdatas != null && (rdatas.Count > 0))
542 {
543// m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count);
544 foreach (RegionData rdata in rdatas)
545 {
546 if (count++ < maxNumber)
547 rinfos.Add(RegionData2RegionInfo(rdata));
548 if(rdata.RegionName == mapname)
549 {
550 haveMatch = true;
551 if(count == maxNumber)
552 {
553 rinfos.RemoveAt(count - 1);
554 rinfos.Add(RegionData2RegionInfo(rdata));
555 break;
556 }
557 }
558 }
559 if(haveMatch)
560 return rinfos;
561 }
562 if(!localGrid && !string.IsNullOrWhiteSpace(regionURI))
563 {
564 string HGname = regionURI +" "+ regionName; // include space for compatibility
565 GridRegion r = m_HypergridLinker.LinkRegion(scopeID, HGname);
566 if (r != null)
567 {
568 if( count == maxNumber)
569 rinfos.RemoveAt(count - 1);
570 rinfos.Add(r);
571 }
572 }
573 }
574 else if (rdatas != null && (rdatas.Count > 0))
588 { 575 {
589// m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count); 576// m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count);
590 foreach (RegionData rdata in rdatas) 577 foreach (RegionData rdata in rdatas)
@@ -594,13 +581,6 @@ namespace OpenSim.Services.GridService
594 } 581 }
595 } 582 }
596 583
597 if (m_AllowHypergridMapSearch && (rdatas == null || (rdatas != null && rdatas.Count == 0)))
598 {
599 GridRegion r = GetHypergridRegionByName(scopeID, name);
600 if (r != null)
601 rinfos.Add(r);
602 }
603
604 return rinfos; 584 return rinfos;
605 } 585 }
606 586
@@ -613,9 +593,30 @@ namespace OpenSim.Services.GridService
613 protected GridRegion GetHypergridRegionByName(UUID scopeID, string name) 593 protected GridRegion GetHypergridRegionByName(UUID scopeID, string name)
614 { 594 {
615 if (name.Contains(".")) 595 if (name.Contains("."))
616 return m_HypergridLinker.LinkRegion(scopeID, name); 596 {
617 else 597 string regionURI = "";
618 return null; 598 string regionName = "";
599 if(!Util.buildHGRegionURI(name, out regionURI, out regionName))
600 return null;
601
602 string mapname;
603 bool localGrid = m_HypergridLinker.IsLocalGrid(regionURI);
604 if(localGrid)
605 mapname = regionName;
606 else
607 mapname = regionURI + regionName;
608
609 List<RegionData> rdatas = m_Database.Get(Util.EscapeForLike(mapname), scopeID);
610 if ((rdatas != null) && (rdatas.Count > 0))
611 return RegionData2RegionInfo(rdatas[0]); // get the first
612
613 if(!localGrid && !string.IsNullOrWhiteSpace(regionURI))
614 {
615 string HGname = regionURI +" "+ regionName;
616 return m_HypergridLinker.LinkRegion(scopeID, HGname);
617 }
618 }
619 return null;
619 } 620 }
620 621
621 public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) 622 public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
@@ -666,7 +667,7 @@ namespace OpenSim.Services.GridService
666 return rinfo; 667 return rinfo;
667 } 668 }
668 669
669 #endregion 670 #endregion
670 671
671 public List<GridRegion> GetDefaultRegions(UUID scopeID) 672 public List<GridRegion> GetDefaultRegions(UUID scopeID)
672 { 673 {
@@ -705,7 +706,7 @@ namespace OpenSim.Services.GridService
705 int normalDefaultRegionsFoundOnline = ret.Count - hgDefaultRegionsFoundOnline; 706 int normalDefaultRegionsFoundOnline = ret.Count - hgDefaultRegionsFoundOnline;
706 707
707 m_log.DebugFormat( 708 m_log.DebugFormat(
708 "[GRID SERVICE]: GetDefaultHypergridRegions returning {0} hypergrid default and {1} normal default regions", 709 "[GRID SERVICE]: GetDefaultHypergridRegions returning {0} hypergrid default and {1} normal default regions",
709 hgDefaultRegionsFoundOnline, normalDefaultRegionsFoundOnline); 710 hgDefaultRegionsFoundOnline, normalDefaultRegionsFoundOnline);
710 711
711 return ret; 712 return ret;
@@ -742,7 +743,7 @@ namespace OpenSim.Services.GridService
742 m_log.DebugFormat("[GRID SERVICE]: Hyperlinks returned {0} regions", ret.Count); 743 m_log.DebugFormat("[GRID SERVICE]: Hyperlinks returned {0} regions", ret.Count);
743 return ret; 744 return ret;
744 } 745 }
745 746
746 public int GetRegionFlags(UUID scopeID, UUID regionID) 747 public int GetRegionFlags(UUID scopeID, UUID regionID)
747 { 748 {
748 RegionData region = m_Database.Get(regionID, scopeID); 749 RegionData region = m_Database.Get(regionID, scopeID);
@@ -804,14 +805,14 @@ namespace OpenSim.Services.GridService
804 return; 805 return;
805 } 806 }
806 807
807 List<RegionData> regions = m_Database.Get(int.MinValue, int.MinValue, int.MaxValue, int.MaxValue, UUID.Zero); 808 List<RegionData> regions = m_Database.Get(0, 0, int.MaxValue, int.MaxValue, UUID.Zero);
808 809
809 OutputRegionsToConsoleSummary(regions); 810 OutputRegionsToConsoleSummary(regions);
810 } 811 }
811 812
812 private void HandleShowGridSize(string module, string[] cmd) 813 private void HandleShowGridSize(string module, string[] cmd)
813 { 814 {
814 List<RegionData> regions = m_Database.Get(int.MinValue, int.MinValue, int.MaxValue, int.MaxValue, UUID.Zero); 815 List<RegionData> regions = m_Database.Get(0, 0, int.MaxValue, int.MaxValue, UUID.Zero);
815 816
816 double size = 0; 817 double size = 0;
817 818
@@ -872,7 +873,9 @@ namespace OpenSim.Services.GridService
872 return; 873 return;
873 } 874 }
874 875
876
875 RegionData region = m_Database.Get((int)Util.RegionToWorldLoc(x), (int)Util.RegionToWorldLoc(y), UUID.Zero); 877 RegionData region = m_Database.Get((int)Util.RegionToWorldLoc(x), (int)Util.RegionToWorldLoc(y), UUID.Zero);
878
876 if (region == null) 879 if (region == null)
877 { 880 {
878 MainConsole.Instance.OutputFormat("No region found at {0},{1}", x, y); 881 MainConsole.Instance.OutputFormat("No region found at {0},{1}", x, y);
@@ -889,7 +892,7 @@ namespace OpenSim.Services.GridService
889 ConsoleDisplayList dispList = new ConsoleDisplayList(); 892 ConsoleDisplayList dispList = new ConsoleDisplayList();
890 dispList.AddRow("Region Name", r.RegionName); 893 dispList.AddRow("Region Name", r.RegionName);
891 dispList.AddRow("Region ID", r.RegionID); 894 dispList.AddRow("Region ID", r.RegionID);
892 dispList.AddRow("Position", string.Format("{0},{1}", r.coordX, r.coordY)); 895 dispList.AddRow("Location", string.Format("{0},{1}", r.coordX, r.coordY));
893 dispList.AddRow("Size", string.Format("{0}x{1}", r.sizeX, r.sizeY)); 896 dispList.AddRow("Size", string.Format("{0}x{1}", r.sizeX, r.sizeY));
894 dispList.AddRow("URI", r.Data["serverURI"]); 897 dispList.AddRow("URI", r.Data["serverURI"]);
895 dispList.AddRow("Owner ID", r.Data["owner_uuid"]); 898 dispList.AddRow("Owner ID", r.Data["owner_uuid"]);
@@ -907,9 +910,9 @@ namespace OpenSim.Services.GridService
907 private void OutputRegionsToConsoleSummary(List<RegionData> regions) 910 private void OutputRegionsToConsoleSummary(List<RegionData> regions)
908 { 911 {
909 ConsoleDisplayTable dispTable = new ConsoleDisplayTable(); 912 ConsoleDisplayTable dispTable = new ConsoleDisplayTable();
910 dispTable.AddColumn("Name", 44); 913 dispTable.AddColumn("Name", ConsoleDisplayUtil.RegionNameSize);
911 dispTable.AddColumn("ID", 36); 914 dispTable.AddColumn("ID", ConsoleDisplayUtil.UuidSize);
912 dispTable.AddColumn("Position", 11); 915 dispTable.AddColumn("Position", ConsoleDisplayUtil.CoordTupleSize);
913 dispTable.AddColumn("Size", 11); 916 dispTable.AddColumn("Size", 11);
914 dispTable.AddColumn("Flags", 60); 917 dispTable.AddColumn("Flags", 60);
915 918
@@ -992,7 +995,7 @@ namespace OpenSim.Services.GridService
992 } 995 }
993 996
994 /// <summary> 997 /// <summary>
995 /// Gets the grid extra service URls we wish for the region to send in OpenSimExtras to dynamically refresh 998 /// Gets the grid extra service URls we wish for the region to send in OpenSimExtras to dynamically refresh
996 /// parameters in the viewer used to access services like map, search and destination guides. 999 /// parameters in the viewer used to access services like map, search and destination guides.
997 /// <para>see "SimulatorFeaturesModule" </para> 1000 /// <para>see "SimulatorFeaturesModule" </para>
998 /// </summary> 1001 /// </summary>
diff --git a/OpenSim/Services/GridService/GridServiceBase.cs b/OpenSim/Services/GridService/GridServiceBase.cs
index 444f79b..7522e64 100644
--- a/OpenSim/Services/GridService/GridServiceBase.cs
+++ b/OpenSim/Services/GridService/GridServiceBase.cs
@@ -68,7 +68,7 @@ namespace OpenSim.Services.GridService
68 connString = gridConfig.GetString("ConnectionString", connString); 68 connString = gridConfig.GetString("ConnectionString", connString);
69 realm = gridConfig.GetString("Realm", realm); 69 realm = gridConfig.GetString("Realm", realm);
70 } 70 }
71 71
72 // 72 //
73 // We tried, but this doesn't exist. We can't proceed. 73 // We tried, but this doesn't exist. We can't proceed.
74 // 74 //
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs
index aebbf7c..7c384d5 100644
--- a/OpenSim/Services/GridService/HypergridLinker.cs
+++ b/OpenSim/Services/GridService/HypergridLinker.cs
@@ -119,13 +119,13 @@ namespace OpenSim.Services.GridService
119 if (scope != string.Empty) 119 if (scope != string.Empty)
120 UUID.TryParse(scope, out m_ScopeID); 120 UUID.TryParse(scope, out m_ScopeID);
121 121
122// TODO OpenSim is crazy, this is called from Robust and OpenSim, Robust needs the ../caches bit, OpenSim somehow adds a path already. I can't tell why. So strip the path. 122//// TODO OpenSim is crazy, this is called from Robust and OpenSim, Robust needs the ../caches bit, OpenSim somehow adds a path already. I can't tell why. So strip the path.
123 m_MapTileDirectory = "../caches/" + Path.GetFileName(gridConfig.GetString("MapTileDirectory", "maptiles")); 123 m_MapTileDirectory = Path.Combine(Util.cacheDir(), Path.GetFileName(gridConfig.GetString("MapTileDirectory", "maptiles")));
124 124
125 m_ThisGatekeeper = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI", 125 m_ThisGatekeeper = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI",
126 new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty); 126 new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty);
127 // Legacy. Remove soon! 127 // Legacy. Remove soon!
128 m_ThisGatekeeper = gridConfig.GetString("Gatekeeper", m_ThisGatekeeper); 128//// m_ThisGatekeeper = gridConfig.GetString("Gatekeeper", m_ThisGatekeeper);
129 try 129 try
130 { 130 {
131 m_ThisGatekeeperURI = new Uri(m_ThisGatekeeper); 131 m_ThisGatekeeperURI = new Uri(m_ThisGatekeeper);
@@ -135,6 +135,12 @@ namespace OpenSim.Services.GridService
135 m_log.WarnFormat("[HYPERGRID LINKER]: Malformed URL in [GridService], variable Gatekeeper = {0}", m_ThisGatekeeper); 135 m_log.WarnFormat("[HYPERGRID LINKER]: Malformed URL in [GridService], variable Gatekeeper = {0}", m_ThisGatekeeper);
136 } 136 }
137 137
138 m_ThisGatekeeper = m_ThisGatekeeperURI.AbsoluteUri;
139 if(m_ThisGatekeeperURI.Port == 80)
140 m_ThisGatekeeper = m_ThisGatekeeper.Trim(new char[] { '/', ' ' }) +":80/";
141 else if(m_ThisGatekeeperURI.Port == 443)
142 m_ThisGatekeeper = m_ThisGatekeeper.Trim(new char[] { '/', ' ' }) +":443/";
143
138 m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService); 144 m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService);
139 145
140 m_log.Debug("[HYPERGRID LINKER]: Loaded all services..."); 146 m_log.Debug("[HYPERGRID LINKER]: Loaded all services...");
@@ -186,85 +192,29 @@ namespace OpenSim.Services.GridService
186 return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason); 192 return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason);
187 } 193 }
188 194
195 public bool IsLocalGrid(string serverURI)
196 {
197 return serverURI == m_ThisGatekeeper;
198 }
199
189 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason) 200 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason)
190 { 201 {
191 reason = string.Empty; 202 reason = string.Empty;
192 GridRegion regInfo = null; 203 GridRegion regInfo = null;
193 204
194 mapName = mapName.Trim(); 205 string serverURI = string.Empty;
206 string regionName = string.Empty;
195 207
196 if (!mapName.StartsWith("http")) 208 if(!Util.buildHGRegionURI(mapName, out serverURI, out regionName))
197 { 209 {
198 // Formats: grid.example.com:8002:region name 210 reason = "Wrong URI format for link-region";
199 // grid.example.com:region name 211 return null;
200 // grid.example.com:8002
201 // grid.example.com
202
203 string host;
204 uint port = 80;
205 string regionName = "";
206
207 string[] parts = mapName.Split(new char[] { ':' });
208
209 if (parts.Length == 0)
210 {
211 reason = "Wrong format for link-region";
212 return null;
213 }
214
215 host = parts[0];
216
217 if (parts.Length >= 2)
218 {
219 // If it's a number then assume it's a port. Otherwise, it's a region name.
220 if (!UInt32.TryParse(parts[1], out port))
221 regionName = parts[1];
222 }
223
224 // always take the last one
225 if (parts.Length >= 3)
226 {
227 regionName = parts[2];
228 }
229
230
231 bool success = TryCreateLink(scopeID, xloc, yloc, regionName, port, host, ownerID, out regInfo, out reason);
232 if (success)
233 {
234 regInfo.RegionName = mapName;
235 return regInfo;
236 }
237 } 212 }
238 else
239 {
240 // Formats: http://grid.example.com region name
241 // http://grid.example.com "region name"
242 // http://grid.example.com
243
244 string serverURI;
245 string regionName = "";
246
247 string[] parts = mapName.Split(new char[] { ' ' });
248
249 if (parts.Length == 0)
250 {
251 reason = "Wrong format for link-region";
252 return null;
253 }
254 213
255 serverURI = parts[0]; 214 if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, serverURI, ownerID, out regInfo, out reason))
256 215 {
257 if (parts.Length >= 2) 216 regInfo.RegionName = serverURI + regionName;
258 { 217 return regInfo;
259 regionName = mapName.Substring(serverURI.Length);
260 regionName = regionName.Trim(new char[] { '"', ' ' });
261 }
262
263 if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, serverURI, ownerID, out regInfo, out reason))
264 {
265 regInfo.RegionName = mapName;
266 return regInfo;
267 }
268 } 218 }
269 219
270 return null; 220 return null;
@@ -285,7 +235,7 @@ namespace OpenSim.Services.GridService
285 235
286 private bool TryCreateLinkImpl(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason) 236 private bool TryCreateLinkImpl(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason)
287 { 237 {
288 m_log.InfoFormat("[HYPERGRID LINKER]: Link to {0} {1}, in <{2},{3}>", 238 m_log.InfoFormat("[HYPERGRID LINKER]: Link to {0} {1}, in <{2},{3}>",
289 ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI), 239 ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI),
290 remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc)); 240 remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc));
291 241
@@ -361,7 +311,9 @@ namespace OpenSim.Services.GridService
361 UUID regionID = UUID.Zero; 311 UUID regionID = UUID.Zero;
362 string externalName = string.Empty; 312 string externalName = string.Empty;
363 string imageURL = string.Empty; 313 string imageURL = string.Empty;
364 if (!m_GatekeeperConnector.LinkRegion(regInfo, out regionID, out handle, out externalName, out imageURL, out reason)) 314 int sizeX = (int)Constants.RegionSize;
315 int sizeY = (int)Constants.RegionSize;
316 if (!m_GatekeeperConnector.LinkRegion(regInfo, out regionID, out handle, out externalName, out imageURL, out reason, out sizeX, out sizeY))
365 return false; 317 return false;
366 318
367 if (regionID == UUID.Zero) 319 if (regionID == UUID.Zero)
@@ -374,13 +326,14 @@ namespace OpenSim.Services.GridService
374 region = m_GridService.GetRegionByUUID(scopeID, regionID); 326 region = m_GridService.GetRegionByUUID(scopeID, regionID);
375 if (region != null) 327 if (region != null)
376 { 328 {
377 m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates <{0},{1}>", 329 m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates <{0},{1}>", Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
378 Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
379 regInfo = region; 330 regInfo = region;
380 return true; 331 return true;
381 } 332 }
382 333
383 regInfo.RegionID = regionID; 334 regInfo.RegionID = regionID;
335 regInfo.RegionSizeX = sizeX;
336 regInfo.RegionSizeY = sizeY;
384 337
385 if (externalName == string.Empty) 338 if (externalName == string.Empty)
386 regInfo.RegionName = regInfo.ServerURI; 339 regInfo.RegionName = regInfo.ServerURI;
@@ -412,7 +365,7 @@ namespace OpenSim.Services.GridService
412 OpenSim.Framework.RegionFlags rflags = (OpenSim.Framework.RegionFlags)Convert.ToInt32(regions[0].Data["flags"]); 365 OpenSim.Framework.RegionFlags rflags = (OpenSim.Framework.RegionFlags)Convert.ToInt32(regions[0].Data["flags"]);
413 if ((rflags & OpenSim.Framework.RegionFlags.Hyperlink) != 0) 366 if ((rflags & OpenSim.Framework.RegionFlags.Hyperlink) != 0)
414 { 367 {
415 regInfo = new GridRegion(); 368 regInfo = new GridRegion();
416 regInfo.RegionID = regions[0].RegionID; 369 regInfo.RegionID = regions[0].RegionID;
417 regInfo.ScopeID = m_ScopeID; 370 regInfo.ScopeID = m_ScopeID;
418 } 371 }
@@ -474,7 +427,7 @@ namespace OpenSim.Services.GridService
474 { 427 {
475 MainConsole.Instance.Output( 428 MainConsole.Instance.Output(
476 String.Format("{0}\n{2,-32} {1}\n", 429 String.Format("{0}\n{2,-32} {1}\n",
477 r.RegionName, r.RegionID, 430 r.RegionName, r.RegionID,
478 String.Format("{0},{1} ({2},{3})", r.posX, r.posY, 431 String.Format("{0},{1} ({2},{3})", r.posX, r.posY,
479 Util.WorldToRegionLoc((uint)r.posX), Util.WorldToRegionLoc((uint)r.posY) 432 Util.WorldToRegionLoc((uint)r.posX), Util.WorldToRegionLoc((uint)r.posY)
480 ) 433 )
@@ -556,7 +509,7 @@ namespace OpenSim.Services.GridService
556 if (cmdparams[2].StartsWith("http")) 509 if (cmdparams[2].StartsWith("http"))
557 { 510 {
558 RunLinkRegionCommand(cmdparams); 511 RunLinkRegionCommand(cmdparams);
559 } 512 }
560 else if (cmdparams[2].Contains(":")) 513 else if (cmdparams[2].Contains(":"))
561 { 514 {
562 // New format 515 // New format
diff --git a/OpenSim/Services/GridService/Properties/AssemblyInfo.cs b/OpenSim/Services/GridService/Properties/AssemblyInfo.cs
index 0841e5a..69a3c44 100644
--- a/OpenSim/Services/GridService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/GridService/Properties/AssemblyInfo.cs
@@ -2,7 +2,7 @@
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4 4
5// General Information about an assembly is controlled through the following 5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly. 7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Services.GridService")] 8[assembly: AssemblyTitle("OpenSim.Services.GridService")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
14[assembly: AssemblyTrademark("")] 14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")] 15[assembly: AssemblyCulture("")]
16 16
17// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)] 20[assembly: ComVisible(false)]
21 21
@@ -25,9 +25,9 @@ using System.Runtime.InteropServices;
25// Version information for an assembly consists of the following four values: 25// Version information for an assembly consists of the following four values:
26// 26//
27// Major Version 27// Major Version
28// Minor Version 28// Minor Version
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.8.3.*")] 32[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
33 33
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs
index 8e10125..24979be 100644
--- a/OpenSim/Services/HypergridService/GatekeeperService.cs
+++ b/OpenSim/Services/HypergridService/GatekeeperService.cs
@@ -35,8 +35,8 @@ using OpenSim.Framework;
35using OpenSim.Services.Interfaces; 35using OpenSim.Services.Interfaces;
36using GridRegion = OpenSim.Services.Interfaces.GridRegion; 36using GridRegion = OpenSim.Services.Interfaces.GridRegion;
37using OpenSim.Server.Base; 37using OpenSim.Server.Base;
38using OpenSim.Services.Connectors.InstantMessage;
38using OpenSim.Services.Connectors.Hypergrid; 39using OpenSim.Services.Connectors.Hypergrid;
39
40using OpenMetaverse; 40using OpenMetaverse;
41 41
42using Nini.Config; 42using Nini.Config;
@@ -71,6 +71,7 @@ namespace OpenSim.Services.HypergridService
71 private static string m_ExternalName; 71 private static string m_ExternalName;
72 private static Uri m_Uri; 72 private static Uri m_Uri;
73 private static GridRegion m_DefaultGatewayRegion; 73 private static GridRegion m_DefaultGatewayRegion;
74 private bool m_allowDuplicatePresences = false;
74 75
75 public GatekeeperService(IConfigSource config, ISimulationService simService) 76 public GatekeeperService(IConfigSource config, ISimulationService simService)
76 { 77 {
@@ -93,7 +94,7 @@ namespace OpenSim.Services.HypergridService
93 // These are mandatory, the others aren't 94 // These are mandatory, the others aren't
94 if (gridService == string.Empty || presenceService == string.Empty) 95 if (gridService == string.Empty || presenceService == string.Empty)
95 throw new Exception("Incomplete specifications, Gatekeeper Service cannot function."); 96 throw new Exception("Incomplete specifications, Gatekeeper Service cannot function.");
96 97
97 string scope = serverConfig.GetString("ScopeID", UUID.Zero.ToString()); 98 string scope = serverConfig.GetString("ScopeID", UUID.Zero.ToString());
98 UUID.TryParse(scope, out m_ScopeID); 99 UUID.TryParse(scope, out m_ScopeID);
99 //m_WelcomeMessage = serverConfig.GetString("WelcomeMessage", "Welcome to OpenSim!"); 100 //m_WelcomeMessage = serverConfig.GetString("WelcomeMessage", "Welcome to OpenSim!");
@@ -135,7 +136,7 @@ namespace OpenSim.Services.HypergridService
135 m_AllowedClients = Util.GetConfigVarFromSections<string>( 136 m_AllowedClients = Util.GetConfigVarFromSections<string>(
136 config, "AllowedClients", possibleAccessControlConfigSections, string.Empty); 137 config, "AllowedClients", possibleAccessControlConfigSections, string.Empty);
137 m_DeniedClients = Util.GetConfigVarFromSections<string>( 138 m_DeniedClients = Util.GetConfigVarFromSections<string>(
138 config, "DeniedClients", possibleAccessControlConfigSections, string.Empty); 139 config, "DeniedClients", possibleAccessControlConfigSections, string.Empty);
139 m_ForeignAgentsAllowed = serverConfig.GetBoolean("ForeignAgentsAllowed", true); 140 m_ForeignAgentsAllowed = serverConfig.GetBoolean("ForeignAgentsAllowed", true);
140 141
141 LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_ForeignsAllowedExceptions); 142 LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_ForeignsAllowedExceptions);
@@ -144,6 +145,12 @@ namespace OpenSim.Services.HypergridService
144 if (m_GridService == null || m_PresenceService == null || m_SimulationService == null) 145 if (m_GridService == null || m_PresenceService == null || m_SimulationService == null)
145 throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function."); 146 throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function.");
146 147
148 IConfig presenceConfig = config.Configs["PresenceService"];
149 if (presenceConfig != null)
150 {
151 m_allowDuplicatePresences = presenceConfig.GetBoolean("AllowDuplicatePresences", m_allowDuplicatePresences);
152 }
153
147 m_log.Debug("[GATEKEEPER SERVICE]: Starting..."); 154 m_log.Debug("[GATEKEEPER SERVICE]: Starting...");
148 } 155 }
149 } 156 }
@@ -162,10 +169,12 @@ namespace OpenSim.Services.HypergridService
162 exceptions.Add(s.Trim()); 169 exceptions.Add(s.Trim());
163 } 170 }
164 171
165 public bool LinkRegion(string regionName, out UUID regionID, out ulong regionHandle, out string externalName, out string imageURL, out string reason) 172 public bool LinkRegion(string regionName, out UUID regionID, out ulong regionHandle, out string externalName, out string imageURL, out string reason, out int sizeX, out int sizeY)
166 { 173 {
167 regionID = UUID.Zero; 174 regionID = UUID.Zero;
168 regionHandle = 0; 175 regionHandle = 0;
176 sizeX = (int)Constants.RegionSize;
177 sizeY = (int)Constants.RegionSize;
169 externalName = m_ExternalName + ((regionName != string.Empty) ? " " + regionName : ""); 178 externalName = m_ExternalName + ((regionName != string.Empty) ? " " + regionName : "");
170 imageURL = string.Empty; 179 imageURL = string.Empty;
171 reason = string.Empty; 180 reason = string.Empty;
@@ -199,6 +208,8 @@ namespace OpenSim.Services.HypergridService
199 208
200 regionID = region.RegionID; 209 regionID = region.RegionID;
201 regionHandle = region.RegionHandle; 210 regionHandle = region.RegionHandle;
211 sizeX = region.RegionSizeX;
212 sizeY = region.RegionSizeY;
202 213
203 string regionimage = "regionImage" + regionID.ToString(); 214 string regionimage = "regionImage" + regionID.ToString();
204 regionimage = regionimage.Replace("-", ""); 215 regionimage = regionimage.Replace("-", "");
@@ -215,11 +226,11 @@ namespace OpenSim.Services.HypergridService
215 { 226 {
216 // Don't even check the given regionID 227 // Don't even check the given regionID
217 m_log.DebugFormat( 228 m_log.DebugFormat(
218 "[GATEKEEPER SERVICE]: Returning gateway region {0} {1} @ {2} to user {3}{4} as teleporting to arbitrary regions is not allowed.", 229 "[GATEKEEPER SERVICE]: Returning gateway region {0} {1} @ {2} to user {3}{4} as teleporting to arbitrary regions is not allowed.",
219 m_DefaultGatewayRegion.RegionName, 230 m_DefaultGatewayRegion.RegionName,
220 m_DefaultGatewayRegion.RegionID, 231 m_DefaultGatewayRegion.RegionID,
221 m_DefaultGatewayRegion.ServerURI, 232 m_DefaultGatewayRegion.ServerURI,
222 agentID, 233 agentID,
223 agentHomeURI == null ? "" : " @ " + agentHomeURI); 234 agentHomeURI == null ? "" : " @ " + agentHomeURI);
224 235
225 message = "Teleporting to the default region."; 236 message = "Teleporting to the default region.";
@@ -240,10 +251,10 @@ namespace OpenSim.Services.HypergridService
240 251
241 m_log.DebugFormat( 252 m_log.DebugFormat(
242 "[GATEKEEPER SERVICE]: Returning region {0} {1} @ {2} to user {3}{4}.", 253 "[GATEKEEPER SERVICE]: Returning region {0} {1} @ {2} to user {3}{4}.",
243 region.RegionName, 254 region.RegionName,
244 region.RegionID, 255 region.RegionID,
245 region.ServerURI, 256 region.ServerURI,
246 agentID, 257 agentID,
247 agentHomeURI == null ? "" : " @ " + agentHomeURI); 258 agentHomeURI == null ? "" : " @ " + agentHomeURI);
248 259
249 return region; 260 return region;
@@ -275,6 +286,7 @@ namespace OpenSim.Services.HypergridService
275 286
276 if (!am.Success) 287 if (!am.Success)
277 { 288 {
289 reason = "Login failed: client " + curViewer + " is not allowed";
278 m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is not allowed", curViewer); 290 m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is not allowed", curViewer);
279 return false; 291 return false;
280 } 292 }
@@ -287,6 +299,7 @@ namespace OpenSim.Services.HypergridService
287 299
288 if (dm.Success) 300 if (dm.Success)
289 { 301 {
302 reason = "Login failed: client " + curViewer + " is denied";
290 m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is denied", curViewer); 303 m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is denied", curViewer);
291 return false; 304 return false;
292 } 305 }
@@ -302,7 +315,7 @@ namespace OpenSim.Services.HypergridService
302 return false; 315 return false;
303 } 316 }
304 m_log.DebugFormat("[GATEKEEPER SERVICE]: Identity verified for {0} {1} @ {2}", aCircuit.firstname, aCircuit.lastname, authURL); 317 m_log.DebugFormat("[GATEKEEPER SERVICE]: Identity verified for {0} {1} @ {2}", aCircuit.firstname, aCircuit.lastname, authURL);
305 318
306 // 319 //
307 // Check for impersonations 320 // Check for impersonations
308 // 321 //
@@ -363,6 +376,64 @@ namespace OpenSim.Services.HypergridService
363 return false; 376 return false;
364 } 377 }
365 378
379 UUID agentID = aCircuit.AgentID;
380 if(agentID == new UUID("6571e388-6218-4574-87db-f9379718315e"))
381 {
382 // really?
383 reason = "Invalid account ID";
384 return false;
385 }
386
387 if(m_GridUserService != null)
388 {
389 string PrincipalIDstr = agentID.ToString();
390 GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(PrincipalIDstr);
391
392 if(!m_allowDuplicatePresences)
393 {
394//// TODO - Should also check Presence.UserID if RegionID == UUID.Zero, they are a ghost. Maybe.
395//// NOTE - this is a person hypergridding in, or returning home, or just logging in and it's duplicating effort in OpenSim/Services/LLLoginService/LLLoginService.cs.
396 if(guinfo != null && guinfo.Online && guinfo.LastRegionID != UUID.Zero)
397 {
398 // Also check Presence.UserID if RegionID == UUID.Zero, they are a ghost.
399 // Ghosting might be caused by failure to call PresenceService.LogoutAgent() on logout / crash / failed login.
400 // Might also need to double check if they are out hypergridding.
401
402 bool success = false;
403 if (m_PresenceService != null)
404 {
405 PresenceInfo pi = m_PresenceService.GetAgentByUser(account.PrincipalID);
406 if (null != pi)
407 {
408 Dictionary<string, object> pid = pi.ToKeyValuePairs();
409 if ((pid["RegionID"].ToString() == UUID.Zero.ToString()) && (0 != String.Compare(pid["SessionID"].ToString(), aCircuit.SessionID.ToString())))
410 {
411 m_log.WarnFormat("[GATEKEEPER SERVICE]: Exorcising ghost avatar {0}, session {1}, new session {2}.", pid["UserID"], pid["SessionID"], aCircuit.SessionID);
412m_log.WarnFormat("[GATEKEEPER SERVICE]: NOT REALLY.");
413//// Don't do this until after more checking.
414//// success = m_PresenceService.LogoutAgent(new UUID(pid["SessionID"].ToString()));
415//// if (success)
416//// m_log.WarnFormat("[GATEKEEPER SERVICE]: Ghost avatar exorcised {0}, session {1}, new session {2}.", pid["UserID"], pid["SessionID"], aCircuit.SessionID);
417//// else
418//// m_log.ErrorFormat("[GATEKEEPER SERVICE]: Ghost avatar not exorcised {0}, session {1}, new session {2}!", pid["UserID"], pid["SessionID"], aCircuit.SessionID);
419 }
420 }
421 }
422 if ((!success) && SendAgentGodKillToRegion(UUID.Zero, agentID, guinfo))
423 {
424 if(account != null)
425 m_log.InfoFormat(
426 "[GATEKEEPER SERVICE]: Login failed for {0} {1}, reason: already logged in. This may be bogus if a ghost avatar was exorcised above.",
427 account.FirstName, account.LastName);
428 reason = "You appear to be already logged in on the destination grid " +
429 "Please wait a a minute or two and retry. " +
430 "If this takes longer than a few minutes please contact the grid owner.";
431 return false;
432 }
433 }
434 }
435 }
436
366 m_log.DebugFormat("[GATEKEEPER SERVICE]: User {0} is ok", aCircuit.Name); 437 m_log.DebugFormat("[GATEKEEPER SERVICE]: User {0} is ok", aCircuit.Name);
367 438
368 bool isFirstLogin = false; 439 bool isFirstLogin = false;
@@ -383,26 +454,6 @@ namespace OpenSim.Services.HypergridService
383 return false; 454 return false;
384 } 455 }
385 456
386 m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence {0} is ok", aCircuit.Name);
387
388 // Also login foreigners with GridUser service
389 if (m_GridUserService != null && account == null)
390 {
391 string userId = aCircuit.AgentID.ToString();
392 string first = aCircuit.firstname, last = aCircuit.lastname;
393 if (last.StartsWith("@"))
394 {
395 string[] parts = aCircuit.firstname.Split('.');
396 if (parts.Length >= 2)
397 {
398 first = parts[0];
399 last = parts[1];
400 }
401 }
402
403 userId += ";" + aCircuit.ServiceURLs["HomeURI"] + ";" + first + " " + last;
404 m_GridUserService.LoggedIn(userId);
405 }
406 } 457 }
407 458
408 // 459 //
@@ -455,11 +506,37 @@ namespace OpenSim.Services.HypergridService
455 EntityTransferContext ctx = new EntityTransferContext(); 506 EntityTransferContext ctx = new EntityTransferContext();
456 507
457 if (!m_SimulationService.QueryAccess( 508 if (!m_SimulationService.QueryAccess(
458 destination, aCircuit.AgentID, aCircuit.ServiceURLs["HomeURI"].ToString(), 509 destination, aCircuit.AgentID, aCircuit.ServiceURLs["HomeURI"].ToString(),
459 true, aCircuit.startpos, new List<UUID>(), ctx, out reason)) 510 true, aCircuit.startpos, new List<UUID>(), ctx, out reason))
460 return false; 511 return false;
461 512
462 return m_SimulationService.CreateAgent(source, destination, aCircuit, (uint)loginFlag, out reason); 513 bool didit = m_SimulationService.CreateAgent(source, destination, aCircuit, (uint)loginFlag, ctx, out reason);
514
515 if(didit)
516 {
517 m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence {0} is ok", aCircuit.Name);
518
519 if(!isFirstLogin && m_GridUserService != null && account == null)
520 {
521 // Also login foreigners with GridUser service
522 string userId = aCircuit.AgentID.ToString();
523 string first = aCircuit.firstname, last = aCircuit.lastname;
524 if (last.StartsWith("@"))
525 {
526 string[] parts = aCircuit.firstname.Split('.');
527 if (parts.Length >= 2)
528 {
529 first = parts[0];
530 last = parts[1];
531 }
532 }
533
534 userId += ";" + aCircuit.ServiceURLs["HomeURI"] + ";" + first + " " + last;
535 m_GridUserService.LoggedIn(userId);
536 }
537 }
538
539 return didit;
463 } 540 }
464 541
465 protected bool Authenticate(AgentCircuitData aCircuit) 542 protected bool Authenticate(AgentCircuitData aCircuit)
@@ -489,7 +566,7 @@ namespace OpenSim.Services.HypergridService
489 } 566 }
490 else 567 else
491 { 568 {
492 IUserAgentService userAgentService = new UserAgentServiceConnector(userURL); 569 IUserAgentService userAgentService = new UserAgentServiceConnector(userURL);
493 570
494 try 571 try
495 { 572 {
@@ -557,6 +634,40 @@ namespace OpenSim.Services.HypergridService
557 return exception; 634 return exception;
558 } 635 }
559 636
637 private bool SendAgentGodKillToRegion(UUID scopeID, UUID agentID , GridUserInfo guinfo)
638 {
639 UUID regionID = guinfo.LastRegionID;
640 GridRegion regInfo = m_GridService.GetRegionByUUID(scopeID, regionID);
641 if(regInfo == null)
642 return false;
643
644 string regURL = regInfo.ServerURI;
645 if(String.IsNullOrEmpty(regURL))
646 return false;
647
648 UUID guuid = new UUID("6571e388-6218-4574-87db-f9379718315e");
649
650 GridInstantMessage msg = new GridInstantMessage();
651 msg.imSessionID = UUID.Zero.Guid;
652 msg.fromAgentID = guuid.Guid;
653 msg.toAgentID = agentID.Guid;
654 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
655 msg.fromAgentName = "GRID";
656 msg.message = string.Format("New login detected");
657 msg.dialog = 250; // God kick
658 msg.fromGroup = false;
659 msg.offline = (byte)0;
660 msg.ParentEstateID = 0;
661 msg.Position = Vector3.Zero;
662 msg.RegionID = scopeID.Guid;
663 msg.binaryBucket = new byte[1] {0};
664 InstantMessageServiceConnector.SendInstantMessage(regURL,msg);
665
666 m_GridUserService.LoggedOut(agentID.ToString(),
667 UUID.Zero, guinfo.LastRegionID, guinfo.LastPosition, guinfo.LastLookAt);
668
669 return true;
670 }
560 #endregion 671 #endregion
561 } 672 }
562} 673}
diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs
index b83fb1e..a66478e 100644
--- a/OpenSim/Services/HypergridService/HGAssetService.cs
+++ b/OpenSim/Services/HypergridService/HGAssetService.cs
@@ -164,7 +164,7 @@ namespace OpenSim.Services.HypergridService
164 return false; 164 return false;
165 } 165 }
166 166
167 #endregion 167 #endregion
168 168
169 protected void AdjustIdentifiers(AssetMetadata meta) 169 protected void AdjustIdentifiers(AssetMetadata meta)
170 { 170 {
diff --git a/OpenSim/Services/HypergridService/HGFSAssetService.cs b/OpenSim/Services/HypergridService/HGFSAssetService.cs
index 54e8ccb..2b30b3a 100644
--- a/OpenSim/Services/HypergridService/HGFSAssetService.cs
+++ b/OpenSim/Services/HypergridService/HGFSAssetService.cs
@@ -160,7 +160,7 @@ namespace OpenSim.Services.HypergridService
160 return false; 160 return false;
161 } 161 }
162 162
163 #endregion 163 #endregion
164 164
165 protected void AdjustIdentifiers(AssetMetadata meta) 165 protected void AdjustIdentifiers(AssetMetadata meta)
166 { 166 {
diff --git a/OpenSim/Services/HypergridService/HGFriendsService.cs b/OpenSim/Services/HypergridService/HGFriendsService.cs
index 6e35a88..d3b4f18 100644
--- a/OpenSim/Services/HypergridService/HGFriendsService.cs
+++ b/OpenSim/Services/HypergridService/HGFriendsService.cs
@@ -227,7 +227,7 @@ namespace OpenSim.Services.HypergridService
227 227
228 List<UUID> localFriendsOnline = new List<UUID>(); 228 List<UUID> localFriendsOnline = new List<UUID>();
229 229
230 m_log.DebugFormat("[HGFRIENDS SERVICE]: Status notification: foreign user {0} wants to notify {1} local friends of {2} status", 230 m_log.DebugFormat("[HGFRIENDS SERVICE]: Status notification: foreign user {0} wants to notify {1} local friends of {2} status",
231 foreignUserID, friends.Count, (online ? "online" : "offline")); 231 foreignUserID, friends.Count, (online ? "online" : "offline"));
232 232
233 // First, let's double check that the reported friends are, indeed, friends of that user 233 // First, let's double check that the reported friends are, indeed, friends of that user
diff --git a/OpenSim/Services/HypergridService/HGInstantMessageService.cs b/OpenSim/Services/HypergridService/HGInstantMessageService.cs
index 32ca09a..d1739cf 100644
--- a/OpenSim/Services/HypergridService/HGInstantMessageService.cs
+++ b/OpenSim/Services/HypergridService/HGInstantMessageService.cs
@@ -184,7 +184,7 @@ namespace OpenSim.Services.HypergridService
184 else if (o is string) 184 else if (o is string)
185 url = (string)o; 185 url = (string)o;
186 186
187 // We need to compare the current location with the previous 187 // We need to compare the current location with the previous
188 // or the recursive loop will never end because it will never try to lookup the agent again 188 // or the recursive loop will never end because it will never try to lookup the agent again
189 if (!firstTime) 189 if (!firstTime)
190 { 190 {
diff --git a/OpenSim/Services/HypergridService/HGInventoryService.cs b/OpenSim/Services/HypergridService/HGInventoryService.cs
index 9158b41..f14593e 100644
--- a/OpenSim/Services/HypergridService/HGInventoryService.cs
+++ b/OpenSim/Services/HypergridService/HGInventoryService.cs
@@ -70,7 +70,7 @@ namespace OpenSim.Services.HypergridService
70 // 70 //
71 IConfig invConfig = config.Configs[m_ConfigName]; 71 IConfig invConfig = config.Configs[m_ConfigName];
72 if (invConfig != null) 72 if (invConfig != null)
73 { 73 {
74 // realm = authConfig.GetString("Realm", realm); 74 // realm = authConfig.GetString("Realm", realm);
75 string userAccountsDll = invConfig.GetString("UserAccountsService", string.Empty); 75 string userAccountsDll = invConfig.GetString("UserAccountsService", string.Empty);
76 if (userAccountsDll == string.Empty) 76 if (userAccountsDll == string.Empty)
@@ -82,7 +82,7 @@ namespace OpenSim.Services.HypergridService
82 throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll)); 82 throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll));
83 83
84 m_HomeURL = Util.GetConfigVarFromSections<string>(config, "HomeURI", 84 m_HomeURL = Util.GetConfigVarFromSections<string>(config, "HomeURI",
85 new string[] { "Startup", "Hypergrid", m_ConfigName }, String.Empty); 85 new string[] { "Startup", "Hypergrid", m_ConfigName }, String.Empty);
86 86
87 m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); 87 m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
88 } 88 }
@@ -113,7 +113,7 @@ namespace OpenSim.Services.HypergridService
113 113
114 if (folders.Length > 0) 114 if (folders.Length > 0)
115 return ConvertToOpenSim(folders[0]); 115 return ConvertToOpenSim(folders[0]);
116 116
117 // make one 117 // make one
118 XInventoryFolder suitcase = CreateFolder(principalID, UUID.Zero, (int)FolderType.Suitcase, "My Suitcase"); 118 XInventoryFolder suitcase = CreateFolder(principalID, UUID.Zero, (int)FolderType.Suitcase, "My Suitcase");
119 return ConvertToOpenSim(suitcase); 119 return ConvertToOpenSim(suitcase);
@@ -160,7 +160,7 @@ namespace OpenSim.Services.HypergridService
160 { 160 {
161 return new InventoryCollection[0]; 161 return new InventoryCollection[0];
162 } 162 }
163 163
164 //public List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID) 164 //public List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID)
165 //{ 165 //{
166 //} 166 //}
@@ -291,9 +291,9 @@ namespace OpenSim.Services.HypergridService
291 //{ 291 //{
292 //} 292 //}
293 293
294 public override InventoryItemBase GetItem(InventoryItemBase item) 294 public override InventoryItemBase GetItem(UUID principalID, UUID itemID)
295 { 295 {
296 InventoryItemBase it = base.GetItem(item); 296 InventoryItemBase it = base.GetItem(principalID, itemID);
297 if (it != null) 297 if (it != null)
298 { 298 {
299 UserAccount user = m_Cache.GetUser(it.CreatorId); 299 UserAccount user = m_Cache.GetUser(it.CreatorId);
diff --git a/OpenSim/Services/HypergridService/HGRemoteAssetService.cs b/OpenSim/Services/HypergridService/HGRemoteAssetService.cs
new file mode 100644
index 0000000..5e98af9
--- /dev/null
+++ b/OpenSim/Services/HypergridService/HGRemoteAssetService.cs
@@ -0,0 +1,240 @@
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 */
27using System;
28using System.Collections.Generic;
29using System.IO;
30using System.Reflection;
31using System.Xml;
32
33using Nini.Config;
34using log4net;
35using OpenMetaverse;
36
37using OpenSim.Framework;
38using OpenSim.Framework.Serialization.External;
39using OpenSim.Server.Base;
40using OpenSim.Services.Interfaces;
41using OpenSim.Services.AssetService;
42
43namespace OpenSim.Services.HypergridService
44{
45 /// <summary>
46 /// Hypergrid asset service. It serves the IAssetService interface,
47 /// but implements it in ways that are appropriate for inter-grid
48 /// asset exchanges.
49 /// </summary>
50 public class HGRemoteAssetService : IAssetService
51 {
52 private static readonly ILog m_log =
53 LogManager.GetLogger(
54 MethodBase.GetCurrentMethod().DeclaringType);
55
56 private string m_HomeURL;
57 private IUserAccountService m_UserAccountService;
58 private IAssetService m_assetConnector;
59
60 private UserAccountCache m_Cache;
61
62 private AssetPermissions m_AssetPerms;
63
64 public HGRemoteAssetService(IConfigSource config, string configName)
65 {
66 m_log.Debug("[HGRemoteAsset Service]: Starting");
67 IConfig assetConfig = config.Configs[configName];
68 if (assetConfig == null)
69 throw new Exception("No HGAssetService configuration");
70
71 Object[] args = new Object[] { config };
72
73 string assetConnectorDll = assetConfig.GetString("AssetConnector", String.Empty);
74 if (assetConnectorDll == String.Empty)
75 throw new Exception("Please specify AssetConnector in HGAssetService configuration");
76
77 m_assetConnector = ServerUtils.LoadPlugin<IAssetService>(assetConnectorDll, args);
78 if (m_assetConnector == null)
79 throw new Exception(String.Format("Unable to create AssetConnector from {0}", assetConnectorDll));
80
81 string userAccountsDll = assetConfig.GetString("UserAccountsService", string.Empty);
82 if (userAccountsDll == string.Empty)
83 throw new Exception("Please specify UserAccountsService in HGAssetService configuration");
84
85 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountsDll, args);
86 if (m_UserAccountService == null)
87 throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll));
88
89 m_HomeURL = Util.GetConfigVarFromSections<string>(config, "HomeURI",
90 new string[] { "Startup", "Hypergrid", configName }, string.Empty);
91 if (m_HomeURL == string.Empty)
92 throw new Exception("[HGAssetService] No HomeURI specified");
93
94 m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
95
96 // Permissions
97 m_AssetPerms = new AssetPermissions(assetConfig);
98
99 }
100
101 #region IAssetService overrides
102 public AssetBase Get(string id)
103 {
104 AssetBase asset = m_assetConnector.Get(id);
105
106 if (asset == null)
107 return null;
108
109 if (!m_AssetPerms.AllowedExport(asset.Type))
110 return null;
111
112 if (asset.Metadata.Type == (sbyte)AssetType.Object)
113 asset.Data = AdjustIdentifiers(asset.Data);
114
115 AdjustIdentifiers(asset.Metadata);
116
117 return asset;
118 }
119
120 public AssetMetadata GetMetadata(string id)
121 {
122 AssetMetadata meta = m_assetConnector.GetMetadata(id);
123
124 if (meta == null)
125 return null;
126
127 AdjustIdentifiers(meta);
128
129 return meta;
130 }
131
132 public byte[] GetData(string id)
133 {
134 AssetBase asset = Get(id);
135
136 if (asset == null)
137 return null;
138
139 if (!m_AssetPerms.AllowedExport(asset.Type))
140 return null;
141
142 // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8)
143 // Fix bad assets before sending them elsewhere
144 if (asset.Type == (int)AssetType.Object && asset.Data != null)
145 {
146 string xml = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(asset.Data));
147 asset.Data = Utils.StringToBytes(xml);
148 }
149
150 return asset.Data;
151 }
152
153 // public delegate void AssetRetrieved(string id, Object sender, AssetBase asset);
154 public virtual bool Get(string id, Object sender, AssetRetrieved handler)
155 {
156 return m_assetConnector.Get(id, sender, (i, s, asset) =>
157 {
158 if (asset != null)
159 {
160 if (!m_AssetPerms.AllowedExport(asset.Type))
161 {
162 asset = null;
163 }
164 else
165 {
166 if (asset.Metadata.Type == (sbyte)AssetType.Object)
167 asset.Data = AdjustIdentifiers(asset.Data);
168
169 AdjustIdentifiers(asset.Metadata);
170 }
171 }
172
173 handler(i, s, asset);
174 });
175 }
176
177 public string Store(AssetBase asset)
178 {
179 if (!m_AssetPerms.AllowedImport(asset.Type))
180 return string.Empty;
181
182 // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8)
183 // Fix bad assets before storing on this server
184 if (asset.Type == (int)AssetType.Object && asset.Data != null)
185 {
186 string xml = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(asset.Data));
187 asset.Data = Utils.StringToBytes(xml);
188 }
189
190 return m_assetConnector.Store(asset);
191 }
192
193 public bool Delete(string id)
194 {
195 // NOGO
196 return false;
197 }
198
199 #endregion
200
201 protected void AdjustIdentifiers(AssetMetadata meta)
202 {
203 if (meta == null || m_Cache == null)
204 return;
205
206 UserAccount creator = m_Cache.GetUser(meta.CreatorID);
207 if (creator != null)
208 meta.CreatorID = meta.CreatorID + ";" + m_HomeURL + "/" + creator.FirstName + " " + creator.LastName;
209 }
210
211 // Only for Object
212 protected byte[] AdjustIdentifiers(byte[] data)
213 {
214 string xml = Utils.BytesToString(data);
215
216 // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8)
217 // Fix bad assets before sending them elsewhere
218 xml = ExternalRepresentationUtils.SanitizeXml(xml);
219
220 return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, "HGAssetService", m_HomeURL, m_Cache, UUID.Zero));
221 }
222
223 public AssetBase GetCached(string id)
224 {
225 return Get(id);
226 }
227
228 public bool[] AssetsExist(string[] ids)
229 {
230 return m_assetConnector.AssetsExist(ids);
231 }
232
233 public bool UpdateContent(string id, byte[] data)
234 {
235 // SO not happening!!
236 return false;
237 }
238 }
239
240}
diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
index 40eb6d4..d1f2e70 100644
--- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
+++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
@@ -97,7 +97,7 @@ namespace OpenSim.Services.HypergridService
97 throw new Exception(String.Format("Unable to create m_AvatarService from {0}", avatarDll)); 97 throw new Exception(String.Format("Unable to create m_AvatarService from {0}", avatarDll));
98 98
99// m_HomeURL = Util.GetConfigVarFromSections<string>(config, "HomeURI", 99// m_HomeURL = Util.GetConfigVarFromSections<string>(config, "HomeURI",
100// new string[] { "Startup", "Hypergrid", m_ConfigName }, String.Empty); 100// new string[] { "Startup", "Hypergrid", m_ConfigName }, String.Empty);
101 101
102// m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); 102// m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
103 } 103 }
@@ -318,7 +318,7 @@ namespace OpenSim.Services.HypergridService
318 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {0} (user {1}) is not within Suitcase tree", folder.ID, folder.Owner); 318 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {0} (user {1}) is not within Suitcase tree", folder.ID, folder.Owner);
319 return false; 319 return false;
320 } 320 }
321 321
322 if (!IsWithinSuitcaseTree(folder.Owner, folder.ParentID)) 322 if (!IsWithinSuitcaseTree(folder.Owner, folder.ParentID))
323 { 323 {
324 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {0} (user {1}) is not within Suitcase tree", folder.ParentID, folder.Owner); 324 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {0} (user {1}) is not within Suitcase tree", folder.ParentID, folder.Owner);
@@ -383,7 +383,7 @@ namespace OpenSim.Services.HypergridService
383 // Check the items' current folders 383 // Check the items' current folders
384 foreach (InventoryItemBase item in items) 384 foreach (InventoryItemBase item in items)
385 { 385 {
386 InventoryItemBase originalItem = base.GetItem(item); 386 InventoryItemBase originalItem = base.GetItem(item.Owner, item.ID);
387 if (!IsWithinSuitcaseTree(originalItem.Owner, originalItem.Folder)) 387 if (!IsWithinSuitcaseTree(originalItem.Owner, originalItem.Folder))
388 { 388 {
389 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveItems: folder {0} (user {1}) is not within Suitcase tree", item.Folder, item.Owner); 389 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveItems: folder {0} (user {1}) is not within Suitcase tree", item.Folder, item.Owner);
@@ -401,7 +401,7 @@ namespace OpenSim.Services.HypergridService
401 401
402 public new InventoryItemBase GetItem(InventoryItemBase item) 402 public new InventoryItemBase GetItem(InventoryItemBase item)
403 { 403 {
404 InventoryItemBase it = base.GetItem(item); 404 InventoryItemBase it = base.GetItem(item.Owner, item.ID);
405 if (it == null) 405 if (it == null)
406 { 406 {
407 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve item {0} ({1}) in folder {2}", 407 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve item {0} ({1}) in folder {2}",
@@ -426,9 +426,9 @@ namespace OpenSim.Services.HypergridService
426 return it; 426 return it;
427 } 427 }
428 428
429 public new InventoryFolderBase GetFolder(InventoryFolderBase folder) 429 public new InventoryFolderBase GetFolder(UUID principalID, UUID folderID)
430 { 430 {
431 InventoryFolderBase f = base.GetFolder(folder); 431 InventoryFolderBase f = base.GetFolder(principalID, folderID);
432 432
433 if (f != null) 433 if (f != null)
434 { 434 {
@@ -505,11 +505,11 @@ namespace OpenSim.Services.HypergridService
505 // Warp! Root folder for travelers 505 // Warp! Root folder for travelers
506 XInventoryFolder[] folders = m_Database.GetFolders( 506 XInventoryFolder[] folders = m_Database.GetFolders(
507 new string[] { "agentID", "type" }, 507 new string[] { "agentID", "type" },
508 new string[] { principalID.ToString(), ((int)FolderType.Suitcase).ToString() }); 508 new string[] { principalID.ToString(), ((int)FolderType.Suitcase).ToString() });
509 509
510 if (folders != null && folders.Length > 0) 510 if (folders != null && folders.Length > 0)
511 return folders[0]; 511 return folders[0];
512 512
513 // check to see if we have the old Suitcase folder 513 // check to see if we have the old Suitcase folder
514 folders = m_Database.GetFolders( 514 folders = m_Database.GetFolders(
515 new string[] { "agentID", "folderName", "parentFolderID" }, 515 new string[] { "agentID", "folderName", "parentFolderID" },
@@ -629,7 +629,7 @@ namespace OpenSim.Services.HypergridService
629 { 629 {
630 if (a.Wearables[i][j].ItemID == itemID) 630 if (a.Wearables[i][j].ItemID == itemID)
631 { 631 {
632 //m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: item {0} is a wearable", itemID); 632 //m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: item {0} is a wearable", itemID);
633 return true; 633 return true;
634 } 634 }
635 } 635 }
@@ -638,7 +638,7 @@ namespace OpenSim.Services.HypergridService
638 // Check attachments 638 // Check attachments
639 if (a.GetAttachmentForItem(itemID) != null) 639 if (a.GetAttachmentForItem(itemID) != null)
640 { 640 {
641 //m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: item {0} is an attachment", itemID); 641 //m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: item {0} is an attachment", itemID);
642 return true; 642 return true;
643 } 643 }
644 644
diff --git a/OpenSim/Services/HypergridService/Properties/AssemblyInfo.cs b/OpenSim/Services/HypergridService/Properties/AssemblyInfo.cs
index 9999237..31b9f4e 100644
--- a/OpenSim/Services/HypergridService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/HypergridService/Properties/AssemblyInfo.cs
@@ -2,7 +2,7 @@
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4 4
5// General Information about an assembly is controlled through the following 5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly. 7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Services.HypergridService")] 8[assembly: AssemblyTitle("OpenSim.Services.HypergridService")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
14[assembly: AssemblyTrademark("")] 14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")] 15[assembly: AssemblyCulture("")]
16 16
17// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)] 20[assembly: ComVisible(false)]
21 21
@@ -25,9 +25,9 @@ using System.Runtime.InteropServices;
25// Version information for an assembly consists of the following four values: 25// Version information for an assembly consists of the following four values:
26// 26//
27// Major Version 27// Major Version
28// Minor Version 28// Minor Version
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.8.3.*")] 32[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
33 33
diff --git a/OpenSim/Services/HypergridService/UserAccountCache.cs b/OpenSim/Services/HypergridService/UserAccountCache.cs
index fa7dd0b..ae0f7ce 100644
--- a/OpenSim/Services/HypergridService/UserAccountCache.cs
+++ b/OpenSim/Services/HypergridService/UserAccountCache.cs
@@ -16,7 +16,7 @@ namespace OpenSim.Services.HypergridService
16// private static readonly ILog m_log = 16// private static readonly ILog m_log =
17// LogManager.GetLogger( 17// LogManager.GetLogger(
18// MethodBase.GetCurrentMethod().DeclaringType); 18// MethodBase.GetCurrentMethod().DeclaringType);
19 19
20 private ExpiringCache<UUID, UserAccount> m_UUIDCache; 20 private ExpiringCache<UUID, UserAccount> m_UUIDCache;
21 21
22 private IUserAccountService m_UserAccountService; 22 private IUserAccountService m_UserAccountService;
@@ -90,11 +90,21 @@ namespace OpenSim.Services.HypergridService
90 return null; 90 return null;
91 } 91 }
92 92
93 public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string query)
94 {
95 return null;
96 }
97
93 public List<UserAccount> GetUserAccounts(UUID scopeID, string query) 98 public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
94 { 99 {
95 return null; 100 return null;
96 } 101 }
97 102
103 public List<UserAccount> GetUserAccounts(UUID scopeID, List<string> IDs)
104 {
105 return null;
106 }
107
98 public void InvalidateCache(UUID userID) 108 public void InvalidateCache(UUID userID)
99 { 109 {
100 m_UUIDCache.Remove(userID); 110 m_UUIDCache.Remove(userID);
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index c65122a..6f2cdd5 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -219,7 +219,7 @@ namespace OpenSim.Services.HypergridService
219 219
220 public bool LoginAgentToGrid(GridRegion source, AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, bool fromLogin, out string reason) 220 public bool LoginAgentToGrid(GridRegion source, AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, bool fromLogin, out string reason)
221 { 221 {
222 m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} (@{2}) to grid {3}", 222 m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} (@{2}) to grid {3}",
223 agentCircuit.firstname, agentCircuit.lastname, (fromLogin ? agentCircuit.IPAddress : "stored IP"), gatekeeper.ServerURI); 223 agentCircuit.firstname, agentCircuit.lastname, (fromLogin ? agentCircuit.IPAddress : "stored IP"), gatekeeper.ServerURI);
224 224
225 string gridName = gatekeeper.ServerURI; 225 string gridName = gatekeeper.ServerURI;
@@ -254,7 +254,6 @@ namespace OpenSim.Services.HypergridService
254 } 254 }
255 } 255 }
256 256
257
258 // Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination 257 // Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination
259 GridRegion region = new GridRegion(gatekeeper); 258 GridRegion region = new GridRegion(gatekeeper);
260 region.ServerURI = gatekeeper.ServerURI; 259 region.ServerURI = gatekeeper.ServerURI;
@@ -269,7 +268,7 @@ namespace OpenSim.Services.HypergridService
269 agentCircuit.ServiceSessionID = region.ServerURI + ";" + UUID.Random(); 268 agentCircuit.ServiceSessionID = region.ServerURI + ";" + UUID.Random();
270 TravelingAgentInfo old = null; 269 TravelingAgentInfo old = null;
271 TravelingAgentInfo travel = CreateTravelInfo(agentCircuit, region, fromLogin, out old); 270 TravelingAgentInfo travel = CreateTravelInfo(agentCircuit, region, fromLogin, out old);
272 271
273 bool success = false; 272 bool success = false;
274 string myExternalIP = string.Empty; 273 string myExternalIP = string.Empty;
275 274
@@ -281,12 +280,14 @@ namespace OpenSim.Services.HypergridService
281 } 280 }
282 else 281 else
283 { 282 {
284 success = m_GatekeeperConnector.CreateAgent(source, region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, out myExternalIP, out reason); 283 //TODO: Should there not be a call to QueryAccess here?
284 EntityTransferContext ctx = new EntityTransferContext();
285 success = m_GatekeeperConnector.CreateAgent(source, region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, ctx, out myExternalIP, out reason);
285 } 286 }
286 287
287 if (!success) 288 if (!success)
288 { 289 {
289 m_log.DebugFormat("[USER AGENT SERVICE]: Unable to login user {0} {1} to grid {2}, reason: {3}", 290 m_log.DebugFormat("[USER AGENT SERVICE]: Unable to login user {0} {1} to grid {2}, reason: {3}",
290 agentCircuit.firstname, agentCircuit.lastname, region.ServerURI, reason); 291 agentCircuit.firstname, agentCircuit.lastname, region.ServerURI, reason);
291 292
292 if (old != null) 293 if (old != null)
@@ -299,8 +300,12 @@ namespace OpenSim.Services.HypergridService
299 300
300 // Everything is ok 301 // Everything is ok
301 302
302 // Update the perceived IP Address of our grid 303 if (!fromLogin)
303 m_log.DebugFormat("[USER AGENT SERVICE]: Gatekeeper sees me as {0}", myExternalIP); 304 {
305 // Update the perceived IP Address of our grid
306 m_log.DebugFormat("[USER AGENT SERVICE]: Gatekeeper sees me as {0}", myExternalIP);
307 }
308
304 travel.MyIpAddress = myExternalIP; 309 travel.MyIpAddress = myExternalIP;
305 310
306 StoreTravelInfo(travel); 311 StoreTravelInfo(travel);
@@ -370,7 +375,7 @@ namespace OpenSim.Services.HypergridService
370 if (m_BypassClientVerification) 375 if (m_BypassClientVerification)
371 return true; 376 return true;
372 377
373 m_log.DebugFormat("[USER AGENT SERVICE]: Verifying Client session {0} with reported IP {1}.", 378 m_log.DebugFormat("[USER AGENT SERVICE]: Verifying Client session {0} with reported IP {1}.",
374 sessionID, reportedIP); 379 sessionID, reportedIP);
375 380
376 HGTravelingData hgt = m_Database.Get(sessionID); 381 HGTravelingData hgt = m_Database.Get(sessionID);
@@ -529,7 +534,7 @@ namespace OpenSim.Services.HypergridService
529 FriendInfo[] friendInfos = m_FriendsService.GetFriends(localUserID); 534 FriendInfo[] friendInfos = m_FriendsService.GetFriends(localUserID);
530 foreach (FriendInfo finfo in friendInfos) 535 foreach (FriendInfo finfo in friendInfos)
531 { 536 {
532 if (finfo.Friend.StartsWith(foreignUserID.ToString()) && finfo.Friend.EndsWith(secret) && 537 if (finfo.Friend.StartsWith(foreignUserID.ToString()) && finfo.Friend.EndsWith(secret) &&
533 (finfo.TheirFlags & (int)FriendRights.CanSeeOnline) != 0 && (finfo.TheirFlags != -1)) 538 (finfo.TheirFlags & (int)FriendRights.CanSeeOnline) != 0 && (finfo.TheirFlags != -1))
534 { 539 {
535 // great! 540 // great!
@@ -635,7 +640,7 @@ namespace OpenSim.Services.HypergridService
635 foreach (FriendInfo f in friends) 640 foreach (FriendInfo f in friends)
636 if (f.Friend.StartsWith(targetUserID.ToString())) 641 if (f.Friend.StartsWith(targetUserID.ToString()))
637 { 642 {
638 // Let's remove the secret 643 // Let's remove the secret
639 UUID id; string tmp = string.Empty, secret = string.Empty; 644 UUID id; string tmp = string.Empty, secret = string.Empty;
640 if (Util.ParseUniversalUserIdentifier(f.Friend, out id, out tmp, out tmp, out tmp, out secret)) 645 if (Util.ParseUniversalUserIdentifier(f.Friend, out id, out tmp, out tmp, out tmp, out secret))
641 return f.Friend.Replace(secret, "0"); 646 return f.Friend.Replace(secret, "0");
diff --git a/OpenSim/Services/Interfaces/IAgentPreferencesService.cs b/OpenSim/Services/Interfaces/IAgentPreferencesService.cs
index 3b4fda2..af92326 100644
--- a/OpenSim/Services/Interfaces/IAgentPreferencesService.cs
+++ b/OpenSim/Services/Interfaces/IAgentPreferencesService.cs
@@ -33,7 +33,7 @@ namespace OpenSim.Services.Interfaces
33{ 33{
34 public class AgentPrefs 34 public class AgentPrefs
35 { 35 {
36 public AgentPrefs(UUID principalID) 36 public AgentPrefs(UUID principalID)
37 { 37 {
38 PrincipalID = principalID; 38 PrincipalID = principalID;
39 } 39 }
@@ -101,7 +101,7 @@ namespace OpenSim.Services.Interfaces
101 // DefaultObjectPermMasks 101 // DefaultObjectPermMasks
102 public int PermEveryone = 0; 102 public int PermEveryone = 0;
103 public int PermGroup = 0; 103 public int PermGroup = 0;
104 public int PermNextOwner = 532480; 104 public int PermNextOwner = 0; // Illegal value by design
105 } 105 }
106 106
107 public interface IAgentPreferencesService 107 public interface IAgentPreferencesService
diff --git a/OpenSim/Services/Interfaces/IAssetService.cs b/OpenSim/Services/Interfaces/IAssetService.cs
index 28c3315..170dc97 100644
--- a/OpenSim/Services/Interfaces/IAssetService.cs
+++ b/OpenSim/Services/Interfaces/IAssetService.cs
@@ -47,7 +47,7 @@ namespace OpenSim.Services.Interfaces
47 /// <param name="id"></param> 47 /// <param name="id"></param>
48 /// <returns></returns> 48 /// <returns></returns>
49 AssetMetadata GetMetadata(string id); 49 AssetMetadata GetMetadata(string id);
50 50
51 /// <summary> 51 /// <summary>
52 /// Get an asset's data, ignoring the metadata. 52 /// Get an asset's data, ignoring the metadata.
53 /// </summary> 53 /// </summary>
@@ -63,7 +63,7 @@ namespace OpenSim.Services.Interfaces
63 AssetBase GetCached(string id); 63 AssetBase GetCached(string id);
64 64
65 /// <summary> 65 /// <summary>
66 /// Get an asset synchronously or asynchronously (depending on whether 66 /// Get an asset synchronously or asynchronously (depending on whether
67 /// it is locally cached) and fire a callback with the fetched asset 67 /// it is locally cached) and fire a callback with the fetched asset
68 /// </summary> 68 /// </summary>
69 /// <param name="id">The asset id</param> 69 /// <param name="id">The asset id</param>
@@ -75,7 +75,7 @@ namespace OpenSim.Services.Interfaces
75 /// </param> 75 /// </param>
76 /// <returns>True if the id was parseable, false otherwise</returns> 76 /// <returns>True if the id was parseable, false otherwise</returns>
77 bool Get(string id, Object sender, AssetRetrieved handler); 77 bool Get(string id, Object sender, AssetRetrieved handler);
78 78
79 /// <summary> 79 /// <summary>
80 /// Check if assets exist in the database. 80 /// Check if assets exist in the database.
81 /// </summary> 81 /// </summary>
diff --git a/OpenSim/Services/Interfaces/IAttachmentsService.cs b/OpenSim/Services/Interfaces/IAttachmentsService.cs
new file mode 100644
index 0000000..7d33662
--- /dev/null
+++ b/OpenSim/Services/Interfaces/IAttachmentsService.cs
@@ -0,0 +1,38 @@
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 Nini.Config;
30
31namespace OpenSim.Services.Interfaces
32{
33 public interface IAttachmentsService
34 {
35 string Get(string id);
36 void Store(string id, string data);
37 }
38}
diff --git a/OpenSim/Services/Interfaces/IAuthenticationService.cs b/OpenSim/Services/Interfaces/IAuthenticationService.cs
index cee8bc0..1ff092f 100644
--- a/OpenSim/Services/Interfaces/IAuthenticationService.cs
+++ b/OpenSim/Services/Interfaces/IAuthenticationService.cs
@@ -55,7 +55,7 @@ namespace OpenSim.Services.Interfaces
55 // Generic Authentication service used for identifying 55 // Generic Authentication service used for identifying
56 // and authenticating principals. 56 // and authenticating principals.
57 // Principals may be clients acting on users' behalf, 57 // Principals may be clients acting on users' behalf,
58 // or any other components that need 58 // or any other components that need
59 // verifiable identification. 59 // verifiable identification.
60 // 60 //
61 public interface IAuthenticationService 61 public interface IAuthenticationService
@@ -67,6 +67,7 @@ namespace OpenSim.Services.Interfaces
67 // various services. 67 // various services.
68 // 68 //
69 string Authenticate(UUID principalID, string password, int lifetime); 69 string Authenticate(UUID principalID, string password, int lifetime);
70 string Authenticate(UUID principalID, string password, int lifetime, out UUID realID);
70 71
71 ////////////////////////////////////////////////////// 72 //////////////////////////////////////////////////////
72 // Verification 73 // Verification
diff --git a/OpenSim/Services/Interfaces/IAuthorizationService.cs b/OpenSim/Services/Interfaces/IAuthorizationService.cs
index e5c68f6..1974234 100644
--- a/OpenSim/Services/Interfaces/IAuthorizationService.cs
+++ b/OpenSim/Services/Interfaces/IAuthorizationService.cs
@@ -31,7 +31,7 @@ using OpenSim.Framework;
31namespace OpenSim.Services.Interfaces 31namespace OpenSim.Services.Interfaces
32{ 32{
33 // Generic Authorization service used for authorizing principals in a particular region 33 // Generic Authorization service used for authorizing principals in a particular region
34 34
35 public interface IAuthorizationService 35 public interface IAuthorizationService
36 { 36 {
37 /// <summary> 37 /// <summary>
@@ -48,9 +48,9 @@ namespace OpenSim.Services.Interfaces
48 /// <param name="message"></param> 48 /// <param name="message"></param>
49 /// <returns></returns> 49 /// <returns></returns>
50 bool IsAuthorizedForRegion( 50 bool IsAuthorizedForRegion(
51 string userID, string firstName, string lastName, string regionID, out string message); 51 string userID, string firstName, string lastName, string regionID, out string message, out bool isLocal);
52 } 52 }
53 53
54 public class AuthorizationRequest 54 public class AuthorizationRequest
55 { 55 {
56 private string m_userID; 56 private string m_userID;
@@ -69,7 +69,7 @@ namespace OpenSim.Services.Interfaces
69 m_userID = ID; 69 m_userID = ID;
70 m_regionID = RegionID; 70 m_regionID = RegionID;
71 } 71 }
72 72
73 public AuthorizationRequest( 73 public AuthorizationRequest(
74 string ID, string FirstName, string SurName, string Email, string RegionName, string RegionID) 74 string ID, string FirstName, string SurName, string Email, string RegionName, string RegionID)
75 { 75 {
@@ -80,44 +80,44 @@ namespace OpenSim.Services.Interfaces
80 m_regionName = RegionName; 80 m_regionName = RegionName;
81 m_regionID = RegionID; 81 m_regionID = RegionID;
82 } 82 }
83 83
84 public string ID 84 public string ID
85 { 85 {
86 get { return m_userID; } 86 get { return m_userID; }
87 set { m_userID = value; } 87 set { m_userID = value; }
88 } 88 }
89 89
90 public string FirstName 90 public string FirstName
91 { 91 {
92 get { return m_firstname; } 92 get { return m_firstname; }
93 set { m_firstname = value; } 93 set { m_firstname = value; }
94 } 94 }
95 95
96 public string SurName 96 public string SurName
97 { 97 {
98 get { return m_surname; } 98 get { return m_surname; }
99 set { m_surname = value; } 99 set { m_surname = value; }
100 } 100 }
101 101
102 public string Email 102 public string Email
103 { 103 {
104 get { return m_email; } 104 get { return m_email; }
105 set { m_email = value; } 105 set { m_email = value; }
106 } 106 }
107 107
108 public string RegionName 108 public string RegionName
109 { 109 {
110 get { return m_regionName; } 110 get { return m_regionName; }
111 set { m_regionName = value; } 111 set { m_regionName = value; }
112 } 112 }
113 113
114 public string RegionID 114 public string RegionID
115 { 115 {
116 get { return m_regionID; } 116 get { return m_regionID; }
117 set { m_regionID = value; } 117 set { m_regionID = value; }
118 } 118 }
119 } 119 }
120 120
121 public class AuthorizationResponse 121 public class AuthorizationResponse
122 { 122 {
123 private bool m_isAuthorized; 123 private bool m_isAuthorized;
@@ -132,13 +132,13 @@ namespace OpenSim.Services.Interfaces
132 m_isAuthorized = isAuthorized; 132 m_isAuthorized = isAuthorized;
133 m_message = message; 133 m_message = message;
134 } 134 }
135 135
136 public bool IsAuthorized 136 public bool IsAuthorized
137 { 137 {
138 get { return m_isAuthorized; } 138 get { return m_isAuthorized; }
139 set { m_isAuthorized = value; } 139 set { m_isAuthorized = value; }
140 } 140 }
141 141
142 public string Message 142 public string Message
143 { 143 {
144 get { return m_message; } 144 get { return m_message; }
diff --git a/OpenSim/Services/Interfaces/IAvatarService.cs b/OpenSim/Services/Interfaces/IAvatarService.cs
index 892e0b4..b4dc511 100644
--- a/OpenSim/Services/Interfaces/IAvatarService.cs
+++ b/OpenSim/Services/Interfaces/IAvatarService.cs
@@ -51,7 +51,7 @@ namespace OpenSim.Services.Interfaces
51 /// <param name="appearance"></param> 51 /// <param name="appearance"></param>
52 /// <returns></returns> 52 /// <returns></returns>
53 bool SetAppearance(UUID userID, AvatarAppearance appearance); 53 bool SetAppearance(UUID userID, AvatarAppearance appearance);
54 54
55 /// <summary> 55 /// <summary>
56 /// Called by the login service 56 /// Called by the login service
57 /// </summary> 57 /// </summary>
@@ -75,7 +75,7 @@ namespace OpenSim.Services.Interfaces
75 bool ResetAvatar(UUID userID); 75 bool ResetAvatar(UUID userID);
76 76
77 /// <summary> 77 /// <summary>
78 /// These methods raison d'etre: 78 /// These methods raison d'etre:
79 /// No need to send the entire avatar data (SetAvatar) for changing attachments 79 /// No need to send the entire avatar data (SetAvatar) for changing attachments
80 /// </summary> 80 /// </summary>
81 /// <param name="userID"></param> 81 /// <param name="userID"></param>
@@ -150,7 +150,8 @@ namespace OpenSim.Services.Interfaces
150 // Wearables 150 // Wearables
151 Data["AvatarHeight"] = appearance.AvatarHeight.ToString(); 151 Data["AvatarHeight"] = appearance.AvatarHeight.ToString();
152 152
153 for (int i = 0 ; i < AvatarWearable.MAX_WEARABLES ; i++) 153 // TODO: With COF, is this even needed?
154 for (int i = 0 ; i < AvatarWearable.LEGACY_VERSION_MAX_WEARABLES ; i++)
154 { 155 {
155 for (int j = 0 ; j < appearance.Wearables[i].Count ; j++) 156 for (int j = 0 ; j < appearance.Wearables[i].Count ; j++)
156 { 157 {
@@ -211,8 +212,8 @@ namespace OpenSim.Services.Interfaces
211 float h = float.Parse(Data["AvatarHeight"]); 212 float h = float.Parse(Data["AvatarHeight"]);
212 if( h == 0f) 213 if( h == 0f)
213 h = 1.9f; 214 h = 1.9f;
214 215 appearance.SetSize(new Vector3(0.45f, 0.6f, h ));
215 appearance.AvatarHeight = h; 216// appearance.AvatarHeight = float.Parse(Data["AvatarHeight"]);
216 } 217 }
217 218
218 // Legacy Wearables 219 // Legacy Wearables
@@ -287,12 +288,11 @@ namespace OpenSim.Services.Interfaces
287 //byte[] binary = new byte[AvatarAppearance.VISUALPARAM_COUNT]; 288 //byte[] binary = new byte[AvatarAppearance.VISUALPARAM_COUNT];
288 289
289 //for (int i = 0 ; i < vps.Length && i < binary.Length ; i++) 290 //for (int i = 0 ; i < vps.Length && i < binary.Length ; i++)
290
291 byte[] binary = new byte[vps.Length]; 291 byte[] binary = new byte[vps.Length];
292 292
293 for (int i = 0; i < vps.Length; i++) 293 for (int i = 0; i < vps.Length; i++)
294 binary[i] = (byte)Convert.ToInt32(vps[i]); 294 binary[i] = (byte)Convert.ToInt32(vps[i]);
295 295
296 appearance.VisualParams = binary; 296 appearance.VisualParams = binary;
297 } 297 }
298 298
@@ -357,6 +357,7 @@ namespace OpenSim.Services.Interfaces
357 appearance.Wearables[AvatarWearable.EYES].Wear( 357 appearance.Wearables[AvatarWearable.EYES].Wear(
358 AvatarWearable.DefaultWearables[ 358 AvatarWearable.DefaultWearables[
359 AvatarWearable.EYES][0]); 359 AvatarWearable.EYES][0]);
360
360 } 361 }
361 catch 362 catch
362 { 363 {
diff --git a/OpenSim/Services/Interfaces/IEstateDataService.cs b/OpenSim/Services/Interfaces/IEstateDataService.cs
index 719563d..9b64a39 100644
--- a/OpenSim/Services/Interfaces/IEstateDataService.cs
+++ b/OpenSim/Services/Interfaces/IEstateDataService.cs
@@ -39,14 +39,14 @@ namespace OpenSim.Services.Interfaces
39 /// </summary> 39 /// </summary>
40 /// <param name="regionID"></param> 40 /// <param name="regionID"></param>
41 /// <param name="create">If true, then an estate is created if one is not found.</param> 41 /// <param name="create">If true, then an estate is created if one is not found.</param>
42 /// <returns></returns> 42 /// <returns></returns>
43 EstateSettings LoadEstateSettings(UUID regionID, bool create); 43 EstateSettings LoadEstateSettings(UUID regionID, bool create);
44 44
45 /// <summary> 45 /// <summary>
46 /// Load estate settings for an estate ID. 46 /// Load estate settings for an estate ID.
47 /// </summary> 47 /// </summary>
48 /// <param name="estateID"></param> 48 /// <param name="estateID"></param>
49 /// <returns></returns> 49 /// <returns></returns>
50 EstateSettings LoadEstateSettings(int estateID); 50 EstateSettings LoadEstateSettings(int estateID);
51 51
52 /// <summary> 52 /// <summary>
@@ -56,60 +56,60 @@ namespace OpenSim.Services.Interfaces
56 /// A <see cref="EstateSettings"/> 56 /// A <see cref="EstateSettings"/>
57 /// </returns> 57 /// </returns>
58 EstateSettings CreateNewEstate(); 58 EstateSettings CreateNewEstate();
59 59
60 /// <summary> 60 /// <summary>
61 /// Load/Get all estate settings. 61 /// Load/Get all estate settings.
62 /// </summary> 62 /// </summary>
63 /// <returns>An empty list if no estates were found.</returns> 63 /// <returns>An empty list if no estates were found.</returns>
64 List<EstateSettings> LoadEstateSettingsAll(); 64 List<EstateSettings> LoadEstateSettingsAll();
65 65
66 /// <summary> 66 /// <summary>
67 /// Store estate settings. 67 /// Store estate settings.
68 /// </summary> 68 /// </summary>
69 /// <remarks> 69 /// <remarks>
70 /// This is also called by EstateSettings.Save()</remarks> 70 /// This is also called by EstateSettings.Save()</remarks>
71 /// <param name="es"></param> 71 /// <param name="es"></param>
72 void StoreEstateSettings(EstateSettings es); 72 void StoreEstateSettings(EstateSettings es);
73 73
74 /// <summary> 74 /// <summary>
75 /// Get estate IDs. 75 /// Get estate IDs.
76 /// </summary> 76 /// </summary>
77 /// <param name="search">Name of estate to search for. This is the exact name, no parttern matching is done.</param> 77 /// <param name="search">Name of estate to search for. This is the exact name, no parttern matching is done.</param>
78 /// <returns></returns> 78 /// <returns></returns>
79 List<int> GetEstates(string search); 79 List<int> GetEstates(string search);
80 80
81 /// <summary> 81 /// <summary>
82 /// Get the IDs of all estates owned by the given user. 82 /// Get the IDs of all estates owned by the given user.
83 /// </summary> 83 /// </summary>
84 /// <returns>An empty list if no estates were found.</returns> 84 /// <returns>An empty list if no estates were found.</returns>
85 List<int> GetEstatesByOwner(UUID ownerID); 85 List<int> GetEstatesByOwner(UUID ownerID);
86 86
87 /// <summary> 87 /// <summary>
88 /// Get the IDs of all estates. 88 /// Get the IDs of all estates.
89 /// </summary> 89 /// </summary>
90 /// <returns>An empty list if no estates were found.</returns> 90 /// <returns>An empty list if no estates were found.</returns>
91 List<int> GetEstatesAll(); 91 List<int> GetEstatesAll();
92 92
93 /// <summary> 93 /// <summary>
94 /// Link a region to an estate. 94 /// Link a region to an estate.
95 /// </summary> 95 /// </summary>
96 /// <param name="regionID"></param> 96 /// <param name="regionID"></param>
97 /// <param name="estateID"></param> 97 /// <param name="estateID"></param>
98 /// <returns>true if the link succeeded, false otherwise</returns> 98 /// <returns>true if the link succeeded, false otherwise</returns>
99 bool LinkRegion(UUID regionID, int estateID); 99 bool LinkRegion(UUID regionID, int estateID);
100 100
101 /// <summary> 101 /// <summary>
102 /// Get the UUIDs of all the regions in an estate. 102 /// Get the UUIDs of all the regions in an estate.
103 /// </summary> 103 /// </summary>
104 /// <param name="estateID"></param> 104 /// <param name="estateID"></param>
105 /// <returns></returns> 105 /// <returns></returns>
106 List<UUID> GetRegions(int estateID); 106 List<UUID> GetRegions(int estateID);
107 107
108 /// <summary> 108 /// <summary>
109 /// Delete an estate 109 /// Delete an estate
110 /// </summary> 110 /// </summary>
111 /// <param name="estateID"></param> 111 /// <param name="estateID"></param>
112 /// <returns>true if the delete succeeded, false otherwise</returns> 112 /// <returns>true if the delete succeeded, false otherwise</returns>
113 bool DeleteEstate(int estateID); 113 bool DeleteEstate(int estateID);
114 } 114 }
115} \ No newline at end of file 115} \ No newline at end of file
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs
index f5f1f75..ead5d3c 100644
--- a/OpenSim/Services/Interfaces/IGridService.cs
+++ b/OpenSim/Services/Interfaces/IGridService.cs
@@ -85,7 +85,7 @@ namespace OpenSim.Services.Interfaces
85 GridRegion GetRegionByName(UUID scopeID, string regionName); 85 GridRegion GetRegionByName(UUID scopeID, string regionName);
86 86
87 /// <summary> 87 /// <summary>
88 /// Get information about regions starting with the provided name. 88 /// Get information about regions starting with the provided name.
89 /// </summary> 89 /// </summary>
90 /// <param name="name"> 90 /// <param name="name">
91 /// The name to match against. 91 /// The name to match against.
@@ -95,7 +95,7 @@ namespace OpenSim.Services.Interfaces
95 /// </param> 95 /// </param>
96 /// <returns> 96 /// <returns>
97 /// A list of <see cref="RegionInfo"/>s of regions with matching name. If the 97 /// A list of <see cref="RegionInfo"/>s of regions with matching name. If the
98 /// grid-server couldn't be contacted or returned an error, return null. 98 /// grid-server couldn't be contacted or returned an error, return null.
99 /// </returns> 99 /// </returns>
100 List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber); 100 List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber);
101 101
@@ -139,7 +139,7 @@ namespace OpenSim.Services.Interfaces
139#pragma warning restore 414 139#pragma warning restore 414
140 140
141 /// <summary> 141 /// <summary>
142 /// The port by which http communication occurs with the region 142 /// The port by which http communication occurs with the region
143 /// </summary> 143 /// </summary>
144 public uint HttpPort { get; set; } 144 public uint HttpPort { get; set; }
145 145
@@ -148,7 +148,7 @@ namespace OpenSim.Services.Interfaces
148 /// </summary> 148 /// </summary>
149 public string ServerURI 149 public string ServerURI
150 { 150 {
151 get { 151 get {
152 if (!String.IsNullOrEmpty(m_serverURI)) { 152 if (!String.IsNullOrEmpty(m_serverURI)) {
153 return m_serverURI; 153 return m_serverURI;
154 } else { 154 } else {
@@ -158,14 +158,25 @@ namespace OpenSim.Services.Interfaces
158 return "http://" + m_externalHostName + ":" + HttpPort + "/"; 158 return "http://" + m_externalHostName + ":" + HttpPort + "/";
159 } 159 }
160 } 160 }
161 set { 161 set {
162 if (value.EndsWith("/")) { 162 if ( value == null)
163 {
164 m_serverURI = String.Empty;
165 return;
166 }
167
168 if ( value.EndsWith("/") )
169 {
170
163 m_serverURI = value; 171 m_serverURI = value;
164 } else { 172 }
173 else
174 {
165 m_serverURI = value + '/'; 175 m_serverURI = value + '/';
166 } 176 }
167 } 177 }
168 } 178 }
179
169 protected string m_serverURI; 180 protected string m_serverURI;
170 181
171 /// <summary> 182 /// <summary>
@@ -260,31 +271,6 @@ namespace OpenSim.Services.Interfaces
260 m_serverURI = string.Empty; 271 m_serverURI = string.Empty;
261 } 272 }
262 273
263 /*
264 public GridRegion(int regionLocX, int regionLocY, IPEndPoint internalEndPoint, string externalUri)
265 {
266 m_regionLocX = regionLocX;
267 m_regionLocY = regionLocY;
268 RegionSizeX = (int)Constants.RegionSize;
269 RegionSizeY = (int)Constants.RegionSize;
270
271 m_internalEndPoint = internalEndPoint;
272 m_externalHostName = externalUri;
273 }
274
275 public GridRegion(int regionLocX, int regionLocY, string externalUri, uint port)
276 {
277 m_regionLocX = regionLocX;
278 m_regionLocY = regionLocY;
279 RegionSizeX = (int)Constants.RegionSize;
280 RegionSizeY = (int)Constants.RegionSize;
281
282 m_externalHostName = externalUri;
283
284 m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)port);
285 }
286 */
287
288 public GridRegion(uint xcell, uint ycell) 274 public GridRegion(uint xcell, uint ycell)
289 { 275 {
290 m_regionLocX = (int)Util.RegionToWorldLoc(xcell); 276 m_regionLocX = (int)Util.RegionToWorldLoc(xcell);
@@ -333,7 +319,7 @@ namespace OpenSim.Services.Interfaces
333 RegionSecret = ConvertFrom.RegionSecret; 319 RegionSecret = ConvertFrom.RegionSecret;
334 EstateOwner = ConvertFrom.EstateOwner; 320 EstateOwner = ConvertFrom.EstateOwner;
335 } 321 }
336 322
337 public GridRegion(Dictionary<string, object> kvp) 323 public GridRegion(Dictionary<string, object> kvp)
338 { 324 {
339 if (kvp.ContainsKey("uuid")) 325 if (kvp.ContainsKey("uuid"))
@@ -358,6 +344,13 @@ namespace OpenSim.Services.Interfaces
358 if (kvp.ContainsKey("regionName")) 344 if (kvp.ContainsKey("regionName"))
359 RegionName = (string)kvp["regionName"]; 345 RegionName = (string)kvp["regionName"];
360 346
347 if (kvp.ContainsKey("access"))
348 {
349 byte access = Convert.ToByte((string)kvp["access"]);
350 Access = access;
351 Maturity = (int)Util.ConvertAccessLevelToMaturity(access);
352 }
353
361 if (kvp.ContainsKey("flags") && kvp["flags"] != null) 354 if (kvp.ContainsKey("flags") && kvp["flags"] != null)
362 RegionFlags = (OpenSim.Framework.RegionFlags?)Convert.ToInt32((string)kvp["flags"]); 355 RegionFlags = (OpenSim.Framework.RegionFlags?)Convert.ToInt32((string)kvp["flags"]);
363 356
@@ -394,9 +387,6 @@ namespace OpenSim.Services.Interfaces
394 if (kvp.ContainsKey("parcelMapTexture")) 387 if (kvp.ContainsKey("parcelMapTexture"))
395 UUID.TryParse((string)kvp["parcelMapTexture"], out ParcelImage); 388 UUID.TryParse((string)kvp["parcelMapTexture"], out ParcelImage);
396 389
397 if (kvp.ContainsKey("access"))
398 Access = Byte.Parse((string)kvp["access"]);
399
400 if (kvp.ContainsKey("regionSecret")) 390 if (kvp.ContainsKey("regionSecret"))
401 RegionSecret =(string)kvp["regionSecret"]; 391 RegionSecret =(string)kvp["regionSecret"];
402 392
@@ -409,7 +399,7 @@ namespace OpenSim.Services.Interfaces
409 // m_log.DebugFormat("{0} New GridRegion. id={1}, loc=<{2},{3}>, size=<{4},{5}>", 399 // m_log.DebugFormat("{0} New GridRegion. id={1}, loc=<{2},{3}>, size=<{4},{5}>",
410 // LogHeader, RegionID, RegionLocX, RegionLocY, RegionSizeX, RegionSizeY); 400 // LogHeader, RegionID, RegionLocX, RegionLocY, RegionSizeX, RegionSizeY);
411 } 401 }
412 402
413 public Dictionary<string, object> ToKeyValuePairs() 403 public Dictionary<string, object> ToKeyValuePairs()
414 { 404 {
415 Dictionary<string, object> kvp = new Dictionary<string, object>(); 405 Dictionary<string, object> kvp = new Dictionary<string, object>();
@@ -472,41 +462,7 @@ namespace OpenSim.Services.Interfaces
472 /// </value> 462 /// </value>
473 public IPEndPoint ExternalEndPoint 463 public IPEndPoint ExternalEndPoint
474 { 464 {
475 get 465 get { return Util.getEndPoint(m_externalHostName, m_internalEndPoint.Port); }
476 {
477 // Old one defaults to IPv6
478 //return new IPEndPoint(Dns.GetHostAddresses(m_externalHostName)[0], m_internalEndPoint.Port);
479
480 IPAddress ia = null;
481 // If it is already an IP, don't resolve it - just return directly
482 if (IPAddress.TryParse(m_externalHostName, out ia))
483 return new IPEndPoint(ia, m_internalEndPoint.Port);
484
485 // Reset for next check
486 ia = null;
487 try
488 {
489 foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName))
490 {
491 if (ia == null)
492 ia = Adr;
493
494 if (Adr.AddressFamily == AddressFamily.InterNetwork)
495 {
496 ia = Adr;
497 break;
498 }
499 }
500 }
501 catch (SocketException e)
502 {
503 throw new Exception(
504 "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" +
505 e + "' attached to this exception", e);
506 }
507
508 return new IPEndPoint(ia, m_internalEndPoint.Port);
509 }
510 } 466 }
511 467
512 public string ExternalHostName 468 public string ExternalHostName
@@ -526,4 +482,4 @@ namespace OpenSim.Services.Interfaces
526 get { return Util.UIntsToLong((uint)RegionLocX, (uint)RegionLocY); } 482 get { return Util.UIntsToLong((uint)RegionLocX, (uint)RegionLocY); }
527 } 483 }
528 } 484 }
529} \ No newline at end of file 485}
diff --git a/OpenSim/Services/Interfaces/IGridUserService.cs b/OpenSim/Services/Interfaces/IGridUserService.cs
index 2e7237e..6ad0f42 100644
--- a/OpenSim/Services/Interfaces/IGridUserService.cs
+++ b/OpenSim/Services/Interfaces/IGridUserService.cs
@@ -37,7 +37,7 @@ namespace OpenSim.Services.Interfaces
37 public class GridUserInfo 37 public class GridUserInfo
38 { 38 {
39 public string UserID; 39 public string UserID;
40 40
41 public UUID HomeRegionID; 41 public UUID HomeRegionID;
42 public Vector3 HomePosition; 42 public Vector3 HomePosition;
43 public Vector3 HomeLookAt; 43 public Vector3 HomeLookAt;
@@ -45,13 +45,13 @@ namespace OpenSim.Services.Interfaces
45 public UUID LastRegionID; 45 public UUID LastRegionID;
46 public Vector3 LastPosition; 46 public Vector3 LastPosition;
47 public Vector3 LastLookAt; 47 public Vector3 LastLookAt;
48 48
49 public bool Online; 49 public bool Online;
50 public DateTime Login; 50 public DateTime Login;
51 public DateTime Logout; 51 public DateTime Logout;
52 52
53 public GridUserInfo() {} 53 public GridUserInfo() {}
54 54
55 public GridUserInfo(Dictionary<string, object> kvp) 55 public GridUserInfo(Dictionary<string, object> kvp)
56 { 56 {
57 if (kvp.ContainsKey("UserID")) 57 if (kvp.ContainsKey("UserID"))
@@ -96,11 +96,11 @@ namespace OpenSim.Services.Interfaces
96 result["Online"] = Online.ToString(); 96 result["Online"] = Online.ToString();
97 result["Login"] = Login.ToString(); 97 result["Login"] = Login.ToString();
98 result["Logout"] = Logout.ToString(); 98 result["Logout"] = Logout.ToString();
99 99
100 return result; 100 return result;
101 } 101 }
102 } 102 }
103 103
104 public interface IGridUserService 104 public interface IGridUserService
105 { 105 {
106 GridUserInfo LoggedIn(string userID); 106 GridUserInfo LoggedIn(string userID);
@@ -115,7 +115,7 @@ namespace OpenSim.Services.Interfaces
115 /// <param name="lastLookAt">Last normalized look direction for the user</param> 115 /// <param name="lastLookAt">Last normalized look direction for the user</param>
116 /// <returns>True if the logout request was successfully processed, otherwise false</returns> 116 /// <returns>True if the logout request was successfully processed, otherwise false</returns>
117 bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt); 117 bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt);
118 118
119 bool SetHome(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt); 119 bool SetHome(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt);
120 120
121 /// <summary> 121 /// <summary>
@@ -128,7 +128,7 @@ namespace OpenSim.Services.Interfaces
128 /// <param name="lastLookAt">Normalized look direction</param> 128 /// <param name="lastLookAt">Normalized look direction</param>
129 /// <returns>True if the user's last position was successfully updated, otherwise false</returns> 129 /// <returns>True if the user's last position was successfully updated, otherwise false</returns>
130 bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt); 130 bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt);
131 131
132 GridUserInfo GetGridUserInfo(string userID); 132 GridUserInfo GetGridUserInfo(string userID);
133 GridUserInfo[] GetGridUserInfo(string[] userID); 133 GridUserInfo[] GetGridUserInfo(string[] userID);
134 } 134 }
diff --git a/OpenSim/Services/Interfaces/IHypergridServices.cs b/OpenSim/Services/Interfaces/IHypergridServices.cs
index 5e012fb..e0a63ca 100644
--- a/OpenSim/Services/Interfaces/IHypergridServices.cs
+++ b/OpenSim/Services/Interfaces/IHypergridServices.cs
@@ -36,8 +36,8 @@ namespace OpenSim.Services.Interfaces
36{ 36{
37 public interface IGatekeeperService 37 public interface IGatekeeperService
38 { 38 {
39 bool LinkRegion(string regionDescriptor, out UUID regionID, out ulong regionHandle, out string externalName, out string imageURL, out string reason); 39 bool LinkRegion(string regionDescriptor, out UUID regionID, out ulong regionHandle, out string externalName, out string imageURL, out string reason, out int sizeX, out int sizeY);
40 40
41 /// <summary> 41 /// <summary>
42 /// Returns the region a Hypergrid visitor should enter. 42 /// Returns the region a Hypergrid visitor should enter.
43 /// </summary> 43 /// </summary>
@@ -59,7 +59,7 @@ namespace OpenSim.Services.Interfaces
59 public interface IUserAgentService 59 public interface IUserAgentService
60 { 60 {
61 bool LoginAgentToGrid(GridRegion source, AgentCircuitData agent, GridRegion gatekeeper, GridRegion finalDestination, bool fromLogin, out string reason); 61 bool LoginAgentToGrid(GridRegion source, AgentCircuitData agent, GridRegion gatekeeper, GridRegion finalDestination, bool fromLogin, out string reason);
62 62
63 void LogoutAgent(UUID userID, UUID sessionID); 63 void LogoutAgent(UUID userID, UUID sessionID);
64 64
65 /// <summary> 65 /// <summary>
@@ -89,7 +89,7 @@ namespace OpenSim.Services.Interfaces
89 /// <returns>On success: the user's Server URLs. If the user doesn't exist: "".</returns> 89 /// <returns>On success: the user's Server URLs. If the user doesn't exist: "".</returns>
90 /// <remarks>Throws an exception if an error occurs (e.g., can't contact the server).</remarks> 90 /// <remarks>Throws an exception if an error occurs (e.g., can't contact the server).</remarks>
91 string LocateUser(UUID userID); 91 string LocateUser(UUID userID);
92 92
93 /// <summary> 93 /// <summary>
94 /// Returns the Universal User Identifier for 'targetUserID' on behalf of 'userID'. 94 /// Returns the Universal User Identifier for 'targetUserID' on behalf of 'userID'.
95 /// </summary> 95 /// </summary>
diff --git a/OpenSim/Services/Interfaces/IInventoryService.cs b/OpenSim/Services/Interfaces/IInventoryService.cs
index 4289bba..582ea90 100644
--- a/OpenSim/Services/Interfaces/IInventoryService.cs
+++ b/OpenSim/Services/Interfaces/IInventoryService.cs
@@ -84,7 +84,7 @@ namespace OpenSim.Services.Interfaces
84 /// <param name="folderIDs"></param> 84 /// <param name="folderIDs"></param>
85 /// <returns>Inventory content.</returns> 85 /// <returns>Inventory content.</returns>
86 InventoryCollection[] GetMultipleFoldersContent(UUID userID, UUID[] folderIDs); 86 InventoryCollection[] GetMultipleFoldersContent(UUID userID, UUID[] folderIDs);
87 87
88 /// <summary> 88 /// <summary>
89 /// Gets the items inside a folder 89 /// Gets the items inside a folder
90 /// </summary> 90 /// </summary>
@@ -161,7 +161,7 @@ namespace OpenSim.Services.Interfaces
161 /// </summary> 161 /// </summary>
162 /// <param name="item"></param> 162 /// <param name="item"></param>
163 /// <returns>null if no item was found, otherwise the found item</returns> 163 /// <returns>null if no item was found, otherwise the found item</returns>
164 InventoryItemBase GetItem(InventoryItemBase item); 164 InventoryItemBase GetItem(UUID userID, UUID itemID);
165 165
166 /// <summary> 166 /// <summary>
167 /// Get multiple items, given by their UUIDs 167 /// Get multiple items, given by their UUIDs
@@ -175,7 +175,7 @@ namespace OpenSim.Services.Interfaces
175 /// </summary> 175 /// </summary>
176 /// <param name="folder"></param> 176 /// <param name="folder"></param>
177 /// <returns></returns> 177 /// <returns></returns>
178 InventoryFolderBase GetFolder(InventoryFolderBase folder); 178 InventoryFolderBase GetFolder(UUID userID, UUID folderID);
179 179
180 /// <summary> 180 /// <summary>
181 /// Does the given user have an inventory structure? 181 /// Does the given user have an inventory structure?
@@ -193,11 +193,11 @@ namespace OpenSim.Services.Interfaces
193 193
194 /// <summary> 194 /// <summary>
195 /// Get the union of permissions of all inventory items 195 /// Get the union of permissions of all inventory items
196 /// that hold the given assetID. 196 /// that hold the given assetID.
197 /// </summary> 197 /// </summary>
198 /// <param name="userID"></param> 198 /// <param name="userID"></param>
199 /// <param name="assetID"></param> 199 /// <param name="assetID"></param>
200 /// <returns>The permissions or 0 if no such asset is found in 200 /// <returns>The permissions or 0 if no such asset is found in
201 /// the user's inventory</returns> 201 /// the user's inventory</returns>
202 int GetAssetPermissions(UUID userID, UUID assetID); 202 int GetAssetPermissions(UUID userID, UUID assetID);
203 } 203 }
diff --git a/OpenSim/Services/Interfaces/ILoginService.cs b/OpenSim/Services/Interfaces/ILoginService.cs
index ee9b0b1..7c44cd8 100644
--- a/OpenSim/Services/Interfaces/ILoginService.cs
+++ b/OpenSim/Services/Interfaces/ILoginService.cs
@@ -47,8 +47,8 @@ namespace OpenSim.Services.Interfaces
47 47
48 public interface ILoginService 48 public interface ILoginService
49 { 49 {
50 LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, UUID scopeID, 50 LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, UUID scopeID,
51 string clientVersion, string channel, string mac, string id0, IPEndPoint clientIP); 51 string clientVersion, string channel, string mac, string id0, IPEndPoint clientIP, bool LibOMVclient);
52 Hashtable SetLevel(string firstName, string lastName, string passwd, int level, IPEndPoint clientIP); 52 Hashtable SetLevel(string firstName, string lastName, string passwd, int level, IPEndPoint clientIP);
53 } 53 }
54 54
diff --git a/OpenSim/Services/Interfaces/IMapImageService.cs b/OpenSim/Services/Interfaces/IMapImageService.cs
index 78daa5f..b8d45dd 100644
--- a/OpenSim/Services/Interfaces/IMapImageService.cs
+++ b/OpenSim/Services/Interfaces/IMapImageService.cs
@@ -34,8 +34,8 @@ namespace OpenSim.Services.Interfaces
34 public interface IMapImageService 34 public interface IMapImageService
35 { 35 {
36 //List<MapBlockData> GetMapBlocks(UUID scopeID, int minX, int minY, int maxX, int maxY); 36 //List<MapBlockData> GetMapBlocks(UUID scopeID, int minX, int minY, int maxX, int maxY);
37 bool AddMapTile(int x, int y, byte[] imageData, out string reason); 37 bool AddMapTile(int x, int y, byte[] imageData, UUID scopeID, out string reason);
38 bool RemoveMapTile(int x, int y, out string reason); 38 bool RemoveMapTile(int x, int y, UUID scopeID, out string reason);
39 byte[] GetMapTile(string fileName, out string format); 39 byte[] GetMapTile(string fileName, UUID scopeID, out string format);
40 } 40 }
41} 41}
diff --git a/OpenSim/Services/Interfaces/IMuteLIstService.cs b/OpenSim/Services/Interfaces/IMuteLIstService.cs
new file mode 100644
index 0000000..9ffd47f
--- /dev/null
+++ b/OpenSim/Services/Interfaces/IMuteLIstService.cs
@@ -0,0 +1,41 @@
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 OpenSim.Framework;
31using OpenMetaverse;
32
33namespace OpenSim.Services.Interfaces
34{
35 public interface IMuteListService
36 {
37 Byte[] MuteListRequest(UUID agent, uint crc);
38 bool UpdateMute(MuteData mute);
39 bool RemoveMute(UUID agentID, UUID muteID, string muteName);
40 }
41} \ No newline at end of file
diff --git a/OpenSim/Services/Interfaces/IOfflineIMService.cs b/OpenSim/Services/Interfaces/IOfflineIMService.cs
index 588aaaf..db501fd 100644
--- a/OpenSim/Services/Interfaces/IOfflineIMService.cs
+++ b/OpenSim/Services/Interfaces/IOfflineIMService.cs
@@ -35,9 +35,9 @@ namespace OpenSim.Services.Interfaces
35 public interface IOfflineIMService 35 public interface IOfflineIMService
36 { 36 {
37 List<GridInstantMessage> GetMessages(UUID principalID); 37 List<GridInstantMessage> GetMessages(UUID principalID);
38 38
39 bool StoreMessage(GridInstantMessage im, out string reason); 39 bool StoreMessage(GridInstantMessage im, out string reason);
40 40
41 /// <summary> 41 /// <summary>
42 /// Delete messages to or from this user (or group). 42 /// Delete messages to or from this user (or group).
43 /// </summary> 43 /// </summary>
diff --git a/OpenSim/Services/Interfaces/IPresenceService.cs b/OpenSim/Services/Interfaces/IPresenceService.cs
index 90f9842..4843759 100644
--- a/OpenSim/Services/Interfaces/IPresenceService.cs
+++ b/OpenSim/Services/Interfaces/IPresenceService.cs
@@ -36,6 +36,7 @@ namespace OpenSim.Services.Interfaces
36 { 36 {
37 public string UserID; 37 public string UserID;
38 public UUID RegionID; 38 public UUID RegionID;
39 public UUID SessionID;
39 40
40 public PresenceInfo() 41 public PresenceInfo()
41 { 42 {
@@ -47,6 +48,8 @@ namespace OpenSim.Services.Interfaces
47 UserID = kvp["UserID"].ToString(); 48 UserID = kvp["UserID"].ToString();
48 if (kvp.ContainsKey("RegionID")) 49 if (kvp.ContainsKey("RegionID"))
49 UUID.TryParse(kvp["RegionID"].ToString(), out RegionID); 50 UUID.TryParse(kvp["RegionID"].ToString(), out RegionID);
51 if (kvp.ContainsKey("SessionID"))
52 UUID.TryParse(kvp["SessionID"].ToString(), out SessionID);
50 } 53 }
51 54
52 public Dictionary<string, object> ToKeyValuePairs() 55 public Dictionary<string, object> ToKeyValuePairs()
@@ -54,6 +57,7 @@ namespace OpenSim.Services.Interfaces
54 Dictionary<string, object> result = new Dictionary<string, object>(); 57 Dictionary<string, object> result = new Dictionary<string, object>();
55 result["UserID"] = UserID; 58 result["UserID"] = UserID;
56 result["RegionID"] = RegionID.ToString(); 59 result["RegionID"] = RegionID.ToString();
60 result["SessionID"] = SessionID.ToString();
57 61
58 return result; 62 return result;
59 } 63 }
@@ -100,6 +104,13 @@ namespace OpenSim.Services.Interfaces
100 PresenceInfo GetAgent(UUID sessionID); 104 PresenceInfo GetAgent(UUID sessionID);
101 105
102 /// <summary> 106 /// <summary>
107 /// Get session information for a given session ID.
108 /// </summary>
109 /// <returns></returns>
110 /// <param name='sessionID'></param>
111 PresenceInfo GetAgentByUser(UUID userID);
112
113 /// <summary>
103 /// Get session information for a collection of users. 114 /// Get session information for a collection of users.
104 /// </summary> 115 /// </summary>
105 /// <returns>Session information for the users.</returns> 116 /// <returns>Session information for the users.</returns>
diff --git a/OpenSim/Services/Interfaces/ISimulationService.cs b/OpenSim/Services/Interfaces/ISimulationService.cs
index 8a25509..a01897a 100644
--- a/OpenSim/Services/Interfaces/ISimulationService.cs
+++ b/OpenSim/Services/Interfaces/ISimulationService.cs
@@ -34,20 +34,6 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion;
34 34
35namespace OpenSim.Services.Interfaces 35namespace OpenSim.Services.Interfaces
36{ 36{
37 public class EntityTransferContext
38 {
39 public EntityTransferContext()
40 {
41 InboundVersion = VersionInfo.SimulationServiceVersionAcceptedMax;
42 OutboundVersion = VersionInfo.SimulationServiceVersionSupportedMax;
43 VariableWearablesSupported = false;
44 }
45
46 public float InboundVersion { get; set; }
47 public float OutboundVersion { get; set; }
48 public bool VariableWearablesSupported { get; set; }
49 }
50
51 public interface ISimulationService 37 public interface ISimulationService
52 { 38 {
53 /// <summary> 39 /// <summary>
@@ -73,8 +59,8 @@ namespace OpenSim.Services.Interfaces
73 /// <param name="destination"></param> 59 /// <param name="destination"></param>
74 /// <param name="aCircuit"></param> 60 /// <param name="aCircuit"></param>
75 /// <param name="flags"></param> 61 /// <param name="flags"></param>
76 /// <param name="reason">Reason message in the event of a failure.</param> 62 /// <param name="reason">Reason message in the event of a failure.</param>
77 bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason); 63 bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, EntityTransferContext ctx, out string reason);
78 64
79 /// <summary> 65 /// <summary>
80 /// Full child agent update. 66 /// Full child agent update.
@@ -82,7 +68,7 @@ namespace OpenSim.Services.Interfaces
82 /// <param name="regionHandle"></param> 68 /// <param name="regionHandle"></param>
83 /// <param name="data"></param> 69 /// <param name="data"></param>
84 /// <returns></returns> 70 /// <returns></returns>
85 bool UpdateAgent(GridRegion destination, AgentData data); 71 bool UpdateAgent(GridRegion destination, AgentData data, EntityTransferContext ctx);
86 72
87 /// <summary> 73 /// <summary>
88 /// Short child agent update, mostly for position. 74 /// Short child agent update, mostly for position.
@@ -100,6 +86,7 @@ namespace OpenSim.Services.Interfaces
100 /// <param name="agentHomeURI">The visitor's Home URI. Will be missing (null) in older OpenSims.</param> 86 /// <param name="agentHomeURI">The visitor's Home URI. Will be missing (null) in older OpenSims.</param>
101 /// <param name="viaTeleport">True: via teleport; False: via cross (walking)</param> 87 /// <param name="viaTeleport">True: via teleport; False: via cross (walking)</param>
102 /// <param name="position">Position in the region</param> 88 /// <param name="position">Position in the region</param>
89
103 /// <param name="sversion"> 90 /// <param name="sversion">
104 /// Version that the requesting simulator is runing. If null then no version check is carried out. 91 /// Version that the requesting simulator is runing. If null then no version check is carried out.
105 /// </param> 92 /// </param>
diff --git a/OpenSim/Services/Interfaces/IUserAccountService.cs b/OpenSim/Services/Interfaces/IUserAccountService.cs
index 2f7702c..c6f3ef3 100644
--- a/OpenSim/Services/Interfaces/IUserAccountService.cs
+++ b/OpenSim/Services/Interfaces/IUserAccountService.cs
@@ -91,6 +91,7 @@ namespace OpenSim.Services.Interfaces
91 public int UserLevel; 91 public int UserLevel;
92 public int UserFlags; 92 public int UserFlags;
93 public string UserTitle; 93 public string UserTitle;
94 public string UserCountry;
94 public Boolean LocalToGrid = true; 95 public Boolean LocalToGrid = true;
95 96
96 public Dictionary<string, object> ServiceURLs; 97 public Dictionary<string, object> ServiceURLs;
@@ -120,6 +121,8 @@ namespace OpenSim.Services.Interfaces
120 UserFlags = Convert.ToInt32(kvp["UserFlags"].ToString()); 121 UserFlags = Convert.ToInt32(kvp["UserFlags"].ToString());
121 if (kvp.ContainsKey("UserTitle")) 122 if (kvp.ContainsKey("UserTitle"))
122 UserTitle = kvp["UserTitle"].ToString(); 123 UserTitle = kvp["UserTitle"].ToString();
124 if (kvp.ContainsKey("UserCountry"))
125 UserCountry = kvp["UserCountry"].ToString();
123 if (kvp.ContainsKey("LocalToGrid")) 126 if (kvp.ContainsKey("LocalToGrid"))
124 Boolean.TryParse(kvp["LocalToGrid"].ToString(), out LocalToGrid); 127 Boolean.TryParse(kvp["LocalToGrid"].ToString(), out LocalToGrid);
125 128
@@ -155,6 +158,7 @@ namespace OpenSim.Services.Interfaces
155 result["UserLevel"] = UserLevel.ToString(); 158 result["UserLevel"] = UserLevel.ToString();
156 result["UserFlags"] = UserFlags.ToString(); 159 result["UserFlags"] = UserFlags.ToString();
157 result["UserTitle"] = UserTitle; 160 result["UserTitle"] = UserTitle;
161 result["UserCountry"] = UserCountry;
158 result["LocalToGrid"] = LocalToGrid.ToString(); 162 result["LocalToGrid"] = LocalToGrid.ToString();
159 163
160 string str = string.Empty; 164 string str = string.Empty;
@@ -182,6 +186,8 @@ namespace OpenSim.Services.Interfaces
182 /// <param name="query"></param> 186 /// <param name="query"></param>
183 /// <returns></returns> 187 /// <returns></returns>
184 List<UserAccount> GetUserAccounts(UUID scopeID, string query); 188 List<UserAccount> GetUserAccounts(UUID scopeID, string query);
189 List<UserAccount> GetUserAccountsWhere(UUID scopeID, string where);
190 List<UserAccount> GetUserAccounts(UUID scopeID, List<string> IDs);
185 191
186 /// <summary> 192 /// <summary>
187 /// Store the data given, wich replaces the stored data, therefore must be complete. 193 /// Store the data given, wich replaces the stored data, therefore must be complete.
diff --git a/OpenSim/Services/Interfaces/IUserManagement.cs b/OpenSim/Services/Interfaces/IUserManagement.cs
index 9e560d5..91b344e 100644
--- a/OpenSim/Services/Interfaces/IUserManagement.cs
+++ b/OpenSim/Services/Interfaces/IUserManagement.cs
@@ -42,6 +42,7 @@ namespace OpenSim.Services.Interfaces
42 string GetUserUUI(UUID uuid); 42 string GetUserUUI(UUID uuid);
43 bool GetUserUUI(UUID userID, out string uui); 43 bool GetUserUUI(UUID userID, out string uui);
44 string GetUserServerURL(UUID uuid, string serverType); 44 string GetUserServerURL(UUID uuid, string serverType);
45 Dictionary<UUID,string> GetUsersNames(string[] ids);
45 46
46 /// <summary> 47 /// <summary>
47 /// Get user ID by the given name. 48 /// Get user ID by the given name.
@@ -78,7 +79,7 @@ namespace OpenSim.Services.Interfaces
78 /// <param name="uuid"></param> 79 /// <param name="uuid"></param>
79 /// <param name="firstName"></param> 80 /// <param name="firstName"></param>
80 /// <param name="lastName"></param> 81 /// <param name="lastName"></param>
81 void AddUser(UUID uuid, string firstName, string lastName); 82 void AddUser(UUID uuid, string first, string last, bool isNPC = false);
82 83
83 /// <summary> 84 /// <summary>
84 /// Add a user. 85 /// Add a user.
diff --git a/OpenSim/Services/Interfaces/IUserProfilesService.cs b/OpenSim/Services/Interfaces/IUserProfilesService.cs
index 121baa8..867c623 100644
--- a/OpenSim/Services/Interfaces/IUserProfilesService.cs
+++ b/OpenSim/Services/Interfaces/IUserProfilesService.cs
@@ -40,19 +40,19 @@ namespace OpenSim.Services.Interfaces
40 bool ClassifiedInfoRequest(ref UserClassifiedAdd ad, ref string result); 40 bool ClassifiedInfoRequest(ref UserClassifiedAdd ad, ref string result);
41 bool ClassifiedDelete(UUID recordId); 41 bool ClassifiedDelete(UUID recordId);
42 #endregion Classifieds 42 #endregion Classifieds
43 43
44 #region Picks 44 #region Picks
45 OSD AvatarPicksRequest(UUID creatorId); 45 OSD AvatarPicksRequest(UUID creatorId);
46 bool PickInfoRequest(ref UserProfilePick pick, ref string result); 46 bool PickInfoRequest(ref UserProfilePick pick, ref string result);
47 bool PicksUpdate(ref UserProfilePick pick, ref string result); 47 bool PicksUpdate(ref UserProfilePick pick, ref string result);
48 bool PicksDelete(UUID pickId); 48 bool PicksDelete(UUID pickId);
49 #endregion Picks 49 #endregion Picks
50 50
51 #region Notes 51 #region Notes
52 bool AvatarNotesRequest(ref UserProfileNotes note); 52 bool AvatarNotesRequest(ref UserProfileNotes note);
53 bool NotesUpdate(ref UserProfileNotes note, ref string result); 53 bool NotesUpdate(ref UserProfileNotes note, ref string result);
54 #endregion Notes 54 #endregion Notes
55 55
56 #region Profile Properties 56 #region Profile Properties
57 bool AvatarPropertiesRequest(ref UserProfileProperties prop, ref string result); 57 bool AvatarPropertiesRequest(ref UserProfileProperties prop, ref string result);
58 bool AvatarPropertiesUpdate(ref UserProfileProperties prop, ref string result); 58 bool AvatarPropertiesUpdate(ref UserProfileProperties prop, ref string result);
@@ -62,7 +62,7 @@ namespace OpenSim.Services.Interfaces
62 bool UserPreferencesRequest(ref UserPreferences pref, ref string result); 62 bool UserPreferencesRequest(ref UserPreferences pref, ref string result);
63 bool UserPreferencesUpdate(ref UserPreferences pref, ref string result); 63 bool UserPreferencesUpdate(ref UserPreferences pref, ref string result);
64 #endregion User Preferences 64 #endregion User Preferences
65 65
66 #region Interests 66 #region Interests
67 bool AvatarInterestsUpdate(UserProfileProperties prop, ref string result); 67 bool AvatarInterestsUpdate(UserProfileProperties prop, ref string result);
68 #endregion Interests 68 #endregion Interests
diff --git a/OpenSim/Services/Interfaces/OpenProfileClient.cs b/OpenSim/Services/Interfaces/OpenProfileClient.cs
index bda8151..8c4d14b 100644
--- a/OpenSim/Services/Interfaces/OpenProfileClient.cs
+++ b/OpenSim/Services/Interfaces/OpenProfileClient.cs
@@ -49,7 +49,7 @@ namespace OpenSim.Services.UserProfilesService
49 public class OpenProfileClient 49 public class OpenProfileClient
50 { 50 {
51// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 51// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 52
53 private string m_serverURI; 53 private string m_serverURI;
54 54
55 /// <summary> 55 /// <summary>
@@ -60,7 +60,7 @@ namespace OpenSim.Services.UserProfilesService
60 { 60 {
61 m_serverURI = serverURI; 61 m_serverURI = serverURI;
62 } 62 }
63 63
64 /// <summary> 64 /// <summary>
65 /// Gets an avatar's profile using the OpenProfile protocol. 65 /// Gets an avatar's profile using the OpenProfile protocol.
66 /// </summary> 66 /// </summary>
diff --git a/OpenSim/Services/Interfaces/Properties/AssemblyInfo.cs b/OpenSim/Services/Interfaces/Properties/AssemblyInfo.cs
index 01cafbf..6c683b4 100644
--- a/OpenSim/Services/Interfaces/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/Interfaces/Properties/AssemblyInfo.cs
@@ -2,7 +2,7 @@
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4 4
5// General Information about an assembly is controlled through the following 5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly. 7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Services.Interfaces")] 8[assembly: AssemblyTitle("OpenSim.Services.Interfaces")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
14[assembly: AssemblyTrademark("")] 14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")] 15[assembly: AssemblyCulture("")]
16 16
17// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)] 20[assembly: ComVisible(false)]
21 21
@@ -25,9 +25,9 @@ using System.Runtime.InteropServices;
25// Version information for an assembly consists of the following four values: 25// Version information for an assembly consists of the following four values:
26// 26//
27// Major Version 27// Major Version
28// Minor Version 28// Minor Version
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.8.3.*")] 32[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
33 33
diff --git a/OpenSim/Services/InventoryService/Properties/AssemblyInfo.cs b/OpenSim/Services/InventoryService/Properties/AssemblyInfo.cs
index ec89097..2e3fb3e 100644
--- a/OpenSim/Services/InventoryService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/InventoryService/Properties/AssemblyInfo.cs
@@ -2,7 +2,7 @@
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4 4
5// General Information about an assembly is controlled through the following 5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly. 7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Services.InventoryService")] 8[assembly: AssemblyTitle("OpenSim.Services.InventoryService")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
14[assembly: AssemblyTrademark("")] 14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")] 15[assembly: AssemblyCulture("")]
16 16
17// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)] 20[assembly: ComVisible(false)]
21 21
@@ -25,9 +25,9 @@ using System.Runtime.InteropServices;
25// Version information for an assembly consists of the following four values: 25// Version information for an assembly consists of the following four values:
26// 26//
27// Major Version 27// Major Version
28// Minor Version 28// Minor Version
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.8.3.*")] 32[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
33 33
diff --git a/OpenSim/Services/InventoryService/Tests/XInventoryServiceTests.cs b/OpenSim/Services/InventoryService/Tests/XInventoryServiceTests.cs
index 9e3fa69..2e4637c 100644
--- a/OpenSim/Services/InventoryService/Tests/XInventoryServiceTests.cs
+++ b/OpenSim/Services/InventoryService/Tests/XInventoryServiceTests.cs
@@ -47,7 +47,7 @@ namespace OpenSim.Services.InventoryService.Tests
47 { 47 {
48 private IInventoryService CreateXInventoryService() 48 private IInventoryService CreateXInventoryService()
49 { 49 {
50 IConfigSource config = new IniConfigSource(); 50 IConfigSource config = new IniConfigSource();
51 config.AddConfig("InventoryService"); 51 config.AddConfig("InventoryService");
52 config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); 52 config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");
53 53
@@ -73,25 +73,24 @@ namespace OpenSim.Services.InventoryService.Tests
73 UUID folderId = TestHelpers.ParseTail(0x30); 73 UUID folderId = TestHelpers.ParseTail(0x30);
74 int invType = (int)InventoryType.Animation; 74 int invType = (int)InventoryType.Animation;
75 int assetType = (int)AssetType.Animation; 75 int assetType = (int)AssetType.Animation;
76 string itemName = "item1"; 76 string itemName = "item1";
77 77
78 IInventoryService xis = CreateXInventoryService(); 78 IInventoryService xis = CreateXInventoryService();
79 79
80 InventoryItemBase itemToStore 80 InventoryItemBase itemToStore
81 = new InventoryItemBase(itemId, ownerId) 81 = new InventoryItemBase(itemId, ownerId)
82 { 82 {
83 CreatorIdentification = creatorId.ToString(), 83 CreatorIdentification = creatorId.ToString(),
84 AssetID = assetId, 84 AssetID = assetId,
85 Name = itemName, 85 Name = itemName,
86 Folder = folderId, 86 Folder = folderId,
87 InvType = invType, 87 InvType = invType,
88 AssetType = assetType 88 AssetType = assetType
89 }; 89 };
90 90
91 Assert.That(xis.AddItem(itemToStore), Is.True); 91 Assert.That(xis.AddItem(itemToStore), Is.True);
92 92
93 InventoryItemBase itemRetrieved = new InventoryItemBase(itemId); 93 InventoryItemBase itemRetrieved = xis.GetItem(UUID.Zero, itemId);
94 itemRetrieved = xis.GetItem(itemRetrieved);
95 94
96 Assert.That(itemRetrieved, Is.Not.Null); 95 Assert.That(itemRetrieved, Is.Not.Null);
97 Assert.That(itemRetrieved.CreatorId, Is.EqualTo(creatorId)); 96 Assert.That(itemRetrieved.CreatorId, Is.EqualTo(creatorId));
@@ -116,20 +115,20 @@ namespace OpenSim.Services.InventoryService.Tests
116 UUID folderId = TestHelpers.ParseTail(0x30); 115 UUID folderId = TestHelpers.ParseTail(0x30);
117 int invType = (int)InventoryType.Animation; 116 int invType = (int)InventoryType.Animation;
118 int assetType = (int)AssetType.Animation; 117 int assetType = (int)AssetType.Animation;
119 string itemName = "item1"; 118 string itemName = "item1";
120 string itemName2 = "item2"; 119 string itemName2 = "item2";
121 120
122 IInventoryService xis = CreateXInventoryService(); 121 IInventoryService xis = CreateXInventoryService();
123 122
124 InventoryItemBase itemToStore 123 InventoryItemBase itemToStore
125 = new InventoryItemBase(itemId, ownerId) 124 = new InventoryItemBase(itemId, ownerId)
126 { 125 {
127 CreatorIdentification = creatorId.ToString(), 126 CreatorIdentification = creatorId.ToString(),
128 AssetID = assetId, 127 AssetID = assetId,
129 Name = itemName, 128 Name = itemName,
130 Folder = folderId, 129 Folder = folderId,
131 InvType = invType, 130 InvType = invType,
132 AssetType = assetType 131 AssetType = assetType
133 }; 132 };
134 133
135 Assert.That(xis.AddItem(itemToStore), Is.True); 134 Assert.That(xis.AddItem(itemToStore), Is.True);
@@ -139,8 +138,7 @@ namespace OpenSim.Services.InventoryService.Tests
139 138
140 Assert.That(xis.UpdateItem(itemToStore), Is.True); 139 Assert.That(xis.UpdateItem(itemToStore), Is.True);
141 140
142 InventoryItemBase itemRetrieved = new InventoryItemBase(itemId); 141 InventoryItemBase itemRetrieved = xis.GetItem(UUID.Zero, itemId);
143 itemRetrieved = xis.GetItem(itemRetrieved);
144 142
145 Assert.That(itemRetrieved, Is.Not.Null); 143 Assert.That(itemRetrieved, Is.Not.Null);
146 Assert.That(itemRetrieved.Name, Is.EqualTo(itemName2)); 144 Assert.That(itemRetrieved.Name, Is.EqualTo(itemName2));
@@ -151,7 +149,7 @@ namespace OpenSim.Services.InventoryService.Tests
151 UUID folderId2 = TestHelpers.ParseTail(0x70); 149 UUID folderId2 = TestHelpers.ParseTail(0x70);
152 int invType2 = (int)InventoryType.CallingCard; 150 int invType2 = (int)InventoryType.CallingCard;
153 int assetType2 = (int)AssetType.CallingCard; 151 int assetType2 = (int)AssetType.CallingCard;
154 string itemName3 = "item3"; 152 string itemName3 = "item3";
155 153
156 itemToStore.CreatorIdentification = creatorId2.ToString(); 154 itemToStore.CreatorIdentification = creatorId2.ToString();
157 itemToStore.Owner = ownerId2; 155 itemToStore.Owner = ownerId2;
@@ -162,7 +160,7 @@ namespace OpenSim.Services.InventoryService.Tests
162 160
163 Assert.That(xis.UpdateItem(itemToStore), Is.True); 161 Assert.That(xis.UpdateItem(itemToStore), Is.True);
164 162
165 itemRetrieved = xis.GetItem(itemRetrieved); 163 itemRetrieved = xis.GetItem(itemRetrieved.Owner, itemRetrieved.ID);
166 164
167 Assert.That(itemRetrieved, Is.Not.Null); 165 Assert.That(itemRetrieved, Is.Not.Null);
168 Assert.That(itemRetrieved.CreatorId, Is.EqualTo(creatorId)); 166 Assert.That(itemRetrieved.CreatorId, Is.EqualTo(creatorId));
@@ -174,4 +172,4 @@ namespace OpenSim.Services.InventoryService.Tests
174 Assert.That(itemRetrieved.Name, Is.EqualTo(itemName3)); 172 Assert.That(itemRetrieved.Name, Is.EqualTo(itemName3));
175 } 173 }
176 } 174 }
177} \ No newline at end of file 175}
diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs
index b75193f..b8ed46c 100644
--- a/OpenSim/Services/InventoryService/XInventoryService.cs
+++ b/OpenSim/Services/InventoryService/XInventoryService.cs
@@ -176,7 +176,7 @@ namespace OpenSim.Services.InventoryService
176 protected virtual XInventoryFolder[] GetSystemFolders(UUID principalID, UUID rootID) 176 protected virtual XInventoryFolder[] GetSystemFolders(UUID principalID, UUID rootID)
177 { 177 {
178// m_log.DebugFormat("[XINVENTORY SERVICE]: Getting system folders for {0}", principalID); 178// m_log.DebugFormat("[XINVENTORY SERVICE]: Getting system folders for {0}", principalID);
179 179
180 XInventoryFolder[] allFolders = m_Database.GetFolders( 180 XInventoryFolder[] allFolders = m_Database.GetFolders(
181 new string[] { "agentID", "parentFolderID" }, 181 new string[] { "agentID", "parentFolderID" },
182 new string[] { principalID.ToString(), rootID.ToString() }); 182 new string[] { principalID.ToString(), rootID.ToString() });
@@ -192,7 +192,7 @@ namespace OpenSim.Services.InventoryService
192 192
193// m_log.DebugFormat( 193// m_log.DebugFormat(
194// "[XINVENTORY SERVICE]: Found {0} system folders for {1}", sysFolders.Length, principalID); 194// "[XINVENTORY SERVICE]: Found {0} system folders for {1}", sysFolders.Length, principalID);
195 195
196 return sysFolders; 196 return sysFolders;
197 } 197 }
198 198
@@ -234,7 +234,7 @@ namespace OpenSim.Services.InventoryService
234 break; 234 break;
235 } 235 }
236 } 236 }
237 237
238 if (root == null) // oops 238 if (root == null) // oops
239 root = folders[0]; 239 root = folders[0];
240 240
@@ -255,7 +255,7 @@ namespace OpenSim.Services.InventoryService
255 255
256 return null; 256 return null;
257 } 257 }
258 258
259 return GetSystemFolderForType(rootFolder, type); 259 return GetSystemFolderForType(rootFolder, type);
260 } 260 }
261 261
@@ -315,8 +315,7 @@ namespace OpenSim.Services.InventoryService
315 inventory.Items.Add(ConvertToOpenSim(i)); 315 inventory.Items.Add(ConvertToOpenSim(i));
316 } 316 }
317 317
318 InventoryFolderBase f = new InventoryFolderBase(folderID, principalID); 318 InventoryFolderBase f = GetFolder(principalID, folderID);
319 f = GetFolder(f);
320 if (f != null) 319 if (f != null)
321 { 320 {
322 inventory.Version = f.Version; 321 inventory.Version = f.Version;
@@ -336,11 +335,11 @@ namespace OpenSim.Services.InventoryService
336 335
337 return multiple; 336 return multiple;
338 } 337 }
339 338
340 public virtual List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID) 339 public virtual List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID)
341 { 340 {
342// m_log.DebugFormat("[XINVENTORY]: Fetch items for folder {0}", folderID); 341// m_log.DebugFormat("[XINVENTORY]: Fetch items for folder {0}", folderID);
343 342
344 // Since we probably don't get a valid principal here, either ... 343 // Since we probably don't get a valid principal here, either ...
345 // 344 //
346 List<InventoryItemBase> invItems = new List<InventoryItemBase>(); 345 List<InventoryItemBase> invItems = new List<InventoryItemBase>();
@@ -359,7 +358,7 @@ namespace OpenSim.Services.InventoryService
359 { 358 {
360// m_log.DebugFormat("[XINVENTORY]: Add folder {0} type {1} in parent {2}", folder.Name, folder.Type, folder.ParentID); 359// m_log.DebugFormat("[XINVENTORY]: Add folder {0} type {1} in parent {2}", folder.Name, folder.Type, folder.ParentID);
361 360
362 InventoryFolderBase check = GetFolder(folder); 361 InventoryFolderBase check = GetFolder(folder.Owner, folder.ID);
363 if (check != null) 362 if (check != null)
364 return false; 363 return false;
365 364
@@ -387,7 +386,7 @@ namespace OpenSim.Services.InventoryService
387 m_log.WarnFormat( 386 m_log.WarnFormat(
388 "[XINVENTORY]: System folder of type {0} already exists when tried to add {1} to {2} for {3}", 387 "[XINVENTORY]: System folder of type {0} already exists when tried to add {1} to {2} for {3}",
389 folder.Type, folder.Name, folder.ParentID, folder.Owner); 388 folder.Type, folder.Name, folder.ParentID, folder.Owner);
390 389
391 return false; 390 return false;
392 } 391 }
393 } 392 }
@@ -402,7 +401,7 @@ namespace OpenSim.Services.InventoryService
402// m_log.DebugFormat("[XINVENTORY]: Update folder {0} {1} ({2})", folder.Name, folder.Type, folder.ID); 401// m_log.DebugFormat("[XINVENTORY]: Update folder {0} {1} ({2})", folder.Name, folder.Type, folder.ID);
403 402
404 XInventoryFolder xFolder = ConvertFromOpenSim(folder); 403 XInventoryFolder xFolder = ConvertFromOpenSim(folder);
405 InventoryFolderBase check = GetFolder(folder); 404 InventoryFolderBase check = GetFolder(folder.Owner, folder.ID);
406 405
407 if (check == null) 406 if (check == null)
408 return AddFolder(folder); 407 return AddFolder(folder);
@@ -499,7 +498,7 @@ namespace OpenSim.Services.InventoryService
499 { 498 {
500// m_log.DebugFormat( 499// m_log.DebugFormat(
501// "[XINVENTORY SERVICE]: Adding item {0} {1} to folder {2} for {3}", item.Name, item.ID, item.Folder, item.Owner); 500// "[XINVENTORY SERVICE]: Adding item {0} {1} to folder {2} for {3}", item.Name, item.ID, item.Folder, item.Owner);
502 501
503 return m_Database.StoreItem(ConvertFromOpenSim(item)); 502 return m_Database.StoreItem(ConvertFromOpenSim(item));
504 } 503 }
505 504
@@ -512,32 +511,32 @@ namespace OpenSim.Services.InventoryService
512// m_log.InfoFormat( 511// m_log.InfoFormat(
513// "[XINVENTORY SERVICE]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder); 512// "[XINVENTORY SERVICE]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder);
514 513
515 InventoryItemBase retrievedItem = GetItem(item); 514 InventoryItemBase retrievedItem = GetItem(item.Owner, item.ID);
516 515
517 if (retrievedItem == null) 516 if (retrievedItem == null)
518 { 517 {
519 m_log.WarnFormat( 518 m_log.WarnFormat(
520 "[XINVENTORY SERVICE]: Tried to update item {0} {1}, owner {2} but no existing item found.", 519 "[XINVENTORY SERVICE]: Tried to update item {0} {1}, owner {2} but no existing item found.",
521 item.Name, item.ID, item.Owner); 520 item.Name, item.ID, item.Owner);
522 521
523 return false; 522 return false;
524 } 523 }
525 524
526 // Do not allow invariants to change. Changes to folder ID occur in MoveItems() 525 // Do not allow invariants to change. Changes to folder ID occur in MoveItems()
527 if (retrievedItem.InvType != item.InvType 526 if (retrievedItem.InvType != item.InvType
528 || retrievedItem.AssetType != item.AssetType 527 || retrievedItem.AssetType != item.AssetType
529 || retrievedItem.Folder != item.Folder 528 || retrievedItem.Folder != item.Folder
530 || retrievedItem.CreatorIdentification != item.CreatorIdentification 529 || retrievedItem.CreatorIdentification != item.CreatorIdentification
531 || retrievedItem.Owner != item.Owner) 530 || retrievedItem.Owner != item.Owner)
532 { 531 {
533 m_log.WarnFormat( 532 m_log.WarnFormat(
534 "[XINVENTORY SERVICE]: Caller to UpdateItem() for {0} {1} tried to alter property(s) that should be invariant, (InvType, AssetType, Folder, CreatorIdentification, Owner), existing ({2}, {3}, {4}, {5}, {6}), update ({7}, {8}, {9}, {10}, {11})", 533 "[XINVENTORY SERVICE]: Caller to UpdateItem() for {0} {1} tried to alter property(s) that should be invariant, (InvType, AssetType, Folder, CreatorIdentification, Owner), existing ({2}, {3}, {4}, {5}, {6}), update ({7}, {8}, {9}, {10}, {11})",
535 retrievedItem.Name, 534 retrievedItem.Name,
536 retrievedItem.ID, 535 retrievedItem.ID,
537 retrievedItem.InvType, 536 retrievedItem.InvType,
538 retrievedItem.AssetType, 537 retrievedItem.AssetType,
539 retrievedItem.Folder, 538 retrievedItem.Folder,
540 retrievedItem.CreatorIdentification, 539 retrievedItem.CreatorIdentification,
541 retrievedItem.Owner, 540 retrievedItem.Owner,
542 item.InvType, 541 item.InvType,
543 item.AssetType, 542 item.AssetType,
@@ -598,11 +597,11 @@ namespace OpenSim.Services.InventoryService
598 return true; 597 return true;
599 } 598 }
600 599
601 public virtual InventoryItemBase GetItem(InventoryItemBase item) 600 public virtual InventoryItemBase GetItem(UUID principalID, UUID itemID)
602 { 601 {
603 XInventoryItem[] items = m_Database.GetItems( 602 XInventoryItem[] items = m_Database.GetItems(
604 new string[] { "inventoryID" }, 603 new string[] { "inventoryID" },
605 new string[] { item.ID.ToString() }); 604 new string[] { itemID.ToString() });
606 605
607 if (items.Length == 0) 606 if (items.Length == 0)
608 return null; 607 return null;
@@ -614,22 +613,17 @@ namespace OpenSim.Services.InventoryService
614 { 613 {
615 InventoryItemBase[] items = new InventoryItemBase[ids.Length]; 614 InventoryItemBase[] items = new InventoryItemBase[ids.Length];
616 int i = 0; 615 int i = 0;
617 InventoryItemBase item = new InventoryItemBase();
618 item.Owner = userID;
619 foreach (UUID id in ids) 616 foreach (UUID id in ids)
620 { 617 items[i++] = GetItem(userID, id);
621 item.ID = id;
622 items[i++] = GetItem(item);
623 }
624 618
625 return items; 619 return items;
626 } 620 }
627 621
628 public virtual InventoryFolderBase GetFolder(InventoryFolderBase folder) 622 public virtual InventoryFolderBase GetFolder(UUID principalID, UUID folderID)
629 { 623 {
630 XInventoryFolder[] folders = m_Database.GetFolders( 624 XInventoryFolder[] folders = m_Database.GetFolders(
631 new string[] { "folderID"}, 625 new string[] { "folderID"},
632 new string[] { folder.ID.ToString() }); 626 new string[] { folderID.ToString() });
633 627
634 if (folders.Length == 0) 628 if (folders.Length == 0)
635 return null; 629 return null;
@@ -645,7 +639,7 @@ namespace OpenSim.Services.InventoryService
645 return new List<InventoryItemBase>(); 639 return new List<InventoryItemBase>();
646 640
647 List<InventoryItemBase> ret = new List<InventoryItemBase>(); 641 List<InventoryItemBase> ret = new List<InventoryItemBase>();
648 642
649 foreach (XInventoryItem x in items) 643 foreach (XInventoryItem x in items)
650 ret.Add(ConvertToOpenSim(x)); 644 ret.Add(ConvertToOpenSim(x));
651 645
diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
index c3756d0..823fd36 100644
--- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
@@ -55,12 +55,13 @@ namespace OpenSim.Services.LLLoginService
55 public static LLFailedLoginResponse InventoryProblem; 55 public static LLFailedLoginResponse InventoryProblem;
56 public static LLFailedLoginResponse DeadRegionProblem; 56 public static LLFailedLoginResponse DeadRegionProblem;
57 public static LLFailedLoginResponse LoginBlockedProblem; 57 public static LLFailedLoginResponse LoginBlockedProblem;
58 public static LLFailedLoginResponse UnverifiedAccountProblem;
58 public static LLFailedLoginResponse AlreadyLoggedInProblem; 59 public static LLFailedLoginResponse AlreadyLoggedInProblem;
59 public static LLFailedLoginResponse InternalError; 60 public static LLFailedLoginResponse InternalError;
60 61
61 static LLFailedLoginResponse() 62 static LLFailedLoginResponse()
62 { 63 {
63 UserProblem = new LLFailedLoginResponse("key", 64 UserProblem = new LLFailedLoginResponse("key",
64 "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", 65 "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.",
65 "false"); 66 "false");
66 GridProblem = new LLFailedLoginResponse("key", 67 GridProblem = new LLFailedLoginResponse("key",
@@ -75,11 +76,14 @@ namespace OpenSim.Services.LLLoginService
75 LoginBlockedProblem = new LLFailedLoginResponse("presence", 76 LoginBlockedProblem = new LLFailedLoginResponse("presence",
76 "Logins are currently restricted. Please try again later.", 77 "Logins are currently restricted. Please try again later.",
77 "false"); 78 "false");
79 UnverifiedAccountProblem = new LLFailedLoginResponse("presence",
80 "Your account has not yet been verified. Please check " +
81 "your email and click the provided link.",
82 "false");
78 AlreadyLoggedInProblem = new LLFailedLoginResponse("presence", 83 AlreadyLoggedInProblem = new LLFailedLoginResponse("presence",
79 "You appear to be already logged in. " + 84 "You appear to be already logged in. " +
80 "If this is not the case please wait for your session to timeout. " + 85 "Please wait a a minute or two and retry. " +
81 "If this takes longer than a few minutes please contact the grid owner. " + 86 "If this takes longer than a few minutes please contact the grid owner. ",
82 "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.",
83 "false"); 87 "false");
84 InternalError = new LLFailedLoginResponse("Internal Error", "Error generating Login Response", "false"); 88 InternalError = new LLFailedLoginResponse("Internal Error", "Error generating Login Response", "false");
85 } 89 }
@@ -145,6 +149,7 @@ namespace OpenSim.Services.LLLoginService
145 private UUID agentID; 149 private UUID agentID;
146 private UUID sessionID; 150 private UUID sessionID;
147 private UUID secureSessionID; 151 private UUID secureSessionID;
152 private UUID realID;
148 153
149 // Login Flags 154 // Login Flags
150 private string dst; 155 private string dst;
@@ -228,8 +233,9 @@ namespace OpenSim.Services.LLLoginService
228 public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, GridUserInfo pinfo, 233 public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, GridUserInfo pinfo,
229 GridRegion destination, List<InventoryFolderBase> invSkel, FriendInfo[] friendsList, ILibraryService libService, 234 GridRegion destination, List<InventoryFolderBase> invSkel, FriendInfo[] friendsList, ILibraryService libService,
230 string where, string startlocation, Vector3 position, Vector3 lookAt, List<InventoryItemBase> gestures, string message, 235 string where, string startlocation, Vector3 position, Vector3 lookAt, List<InventoryItemBase> gestures, string message,
231 GridRegion home, IPEndPoint clientIP, string mapTileURL, string searchURL, string currency, 236
232 string DSTZone, string destinationsURL, string avatarsURL, string classifiedFee, int maxAgentGroups) 237 GridRegion home, IPEndPoint clientIP, string mapTileURL, string profileURL, string openIDURL, string searchURL, string currency,
238 string DSTZone, string destinationsURL, string avatarsURL, UUID realID, string classifiedFee,int maxAgentGroups)
233 : this() 239 : this()
234 { 240 {
235 FillOutInventoryData(invSkel, libService); 241 FillOutInventoryData(invSkel, libService);
@@ -242,6 +248,7 @@ namespace OpenSim.Services.LLLoginService
242 AgentID = account.PrincipalID; 248 AgentID = account.PrincipalID;
243 SessionID = aCircuit.SessionID; 249 SessionID = aCircuit.SessionID;
244 SecureSessionID = aCircuit.SecureSessionID; 250 SecureSessionID = aCircuit.SecureSessionID;
251 RealID = realID;
245 Message = message; 252 Message = message;
246 BuddList = ConvertFriendListItem(friendsList); 253 BuddList = ConvertFriendListItem(friendsList);
247 StartLocation = where; 254 StartLocation = where;
@@ -299,7 +306,7 @@ namespace OpenSim.Services.LLLoginService
299 { 306 {
300 DST = dstTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; 307 DST = dstTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N";
301 } 308 }
302 309
303 break; 310 break;
304 } 311 }
305 } 312 }
@@ -383,6 +390,7 @@ namespace OpenSim.Services.LLLoginService
383 private void FillOutRegionData(GridRegion destination) 390 private void FillOutRegionData(GridRegion destination)
384 { 391 {
385 IPEndPoint endPoint = destination.ExternalEndPoint; 392 IPEndPoint endPoint = destination.ExternalEndPoint;
393 if (endPoint == null) return;
386 SimAddress = endPoint.Address.ToString(); 394 SimAddress = endPoint.Address.ToString();
387 SimPort = (uint)endPoint.Port; 395 SimPort = (uint)endPoint.Port;
388 RegionX = (uint)destination.RegionLocX; 396 RegionX = (uint)destination.RegionLocX;
@@ -408,7 +416,7 @@ namespace OpenSim.Services.LLLoginService
408// try 416// try
409// { 417// {
410// // First try to fetch DST from Pacific Standard Time, because this is 418// // First try to fetch DST from Pacific Standard Time, because this is
411// // the one expected by the viewer. "US/Pacific" is the string to search 419// // the one expected by the viewer. "US/Pacific" is the string to search
412// // on linux and mac, and should work also on Windows (to confirm) 420// // on linux and mac, and should work also on Windows (to confirm)
413// gridTimeZone = TimeZoneInfo.FindSystemTimeZoneById("US/Pacific"); 421// gridTimeZone = TimeZoneInfo.FindSystemTimeZoneById("US/Pacific");
414// } 422// }
@@ -438,7 +446,7 @@ namespace OpenSim.Services.LLLoginService
438 ErrorReason = "key"; 446 ErrorReason = "key";
439 welcomeMessage = "Welcome to OpenSim!"; 447 welcomeMessage = "Welcome to OpenSim!";
440 seedCapability = String.Empty; 448 seedCapability = String.Empty;
441 home = "{'region_handle':[" 449 home = "{'region_handle':["
442 + "r" + Util.RegionToWorldLoc(1000).ToString() 450 + "r" + Util.RegionToWorldLoc(1000).ToString()
443 + "," 451 + ","
444 + "r" + Util.RegionToWorldLoc(1000).ToString() 452 + "r" + Util.RegionToWorldLoc(1000).ToString()
@@ -473,6 +481,7 @@ namespace OpenSim.Services.LLLoginService
473 SessionID = UUID.Random(); 481 SessionID = UUID.Random();
474 SecureSessionID = UUID.Random(); 482 SecureSessionID = UUID.Random();
475 AgentID = UUID.Random(); 483 AgentID = UUID.Random();
484 RealID = UUID.Zero;
476 485
477 Hashtable InitialOutfitHash = new Hashtable(); 486 Hashtable InitialOutfitHash = new Hashtable();
478 InitialOutfitHash["folder_name"] = "Nightclub Female"; 487 InitialOutfitHash["folder_name"] = "Nightclub Female";
@@ -518,6 +527,7 @@ namespace OpenSim.Services.LLLoginService
518 responseData["http_port"] = (Int32)SimHttpPort; 527 responseData["http_port"] = (Int32)SimHttpPort;
519 528
520 responseData["agent_id"] = AgentID.ToString(); 529 responseData["agent_id"] = AgentID.ToString();
530 responseData["real_id"] = RealID.ToString();
521 responseData["session_id"] = SessionID.ToString(); 531 responseData["session_id"] = SessionID.ToString();
522 responseData["secure_session_id"] = SecureSessionID.ToString(); 532 responseData["secure_session_id"] = SecureSessionID.ToString();
523 responseData["circuit_code"] = CircuitCode; 533 responseData["circuit_code"] = CircuitCode;
@@ -582,7 +592,7 @@ namespace OpenSim.Services.LLLoginService
582 // responseData["real_currency"] = currency; 592 // responseData["real_currency"] = currency;
583 responseData["currency"] = currency; 593 responseData["currency"] = currency;
584 } 594 }
585 595
586 if (ClassifiedFee != String.Empty) 596 if (ClassifiedFee != String.Empty)
587 responseData["classified_fee"] = ClassifiedFee; 597 responseData["classified_fee"] = ClassifiedFee;
588 598
@@ -613,6 +623,7 @@ namespace OpenSim.Services.LLLoginService
613 map["sim_ip"] = OSD.FromString(SimAddress); 623 map["sim_ip"] = OSD.FromString(SimAddress);
614 624
615 map["agent_id"] = OSD.FromUUID(AgentID); 625 map["agent_id"] = OSD.FromUUID(AgentID);
626 map["real_id"] = OSD.FromUUID(RealID);
616 map["session_id"] = OSD.FromUUID(SessionID); 627 map["session_id"] = OSD.FromUUID(SessionID);
617 map["secure_session_id"] = OSD.FromUUID(SecureSessionID); 628 map["secure_session_id"] = OSD.FromUUID(SecureSessionID);
618 map["circuit_code"] = OSD.FromInteger(CircuitCode); 629 map["circuit_code"] = OSD.FromInteger(CircuitCode);
@@ -924,6 +935,12 @@ namespace OpenSim.Services.LLLoginService
924 set { secureSessionID = value; } 935 set { secureSessionID = value; }
925 } 936 }
926 937
938 public UUID RealID
939 {
940 get { return realID; }
941 set { realID = value; }
942 }
943
927 public Int32 CircuitCode 944 public Int32 CircuitCode
928 { 945 {
929 get { return circuitCode; } 946 get { return circuitCode; }
@@ -1052,7 +1069,7 @@ namespace OpenSim.Services.LLLoginService
1052 get { return activeGestures; } 1069 get { return activeGestures; }
1053 set { activeGestures = value; } 1070 set { activeGestures = value; }
1054 } 1071 }
1055 1072
1056 public string Home 1073 public string Home
1057 { 1074 {
1058 get { return home; } 1075 get { return home; }
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index 0b38738..cad0988 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -40,6 +40,7 @@ using OpenMetaverse;
40using OpenSim.Framework; 40using OpenSim.Framework;
41using OpenSim.Framework.Console; 41using OpenSim.Framework.Console;
42using OpenSim.Server.Base; 42using OpenSim.Server.Base;
43using OpenSim.Services.Connectors.InstantMessage;
43using OpenSim.Services.Interfaces; 44using OpenSim.Services.Interfaces;
44using GridRegion = OpenSim.Services.Interfaces.GridRegion; 45using GridRegion = OpenSim.Services.Interfaces.GridRegion;
45using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; 46using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
@@ -77,16 +78,19 @@ namespace OpenSim.Services.LLLoginService
77 protected string m_GatekeeperURL; 78 protected string m_GatekeeperURL;
78 protected bool m_AllowRemoteSetLoginLevel; 79 protected bool m_AllowRemoteSetLoginLevel;
79 protected string m_MapTileURL; 80 protected string m_MapTileURL;
81 protected string m_ProfileURL;
82 protected string m_OpenIDURL;
80 protected string m_SearchURL; 83 protected string m_SearchURL;
81 protected string m_Currency; 84 protected string m_Currency;
82 protected string m_ClassifiedFee; 85 protected string m_ClassifiedFee;
83 protected int m_MaxAgentGroups; 86 protected int m_MaxAgentGroups = 42;
84 protected string m_DestinationGuide; 87 protected string m_DestinationGuide;
85 protected string m_AvatarPicker; 88 protected string m_AvatarPicker;
86 protected string m_AllowedClients; 89 protected string m_AllowedClients;
87 protected string m_DeniedClients; 90 protected string m_DeniedClients;
88 protected string m_MessageUrl; 91 protected string m_MessageUrl;
89 protected string m_DSTZone; 92 protected string m_DSTZone;
93 protected bool m_allowDuplicatePresences = false;
90 94
91 IConfig m_LoginServerConfig; 95 IConfig m_LoginServerConfig;
92// IConfig m_ClientsConfig; 96// IConfig m_ClientsConfig;
@@ -117,6 +121,8 @@ namespace OpenSim.Services.LLLoginService
117 m_GatekeeperURL = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI", 121 m_GatekeeperURL = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI",
118 new string[] { "Startup", "Hypergrid", "LoginService" }, String.Empty); 122 new string[] { "Startup", "Hypergrid", "LoginService" }, String.Empty);
119 m_MapTileURL = m_LoginServerConfig.GetString("MapTileURL", string.Empty); 123 m_MapTileURL = m_LoginServerConfig.GetString("MapTileURL", string.Empty);
124 m_ProfileURL = m_LoginServerConfig.GetString("ProfileServerURL", string.Empty);
125 m_OpenIDURL = m_LoginServerConfig.GetString("OpenIDServerURL", String.Empty);
120 m_SearchURL = m_LoginServerConfig.GetString("SearchURL", string.Empty); 126 m_SearchURL = m_LoginServerConfig.GetString("SearchURL", string.Empty);
121 m_Currency = m_LoginServerConfig.GetString("Currency", string.Empty); 127 m_Currency = m_LoginServerConfig.GetString("Currency", string.Empty);
122 m_ClassifiedFee = m_LoginServerConfig.GetString("ClassifiedFee", string.Empty); 128 m_ClassifiedFee = m_LoginServerConfig.GetString("ClassifiedFee", string.Empty);
@@ -127,7 +133,7 @@ namespace OpenSim.Services.LLLoginService
127 m_AllowedClients = Util.GetConfigVarFromSections<string>( 133 m_AllowedClients = Util.GetConfigVarFromSections<string>(
128 config, "AllowedClients", possibleAccessControlConfigSections, string.Empty); 134 config, "AllowedClients", possibleAccessControlConfigSections, string.Empty);
129 m_DeniedClients = Util.GetConfigVarFromSections<string>( 135 m_DeniedClients = Util.GetConfigVarFromSections<string>(
130 config, "DeniedClients", possibleAccessControlConfigSections, string.Empty); 136 config, "DeniedClients", possibleAccessControlConfigSections, string.Empty);
131 137
132 m_MessageUrl = m_LoginServerConfig.GetString("MessageUrl", string.Empty); 138 m_MessageUrl = m_LoginServerConfig.GetString("MessageUrl", string.Empty);
133 m_DSTZone = m_LoginServerConfig.GetString("DSTZone", "America/Los_Angeles;Pacific Standard Time"); 139 m_DSTZone = m_LoginServerConfig.GetString("DSTZone", "America/Los_Angeles;Pacific Standard Time");
@@ -136,6 +142,11 @@ namespace OpenSim.Services.LLLoginService
136 if (groupConfig != null) 142 if (groupConfig != null)
137 m_MaxAgentGroups = groupConfig.GetInt("MaxAgentGroups", 42); 143 m_MaxAgentGroups = groupConfig.GetInt("MaxAgentGroups", 42);
138 144
145 IConfig presenceConfig = config.Configs["PresenceService"];
146 if (presenceConfig != null)
147 {
148 m_allowDuplicatePresences = presenceConfig.GetBoolean("AllowDuplicatePresences", m_allowDuplicatePresences);
149 }
139 150
140 // Clean up some of these vars 151 // Clean up some of these vars
141 if (m_MapTileURL != String.Empty) 152 if (m_MapTileURL != String.Empty)
@@ -155,7 +166,8 @@ namespace OpenSim.Services.LLLoginService
155 Object[] args = new Object[] { config }; 166 Object[] args = new Object[] { config };
156 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args); 167 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
157 m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args); 168 m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args);
158 m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args); 169 Object[] authArgs = new Object[] { config, m_UserAccountService };
170 m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, authArgs);
159 m_InventoryService = ServerUtils.LoadPlugin<IInventoryService>(invService, args); 171 m_InventoryService = ServerUtils.LoadPlugin<IInventoryService>(invService, args);
160 172
161 if (gridService != string.Empty) 173 if (gridService != string.Empty)
@@ -175,9 +187,14 @@ namespace OpenSim.Services.LLLoginService
175 string hgInvServicePlugin = m_LoginServerConfig.GetString("HGInventoryServicePlugin", String.Empty); 187 string hgInvServicePlugin = m_LoginServerConfig.GetString("HGInventoryServicePlugin", String.Empty);
176 if (hgInvServicePlugin != string.Empty) 188 if (hgInvServicePlugin != string.Empty)
177 { 189 {
190 // TODO: Remove HGInventoryServiceConstructorArg after 0.9 release
178 string hgInvServiceArg = m_LoginServerConfig.GetString("HGInventoryServiceConstructorArg", String.Empty); 191 string hgInvServiceArg = m_LoginServerConfig.GetString("HGInventoryServiceConstructorArg", String.Empty);
179 Object[] args2 = new Object[] { config, hgInvServiceArg }; 192 if (hgInvServiceArg != String.Empty)
180 m_HGInventoryService = ServerUtils.LoadPlugin<IInventoryService>(hgInvServicePlugin, args2); 193 {
194 m_log.Warn("[LLOGIN SERVICE]: You are using HGInventoryServiceConstructorArg, which is deprecated. See example file for correct syntax.");
195 hgInvServicePlugin = hgInvServiceArg + "@" + hgInvServicePlugin;
196 }
197 m_HGInventoryService = ServerUtils.LoadPlugin<IInventoryService>(hgInvServicePlugin, args);
181 } 198 }
182 199
183 // 200 //
@@ -260,16 +277,20 @@ namespace OpenSim.Services.LLLoginService
260 return response; 277 return response;
261 } 278 }
262 279
263 public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, UUID scopeID, 280 public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, UUID scopeID,
264 string clientVersion, string channel, string mac, string id0, IPEndPoint clientIP) 281 string clientVersion, string channel, string mac, string id0, IPEndPoint clientIP, bool LibOMVclient)
265 { 282 {
266 bool success = false; 283 bool success = false;
267 UUID session = UUID.Random(); 284 UUID session = UUID.Random();
285
268 string processedMessage; 286 string processedMessage;
269 287
270 m_log.InfoFormat("[LLOGIN SERVICE]: Login request for {0} {1} at {2} using viewer {3}, channel {4}, IP {5}, Mac {6}, Id0 {7}", 288 if (clientVersion.Contains("Radegast"))
271 firstName, lastName, startLocation, clientVersion, channel, clientIP.Address.ToString(), mac, id0); 289 LibOMVclient = false;
272 290
291 m_log.InfoFormat("[LLOGIN SERVICE]: Login request for {0} {1} at {2} using viewer {3}, channel {4}, IP {5}, Mac {6}, Id0 {7}, Possible LibOMVGridProxy: {8} ",
292 firstName, lastName, startLocation, clientVersion, channel, clientIP.Address.ToString(), mac, id0, LibOMVclient.ToString());
293
273 try 294 try
274 { 295 {
275 // 296 //
@@ -345,7 +366,8 @@ namespace OpenSim.Services.LLLoginService
345 if (!passwd.StartsWith("$1$")) 366 if (!passwd.StartsWith("$1$"))
346 passwd = "$1$" + Util.Md5Hash(passwd); 367 passwd = "$1$" + Util.Md5Hash(passwd);
347 passwd = passwd.Remove(0, 3); //remove $1$ 368 passwd = passwd.Remove(0, 3); //remove $1$
348 string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30); 369 UUID realID;
370 string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30, out realID);
349 UUID secureSession = UUID.Zero; 371 UUID secureSession = UUID.Zero;
350 if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession))) 372 if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession)))
351 { 373 {
@@ -355,6 +377,52 @@ namespace OpenSim.Services.LLLoginService
355 return LLFailedLoginResponse.UserProblem; 377 return LLFailedLoginResponse.UserProblem;
356 } 378 }
357 379
380 if(account.PrincipalID == new UUID("6571e388-6218-4574-87db-f9379718315e"))
381 {
382 // really?
383 return LLFailedLoginResponse.UserProblem;
384 }
385
386 string PrincipalIDstr = account.PrincipalID.ToString();
387 GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(PrincipalIDstr);
388
389 if(!m_allowDuplicatePresences)
390 {
391 if(guinfo != null && guinfo.Online && guinfo.LastRegionID != UUID.Zero)
392 {
393 // Also check Presence.UserID if RegionID == UUID.Zero, they are a ghost.
394 // Ghosting might be caused by failure to call PresenceService.LogoutAgent() on logout / crash / failed login.
395 // Might also need to double check if they are out hypergridding.
396
397 success = false;
398 if (m_PresenceService != null)
399 {
400 PresenceInfo pi = m_PresenceService.GetAgentByUser(account.PrincipalID);
401 if (null != pi)
402 {
403 Dictionary<string, object> pid = pi.ToKeyValuePairs();
404 if (pid["RegionID"].ToString() == UUID.Zero.ToString())
405 {
406 m_log.WarnFormat("[LLOGIN SERVICE]: Exorcising ghost avatar {0} {1}, session {2}, new session {3}.", firstName, lastName, pid["SessionID"], session);
407 success = m_PresenceService.LogoutAgent(new UUID(pid["SessionID"].ToString()));
408 if (success)
409 m_log.WarnFormat("[LLOGIN SERVICE]: Ghost avatar exorcised {0} {1}, session {2}, new session {3}.", firstName, lastName, pid["SessionID"], session);
410 else
411 m_log.ErrorFormat("[LLOGIN SERVICE]: Ghost avatar not exorcised {0} {1}, session {2}, new session {3}!", firstName, lastName, pid["SessionID"], session);
412 }
413 }
414 }
415
416 if ((!success) && SendAgentGodKillToRegion(scopeID, account.PrincipalID, guinfo))
417 {
418 m_log.InfoFormat(
419 "[LLOGIN SERVICE]: Login failed for {0} {1}, reason: already logged in",
420 firstName, lastName);
421 return LLFailedLoginResponse.AlreadyLoggedInProblem;
422 }
423 }
424 }
425
358 // 426 //
359 // Get the user's inventory 427 // Get the user's inventory
360 // 428 //
@@ -391,7 +459,7 @@ namespace OpenSim.Services.LLLoginService
391 // 459 //
392 if (m_PresenceService != null) 460 if (m_PresenceService != null)
393 { 461 {
394 success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession); 462 success = m_PresenceService.LoginAgent(PrincipalIDstr, session, secureSession);
395 463
396 if (!success) 464 if (!success)
397 { 465 {
@@ -406,7 +474,6 @@ namespace OpenSim.Services.LLLoginService
406 // Change Online status and get the home region 474 // Change Online status and get the home region
407 // 475 //
408 GridRegion home = null; 476 GridRegion home = null;
409 GridUserInfo guinfo = m_GridUserService.LoggedIn(account.PrincipalID.ToString());
410 477
411 // We are only going to complain about no home if the user actually tries to login there, to avoid 478 // We are only going to complain about no home if the user actually tries to login there, to avoid
412 // spamming the console. 479 // spamming the console.
@@ -437,7 +504,7 @@ namespace OpenSim.Services.LLLoginService
437 guinfo = new GridUserInfo(); 504 guinfo = new GridUserInfo();
438 guinfo.LastPosition = guinfo.HomePosition = new Vector3(128, 128, 30); 505 guinfo.LastPosition = guinfo.HomePosition = new Vector3(128, 128, 30);
439 } 506 }
440 507
441 // 508 //
442 // Find the destination region/grid 509 // Find the destination region/grid
443 // 510 //
@@ -445,7 +512,7 @@ namespace OpenSim.Services.LLLoginService
445 Vector3 position = Vector3.Zero; 512 Vector3 position = Vector3.Zero;
446 Vector3 lookAt = Vector3.Zero; 513 Vector3 lookAt = Vector3.Zero;
447 GridRegion gatekeeper = null; 514 GridRegion gatekeeper = null;
448 TeleportFlags flags; 515 Constants.TeleportFlags flags;
449 GridRegion destination = FindDestination(account, scopeID, guinfo, session, startLocation, home, out gatekeeper, out where, out position, out lookAt, out flags); 516 GridRegion destination = FindDestination(account, scopeID, guinfo, session, startLocation, home, out gatekeeper, out where, out position, out lookAt, out flags);
450 if (destination == null) 517 if (destination == null)
451 { 518 {
@@ -464,7 +531,7 @@ namespace OpenSim.Services.LLLoginService
464 } 531 }
465 532
466 if (account.UserLevel >= 200) 533 if (account.UserLevel >= 200)
467 flags |= TeleportFlags.Godlike; 534 flags |= Constants.TeleportFlags.Godlike;
468 // 535 //
469 // Get the avatar 536 // Get the avatar
470 // 537 //
@@ -479,7 +546,7 @@ namespace OpenSim.Services.LLLoginService
479 // 546 //
480 string reason = string.Empty; 547 string reason = string.Empty;
481 GridRegion dest; 548 GridRegion dest;
482 AgentCircuitData aCircuit = LaunchAgentAtGrid(gatekeeper, destination, account, avatar, session, secureSession, position, where, 549 AgentCircuitData aCircuit = LaunchAgentAtGrid(gatekeeper, destination, account, avatar, session, secureSession, position, where,
483 clientVersion, channel, mac, id0, clientIP, flags, out where, out reason, out dest); 550 clientVersion, channel, mac, id0, clientIP, flags, out where, out reason, out dest);
484 destination = dest; 551 destination = dest;
485 if (aCircuit == null) 552 if (aCircuit == null)
@@ -489,7 +556,11 @@ namespace OpenSim.Services.LLLoginService
489 return new LLFailedLoginResponse("key", reason, "false"); 556 return new LLFailedLoginResponse("key", reason, "false");
490 557
491 } 558 }
492 // Get Friends list 559
560 // only now we can assume a login
561 guinfo = m_GridUserService.LoggedIn(PrincipalIDstr);
562
563 // Get Friends list
493 FriendInfo[] friendsList = new FriendInfo[0]; 564 FriendInfo[] friendsList = new FriendInfo[0];
494 if (m_FriendsService != null) 565 if (m_FriendsService != null)
495 { 566 {
@@ -502,8 +573,8 @@ namespace OpenSim.Services.LLLoginService
502 // 573 //
503 if (m_MessageUrl != String.Empty) 574 if (m_MessageUrl != String.Empty)
504 { 575 {
505 WebClient client = new WebClient(); 576 using(WebClient client = new WebClient())
506 processedMessage = client.DownloadString(m_MessageUrl); 577 processedMessage = client.DownloadString(m_MessageUrl);
507 } 578 }
508 else 579 else
509 { 580 {
@@ -512,11 +583,11 @@ namespace OpenSim.Services.LLLoginService
512 processedMessage = processedMessage.Replace("\\n", "\n").Replace("<USERNAME>", firstName + " " + lastName); 583 processedMessage = processedMessage.Replace("\\n", "\n").Replace("<USERNAME>", firstName + " " + lastName);
513 584
514 LLLoginResponse response 585 LLLoginResponse response
515 = new LLLoginResponse( 586 = new LLLoginResponse(
516 account, aCircuit, guinfo, destination, inventorySkel, friendsList, m_LibraryService, 587 account, aCircuit, guinfo, destination, inventorySkel, friendsList, m_LibraryService,
517 where, startLocation, position, lookAt, gestures, processedMessage, home, clientIP, 588 where, startLocation, position, lookAt, gestures, processedMessage, home, clientIP,
518 m_MapTileURL, m_SearchURL, m_Currency, m_DSTZone, 589 m_MapTileURL, m_ProfileURL, m_OpenIDURL, m_SearchURL, m_Currency, m_DSTZone,
519 m_DestinationGuide, m_AvatarPicker, m_ClassifiedFee, m_MaxAgentGroups); 590 m_DestinationGuide, m_AvatarPicker, realID, m_ClassifiedFee,m_MaxAgentGroups);
520 591
521 m_log.DebugFormat("[LLOGIN SERVICE]: All clear. Sending login response to {0} {1}", firstName, lastName); 592 m_log.DebugFormat("[LLOGIN SERVICE]: All clear. Sending login response to {0} {1}", firstName, lastName);
522 593
@@ -534,9 +605,9 @@ namespace OpenSim.Services.LLLoginService
534 protected GridRegion FindDestination( 605 protected GridRegion FindDestination(
535 UserAccount account, UUID scopeID, GridUserInfo pinfo, UUID sessionID, string startLocation, 606 UserAccount account, UUID scopeID, GridUserInfo pinfo, UUID sessionID, string startLocation,
536 GridRegion home, out GridRegion gatekeeper, 607 GridRegion home, out GridRegion gatekeeper,
537 out string where, out Vector3 position, out Vector3 lookAt, out TeleportFlags flags) 608 out string where, out Vector3 position, out Vector3 lookAt, out Constants.TeleportFlags flags)
538 { 609 {
539 flags = TeleportFlags.ViaLogin; 610 flags = Constants.TeleportFlags.ViaLogin;
540 611
541 m_log.DebugFormat( 612 m_log.DebugFormat(
542 "[LLOGIN SERVICE]: Finding destination matching start location {0} for {1}", 613 "[LLOGIN SERVICE]: Finding destination matching start location {0} for {1}",
@@ -570,14 +641,15 @@ namespace OpenSim.Services.LLLoginService
570 641
571 position = pinfo.HomePosition; 642 position = pinfo.HomePosition;
572 lookAt = pinfo.HomeLookAt; 643 lookAt = pinfo.HomeLookAt;
573 flags |= TeleportFlags.ViaHome; 644 flags |= Constants.TeleportFlags.ViaHome;
574 } 645 }
575 646
576 if (tryDefaults) 647 if (tryDefaults)
577 { 648 {
578 List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID); 649 List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID);
579 if (defaults != null && defaults.Count > 0) 650 if (defaults != null && defaults.Count > 0)
580 { 651 {
652 flags |= Constants.TeleportFlags.ViaRegionID;
581 region = defaults[0]; 653 region = defaults[0];
582 where = "safe"; 654 where = "safe";
583 } 655 }
@@ -587,7 +659,10 @@ namespace OpenSim.Services.LLLoginService
587 account.FirstName, account.LastName); 659 account.FirstName, account.LastName);
588 region = FindAlternativeRegion(scopeID); 660 region = FindAlternativeRegion(scopeID);
589 if (region != null) 661 if (region != null)
662 {
663 flags |= Constants.TeleportFlags.ViaRegionID;
590 where = "safe"; 664 where = "safe";
665 }
591 } 666 }
592 } 667 }
593 668
@@ -608,6 +683,7 @@ namespace OpenSim.Services.LLLoginService
608 List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID); 683 List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID);
609 if (defaults != null && defaults.Count > 0) 684 if (defaults != null && defaults.Count > 0)
610 { 685 {
686 flags |= Constants.TeleportFlags.ViaRegionID;
611 region = defaults[0]; 687 region = defaults[0];
612 where = "safe"; 688 where = "safe";
613 } 689 }
@@ -616,7 +692,10 @@ namespace OpenSim.Services.LLLoginService
616 m_log.Info("[LLOGIN SERVICE]: Last Region Not Found Attempting to find random region"); 692 m_log.Info("[LLOGIN SERVICE]: Last Region Not Found Attempting to find random region");
617 region = FindAlternativeRegion(scopeID); 693 region = FindAlternativeRegion(scopeID);
618 if (region != null) 694 if (region != null)
695 {
696 flags |= Constants.TeleportFlags.ViaRegionID;
619 where = "safe"; 697 where = "safe";
698 }
620 } 699 }
621 700
622 } 701 }
@@ -625,12 +704,12 @@ namespace OpenSim.Services.LLLoginService
625 position = pinfo.LastPosition; 704 position = pinfo.LastPosition;
626 lookAt = pinfo.LastLookAt; 705 lookAt = pinfo.LastLookAt;
627 } 706 }
628 707
629 return region; 708 return region;
630 } 709 }
631 else 710 else
632 { 711 {
633 flags |= TeleportFlags.ViaRegionID; 712 flags |= Constants.TeleportFlags.ViaRegionID;
634 713
635 // free uri form 714 // free uri form
636 // e.g. New Moon&135&46 New Moon@osgrid.org:8002&153&34 715 // e.g. New Moon&135&46 New Moon@osgrid.org:8002&153&34
@@ -648,6 +727,8 @@ namespace OpenSim.Services.LLLoginService
648 position = new Vector3(float.Parse(uriMatch.Groups["x"].Value, Culture.NumberFormatInfo), 727 position = new Vector3(float.Parse(uriMatch.Groups["x"].Value, Culture.NumberFormatInfo),
649 float.Parse(uriMatch.Groups["y"].Value, Culture.NumberFormatInfo), 728 float.Parse(uriMatch.Groups["y"].Value, Culture.NumberFormatInfo),
650 float.Parse(uriMatch.Groups["z"].Value, Culture.NumberFormatInfo)); 729 float.Parse(uriMatch.Groups["z"].Value, Culture.NumberFormatInfo));
730 if (0 == position.Z)
731 flags |= Constants.TeleportFlags.ViaMap;
651 732
652 string regionName = uriMatch.Groups["region"].ToString(); 733 string regionName = uriMatch.Groups["region"].ToString();
653 if (regionName != null) 734 if (regionName != null)
@@ -661,7 +742,7 @@ namespace OpenSim.Services.LLLoginService
661 regions = m_GridService.GetDefaultRegions(scopeID); 742 regions = m_GridService.GetDefaultRegions(scopeID);
662 if (regions != null && regions.Count > 0) 743 if (regions != null && regions.Count > 0)
663 { 744 {
664 where = "safe"; 745 where = "safe";
665 return regions[0]; 746 return regions[0];
666 } 747 }
667 else 748 else
@@ -696,7 +777,7 @@ namespace OpenSim.Services.LLLoginService
696 return null; 777 return null;
697 } 778 }
698 // Valid specification of a remote grid 779 // Valid specification of a remote grid
699 780
700 regionName = parts[0]; 781 regionName = parts[0];
701 string domainLocator = parts[1]; 782 string domainLocator = parts[1];
702 parts = domainLocator.Split(new char[] {':'}); 783 parts = domainLocator.Split(new char[] {':'});
@@ -714,7 +795,7 @@ namespace OpenSim.Services.LLLoginService
714 List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID); 795 List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID);
715 if (defaults != null && defaults.Count > 0) 796 if (defaults != null && defaults.Count > 0)
716 { 797 {
717 where = "safe"; 798 where = "safe";
718 return defaults[0]; 799 return defaults[0];
719 } 800 }
720 else 801 else
@@ -767,12 +848,15 @@ namespace OpenSim.Services.LLLoginService
767 ulong handle; 848 ulong handle;
768 string imageURL = string.Empty, reason = string.Empty; 849 string imageURL = string.Empty, reason = string.Empty;
769 string message; 850 string message;
770 if (m_GatekeeperConnector.LinkRegion(gatekeeper, out regionID, out handle, out domainName, out imageURL, out reason)) 851 int sizeX = (int)Constants.RegionSize;
852 int sizeY = (int)Constants.RegionSize;
853
854 if (m_GatekeeperConnector.LinkRegion(gatekeeper, out regionID, out handle, out domainName, out imageURL, out reason, out sizeX, out sizeY))
771 { 855 {
772 string homeURI = null; 856 string homeURI = null;
773 if (account.ServiceURLs != null && account.ServiceURLs.ContainsKey("HomeURI")) 857 if (account.ServiceURLs != null && account.ServiceURLs.ContainsKey("HomeURI"))
774 homeURI = (string)account.ServiceURLs["HomeURI"]; 858 homeURI = (string)account.ServiceURLs["HomeURI"];
775 859
776 GridRegion destination = m_GatekeeperConnector.GetHyperlinkRegion(gatekeeper, regionID, account.PrincipalID, homeURI, out message); 860 GridRegion destination = m_GatekeeperConnector.GetHyperlinkRegion(gatekeeper, regionID, account.PrincipalID, homeURI, out message);
777 return destination; 861 return destination;
778 } 862 }
@@ -799,13 +883,16 @@ namespace OpenSim.Services.LLLoginService
799 883
800 protected AgentCircuitData LaunchAgentAtGrid(GridRegion gatekeeper, GridRegion destination, UserAccount account, AvatarAppearance avatar, 884 protected AgentCircuitData LaunchAgentAtGrid(GridRegion gatekeeper, GridRegion destination, UserAccount account, AvatarAppearance avatar,
801 UUID session, UUID secureSession, Vector3 position, string currentWhere, string viewer, string channel, string mac, string id0, 885 UUID session, UUID secureSession, Vector3 position, string currentWhere, string viewer, string channel, string mac, string id0,
802 IPEndPoint clientIP, TeleportFlags flags, out string where, out string reason, out GridRegion dest) 886 IPEndPoint clientIP, Constants.TeleportFlags flags, out string where, out string reason, out GridRegion dest)
803 { 887 {
804 where = currentWhere; 888 where = currentWhere;
805 ISimulationService simConnector = null; 889 ISimulationService simConnector = null;
806 reason = string.Empty; 890 reason = string.Empty;
807 uint circuitCode = 0; 891 uint circuitCode = 0;
808 AgentCircuitData aCircuit = null; 892 AgentCircuitData aCircuit = null;
893 dest = null;
894
895 bool success = false;
809 896
810 if (m_UserAgentService == null) 897 if (m_UserAgentService == null)
811 { 898 {
@@ -816,28 +903,14 @@ namespace OpenSim.Services.LLLoginService
816 simConnector = m_LocalSimulationService; 903 simConnector = m_LocalSimulationService;
817 else if (m_RemoteSimulationService != null) 904 else if (m_RemoteSimulationService != null)
818 simConnector = m_RemoteSimulationService; 905 simConnector = m_RemoteSimulationService;
819 }
820 else // User Agent Service is on
821 {
822 if (gatekeeper == null) // login to local grid
823 {
824 if (hostName == string.Empty)
825 SetHostAndPort(m_GatekeeperURL);
826
827 gatekeeper = new GridRegion(destination);
828 gatekeeper.ExternalHostName = hostName;
829 gatekeeper.HttpPort = (uint)port;
830 gatekeeper.ServerURI = m_GatekeeperURL;
831 }
832 m_log.Debug("[LLLOGIN SERVICE]: no gatekeeper detected..... using " + m_GatekeeperURL);
833 }
834 906
835 bool success = false; 907 if(simConnector == null)
908 return null;
836 909
837 if (m_UserAgentService == null && simConnector != null)
838 {
839 circuitCode = (uint)Util.RandomClass.Next(); ; 910 circuitCode = (uint)Util.RandomClass.Next(); ;
840 aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position, clientIP.Address.ToString(), viewer, channel, mac, id0); 911 aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position,
912 clientIP.Address.ToString(), viewer, channel, mac, id0);
913
841 success = LaunchAgentDirectly(simConnector, destination, aCircuit, flags, out reason); 914 success = LaunchAgentDirectly(simConnector, destination, aCircuit, flags, out reason);
842 if (!success && m_GridService != null) 915 if (!success && m_GridService != null)
843 { 916 {
@@ -847,7 +920,7 @@ namespace OpenSim.Services.LLLoginService
847 { 920 {
848 foreach (GridRegion r in fallbacks) 921 foreach (GridRegion r in fallbacks)
849 { 922 {
850 success = LaunchAgentDirectly(simConnector, r, aCircuit, flags | TeleportFlags.ViaRegionID, out reason); 923 success = LaunchAgentDirectly(simConnector, r, aCircuit, flags | Constants.TeleportFlags.ViaRegionID | Constants.TeleportFlags.ViaMap, out reason);
851 if (success) 924 if (success)
852 { 925 {
853 where = "safe"; 926 where = "safe";
@@ -859,10 +932,22 @@ namespace OpenSim.Services.LLLoginService
859 } 932 }
860 } 933 }
861 934
862 if (m_UserAgentService != null) 935 else
863 { 936 {
937 if (gatekeeper == null) // login to local grid
938 {
939 if (hostName == string.Empty)
940 SetHostAndPort(m_GatekeeperURL);
941
942 gatekeeper = new GridRegion(destination);
943 gatekeeper.ExternalHostName = hostName;
944 gatekeeper.HttpPort = (uint)port;
945 gatekeeper.ServerURI = m_GatekeeperURL;
946 }
864 circuitCode = (uint)Util.RandomClass.Next(); ; 947 circuitCode = (uint)Util.RandomClass.Next(); ;
865 aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position, clientIP.Address.ToString(), viewer, channel, mac, id0); 948 aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position,
949 clientIP.Address.ToString(), viewer, channel, mac, id0);
950
866 aCircuit.teleportFlags |= (uint)flags; 951 aCircuit.teleportFlags |= (uint)flags;
867 success = LaunchAgentIndirectly(gatekeeper, destination, aCircuit, clientIP, out reason); 952 success = LaunchAgentIndirectly(gatekeeper, destination, aCircuit, clientIP, out reason);
868 if (!success && m_GridService != null) 953 if (!success && m_GridService != null)
@@ -891,8 +976,8 @@ namespace OpenSim.Services.LLLoginService
891 return null; 976 return null;
892 } 977 }
893 978
894 private AgentCircuitData MakeAgent(GridRegion region, UserAccount account, 979 private AgentCircuitData MakeAgent(GridRegion region, UserAccount account,
895 AvatarAppearance avatar, UUID session, UUID secureSession, uint circuit, Vector3 position, 980 AvatarAppearance avatar, UUID session, UUID secureSession, uint circuit, Vector3 position,
896 string ipaddress, string viewer, string channel, string mac, string id0) 981 string ipaddress, string viewer, string channel, string mac, string id0)
897 { 982 {
898 AgentCircuitData aCircuit = new AgentCircuitData(); 983 AgentCircuitData aCircuit = new AgentCircuitData();
@@ -930,7 +1015,7 @@ namespace OpenSim.Services.LLLoginService
930 if (account.ServiceURLs == null) 1015 if (account.ServiceURLs == null)
931 return; 1016 return;
932 1017
933 // Old style: get the service keys from the DB 1018 // Old style: get the service keys from the DB
934 foreach (KeyValuePair<string, object> kvp in account.ServiceURLs) 1019 foreach (KeyValuePair<string, object> kvp in account.ServiceURLs)
935 { 1020 {
936 if (kvp.Value != null) 1021 if (kvp.Value != null)
@@ -981,7 +1066,7 @@ namespace OpenSim.Services.LLLoginService
981 1066
982 } 1067 }
983 1068
984 private bool LaunchAgentDirectly(ISimulationService simConnector, GridRegion region, AgentCircuitData aCircuit, TeleportFlags flags, out string reason) 1069 private bool LaunchAgentDirectly(ISimulationService simConnector, GridRegion region, AgentCircuitData aCircuit, Constants.TeleportFlags flags, out string reason)
985 { 1070 {
986 EntityTransferContext ctx = new EntityTransferContext(); 1071 EntityTransferContext ctx = new EntityTransferContext();
987 1072
@@ -989,7 +1074,7 @@ namespace OpenSim.Services.LLLoginService
989 region, aCircuit.AgentID, null, true, aCircuit.startpos, new List<UUID>(), ctx, out reason)) 1074 region, aCircuit.AgentID, null, true, aCircuit.startpos, new List<UUID>(), ctx, out reason))
990 return false; 1075 return false;
991 1076
992 return simConnector.CreateAgent(null, region, aCircuit, (uint)flags, out reason); 1077 return simConnector.CreateAgent(null, region, aCircuit, (uint)flags, ctx, out reason);
993 } 1078 }
994 1079
995 private bool LaunchAgentIndirectly(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, IPEndPoint clientIP, out string reason) 1080 private bool LaunchAgentIndirectly(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, IPEndPoint clientIP, out string reason)
@@ -1027,7 +1112,7 @@ namespace OpenSim.Services.LLLoginService
1027 switch (subcommand) 1112 switch (subcommand)
1028 { 1113 {
1029 case "level": 1114 case "level":
1030 // Set the minimum level to allow login 1115 // Set the minimum level to allow login
1031 // Useful to allow grid update without worrying about users. 1116 // Useful to allow grid update without worrying about users.
1032 // or fixing critical issues 1117 // or fixing critical issues
1033 // 1118 //
@@ -1040,8 +1125,8 @@ namespace OpenSim.Services.LLLoginService
1040 } 1125 }
1041 break; 1126 break;
1042 1127
1043 case "reset": 1128 case "reset":
1044 m_MinLoginLevel = 0; 1129 m_MinLoginLevel = m_LoginServerConfig.GetInt("MinLoginLevel", 0);
1045 MainConsole.Instance.OutputFormat("Reset min login level to {0}", m_MinLoginLevel); 1130 MainConsole.Instance.OutputFormat("Reset min login level to {0}", m_MinLoginLevel);
1046 break; 1131 break;
1047 1132
@@ -1054,6 +1139,41 @@ namespace OpenSim.Services.LLLoginService
1054 break; 1139 break;
1055 } 1140 }
1056 } 1141 }
1142
1143 private bool SendAgentGodKillToRegion(UUID scopeID, UUID agentID , GridUserInfo guinfo)
1144 {
1145 UUID regionID = guinfo.LastRegionID;
1146 GridRegion regInfo = m_GridService.GetRegionByUUID(scopeID, regionID);
1147 if(regInfo == null)
1148 return false;
1149
1150 string regURL = regInfo.ServerURI;
1151 if(String.IsNullOrEmpty(regURL))
1152 return false;
1153
1154 UUID guuid = new UUID("6571e388-6218-4574-87db-f9379718315e");
1155
1156 GridInstantMessage msg = new GridInstantMessage();
1157 msg.imSessionID = UUID.Zero.Guid;
1158 msg.fromAgentID = guuid.Guid;
1159 msg.toAgentID = agentID.Guid;
1160 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
1161 msg.fromAgentName = "GRID";
1162 msg.message = string.Format("New login detected");
1163 msg.dialog = 250; // God kick
1164 msg.fromGroup = false;
1165 msg.offline = (byte)0;
1166 msg.ParentEstateID = 0;
1167 msg.Position = Vector3.Zero;
1168 msg.RegionID = scopeID.Guid;
1169 msg.binaryBucket = new byte[1] {0};
1170 InstantMessageServiceConnector.SendInstantMessage(regURL,msg);
1171
1172 m_GridUserService.LoggedOut(agentID.ToString(),
1173 UUID.Zero, guinfo.LastRegionID, guinfo.LastPosition, guinfo.LastLookAt);
1174
1175 return true;
1176 }
1057 } 1177 }
1058 1178
1059 #endregion 1179 #endregion
diff --git a/OpenSim/Services/LLLoginService/Properties/AssemblyInfo.cs b/OpenSim/Services/LLLoginService/Properties/AssemblyInfo.cs
index 5c150e3..005ddd8 100644
--- a/OpenSim/Services/LLLoginService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/LLLoginService/Properties/AssemblyInfo.cs
@@ -2,7 +2,7 @@
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4 4
5// General Information about an assembly is controlled through the following 5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly. 7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Services.LLLoginService")] 8[assembly: AssemblyTitle("OpenSim.Services.LLLoginService")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
14[assembly: AssemblyTrademark("")] 14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")] 15[assembly: AssemblyCulture("")]
16 16
17// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)] 20[assembly: ComVisible(false)]
21 21
@@ -25,9 +25,9 @@ using System.Runtime.InteropServices;
25// Version information for an assembly consists of the following four values: 25// Version information for an assembly consists of the following four values:
26// 26//
27// Major Version 27// Major Version
28// Minor Version 28// Minor Version
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.8.3.*")] 32[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
33 33
diff --git a/OpenSim/Services/MapImageService/MapImageService.cs b/OpenSim/Services/MapImageService/MapImageService.cs
index 6b4a91a..e9db41d 100644
--- a/OpenSim/Services/MapImageService/MapImageService.cs
+++ b/OpenSim/Services/MapImageService/MapImageService.cs
@@ -23,8 +23,8 @@
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 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 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * 26 *
27 * The design of this map service is based on SimianGrid's PHP-based 27 * The design of this map service is based on SimianGrid's PHP-based
28 * map service. See this URL for the original PHP version: 28 * map service. See this URL for the original PHP version:
29 * https://github.com/openmetaversefoundation/simiangrid/ 29 * https://github.com/openmetaversefoundation/simiangrid/
30 */ 30 */
@@ -63,12 +63,14 @@ namespace OpenSim.Services.MapImageService
63 private const int HALF_WIDTH = 128; 63 private const int HALF_WIDTH = 128;
64 private const int JPEG_QUALITY = 80; 64 private const int JPEG_QUALITY = 80;
65 65
66 private static string m_TilesStoragePath = "maptiles"; 66 private static string m_TilesStoragePath = Path.Combine(Util.cacheDir(), "/maptiles");
67 67
68 private static object m_Sync = new object(); 68 private static object m_Sync = new object();
69 private static bool m_Initialized = false; 69 private static bool m_Initialized = false;
70 private static string m_WaterTileFile = string.Empty; 70 private static string m_WaterTileFile = string.Empty;
71 private static Color m_Watercolor = Color.FromArgb(29, 71, 95); 71 private static Color m_Watercolor = Color.FromArgb(29, 71, 95);
72 private static Bitmap m_WaterBitmap = null;
73 private static byte[] m_WaterBytes = null;
72 74
73 public MapImageService(IConfigSource config) 75 public MapImageService(IConfigSource config)
74 { 76 {
@@ -80,7 +82,7 @@ namespace OpenSim.Services.MapImageService
80 IConfig serviceConfig = config.Configs["MapImageService"]; 82 IConfig serviceConfig = config.Configs["MapImageService"];
81 if (serviceConfig != null) 83 if (serviceConfig != null)
82 { 84 {
83 m_TilesStoragePath = "../caches/" + serviceConfig.GetString("TilesStoragePath", m_TilesStoragePath); 85 m_TilesStoragePath = serviceConfig.GetString("TilesStoragePath", m_TilesStoragePath);
84 if (!Directory.Exists(m_TilesStoragePath)) 86 if (!Directory.Exists(m_TilesStoragePath))
85 Directory.CreateDirectory(m_TilesStoragePath); 87 Directory.CreateDirectory(m_TilesStoragePath);
86 88
@@ -91,6 +93,18 @@ namespace OpenSim.Services.MapImageService
91 Bitmap waterTile = new Bitmap(IMAGE_WIDTH, IMAGE_WIDTH); 93 Bitmap waterTile = new Bitmap(IMAGE_WIDTH, IMAGE_WIDTH);
92 FillImage(waterTile, m_Watercolor); 94 FillImage(waterTile, m_Watercolor);
93 waterTile.Save(m_WaterTileFile, ImageFormat.Jpeg); 95 waterTile.Save(m_WaterTileFile, ImageFormat.Jpeg);
96 m_WaterBitmap = waterTile;
97 }
98
99 if (File.Exists(m_WaterTileFile))
100 {
101 m_WaterBitmap = new Bitmap(m_WaterTileFile);
102 using (MemoryStream ms = new MemoryStream())
103 {
104 m_WaterBitmap.Save(ms,ImageFormat.Jpeg);
105 ms.Seek(0, SeekOrigin.Begin);
106 m_WaterBytes = ms.ToArray();
107 }
94 } 108 }
95 } 109 }
96 } 110 }
@@ -98,10 +112,10 @@ namespace OpenSim.Services.MapImageService
98 112
99 #region IMapImageService 113 #region IMapImageService
100 114
101 public bool AddMapTile(int x, int y, byte[] imageData, out string reason) 115 public bool AddMapTile(int x, int y, byte[] imageData, UUID scopeID, out string reason)
102 { 116 {
103 reason = string.Empty; 117 reason = string.Empty;
104 string fileName = GetFileName(1, x, y); 118 string fileName = GetFileName(1, x, y, scopeID);
105 119
106 lock (m_Sync) 120 lock (m_Sync)
107 { 121 {
@@ -118,13 +132,13 @@ namespace OpenSim.Services.MapImageService
118 } 132 }
119 } 133 }
120 134
121 return UpdateMultiResolutionFilesAsync(x, y, out reason); 135 return UpdateMultiResolutionFiles(x, y, scopeID, out reason);
122 } 136 }
123 137
124 public bool RemoveMapTile(int x, int y, out string reason) 138 public bool RemoveMapTile(int x, int y, UUID scopeID, out string reason)
125 { 139 {
126 reason = String.Empty; 140 reason = String.Empty;
127 string fileName = GetFileName(1, x, y); 141 string fileName = GetFileName(1, x, y, scopeID);
128 142
129 lock (m_Sync) 143 lock (m_Sync)
130 { 144 {
@@ -134,15 +148,16 @@ namespace OpenSim.Services.MapImageService
134 } 148 }
135 catch (Exception e) 149 catch (Exception e)
136 { 150 {
151
137 m_log.WarnFormat("[MAP IMAGE SERVICE]: Unable to save delete file {0}: {1}", fileName, e); 152 m_log.WarnFormat("[MAP IMAGE SERVICE]: Unable to save delete file {0}: {1}", fileName, e);
138 reason = e.Message; 153 reason = e.Message;
139 return false; 154 return false;
140 } 155 }
141 } 156 }
142 157 return UpdateMultiResolutionFiles(x, y, scopeID, out reason);
143 return UpdateMultiResolutionFilesAsync(x, y, out reason);
144 } 158 }
145 159
160
146 // When large varregions start up, they can send piles of new map tiles. This causes 161 // When large varregions start up, they can send piles of new map tiles. This causes
147 // this multi-resolution routine to be called a zillion times an causes much CPU 162 // this multi-resolution routine to be called a zillion times an causes much CPU
148 // time to be spent creating multi-resolution tiles that will be replaced when 163 // time to be spent creating multi-resolution tiles that will be replaced when
@@ -151,23 +166,27 @@ namespace OpenSim.Services.MapImageService
151 { 166 {
152 public int xx; 167 public int xx;
153 public int yy; 168 public int yy;
154 public mapToMultiRez(int pX, int pY) 169 public UUID scopeID;
170 public mapToMultiRez(int pX, int pY, UUID pscopeID)
155 { 171 {
156 xx = pX; 172 xx = pX;
157 yy = pY; 173 yy = pY;
174 scopeID = pscopeID;
158 } 175 }
159 }; 176 };
160 private Queue<mapToMultiRez> multiRezToBuild = new Queue<mapToMultiRez>(); 177 private Queue<mapToMultiRez> multiRezToBuild = new Queue<mapToMultiRez>();
161 private bool UpdateMultiResolutionFilesAsync(int x, int y, out string reason) 178
179 private bool UpdateMultiResolutionFiles(int x, int y, UUID scopeID, out string reason)
162 { 180 {
163 reason = String.Empty; 181 reason = String.Empty;
182
164 lock (multiRezToBuild) 183 lock (multiRezToBuild)
165 { 184 {
166 // m_log.DebugFormat("{0} UpdateMultiResolutionFilesAsync: scheduling update for <{1},{2}>", LogHeader, x, y); 185 // m_log.DebugFormat("{0} UpdateMultiResolutionFilesAsync: scheduling update for <{1},{2}>", LogHeader, x, y);
167 multiRezToBuild.Enqueue(new mapToMultiRez(x, y)); 186 multiRezToBuild.Enqueue(new mapToMultiRez(x, y, scopeID));
168 if (multiRezToBuild.Count == 1) 187 if (multiRezToBuild.Count == 1)
169 Util.FireAndForget( 188 Util.FireAndForget(
170 DoUpdateMultiResolutionFilesAsync, null, "MapImageService.DoUpdateMultiResolutionFilesAsync"); 189 DoUpdateMultiResolutionFilesAsync);
171 } 190 }
172 191
173 return true; 192 return true;
@@ -175,10 +194,8 @@ namespace OpenSim.Services.MapImageService
175 194
176 private void DoUpdateMultiResolutionFilesAsync(object o) 195 private void DoUpdateMultiResolutionFilesAsync(object o)
177 { 196 {
178 // This sleep causes the FireAndForget thread to be different than the invocation thread. 197 // let acumulate large region tiles
179 // It also allows other tiles to be uploaded so the multi-rez images are more likely 198 Thread.Sleep(60 * 1000); // large regions take time to upload tiles
180 // to be correct.
181 Thread.Sleep(1 * 1000);
182 199
183 while (multiRezToBuild.Count > 0) 200 while (multiRezToBuild.Count > 0)
184 { 201 {
@@ -192,20 +209,23 @@ namespace OpenSim.Services.MapImageService
192 { 209 {
193 int x = toMultiRez.xx; 210 int x = toMultiRez.xx;
194 int y = toMultiRez.yy; 211 int y = toMultiRez.yy;
212 UUID scopeID = toMultiRez.scopeID;
195 // m_log.DebugFormat("{0} DoUpdateMultiResolutionFilesAsync: doing build for <{1},{2}>", LogHeader, x, y); 213 // m_log.DebugFormat("{0} DoUpdateMultiResolutionFilesAsync: doing build for <{1},{2}>", LogHeader, x, y);
196 214
215 int width = 1;
216
197 // Stitch seven more aggregate tiles together 217 // Stitch seven more aggregate tiles together
198 for (uint zoomLevel = 2; zoomLevel <= ZOOM_LEVELS; zoomLevel++) 218 for (uint zoomLevel = 2; zoomLevel <= ZOOM_LEVELS; zoomLevel++)
199 { 219 {
200 // Calculate the width (in full resolution tiles) and bottom-left 220 // Calculate the width (in full resolution tiles) and bottom-left
201 // corner of the current zoom level 221 // corner of the current zoom level
202 int width = (int)Math.Pow(2, (double)(zoomLevel - 1)); 222 width *= 2;
203 int x1 = x - (x % width); 223 int x1 = x - (x % width);
204 int y1 = y - (y % width); 224 int y1 = y - (y % width);
205 225
206 lock (m_Sync) // must lock the reading and writing of the maptile files 226 lock (m_Sync) // must lock the reading and writing of the maptile files
207 { 227 {
208 if (!CreateTile(zoomLevel, x1, y1)) 228 if (!CreateTile(zoomLevel, x1, y1, scopeID))
209 { 229 {
210 m_log.WarnFormat("[MAP IMAGE SERVICE]: Unable to create tile for {0},{1} at zoom level {1}", x, y, zoomLevel); 230 m_log.WarnFormat("[MAP IMAGE SERVICE]: Unable to create tile for {0},{1} at zoom level {1}", x, y, zoomLevel);
211 return; 231 return;
@@ -214,25 +234,25 @@ namespace OpenSim.Services.MapImageService
214 } 234 }
215 } 235 }
216 } 236 }
217
218 return; 237 return;
219 } 238 }
220 239
221 public byte[] GetMapTile(string fileName, out string format) 240 public byte[] GetMapTile(string fileName, UUID scopeID, out string format)
222 { 241 {
223// m_log.DebugFormat("[MAP IMAGE SERVICE]: Getting map tile {0}", fileName); 242// m_log.DebugFormat("[MAP IMAGE SERVICE]: Getting map tile {0}", fileName);
224 243
225 format = ".jpg"; 244 format = ".jpg";
226 string fullName = Path.Combine(m_TilesStoragePath, fileName); 245 string fullName = Path.Combine(m_TilesStoragePath, scopeID.ToString());
246 fullName = Path.Combine(fullName, fileName);
227 if (File.Exists(fullName)) 247 if (File.Exists(fullName))
228 { 248 {
229 format = Path.GetExtension(fileName).ToLower(); 249 format = Path.GetExtension(fileName).ToLower();
230 //m_log.DebugFormat("[MAP IMAGE SERVICE]: Found file {0}, extension {1}", fileName, format); 250 //m_log.DebugFormat("[MAP IMAGE SERVICE]: Found file {0}, extension {1}", fileName, format);
231 return File.ReadAllBytes(fullName); 251 return File.ReadAllBytes(fullName);
232 } 252 }
233 else if (File.Exists(m_WaterTileFile)) 253 else if (m_WaterBytes != null)
234 { 254 {
235 return File.ReadAllBytes(m_WaterTileFile); 255 return (byte[])m_WaterBytes.Clone();
236 } 256 }
237 else 257 else
238 { 258 {
@@ -244,10 +264,12 @@ namespace OpenSim.Services.MapImageService
244 #endregion 264 #endregion
245 265
246 266
247 private string GetFileName(uint zoomLevel, int x, int y) 267 private string GetFileName(uint zoomLevel, int x, int y, UUID scopeID)
248 { 268 {
249 string extension = "jpg"; 269 string extension = "jpg";
250 return Path.Combine(m_TilesStoragePath, string.Format("map-{0}-{1}-{2}-objects.{3}", zoomLevel, x, y, extension)); 270 string path = Path.Combine(m_TilesStoragePath, scopeID.ToString());
271 Directory.CreateDirectory(path);
272 return Path.Combine(path, string.Format("map-{0}-{1}-{2}-objects.{3}", zoomLevel, x, y, extension));
251 } 273 }
252 274
253 private Bitmap GetInputTileImage(string fileName) 275 private Bitmap GetInputTileImage(string fileName)
@@ -269,14 +291,14 @@ namespace OpenSim.Services.MapImageService
269 { 291 {
270 try 292 try
271 { 293 {
272 if (File.Exists(fileName)) 294 if (File.Exists(fileName))
273 return new Bitmap(fileName); 295 return new Bitmap(fileName);
274 296
275 else 297 else
276 { 298 {
277 // Create a new output tile with a transparent background 299 // Create a new output tile with a transparent background
278 Bitmap bm = new Bitmap(IMAGE_WIDTH, IMAGE_WIDTH, PixelFormat.Format24bppRgb); 300 Bitmap bm = new Bitmap(IMAGE_WIDTH, IMAGE_WIDTH, PixelFormat.Format24bppRgb);
279 bm.MakeTransparent(); 301 //bm.MakeTransparent(); // 24bpp does not have transparency, this would make it 32bpp
280 return bm; 302 return bm;
281 } 303 }
282 } 304 }
@@ -288,7 +310,7 @@ namespace OpenSim.Services.MapImageService
288 return null; 310 return null;
289 } 311 }
290 312
291 private bool CreateTile(uint zoomLevel, int x, int y) 313 private bool CreateTile(uint zoomLevel, int x, int y, UUID scopeID)
292 { 314 {
293// m_log.DebugFormat("[MAP IMAGE SERVICE]: Create tile for {0} {1}, zoom {2}", x, y, zoomLevel); 315// m_log.DebugFormat("[MAP IMAGE SERVICE]: Create tile for {0} {1}, zoom {2}", x, y, zoomLevel);
294 int prevWidth = (int)Math.Pow(2, (double)zoomLevel - 2); 316 int prevWidth = (int)Math.Pow(2, (double)zoomLevel - 2);
@@ -303,55 +325,60 @@ namespace OpenSim.Services.MapImageService
303 int yOut = y - (y % thisWidth); 325 int yOut = y - (y % thisWidth);
304 326
305 // Try to open the four input tiles from the previous zoom level 327 // Try to open the four input tiles from the previous zoom level
306 Bitmap inputBL = GetInputTileImage(GetFileName(zoomLevel - 1, xIn, yIn)); 328 Bitmap inputBL = GetInputTileImage(GetFileName(zoomLevel - 1, xIn, yIn, scopeID));
307 Bitmap inputBR = GetInputTileImage(GetFileName(zoomLevel - 1, xIn + prevWidth, yIn)); 329 Bitmap inputBR = GetInputTileImage(GetFileName(zoomLevel - 1, xIn + prevWidth, yIn, scopeID));
308 Bitmap inputTL = GetInputTileImage(GetFileName(zoomLevel - 1, xIn, yIn + prevWidth)); 330 Bitmap inputTL = GetInputTileImage(GetFileName(zoomLevel - 1, xIn, yIn + prevWidth, scopeID));
309 Bitmap inputTR = GetInputTileImage(GetFileName(zoomLevel - 1, xIn + prevWidth, yIn + prevWidth)); 331 Bitmap inputTR = GetInputTileImage(GetFileName(zoomLevel - 1, xIn + prevWidth, yIn + prevWidth, scopeID));
310 332
311 // Open the output tile (current zoom level) 333 // Open the output tile (current zoom level)
312 string outputFile = GetFileName(zoomLevel, xOut, yOut); 334 string outputFile = GetFileName(zoomLevel, xOut, yOut, scopeID);
313 Bitmap output = GetOutputTileImage(outputFile); 335
314 if (output == null) 336 int ntiles = 0;
315 return false; 337 Bitmap output = (Bitmap)m_WaterBitmap.Clone();
316 FillImage(output, m_Watercolor);
317 338
318 if (inputBL != null) 339 if (inputBL != null)
319 { 340 {
320 ImageCopyResampled(output, inputBL, 0, HALF_WIDTH, 0, 0); 341 ImageCopyResampled(output, inputBL, 0, HALF_WIDTH, 0, 0);
321 inputBL.Dispose(); 342 inputBL.Dispose();
343 ntiles++;
322 } 344 }
323 if (inputBR != null) 345 if (inputBR != null)
324 { 346 {
325 ImageCopyResampled(output, inputBR, HALF_WIDTH, HALF_WIDTH, 0, 0); 347 ImageCopyResampled(output, inputBR, HALF_WIDTH, HALF_WIDTH, 0, 0);
326 inputBR.Dispose(); 348 inputBR.Dispose();
349 ntiles++;
327 } 350 }
328 if (inputTL != null) 351 if (inputTL != null)
329 { 352 {
330 ImageCopyResampled(output, inputTL, 0, 0, 0, 0); 353 ImageCopyResampled(output, inputTL, 0, 0, 0, 0);
331 inputTL.Dispose(); 354 inputTL.Dispose();
355 ntiles++;
332 } 356 }
333 if (inputTR != null) 357 if (inputTR != null)
334 { 358 {
335 ImageCopyResampled(output, inputTR, HALF_WIDTH, 0, 0, 0); 359 ImageCopyResampled(output, inputTR, HALF_WIDTH, 0, 0, 0);
336 inputTR.Dispose(); 360 inputTR.Dispose();
361 ntiles++;
337 } 362 }
338 363
339 // Write the modified output 364 // Write the modified output
340 try 365 if (ntiles == 0)
366 File.Delete(outputFile);
367
368 else
341 { 369 {
342 using (Bitmap final = new Bitmap(output)) 370
371 try
343 { 372 {
344 output.Dispose(); 373 output.Save(outputFile, ImageFormat.Jpeg);
345 final.Save(outputFile, ImageFormat.Jpeg);
346 } 374 }
347 } 375 catch (Exception e)
348 catch (Exception e) 376 {
349 { 377 m_log.WarnFormat("[MAP IMAGE SERVICE]: Oops on saving {0} {1}", outputFile, e);
350 m_log.WarnFormat("[MAP IMAGE SERVICE]: Oops on saving {0} {1}", outputFile, e); 378 }
351 } 379 } // Save also as png?
352
353 // Save also as png?
354 380
381 output.Dispose();
355 return true; 382 return true;
356 } 383 }
357 384
diff --git a/OpenSim/Services/MapImageService/Properties/AssemblyInfo.cs b/OpenSim/Services/MapImageService/Properties/AssemblyInfo.cs
index e779238..8f4b9b9 100644
--- a/OpenSim/Services/MapImageService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/MapImageService/Properties/AssemblyInfo.cs
@@ -2,7 +2,7 @@
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4 4
5// General Information about an assembly is controlled through the following 5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly. 7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Services.MapImageService")] 8[assembly: AssemblyTitle("OpenSim.Services.MapImageService")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
14[assembly: AssemblyTrademark("")] 14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")] 15[assembly: AssemblyCulture("")]
16 16
17// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)] 20[assembly: ComVisible(false)]
21 21
@@ -25,9 +25,9 @@ using System.Runtime.InteropServices;
25// Version information for an assembly consists of the following four values: 25// Version information for an assembly consists of the following four values:
26// 26//
27// Major Version 27// Major Version
28// Minor Version 28// Minor Version
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.8.3.*")] 32[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
33 33
diff --git a/OpenSim/Services/MuteListService/MuteListService.cs b/OpenSim/Services/MuteListService/MuteListService.cs
new file mode 100644
index 0000000..7e5ded1
--- /dev/null
+++ b/OpenSim/Services/MuteListService/MuteListService.cs
@@ -0,0 +1,127 @@
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.Text;
30using OpenMetaverse;
31using log4net;
32using Nini.Config;
33using OpenSim.Services.Base;
34using OpenSim.Services.Interfaces;
35using OpenSim.Data;
36using OpenSim.Framework;
37
38namespace OpenSim.Services.EstateService
39{
40 public class MuteListService : ServiceBase, IMuteListService
41 {
42// private static readonly ILog m_log =
43// LogManager.GetLogger(
44// MethodBase.GetCurrentMethod().DeclaringType);
45
46 protected IMuteListData m_database;
47
48 public MuteListService(IConfigSource config)
49 : base(config)
50 {
51 string dllName = String.Empty;
52 string connString = String.Empty;
53
54 // Try reading the [DatabaseService] section, if it exists
55 IConfig dbConfig = config.Configs["DatabaseService"];
56 if (dbConfig != null)
57 {
58 dllName = dbConfig.GetString("StorageProvider", String.Empty);
59 connString = dbConfig.GetString("ConnectionString", String.Empty);
60 connString = dbConfig.GetString("MuteConnectionString", connString);
61 }
62
63 // Try reading the [MuteListStore] section, if it exists
64 IConfig muteConfig = config.Configs["MuteListStore"];
65 if (muteConfig != null)
66 {
67 dllName = muteConfig.GetString("StorageProvider", dllName);
68 connString = muteConfig.GetString("ConnectionString", connString);
69 }
70
71 // We tried, but this doesn't exist. We can't proceed
72 if (dllName == String.Empty)
73 throw new Exception("No StorageProvider configured");
74
75 m_database = LoadPlugin<IMuteListData>(dllName, new Object[] { connString });
76 if (m_database == null)
77 throw new Exception("Could not find a storage interface in the given module");
78 }
79
80 public Byte[] MuteListRequest(UUID agentID, uint crc)
81 {
82 if(m_database == null)
83 return null;
84
85 MuteData[] data = m_database.Get(agentID);
86 if (data == null || data.Length == 0)
87 return new Byte[0];
88
89 StringBuilder sb = new StringBuilder(16384);
90 foreach (MuteData d in data)
91 sb.AppendFormat("{0} {1} {2}|{3}\n",
92 d.MuteType,
93 d.MuteID.ToString(),
94 d.MuteName,
95 d.MuteFlags);
96
97 Byte[] filedata = Util.UTF8.GetBytes(sb.ToString());
98
99 uint dataCrc = Crc32.Compute(filedata);
100
101 if (dataCrc == crc)
102 {
103 if(crc == 0)
104 return new Byte[0];
105
106 Byte[] ret = new Byte[1] {1};
107 return ret;
108 }
109
110 return filedata;
111 }
112
113 public bool UpdateMute(MuteData mute)
114 {
115 if(m_database == null)
116 return false;
117 return m_database.Store(mute);
118 }
119
120 public bool RemoveMute(UUID agentID, UUID muteID, string muteName)
121 {
122 if(m_database == null)
123 return false;
124 return m_database.Delete(agentID, muteID, muteName);
125 }
126 }
127}
diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs
index b5ca4d5..1059b2b 100644
--- a/OpenSim/Services/PresenceService/PresenceService.cs
+++ b/OpenSim/Services/PresenceService/PresenceService.cs
@@ -71,7 +71,7 @@ namespace OpenSim.Services.PresenceService
71 data.SessionID = sessionID; 71 data.SessionID = sessionID;
72 data.Data = new Dictionary<string, string>(); 72 data.Data = new Dictionary<string, string>();
73 data.Data["SecureSessionID"] = secureSessionID.ToString(); 73 data.Data["SecureSessionID"] = secureSessionID.ToString();
74 74
75 m_Database.Store(data); 75 m_Database.Store(data);
76 76
77 string prevUserStr = ""; 77 string prevUserStr = "";
@@ -80,7 +80,7 @@ namespace OpenSim.Services.PresenceService
80 80
81 m_log.DebugFormat("[PRESENCE SERVICE]: LoginAgent: session {0}, user {1}, region {2}, secure session {3}{4}", 81 m_log.DebugFormat("[PRESENCE SERVICE]: LoginAgent: session {0}, user {1}, region {2}, secure session {3}{4}",
82 data.SessionID, data.UserID, data.RegionID, secureSessionID, prevUserStr); 82 data.SessionID, data.UserID, data.RegionID, secureSessionID, prevUserStr);
83 83
84 return true; 84 return true;
85 } 85 }
86 86
@@ -92,7 +92,7 @@ namespace OpenSim.Services.PresenceService
92 sessionID, 92 sessionID,
93 (presence == null) ? null : presence.UserID, 93 (presence == null) ? null : presence.UserID,
94 (presence == null) ? null : presence.RegionID.ToString()); 94 (presence == null) ? null : presence.RegionID.ToString());
95 95
96 return m_Database.Delete("SessionID", sessionID.ToString()); 96 return m_Database.Delete("SessionID", sessionID.ToString());
97 } 97 }
98 98
@@ -144,13 +144,29 @@ namespace OpenSim.Services.PresenceService
144 public PresenceInfo GetAgent(UUID sessionID) 144 public PresenceInfo GetAgent(UUID sessionID)
145 { 145 {
146 PresenceInfo ret = new PresenceInfo(); 146 PresenceInfo ret = new PresenceInfo();
147 147
148 PresenceData data = m_Database.Get(sessionID); 148 PresenceData data = m_Database.Get(sessionID);
149 if (data == null) 149 if (data == null)
150 return null; 150 return null;
151 151
152 ret.UserID = data.UserID; 152 ret.UserID = data.UserID;
153 ret.RegionID = data.RegionID; 153 ret.RegionID = data.RegionID;
154 ret.SessionID = data.SessionID;
155
156 return ret;
157 }
158
159 public PresenceInfo GetAgentByUser(UUID userID)
160 {
161 PresenceInfo ret = new PresenceInfo();
162
163 PresenceData data = m_Database.GetByUser(userID);
164 if (data == null)
165 return null;
166
167 ret.UserID = data.UserID;
168 ret.RegionID = data.RegionID;
169 ret.SessionID = data.SessionID;
154 170
155 return ret; 171 return ret;
156 } 172 }
@@ -169,6 +185,7 @@ namespace OpenSim.Services.PresenceService
169 185
170 ret.UserID = d.UserID; 186 ret.UserID = d.UserID;
171 ret.RegionID = d.RegionID; 187 ret.RegionID = d.RegionID;
188 ret.SessionID = d.SessionID;
172 189
173 info.Add(ret); 190 info.Add(ret);
174 } 191 }
diff --git a/OpenSim/Services/PresenceService/PresenceServiceBase.cs b/OpenSim/Services/PresenceService/PresenceServiceBase.cs
index a4adb2f..7647865 100644
--- a/OpenSim/Services/PresenceService/PresenceServiceBase.cs
+++ b/OpenSim/Services/PresenceService/PresenceServiceBase.cs
@@ -68,7 +68,7 @@ namespace OpenSim.Services.PresenceService
68 connString = presenceConfig.GetString("ConnectionString", connString); 68 connString = presenceConfig.GetString("ConnectionString", connString);
69 realm = presenceConfig.GetString("Realm", realm); 69 realm = presenceConfig.GetString("Realm", realm);
70 } 70 }
71 71
72 // 72 //
73 // We tried, but this doesn't exist. We can't proceed. 73 // We tried, but this doesn't exist. We can't proceed.
74 // 74 //
diff --git a/OpenSim/Services/PresenceService/Properties/AssemblyInfo.cs b/OpenSim/Services/PresenceService/Properties/AssemblyInfo.cs
index 4fd21a8..a79bc9f 100644
--- a/OpenSim/Services/PresenceService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/PresenceService/Properties/AssemblyInfo.cs
@@ -2,7 +2,7 @@
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4 4
5// General Information about an assembly is controlled through the following 5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly. 7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Services.PresenceService")] 8[assembly: AssemblyTitle("OpenSim.Services.PresenceService")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
14[assembly: AssemblyTrademark("")] 14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")] 15[assembly: AssemblyCulture("")]
16 16
17// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)] 20[assembly: ComVisible(false)]
21 21
@@ -25,9 +25,9 @@ using System.Runtime.InteropServices;
25// Version information for an assembly consists of the following four values: 25// Version information for an assembly consists of the following four values:
26// 26//
27// Major Version 27// Major Version
28// Minor Version 28// Minor Version
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.8.3.*")] 32[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
33 33
diff --git a/OpenSim/Services/SimulationService/SimulationDataService.cs b/OpenSim/Services/SimulationService/SimulationDataService.cs
index d9684c4..eef958a 100644
--- a/OpenSim/Services/SimulationService/SimulationDataService.cs
+++ b/OpenSim/Services/SimulationService/SimulationDataService.cs
@@ -104,6 +104,11 @@ namespace OpenSim.Services.SimulationService
104 m_database.StoreTerrain(terrain, regionID); 104 m_database.StoreTerrain(terrain, regionID);
105 } 105 }
106 106
107 public void StoreBakedTerrain(TerrainData terrain, UUID regionID)
108 {
109 m_database.StoreBakedTerrain(terrain, regionID);
110 }
111
107 public void StoreTerrain(double[,] terrain, UUID regionID) 112 public void StoreTerrain(double[,] terrain, UUID regionID)
108 { 113 {
109 m_database.StoreTerrain(terrain, regionID); 114 m_database.StoreTerrain(terrain, regionID);
@@ -119,6 +124,11 @@ namespace OpenSim.Services.SimulationService
119 return m_database.LoadTerrain(regionID, pSizeX, pSizeY, pSizeZ); 124 return m_database.LoadTerrain(regionID, pSizeX, pSizeY, pSizeZ);
120 } 125 }
121 126
127 public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
128 {
129 return m_database.LoadBakedTerrain(regionID, pSizeX, pSizeY, pSizeZ);
130 }
131
122 public void StoreLandObject(ILandObject Parcel) 132 public void StoreLandObject(ILandObject Parcel)
123 { 133 {
124 m_database.StoreLandObject(Parcel); 134 m_database.StoreLandObject(Parcel);
@@ -173,6 +183,11 @@ namespace OpenSim.Services.SimulationService
173 m_database.RemoveRegionEnvironmentSettings(regionUUID); 183 m_database.RemoveRegionEnvironmentSettings(regionUUID);
174 } 184 }
175 185
186 public UUID[] GetObjectIDs(UUID regionID)
187 {
188 return m_database.GetObjectIDs(regionID);
189 }
190
176 public void SaveExtra(UUID regionID, string name, string val) 191 public void SaveExtra(UUID regionID, string name, string val)
177 { 192 {
178 m_database.SaveExtra(regionID, name, val); 193 m_database.SaveExtra(regionID, name, val);
diff --git a/OpenSim/Services/UserAccountService/AgentPreferencesService.cs b/OpenSim/Services/UserAccountService/AgentPreferencesService.cs
index 1808ee5..c473d4a 100644
--- a/OpenSim/Services/UserAccountService/AgentPreferencesService.cs
+++ b/OpenSim/Services/UserAccountService/AgentPreferencesService.cs
@@ -41,7 +41,7 @@ namespace OpenSim.Services.UserAccountService
41 { 41 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 43
44 public AgentPreferencesService(IConfigSource config) : base(config) 44 public AgentPreferencesService(IConfigSource config) : base(config)
45 { 45 {
46 m_log.Debug("[AGENT PREFERENCES SERVICE]: Starting agent preferences service"); 46 m_log.Debug("[AGENT PREFERENCES SERVICE]: Starting agent preferences service");
47 } 47 }
@@ -49,7 +49,7 @@ namespace OpenSim.Services.UserAccountService
49 public AgentPrefs GetAgentPreferences(UUID principalID) 49 public AgentPrefs GetAgentPreferences(UUID principalID)
50 { 50 {
51 AgentPreferencesData d = m_Database.GetPrefs(principalID); 51 AgentPreferencesData d = m_Database.GetPrefs(principalID);
52 AgentPrefs prefs = (d == null) ? new AgentPrefs(principalID) : new AgentPrefs(d.Data); 52 AgentPrefs prefs = (d == null) ? null : new AgentPrefs(d.Data);
53 return prefs; 53 return prefs;
54 } 54 }
55 55
diff --git a/OpenSim/Services/UserAccountService/GridUserService.cs b/OpenSim/Services/UserAccountService/GridUserService.cs
index 80a9d9d..3cb672e 100644
--- a/OpenSim/Services/UserAccountService/GridUserService.cs
+++ b/OpenSim/Services/UserAccountService/GridUserService.cs
@@ -45,7 +45,7 @@ namespace OpenSim.Services.UserAccountService
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 private static bool m_Initialized; 46 private static bool m_Initialized;
47 47
48 public GridUserService(IConfigSource config) : base(config) 48 public GridUserService(IConfigSource config) : base(config)
49 { 49 {
50 m_log.Debug("[GRID USER SERVICE]: Starting user grid service"); 50 m_log.Debug("[GRID USER SERVICE]: Starting user grid service");
51 51
@@ -207,7 +207,7 @@ namespace OpenSim.Services.UserAccountService
207 207
208 public bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) 208 public bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
209 { 209 {
210 m_log.InfoFormat("[GRID USER SERVICE]: User {0} is offline", userID); 210 m_log.DebugFormat("[GRID USER SERVICE]: User {0} is offline", userID);
211 211
212 GridUserData d = GetGridUserData(userID); 212 GridUserData d = GetGridUserData(userID);
213 213
diff --git a/OpenSim/Services/UserAccountService/GridUserServiceBase.cs b/OpenSim/Services/UserAccountService/GridUserServiceBase.cs
index 8c5f5df..f9a7260 100644
--- a/OpenSim/Services/UserAccountService/GridUserServiceBase.cs
+++ b/OpenSim/Services/UserAccountService/GridUserServiceBase.cs
@@ -67,7 +67,7 @@ namespace OpenSim.Services.UserAccountService
67 connString = usersConfig.GetString("ConnectionString", connString); 67 connString = usersConfig.GetString("ConnectionString", connString);
68 realm = usersConfig.GetString("Realm", realm); 68 realm = usersConfig.GetString("Realm", realm);
69 } 69 }
70 70
71 // 71 //
72 // We tried, but this doesn't exist. We can't proceed. 72 // We tried, but this doesn't exist. We can't proceed.
73 // 73 //
diff --git a/OpenSim/Services/UserAccountService/Properties/AssemblyInfo.cs b/OpenSim/Services/UserAccountService/Properties/AssemblyInfo.cs
index 6ca07a6..0c1464d 100644
--- a/OpenSim/Services/UserAccountService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/UserAccountService/Properties/AssemblyInfo.cs
@@ -2,7 +2,7 @@
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4 4
5// General Information about an assembly is controlled through the following 5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly. 7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Services.UserAccountService")] 8[assembly: AssemblyTitle("OpenSim.Services.UserAccountService")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
14[assembly: AssemblyTrademark("")] 14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")] 15[assembly: AssemblyCulture("")]
16 16
17// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)] 20[assembly: ComVisible(false)]
21 21
@@ -25,9 +25,9 @@ using System.Runtime.InteropServices;
25// Version information for an assembly consists of the following four values: 25// Version information for an assembly consists of the following four values:
26// 26//
27// Major Version 27// Major Version
28// Minor Version 28// Minor Version
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.8.3.*")] 32[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
33 33
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs
index 2e19ece..48929ee 100644
--- a/OpenSim/Services/UserAccountService/UserAccountService.cs
+++ b/OpenSim/Services/UserAccountService/UserAccountService.cs
@@ -43,6 +43,7 @@ namespace OpenSim.Services.UserAccountService
43 public class UserAccountService : UserAccountServiceBase, IUserAccountService 43 public class UserAccountService : UserAccountServiceBase, IUserAccountService
44 { 44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 private static readonly UUID UUID_GRID_GOD = new UUID("6571e388-6218-4574-87db-f9379718315e");
46 private static UserAccountService m_RootInstance; 47 private static UserAccountService m_RootInstance;
47 48
48 /// <summary> 49 /// <summary>
@@ -85,38 +86,63 @@ namespace OpenSim.Services.UserAccountService
85 86
86 m_CreateDefaultAvatarEntries = userConfig.GetBoolean("CreateDefaultAvatarEntries", false); 87 m_CreateDefaultAvatarEntries = userConfig.GetBoolean("CreateDefaultAvatarEntries", false);
87 88
88 // In case there are several instances of this class in the same process, 89 // create a system grid god account
89 // the console commands are only registered for the root instance 90 UserAccount ggod = GetUserAccount(UUID.Zero, UUID_GRID_GOD);
90 if (m_RootInstance == null && MainConsole.Instance != null) 91 if(ggod == null)
92 {
93 UserAccountData d = new UserAccountData();
94
95 d.FirstName = "GRID";
96 d.LastName = "SERVICES";
97 d.PrincipalID = UUID_GRID_GOD;
98 d.ScopeID = UUID.Zero;
99 d.Data = new Dictionary<string, string>();
100 d.Data["Email"] = string.Empty;
101 d.Data["Created"] = Util.UnixTimeSinceEpoch().ToString();
102 d.Data["UserLevel"] = "240";
103 d.Data["UserFlags"] = "0";
104 d.Data["ServiceURLs"] = string.Empty;
105
106 m_Database.Store(d);
107 }
108
109 if (m_RootInstance == null)
91 { 110 {
92 m_RootInstance = this; 111 m_RootInstance = this;
93 MainConsole.Instance.Commands.AddCommand("Users", false, 112
94 "create user", 113 // In case there are several instances of this class in the same process,
95 "create user [<first> [<last> [<pass> [<email> [<user id>]]]]]", 114 // the console commands are only registered for the root instance
96 "Create a new user", HandleCreateUser); 115 if (MainConsole.Instance != null)
97 116 {
98 MainConsole.Instance.Commands.AddCommand("Users", false, 117
99 "reset user password", 118 MainConsole.Instance.Commands.AddCommand("Users", false,
100 "reset user password [<first> [<last> [<password>]]]", 119 "create user",
101 "Reset a user password", HandleResetUserPassword); 120 "create user [<first> [<last> [<pass> [<email> [<user id> [<model>]]]]]]",
102 121 "Create a new user", HandleCreateUser);
103 MainConsole.Instance.Commands.AddCommand("Users", false, 122
104 "reset user email", 123 MainConsole.Instance.Commands.AddCommand("Users", false,
105 "reset user email [<first> [<last> [<email>]]]", 124 "reset user password",
106 "Reset a user email address", HandleResetUserEmail); 125 "reset user password [<first> [<last> [<password>]]]",
107 126 "Reset a user password", HandleResetUserPassword);
108 MainConsole.Instance.Commands.AddCommand("Users", false, 127
109 "set user level", 128 MainConsole.Instance.Commands.AddCommand("Users", false,
110 "set user level [<first> [<last> [<level>]]]", 129 "reset user email",
111 "Set user level. If >= 200 and 'allow_grid_gods = true' in OpenSim.ini, " 130 "reset user email [<first> [<last> [<email>]]]",
112 + "this account will be treated as god-moded. " 131 "Reset a user email address", HandleResetUserEmail);
113 + "It will also affect the 'login level' command. ", 132
114 HandleSetUserLevel); 133 MainConsole.Instance.Commands.AddCommand("Users", false,
115 134 "set user level",
116 MainConsole.Instance.Commands.AddCommand("Users", false, 135 "set user level [<first> [<last> [<level>]]]",
117 "show account", 136 "Set user level. If >= 200 and 'allow_grid_gods = true' in OpenSim.ini, "
118 "show account <first> <last>", 137 + "this account will be treated as god-moded. "
119 "Show account details for the given user", HandleShowAccount); 138 + "It will also affect the 'login level' command. ",
139 HandleSetUserLevel);
140
141 MainConsole.Instance.Commands.AddCommand("Users", false,
142 "show account",
143 "show account <first> <last>",
144 "Show account details for the given user", HandleShowAccount);
145 }
120 } 146 }
121 } 147 }
122 148
@@ -176,6 +202,10 @@ namespace OpenSim.Services.UserAccountService
176 Int32.TryParse(d.Data["UserLevel"], out u.UserLevel); 202 Int32.TryParse(d.Data["UserLevel"], out u.UserLevel);
177 if (d.Data.ContainsKey("UserFlags") && d.Data["UserFlags"] != null) 203 if (d.Data.ContainsKey("UserFlags") && d.Data["UserFlags"] != null)
178 Int32.TryParse(d.Data["UserFlags"], out u.UserFlags); 204 Int32.TryParse(d.Data["UserFlags"], out u.UserFlags);
205 if (d.Data.ContainsKey("UserCountry") && d.Data["UserCountry"] != null)
206 u.UserCountry = d.Data["UserCountry"].ToString();
207 else
208 u.UserCountry = string.Empty;
179 209
180 if (d.Data.ContainsKey("ServiceURLs") && d.Data["ServiceURLs"] != null) 210 if (d.Data.ContainsKey("ServiceURLs") && d.Data["ServiceURLs"] != null)
181 { 211 {
@@ -261,6 +291,19 @@ namespace OpenSim.Services.UserAccountService
261 return MakeUserAccount(d[0]); 291 return MakeUserAccount(d[0]);
262 } 292 }
263 293
294 public List<UserAccount> GetUserAccounts(UUID scopeID, List<string> IDs)
295 {
296 // do it one at a time db access should be fast, so no need to break its api
297 List<UserAccount> accs = new List<UserAccount>();
298 UUID uuid = UUID.Zero;
299 foreach(string id in IDs)
300 {
301 if (UUID.TryParse(id, out uuid) && uuid != UUID.Zero)
302 accs.Add(GetUserAccount(scopeID, uuid));
303 }
304 return accs;
305 }
306
264 public void InvalidateCache(UUID userID) 307 public void InvalidateCache(UUID userID)
265 { 308 {
266 } 309 }
@@ -301,7 +344,22 @@ namespace OpenSim.Services.UserAccountService
301 344
302 public List<UserAccount> GetUserAccounts(UUID scopeID, string query) 345 public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
303 { 346 {
304 UserAccountData[] d = m_Database.GetUsers(scopeID, query); 347 UserAccountData[] d = m_Database.GetUsers(scopeID, query.Trim());
348
349 if (d == null)
350 return new List<UserAccount>();
351
352 List<UserAccount> ret = new List<UserAccount>();
353
354 foreach (UserAccountData data in d)
355 ret.Add(MakeUserAccount(data));
356
357 return ret;
358 }
359
360 public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string where)
361 {
362 UserAccountData[] d = m_Database.GetUsersWhere(scopeID, where);
305 363
306 if (d == null) 364 if (d == null)
307 return new List<UserAccount>(); 365 return new List<UserAccount>();
@@ -321,7 +379,7 @@ namespace OpenSim.Services.UserAccountService
321 /// <summary> 379 /// <summary>
322 /// Handle the create user command from the console. 380 /// Handle the create user command from the console.
323 /// </summary> 381 /// </summary>
324 /// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email</param> 382 /// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email, userID, model name </param>
325 protected void HandleCreateUser(string module, string[] cmdparams) 383 protected void HandleCreateUser(string module, string[] cmdparams)
326 { 384 {
327 string firstName; 385 string firstName;
@@ -329,6 +387,7 @@ namespace OpenSim.Services.UserAccountService
329 string password; 387 string password;
330 string email; 388 string email;
331 string rawPrincipalId; 389 string rawPrincipalId;
390 string model;
332 391
333 List<char> excluded = new List<char>(new char[]{' '}); 392 List<char> excluded = new List<char>(new char[]{' '});
334 393
@@ -353,11 +412,16 @@ namespace OpenSim.Services.UserAccountService
353 else 412 else
354 rawPrincipalId = cmdparams[6]; 413 rawPrincipalId = cmdparams[6];
355 414
415 if (cmdparams.Length < 8)
416 model = MainConsole.Instance.CmdPrompt("Model name","");
417 else
418 model = cmdparams[7];
419
356 UUID principalId = UUID.Zero; 420 UUID principalId = UUID.Zero;
357 if (!UUID.TryParse(rawPrincipalId, out principalId)) 421 if (!UUID.TryParse(rawPrincipalId, out principalId))
358 throw new Exception(string.Format("ID {0} is not a valid UUID", rawPrincipalId)); 422 throw new Exception(string.Format("ID {0} is not a valid UUID", rawPrincipalId));
359 423
360 CreateUser(UUID.Zero, principalId, firstName, lastName, password, email); 424 CreateUser(UUID.Zero, principalId, firstName, lastName, password, email, model);
361 } 425 }
362 426
363 protected void HandleShowAccount(string module, string[] cmdparams) 427 protected void HandleShowAccount(string module, string[] cmdparams)
@@ -512,7 +576,8 @@ namespace OpenSim.Services.UserAccountService
512 /// <param name="lastName"></param> 576 /// <param name="lastName"></param>
513 /// <param name="password"></param> 577 /// <param name="password"></param>
514 /// <param name="email"></param> 578 /// <param name="email"></param>
515 public UserAccount CreateUser(UUID scopeID, UUID principalID, string firstName, string lastName, string password, string email) 579 /// <param name="model"></param>
580 public UserAccount CreateUser(UUID scopeID, UUID principalID, string firstName, string lastName, string password, string email, string model = "")
516 { 581 {
517 UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName); 582 UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName);
518 if (null == account) 583 if (null == account)
@@ -571,7 +636,12 @@ namespace OpenSim.Services.UserAccountService
571 } 636 }
572 637
573 if (m_CreateDefaultAvatarEntries) 638 if (m_CreateDefaultAvatarEntries)
574 CreateDefaultAppearanceEntries(account.PrincipalID); 639 {
640 if (String.IsNullOrEmpty(model))
641 CreateDefaultAppearanceEntries(account.PrincipalID);
642 else
643 EstablishAppearance(account.PrincipalID, model);
644 }
575 } 645 }
576 646
577 m_log.InfoFormat( 647 m_log.InfoFormat(
@@ -596,9 +666,11 @@ namespace OpenSim.Services.UserAccountService
596 m_log.DebugFormat("[USER ACCOUNT SERVICE]: Creating default appearance items for {0}", principalID); 666 m_log.DebugFormat("[USER ACCOUNT SERVICE]: Creating default appearance items for {0}", principalID);
597 667
598 InventoryFolderBase bodyPartsFolder = m_InventoryService.GetFolderForType(principalID, FolderType.BodyPart); 668 InventoryFolderBase bodyPartsFolder = m_InventoryService.GetFolderForType(principalID, FolderType.BodyPart);
669 // Get Current Outfit folder
670 InventoryFolderBase currentOutfitFolder = m_InventoryService.GetFolderForType(principalID, FolderType.CurrentOutfit);
599 671
600 InventoryItemBase eyes = new InventoryItemBase(UUID.Random(), principalID); 672 InventoryItemBase eyes = new InventoryItemBase(UUID.Random(), principalID);
601 eyes.AssetID = new UUID("4bb6fa4d-1cd2-498a-a84c-95c1a0e745a7"); 673 eyes.AssetID = AvatarWearable.DEFAULT_EYES_ASSET;
602 eyes.Name = "Default Eyes"; 674 eyes.Name = "Default Eyes";
603 eyes.CreatorId = principalID.ToString(); 675 eyes.CreatorId = principalID.ToString();
604 eyes.AssetType = (int)AssetType.Bodypart; 676 eyes.AssetType = (int)AssetType.Bodypart;
@@ -611,6 +683,7 @@ namespace OpenSim.Services.UserAccountService
611 eyes.NextPermissions = (uint)PermissionMask.All; 683 eyes.NextPermissions = (uint)PermissionMask.All;
612 eyes.Flags = (uint)WearableType.Eyes; 684 eyes.Flags = (uint)WearableType.Eyes;
613 m_InventoryService.AddItem(eyes); 685 m_InventoryService.AddItem(eyes);
686 CreateCurrentOutfitLink((int)InventoryType.Wearable, (uint)WearableType.Eyes, eyes.Name, eyes.ID, principalID, currentOutfitFolder.ID);
614 687
615 InventoryItemBase shape = new InventoryItemBase(UUID.Random(), principalID); 688 InventoryItemBase shape = new InventoryItemBase(UUID.Random(), principalID);
616 shape.AssetID = AvatarWearable.DEFAULT_BODY_ASSET; 689 shape.AssetID = AvatarWearable.DEFAULT_BODY_ASSET;
@@ -626,6 +699,7 @@ namespace OpenSim.Services.UserAccountService
626 shape.NextPermissions = (uint)PermissionMask.All; 699 shape.NextPermissions = (uint)PermissionMask.All;
627 shape.Flags = (uint)WearableType.Shape; 700 shape.Flags = (uint)WearableType.Shape;
628 m_InventoryService.AddItem(shape); 701 m_InventoryService.AddItem(shape);
702 CreateCurrentOutfitLink((int)InventoryType.Wearable, (uint)WearableType.Shape, shape.Name, shape.ID, principalID, currentOutfitFolder.ID);
629 703
630 InventoryItemBase skin = new InventoryItemBase(UUID.Random(), principalID); 704 InventoryItemBase skin = new InventoryItemBase(UUID.Random(), principalID);
631 skin.AssetID = AvatarWearable.DEFAULT_SKIN_ASSET; 705 skin.AssetID = AvatarWearable.DEFAULT_SKIN_ASSET;
@@ -641,6 +715,7 @@ namespace OpenSim.Services.UserAccountService
641 skin.NextPermissions = (uint)PermissionMask.All; 715 skin.NextPermissions = (uint)PermissionMask.All;
642 skin.Flags = (uint)WearableType.Skin; 716 skin.Flags = (uint)WearableType.Skin;
643 m_InventoryService.AddItem(skin); 717 m_InventoryService.AddItem(skin);
718 CreateCurrentOutfitLink((int)InventoryType.Wearable, (uint)WearableType.Skin, skin.Name, skin.ID, principalID, currentOutfitFolder.ID);
644 719
645 InventoryItemBase hair = new InventoryItemBase(UUID.Random(), principalID); 720 InventoryItemBase hair = new InventoryItemBase(UUID.Random(), principalID);
646 hair.AssetID = AvatarWearable.DEFAULT_HAIR_ASSET; 721 hair.AssetID = AvatarWearable.DEFAULT_HAIR_ASSET;
@@ -656,6 +731,7 @@ namespace OpenSim.Services.UserAccountService
656 hair.NextPermissions = (uint)PermissionMask.All; 731 hair.NextPermissions = (uint)PermissionMask.All;
657 hair.Flags = (uint)WearableType.Hair; 732 hair.Flags = (uint)WearableType.Hair;
658 m_InventoryService.AddItem(hair); 733 m_InventoryService.AddItem(hair);
734 CreateCurrentOutfitLink((int)InventoryType.Wearable, (uint)WearableType.Hair, hair.Name, hair.ID, principalID, currentOutfitFolder.ID);
659 735
660 InventoryFolderBase clothingFolder = m_InventoryService.GetFolderForType(principalID, FolderType.Clothing); 736 InventoryFolderBase clothingFolder = m_InventoryService.GetFolderForType(principalID, FolderType.Clothing);
661 737
@@ -673,6 +749,7 @@ namespace OpenSim.Services.UserAccountService
673 shirt.NextPermissions = (uint)PermissionMask.All; 749 shirt.NextPermissions = (uint)PermissionMask.All;
674 shirt.Flags = (uint)WearableType.Shirt; 750 shirt.Flags = (uint)WearableType.Shirt;
675 m_InventoryService.AddItem(shirt); 751 m_InventoryService.AddItem(shirt);
752 CreateCurrentOutfitLink((int)InventoryType.Wearable, (uint)WearableType.Shirt, shirt.Name, shirt.ID, principalID, currentOutfitFolder.ID);
676 753
677 InventoryItemBase pants = new InventoryItemBase(UUID.Random(), principalID); 754 InventoryItemBase pants = new InventoryItemBase(UUID.Random(), principalID);
678 pants.AssetID = AvatarWearable.DEFAULT_PANTS_ASSET; 755 pants.AssetID = AvatarWearable.DEFAULT_PANTS_ASSET;
@@ -688,6 +765,7 @@ namespace OpenSim.Services.UserAccountService
688 pants.NextPermissions = (uint)PermissionMask.All; 765 pants.NextPermissions = (uint)PermissionMask.All;
689 pants.Flags = (uint)WearableType.Pants; 766 pants.Flags = (uint)WearableType.Pants;
690 m_InventoryService.AddItem(pants); 767 m_InventoryService.AddItem(pants);
768 CreateCurrentOutfitLink((int)InventoryType.Wearable, (uint)WearableType.Pants, pants.Name, pants.ID, principalID, currentOutfitFolder.ID);
691 769
692 if (m_AvatarService != null) 770 if (m_AvatarService != null)
693 { 771 {
@@ -702,6 +780,7 @@ namespace OpenSim.Services.UserAccountService
702 wearables[AvatarWearable.PANTS] = new AvatarWearable(pants.ID, pants.AssetID); 780 wearables[AvatarWearable.PANTS] = new AvatarWearable(pants.ID, pants.AssetID);
703 781
704 AvatarAppearance ap = new AvatarAppearance(); 782 AvatarAppearance ap = new AvatarAppearance();
783 // this loop works, but is questionable
705 for (int i = 0; i < 6; i++) 784 for (int i = 0; i < 6; i++)
706 { 785 {
707 ap.SetWearable(i, wearables[i]); 786 ap.SetWearable(i, wearables[i]);
@@ -710,5 +789,237 @@ namespace OpenSim.Services.UserAccountService
710 m_AvatarService.SetAppearance(principalID, ap); 789 m_AvatarService.SetAppearance(principalID, ap);
711 } 790 }
712 } 791 }
792
793 protected void EstablishAppearance(UUID destinationAgent, string model)
794 {
795 m_log.DebugFormat("[USER ACCOUNT SERVICE]: Establishing new appearance for {0} - {1}",
796 destinationAgent.ToString(), model);
797
798 string[] modelSpecifiers = model.Split();
799 if (modelSpecifiers.Length != 2)
800 {
801 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Invalid model name \'{0}\'. Falling back to Ruth for {1}",
802 model, destinationAgent);
803 CreateDefaultAppearanceEntries(destinationAgent);
804 return;
805 }
806
807 // Does the source model exist?
808 UserAccount modelAccount = GetUserAccount(UUID.Zero, modelSpecifiers[0], modelSpecifiers[1]);
809 if (modelAccount == null)
810 {
811 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Requested model \'{0}\' not found. Falling back to Ruth for {1}",
812 model, destinationAgent);
813 CreateDefaultAppearanceEntries(destinationAgent);
814 return;
815 }
816
817 // Does the source model have an established appearance herself?
818 AvatarAppearance modelAppearance = m_AvatarService.GetAppearance(modelAccount.PrincipalID);
819 if (modelAppearance == null)
820 {
821 m_log.WarnFormat("USER ACCOUNT SERVICE]: Requested model \'{0}\' does not have an established appearance. Falling back to Ruth for {1}",
822 model, destinationAgent);
823 CreateDefaultAppearanceEntries(destinationAgent);
824 return;
825 }
826
827 try
828 {
829 CopyWearablesAndAttachments(destinationAgent, modelAccount.PrincipalID, modelAppearance);
830
831 m_AvatarService.SetAppearance(destinationAgent, modelAppearance);
832 }
833 catch (Exception e)
834 {
835 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Error transferring appearance for {0} : {1}",
836 destinationAgent, e.Message);
837 }
838
839 m_log.DebugFormat("[USER ACCOUNT SERVICE]: Finished establishing appearance for {0}",
840 destinationAgent.ToString());
841 }
842
843 /// <summary>
844 /// This method is called by EstablishAppearance to do a copy all inventory items
845 /// worn or attached to the Clothing inventory folder of the receiving avatar.
846 /// In parallel the avatar wearables and attachments are updated.
847 /// </summary>
848 private void CopyWearablesAndAttachments(UUID destination, UUID source, AvatarAppearance avatarAppearance)
849 {
850 // Get Clothing folder of receiver
851 InventoryFolderBase destinationFolder = m_InventoryService.GetFolderForType(destination, FolderType.Clothing);
852 // Get Current Outfit folder
853 InventoryFolderBase currentOutfitFolder = m_InventoryService.GetFolderForType(destination, FolderType.CurrentOutfit);
854
855 if (destinationFolder == null)
856 throw new Exception("Cannot locate folder(s)");
857
858 // Missing destination folder? This should *never* be the case
859 if (destinationFolder.Type != (short)FolderType.Clothing)
860 {
861 destinationFolder = new InventoryFolderBase();
862
863 destinationFolder.ID = UUID.Random();
864 destinationFolder.Name = "Clothing";
865 destinationFolder.Owner = destination;
866 destinationFolder.Type = (short)AssetType.Clothing;
867 destinationFolder.ParentID = m_InventoryService.GetRootFolder(destination).ID;
868 destinationFolder.Version = 1;
869 m_InventoryService.AddFolder(destinationFolder); // store base record
870 m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Created folder for destination {0}", source);
871 }
872
873 // Wearables
874 AvatarWearable[] wearables = avatarAppearance.Wearables;
875 AvatarWearable wearable;
876
877 for (int i = 0; i < wearables.Length; i++)
878 {
879 wearable = wearables[i];
880 m_log.DebugFormat("[XXX]: Getting item {0} from avie {1}", wearable[0].ItemID, source);
881 if (wearable[0].ItemID != UUID.Zero)
882 {
883 // Get inventory item and copy it
884 InventoryItemBase item = m_InventoryService.GetItem(source, wearable[0].ItemID);
885
886 if (item != null)
887 {
888 InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination);
889 destinationItem.Name = item.Name;
890 destinationItem.Owner = destination;
891 destinationItem.Description = item.Description;
892 destinationItem.InvType = item.InvType;
893 destinationItem.CreatorId = item.CreatorId;
894 destinationItem.CreatorData = item.CreatorData;
895 destinationItem.NextPermissions = item.NextPermissions;
896 destinationItem.CurrentPermissions = item.CurrentPermissions;
897 destinationItem.BasePermissions = item.BasePermissions;
898 destinationItem.EveryOnePermissions = item.EveryOnePermissions;
899 destinationItem.GroupPermissions = item.GroupPermissions;
900 destinationItem.AssetType = item.AssetType;
901 destinationItem.AssetID = item.AssetID;
902 destinationItem.GroupID = item.GroupID;
903 destinationItem.GroupOwned = item.GroupOwned;
904 destinationItem.SalePrice = item.SalePrice;
905 destinationItem.SaleType = item.SaleType;
906 destinationItem.Flags = item.Flags;
907 destinationItem.CreationDate = item.CreationDate;
908 destinationItem.Folder = destinationFolder.ID;
909 ApplyNextOwnerPermissions(destinationItem);
910
911 m_InventoryService.AddItem(destinationItem);
912 m_log.DebugFormat("[USER ACCOUNT SERVICE]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID);
913
914 // Wear item
915 AvatarWearable newWearable = new AvatarWearable();
916 newWearable.Wear(destinationItem.ID, wearable[0].AssetID);
917 avatarAppearance.SetWearable(i, newWearable);
918
919 // Add to Current Outfit
920 CreateCurrentOutfitLink((int)InventoryType.Wearable, item.Flags, item.Name, destinationItem.ID, destination, currentOutfitFolder.ID);
921 }
922 else
923 {
924 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Error transferring {0} to folder {1}", wearable[0].ItemID, destinationFolder.ID);
925 }
926 }
927 }
928
929 // Attachments
930 List<AvatarAttachment> attachments = avatarAppearance.GetAttachments();
931
932 foreach (AvatarAttachment attachment in attachments)
933 {
934 int attachpoint = attachment.AttachPoint;
935 UUID itemID = attachment.ItemID;
936
937 if (itemID != UUID.Zero)
938 {
939 // Get inventory item and copy it
940 InventoryItemBase item = m_InventoryService.GetItem(source, itemID);
941
942 if (item != null)
943 {
944 InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination);
945 destinationItem.Name = item.Name;
946 destinationItem.Owner = destination;
947 destinationItem.Description = item.Description;
948 destinationItem.InvType = item.InvType;
949 destinationItem.CreatorId = item.CreatorId;
950 destinationItem.CreatorData = item.CreatorData;
951 destinationItem.NextPermissions = item.NextPermissions;
952 destinationItem.CurrentPermissions = item.CurrentPermissions;
953 destinationItem.BasePermissions = item.BasePermissions;
954 destinationItem.EveryOnePermissions = item.EveryOnePermissions;
955 destinationItem.GroupPermissions = item.GroupPermissions;
956 destinationItem.AssetType = item.AssetType;
957 destinationItem.AssetID = item.AssetID;
958 destinationItem.GroupID = item.GroupID;
959 destinationItem.GroupOwned = item.GroupOwned;
960 destinationItem.SalePrice = item.SalePrice;
961 destinationItem.SaleType = item.SaleType;
962 destinationItem.Flags = item.Flags;
963 destinationItem.CreationDate = item.CreationDate;
964 destinationItem.Folder = destinationFolder.ID;
965 ApplyNextOwnerPermissions(destinationItem);
966
967 m_InventoryService.AddItem(destinationItem);
968 m_log.DebugFormat("[USER ACCOUNT SERVICE]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID);
969
970 // Attach item
971 avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID);
972 m_log.DebugFormat("[USER ACCOUNT SERVICE]: Attached {0}", destinationItem.ID);
973
974 // Add to Current Outfit
975 CreateCurrentOutfitLink(destinationItem.InvType, item.Flags, item.Name, destinationItem.ID, destination, currentOutfitFolder.ID);
976 }
977 else
978 {
979 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Error transferring {0} to folder {1}", itemID, destinationFolder.ID);
980 }
981 }
982 }
983 }
984
985 protected void CreateCurrentOutfitLink(int invType, uint itemType, string name, UUID itemID, UUID userID, UUID currentOutfitFolderUUID)
986 {
987 UUID LinkInvItem = UUID.Random();
988 InventoryItemBase itembase = new InventoryItemBase(LinkInvItem, userID)
989 {
990 AssetID = itemID,
991 AssetType = (int)AssetType.Link,
992 CreatorId = userID.ToString(),
993 InvType = invType,
994 Description = "",
995 //Folder = m_InventoryService.GetFolderForType(userID, FolderType.CurrentOutfit).ID,
996 Folder = currentOutfitFolderUUID,
997 Flags = itemType,
998 Name = name,
999 BasePermissions = (uint)PermissionMask.Copy,
1000 CurrentPermissions = (uint)PermissionMask.Copy,
1001 EveryOnePermissions = (uint)PermissionMask.Copy,
1002 GroupPermissions = (uint)PermissionMask.Copy,
1003 NextPermissions = (uint)PermissionMask.Copy
1004 };
1005
1006 m_InventoryService.AddItem(itembase);
1007 }
1008
1009 /// <summary>
1010 /// Apply next owner permissions.
1011 /// </summary>
1012 private void ApplyNextOwnerPermissions(InventoryItemBase item)
1013 {
1014 if (item.InvType == (int)InventoryType.Object)
1015 {
1016 uint perms = item.CurrentPermissions;
1017 item.CurrentPermissions = perms;
1018 }
1019
1020 item.CurrentPermissions &= item.NextPermissions;
1021 item.BasePermissions &= item.NextPermissions;
1022 item.EveryOnePermissions &= item.NextPermissions;
1023 }
713 } 1024 }
714} 1025}
diff --git a/OpenSim/Services/UserProfilesService/UserProfilesService.cs b/OpenSim/Services/UserProfilesService/UserProfilesService.cs
index 96c13c0..76aa093 100644
--- a/OpenSim/Services/UserProfilesService/UserProfilesService.cs
+++ b/OpenSim/Services/UserProfilesService/UserProfilesService.cs
@@ -45,7 +45,7 @@ namespace OpenSim.Services.ProfilesService
45 static readonly ILog m_log = 45 static readonly ILog m_log =
46 LogManager.GetLogger( 46 LogManager.GetLogger(
47 MethodBase.GetCurrentMethod().DeclaringType); 47 MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 IUserAccountService userAccounts; 49 IUserAccountService userAccounts;
50 50
51 public UserProfilesService(IConfigSource config, string configName): 51 public UserProfilesService(IConfigSource config, string configName):
@@ -58,23 +58,23 @@ namespace OpenSim.Services.ProfilesService
58 return; 58 return;
59 } 59 }
60 Object[] args = null; 60 Object[] args = null;
61 61
62 args = new Object[] { config }; 62 args = new Object[] { config };
63 string accountService = Config.GetString("UserAccountService", String.Empty); 63 string accountService = Config.GetString("UserAccountService", String.Empty);
64 if (accountService != string.Empty) 64 if (accountService != string.Empty)
65 userAccounts = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args); 65 userAccounts = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
66 66
67 args = new Object[] { config }; 67 args = new Object[] { config };
68 } 68 }
69 69
70 #region Classifieds 70 #region Classifieds
71 public OSD AvatarClassifiedsRequest(UUID creatorId) 71 public OSD AvatarClassifiedsRequest(UUID creatorId)
72 { 72 {
73 OSDArray records = ProfilesData.GetClassifiedRecords(creatorId); 73 OSDArray records = ProfilesData.GetClassifiedRecords(creatorId);
74 74
75 return records; 75 return records;
76 } 76 }
77 77
78 public bool ClassifiedUpdate(UserClassifiedAdd ad, ref string result) 78 public bool ClassifiedUpdate(UserClassifiedAdd ad, ref string result)
79 { 79 {
80 if(!ProfilesData.UpdateClassifiedRecord(ad, ref result)) 80 if(!ProfilesData.UpdateClassifiedRecord(ad, ref result))
@@ -84,74 +84,74 @@ namespace OpenSim.Services.ProfilesService
84 result = "success"; 84 result = "success";
85 return true; 85 return true;
86 } 86 }
87 87
88 public bool ClassifiedDelete(UUID recordId) 88 public bool ClassifiedDelete(UUID recordId)
89 { 89 {
90 if(ProfilesData.DeleteClassifiedRecord(recordId)) 90 if(ProfilesData.DeleteClassifiedRecord(recordId))
91 return true; 91 return true;
92 92
93 return false; 93 return false;
94 } 94 }
95 95
96 public bool ClassifiedInfoRequest(ref UserClassifiedAdd ad, ref string result) 96 public bool ClassifiedInfoRequest(ref UserClassifiedAdd ad, ref string result)
97 { 97 {
98 if(ProfilesData.GetClassifiedInfo(ref ad, ref result)) 98 if(ProfilesData.GetClassifiedInfo(ref ad, ref result))
99 return true; 99 return true;
100 100
101 return false; 101 return false;
102 } 102 }
103 #endregion Classifieds 103 #endregion Classifieds
104 104
105 #region Picks 105 #region Picks
106 public OSD AvatarPicksRequest(UUID creatorId) 106 public OSD AvatarPicksRequest(UUID creatorId)
107 { 107 {
108 OSDArray records = ProfilesData.GetAvatarPicks(creatorId); 108 OSDArray records = ProfilesData.GetAvatarPicks(creatorId);
109 109
110 return records; 110 return records;
111 } 111 }
112 112
113 public bool PickInfoRequest(ref UserProfilePick pick, ref string result) 113 public bool PickInfoRequest(ref UserProfilePick pick, ref string result)
114 { 114 {
115 pick = ProfilesData.GetPickInfo(pick.CreatorId, pick.PickId); 115 pick = ProfilesData.GetPickInfo(pick.CreatorId, pick.PickId);
116 result = "OK"; 116 result = "OK";
117 return true; 117 return true;
118 } 118 }
119 119
120 public bool PicksUpdate(ref UserProfilePick pick, ref string result) 120 public bool PicksUpdate(ref UserProfilePick pick, ref string result)
121 { 121 {
122 return ProfilesData.UpdatePicksRecord(pick); 122 return ProfilesData.UpdatePicksRecord(pick);
123 } 123 }
124 124
125 public bool PicksDelete(UUID pickId) 125 public bool PicksDelete(UUID pickId)
126 { 126 {
127 return ProfilesData.DeletePicksRecord(pickId); 127 return ProfilesData.DeletePicksRecord(pickId);
128 } 128 }
129 #endregion Picks 129 #endregion Picks
130 130
131 #region Notes 131 #region Notes
132 public bool AvatarNotesRequest(ref UserProfileNotes note) 132 public bool AvatarNotesRequest(ref UserProfileNotes note)
133 { 133 {
134 return ProfilesData.GetAvatarNotes(ref note); 134 return ProfilesData.GetAvatarNotes(ref note);
135 } 135 }
136 136
137 public bool NotesUpdate(ref UserProfileNotes note, ref string result) 137 public bool NotesUpdate(ref UserProfileNotes note, ref string result)
138 { 138 {
139 return ProfilesData.UpdateAvatarNotes(ref note, ref result); 139 return ProfilesData.UpdateAvatarNotes(ref note, ref result);
140 } 140 }
141 #endregion Notes 141 #endregion Notes
142 142
143 #region Profile Properties 143 #region Profile Properties
144 public bool AvatarPropertiesRequest(ref UserProfileProperties prop, ref string result) 144 public bool AvatarPropertiesRequest(ref UserProfileProperties prop, ref string result)
145 { 145 {
146 return ProfilesData.GetAvatarProperties(ref prop, ref result); 146 return ProfilesData.GetAvatarProperties(ref prop, ref result);
147 } 147 }
148 148
149 public bool AvatarPropertiesUpdate(ref UserProfileProperties prop, ref string result) 149 public bool AvatarPropertiesUpdate(ref UserProfileProperties prop, ref string result)
150 { 150 {
151 return ProfilesData.UpdateAvatarProperties(ref prop, ref result); 151 return ProfilesData.UpdateAvatarProperties(ref prop, ref result);
152 } 152 }
153 #endregion Profile Properties 153 #endregion Profile Properties
154 154
155 #region Interests 155 #region Interests
156 public bool AvatarInterestsUpdate(UserProfileProperties prop, ref string result) 156 public bool AvatarInterestsUpdate(UserProfileProperties prop, ref string result)
157 { 157 {
@@ -159,6 +159,7 @@ namespace OpenSim.Services.ProfilesService
159 } 159 }
160 #endregion Interests 160 #endregion Interests
161 161
162
162 #region User Preferences 163 #region User Preferences
163 public bool UserPreferencesUpdate(ref UserPreferences pref, ref string result) 164 public bool UserPreferencesUpdate(ref UserPreferences pref, ref string result)
164 { 165 {
@@ -239,6 +240,7 @@ namespace OpenSim.Services.ProfilesService
239 } 240 }
240 #endregion User Preferences 241 #endregion User Preferences
241 242
243
242 #region Utility 244 #region Utility
243 public OSD AvatarImageAssetsRequest(UUID avatarId) 245 public OSD AvatarImageAssetsRequest(UUID avatarId)
244 { 246 {
@@ -252,7 +254,7 @@ namespace OpenSim.Services.ProfilesService
252 { 254 {
253 return ProfilesData.GetUserAppData(ref prop, ref result); 255 return ProfilesData.GetUserAppData(ref prop, ref result);
254 } 256 }
255 257
256 public bool SetUserAppData(UserAppData prop, ref string result) 258 public bool SetUserAppData(UserAppData prop, ref string result)
257 { 259 {
258 return true; 260 return true;
diff --git a/OpenSim/Services/UserProfilesService/UserProfilesServiceBase.cs b/OpenSim/Services/UserProfilesService/UserProfilesServiceBase.cs
index c31578f..48b43a6 100644
--- a/OpenSim/Services/UserProfilesService/UserProfilesServiceBase.cs
+++ b/OpenSim/Services/UserProfilesService/UserProfilesServiceBase.cs
@@ -68,7 +68,7 @@ namespace OpenSim.Services.ProfilesService
68 if (string.IsNullOrEmpty(connString)) 68 if (string.IsNullOrEmpty(connString))
69 connString = dbConfig.GetString("ConnectionString", String.Empty); 69 connString = dbConfig.GetString("ConnectionString", String.Empty);
70 } 70 }
71 71
72 IConfig ProfilesConfig = config.Configs[configName]; 72 IConfig ProfilesConfig = config.Configs[configName];
73 if (ProfilesConfig != null) 73 if (ProfilesConfig != null)
74 { 74 {
@@ -76,7 +76,7 @@ namespace OpenSim.Services.ProfilesService
76 connString = ProfilesConfig.GetString("ConnectionString", connString); 76 connString = ProfilesConfig.GetString("ConnectionString", connString);
77 realm = ProfilesConfig.GetString("Realm", realm); 77 realm = ProfilesConfig.GetString("Realm", realm);
78 } 78 }
79 79
80 ProfilesData = LoadPlugin<IProfilesData>(dllName, new Object[] { connString }); 80 ProfilesData = LoadPlugin<IProfilesData>(dllName, new Object[] { connString });
81 if (ProfilesData == null) 81 if (ProfilesData == null)
82 throw new Exception("Could not find a storage interface in the given module"); 82 throw new Exception("Could not find a storage interface in the given module");