aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/AssetService/AssetService.cs2
-rw-r--r--OpenSim/Services/AssetService/XAssetService.cs2
-rw-r--r--OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs22
-rw-r--r--OpenSim/Services/Connectors/Estate/EstateDataConnector.cs18
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs2
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs11
-rw-r--r--OpenSim/Services/Connectors/Land/LandServicesConnector.cs2
-rw-r--r--OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs3
-rw-r--r--OpenSim/Services/Connectors/MuteList/MuteListServicesConnector.cs183
-rw-r--r--OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs5
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs3
-rw-r--r--OpenSim/Services/GridService/GridService.cs8
-rw-r--r--OpenSim/Services/HypergridService/GatekeeperService.cs143
-rw-r--r--OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs2
-rw-r--r--OpenSim/Services/HypergridService/UserAgentService.cs1
-rw-r--r--OpenSim/Services/Interfaces/IAvatarService.cs81
-rw-r--r--OpenSim/Services/Interfaces/IGridService.cs65
-rw-r--r--OpenSim/Services/Interfaces/ILibraryService.cs3
-rw-r--r--OpenSim/Services/Interfaces/IMuteLIstService.cs41
-rw-r--r--OpenSim/Services/InventoryService/LibraryService.cs87
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginResponse.cs5
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs135
-rw-r--r--OpenSim/Services/MuteListService/MuteListService.cs127
-rw-r--r--OpenSim/Services/UserAccountService/UserAccountService.cs246
24 files changed, 908 insertions, 289 deletions
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs
index 5c37c33..ee2e568 100644
--- a/OpenSim/Services/AssetService/AssetService.cs
+++ b/OpenSim/Services/AssetService/AssetService.cs
@@ -82,7 +82,7 @@ namespace OpenSim.Services.AssetService
82 if (existingAsset == null || Util.SHA1Hash(existingAsset.Data) != Util.SHA1Hash(a.Data)) 82 if (existingAsset == null || Util.SHA1Hash(existingAsset.Data) != Util.SHA1Hash(a.Data))
83 { 83 {
84// m_log.DebugFormat("[ASSET]: Storing {0} {1}", a.Name, a.ID); 84// m_log.DebugFormat("[ASSET]: Storing {0} {1}", a.Name, a.ID);
85 Store(a); 85 m_Database.StoreAsset(a);
86 } 86 }
87 }); 87 });
88 } 88 }
diff --git a/OpenSim/Services/AssetService/XAssetService.cs b/OpenSim/Services/AssetService/XAssetService.cs
index 9490d55..de7223b 100644
--- a/OpenSim/Services/AssetService/XAssetService.cs
+++ b/OpenSim/Services/AssetService/XAssetService.cs
@@ -80,7 +80,7 @@ namespace OpenSim.Services.AssetService
80 if (existingAsset == null || Util.SHA1Hash(existingAsset.Data) != Util.SHA1Hash(a.Data)) 80 if (existingAsset == null || Util.SHA1Hash(existingAsset.Data) != Util.SHA1Hash(a.Data))
81 { 81 {
82// m_log.DebugFormat("[ASSET]: Storing {0} {1}", a.Name, a.ID); 82// m_log.DebugFormat("[ASSET]: Storing {0} {1}", a.Name, a.ID);
83 Store(a); 83 m_Database.StoreAsset(a);
84 } 84 }
85 }); 85 });
86 } 86 }
diff --git a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
index 810da2f..205426e 100644
--- a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
@@ -29,12 +29,13 @@ using log4net;
29using System; 29using System;
30using System.Threading; 30using System.Threading;
31using System.Collections.Generic; 31using System.Collections.Generic;
32using System.Collections.Concurrent;
32using System.IO; 33using System.IO;
33using System.Reflection; 34using System.Reflection;
34using System.Timers; 35using System.Timers;
35using Nini.Config; 36using Nini.Config;
36using OpenSim.Framework; 37using OpenSim.Framework;
37using OpenSim.Framework.Console; 38using OpenSim.Framework.Monitoring;
38using OpenSim.Services.Interfaces; 39using OpenSim.Services.Interfaces;
39using OpenMetaverse; 40using OpenMetaverse;
40 41
@@ -135,8 +136,11 @@ namespace OpenSim.Services.Connectors
135 136
136 for (int i = 0 ; i < 2 ; i++) 137 for (int i = 0 ; i < 2 ; i++)
137 { 138 {
138 m_fetchThreads[i] = new Thread(AssetRequestProcessor); 139 m_fetchThreads[i] = WorkManager.StartThread(AssetRequestProcessor,
139 m_fetchThreads[i].Start(); 140 String.Format("GetTextureWorker{0}", i),
141 ThreadPriority.Normal,
142 true,
143 false);
140 } 144 }
141 } 145 }
142 146
@@ -349,8 +353,7 @@ namespace OpenSim.Services.Connectors
349 public string id; 353 public string id;
350 } 354 }
351 355
352 private OpenMetaverse.BlockingQueue<QueuedAssetRequest> m_requestQueue = 356 private BlockingCollection<QueuedAssetRequest> m_requestQueue = new BlockingCollection<QueuedAssetRequest>();
353 new OpenMetaverse.BlockingQueue<QueuedAssetRequest>();
354 357
355 private void AssetRequestProcessor() 358 private void AssetRequestProcessor()
356 { 359 {
@@ -358,8 +361,13 @@ namespace OpenSim.Services.Connectors
358 361
359 while (true) 362 while (true)
360 { 363 {
361 r = m_requestQueue.Dequeue(); 364 if(!m_requestQueue.TryTake(out r, 4500) || r == null)
365 {
366 Watchdog.UpdateThread();
367 continue;
368 }
362 369
370 Watchdog.UpdateThread();
363 string uri = r.uri; 371 string uri = r.uri;
364 string id = r.id; 372 string id = r.id;
365 373
@@ -427,7 +435,7 @@ namespace OpenSim.Services.Connectors
427 QueuedAssetRequest request = new QueuedAssetRequest(); 435 QueuedAssetRequest request = new QueuedAssetRequest();
428 request.id = id; 436 request.id = id;
429 request.uri = uri; 437 request.uri = uri;
430 m_requestQueue.Enqueue(request); 438 m_requestQueue.Add(request);
431 } 439 }
432 } 440 }
433 else 441 else
diff --git a/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs b/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs
index b9a6281..0971b38 100644
--- a/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs
+++ b/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs
@@ -195,6 +195,14 @@ namespace OpenSim.Services.Connectors
195 string uri = m_ServerURI + string.Format("/estates/estate/?region={0}&create={1}", regionID, create); 195 string uri = m_ServerURI + string.Format("/estates/estate/?region={0}&create={1}", regionID, create);
196 196
197 reply = MakeRequest("GET", uri, string.Empty); 197 reply = MakeRequest("GET", uri, string.Empty);
198 if(reply == null)
199 {
200 // this is a fatal error
201 m_log.DebugFormat("[ESTATE CONNECTOR] connection to remote estates service failed");
202 m_log.DebugFormat("[ESTATE CONNECTOR] simulator needs to terminate");
203 Environment.Exit(-1);
204 }
205
198 if (String.IsNullOrEmpty(reply)) 206 if (String.IsNullOrEmpty(reply))
199 return null; 207 return null;
200 208
@@ -308,7 +316,8 @@ namespace OpenSim.Services.Connectors
308 string reply = string.Empty; 316 string reply = string.Empty;
309 try 317 try
310 { 318 {
311 reply = SynchronousRestFormsRequester.MakeRequest(verb, uri, formdata, m_Auth); 319 reply = SynchronousRestFormsRequester.MakeRequest(verb, uri, formdata, 30, m_Auth);
320 return reply;
312 } 321 }
313 catch (WebException e) 322 catch (WebException e)
314 { 323 {
@@ -317,14 +326,17 @@ namespace OpenSim.Services.Connectors
317 if (hwr != null) 326 if (hwr != null)
318 { 327 {
319 if (hwr.StatusCode == HttpStatusCode.NotFound) 328 if (hwr.StatusCode == HttpStatusCode.NotFound)
329 {
320 m_log.Error(string.Format("[ESTATE CONNECTOR]: Resource {0} not found ", uri)); 330 m_log.Error(string.Format("[ESTATE CONNECTOR]: Resource {0} not found ", uri));
331 return reply;
332 }
321 if (hwr.StatusCode == HttpStatusCode.Unauthorized) 333 if (hwr.StatusCode == HttpStatusCode.Unauthorized)
322 m_log.Error(string.Format("[ESTATE CONNECTOR]: Web request {0} requires authentication ", uri)); 334 m_log.Error(string.Format("[ESTATE CONNECTOR]: Web request {0} requires authentication ", uri));
323 } 335 }
324 else 336 else
325 m_log.Error(string.Format( 337 m_log.Error(string.Format(
326 "[ESTATE CONNECTOR]: WebException for {0} {1} {2} {3}", 338 "[ESTATE CONNECTOR]: WebException for {0} {1} {2} {3}",
327 verb, uri, formdata, e)); 339 verb, uri, formdata, e.Message));
328 } 340 }
329 } 341 }
330 catch (Exception e) 342 catch (Exception e)
@@ -332,7 +344,7 @@ namespace OpenSim.Services.Connectors
332 m_log.DebugFormat("[ESTATE CONNECTOR]: Exception when contacting estate server at {0}: {1}", uri, e.Message); 344 m_log.DebugFormat("[ESTATE CONNECTOR]: Exception when contacting estate server at {0}: {1}", uri, e.Message);
333 } 345 }
334 346
335 return reply; 347 return null;
336 } 348 }
337 } 349 }
338} 350}
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
index e814c45..cb15fc0 100644
--- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
@@ -189,7 +189,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
189 using (Bitmap bitmap = new Bitmap(filename)) 189 using (Bitmap bitmap = new Bitmap(filename))
190 { 190 {
191 //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); 191 //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width);
192 imageData = OpenJPEG.EncodeFromImage(bitmap, true); 192 imageData = OpenJPEG.EncodeFromImage(bitmap, false);
193 } 193 }
194 194
195 AssetBase ass = new AssetBase(UUID.Random(), "region " + name, (sbyte)AssetType.Texture, regionID.ToString()); 195 AssetBase ass = new AssetBase(UUID.Random(), "region " + name, (sbyte)AssetType.Texture, regionID.ToString());
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
index b261675..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 {
diff --git a/OpenSim/Services/Connectors/Land/LandServicesConnector.cs b/OpenSim/Services/Connectors/Land/LandServicesConnector.cs
index 047880a..5492e83 100644
--- a/OpenSim/Services/Connectors/Land/LandServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Land/LandServicesConnector.cs
@@ -117,6 +117,8 @@ namespace OpenSim.Services.Connectors
117 landData.UserLocation = Vector3.Parse((string)hash["UserLocation"]); 117 landData.UserLocation = Vector3.Parse((string)hash["UserLocation"]);
118 if (hash["RegionAccess"] != null) 118 if (hash["RegionAccess"] != null)
119 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"]);
120 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);
121 } 123 }
122 catch (Exception e) 124 catch (Exception e)
diff --git a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs
index 84c4efe..762d2f7 100644
--- a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs
+++ b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs
@@ -229,6 +229,7 @@ namespace OpenSim.Services.Connectors
229 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 229 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
230 uri, 230 uri,
231 reqString, 231 reqString,
232 30,
232 m_Auth); 233 m_Auth);
233 if (reply != string.Empty) 234 if (reply != string.Empty)
234 { 235 {
@@ -271,7 +272,7 @@ namespace OpenSim.Services.Connectors
271 { 272 {
272 // This just dumps a warning for any operation that takes more than 100 ms 273 // This just dumps a warning for any operation that takes more than 100 ms
273 int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); 274 int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
274 m_log.DebugFormat("[MAP IMAGE CONNECTOR]: map tile uploaded in {0}ms", tickdiff); 275 m_log.DebugFormat("[MAP IMAGE CONNECTOR]: map tile upload time {0}ms", tickdiff);
275 } 276 }
276 277
277 return false; 278 return false;
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 939059d..9f3b94c 100644
--- a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
@@ -151,7 +151,8 @@ 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 catch
155 { 156 {
156// m_log.WarnFormat( 157// m_log.WarnFormat(
157// "[NEIGHBOUR SERVICE CONNCTOR]: Unable to send HelloNeighbour from {0} to {1}. Exception {2}{3}", 158// "[NEIGHBOUR SERVICE CONNCTOR]: Unable to send HelloNeighbour from {0} to {1}. Exception {2}{3}",
@@ -183,8 +184,8 @@ namespace OpenSim.Services.Connectors
183 { 184 {
184 using (StreamReader sr = new StreamReader(s)) 185 using (StreamReader sr = new StreamReader(s))
185 { 186 {
187 sr.ReadToEnd(); // just try to read
186 //reply = sr.ReadToEnd().Trim(); 188 //reply = sr.ReadToEnd().Trim();
187 sr.ReadToEnd().Trim();
188 //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); 189 //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply);
189 } 190 }
190 } 191 }
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
index 9f4d89a..a4ca2d3 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -295,9 +295,6 @@ namespace OpenSim.Services.Connectors.Simulation
295 295
296 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: QueryAccess start, position={0}", position); 296 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: QueryAccess start, position={0}", position);
297 297
298 IPEndPoint ext = destination.ExternalEndPoint;
299 if (ext == null) return false;
300
301 // 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
302 string uri = destination.ServerURI + AgentPath() + agentID + "/" + destination.RegionID.ToString() + "/"; 299 string uri = destination.ServerURI + AgentPath() + agentID + "/" + destination.RegionID.ToString() + "/";
303 300
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index 6153f5e..78fffa6 100644
--- a/OpenSim/Services/GridService/GridService.cs
+++ b/OpenSim/Services/GridService/GridService.cs
@@ -494,7 +494,7 @@ namespace OpenSim.Services.GridService
494 { 494 {
495// m_log.DebugFormat("[GRID SERVICE]: GetRegionsByName {0}", name); 495// m_log.DebugFormat("[GRID SERVICE]: GetRegionsByName {0}", name);
496 496
497 List<RegionData> rdatas = m_Database.Get(Util.EscapeForLike(name) + "%", scopeID); 497 List<RegionData> rdatas = m_Database.Get("%" + Util.EscapeForLike(name) + "%", scopeID);
498 498
499 int count = 0; 499 int count = 0;
500 List<GridRegion> rinfos = new List<GridRegion>(); 500 List<GridRegion> rinfos = new List<GridRegion>();
@@ -909,9 +909,9 @@ namespace OpenSim.Services.GridService
909 private void OutputRegionsToConsoleSummary(List<RegionData> regions) 909 private void OutputRegionsToConsoleSummary(List<RegionData> regions)
910 { 910 {
911 ConsoleDisplayTable dispTable = new ConsoleDisplayTable(); 911 ConsoleDisplayTable dispTable = new ConsoleDisplayTable();
912 dispTable.AddColumn("Name", 44); 912 dispTable.AddColumn("Name", ConsoleDisplayUtil.RegionNameSize);
913 dispTable.AddColumn("ID", 36); 913 dispTable.AddColumn("ID", ConsoleDisplayUtil.UuidSize);
914 dispTable.AddColumn("Position", 11); 914 dispTable.AddColumn("Position", ConsoleDisplayUtil.CoordTupleSize);
915 dispTable.AddColumn("Size", 11); 915 dispTable.AddColumn("Size", 11);
916 dispTable.AddColumn("Flags", 60); 916 dispTable.AddColumn("Flags", 60);
917 917
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs
index b80700f..1b652a0 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;
@@ -62,6 +62,7 @@ namespace OpenSim.Services.HypergridService
62 62
63 private static string m_AllowedClients = string.Empty; 63 private static string m_AllowedClients = string.Empty;
64 private static string m_DeniedClients = string.Empty; 64 private static string m_DeniedClients = string.Empty;
65 private static string m_DeniedMacs = string.Empty;
65 private static bool m_ForeignAgentsAllowed = true; 66 private static bool m_ForeignAgentsAllowed = true;
66 private static List<string> m_ForeignsAllowedExceptions = new List<string>(); 67 private static List<string> m_ForeignsAllowedExceptions = new List<string>();
67 private static List<string> m_ForeignsDisallowedExceptions = new List<string>(); 68 private static List<string> m_ForeignsDisallowedExceptions = new List<string>();
@@ -71,6 +72,7 @@ namespace OpenSim.Services.HypergridService
71 private static string m_ExternalName; 72 private static string m_ExternalName;
72 private static Uri m_Uri; 73 private static Uri m_Uri;
73 private static GridRegion m_DefaultGatewayRegion; 74 private static GridRegion m_DefaultGatewayRegion;
75 private bool m_allowDuplicatePresences = false;
74 76
75 public GatekeeperService(IConfigSource config, ISimulationService simService) 77 public GatekeeperService(IConfigSource config, ISimulationService simService)
76 { 78 {
@@ -136,6 +138,8 @@ namespace OpenSim.Services.HypergridService
136 config, "AllowedClients", possibleAccessControlConfigSections, string.Empty); 138 config, "AllowedClients", possibleAccessControlConfigSections, string.Empty);
137 m_DeniedClients = Util.GetConfigVarFromSections<string>( 139 m_DeniedClients = Util.GetConfigVarFromSections<string>(
138 config, "DeniedClients", possibleAccessControlConfigSections, string.Empty); 140 config, "DeniedClients", possibleAccessControlConfigSections, string.Empty);
141 m_DeniedMacs = Util.GetConfigVarFromSections<string>(
142 config, "DeniedMacs", possibleAccessControlConfigSections, string.Empty);
139 m_ForeignAgentsAllowed = serverConfig.GetBoolean("ForeignAgentsAllowed", true); 143 m_ForeignAgentsAllowed = serverConfig.GetBoolean("ForeignAgentsAllowed", true);
140 144
141 LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_ForeignsAllowedExceptions); 145 LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_ForeignsAllowedExceptions);
@@ -144,6 +148,12 @@ namespace OpenSim.Services.HypergridService
144 if (m_GridService == null || m_PresenceService == null || m_SimulationService == null) 148 if (m_GridService == null || m_PresenceService == null || m_SimulationService == null)
145 throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function."); 149 throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function.");
146 150
151 IConfig presenceConfig = config.Configs["PresenceService"];
152 if (presenceConfig != null)
153 {
154 m_allowDuplicatePresences = presenceConfig.GetBoolean("AllowDuplicatePresences", m_allowDuplicatePresences);
155 }
156
147 m_log.Debug("[GATEKEEPER SERVICE]: Starting..."); 157 m_log.Debug("[GATEKEEPER SERVICE]: Starting...");
148 } 158 }
149 } 159 }
@@ -268,11 +278,13 @@ namespace OpenSim.Services.HypergridService
268 (source == null) ? "Unknown" : string.Format("{0} ({1}){2}", source.RegionName, source.RegionID, (source.RawServerURI == null) ? "" : " @ " + source.ServerURI)); 278 (source == null) ? "Unknown" : string.Format("{0} ({1}){2}", source.RegionName, source.RegionID, (source.RawServerURI == null) ? "" : " @ " + source.ServerURI));
269 279
270 string curViewer = Util.GetViewerName(aCircuit); 280 string curViewer = Util.GetViewerName(aCircuit);
281 string curMac = aCircuit.Mac.ToString();
282
271 283
272 // 284 //
273 // Check client 285 // Check client
274 // 286 //
275 if (m_AllowedClients != string.Empty) 287 if (!String.IsNullOrWhiteSpace(m_AllowedClients))
276 { 288 {
277 Regex arx = new Regex(m_AllowedClients); 289 Regex arx = new Regex(m_AllowedClients);
278 Match am = arx.Match(curViewer); 290 Match am = arx.Match(curViewer);
@@ -285,7 +297,7 @@ namespace OpenSim.Services.HypergridService
285 } 297 }
286 } 298 }
287 299
288 if (m_DeniedClients != string.Empty) 300 if (!String.IsNullOrWhiteSpace(m_DeniedClients))
289 { 301 {
290 Regex drx = new Regex(m_DeniedClients); 302 Regex drx = new Regex(m_DeniedClients);
291 Match dm = drx.Match(curViewer); 303 Match dm = drx.Match(curViewer);
@@ -298,6 +310,17 @@ namespace OpenSim.Services.HypergridService
298 } 310 }
299 } 311 }
300 312
313 if (!String.IsNullOrWhiteSpace(m_DeniedMacs))
314 {
315 m_log.InfoFormat("[GATEKEEPER SERVICE]: Checking users Mac {0} against list of denied macs {1} ...", curMac, m_DeniedMacs);
316 if (m_DeniedMacs.Contains(curMac))
317 {
318 reason = "Login failed: client with Mac " + curMac + " is denied";
319 m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client with mac {0} is denied", curMac);
320 return false;
321 }
322 }
323
301 // 324 //
302 // Authenticate the user 325 // Authenticate the user
303 // 326 //
@@ -369,6 +392,38 @@ namespace OpenSim.Services.HypergridService
369 return false; 392 return false;
370 } 393 }
371 394
395 UUID agentID = aCircuit.AgentID;
396 if(agentID == new UUID("6571e388-6218-4574-87db-f9379718315e"))
397 {
398 // really?
399 reason = "Invalid account ID";
400 return false;
401 }
402
403 if(m_GridUserService != null)
404 {
405 string PrincipalIDstr = agentID.ToString();
406 GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(PrincipalIDstr);
407
408 if(!m_allowDuplicatePresences)
409 {
410 if(guinfo != null && guinfo.Online && guinfo.LastRegionID != UUID.Zero)
411 {
412 if(SendAgentGodKillToRegion(UUID.Zero, agentID, guinfo))
413 {
414 if(account != null)
415 m_log.InfoFormat(
416 "[GATEKEEPER SERVICE]: Login failed for {0} {1}, reason: already logged in",
417 account.FirstName, account.LastName);
418 reason = "You appear to be already logged in on the destination grid " +
419 "Please wait a a minute or two and retry. " +
420 "If this takes longer than a few minutes please contact the grid owner.";
421 return false;
422 }
423 }
424 }
425 }
426
372 m_log.DebugFormat("[GATEKEEPER SERVICE]: User {0} is ok", aCircuit.Name); 427 m_log.DebugFormat("[GATEKEEPER SERVICE]: User {0} is ok", aCircuit.Name);
373 428
374 bool isFirstLogin = false; 429 bool isFirstLogin = false;
@@ -389,26 +444,6 @@ namespace OpenSim.Services.HypergridService
389 return false; 444 return false;
390 } 445 }
391 446
392 m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence {0} is ok", aCircuit.Name);
393
394 // Also login foreigners with GridUser service
395 if (m_GridUserService != null && account == null)
396 {
397 string userId = aCircuit.AgentID.ToString();
398 string first = aCircuit.firstname, last = aCircuit.lastname;
399 if (last.StartsWith("@"))
400 {
401 string[] parts = aCircuit.firstname.Split('.');
402 if (parts.Length >= 2)
403 {
404 first = parts[0];
405 last = parts[1];
406 }
407 }
408
409 userId += ";" + aCircuit.ServiceURLs["HomeURI"] + ";" + first + " " + last;
410 m_GridUserService.LoggedIn(userId);
411 }
412 } 447 }
413 448
414 // 449 //
@@ -465,7 +500,33 @@ namespace OpenSim.Services.HypergridService
465 true, aCircuit.startpos, new List<UUID>(), ctx, out reason)) 500 true, aCircuit.startpos, new List<UUID>(), ctx, out reason))
466 return false; 501 return false;
467 502
468 return m_SimulationService.CreateAgent(source, destination, aCircuit, (uint)loginFlag, ctx, out reason); 503 bool didit = m_SimulationService.CreateAgent(source, destination, aCircuit, (uint)loginFlag, ctx, out reason);
504
505 if(didit)
506 {
507 m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence {0} is ok", aCircuit.Name);
508
509 if(!isFirstLogin && m_GridUserService != null && account == null)
510 {
511 // Also login foreigners with GridUser service
512 string userId = aCircuit.AgentID.ToString();
513 string first = aCircuit.firstname, last = aCircuit.lastname;
514 if (last.StartsWith("@"))
515 {
516 string[] parts = aCircuit.firstname.Split('.');
517 if (parts.Length >= 2)
518 {
519 first = parts[0];
520 last = parts[1];
521 }
522 }
523
524 userId += ";" + aCircuit.ServiceURLs["HomeURI"] + ";" + first + " " + last;
525 m_GridUserService.LoggedIn(userId);
526 }
527 }
528
529 return didit;
469 } 530 }
470 531
471 protected bool Authenticate(AgentCircuitData aCircuit) 532 protected bool Authenticate(AgentCircuitData aCircuit)
@@ -563,6 +624,40 @@ namespace OpenSim.Services.HypergridService
563 return exception; 624 return exception;
564 } 625 }
565 626
627 private bool SendAgentGodKillToRegion(UUID scopeID, UUID agentID , GridUserInfo guinfo)
628 {
629 UUID regionID = guinfo.LastRegionID;
630 GridRegion regInfo = m_GridService.GetRegionByUUID(scopeID, regionID);
631 if(regInfo == null)
632 return false;
633
634 string regURL = regInfo.ServerURI;
635 if(String.IsNullOrEmpty(regURL))
636 return false;
637
638 UUID guuid = new UUID("6571e388-6218-4574-87db-f9379718315e");
639
640 GridInstantMessage msg = new GridInstantMessage();
641 msg.imSessionID = UUID.Zero.Guid;
642 msg.fromAgentID = guuid.Guid;
643 msg.toAgentID = agentID.Guid;
644 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
645 msg.fromAgentName = "GRID";
646 msg.message = string.Format("New login detected");
647 msg.dialog = 250; // God kick
648 msg.fromGroup = false;
649 msg.offline = (byte)0;
650 msg.ParentEstateID = 0;
651 msg.Position = Vector3.Zero;
652 msg.RegionID = scopeID.Guid;
653 msg.binaryBucket = new byte[1] {0};
654 InstantMessageServiceConnector.SendInstantMessage(regURL,msg);
655
656 m_GridUserService.LoggedOut(agentID.ToString(),
657 UUID.Zero, guinfo.LastRegionID, guinfo.LastPosition, guinfo.LastLookAt);
658
659 return true;
660 }
566 #endregion 661 #endregion
567 } 662 }
568} 663}
diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
index d1f2e70..9b33217 100644
--- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
+++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
@@ -399,7 +399,7 @@ namespace OpenSim.Services.HypergridService
399 return false; 399 return false;
400 } 400 }
401 401
402 public new InventoryItemBase GetItem(InventoryItemBase item) 402 public InventoryItemBase GetItem(InventoryItemBase item)
403 { 403 {
404 InventoryItemBase it = base.GetItem(item.Owner, item.ID); 404 InventoryItemBase it = base.GetItem(item.Owner, item.ID);
405 if (it == null) 405 if (it == null)
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index ba3cb2f..6f2cdd5 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -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;
diff --git a/OpenSim/Services/Interfaces/IAvatarService.cs b/OpenSim/Services/Interfaces/IAvatarService.cs
index b4dc511..ef8d158 100644
--- a/OpenSim/Services/Interfaces/IAvatarService.cs
+++ b/OpenSim/Services/Interfaces/IAvatarService.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text;
31 32
32using OpenSim.Framework; 33using OpenSim.Framework;
33 34
@@ -150,7 +151,6 @@ namespace OpenSim.Services.Interfaces
150 // Wearables 151 // Wearables
151 Data["AvatarHeight"] = appearance.AvatarHeight.ToString(); 152 Data["AvatarHeight"] = appearance.AvatarHeight.ToString();
152 153
153 // TODO: With COF, is this even needed?
154 for (int i = 0 ; i < AvatarWearable.LEGACY_VERSION_MAX_WEARABLES ; i++) 154 for (int i = 0 ; i < AvatarWearable.LEGACY_VERSION_MAX_WEARABLES ; i++)
155 { 155 {
156 for (int j = 0 ; j < appearance.Wearables[i].Count ; j++) 156 for (int j = 0 ; j < appearance.Wearables[i].Count ; j++)
@@ -162,21 +162,18 @@ namespace OpenSim.Services.Interfaces
162 } 162 }
163 } 163 }
164 164
165 // Visual Params
166 //string[] vps = new string[AvatarAppearance.VISUALPARAM_COUNT];
167 //byte[] binary = appearance.VisualParams;
168
169 // for (int i = 0 ; i < AvatarAppearance.VISUALPARAM_COUNT ; i++)
170
171 byte[] binary = appearance.VisualParams; 165 byte[] binary = appearance.VisualParams;
172 string[] vps = new string[binary.Length]; 166 int len = binary.Length;
167 int last = len - 1;
173 168
174 for (int i = 0; i < binary.Length; i++) 169 StringBuilder sb = new StringBuilder(5 * len);
170 for (int i = 0; i < len; i++)
175 { 171 {
176 vps[i] = binary[i].ToString(); 172 sb.Append(binary[i].ToString());
173 if (i < last)
174 sb.Append(",");
177 } 175 }
178 176 Data["VisualParams"] = sb.ToString();
179 Data["VisualParams"] = String.Join(",", vps);
180 177
181 // Attachments 178 // Attachments
182 List<AvatarAttachment> attachments = appearance.GetAttachments(); 179 List<AvatarAttachment> attachments = appearance.GetAttachments();
@@ -213,7 +210,6 @@ namespace OpenSim.Services.Interfaces
213 if( h == 0f) 210 if( h == 0f)
214 h = 1.9f; 211 h = 1.9f;
215 appearance.SetSize(new Vector3(0.45f, 0.6f, h )); 212 appearance.SetSize(new Vector3(0.45f, 0.6f, h ));
216// appearance.AvatarHeight = float.Parse(Data["AvatarHeight"]);
217 } 213 }
218 214
219 // Legacy Wearables 215 // Legacy Wearables
@@ -285,9 +281,6 @@ namespace OpenSim.Services.Interfaces
285 if (Data.ContainsKey("VisualParams")) 281 if (Data.ContainsKey("VisualParams"))
286 { 282 {
287 string[] vps = Data["VisualParams"].Split(new char[] {','}); 283 string[] vps = Data["VisualParams"].Split(new char[] {','});
288 //byte[] binary = new byte[AvatarAppearance.VISUALPARAM_COUNT];
289
290 //for (int i = 0 ; i < vps.Length && i < binary.Length ; i++)
291 byte[] binary = new byte[vps.Length]; 284 byte[] binary = new byte[vps.Length];
292 285
293 for (int i = 0; i < vps.Length; i++) 286 for (int i = 0; i < vps.Length; i++)
@@ -296,10 +289,12 @@ namespace OpenSim.Services.Interfaces
296 appearance.VisualParams = binary; 289 appearance.VisualParams = binary;
297 } 290 }
298 291
299 // New style wearables 292 AvatarWearable[] wearables = appearance.Wearables;
293 int currentLength = wearables.Length;
300 foreach (KeyValuePair<string, string> _kvp in Data) 294 foreach (KeyValuePair<string, string> _kvp in Data)
301 { 295 {
302 if (_kvp.Key.StartsWith("Wearable ")) 296 // New style wearables
297 if (_kvp.Key.StartsWith("Wearable ") && _kvp.Key.Length > 9)
303 { 298 {
304 string wearIndex = _kvp.Key.Substring(9); 299 string wearIndex = _kvp.Key.Substring(9);
305 string[] wearIndices = wearIndex.Split(new char[] {':'}); 300 string[] wearIndices = wearIndex.Split(new char[] {':'});
@@ -308,33 +303,33 @@ namespace OpenSim.Services.Interfaces
308 string[] ids = _kvp.Value.Split(new char[] {':'}); 303 string[] ids = _kvp.Value.Split(new char[] {':'});
309 UUID itemID = new UUID(ids[0]); 304 UUID itemID = new UUID(ids[0]);
310 UUID assetID = new UUID(ids[1]); 305 UUID assetID = new UUID(ids[1]);
311 306 if (index >= currentLength)
312 appearance.Wearables[index].Add(itemID, assetID); 307 {
313 } 308 Array.Resize(ref wearables, index + 1);
314 } 309 for (int i = currentLength ; i < wearables.Length ; i++)
315 310 wearables[i] = new AvatarWearable();
316 // Attachments 311 currentLength = wearables.Length;
317 Dictionary<string, string> attchs = new Dictionary<string, string>(); 312 }
318 foreach (KeyValuePair<string, string> _kvp in Data) 313 wearables[index].Add(itemID, assetID);
319 if (_kvp.Key.StartsWith("_ap_"))
320 attchs[_kvp.Key] = _kvp.Value;
321
322 foreach (KeyValuePair<string, string> _kvp in attchs)
323 {
324 string pointStr = _kvp.Key.Substring(4);
325 int point = 0;
326 if (!Int32.TryParse(pointStr, out point))
327 continue; 314 continue;
328 315 }
329 List<string> idList = new List<string>(_kvp.Value.Split(new char[] {','})); 316 // Attachments
330 317 if (_kvp.Key.StartsWith("_ap_") && _kvp.Key.Length > 4)
331 appearance.SetAttachment(point, UUID.Zero, UUID.Zero);
332 foreach (string id in idList)
333 { 318 {
334 UUID uuid = UUID.Zero; 319 string pointStr = _kvp.Key.Substring(4);
335 UUID.TryParse(id, out uuid); 320 int point = 0;
336 321 if (Int32.TryParse(pointStr, out point))
337 appearance.SetAttachment(point | 0x80, uuid, UUID.Zero); 322 {
323 List<string> idList = new List<string>(_kvp.Value.Split(new char[] {','}));
324
325 appearance.SetAttachment(point, UUID.Zero, UUID.Zero);
326 foreach (string id in idList)
327 {
328 UUID uuid = UUID.Zero;
329 if(UUID.TryParse(id, out uuid))
330 appearance.SetAttachment(point | 0x80, uuid, UUID.Zero);
331 }
332 }
338 } 333 }
339 } 334 }
340 335
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs
index 66e5870..ead5d3c 100644
--- a/OpenSim/Services/Interfaces/IGridService.cs
+++ b/OpenSim/Services/Interfaces/IGridService.cs
@@ -271,31 +271,6 @@ namespace OpenSim.Services.Interfaces
271 m_serverURI = string.Empty; 271 m_serverURI = string.Empty;
272 } 272 }
273 273
274 /*
275 public GridRegion(int regionLocX, int regionLocY, IPEndPoint internalEndPoint, string externalUri)
276 {
277 m_regionLocX = regionLocX;
278 m_regionLocY = regionLocY;
279 RegionSizeX = (int)Constants.RegionSize;
280 RegionSizeY = (int)Constants.RegionSize;
281
282 m_internalEndPoint = internalEndPoint;
283 m_externalHostName = externalUri;
284 }
285
286 public GridRegion(int regionLocX, int regionLocY, string externalUri, uint port)
287 {
288 m_regionLocX = regionLocX;
289 m_regionLocY = regionLocY;
290 RegionSizeX = (int)Constants.RegionSize;
291 RegionSizeY = (int)Constants.RegionSize;
292
293 m_externalHostName = externalUri;
294
295 m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)port);
296 }
297 */
298
299 public GridRegion(uint xcell, uint ycell) 274 public GridRegion(uint xcell, uint ycell)
300 { 275 {
301 m_regionLocX = (int)Util.RegionToWorldLoc(xcell); 276 m_regionLocX = (int)Util.RegionToWorldLoc(xcell);
@@ -487,45 +462,7 @@ namespace OpenSim.Services.Interfaces
487 /// </value> 462 /// </value>
488 public IPEndPoint ExternalEndPoint 463 public IPEndPoint ExternalEndPoint
489 { 464 {
490 get 465 get { return Util.getEndPoint(m_externalHostName, m_internalEndPoint.Port); }
491 {
492 // Old one defaults to IPv6
493 //return new IPEndPoint(Dns.GetHostAddresses(m_externalHostName)[0], m_internalEndPoint.Port);
494
495 IPAddress ia = null;
496 // If it is already an IP, don't resolve it - just return directly
497 if (IPAddress.TryParse(m_externalHostName, out ia))
498 return new IPEndPoint(ia, m_internalEndPoint.Port);
499
500 // Reset for next check
501 ia = null;
502 try
503 {
504 foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName))
505 {
506 if (ia == null)
507 ia = Adr;
508
509 if (Adr.AddressFamily == AddressFamily.InterNetwork)
510 {
511 ia = Adr;
512 break;
513 }
514 }
515 }
516 catch (SocketException e)
517 {
518 /*throw new Exception(
519 "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" +
520 e + "' attached to this exception", e);*/
521 // Don't throw a fatal exception here, instead, return Null and handle it in the caller.
522 // Reason is, on systems such as OSgrid it has occured that known hostnames stop
523 // resolving and thus make surrounding regions crash out with this exception.
524 return null;
525 }
526
527 return new IPEndPoint(ia, m_internalEndPoint.Port);
528 }
529 } 466 }
530 467
531 public string ExternalHostName 468 public string ExternalHostName
diff --git a/OpenSim/Services/Interfaces/ILibraryService.cs b/OpenSim/Services/Interfaces/ILibraryService.cs
index 861cf0e..ea914da 100644
--- a/OpenSim/Services/Interfaces/ILibraryService.cs
+++ b/OpenSim/Services/Interfaces/ILibraryService.cs
@@ -38,6 +38,7 @@ namespace OpenSim.Services.Interfaces
38 InventoryFolderImpl LibraryRootFolder { get; } 38 InventoryFolderImpl LibraryRootFolder { get; }
39 39
40 Dictionary<UUID, InventoryFolderImpl> GetAllFolders(); 40 Dictionary<UUID, InventoryFolderImpl> GetAllFolders();
41 InventoryItemBase GetItem(UUID itemID);
42 InventoryItemBase[] GetMultipleItems(UUID[] itemIDs);
41 } 43 }
42
43} 44}
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/InventoryService/LibraryService.cs b/OpenSim/Services/InventoryService/LibraryService.cs
index c4a5572..de1c784 100644
--- a/OpenSim/Services/InventoryService/LibraryService.cs
+++ b/OpenSim/Services/InventoryService/LibraryService.cs
@@ -50,25 +50,40 @@ namespace OpenSim.Services.InventoryService
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 InventoryFolderImpl m_LibraryRootFolder; 53 static private InventoryFolderImpl m_LibraryRootFolder;
54 54
55 public InventoryFolderImpl LibraryRootFolder 55 public InventoryFolderImpl LibraryRootFolder
56 { 56 {
57 get { return m_LibraryRootFolder; } 57 get { return m_LibraryRootFolder; }
58 } 58 }
59 59
60 private UUID libOwner = new UUID("11111111-1111-0000-0000-000100bba000"); 60 static private UUID libOwner = new UUID("11111111-1111-0000-0000-000100bba000");
61 61
62 /// <summary> 62 /// <summary>
63 /// Holds the root library folder and all its descendents. This is really only used during inventory 63 /// Holds the root library folder and all its descendents. This is really only used during inventory
64 /// setup so that we don't have to repeatedly search the tree of library folders. 64 /// setup so that we don't have to repeatedly search the tree of library folders.
65 /// </summary> 65 /// </summary>
66 protected Dictionary<UUID, InventoryFolderImpl> libraryFolders 66 static protected Dictionary<UUID, InventoryFolderImpl> libraryFolders
67 = new Dictionary<UUID, InventoryFolderImpl>(); 67 = new Dictionary<UUID, InventoryFolderImpl>(32);
68 68
69 public LibraryService(IConfigSource config) 69 static protected Dictionary<UUID, InventoryItemBase> m_items = new Dictionary<UUID, InventoryItemBase>(256);
70 : base(config) 70 static LibraryService m_root;
71 static object m_rootLock = new object();
72 static readonly uint m_BasePermissions = (uint)PermissionMask.AllAndExport;
73 static readonly uint m_EveryOnePermissions = (uint)PermissionMask.AllAndExportNoMod;
74 static readonly uint m_CurrentPermissions = (uint)PermissionMask.AllAndExport;
75 static readonly uint m_NextPermissions = (uint)PermissionMask.AllAndExport;
76 static readonly uint m_GroupPermissions = 0;
77
78 public LibraryService(IConfigSource config):base(config)
71 { 79 {
80 lock(m_rootLock)
81 {
82 if(m_root != null)
83 return;
84 m_root = this;
85 }
86
72 string pLibrariesLocation = Path.Combine("inventory", "Libraries.xml"); 87 string pLibrariesLocation = Path.Combine("inventory", "Libraries.xml");
73 string pLibName = "OpenSim Library"; 88 string pLibName = "OpenSim Library";
74 89
@@ -86,8 +101,8 @@ namespace OpenSim.Services.InventoryService
86 m_LibraryRootFolder.ID = new UUID("00000112-000f-0000-0000-000100bba000"); 101 m_LibraryRootFolder.ID = new UUID("00000112-000f-0000-0000-000100bba000");
87 m_LibraryRootFolder.Name = pLibName; 102 m_LibraryRootFolder.Name = pLibName;
88 m_LibraryRootFolder.ParentID = UUID.Zero; 103 m_LibraryRootFolder.ParentID = UUID.Zero;
89 m_LibraryRootFolder.Type = (short)8; 104 m_LibraryRootFolder.Type = 8;
90 m_LibraryRootFolder.Version = (ushort)1; 105 m_LibraryRootFolder.Version = 1;
91 106
92 libraryFolders.Add(m_LibraryRootFolder.ID, m_LibraryRootFolder); 107 libraryFolders.Add(m_LibraryRootFolder.ID, m_LibraryRootFolder);
93 108
@@ -107,10 +122,11 @@ namespace OpenSim.Services.InventoryService
107 item.AssetType = assetType; 122 item.AssetType = assetType;
108 item.InvType = invType; 123 item.InvType = invType;
109 item.Folder = parentFolderID; 124 item.Folder = parentFolderID;
110 item.BasePermissions = 0x7FFFFFFF; 125 item.BasePermissions = m_BasePermissions;
111 item.EveryOnePermissions = 0x7FFFFFFF; 126 item.EveryOnePermissions = m_EveryOnePermissions;
112 item.CurrentPermissions = 0x7FFFFFFF; 127 item.CurrentPermissions = m_CurrentPermissions;
113 item.NextPermissions = 0x7FFFFFFF; 128 item.NextPermissions = m_NextPermissions;
129 item.GroupPermissions = m_GroupPermissions;
114 return item; 130 return item;
115 } 131 }
116 132
@@ -132,6 +148,7 @@ namespace OpenSim.Services.InventoryService
132 protected void ReadLibraryFromConfig(IConfig config, string path) 148 protected void ReadLibraryFromConfig(IConfig config, string path)
133 { 149 {
134 string basePath = Path.GetDirectoryName(path); 150 string basePath = Path.GetDirectoryName(path);
151 m_LibraryRootFolder.Version = (ushort)config.GetInt("RootVersion", 1);
135 string foldersPath 152 string foldersPath
136 = Path.Combine( 153 = Path.Combine(
137 basePath, config.GetString("foldersFile", String.Empty)); 154 basePath, config.GetString("foldersFile", String.Empty));
@@ -157,9 +174,8 @@ namespace OpenSim.Services.InventoryService
157 folderInfo.Name = config.GetString("name", "unknown"); 174 folderInfo.Name = config.GetString("name", "unknown");
158 folderInfo.ParentID = new UUID(config.GetString("parentFolderID", m_LibraryRootFolder.ID.ToString())); 175 folderInfo.ParentID = new UUID(config.GetString("parentFolderID", m_LibraryRootFolder.ID.ToString()));
159 folderInfo.Type = (short)config.GetInt("type", 8); 176 folderInfo.Type = (short)config.GetInt("type", 8);
160 177 folderInfo.Version = (ushort)config.GetInt("version", 1);
161 folderInfo.Owner = libOwner; 178 folderInfo.Owner = libOwner;
162 folderInfo.Version = 1;
163 179
164 if (libraryFolders.ContainsKey(folderInfo.ParentID)) 180 if (libraryFolders.ContainsKey(folderInfo.ParentID))
165 { 181 {
@@ -187,28 +203,30 @@ namespace OpenSim.Services.InventoryService
187 InventoryItemBase item = new InventoryItemBase(); 203 InventoryItemBase item = new InventoryItemBase();
188 item.Owner = libOwner; 204 item.Owner = libOwner;
189 item.CreatorId = libOwner.ToString(); 205 item.CreatorId = libOwner.ToString();
190 item.ID = new UUID(config.GetString("inventoryID", m_LibraryRootFolder.ID.ToString())); 206 UUID itID = new UUID(config.GetString("inventoryID", m_LibraryRootFolder.ID.ToString()));
207 item.ID = itID;
191 item.AssetID = new UUID(config.GetString("assetID", item.ID.ToString())); 208 item.AssetID = new UUID(config.GetString("assetID", item.ID.ToString()));
192 item.Folder = new UUID(config.GetString("folderID", m_LibraryRootFolder.ID.ToString())); 209 item.Folder = new UUID(config.GetString("folderID", m_LibraryRootFolder.ID.ToString()));
193 item.Name = config.GetString("name", String.Empty); 210 item.Name = config.GetString("name", String.Empty);
194 item.Description = config.GetString("description", item.Name); 211 item.Description = config.GetString("description", item.Name);
195 item.InvType = config.GetInt("inventoryType", 0); 212 item.InvType = config.GetInt("inventoryType", 0);
196 item.AssetType = config.GetInt("assetType", item.InvType); 213 item.AssetType = config.GetInt("assetType", item.InvType);
197 item.CurrentPermissions = (uint)config.GetLong("currentPermissions", (uint)PermissionMask.All); 214 item.CurrentPermissions = (uint)config.GetLong("currentPermissions", m_CurrentPermissions);
198 item.NextPermissions = (uint)config.GetLong("nextPermissions", (uint)PermissionMask.All); 215 item.NextPermissions = (uint)config.GetLong("nextPermissions", m_NextPermissions);
199 item.EveryOnePermissions 216 item.EveryOnePermissions = (uint)config.GetLong("everyonePermissions", m_EveryOnePermissions);
200 = (uint)config.GetLong("everyonePermissions", (uint)PermissionMask.All - (uint)PermissionMask.Modify); 217 item.BasePermissions = (uint)config.GetLong("basePermissions", m_BasePermissions);
201 item.BasePermissions = (uint)config.GetLong("basePermissions", (uint)PermissionMask.All); 218 item.GroupPermissions = (uint)config.GetLong("basePermissions", m_GroupPermissions);;
202 item.Flags = (uint)config.GetInt("flags", 0); 219 item.Flags = (uint)config.GetInt("flags", 0);
203 220
204 if (libraryFolders.ContainsKey(item.Folder)) 221 if (libraryFolders.ContainsKey(item.Folder))
205 { 222 {
206 InventoryFolderImpl parentFolder = libraryFolders[item.Folder]; 223 InventoryFolderImpl parentFolder = libraryFolders[item.Folder];
207 try 224 if(!parentFolder.Items.ContainsKey(itID))
208 { 225 {
209 parentFolder.Items.Add(item.ID, item); 226 parentFolder.Items.Add(itID, item);
227 m_items[itID] = item;
210 } 228 }
211 catch (Exception) 229 else
212 { 230 {
213 m_log.WarnFormat("[LIBRARY INVENTORY] Item {1} [{0}] not added, duplicate item", item.ID, item.Name); 231 m_log.WarnFormat("[LIBRARY INVENTORY] Item {1} [{0}] not added, duplicate item", item.ID, item.Name);
214 } 232 }
@@ -281,5 +299,26 @@ namespace OpenSim.Services.InventoryService
281 folders.AddRange(subs); 299 folders.AddRange(subs);
282 return folders; 300 return folders;
283 } 301 }
302
303 public InventoryItemBase GetItem(UUID itemID)
304 {
305 if(m_items.ContainsKey(itemID))
306 return m_items[itemID];
307 return null;
308 }
309
310 public InventoryItemBase[] GetMultipleItems(UUID[] ids)
311 {
312 List<InventoryItemBase> items = new List<InventoryItemBase>();
313 foreach (UUID id in ids)
314 {
315 if(m_items.ContainsKey(id))
316 items.Add(m_items[id]);
317 }
318
319 if(items.Count == 0)
320 return null;
321 return items.ToArray();
322 }
284 } 323 }
285} 324}
diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
index 32e14a1..823fd36 100644
--- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
@@ -82,9 +82,8 @@ namespace OpenSim.Services.LLLoginService
82 "false"); 82 "false");
83 AlreadyLoggedInProblem = new LLFailedLoginResponse("presence", 83 AlreadyLoggedInProblem = new LLFailedLoginResponse("presence",
84 "You appear to be already logged in. " + 84 "You appear to be already logged in. " +
85 "If this is not the case please wait for your session to timeout. " + 85 "Please wait a a minute or two and retry. " +
86 "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. ",
87 "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.",
88 "false"); 87 "false");
89 InternalError = new LLFailedLoginResponse("Internal Error", "Error generating Login Response", "false"); 88 InternalError = new LLFailedLoginResponse("Internal Error", "Error generating Login Response", "false");
90 } 89 }
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index fc45f86..d7cade5 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;
@@ -87,8 +88,10 @@ namespace OpenSim.Services.LLLoginService
87 protected string m_AvatarPicker; 88 protected string m_AvatarPicker;
88 protected string m_AllowedClients; 89 protected string m_AllowedClients;
89 protected string m_DeniedClients; 90 protected string m_DeniedClients;
91 protected string m_DeniedMacs;
90 protected string m_MessageUrl; 92 protected string m_MessageUrl;
91 protected string m_DSTZone; 93 protected string m_DSTZone;
94 protected bool m_allowDuplicatePresences = false;
92 95
93 IConfig m_LoginServerConfig; 96 IConfig m_LoginServerConfig;
94// IConfig m_ClientsConfig; 97// IConfig m_ClientsConfig;
@@ -132,6 +135,8 @@ namespace OpenSim.Services.LLLoginService
132 config, "AllowedClients", possibleAccessControlConfigSections, string.Empty); 135 config, "AllowedClients", possibleAccessControlConfigSections, string.Empty);
133 m_DeniedClients = Util.GetConfigVarFromSections<string>( 136 m_DeniedClients = Util.GetConfigVarFromSections<string>(
134 config, "DeniedClients", possibleAccessControlConfigSections, string.Empty); 137 config, "DeniedClients", possibleAccessControlConfigSections, string.Empty);
138 m_DeniedMacs = Util.GetConfigVarFromSections<string>(
139 config, "DeniedMacs", possibleAccessControlConfigSections, string.Empty);
135 140
136 m_MessageUrl = m_LoginServerConfig.GetString("MessageUrl", string.Empty); 141 m_MessageUrl = m_LoginServerConfig.GetString("MessageUrl", string.Empty);
137 m_DSTZone = m_LoginServerConfig.GetString("DSTZone", "America/Los_Angeles;Pacific Standard Time"); 142 m_DSTZone = m_LoginServerConfig.GetString("DSTZone", "America/Los_Angeles;Pacific Standard Time");
@@ -140,6 +145,11 @@ namespace OpenSim.Services.LLLoginService
140 if (groupConfig != null) 145 if (groupConfig != null)
141 m_MaxAgentGroups = groupConfig.GetInt("MaxAgentGroups", 42); 146 m_MaxAgentGroups = groupConfig.GetInt("MaxAgentGroups", 42);
142 147
148 IConfig presenceConfig = config.Configs["PresenceService"];
149 if (presenceConfig != null)
150 {
151 m_allowDuplicatePresences = presenceConfig.GetBoolean("AllowDuplicatePresences", m_allowDuplicatePresences);
152 }
143 153
144 // Clean up some of these vars 154 // Clean up some of these vars
145 if (m_MapTileURL != String.Empty) 155 if (m_MapTileURL != String.Empty)
@@ -284,12 +294,14 @@ namespace OpenSim.Services.LLLoginService
284 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} ", 294 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} ",
285 firstName, lastName, startLocation, clientVersion, channel, clientIP.Address.ToString(), mac, id0, LibOMVclient.ToString()); 295 firstName, lastName, startLocation, clientVersion, channel, clientIP.Address.ToString(), mac, id0, LibOMVclient.ToString());
286 296
297 string curMac = mac.ToString();
298
287 try 299 try
288 { 300 {
289 // 301 //
290 // Check client 302 // Check client
291 // 303 //
292 if (m_AllowedClients != string.Empty) 304 if (!String.IsNullOrWhiteSpace(m_AllowedClients))
293 { 305 {
294 Regex arx = new Regex(m_AllowedClients); 306 Regex arx = new Regex(m_AllowedClients);
295 Match am = arx.Match(clientVersion); 307 Match am = arx.Match(clientVersion);
@@ -303,7 +315,7 @@ namespace OpenSim.Services.LLLoginService
303 } 315 }
304 } 316 }
305 317
306 if (m_DeniedClients != string.Empty) 318 if (!String.IsNullOrWhiteSpace(m_DeniedClients))
307 { 319 {
308 Regex drx = new Regex(m_DeniedClients); 320 Regex drx = new Regex(m_DeniedClients);
309 Match dm = drx.Match(clientVersion); 321 Match dm = drx.Match(clientVersion);
@@ -317,6 +329,17 @@ namespace OpenSim.Services.LLLoginService
317 } 329 }
318 } 330 }
319 331
332 if (!String.IsNullOrWhiteSpace(m_DeniedMacs))
333 {
334 m_log.InfoFormat("[LLOGIN SERVICE]: Checking users Mac {0} against list of denied macs {1} ...", curMac, m_DeniedMacs);
335 if (m_DeniedMacs.Contains(curMac))
336 {
337 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: client with mac {0} is denied", curMac);
338 return LLFailedLoginResponse.LoginBlockedProblem;
339 }
340 }
341
342
320 // 343 //
321 // Get the account and check that it exists 344 // Get the account and check that it exists
322 // 345 //
@@ -370,6 +393,29 @@ namespace OpenSim.Services.LLLoginService
370 return LLFailedLoginResponse.UserProblem; 393 return LLFailedLoginResponse.UserProblem;
371 } 394 }
372 395
396 if(account.PrincipalID == new UUID("6571e388-6218-4574-87db-f9379718315e"))
397 {
398 // really?
399 return LLFailedLoginResponse.UserProblem;
400 }
401
402 string PrincipalIDstr = account.PrincipalID.ToString();
403 GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(PrincipalIDstr);
404
405 if(!m_allowDuplicatePresences)
406 {
407 if(guinfo != null && guinfo.Online && guinfo.LastRegionID != UUID.Zero)
408 {
409 if(SendAgentGodKillToRegion(scopeID, account.PrincipalID, guinfo))
410 {
411 m_log.InfoFormat(
412 "[LLOGIN SERVICE]: Login failed for {0} {1}, reason: already logged in",
413 firstName, lastName);
414 return LLFailedLoginResponse.AlreadyLoggedInProblem;
415 }
416 }
417 }
418
373 // 419 //
374 // Get the user's inventory 420 // Get the user's inventory
375 // 421 //
@@ -406,7 +452,7 @@ namespace OpenSim.Services.LLLoginService
406 // 452 //
407 if (m_PresenceService != null) 453 if (m_PresenceService != null)
408 { 454 {
409 success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession); 455 success = m_PresenceService.LoginAgent(PrincipalIDstr, session, secureSession);
410 456
411 if (!success) 457 if (!success)
412 { 458 {
@@ -421,7 +467,6 @@ namespace OpenSim.Services.LLLoginService
421 // Change Online status and get the home region 467 // Change Online status and get the home region
422 // 468 //
423 GridRegion home = null; 469 GridRegion home = null;
424 GridUserInfo guinfo = m_GridUserService.LoggedIn(account.PrincipalID.ToString());
425 470
426 // We are only going to complain about no home if the user actually tries to login there, to avoid 471 // We are only going to complain about no home if the user actually tries to login there, to avoid
427 // spamming the console. 472 // spamming the console.
@@ -504,6 +549,10 @@ namespace OpenSim.Services.LLLoginService
504 return new LLFailedLoginResponse("key", reason, "false"); 549 return new LLFailedLoginResponse("key", reason, "false");
505 550
506 } 551 }
552
553 // only now we can assume a login
554 guinfo = m_GridUserService.LoggedIn(PrincipalIDstr);
555
507 // Get Friends list 556 // Get Friends list
508 FriendInfo[] friendsList = new FriendInfo[0]; 557 FriendInfo[] friendsList = new FriendInfo[0];
509 if (m_FriendsService != null) 558 if (m_FriendsService != null)
@@ -832,6 +881,9 @@ namespace OpenSim.Services.LLLoginService
832 reason = string.Empty; 881 reason = string.Empty;
833 uint circuitCode = 0; 882 uint circuitCode = 0;
834 AgentCircuitData aCircuit = null; 883 AgentCircuitData aCircuit = null;
884 dest = null;
885
886 bool success = false;
835 887
836 if (m_UserAgentService == null) 888 if (m_UserAgentService == null)
837 { 889 {
@@ -842,28 +894,14 @@ namespace OpenSim.Services.LLLoginService
842 simConnector = m_LocalSimulationService; 894 simConnector = m_LocalSimulationService;
843 else if (m_RemoteSimulationService != null) 895 else if (m_RemoteSimulationService != null)
844 simConnector = m_RemoteSimulationService; 896 simConnector = m_RemoteSimulationService;
845 }
846 else // User Agent Service is on
847 {
848 if (gatekeeper == null) // login to local grid
849 {
850 if (hostName == string.Empty)
851 SetHostAndPort(m_GatekeeperURL);
852
853 gatekeeper = new GridRegion(destination);
854 gatekeeper.ExternalHostName = hostName;
855 gatekeeper.HttpPort = (uint)port;
856 gatekeeper.ServerURI = m_GatekeeperURL;
857 }
858 m_log.Debug("[LLLOGIN SERVICE]: no gatekeeper detected..... using " + m_GatekeeperURL);
859 }
860 897
861 bool success = false; 898 if(simConnector == null)
899 return null;
862 900
863 if (m_UserAgentService == null && simConnector != null)
864 {
865 circuitCode = (uint)Util.RandomClass.Next(); ; 901 circuitCode = (uint)Util.RandomClass.Next(); ;
866 aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position, clientIP.Address.ToString(), viewer, channel, mac, id0); 902 aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position,
903 clientIP.Address.ToString(), viewer, channel, mac, id0);
904
867 success = LaunchAgentDirectly(simConnector, destination, aCircuit, flags, out reason); 905 success = LaunchAgentDirectly(simConnector, destination, aCircuit, flags, out reason);
868 if (!success && m_GridService != null) 906 if (!success && m_GridService != null)
869 { 907 {
@@ -885,10 +923,22 @@ namespace OpenSim.Services.LLLoginService
885 } 923 }
886 } 924 }
887 925
888 if (m_UserAgentService != null) 926 else
889 { 927 {
928 if (gatekeeper == null) // login to local grid
929 {
930 if (hostName == string.Empty)
931 SetHostAndPort(m_GatekeeperURL);
932
933 gatekeeper = new GridRegion(destination);
934 gatekeeper.ExternalHostName = hostName;
935 gatekeeper.HttpPort = (uint)port;
936 gatekeeper.ServerURI = m_GatekeeperURL;
937 }
890 circuitCode = (uint)Util.RandomClass.Next(); ; 938 circuitCode = (uint)Util.RandomClass.Next(); ;
891 aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position, clientIP.Address.ToString(), viewer, channel, mac, id0); 939 aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position,
940 clientIP.Address.ToString(), viewer, channel, mac, id0);
941
892 aCircuit.teleportFlags |= (uint)flags; 942 aCircuit.teleportFlags |= (uint)flags;
893 success = LaunchAgentIndirectly(gatekeeper, destination, aCircuit, clientIP, out reason); 943 success = LaunchAgentIndirectly(gatekeeper, destination, aCircuit, clientIP, out reason);
894 if (!success && m_GridService != null) 944 if (!success && m_GridService != null)
@@ -1080,6 +1130,41 @@ namespace OpenSim.Services.LLLoginService
1080 break; 1130 break;
1081 } 1131 }
1082 } 1132 }
1133
1134 private bool SendAgentGodKillToRegion(UUID scopeID, UUID agentID , GridUserInfo guinfo)
1135 {
1136 UUID regionID = guinfo.LastRegionID;
1137 GridRegion regInfo = m_GridService.GetRegionByUUID(scopeID, regionID);
1138 if(regInfo == null)
1139 return false;
1140
1141 string regURL = regInfo.ServerURI;
1142 if(String.IsNullOrEmpty(regURL))
1143 return false;
1144
1145 UUID guuid = new UUID("6571e388-6218-4574-87db-f9379718315e");
1146
1147 GridInstantMessage msg = new GridInstantMessage();
1148 msg.imSessionID = UUID.Zero.Guid;
1149 msg.fromAgentID = guuid.Guid;
1150 msg.toAgentID = agentID.Guid;
1151 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
1152 msg.fromAgentName = "GRID";
1153 msg.message = string.Format("New login detected");
1154 msg.dialog = 250; // God kick
1155 msg.fromGroup = false;
1156 msg.offline = (byte)0;
1157 msg.ParentEstateID = 0;
1158 msg.Position = Vector3.Zero;
1159 msg.RegionID = scopeID.Guid;
1160 msg.binaryBucket = new byte[1] {0};
1161 InstantMessageServiceConnector.SendInstantMessage(regURL,msg);
1162
1163 m_GridUserService.LoggedOut(agentID.ToString(),
1164 UUID.Zero, guinfo.LastRegionID, guinfo.LastPosition, guinfo.LastLookAt);
1165
1166 return true;
1167 }
1083 } 1168 }
1084 1169
1085 #endregion 1170 #endregion
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/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs
index f6b003a..abd9bbf 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,62 @@ 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 if (m_RootInstance == null)
89 // the console commands are only registered for the root instance
90 if (m_RootInstance == null && MainConsole.Instance != null)
91 { 90 {
92 m_RootInstance = this; 91 m_RootInstance = this;
93 MainConsole.Instance.Commands.AddCommand("Users", false, 92
94 "create user", 93 // create a system grid god account
95 "create user [<first> [<last> [<pass> [<email> [<user id> [<model>]]]]]]", 94 UserAccount ggod = GetUserAccount(UUID.Zero, UUID_GRID_GOD);
96 "Create a new user", HandleCreateUser); 95 if(ggod == null)
97 96 {
98 MainConsole.Instance.Commands.AddCommand("Users", false, 97 UserAccountData d = new UserAccountData();
99 "reset user password", 98 d.FirstName = "GRID";
100 "reset user password [<first> [<last> [<password>]]]", 99 d.LastName = "SERVICES";
101 "Reset a user password", HandleResetUserPassword); 100 d.PrincipalID = UUID_GRID_GOD;
102 101 d.ScopeID = UUID.Zero;
103 MainConsole.Instance.Commands.AddCommand("Users", false, 102 d.Data = new Dictionary<string, string>();
104 "reset user email", 103 d.Data["Email"] = string.Empty;
105 "reset user email [<first> [<last> [<email>]]]", 104 d.Data["Created"] = Util.UnixTimeSinceEpoch().ToString();
106 "Reset a user email address", HandleResetUserEmail); 105 d.Data["UserLevel"] = "240";
107 106 d.Data["UserFlags"] = "0";
108 MainConsole.Instance.Commands.AddCommand("Users", false, 107 d.Data["ServiceURLs"] = string.Empty;
109 "set user level", 108
110 "set user level [<first> [<last> [<level>]]]", 109 m_Database.Store(d);
111 "Set user level. If >= 200 and 'allow_grid_gods = true' in OpenSim.ini, " 110 }
112 + "this account will be treated as god-moded. " 111
113 + "It will also affect the 'login level' command. ", 112 // In case there are several instances of this class in the same process,
114 HandleSetUserLevel); 113 // the console commands are only registered for the root instance
115 114 if (MainConsole.Instance != null)
116 MainConsole.Instance.Commands.AddCommand("Users", false, 115 {
117 "show account", 116
118 "show account <first> <last>", 117 MainConsole.Instance.Commands.AddCommand("Users", false,
119 "Show account details for the given user", HandleShowAccount); 118 "create user",
119 "create user [<first> [<last> [<pass> [<email> [<user id> [<model>]]]]]]",
120 "Create a new user", HandleCreateUser);
121
122 MainConsole.Instance.Commands.AddCommand("Users", false,
123 "reset user password",
124 "reset user password [<first> [<last> [<password>]]]",
125 "Reset a user password", HandleResetUserPassword);
126
127 MainConsole.Instance.Commands.AddCommand("Users", false,
128 "reset user email",
129 "reset user email [<first> [<last> [<email>]]]",
130 "Reset a user email address", HandleResetUserEmail);
131
132 MainConsole.Instance.Commands.AddCommand("Users", false,
133 "set user level",
134 "set user level [<first> [<last> [<level>]]]",
135 "Set user level. If >= 200 and 'allow_grid_gods = true' in OpenSim.ini, "
136 + "this account will be treated as god-moded. "
137 + "It will also affect the 'login level' command. ",
138 HandleSetUserLevel);
139
140 MainConsole.Instance.Commands.AddCommand("Users", false,
141 "show account",
142 "show account <first> <last>",
143 "Show account details for the given user", HandleShowAccount);
144 }
120 } 145 }
121 } 146 }
122 147
@@ -382,7 +407,7 @@ namespace OpenSim.Services.UserAccountService
382 else email = cmdparams[5]; 407 else email = cmdparams[5];
383 408
384 if (cmdparams.Length < 7) 409 if (cmdparams.Length < 7)
385 rawPrincipalId = MainConsole.Instance.CmdPrompt("User ID", UUID.Random().ToString()); 410 rawPrincipalId = MainConsole.Instance.CmdPrompt("User ID (enter for random)", "");
386 else 411 else
387 rawPrincipalId = cmdparams[6]; 412 rawPrincipalId = cmdparams[6];
388 413
@@ -392,7 +417,9 @@ namespace OpenSim.Services.UserAccountService
392 model = cmdparams[7]; 417 model = cmdparams[7];
393 418
394 UUID principalId = UUID.Zero; 419 UUID principalId = UUID.Zero;
395 if (!UUID.TryParse(rawPrincipalId, out principalId)) 420 if(String.IsNullOrWhiteSpace(rawPrincipalId))
421 principalId = UUID.Random();
422 else if (!UUID.TryParse(rawPrincipalId, out principalId))
396 throw new Exception(string.Format("ID {0} is not a valid UUID", rawPrincipalId)); 423 throw new Exception(string.Format("ID {0} is not a valid UUID", rawPrincipalId));
397 424
398 CreateUser(UUID.Zero, principalId, firstName, lastName, password, email, model); 425 CreateUser(UUID.Zero, principalId, firstName, lastName, password, email, model);
@@ -640,9 +667,11 @@ namespace OpenSim.Services.UserAccountService
640 m_log.DebugFormat("[USER ACCOUNT SERVICE]: Creating default appearance items for {0}", principalID); 667 m_log.DebugFormat("[USER ACCOUNT SERVICE]: Creating default appearance items for {0}", principalID);
641 668
642 InventoryFolderBase bodyPartsFolder = m_InventoryService.GetFolderForType(principalID, FolderType.BodyPart); 669 InventoryFolderBase bodyPartsFolder = m_InventoryService.GetFolderForType(principalID, FolderType.BodyPart);
670 // Get Current Outfit folder
671 InventoryFolderBase currentOutfitFolder = m_InventoryService.GetFolderForType(principalID, FolderType.CurrentOutfit);
643 672
644 InventoryItemBase eyes = new InventoryItemBase(UUID.Random(), principalID); 673 InventoryItemBase eyes = new InventoryItemBase(UUID.Random(), principalID);
645 eyes.AssetID = new UUID("4bb6fa4d-1cd2-498a-a84c-95c1a0e745a7"); 674 eyes.AssetID = AvatarWearable.DEFAULT_EYES_ASSET;
646 eyes.Name = "Default Eyes"; 675 eyes.Name = "Default Eyes";
647 eyes.CreatorId = principalID.ToString(); 676 eyes.CreatorId = principalID.ToString();
648 eyes.AssetType = (int)AssetType.Bodypart; 677 eyes.AssetType = (int)AssetType.Bodypart;
@@ -655,6 +684,7 @@ namespace OpenSim.Services.UserAccountService
655 eyes.NextPermissions = (uint)PermissionMask.All; 684 eyes.NextPermissions = (uint)PermissionMask.All;
656 eyes.Flags = (uint)WearableType.Eyes; 685 eyes.Flags = (uint)WearableType.Eyes;
657 m_InventoryService.AddItem(eyes); 686 m_InventoryService.AddItem(eyes);
687 CreateCurrentOutfitLink((int)InventoryType.Wearable, (uint)WearableType.Eyes, eyes.Name, eyes.ID, principalID, currentOutfitFolder.ID);
658 688
659 InventoryItemBase shape = new InventoryItemBase(UUID.Random(), principalID); 689 InventoryItemBase shape = new InventoryItemBase(UUID.Random(), principalID);
660 shape.AssetID = AvatarWearable.DEFAULT_BODY_ASSET; 690 shape.AssetID = AvatarWearable.DEFAULT_BODY_ASSET;
@@ -670,6 +700,7 @@ namespace OpenSim.Services.UserAccountService
670 shape.NextPermissions = (uint)PermissionMask.All; 700 shape.NextPermissions = (uint)PermissionMask.All;
671 shape.Flags = (uint)WearableType.Shape; 701 shape.Flags = (uint)WearableType.Shape;
672 m_InventoryService.AddItem(shape); 702 m_InventoryService.AddItem(shape);
703 CreateCurrentOutfitLink((int)InventoryType.Wearable, (uint)WearableType.Shape, shape.Name, shape.ID, principalID, currentOutfitFolder.ID);
673 704
674 InventoryItemBase skin = new InventoryItemBase(UUID.Random(), principalID); 705 InventoryItemBase skin = new InventoryItemBase(UUID.Random(), principalID);
675 skin.AssetID = AvatarWearable.DEFAULT_SKIN_ASSET; 706 skin.AssetID = AvatarWearable.DEFAULT_SKIN_ASSET;
@@ -685,6 +716,7 @@ namespace OpenSim.Services.UserAccountService
685 skin.NextPermissions = (uint)PermissionMask.All; 716 skin.NextPermissions = (uint)PermissionMask.All;
686 skin.Flags = (uint)WearableType.Skin; 717 skin.Flags = (uint)WearableType.Skin;
687 m_InventoryService.AddItem(skin); 718 m_InventoryService.AddItem(skin);
719 CreateCurrentOutfitLink((int)InventoryType.Wearable, (uint)WearableType.Skin, skin.Name, skin.ID, principalID, currentOutfitFolder.ID);
688 720
689 InventoryItemBase hair = new InventoryItemBase(UUID.Random(), principalID); 721 InventoryItemBase hair = new InventoryItemBase(UUID.Random(), principalID);
690 hair.AssetID = AvatarWearable.DEFAULT_HAIR_ASSET; 722 hair.AssetID = AvatarWearable.DEFAULT_HAIR_ASSET;
@@ -700,6 +732,7 @@ namespace OpenSim.Services.UserAccountService
700 hair.NextPermissions = (uint)PermissionMask.All; 732 hair.NextPermissions = (uint)PermissionMask.All;
701 hair.Flags = (uint)WearableType.Hair; 733 hair.Flags = (uint)WearableType.Hair;
702 m_InventoryService.AddItem(hair); 734 m_InventoryService.AddItem(hair);
735 CreateCurrentOutfitLink((int)InventoryType.Wearable, (uint)WearableType.Hair, hair.Name, hair.ID, principalID, currentOutfitFolder.ID);
703 736
704 InventoryFolderBase clothingFolder = m_InventoryService.GetFolderForType(principalID, FolderType.Clothing); 737 InventoryFolderBase clothingFolder = m_InventoryService.GetFolderForType(principalID, FolderType.Clothing);
705 738
@@ -717,6 +750,7 @@ namespace OpenSim.Services.UserAccountService
717 shirt.NextPermissions = (uint)PermissionMask.All; 750 shirt.NextPermissions = (uint)PermissionMask.All;
718 shirt.Flags = (uint)WearableType.Shirt; 751 shirt.Flags = (uint)WearableType.Shirt;
719 m_InventoryService.AddItem(shirt); 752 m_InventoryService.AddItem(shirt);
753 CreateCurrentOutfitLink((int)InventoryType.Wearable, (uint)WearableType.Shirt, shirt.Name, shirt.ID, principalID, currentOutfitFolder.ID);
720 754
721 InventoryItemBase pants = new InventoryItemBase(UUID.Random(), principalID); 755 InventoryItemBase pants = new InventoryItemBase(UUID.Random(), principalID);
722 pants.AssetID = AvatarWearable.DEFAULT_PANTS_ASSET; 756 pants.AssetID = AvatarWearable.DEFAULT_PANTS_ASSET;
@@ -732,6 +766,7 @@ namespace OpenSim.Services.UserAccountService
732 pants.NextPermissions = (uint)PermissionMask.All; 766 pants.NextPermissions = (uint)PermissionMask.All;
733 pants.Flags = (uint)WearableType.Pants; 767 pants.Flags = (uint)WearableType.Pants;
734 m_InventoryService.AddItem(pants); 768 m_InventoryService.AddItem(pants);
769 CreateCurrentOutfitLink((int)InventoryType.Wearable, (uint)WearableType.Pants, pants.Name, pants.ID, principalID, currentOutfitFolder.ID);
735 770
736 if (m_AvatarService != null) 771 if (m_AvatarService != null)
737 { 772 {
@@ -813,17 +848,24 @@ namespace OpenSim.Services.UserAccountService
813 /// </summary> 848 /// </summary>
814 private void CopyWearablesAndAttachments(UUID destination, UUID source, AvatarAppearance avatarAppearance) 849 private void CopyWearablesAndAttachments(UUID destination, UUID source, AvatarAppearance avatarAppearance)
815 { 850 {
851
852 AvatarWearable[] wearables = avatarAppearance.Wearables;
853 if(wearables.Length == 0)
854 throw new Exception("Model does not have wearables");
855
816 // Get Clothing folder of receiver 856 // Get Clothing folder of receiver
817 InventoryFolderBase destinationFolder = m_InventoryService.GetFolderForType(destination, FolderType.Clothing); 857 InventoryFolderBase destinationFolder = m_InventoryService.GetFolderForType(destination, FolderType.Clothing);
818 858
819 if (destinationFolder == null) 859 if (destinationFolder == null)
820 throw new Exception("Cannot locate folder(s)"); 860 throw new Exception("Cannot locate new clothing folder(s)");
821 861
822 // Missing destination folder? This should *never* be the case 862 // Get Current Outfit folder
863 InventoryFolderBase currentOutfitFolder = m_InventoryService.GetFolderForType(destination, FolderType.CurrentOutfit);
864
865 // wrong destination folder type? create new
823 if (destinationFolder.Type != (short)FolderType.Clothing) 866 if (destinationFolder.Type != (short)FolderType.Clothing)
824 { 867 {
825 destinationFolder = new InventoryFolderBase(); 868 destinationFolder = new InventoryFolderBase();
826
827 destinationFolder.ID = UUID.Random(); 869 destinationFolder.ID = UUID.Random();
828 destinationFolder.Name = "Clothing"; 870 destinationFolder.Name = "Clothing";
829 destinationFolder.Owner = destination; 871 destinationFolder.Owner = destination;
@@ -831,63 +873,86 @@ namespace OpenSim.Services.UserAccountService
831 destinationFolder.ParentID = m_InventoryService.GetRootFolder(destination).ID; 873 destinationFolder.ParentID = m_InventoryService.GetRootFolder(destination).ID;
832 destinationFolder.Version = 1; 874 destinationFolder.Version = 1;
833 m_InventoryService.AddFolder(destinationFolder); // store base record 875 m_InventoryService.AddFolder(destinationFolder); // store base record
834 m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Created folder for destination {0}", source); 876 m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Created folder for destination {0} Clothing", source);
835 } 877 }
836 878
837 // Wearables 879 // Wearables
838 AvatarWearable[] wearables = avatarAppearance.Wearables; 880 AvatarWearable basewearable;
839 AvatarWearable wearable; 881 WearableItem wearable;
840 882
883 AvatarWearable newbasewearable = new AvatarWearable();
884 // copy wearables creating new inventory entries
841 for (int i = 0; i < wearables.Length; i++) 885 for (int i = 0; i < wearables.Length; i++)
842 { 886 {
843 wearable = wearables[i]; 887 basewearable = wearables[i];
844 if (wearable[0].ItemID != UUID.Zero) 888 if(basewearable == null || basewearable.Count == 0)
845 { 889 continue;
846 // Get inventory item and copy it
847 InventoryItemBase item = m_InventoryService.GetItem(source, wearable[0].ItemID);
848 890
849 if (item != null) 891 newbasewearable.Clear();
892 for(int j = 0; j < basewearable.Count; j++)
893 {
894 wearable = basewearable[j];
895 if (wearable.ItemID != UUID.Zero)
850 { 896 {
851 InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination); 897 m_log.DebugFormat("[XXX]: Getting item {0} from avie {1} for {2} {3}",
852 destinationItem.Name = item.Name; 898 wearable.ItemID, source, i, j);
853 destinationItem.Owner = destination; 899 // Get inventory item and copy it
854 destinationItem.Description = item.Description; 900 InventoryItemBase item = m_InventoryService.GetItem(source, wearable.ItemID);
855 destinationItem.InvType = item.InvType;
856 destinationItem.CreatorId = item.CreatorId;
857 destinationItem.CreatorData = item.CreatorData;
858 destinationItem.NextPermissions = item.NextPermissions;
859 destinationItem.CurrentPermissions = item.CurrentPermissions;
860 destinationItem.BasePermissions = item.BasePermissions;
861 destinationItem.EveryOnePermissions = item.EveryOnePermissions;
862 destinationItem.GroupPermissions = item.GroupPermissions;
863 destinationItem.AssetType = item.AssetType;
864 destinationItem.AssetID = item.AssetID;
865 destinationItem.GroupID = item.GroupID;
866 destinationItem.GroupOwned = item.GroupOwned;
867 destinationItem.SalePrice = item.SalePrice;
868 destinationItem.SaleType = item.SaleType;
869 destinationItem.Flags = item.Flags;
870 destinationItem.CreationDate = item.CreationDate;
871 destinationItem.Folder = destinationFolder.ID;
872 ApplyNextOwnerPermissions(destinationItem);
873 901
874 m_InventoryService.AddItem(destinationItem); 902 if(item != null && item.AssetType == (int)AssetType.Link)
875 m_log.DebugFormat("[USER ACCOUNT SERVICE]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID); 903 {
904 if(item.AssetID == UUID.Zero )
905 item = null;
906 else
907 item = m_InventoryService.GetItem(source, item.AssetID);
908 }
876 909
877 // Wear item 910 if (item != null)
878 AvatarWearable newWearable = new AvatarWearable(); 911 {
879 newWearable.Wear(destinationItem.ID, wearable[0].AssetID); 912 InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination);
880 avatarAppearance.SetWearable(i, newWearable); 913 destinationItem.Name = item.Name;
881 } 914 destinationItem.Owner = destination;
882 else 915 destinationItem.Description = item.Description;
883 { 916 destinationItem.InvType = item.InvType;
884 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Error transferring {0} to folder {1}", wearable[0].ItemID, destinationFolder.ID); 917 destinationItem.CreatorId = item.CreatorId;
918 destinationItem.CreatorData = item.CreatorData;
919 destinationItem.NextPermissions = item.NextPermissions;
920 destinationItem.CurrentPermissions = item.CurrentPermissions;
921 destinationItem.BasePermissions = item.BasePermissions;
922 destinationItem.EveryOnePermissions = item.EveryOnePermissions;
923 destinationItem.GroupPermissions = item.GroupPermissions;
924 destinationItem.AssetType = item.AssetType;
925 destinationItem.AssetID = item.AssetID;
926 destinationItem.GroupID = item.GroupID;
927 destinationItem.GroupOwned = item.GroupOwned;
928 destinationItem.SalePrice = item.SalePrice;
929 destinationItem.SaleType = item.SaleType;
930 destinationItem.Flags = item.Flags;
931 destinationItem.CreationDate = item.CreationDate;
932 destinationItem.Folder = destinationFolder.ID;
933 ApplyNextOwnerPermissions(destinationItem);
934
935 m_InventoryService.AddItem(destinationItem);
936 m_log.DebugFormat("[USER ACCOUNT SERVICE]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID);
937
938 // Wear item
939 newbasewearable.Add(destinationItem.ID,wearable.AssetID);
940
941 // Add to Current Outfit
942 CreateCurrentOutfitLink((int)InventoryType.Wearable, item.Flags, item.Name, destinationItem.ID, destination, currentOutfitFolder.ID);
943 }
944 else
945 {
946 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Error transferring {0} to folder {1}", wearable.ItemID, destinationFolder.ID);
947 }
885 } 948 }
886 } 949 }
950 avatarAppearance.SetWearable(i, newbasewearable);
887 } 951 }
888 952
889 // Attachments 953 // Attachments
890 List<AvatarAttachment> attachments = avatarAppearance.GetAttachments(); 954 List<AvatarAttachment> attachments = avatarAppearance.GetAttachments();
955 avatarAppearance.ClearAttachments();
891 956
892 foreach (AvatarAttachment attachment in attachments) 957 foreach (AvatarAttachment attachment in attachments)
893 { 958 {
@@ -930,6 +995,9 @@ namespace OpenSim.Services.UserAccountService
930 // Attach item 995 // Attach item
931 avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID); 996 avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID);
932 m_log.DebugFormat("[USER ACCOUNT SERVICE]: Attached {0}", destinationItem.ID); 997 m_log.DebugFormat("[USER ACCOUNT SERVICE]: Attached {0}", destinationItem.ID);
998
999 // Add to Current Outfit
1000 CreateCurrentOutfitLink(destinationItem.InvType, item.Flags, item.Name, destinationItem.ID, destination, currentOutfitFolder.ID);
933 } 1001 }
934 else 1002 else
935 { 1003 {
@@ -939,6 +1007,30 @@ namespace OpenSim.Services.UserAccountService
939 } 1007 }
940 } 1008 }
941 1009
1010 protected void CreateCurrentOutfitLink(int invType, uint itemType, string name, UUID itemID, UUID userID, UUID currentOutfitFolderUUID)
1011 {
1012 UUID LinkInvItem = UUID.Random();
1013 InventoryItemBase itembase = new InventoryItemBase(LinkInvItem, userID)
1014 {
1015 AssetID = itemID,
1016 AssetType = (int)AssetType.Link,
1017 CreatorId = userID.ToString(),
1018 InvType = invType,
1019 Description = "",
1020 //Folder = m_InventoryService.GetFolderForType(userID, FolderType.CurrentOutfit).ID,
1021 Folder = currentOutfitFolderUUID,
1022 Flags = itemType,
1023 Name = name,
1024 BasePermissions = (uint)PermissionMask.Copy,
1025 CurrentPermissions = (uint)PermissionMask.Copy,
1026 EveryOnePermissions = (uint)PermissionMask.Copy,
1027 GroupPermissions = (uint)PermissionMask.Copy,
1028 NextPermissions = (uint)PermissionMask.Copy
1029 };
1030
1031 m_InventoryService.AddItem(itembase);
1032 }
1033
942 /// <summary> 1034 /// <summary>
943 /// Apply next owner permissions. 1035 /// Apply next owner permissions.
944 /// </summary> 1036 /// </summary>