diff options
author | Melanie | 2010-03-03 02:07:03 +0000 |
---|---|---|
committer | Melanie | 2010-03-03 02:07:03 +0000 |
commit | 028a87fe37002e7a0611f66babf1deee46c83804 (patch) | |
tree | 387aec499fd60c2012bed8148e6a2ddc847c3d95 /OpenSim/Framework | |
parent | Revert "test" (diff) | |
parent | Fixes Region.Framework tests. Although these tests don't fail, they need to b... (diff) | |
download | opensim-SC-028a87fe37002e7a0611f66babf1deee46c83804.zip opensim-SC-028a87fe37002e7a0611f66babf1deee46c83804.tar.gz opensim-SC-028a87fe37002e7a0611f66babf1deee46c83804.tar.bz2 opensim-SC-028a87fe37002e7a0611f66babf1deee46c83804.tar.xz |
Merge branch 'master' into careminster-presence-refactor
This brings careminster on the level of master. To be tested
Diffstat (limited to '')
45 files changed, 903 insertions, 6876 deletions
diff --git a/OpenSim/Framework/AgentCircuitData.cs b/OpenSim/Framework/AgentCircuitData.cs index c0168e2..353e5bf 100644 --- a/OpenSim/Framework/AgentCircuitData.cs +++ b/OpenSim/Framework/AgentCircuitData.cs | |||
@@ -75,6 +75,11 @@ namespace OpenSim.Framework | |||
75 | public uint circuitcode; | 75 | public uint circuitcode; |
76 | 76 | ||
77 | /// <summary> | 77 | /// <summary> |
78 | /// How this agent got here | ||
79 | /// </summary> | ||
80 | public uint teleportFlags; | ||
81 | |||
82 | /// <summary> | ||
78 | /// Agent's account first name | 83 | /// Agent's account first name |
79 | /// </summary> | 84 | /// </summary> |
80 | public string firstname; | 85 | public string firstname; |
@@ -97,10 +102,18 @@ namespace OpenSim.Framework | |||
97 | public UUID SessionID; | 102 | public UUID SessionID; |
98 | 103 | ||
99 | /// <summary> | 104 | /// <summary> |
105 | /// Hypergrid service token; generated by the user domain, consumed by the receiving grid. | ||
106 | /// There is one such unique token for each grid visited. | ||
107 | /// </summary> | ||
108 | public string ServiceSessionID = string.Empty; | ||
109 | |||
110 | /// <summary> | ||
100 | /// Position the Agent's Avatar starts in the region | 111 | /// Position the Agent's Avatar starts in the region |
101 | /// </summary> | 112 | /// </summary> |
102 | public Vector3 startpos; | 113 | public Vector3 startpos; |
103 | 114 | ||
115 | public Dictionary<string, object> ServiceURLs; | ||
116 | |||
104 | public AgentCircuitData() | 117 | public AgentCircuitData() |
105 | { | 118 | { |
106 | } | 119 | } |
@@ -136,17 +149,19 @@ namespace OpenSim.Framework | |||
136 | args["base_folder"] = OSD.FromUUID(BaseFolder); | 149 | args["base_folder"] = OSD.FromUUID(BaseFolder); |
137 | args["caps_path"] = OSD.FromString(CapsPath); | 150 | args["caps_path"] = OSD.FromString(CapsPath); |
138 | 151 | ||
139 | OSDArray childrenSeeds = new OSDArray(ChildrenCapSeeds.Count); | 152 | if (ChildrenCapSeeds != null) |
140 | foreach (KeyValuePair<ulong, string> kvp in ChildrenCapSeeds) | ||
141 | { | 153 | { |
142 | OSDMap pair = new OSDMap(); | 154 | OSDArray childrenSeeds = new OSDArray(ChildrenCapSeeds.Count); |
143 | pair["handle"] = OSD.FromString(kvp.Key.ToString()); | 155 | foreach (KeyValuePair<ulong, string> kvp in ChildrenCapSeeds) |
144 | pair["seed"] = OSD.FromString(kvp.Value); | 156 | { |
145 | childrenSeeds.Add(pair); | 157 | OSDMap pair = new OSDMap(); |
158 | pair["handle"] = OSD.FromString(kvp.Key.ToString()); | ||
159 | pair["seed"] = OSD.FromString(kvp.Value); | ||
160 | childrenSeeds.Add(pair); | ||
161 | } | ||
162 | if (ChildrenCapSeeds.Count > 0) | ||
163 | args["children_seeds"] = childrenSeeds; | ||
146 | } | 164 | } |
147 | if (ChildrenCapSeeds.Count > 0) | ||
148 | args["children_seeds"] = childrenSeeds; | ||
149 | |||
150 | args["child"] = OSD.FromBoolean(child); | 165 | args["child"] = OSD.FromBoolean(child); |
151 | args["circuit_code"] = OSD.FromString(circuitcode.ToString()); | 166 | args["circuit_code"] = OSD.FromString(circuitcode.ToString()); |
152 | args["first_name"] = OSD.FromString(firstname); | 167 | args["first_name"] = OSD.FromString(firstname); |
@@ -154,7 +169,52 @@ namespace OpenSim.Framework | |||
154 | args["inventory_folder"] = OSD.FromUUID(InventoryFolder); | 169 | args["inventory_folder"] = OSD.FromUUID(InventoryFolder); |
155 | args["secure_session_id"] = OSD.FromUUID(SecureSessionID); | 170 | args["secure_session_id"] = OSD.FromUUID(SecureSessionID); |
156 | args["session_id"] = OSD.FromUUID(SessionID); | 171 | args["session_id"] = OSD.FromUUID(SessionID); |
172 | |||
173 | args["service_session_id"] = OSD.FromString(ServiceSessionID); | ||
157 | args["start_pos"] = OSD.FromString(startpos.ToString()); | 174 | args["start_pos"] = OSD.FromString(startpos.ToString()); |
175 | args["appearance_serial"] = OSD.FromInteger(Appearance.Serial); | ||
176 | |||
177 | if (Appearance != null) | ||
178 | { | ||
179 | //System.Console.WriteLine("XXX Before packing Wearables"); | ||
180 | if ((Appearance.Wearables != null) && (Appearance.Wearables.Length > 0)) | ||
181 | { | ||
182 | OSDArray wears = new OSDArray(Appearance.Wearables.Length * 2); | ||
183 | foreach (AvatarWearable awear in Appearance.Wearables) | ||
184 | { | ||
185 | wears.Add(OSD.FromUUID(awear.ItemID)); | ||
186 | wears.Add(OSD.FromUUID(awear.AssetID)); | ||
187 | //System.Console.WriteLine("XXX ItemID=" + awear.ItemID + " assetID=" + awear.AssetID); | ||
188 | } | ||
189 | args["wearables"] = wears; | ||
190 | } | ||
191 | |||
192 | //System.Console.WriteLine("XXX Before packing Attachments"); | ||
193 | Dictionary<int, UUID[]> attachments = Appearance.GetAttachmentDictionary(); | ||
194 | if ((attachments != null) && (attachments.Count > 0)) | ||
195 | { | ||
196 | OSDArray attachs = new OSDArray(attachments.Count); | ||
197 | foreach (KeyValuePair<int, UUID[]> kvp in attachments) | ||
198 | { | ||
199 | AttachmentData adata = new AttachmentData(kvp.Key, kvp.Value[0], kvp.Value[1]); | ||
200 | attachs.Add(adata.PackUpdateMessage()); | ||
201 | //System.Console.WriteLine("XXX att.pt=" + kvp.Key + "; itemID=" + kvp.Value[0] + "; assetID=" + kvp.Value[1]); | ||
202 | } | ||
203 | args["attachments"] = attachs; | ||
204 | } | ||
205 | } | ||
206 | |||
207 | if (ServiceURLs != null && ServiceURLs.Count > 0) | ||
208 | { | ||
209 | OSDArray urls = new OSDArray(ServiceURLs.Count * 2); | ||
210 | foreach (KeyValuePair<string, object> kvp in ServiceURLs) | ||
211 | { | ||
212 | //System.Console.WriteLine("XXX " + kvp.Key + "=" + kvp.Value); | ||
213 | urls.Add(OSD.FromString(kvp.Key)); | ||
214 | urls.Add(OSD.FromString((kvp.Value == null) ? string.Empty : kvp.Value.ToString())); | ||
215 | } | ||
216 | args["service_urls"] = urls; | ||
217 | } | ||
158 | 218 | ||
159 | return args; | 219 | return args; |
160 | } | 220 | } |
@@ -193,6 +253,8 @@ namespace OpenSim.Framework | |||
193 | } | 253 | } |
194 | } | 254 | } |
195 | } | 255 | } |
256 | else | ||
257 | ChildrenCapSeeds = new Dictionary<ulong, string>(); | ||
196 | 258 | ||
197 | if (args["child"] != null) | 259 | if (args["child"] != null) |
198 | child = args["child"].AsBoolean(); | 260 | child = args["child"].AsBoolean(); |
@@ -208,10 +270,51 @@ namespace OpenSim.Framework | |||
208 | SecureSessionID = args["secure_session_id"].AsUUID(); | 270 | SecureSessionID = args["secure_session_id"].AsUUID(); |
209 | if (args["session_id"] != null) | 271 | if (args["session_id"] != null) |
210 | SessionID = args["session_id"].AsUUID(); | 272 | SessionID = args["session_id"].AsUUID(); |
273 | if (args["service_session_id"] != null) | ||
274 | ServiceSessionID = args["service_session_id"].AsString(); | ||
275 | |||
211 | if (args["start_pos"] != null) | 276 | if (args["start_pos"] != null) |
212 | Vector3.TryParse(args["start_pos"].AsString(), out startpos); | 277 | Vector3.TryParse(args["start_pos"].AsString(), out startpos); |
278 | |||
279 | Appearance = new AvatarAppearance(AgentID); | ||
280 | if (args["appearance_serial"] != null) | ||
281 | Appearance.Serial = args["appearance_serial"].AsInteger(); | ||
282 | if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array) | ||
283 | { | ||
284 | OSDArray wears = (OSDArray)(args["wearables"]); | ||
285 | for (int i = 0; i < wears.Count / 2; i++) | ||
286 | { | ||
287 | Appearance.Wearables[i].ItemID = wears[i*2].AsUUID(); | ||
288 | Appearance.Wearables[i].AssetID = wears[(i*2)+1].AsUUID(); | ||
289 | } | ||
290 | } | ||
291 | |||
292 | if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array) | ||
293 | { | ||
294 | OSDArray attachs = (OSDArray)(args["attachments"]); | ||
295 | AttachmentData[] attachments = new AttachmentData[attachs.Count]; | ||
296 | int i = 0; | ||
297 | foreach (OSD o in attachs) | ||
298 | { | ||
299 | if (o.Type == OSDType.Map) | ||
300 | { | ||
301 | attachments[i++] = new AttachmentData((OSDMap)o); | ||
302 | } | ||
303 | } | ||
304 | Appearance.SetAttachments(attachments); | ||
305 | } | ||
213 | 306 | ||
307 | ServiceURLs = new Dictionary<string, object>(); | ||
308 | if (args.ContainsKey("service_urls") && args["service_urls"] != null && (args["service_urls"]).Type == OSDType.Array) | ||
309 | { | ||
310 | OSDArray urls = (OSDArray)(args["service_urls"]); | ||
311 | for (int i = 0; i < urls.Count / 2; i++) | ||
312 | { | ||
313 | ServiceURLs[urls[i * 2].AsString()] = urls[(i * 2) + 1].AsString(); | ||
314 | //System.Console.WriteLine("XXX " + urls[i * 2].AsString() + "=" + urls[(i * 2) + 1].AsString()); | ||
214 | 315 | ||
316 | } | ||
317 | } | ||
215 | } | 318 | } |
216 | } | 319 | } |
217 | 320 | ||
diff --git a/OpenSim/Framework/AssetBase.cs b/OpenSim/Framework/AssetBase.cs index 212f41d..19ca232 100644 --- a/OpenSim/Framework/AssetBase.cs +++ b/OpenSim/Framework/AssetBase.cs | |||
@@ -59,9 +59,10 @@ namespace OpenSim.Framework | |||
59 | m_metadata.FullID = UUID.Zero; | 59 | m_metadata.FullID = UUID.Zero; |
60 | m_metadata.ID = UUID.Zero.ToString(); | 60 | m_metadata.ID = UUID.Zero.ToString(); |
61 | m_metadata.Type = (sbyte)AssetType.Unknown; | 61 | m_metadata.Type = (sbyte)AssetType.Unknown; |
62 | m_metadata.CreatorID = String.Empty; | ||
62 | } | 63 | } |
63 | 64 | ||
64 | public AssetBase(UUID assetID, string name, sbyte assetType) | 65 | public AssetBase(UUID assetID, string name, sbyte assetType, string creatorID) |
65 | { | 66 | { |
66 | if (assetType == (sbyte)AssetType.Unknown) | 67 | if (assetType == (sbyte)AssetType.Unknown) |
67 | { | 68 | { |
@@ -74,9 +75,10 @@ namespace OpenSim.Framework | |||
74 | m_metadata.FullID = assetID; | 75 | m_metadata.FullID = assetID; |
75 | m_metadata.Name = name; | 76 | m_metadata.Name = name; |
76 | m_metadata.Type = assetType; | 77 | m_metadata.Type = assetType; |
78 | m_metadata.CreatorID = creatorID; | ||
77 | } | 79 | } |
78 | 80 | ||
79 | public AssetBase(string assetID, string name, sbyte assetType) | 81 | public AssetBase(string assetID, string name, sbyte assetType, string creatorID) |
80 | { | 82 | { |
81 | if (assetType == (sbyte)AssetType.Unknown) | 83 | if (assetType == (sbyte)AssetType.Unknown) |
82 | { | 84 | { |
@@ -89,6 +91,7 @@ namespace OpenSim.Framework | |||
89 | m_metadata.ID = assetID; | 91 | m_metadata.ID = assetID; |
90 | m_metadata.Name = name; | 92 | m_metadata.Name = name; |
91 | m_metadata.Type = assetType; | 93 | m_metadata.Type = assetType; |
94 | m_metadata.CreatorID = creatorID; | ||
92 | } | 95 | } |
93 | 96 | ||
94 | public bool ContainsReferences | 97 | public bool ContainsReferences |
@@ -220,7 +223,6 @@ namespace OpenSim.Framework | |||
220 | public class AssetMetadata | 223 | public class AssetMetadata |
221 | { | 224 | { |
222 | private UUID m_fullid; | 225 | private UUID m_fullid; |
223 | // m_id added as a dirty hack to transition from FullID to ID | ||
224 | private string m_id; | 226 | private string m_id; |
225 | private string m_name = String.Empty; | 227 | private string m_name = String.Empty; |
226 | private string m_description = String.Empty; | 228 | private string m_description = String.Empty; |
@@ -230,8 +232,7 @@ namespace OpenSim.Framework | |||
230 | private byte[] m_sha1; | 232 | private byte[] m_sha1; |
231 | private bool m_local; | 233 | private bool m_local; |
232 | private bool m_temporary; | 234 | private bool m_temporary; |
233 | //private Dictionary<string, Uri> m_methods = new Dictionary<string, Uri>(); | 235 | private string m_creatorid; |
234 | //private OSDMap m_extra_data; | ||
235 | 236 | ||
236 | public UUID FullID | 237 | public UUID FullID |
237 | { | 238 | { |
@@ -289,8 +290,21 @@ namespace OpenSim.Framework | |||
289 | 290 | ||
290 | public string ContentType | 291 | public string ContentType |
291 | { | 292 | { |
292 | get { return m_content_type; } | 293 | get |
293 | set { m_content_type = value; } | 294 | { |
295 | if (!String.IsNullOrEmpty(m_content_type)) | ||
296 | return m_content_type; | ||
297 | else | ||
298 | return SLUtil.SLAssetTypeToContentType(m_type); | ||
299 | } | ||
300 | set | ||
301 | { | ||
302 | m_content_type = value; | ||
303 | |||
304 | sbyte type = (sbyte)SLUtil.ContentTypeToSLAssetType(value); | ||
305 | if (type != -1) | ||
306 | m_type = type; | ||
307 | } | ||
294 | } | 308 | } |
295 | 309 | ||
296 | public byte[] SHA1 | 310 | public byte[] SHA1 |
@@ -311,16 +325,10 @@ namespace OpenSim.Framework | |||
311 | set { m_temporary = value; } | 325 | set { m_temporary = value; } |
312 | } | 326 | } |
313 | 327 | ||
314 | //public Dictionary<string, Uri> Methods | 328 | public string CreatorID |
315 | //{ | 329 | { |
316 | // get { return m_methods; } | 330 | get { return m_creatorid; } |
317 | // set { m_methods = value; } | 331 | set { m_creatorid = value; } |
318 | //} | 332 | } |
319 | |||
320 | //public OSDMap ExtraData | ||
321 | //{ | ||
322 | // get { return m_extra_data; } | ||
323 | // set { m_extra_data = value; } | ||
324 | //} | ||
325 | } | 333 | } |
326 | } | 334 | } |
diff --git a/OpenSim/Framework/AssetLandmark.cs b/OpenSim/Framework/AssetLandmark.cs index 058b442..7806c1f 100644 --- a/OpenSim/Framework/AssetLandmark.cs +++ b/OpenSim/Framework/AssetLandmark.cs | |||
@@ -38,7 +38,7 @@ namespace OpenSim.Framework | |||
38 | public int Version; | 38 | public int Version; |
39 | 39 | ||
40 | public AssetLandmark(AssetBase a) | 40 | public AssetLandmark(AssetBase a) |
41 | : base(a.FullID, a.Name, a.Type) | 41 | : base(a.FullID, a.Name, a.Type, a.Metadata.CreatorID) |
42 | { | 42 | { |
43 | Data = a.Data; | 43 | Data = a.Data; |
44 | Description = a.Description; | 44 | Description = a.Description; |
diff --git a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs index 6ab1b58..097ad7d 100644 --- a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs +++ b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs | |||
@@ -41,11 +41,12 @@ namespace OpenSim.Framework.AssetLoader.Filesystem | |||
41 | { | 41 | { |
42 | public class AssetLoaderFileSystem : IAssetLoader | 42 | public class AssetLoaderFileSystem : IAssetLoader |
43 | { | 43 | { |
44 | private static readonly UUID LIBRARY_OWNER_ID = new UUID("11111111-1111-0000-0000-000100bba000"); | ||
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 46 | ||
46 | protected static AssetBase CreateAsset(string assetIdStr, string name, string path, sbyte type) | 47 | protected static AssetBase CreateAsset(string assetIdStr, string name, string path, sbyte type) |
47 | { | 48 | { |
48 | AssetBase asset = new AssetBase(new UUID(assetIdStr), name, type); | 49 | AssetBase asset = new AssetBase(new UUID(assetIdStr), name, type, LIBRARY_OWNER_ID.ToString()); |
49 | 50 | ||
50 | if (!String.IsNullOrEmpty(path)) | 51 | if (!String.IsNullOrEmpty(path)) |
51 | { | 52 | { |
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index a3ea499..5da8ba1 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs | |||
@@ -69,7 +69,7 @@ namespace OpenSim.Framework | |||
69 | private static UUID HAIR_ASSET = new UUID("d342e6c0-b9d2-11dc-95ff-0800200c9a66"); | 69 | private static UUID HAIR_ASSET = new UUID("d342e6c0-b9d2-11dc-95ff-0800200c9a66"); |
70 | private static UUID HAIR_ITEM = new UUID("d342e6c1-b9d2-11dc-95ff-0800200c9a66"); | 70 | private static UUID HAIR_ITEM = new UUID("d342e6c1-b9d2-11dc-95ff-0800200c9a66"); |
71 | 71 | ||
72 | public readonly static int VISUALPARAM_COUNT = 218; | 72 | public readonly static int VISUALPARAM_COUNT = 218; |
73 | 73 | ||
74 | protected UUID m_owner; | 74 | protected UUID m_owner; |
75 | 75 | ||
@@ -361,7 +361,7 @@ namespace OpenSim.Framework | |||
361 | // This sets Visual Params with *less* weirder values then default. Instead of a ugly alien, it looks like a fat scientist | 361 | // This sets Visual Params with *less* weirder values then default. Instead of a ugly alien, it looks like a fat scientist |
362 | SetDefaultParams(m_visualparams); | 362 | SetDefaultParams(m_visualparams); |
363 | SetDefaultWearables(); | 363 | SetDefaultWearables(); |
364 | m_texture = GetDefaultTexture(); | 364 | m_texture = GetDefaultTexture(); |
365 | } | 365 | } |
366 | 366 | ||
367 | public AvatarAppearance(UUID avatarID, AvatarWearable[] wearables, byte[] visualParams) | 367 | public AvatarAppearance(UUID avatarID, AvatarWearable[] wearables, byte[] visualParams) |
@@ -390,11 +390,12 @@ namespace OpenSim.Framework | |||
390 | + 0.08f * (float)m_visualparams[(int)VPElement.SHOES_PLATFORM_HEIGHT] / 255.0f // Shoe platform height | 390 | + 0.08f * (float)m_visualparams[(int)VPElement.SHOES_PLATFORM_HEIGHT] / 255.0f // Shoe platform height |
391 | + 0.07f * (float)m_visualparams[(int)VPElement.SHOES_HEEL_HEIGHT] / 255.0f // Shoe heel height | 391 | + 0.07f * (float)m_visualparams[(int)VPElement.SHOES_HEEL_HEIGHT] / 255.0f // Shoe heel height |
392 | + 0.076f * (float)m_visualparams[(int)VPElement.SHAPE_NECK_LENGTH] / 255.0f; // Neck length | 392 | + 0.076f * (float)m_visualparams[(int)VPElement.SHAPE_NECK_LENGTH] / 255.0f; // Neck length |
393 | m_hipOffset = (0.615385f // Half of avatar | 393 | m_hipOffset = (((1.23077f // Half of avatar |
394 | + 0.516945f * (float)m_visualparams[(int)VPElement.SHAPE_HEIGHT] / 255.0f // Body height | ||
395 | + 0.3836f * (float)m_visualparams[(int)VPElement.SHAPE_LEG_LENGTH] / 255.0f // Leg length | ||
394 | + 0.08f * (float)m_visualparams[(int)VPElement.SHOES_PLATFORM_HEIGHT] / 255.0f // Shoe platform height | 396 | + 0.08f * (float)m_visualparams[(int)VPElement.SHOES_PLATFORM_HEIGHT] / 255.0f // Shoe platform height |
395 | + 0.07f * (float)m_visualparams[(int)VPElement.SHOES_HEEL_HEIGHT] / 255.0f // Shoe heel height | 397 | + 0.07f * (float)m_visualparams[(int)VPElement.SHOES_HEEL_HEIGHT] / 255.0f // Shoe heel height |
396 | + 0.3836f * (float)m_visualparams[(int)VPElement.SHAPE_LEG_LENGTH] / 255.0f // Leg length | 398 | ) / 2) - m_avatarHeight / 2) * 0.31f - 0.0425f; |
397 | - m_avatarHeight / 2) * 0.3f - 0.04f; | ||
398 | 399 | ||
399 | 400 | ||
400 | 401 | ||
@@ -558,6 +559,16 @@ namespace OpenSim.Framework | |||
558 | 559 | ||
559 | private Dictionary<int, UUID[]> m_attachments = new Dictionary<int, UUID[]>(); | 560 | private Dictionary<int, UUID[]> m_attachments = new Dictionary<int, UUID[]>(); |
560 | 561 | ||
562 | public void SetAttachments(AttachmentData[] data) | ||
563 | { | ||
564 | foreach (AttachmentData a in data) | ||
565 | { | ||
566 | m_attachments[a.AttachPoint] = new UUID[2]; | ||
567 | m_attachments[a.AttachPoint][0] = a.ItemID; | ||
568 | m_attachments[a.AttachPoint][1] = a.AssetID; | ||
569 | } | ||
570 | } | ||
571 | |||
561 | public void SetAttachments(Hashtable data) | 572 | public void SetAttachments(Hashtable data) |
562 | { | 573 | { |
563 | m_attachments.Clear(); | 574 | m_attachments.Clear(); |
@@ -587,6 +598,11 @@ namespace OpenSim.Framework | |||
587 | } | 598 | } |
588 | } | 599 | } |
589 | 600 | ||
601 | public Dictionary<int, UUID[]> GetAttachmentDictionary() | ||
602 | { | ||
603 | return m_attachments; | ||
604 | } | ||
605 | |||
590 | public Hashtable GetAttachments() | 606 | public Hashtable GetAttachments() |
591 | { | 607 | { |
592 | if (m_attachments.Count == 0) | 608 | if (m_attachments.Count == 0) |
diff --git a/OpenSim/Framework/Capabilities/Caps.cs b/OpenSim/Framework/Capabilities/Caps.cs index 74c6ab0..b27d011 100644 --- a/OpenSim/Framework/Capabilities/Caps.cs +++ b/OpenSim/Framework/Capabilities/Caps.cs | |||
@@ -888,7 +888,7 @@ namespace OpenSim.Framework.Capabilities | |||
888 | } | 888 | } |
889 | 889 | ||
890 | AssetBase asset; | 890 | AssetBase asset; |
891 | asset = new AssetBase(assetID, assetName, assType); | 891 | asset = new AssetBase(assetID, assetName, assType, m_agentID.ToString()); |
892 | asset.Data = data; | 892 | asset.Data = data; |
893 | if (AddNewAsset != null) | 893 | if (AddNewAsset != null) |
894 | AddNewAsset(asset); | 894 | AddNewAsset(asset); |
diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs index 825ab81..fee71f0 100644 --- a/OpenSim/Framework/ChildAgentDataUpdate.cs +++ b/OpenSim/Framework/ChildAgentDataUpdate.cs | |||
@@ -274,7 +274,7 @@ namespace OpenSim.Framework | |||
274 | get { return m_id; } | 274 | get { return m_id; } |
275 | set { m_id = value; } | 275 | set { m_id = value; } |
276 | } | 276 | } |
277 | public ulong RegionHandle; | 277 | public UUID RegionID; |
278 | public uint CircuitCode; | 278 | public uint CircuitCode; |
279 | public UUID SessionID; | 279 | public UUID SessionID; |
280 | 280 | ||
@@ -321,7 +321,7 @@ namespace OpenSim.Framework | |||
321 | OSDMap args = new OSDMap(); | 321 | OSDMap args = new OSDMap(); |
322 | args["message_type"] = OSD.FromString("AgentData"); | 322 | args["message_type"] = OSD.FromString("AgentData"); |
323 | 323 | ||
324 | args["region_handle"] = OSD.FromString(RegionHandle.ToString()); | 324 | args["region_id"] = OSD.FromString(RegionID.ToString()); |
325 | args["circuit_code"] = OSD.FromString(CircuitCode.ToString()); | 325 | args["circuit_code"] = OSD.FromString(CircuitCode.ToString()); |
326 | args["agent_uuid"] = OSD.FromUUID(AgentID); | 326 | args["agent_uuid"] = OSD.FromUUID(AgentID); |
327 | args["session_uuid"] = OSD.FromUUID(SessionID); | 327 | args["session_uuid"] = OSD.FromUUID(SessionID); |
@@ -334,6 +334,7 @@ namespace OpenSim.Framework | |||
334 | args["left_axis"] = OSD.FromString(LeftAxis.ToString()); | 334 | args["left_axis"] = OSD.FromString(LeftAxis.ToString()); |
335 | args["up_axis"] = OSD.FromString(UpAxis.ToString()); | 335 | args["up_axis"] = OSD.FromString(UpAxis.ToString()); |
336 | 336 | ||
337 | |||
337 | args["changed_grid"] = OSD.FromBoolean(ChangedGrid); | 338 | args["changed_grid"] = OSD.FromBoolean(ChangedGrid); |
338 | args["far"] = OSD.FromReal(Far); | 339 | args["far"] = OSD.FromReal(Far); |
339 | args["aspect"] = OSD.FromReal(Aspect); | 340 | args["aspect"] = OSD.FromReal(Aspect); |
@@ -353,7 +354,7 @@ namespace OpenSim.Framework | |||
353 | args["agent_access"] = OSD.FromString(AgentAccess.ToString()); | 354 | args["agent_access"] = OSD.FromString(AgentAccess.ToString()); |
354 | 355 | ||
355 | args["active_group_id"] = OSD.FromUUID(ActiveGroupID); | 356 | args["active_group_id"] = OSD.FromUUID(ActiveGroupID); |
356 | 357 | ||
357 | if ((Groups != null) && (Groups.Length > 0)) | 358 | if ((Groups != null) && (Groups.Length > 0)) |
358 | { | 359 | { |
359 | OSDArray groups = new OSDArray(Groups.Length); | 360 | OSDArray groups = new OSDArray(Groups.Length); |
@@ -378,6 +379,7 @@ namespace OpenSim.Framework | |||
378 | // args["agent_textures"] = textures; | 379 | // args["agent_textures"] = textures; |
379 | //} | 380 | //} |
380 | 381 | ||
382 | |||
381 | if ((AgentTextures != null) && (AgentTextures.Length > 0)) | 383 | if ((AgentTextures != null) && (AgentTextures.Length > 0)) |
382 | args["texture_entry"] = OSD.FromBinary(AgentTextures); | 384 | args["texture_entry"] = OSD.FromBinary(AgentTextures); |
383 | 385 | ||
@@ -393,6 +395,7 @@ namespace OpenSim.Framework | |||
393 | args["wearables"] = wears; | 395 | args["wearables"] = wears; |
394 | } | 396 | } |
395 | 397 | ||
398 | |||
396 | if ((Attachments != null) && (Attachments.Length > 0)) | 399 | if ((Attachments != null) && (Attachments.Length > 0)) |
397 | { | 400 | { |
398 | OSDArray attachs = new OSDArray(Attachments.Length); | 401 | OSDArray attachs = new OSDArray(Attachments.Length); |
@@ -401,9 +404,11 @@ namespace OpenSim.Framework | |||
401 | args["attachments"] = attachs; | 404 | args["attachments"] = attachs; |
402 | } | 405 | } |
403 | 406 | ||
407 | |||
404 | if ((CallbackURI != null) && (!CallbackURI.Equals(""))) | 408 | if ((CallbackURI != null) && (!CallbackURI.Equals(""))) |
405 | args["callback_uri"] = OSD.FromString(CallbackURI); | 409 | args["callback_uri"] = OSD.FromString(CallbackURI); |
406 | 410 | ||
411 | |||
407 | return args; | 412 | return args; |
408 | } | 413 | } |
409 | 414 | ||
@@ -414,8 +419,8 @@ namespace OpenSim.Framework | |||
414 | /// <param name="hash"></param> | 419 | /// <param name="hash"></param> |
415 | public virtual void Unpack(OSDMap args) | 420 | public virtual void Unpack(OSDMap args) |
416 | { | 421 | { |
417 | if (args.ContainsKey("region_handle")) | 422 | if (args.ContainsKey("region_id")) |
418 | UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle); | 423 | UUID.TryParse(args["region_id"].AsString(), out RegionID); |
419 | 424 | ||
420 | if (args["circuit_code"] != null) | 425 | if (args["circuit_code"] != null) |
421 | UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode); | 426 | UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode); |
@@ -572,7 +577,7 @@ namespace OpenSim.Framework | |||
572 | { | 577 | { |
573 | System.Console.WriteLine("------------ AgentData ------------"); | 578 | System.Console.WriteLine("------------ AgentData ------------"); |
574 | System.Console.WriteLine("UUID: " + AgentID); | 579 | System.Console.WriteLine("UUID: " + AgentID); |
575 | System.Console.WriteLine("Region: " + RegionHandle); | 580 | System.Console.WriteLine("Region: " + RegionID); |
576 | System.Console.WriteLine("Position: " + Position); | 581 | System.Console.WriteLine("Position: " + Position); |
577 | } | 582 | } |
578 | } | 583 | } |
diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs deleted file mode 100644 index 6648c36..0000000 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ /dev/null | |||
@@ -1,847 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Services.Interfaces; | ||
34 | |||
35 | namespace OpenSim.Framework.Communications.Cache | ||
36 | { | ||
37 | internal delegate void AddItemDelegate(InventoryItemBase itemInfo); | ||
38 | internal delegate void UpdateItemDelegate(InventoryItemBase itemInfo); | ||
39 | internal delegate void DeleteItemDelegate(UUID itemID); | ||
40 | internal delegate void QueryItemDelegate(UUID itemID); | ||
41 | internal delegate void QueryFolderDelegate(UUID folderID); | ||
42 | |||
43 | internal delegate void CreateFolderDelegate(string folderName, UUID folderID, ushort folderType, UUID parentID); | ||
44 | internal delegate void MoveFolderDelegate(UUID folderID, UUID parentID); | ||
45 | internal delegate void PurgeFolderDelegate(UUID folderID); | ||
46 | internal delegate void UpdateFolderDelegate(string name, UUID folderID, ushort type, UUID parentID); | ||
47 | |||
48 | internal delegate void SendInventoryDescendentsDelegate( | ||
49 | IClientAPI client, UUID folderID, bool fetchFolders, bool fetchItems); | ||
50 | |||
51 | public delegate void OnItemReceivedDelegate(UUID itemID); | ||
52 | public delegate void OnInventoryReceivedDelegate(UUID userID); | ||
53 | |||
54 | /// <summary> | ||
55 | /// Stores user profile and inventory data received from backend services for a particular user. | ||
56 | /// </summary> | ||
57 | public class CachedUserInfo | ||
58 | { | ||
59 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
60 | |||
61 | //// <value> | ||
62 | /// Fired when a particular item has been received from the inventory service | ||
63 | /// </value> | ||
64 | public event OnItemReceivedDelegate OnItemReceived; | ||
65 | |||
66 | /// <value> | ||
67 | /// Fired once the entire inventory has been received for the user | ||
68 | /// </value> | ||
69 | public event OnInventoryReceivedDelegate OnInventoryReceived; | ||
70 | |||
71 | /// <summary> | ||
72 | /// The comms manager holds references to services (user, grid, inventory, etc.) | ||
73 | /// </summary> | ||
74 | private readonly IInventoryService m_InventoryService; | ||
75 | |||
76 | public UserProfileData UserProfile { get { return m_userProfile; } } | ||
77 | private UserProfileData m_userProfile; | ||
78 | |||
79 | /// <summary> | ||
80 | /// Have we received the user's inventory from the inventory service? | ||
81 | /// </summary> | ||
82 | public bool HasReceivedInventory { get { return m_hasReceivedInventory; } } | ||
83 | private bool m_hasReceivedInventory; | ||
84 | |||
85 | /// <summary> | ||
86 | /// Inventory requests waiting for receipt of this user's inventory from the inventory service. | ||
87 | /// </summary> | ||
88 | private readonly IList<IInventoryRequest> m_pendingRequests = new List<IInventoryRequest>(); | ||
89 | |||
90 | /// <summary> | ||
91 | /// The root folder of this user's inventory. Returns null if the root folder has not yet been received. | ||
92 | /// </summary> | ||
93 | public InventoryFolderImpl RootFolder { get { return m_rootFolder; } } | ||
94 | private InventoryFolderImpl m_rootFolder; | ||
95 | |||
96 | public UUID SessionID | ||
97 | { | ||
98 | get { return m_session_id; } | ||
99 | set { m_session_id = value; } | ||
100 | } | ||
101 | private UUID m_session_id = UUID.Zero; | ||
102 | |||
103 | /// <summary> | ||
104 | /// Constructor | ||
105 | /// </summary> | ||
106 | /// <param name="commsManager"></param> | ||
107 | /// <param name="userProfile"></param> | ||
108 | public CachedUserInfo(IInventoryService invService, UserProfileData userProfile) | ||
109 | { | ||
110 | m_userProfile = userProfile; | ||
111 | m_InventoryService = invService; | ||
112 | } | ||
113 | |||
114 | /// <summary> | ||
115 | /// This allows a request to be added to be processed once we receive a user's inventory | ||
116 | /// from the inventory service. If we already have the inventory, the request | ||
117 | /// is executed immediately instead. | ||
118 | /// </summary> | ||
119 | /// <param name="parent"></param> | ||
120 | protected void AddRequest(IInventoryRequest request) | ||
121 | { | ||
122 | lock (m_pendingRequests) | ||
123 | { | ||
124 | if (HasReceivedInventory) | ||
125 | { | ||
126 | request.Execute(); | ||
127 | } | ||
128 | else | ||
129 | { | ||
130 | m_pendingRequests.Add(request); | ||
131 | } | ||
132 | } | ||
133 | } | ||
134 | |||
135 | /// <summary> | ||
136 | /// Helper function for InventoryReceive() - Store a folder temporarily until we've received entire folder list | ||
137 | /// </summary> | ||
138 | /// <param name="folder"></param> | ||
139 | private void AddFolderToDictionary(InventoryFolderImpl folder, IDictionary<UUID, IList<InventoryFolderImpl>> dictionary) | ||
140 | { | ||
141 | UUID parentFolderId = folder.ParentID; | ||
142 | |||
143 | if (dictionary.ContainsKey(parentFolderId)) | ||
144 | { | ||
145 | dictionary[parentFolderId].Add(folder); | ||
146 | } | ||
147 | else | ||
148 | { | ||
149 | IList<InventoryFolderImpl> folders = new List<InventoryFolderImpl>(); | ||
150 | folders.Add(folder); | ||
151 | dictionary[parentFolderId] = folders; | ||
152 | } | ||
153 | } | ||
154 | |||
155 | /// <summary> | ||
156 | /// Recursively, in depth-first order, add all the folders we've received (stored | ||
157 | /// in a dictionary indexed by parent ID) into the tree that describes user folder | ||
158 | /// heirarchy | ||
159 | /// Any folder that is resolved into the tree is also added to resolvedFolderDictionary, | ||
160 | /// indexed by folder ID. | ||
161 | /// </summary> | ||
162 | /// <param name="parentId"> | ||
163 | /// A <see cref="UUID"/> | ||
164 | /// </param> | ||
165 | private void ResolveReceivedFolders(InventoryFolderImpl parentFolder, | ||
166 | IDictionary<UUID, IList<InventoryFolderImpl>> receivedFolderDictionary, | ||
167 | IDictionary<UUID, InventoryFolderImpl> resolvedFolderDictionary) | ||
168 | { | ||
169 | if (receivedFolderDictionary.ContainsKey(parentFolder.ID)) | ||
170 | { | ||
171 | List<InventoryFolderImpl> resolvedFolders = new List<InventoryFolderImpl>(); // Folders we've resolved with this invocation | ||
172 | foreach (InventoryFolderImpl folder in receivedFolderDictionary[parentFolder.ID]) | ||
173 | { | ||
174 | if (parentFolder.ContainsChildFolder(folder.ID)) | ||
175 | { | ||
176 | m_log.WarnFormat( | ||
177 | "[INVENTORY CACHE]: Received folder {0} {1} from inventory service which has already been received", | ||
178 | folder.Name, folder.ID); | ||
179 | } | ||
180 | else | ||
181 | { | ||
182 | if (resolvedFolderDictionary.ContainsKey(folder.ID)) | ||
183 | { | ||
184 | m_log.WarnFormat( | ||
185 | "[INVENTORY CACHE]: Received folder {0} {1} from inventory service has already been received but with different parent", | ||
186 | folder.Name, folder.ID); | ||
187 | } | ||
188 | else | ||
189 | { | ||
190 | resolvedFolders.Add(folder); | ||
191 | resolvedFolderDictionary[folder.ID] = folder; | ||
192 | parentFolder.AddChildFolder(folder); | ||
193 | } | ||
194 | } | ||
195 | } // foreach (folder in pendingCategorizationFolders[parentFolder.ID]) | ||
196 | |||
197 | receivedFolderDictionary.Remove(parentFolder.ID); | ||
198 | foreach (InventoryFolderImpl folder in resolvedFolders) | ||
199 | ResolveReceivedFolders(folder, receivedFolderDictionary, resolvedFolderDictionary); | ||
200 | } // if (receivedFolderDictionary.ContainsKey(parentFolder.ID)) | ||
201 | } | ||
202 | |||
203 | /// <summary> | ||
204 | /// Drop all cached inventory. | ||
205 | /// </summary> | ||
206 | public void DropInventory() | ||
207 | { | ||
208 | m_log.Debug("[INVENTORY CACHE]: DropInventory called"); | ||
209 | // Make sure there aren't pending requests around when we do this | ||
210 | // FIXME: There is still a race condition where an inventory operation can be requested (since these aren't being locked). | ||
211 | // Will have to extend locking to exclude this very soon. | ||
212 | lock (m_pendingRequests) | ||
213 | { | ||
214 | m_hasReceivedInventory = false; | ||
215 | m_rootFolder = null; | ||
216 | } | ||
217 | } | ||
218 | |||
219 | /// <summary> | ||
220 | /// Fetch inventory for this user. | ||
221 | /// </summary> | ||
222 | /// This has to be executed as a separate step once user information is retreived. | ||
223 | /// This will occur synchronously if the inventory service is in the same process as this class, and | ||
224 | /// asynchronously otherwise. | ||
225 | public void FetchInventory() | ||
226 | { | ||
227 | m_InventoryService.GetUserInventory(UserProfile.ID, InventoryReceive); | ||
228 | } | ||
229 | |||
230 | /// <summary> | ||
231 | /// Callback invoked when the inventory is received from an async request to the inventory service | ||
232 | /// </summary> | ||
233 | /// <param name="userID"></param> | ||
234 | /// <param name="inventoryCollection"></param> | ||
235 | public void InventoryReceive(ICollection<InventoryFolderImpl> folders, ICollection<InventoryItemBase> items) | ||
236 | { | ||
237 | // FIXME: Exceptions thrown upwards never appear on the console. Could fix further up if these | ||
238 | // are simply being swallowed | ||
239 | |||
240 | try | ||
241 | { | ||
242 | // collection of all received folders, indexed by their parent ID | ||
243 | IDictionary<UUID, IList<InventoryFolderImpl>> receivedFolders = | ||
244 | new Dictionary<UUID, IList<InventoryFolderImpl>>(); | ||
245 | |||
246 | // collection of all folders that have been placed into the folder heirarchy starting at m_rootFolder | ||
247 | // This dictonary exists so we don't have to do an InventoryFolderImpl.FindFolder(), which is O(n) on the | ||
248 | // number of folders in our inventory. | ||
249 | // Maybe we should make this structure a member so we can skip InventoryFolderImpl.FindFolder() calls later too? | ||
250 | IDictionary<UUID, InventoryFolderImpl> resolvedFolders = | ||
251 | new Dictionary<UUID, InventoryFolderImpl>(); | ||
252 | |||
253 | // Take all received folders, find the root folder, and put ther rest into | ||
254 | // the pendingCategorizationFolders collection | ||
255 | foreach (InventoryFolderImpl folder in folders) | ||
256 | AddFolderToDictionary(folder, receivedFolders); | ||
257 | |||
258 | if (!receivedFolders.ContainsKey(UUID.Zero)) | ||
259 | throw new Exception("Database did not return a root inventory folder"); | ||
260 | else | ||
261 | { | ||
262 | IList<InventoryFolderImpl> rootFolderList = receivedFolders[UUID.Zero]; | ||
263 | m_rootFolder = rootFolderList[0]; | ||
264 | resolvedFolders[m_rootFolder.ID] = m_rootFolder; | ||
265 | if (rootFolderList.Count > 1) | ||
266 | { | ||
267 | for (int i = 1; i < rootFolderList.Count; i++) | ||
268 | { | ||
269 | m_log.WarnFormat( | ||
270 | "[INVENTORY CACHE]: Discarding extra root folder {0}. Using previously received root folder {1}", | ||
271 | rootFolderList[i].ID, RootFolder.ID); | ||
272 | } | ||
273 | } | ||
274 | receivedFolders.Remove(UUID.Zero); | ||
275 | } | ||
276 | |||
277 | // Now take the pendingCategorizationFolders collection, and turn that into a tree, | ||
278 | // with the root being RootFolder | ||
279 | if (RootFolder != null) | ||
280 | ResolveReceivedFolders(RootFolder, receivedFolders, resolvedFolders); | ||
281 | |||
282 | // Generate a warning for folders that are not part of the heirarchy | ||
283 | foreach (KeyValuePair<UUID, IList<InventoryFolderImpl>> folderList in receivedFolders) | ||
284 | { | ||
285 | foreach (InventoryFolderImpl folder in folderList.Value) | ||
286 | m_log.WarnFormat("[INVENTORY CACHE]: Malformed Database: Unresolved Pending Folder {0}", folder.Name); | ||
287 | } | ||
288 | |||
289 | // Take all ther received items and put them into the folder tree heirarchy | ||
290 | foreach (InventoryItemBase item in items) { | ||
291 | InventoryFolderImpl folder = resolvedFolders.ContainsKey(item.Folder) ? resolvedFolders[item.Folder] : null; | ||
292 | ItemReceive(item, folder); | ||
293 | } | ||
294 | } | ||
295 | catch (Exception e) | ||
296 | { | ||
297 | m_log.ErrorFormat("[INVENTORY CACHE]: Error processing inventory received from inventory service, {0}", e); | ||
298 | } | ||
299 | |||
300 | // Deal with pending requests | ||
301 | lock (m_pendingRequests) | ||
302 | { | ||
303 | // We're going to change inventory status within the lock to avoid a race condition | ||
304 | // where requests are processed after the AddRequest() method has been called. | ||
305 | m_hasReceivedInventory = true; | ||
306 | |||
307 | foreach (IInventoryRequest request in m_pendingRequests) | ||
308 | { | ||
309 | request.Execute(); | ||
310 | } | ||
311 | } | ||
312 | |||
313 | if (OnInventoryReceived != null) | ||
314 | OnInventoryReceived(UserProfile.ID); | ||
315 | } | ||
316 | |||
317 | /// <summary> | ||
318 | /// Callback invoked when an item is received from an async request to the inventory service. | ||
319 | /// | ||
320 | /// We're assuming here that items are always received after all the folders | ||
321 | /// received. | ||
322 | /// If folder is null, we will search for it starting from RootFolder (an O(n) operation), | ||
323 | /// otherwise we'll just put it into folder | ||
324 | /// </summary> | ||
325 | /// <param name="folderInfo"></param> | ||
326 | private void ItemReceive(InventoryItemBase itemInfo, InventoryFolderImpl folder) | ||
327 | { | ||
328 | // m_log.DebugFormat( | ||
329 | // "[INVENTORY CACHE]: Received item {0} {1} for user {2}", | ||
330 | // itemInfo.Name, itemInfo.ID, userID); | ||
331 | |||
332 | if (folder == null && RootFolder != null) | ||
333 | folder = RootFolder.FindFolder(itemInfo.Folder); | ||
334 | |||
335 | if (null == folder) | ||
336 | { | ||
337 | m_log.WarnFormat( | ||
338 | "Received item {0} {1} but its folder {2} does not exist", | ||
339 | itemInfo.Name, itemInfo.ID, itemInfo.Folder); | ||
340 | |||
341 | return; | ||
342 | } | ||
343 | |||
344 | lock (folder.Items) | ||
345 | { | ||
346 | folder.Items[itemInfo.ID] = itemInfo; | ||
347 | } | ||
348 | |||
349 | if (OnItemReceived != null) | ||
350 | OnItemReceived(itemInfo.ID); | ||
351 | } | ||
352 | |||
353 | /// <summary> | ||
354 | /// Create a folder in this agent's inventory. | ||
355 | /// </summary> | ||
356 | /// | ||
357 | /// If the inventory service has not yet delievered the inventory | ||
358 | /// for this user then the request will be queued. | ||
359 | /// | ||
360 | /// <param name="parentID"></param> | ||
361 | /// <returns></returns> | ||
362 | public bool CreateFolder(string folderName, UUID folderID, ushort folderType, UUID parentID) | ||
363 | { | ||
364 | // m_log.DebugFormat( | ||
365 | // "[AGENT INVENTORY]: Creating inventory folder {0} {1} for {2} {3}", folderID, folderName, remoteClient.Name, remoteClient.AgentId); | ||
366 | |||
367 | if (m_hasReceivedInventory) | ||
368 | { | ||
369 | InventoryFolderImpl parentFolder = RootFolder.FindFolder(parentID); | ||
370 | |||
371 | if (null == parentFolder) | ||
372 | { | ||
373 | m_log.WarnFormat( | ||
374 | "[AGENT INVENTORY]: Tried to create folder {0} {1} but the parent {2} does not exist", | ||
375 | folderName, folderID, parentID); | ||
376 | |||
377 | return false; | ||
378 | } | ||
379 | |||
380 | InventoryFolderImpl createdFolder = parentFolder.CreateChildFolder(folderID, folderName, folderType); | ||
381 | |||
382 | if (createdFolder != null) | ||
383 | { | ||
384 | InventoryFolderBase createdBaseFolder = new InventoryFolderBase(); | ||
385 | createdBaseFolder.Owner = createdFolder.Owner; | ||
386 | createdBaseFolder.ID = createdFolder.ID; | ||
387 | createdBaseFolder.Name = createdFolder.Name; | ||
388 | createdBaseFolder.ParentID = createdFolder.ParentID; | ||
389 | createdBaseFolder.Type = createdFolder.Type; | ||
390 | createdBaseFolder.Version = createdFolder.Version; | ||
391 | |||
392 | m_InventoryService.AddFolder(createdBaseFolder); | ||
393 | |||
394 | return true; | ||
395 | } | ||
396 | else | ||
397 | { | ||
398 | m_log.WarnFormat( | ||
399 | "[AGENT INVENTORY]: Tried to create folder {0} {1} but the folder already exists", | ||
400 | folderName, folderID); | ||
401 | |||
402 | return false; | ||
403 | } | ||
404 | } | ||
405 | else | ||
406 | { | ||
407 | AddRequest( | ||
408 | new InventoryRequest( | ||
409 | Delegate.CreateDelegate(typeof(CreateFolderDelegate), this, "CreateFolder"), | ||
410 | new object[] { folderName, folderID, folderType, parentID })); | ||
411 | |||
412 | return true; | ||
413 | } | ||
414 | } | ||
415 | |||
416 | /// <summary> | ||
417 | /// Handle a client request to update the inventory folder | ||
418 | /// </summary> | ||
419 | /// | ||
420 | /// If the inventory service has not yet delievered the inventory | ||
421 | /// for this user then the request will be queued. | ||
422 | /// | ||
423 | /// FIXME: We call add new inventory folder because in the data layer, we happen to use an SQL REPLACE | ||
424 | /// so this will work to rename an existing folder. Needless to say, to rely on this is very confusing, | ||
425 | /// and needs to be changed. | ||
426 | /// | ||
427 | /// <param name="folderID"></param> | ||
428 | /// <param name="type"></param> | ||
429 | /// <param name="name"></param> | ||
430 | /// <param name="parentID"></param> | ||
431 | public bool UpdateFolder(string name, UUID folderID, ushort type, UUID parentID) | ||
432 | { | ||
433 | // m_log.DebugFormat( | ||
434 | // "[AGENT INVENTORY]: Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId); | ||
435 | |||
436 | if (m_hasReceivedInventory) | ||
437 | { | ||
438 | InventoryFolderImpl folder = RootFolder.FindFolder(folderID); | ||
439 | |||
440 | // Delegate movement if updated parent id isn't the same as the existing parentId | ||
441 | if (folder.ParentID != parentID) | ||
442 | MoveFolder(folderID, parentID); | ||
443 | |||
444 | InventoryFolderBase baseFolder = new InventoryFolderBase(); | ||
445 | baseFolder.Owner = m_userProfile.ID; | ||
446 | baseFolder.ID = folderID; | ||
447 | baseFolder.Name = name; | ||
448 | baseFolder.ParentID = parentID; | ||
449 | baseFolder.Type = (short)type; | ||
450 | baseFolder.Version = RootFolder.Version; | ||
451 | |||
452 | m_InventoryService.UpdateFolder(baseFolder); | ||
453 | |||
454 | folder.Name = name; | ||
455 | folder.Type = (short)type; | ||
456 | } | ||
457 | else | ||
458 | { | ||
459 | AddRequest( | ||
460 | new InventoryRequest( | ||
461 | Delegate.CreateDelegate(typeof(UpdateFolderDelegate), this, "UpdateFolder"), | ||
462 | new object[] { name, folderID, type, parentID })); | ||
463 | } | ||
464 | |||
465 | return true; | ||
466 | } | ||
467 | |||
468 | /// <summary> | ||
469 | /// Handle an inventory folder move request from the client. | ||
470 | /// | ||
471 | /// If the inventory service has not yet delievered the inventory | ||
472 | /// for this user then the request will be queued. | ||
473 | /// </summary> | ||
474 | /// | ||
475 | /// <param name="folderID"></param> | ||
476 | /// <param name="parentID"></param> | ||
477 | /// <returns> | ||
478 | /// true if the delete was successful, or if it was queued pending folder receipt | ||
479 | /// false if the folder to be deleted did not exist. | ||
480 | /// </returns> | ||
481 | public bool MoveFolder(UUID folderID, UUID parentID) | ||
482 | { | ||
483 | // m_log.DebugFormat( | ||
484 | // "[AGENT INVENTORY]: Moving inventory folder {0} into folder {1} for {2} {3}", | ||
485 | // parentID, remoteClient.Name, remoteClient.Name, remoteClient.AgentId); | ||
486 | |||
487 | if (m_hasReceivedInventory) | ||
488 | { | ||
489 | InventoryFolderBase baseFolder = new InventoryFolderBase(); | ||
490 | baseFolder.Owner = m_userProfile.ID; | ||
491 | baseFolder.ID = folderID; | ||
492 | baseFolder.ParentID = parentID; | ||
493 | |||
494 | m_InventoryService.MoveFolder(baseFolder); | ||
495 | |||
496 | InventoryFolderImpl folder = RootFolder.FindFolder(folderID); | ||
497 | InventoryFolderImpl parentFolder = RootFolder.FindFolder(parentID); | ||
498 | if (parentFolder != null && folder != null) | ||
499 | { | ||
500 | InventoryFolderImpl oldParentFolder = RootFolder.FindFolder(folder.ParentID); | ||
501 | |||
502 | if (oldParentFolder != null) | ||
503 | { | ||
504 | oldParentFolder.RemoveChildFolder(folderID); | ||
505 | parentFolder.AddChildFolder(folder); | ||
506 | } | ||
507 | else | ||
508 | { | ||
509 | return false; | ||
510 | } | ||
511 | } | ||
512 | else | ||
513 | { | ||
514 | return false; | ||
515 | } | ||
516 | |||
517 | return true; | ||
518 | } | ||
519 | else | ||
520 | { | ||
521 | AddRequest( | ||
522 | new InventoryRequest( | ||
523 | Delegate.CreateDelegate(typeof(MoveFolderDelegate), this, "MoveFolder"), | ||
524 | new object[] { folderID, parentID })); | ||
525 | |||
526 | return true; | ||
527 | } | ||
528 | } | ||
529 | |||
530 | /// <summary> | ||
531 | /// This method will delete all the items and folders in the given folder. | ||
532 | /// </summary> | ||
533 | /// If the inventory service has not yet delievered the inventory | ||
534 | /// for this user then the request will be queued. | ||
535 | /// | ||
536 | /// <param name="folderID"></param> | ||
537 | public bool PurgeFolder(UUID folderID) | ||
538 | { | ||
539 | // m_log.InfoFormat("[AGENT INVENTORY]: Purging folder {0} for {1} uuid {2}", | ||
540 | // folderID, remoteClient.Name, remoteClient.AgentId); | ||
541 | |||
542 | if (m_hasReceivedInventory) | ||
543 | { | ||
544 | InventoryFolderImpl purgedFolder = RootFolder.FindFolder(folderID); | ||
545 | |||
546 | if (purgedFolder != null) | ||
547 | { | ||
548 | // XXX Nasty - have to create a new object to hold details we already have | ||
549 | InventoryFolderBase purgedBaseFolder = new InventoryFolderBase(); | ||
550 | purgedBaseFolder.Owner = purgedFolder.Owner; | ||
551 | purgedBaseFolder.ID = purgedFolder.ID; | ||
552 | purgedBaseFolder.Name = purgedFolder.Name; | ||
553 | purgedBaseFolder.ParentID = purgedFolder.ParentID; | ||
554 | purgedBaseFolder.Type = purgedFolder.Type; | ||
555 | purgedBaseFolder.Version = purgedFolder.Version; | ||
556 | |||
557 | m_InventoryService.PurgeFolder(purgedBaseFolder); | ||
558 | |||
559 | purgedFolder.Purge(); | ||
560 | |||
561 | return true; | ||
562 | } | ||
563 | } | ||
564 | else | ||
565 | { | ||
566 | AddRequest( | ||
567 | new InventoryRequest( | ||
568 | Delegate.CreateDelegate(typeof(PurgeFolderDelegate), this, "PurgeFolder"), | ||
569 | new object[] { folderID })); | ||
570 | |||
571 | return true; | ||
572 | } | ||
573 | |||
574 | return false; | ||
575 | } | ||
576 | |||
577 | /// <summary> | ||
578 | /// Add an item to the user's inventory. | ||
579 | /// </summary> | ||
580 | /// If the item has no folder set (i.e. it is UUID.Zero), then it is placed in the most appropriate folder | ||
581 | /// for that type. | ||
582 | /// <param name="itemInfo"></param> | ||
583 | public void AddItem(InventoryItemBase item) | ||
584 | { | ||
585 | if (m_hasReceivedInventory) | ||
586 | { | ||
587 | if (item.Folder == UUID.Zero) | ||
588 | { | ||
589 | InventoryFolderImpl f = FindFolderForType(item.AssetType); | ||
590 | if (f != null) | ||
591 | item.Folder = f.ID; | ||
592 | else | ||
593 | item.Folder = RootFolder.ID; | ||
594 | } | ||
595 | ItemReceive(item, null); | ||
596 | |||
597 | m_InventoryService.AddItem(item); | ||
598 | } | ||
599 | else | ||
600 | { | ||
601 | AddRequest( | ||
602 | new InventoryRequest( | ||
603 | Delegate.CreateDelegate(typeof(AddItemDelegate), this, "AddItem"), | ||
604 | new object[] { item })); | ||
605 | } | ||
606 | } | ||
607 | |||
608 | /// <summary> | ||
609 | /// Update an item in the user's inventory | ||
610 | /// </summary> | ||
611 | /// <param name="userID"></param> | ||
612 | /// <param name="itemInfo"></param> | ||
613 | public void UpdateItem(InventoryItemBase item) | ||
614 | { | ||
615 | if (m_hasReceivedInventory) | ||
616 | { | ||
617 | m_InventoryService.UpdateItem(item); | ||
618 | } | ||
619 | else | ||
620 | { | ||
621 | AddRequest( | ||
622 | new InventoryRequest( | ||
623 | Delegate.CreateDelegate(typeof(UpdateItemDelegate), this, "UpdateItem"), | ||
624 | new object[] { item })); | ||
625 | } | ||
626 | } | ||
627 | |||
628 | /// <summary> | ||
629 | /// Delete an item from the user's inventory | ||
630 | /// | ||
631 | /// If the inventory service has not yet delievered the inventory | ||
632 | /// for this user then the request will be queued. | ||
633 | /// </summary> | ||
634 | /// <param name="itemID"></param> | ||
635 | /// <returns> | ||
636 | /// true on a successful delete or a if the request is queued. | ||
637 | /// Returns false on an immediate failure | ||
638 | /// </returns> | ||
639 | public bool DeleteItem(UUID itemID) | ||
640 | { | ||
641 | if (m_hasReceivedInventory) | ||
642 | { | ||
643 | // XXX For historical reasons (grid comms), we need to retrieve the whole item in order to delete, even though | ||
644 | // really only the item id is required. | ||
645 | InventoryItemBase item = RootFolder.FindItem(itemID); | ||
646 | |||
647 | if (null == item) | ||
648 | { | ||
649 | m_log.WarnFormat("[AGENT INVENTORY]: Tried to delete item {0} which does not exist", itemID); | ||
650 | |||
651 | return false; | ||
652 | } | ||
653 | |||
654 | if (RootFolder.DeleteItem(item.ID)) | ||
655 | { | ||
656 | List<UUID> uuids = new List<UUID>(); | ||
657 | uuids.Add(itemID); | ||
658 | return m_InventoryService.DeleteItems(this.UserProfile.ID, uuids); | ||
659 | } | ||
660 | } | ||
661 | else | ||
662 | { | ||
663 | AddRequest( | ||
664 | new InventoryRequest( | ||
665 | Delegate.CreateDelegate(typeof(DeleteItemDelegate), this, "DeleteItem"), | ||
666 | new object[] { itemID })); | ||
667 | |||
668 | return true; | ||
669 | } | ||
670 | |||
671 | return false; | ||
672 | } | ||
673 | |||
674 | /// <summary> | ||
675 | /// Send details of the inventory items and/or folders in a given folder to the client. | ||
676 | /// </summary> | ||
677 | /// <param name="client"></param> | ||
678 | /// <param name="folderID"></param> | ||
679 | /// <param name="fetchFolders"></param> | ||
680 | /// <param name="fetchItems"></param> | ||
681 | /// <returns>true if the request was queued or successfully processed, false otherwise</returns> | ||
682 | public bool SendInventoryDecendents(IClientAPI client, UUID folderID, int version, bool fetchFolders, bool fetchItems) | ||
683 | { | ||
684 | if (m_hasReceivedInventory) | ||
685 | { | ||
686 | InventoryFolderImpl folder; | ||
687 | |||
688 | if ((folder = RootFolder.FindFolder(folderID)) != null) | ||
689 | { | ||
690 | // m_log.DebugFormat( | ||
691 | // "[AGENT INVENTORY]: Found folder {0} for client {1}", | ||
692 | // folderID, remoteClient.AgentId); | ||
693 | |||
694 | client.SendInventoryFolderDetails( | ||
695 | client.AgentId, folderID, folder.RequestListOfItems(), | ||
696 | folder.RequestListOfFolders(), version, fetchFolders, fetchItems); | ||
697 | |||
698 | return true; | ||
699 | } | ||
700 | else | ||
701 | { | ||
702 | m_log.WarnFormat( | ||
703 | "[AGENT INVENTORY]: Could not find folder {0} requested by user {1} {2}", | ||
704 | folderID, client.Name, client.AgentId); | ||
705 | |||
706 | return false; | ||
707 | } | ||
708 | } | ||
709 | else | ||
710 | { | ||
711 | AddRequest( | ||
712 | new InventoryRequest( | ||
713 | Delegate.CreateDelegate(typeof(SendInventoryDescendentsDelegate), this, "SendInventoryDecendents", false, false), | ||
714 | new object[] { client, folderID, fetchFolders, fetchItems })); | ||
715 | |||
716 | return true; | ||
717 | } | ||
718 | } | ||
719 | |||
720 | /// <summary> | ||
721 | /// Find an appropriate folder for the given asset type | ||
722 | /// </summary> | ||
723 | /// <param name="type"></param> | ||
724 | /// <returns>null if no appropriate folder exists</returns> | ||
725 | public InventoryFolderImpl FindFolderForType(int type) | ||
726 | { | ||
727 | if (RootFolder == null) | ||
728 | return null; | ||
729 | |||
730 | return RootFolder.FindFolderForType(type); | ||
731 | } | ||
732 | |||
733 | // Load additional items that other regions have put into the database | ||
734 | // The item will be added tot he local cache. Returns true if the item | ||
735 | // was found and can be sent to the client | ||
736 | // | ||
737 | public bool QueryItem(InventoryItemBase item) | ||
738 | { | ||
739 | if (m_hasReceivedInventory) | ||
740 | { | ||
741 | InventoryItemBase invItem = RootFolder.FindItem(item.ID); | ||
742 | |||
743 | if (invItem != null) | ||
744 | { | ||
745 | // Item is in local cache, just update client | ||
746 | // | ||
747 | return true; | ||
748 | } | ||
749 | |||
750 | InventoryItemBase itemInfo = null; | ||
751 | |||
752 | itemInfo = m_InventoryService.GetItem(item); | ||
753 | |||
754 | if (itemInfo != null) | ||
755 | { | ||
756 | InventoryFolderImpl folder = RootFolder.FindFolder(itemInfo.Folder); | ||
757 | ItemReceive(itemInfo, folder); | ||
758 | return true; | ||
759 | } | ||
760 | |||
761 | return false; | ||
762 | } | ||
763 | else | ||
764 | { | ||
765 | AddRequest( | ||
766 | new InventoryRequest( | ||
767 | Delegate.CreateDelegate(typeof(QueryItemDelegate), this, "QueryItem"), | ||
768 | new object[] { item.ID })); | ||
769 | |||
770 | return true; | ||
771 | } | ||
772 | } | ||
773 | |||
774 | public bool QueryFolder(InventoryFolderBase folder) | ||
775 | { | ||
776 | if (m_hasReceivedInventory) | ||
777 | { | ||
778 | InventoryFolderBase invFolder = RootFolder.FindFolder(folder.ID); | ||
779 | |||
780 | if (invFolder != null) | ||
781 | { | ||
782 | // Folder is in local cache, just update client | ||
783 | // | ||
784 | return true; | ||
785 | } | ||
786 | |||
787 | InventoryFolderBase folderInfo = null; | ||
788 | |||
789 | folderInfo = m_InventoryService.GetFolder(folder); | ||
790 | |||
791 | if (folderInfo != null) | ||
792 | { | ||
793 | InventoryFolderImpl createdFolder = RootFolder.CreateChildFolder(folderInfo.ID, folderInfo.Name, (ushort)folderInfo.Type); | ||
794 | |||
795 | createdFolder.Version = folderInfo.Version; | ||
796 | createdFolder.Owner = folderInfo.Owner; | ||
797 | createdFolder.ParentID = folderInfo.ParentID; | ||
798 | |||
799 | return true; | ||
800 | } | ||
801 | |||
802 | return false; | ||
803 | } | ||
804 | else | ||
805 | { | ||
806 | AddRequest( | ||
807 | new InventoryRequest( | ||
808 | Delegate.CreateDelegate(typeof(QueryFolderDelegate), this, "QueryFolder"), | ||
809 | new object[] { folder.ID })); | ||
810 | |||
811 | return true; | ||
812 | } | ||
813 | } | ||
814 | } | ||
815 | |||
816 | /// <summary> | ||
817 | /// Should be implemented by callers which require a callback when the user's inventory is received | ||
818 | /// </summary> | ||
819 | public interface IInventoryRequest | ||
820 | { | ||
821 | /// <summary> | ||
822 | /// This is the method executed once we have received the user's inventory by which the request can be fulfilled. | ||
823 | /// </summary> | ||
824 | void Execute(); | ||
825 | } | ||
826 | |||
827 | /// <summary> | ||
828 | /// Generic inventory request | ||
829 | /// </summary> | ||
830 | class InventoryRequest : IInventoryRequest | ||
831 | { | ||
832 | private Delegate m_delegate; | ||
833 | private Object[] m_args; | ||
834 | |||
835 | internal InventoryRequest(Delegate delegat, Object[] args) | ||
836 | { | ||
837 | m_delegate = delegat; | ||
838 | m_args = args; | ||
839 | } | ||
840 | |||
841 | public void Execute() | ||
842 | { | ||
843 | if (m_delegate != null) | ||
844 | m_delegate.DynamicInvoke(m_args); | ||
845 | } | ||
846 | } | ||
847 | } | ||
diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs deleted file mode 100644 index acae4b1..0000000 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ /dev/null | |||
@@ -1,277 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | using log4net; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Services.Interfaces; | ||
33 | |||
34 | namespace OpenSim.Framework.Communications.Cache | ||
35 | { | ||
36 | /// <summary> | ||
37 | /// Holds user profile information and retrieves it from backend services. | ||
38 | /// </summary> | ||
39 | public class UserProfileCacheService | ||
40 | { | ||
41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
42 | |||
43 | /// <value> | ||
44 | /// Standard format for names. | ||
45 | /// </value> | ||
46 | public const string NAME_FORMAT = "{0} {1}"; | ||
47 | |||
48 | /// <summary> | ||
49 | /// The comms manager holds references to services (user, grid, inventory, etc.) | ||
50 | /// </summary> | ||
51 | private readonly CommunicationsManager m_commsManager; | ||
52 | |||
53 | /// <summary> | ||
54 | /// User profiles indexed by UUID | ||
55 | /// </summary> | ||
56 | private readonly Dictionary<UUID, CachedUserInfo> m_userProfilesById | ||
57 | = new Dictionary<UUID, CachedUserInfo>(); | ||
58 | |||
59 | /// <summary> | ||
60 | /// User profiles indexed by name | ||
61 | /// </summary> | ||
62 | private readonly Dictionary<string, CachedUserInfo> m_userProfilesByName | ||
63 | = new Dictionary<string, CachedUserInfo>(); | ||
64 | |||
65 | /// <summary> | ||
66 | /// The root library folder. | ||
67 | /// </summary> | ||
68 | public readonly InventoryFolderImpl LibraryRoot; | ||
69 | |||
70 | private IInventoryService m_InventoryService; | ||
71 | |||
72 | /// <summary> | ||
73 | /// Constructor | ||
74 | /// </summary> | ||
75 | /// <param name="commsManager"></param> | ||
76 | /// <param name="libraryRootFolder"></param> | ||
77 | public UserProfileCacheService(CommunicationsManager commsManager, LibraryRootFolder libraryRootFolder) | ||
78 | { | ||
79 | m_commsManager = commsManager; | ||
80 | LibraryRoot = libraryRootFolder; | ||
81 | } | ||
82 | |||
83 | public void SetInventoryService(IInventoryService invService) | ||
84 | { | ||
85 | m_InventoryService = invService; | ||
86 | } | ||
87 | |||
88 | /// <summary> | ||
89 | /// A new user has moved into a region in this instance so retrieve their profile from the user service. | ||
90 | /// </summary> | ||
91 | /// | ||
92 | /// It isn't strictly necessary to make this call since user data can be lazily requested later on. However, | ||
93 | /// it might be helpful in order to avoid an initial response delay later on | ||
94 | /// | ||
95 | /// <param name="userID"></param> | ||
96 | public void AddNewUser(UUID userID) | ||
97 | { | ||
98 | if (userID == UUID.Zero) | ||
99 | return; | ||
100 | |||
101 | //m_log.DebugFormat("[USER CACHE]: Adding user profile for {0}", userID); | ||
102 | GetUserDetails(userID); | ||
103 | } | ||
104 | |||
105 | /// <summary> | ||
106 | /// Remove this user's profile cache. | ||
107 | /// </summary> | ||
108 | /// <param name="userID"></param> | ||
109 | /// <returns>true if the user was successfully removed, false otherwise</returns> | ||
110 | public bool RemoveUser(UUID userId) | ||
111 | { | ||
112 | if (!RemoveFromCaches(userId)) | ||
113 | { | ||
114 | m_log.WarnFormat( | ||
115 | "[USER CACHE]: Tried to remove the profile of user {0}, but this was not in the scene", userId); | ||
116 | |||
117 | return false; | ||
118 | } | ||
119 | |||
120 | return true; | ||
121 | } | ||
122 | |||
123 | /// <summary> | ||
124 | /// Get details of the given user. | ||
125 | /// </summary> | ||
126 | /// If the user isn't in cache then the user is requested from the profile service. | ||
127 | /// <param name="userID"></param> | ||
128 | /// <returns>null if no user details are found</returns> | ||
129 | public CachedUserInfo GetUserDetails(string fname, string lname) | ||
130 | { | ||
131 | lock (m_userProfilesByName) | ||
132 | { | ||
133 | CachedUserInfo userInfo; | ||
134 | |||
135 | if (m_userProfilesByName.TryGetValue(string.Format(NAME_FORMAT, fname, lname), out userInfo)) | ||
136 | { | ||
137 | return userInfo; | ||
138 | } | ||
139 | else | ||
140 | { | ||
141 | UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(fname, lname); | ||
142 | |||
143 | if (userProfile != null) | ||
144 | { | ||
145 | |||
146 | if ((userProfile.UserAssetURI == null || userProfile.UserAssetURI == "") && m_commsManager.NetworkServersInfo != null) | ||
147 | userProfile.UserAssetURI = m_commsManager.NetworkServersInfo.AssetURL; | ||
148 | if ((userProfile.UserInventoryURI == null || userProfile.UserInventoryURI == "") && m_commsManager.NetworkServersInfo != null) | ||
149 | userProfile.UserInventoryURI = m_commsManager.NetworkServersInfo.InventoryURL; | ||
150 | |||
151 | return AddToCaches(userProfile); | ||
152 | } | ||
153 | else | ||
154 | return null; | ||
155 | } | ||
156 | } | ||
157 | } | ||
158 | |||
159 | /// <summary> | ||
160 | /// Get details of the given user. | ||
161 | /// </summary> | ||
162 | /// If the user isn't in cache then the user is requested from the profile service. | ||
163 | /// <param name="userID"></param> | ||
164 | /// <returns>null if no user details are found</returns> | ||
165 | public CachedUserInfo GetUserDetails(UUID userID) | ||
166 | { | ||
167 | if (userID == UUID.Zero) | ||
168 | return null; | ||
169 | |||
170 | lock (m_userProfilesById) | ||
171 | { | ||
172 | if (m_userProfilesById.ContainsKey(userID)) | ||
173 | { | ||
174 | return m_userProfilesById[userID]; | ||
175 | } | ||
176 | else | ||
177 | { | ||
178 | UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(userID); | ||
179 | if (userProfile != null) | ||
180 | { | ||
181 | |||
182 | if ((userProfile.UserAssetURI == null || userProfile.UserAssetURI == "") && m_commsManager.NetworkServersInfo != null) | ||
183 | userProfile.UserAssetURI = m_commsManager.NetworkServersInfo.AssetURL; | ||
184 | if ((userProfile.UserInventoryURI == null || userProfile.UserInventoryURI == "") && m_commsManager.NetworkServersInfo != null) | ||
185 | userProfile.UserInventoryURI = m_commsManager.NetworkServersInfo.InventoryURL; | ||
186 | |||
187 | return AddToCaches(userProfile); | ||
188 | } | ||
189 | else | ||
190 | return null; | ||
191 | } | ||
192 | } | ||
193 | } | ||
194 | |||
195 | /// <summary> | ||
196 | /// Update an existing profile | ||
197 | /// </summary> | ||
198 | /// <param name="userProfile"></param> | ||
199 | /// <returns>true if a user profile was found to update, false otherwise</returns> | ||
200 | // Commented out for now. The implementation needs to be improved by protecting against race conditions, | ||
201 | // probably by making sure that the update doesn't use the UserCacheInfo.UserProfile directly (possibly via | ||
202 | // returning a read only class from the cache). | ||
203 | // public bool StoreProfile(UserProfileData userProfile) | ||
204 | // { | ||
205 | // lock (m_userProfilesById) | ||
206 | // { | ||
207 | // CachedUserInfo userInfo = GetUserDetails(userProfile.ID); | ||
208 | // | ||
209 | // if (userInfo != null) | ||
210 | // { | ||
211 | // userInfo.m_userProfile = userProfile; | ||
212 | // m_commsManager.UserService.UpdateUserProfile(userProfile); | ||
213 | // | ||
214 | // return true; | ||
215 | // } | ||
216 | // } | ||
217 | // | ||
218 | // return false; | ||
219 | // } | ||
220 | |||
221 | /// <summary> | ||
222 | /// Populate caches with the given user profile | ||
223 | /// </summary> | ||
224 | /// <param name="userProfile"></param> | ||
225 | protected CachedUserInfo AddToCaches(UserProfileData userProfile) | ||
226 | { | ||
227 | CachedUserInfo createdUserInfo = new CachedUserInfo(m_InventoryService, userProfile); | ||
228 | |||
229 | lock (m_userProfilesById) | ||
230 | { | ||
231 | m_userProfilesById[createdUserInfo.UserProfile.ID] = createdUserInfo; | ||
232 | |||
233 | lock (m_userProfilesByName) | ||
234 | { | ||
235 | m_userProfilesByName[createdUserInfo.UserProfile.Name] = createdUserInfo; | ||
236 | } | ||
237 | } | ||
238 | |||
239 | return createdUserInfo; | ||
240 | } | ||
241 | |||
242 | /// <summary> | ||
243 | /// Remove profile belong to the given uuid from the caches | ||
244 | /// </summary> | ||
245 | /// <param name="userUuid"></param> | ||
246 | /// <returns>true if there was a profile to remove, false otherwise</returns> | ||
247 | protected bool RemoveFromCaches(UUID userId) | ||
248 | { | ||
249 | lock (m_userProfilesById) | ||
250 | { | ||
251 | if (m_userProfilesById.ContainsKey(userId)) | ||
252 | { | ||
253 | CachedUserInfo userInfo = m_userProfilesById[userId]; | ||
254 | m_userProfilesById.Remove(userId); | ||
255 | |||
256 | lock (m_userProfilesByName) | ||
257 | { | ||
258 | m_userProfilesByName.Remove(userInfo.UserProfile.Name); | ||
259 | } | ||
260 | |||
261 | return true; | ||
262 | } | ||
263 | } | ||
264 | |||
265 | return false; | ||
266 | } | ||
267 | |||
268 | /// <summary> | ||
269 | /// Preloads User data into the region cache. Modules may use this service to add non-standard clients | ||
270 | /// </summary> | ||
271 | /// <param name="userData"></param> | ||
272 | public void PreloadUserCache(UserProfileData userData) | ||
273 | { | ||
274 | AddToCaches(userData); | ||
275 | } | ||
276 | } | ||
277 | } | ||
diff --git a/OpenSim/Framework/Communications/Clients/AuthClient.cs b/OpenSim/Framework/Communications/Clients/AuthClient.cs deleted file mode 100644 index adae637..0000000 --- a/OpenSim/Framework/Communications/Clients/AuthClient.cs +++ /dev/null | |||
@@ -1,151 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using Nwc.XmlRpc; | ||
32 | using OpenMetaverse; | ||
33 | |||
34 | namespace OpenSim.Framework.Communications.Clients | ||
35 | { | ||
36 | public class AuthClient | ||
37 | { | ||
38 | public static string GetNewKey(string authurl, UUID userID, UUID authToken) | ||
39 | { | ||
40 | //Hashtable keyParams = new Hashtable(); | ||
41 | //keyParams["user_id"] = userID; | ||
42 | //keyParams["auth_token"] = authKey; | ||
43 | |||
44 | List<string> SendParams = new List<string>(); | ||
45 | SendParams.Add(userID.ToString()); | ||
46 | SendParams.Add(authToken.ToString()); | ||
47 | |||
48 | XmlRpcRequest request = new XmlRpcRequest("hg_new_auth_key", SendParams); | ||
49 | XmlRpcResponse reply; | ||
50 | try | ||
51 | { | ||
52 | reply = request.Send(authurl, 6000); | ||
53 | } | ||
54 | catch (Exception e) | ||
55 | { | ||
56 | System.Console.WriteLine("[HGrid]: Failed to get new key. Reason: " + e.Message); | ||
57 | return string.Empty; | ||
58 | } | ||
59 | |||
60 | if (!reply.IsFault) | ||
61 | { | ||
62 | string newKey = string.Empty; | ||
63 | if (reply.Value != null) | ||
64 | newKey = (string)reply.Value; | ||
65 | |||
66 | return newKey; | ||
67 | } | ||
68 | else | ||
69 | { | ||
70 | System.Console.WriteLine("[HGrid]: XmlRpc request to get auth key failed with message {0}" + reply.FaultString + ", code " + reply.FaultCode); | ||
71 | return string.Empty; | ||
72 | } | ||
73 | |||
74 | } | ||
75 | |||
76 | public static bool VerifyKey(string authurl, UUID userID, string authKey) | ||
77 | { | ||
78 | List<string> SendParams = new List<string>(); | ||
79 | SendParams.Add(userID.ToString()); | ||
80 | SendParams.Add(authKey); | ||
81 | |||
82 | System.Console.WriteLine("[HGrid]: Verifying user key with authority " + authurl); | ||
83 | |||
84 | XmlRpcRequest request = new XmlRpcRequest("hg_verify_auth_key", SendParams); | ||
85 | XmlRpcResponse reply; | ||
86 | try | ||
87 | { | ||
88 | reply = request.Send(authurl, 10000); | ||
89 | } | ||
90 | catch (Exception e) | ||
91 | { | ||
92 | System.Console.WriteLine("[HGrid]: Failed to verify key. Reason: " + e.Message); | ||
93 | return false; | ||
94 | } | ||
95 | |||
96 | if (reply != null) | ||
97 | { | ||
98 | if (!reply.IsFault) | ||
99 | { | ||
100 | bool success = false; | ||
101 | if (reply.Value != null) | ||
102 | success = (bool)reply.Value; | ||
103 | |||
104 | return success; | ||
105 | } | ||
106 | else | ||
107 | { | ||
108 | System.Console.WriteLine("[HGrid]: XmlRpc request to verify key failed with message {0}" + reply.FaultString + ", code " + reply.FaultCode); | ||
109 | return false; | ||
110 | } | ||
111 | } | ||
112 | else | ||
113 | { | ||
114 | System.Console.WriteLine("[HGrid]: XmlRpc request to verify key returned null reply"); | ||
115 | return false; | ||
116 | } | ||
117 | } | ||
118 | |||
119 | public static bool VerifySession(string authurl, UUID userID, UUID sessionID) | ||
120 | { | ||
121 | Hashtable requestData = new Hashtable(); | ||
122 | requestData["avatar_uuid"] = userID.ToString(); | ||
123 | requestData["session_id"] = sessionID.ToString(); | ||
124 | ArrayList SendParams = new ArrayList(); | ||
125 | SendParams.Add(requestData); | ||
126 | XmlRpcRequest UserReq = new XmlRpcRequest("check_auth_session", SendParams); | ||
127 | XmlRpcResponse UserResp = null; | ||
128 | try | ||
129 | { | ||
130 | UserResp = UserReq.Send(authurl, 3000); | ||
131 | } | ||
132 | catch (Exception e) | ||
133 | { | ||
134 | System.Console.WriteLine("[Session Auth]: VerifySession XmlRpc: " + e.Message); | ||
135 | return false; | ||
136 | } | ||
137 | |||
138 | Hashtable responseData = (Hashtable)UserResp.Value; | ||
139 | if (responseData != null && responseData.ContainsKey("auth_session") && responseData["auth_session"] != null && responseData["auth_session"].ToString() == "TRUE") | ||
140 | { | ||
141 | //System.Console.WriteLine("[Authorization]: userserver reported authorized session for user " + userID); | ||
142 | return true; | ||
143 | } | ||
144 | else | ||
145 | { | ||
146 | //System.Console.WriteLine("[Authorization]: userserver reported unauthorized session for user " + userID); | ||
147 | return false; | ||
148 | } | ||
149 | } | ||
150 | } | ||
151 | } | ||
diff --git a/OpenSim/Framework/Communications/Clients/GridClient.cs b/OpenSim/Framework/Communications/Clients/GridClient.cs deleted file mode 100644 index 4836556..0000000 --- a/OpenSim/Framework/Communications/Clients/GridClient.cs +++ /dev/null | |||
@@ -1,392 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | |||
34 | using log4net; | ||
35 | using OpenMetaverse; | ||
36 | using Nwc.XmlRpc; | ||
37 | |||
38 | namespace OpenSim.Framework.Communications.Clients | ||
39 | { | ||
40 | public class GridClient | ||
41 | { | ||
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | public bool RegisterRegion( | ||
45 | string gridServerURL, string sendKey, string receiveKey, RegionInfo regionInfo, out bool forcefulBanLines) | ||
46 | { | ||
47 | m_log.InfoFormat( | ||
48 | "[GRID CLIENT]: Registering region {0} with grid at {1}", regionInfo.RegionName, gridServerURL); | ||
49 | |||
50 | forcefulBanLines = true; | ||
51 | |||
52 | Hashtable GridParams = new Hashtable(); | ||
53 | // Login / Authentication | ||
54 | |||
55 | GridParams["authkey"] = sendKey; | ||
56 | GridParams["recvkey"] = receiveKey; | ||
57 | GridParams["UUID"] = regionInfo.RegionID.ToString(); | ||
58 | GridParams["sim_ip"] = regionInfo.ExternalHostName; | ||
59 | GridParams["sim_port"] = regionInfo.InternalEndPoint.Port.ToString(); | ||
60 | GridParams["region_locx"] = regionInfo.RegionLocX.ToString(); | ||
61 | GridParams["region_locy"] = regionInfo.RegionLocY.ToString(); | ||
62 | GridParams["sim_name"] = regionInfo.RegionName; | ||
63 | GridParams["http_port"] = regionInfo.HttpPort.ToString(); | ||
64 | GridParams["remoting_port"] = ConfigSettings.DefaultRegionRemotingPort.ToString(); | ||
65 | GridParams["map-image-id"] = regionInfo.RegionSettings.TerrainImageID.ToString(); | ||
66 | GridParams["originUUID"] = regionInfo.originRegionID.ToString(); | ||
67 | GridParams["server_uri"] = regionInfo.ServerURI; | ||
68 | GridParams["region_secret"] = regionInfo.regionSecret; | ||
69 | GridParams["major_interface_version"] = VersionInfo.MajorInterfaceVersion.ToString(); | ||
70 | |||
71 | if (regionInfo.MasterAvatarAssignedUUID != UUID.Zero) | ||
72 | GridParams["master_avatar_uuid"] = regionInfo.MasterAvatarAssignedUUID.ToString(); | ||
73 | else | ||
74 | GridParams["master_avatar_uuid"] = regionInfo.EstateSettings.EstateOwner.ToString(); | ||
75 | |||
76 | // Package into an XMLRPC Request | ||
77 | ArrayList SendParams = new ArrayList(); | ||
78 | SendParams.Add(GridParams); | ||
79 | |||
80 | // Send Request | ||
81 | XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams); | ||
82 | XmlRpcResponse GridResp; | ||
83 | |||
84 | try | ||
85 | { | ||
86 | // The timeout should always be significantly larger than the timeout for the grid server to request | ||
87 | // the initial status of the region before confirming registration. | ||
88 | GridResp = GridReq.Send(gridServerURL, 90000); | ||
89 | } | ||
90 | catch (Exception e) | ||
91 | { | ||
92 | Exception e2 | ||
93 | = new Exception( | ||
94 | String.Format( | ||
95 | "Unable to register region with grid at {0}. Grid service not running?", | ||
96 | gridServerURL), | ||
97 | e); | ||
98 | |||
99 | throw e2; | ||
100 | } | ||
101 | |||
102 | Hashtable GridRespData = (Hashtable)GridResp.Value; | ||
103 | // Hashtable griddatahash = GridRespData; | ||
104 | |||
105 | // Process Response | ||
106 | if (GridRespData.ContainsKey("error")) | ||
107 | { | ||
108 | string errorstring = (string)GridRespData["error"]; | ||
109 | |||
110 | Exception e = new Exception( | ||
111 | String.Format("Unable to connect to grid at {0}: {1}", gridServerURL, errorstring)); | ||
112 | |||
113 | throw e; | ||
114 | } | ||
115 | else | ||
116 | { | ||
117 | // m_knownRegions = RequestNeighbours(regionInfo.RegionLocX, regionInfo.RegionLocY); | ||
118 | if (GridRespData.ContainsKey("allow_forceful_banlines")) | ||
119 | { | ||
120 | if ((string)GridRespData["allow_forceful_banlines"] != "TRUE") | ||
121 | { | ||
122 | forcefulBanLines = false; | ||
123 | } | ||
124 | } | ||
125 | |||
126 | } | ||
127 | return true; | ||
128 | } | ||
129 | |||
130 | public bool DeregisterRegion(string gridServerURL, string sendKey, string receiveKey, RegionInfo regionInfo, out string errorMsg) | ||
131 | { | ||
132 | errorMsg = ""; | ||
133 | Hashtable GridParams = new Hashtable(); | ||
134 | |||
135 | GridParams["UUID"] = regionInfo.RegionID.ToString(); | ||
136 | |||
137 | // Package into an XMLRPC Request | ||
138 | ArrayList SendParams = new ArrayList(); | ||
139 | SendParams.Add(GridParams); | ||
140 | |||
141 | // Send Request | ||
142 | XmlRpcRequest GridReq = new XmlRpcRequest("simulator_after_region_moved", SendParams); | ||
143 | XmlRpcResponse GridResp = null; | ||
144 | |||
145 | try | ||
146 | { | ||
147 | GridResp = GridReq.Send(gridServerURL, 10000); | ||
148 | } | ||
149 | catch (Exception e) | ||
150 | { | ||
151 | Exception e2 | ||
152 | = new Exception( | ||
153 | String.Format( | ||
154 | "Unable to deregister region with grid at {0}. Grid service not running?", | ||
155 | gridServerURL), | ||
156 | e); | ||
157 | |||
158 | throw e2; | ||
159 | } | ||
160 | |||
161 | Hashtable GridRespData = (Hashtable)GridResp.Value; | ||
162 | |||
163 | // Hashtable griddatahash = GridRespData; | ||
164 | |||
165 | // Process Response | ||
166 | if (GridRespData != null && GridRespData.ContainsKey("error")) | ||
167 | { | ||
168 | errorMsg = (string)GridRespData["error"]; | ||
169 | return false; | ||
170 | } | ||
171 | |||
172 | return true; | ||
173 | } | ||
174 | |||
175 | public bool RequestNeighborInfo( | ||
176 | string gridServerURL, string sendKey, string receiveKey, UUID regionUUID, | ||
177 | out RegionInfo regionInfo, out string errorMsg) | ||
178 | { | ||
179 | // didn't find it so far, we have to go the long way | ||
180 | regionInfo = null; | ||
181 | errorMsg = string.Empty; | ||
182 | Hashtable requestData = new Hashtable(); | ||
183 | requestData["region_UUID"] = regionUUID.ToString(); | ||
184 | requestData["authkey"] = sendKey; | ||
185 | ArrayList SendParams = new ArrayList(); | ||
186 | SendParams.Add(requestData); | ||
187 | XmlRpcRequest gridReq = new XmlRpcRequest("simulator_data_request", SendParams); | ||
188 | XmlRpcResponse gridResp = null; | ||
189 | |||
190 | try | ||
191 | { | ||
192 | gridResp = gridReq.Send(gridServerURL, 3000); | ||
193 | } | ||
194 | catch (Exception e) | ||
195 | { | ||
196 | errorMsg = e.Message; | ||
197 | return false; | ||
198 | } | ||
199 | |||
200 | Hashtable responseData = (Hashtable)gridResp.Value; | ||
201 | |||
202 | if (responseData.ContainsKey("error")) | ||
203 | { | ||
204 | errorMsg = (string)responseData["error"]; | ||
205 | return false; ; | ||
206 | } | ||
207 | |||
208 | regionInfo = BuildRegionInfo(responseData, String.Empty); | ||
209 | |||
210 | return true; | ||
211 | } | ||
212 | |||
213 | public bool RequestNeighborInfo( | ||
214 | string gridServerURL, string sendKey, string receiveKey, ulong regionHandle, | ||
215 | out RegionInfo regionInfo, out string errorMsg) | ||
216 | { | ||
217 | // didn't find it so far, we have to go the long way | ||
218 | regionInfo = null; | ||
219 | errorMsg = string.Empty; | ||
220 | |||
221 | try | ||
222 | { | ||
223 | Hashtable requestData = new Hashtable(); | ||
224 | requestData["region_handle"] = regionHandle.ToString(); | ||
225 | requestData["authkey"] = sendKey; | ||
226 | ArrayList SendParams = new ArrayList(); | ||
227 | SendParams.Add(requestData); | ||
228 | XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); | ||
229 | XmlRpcResponse GridResp = GridReq.Send(gridServerURL, 3000); | ||
230 | |||
231 | Hashtable responseData = (Hashtable)GridResp.Value; | ||
232 | |||
233 | if (responseData.ContainsKey("error")) | ||
234 | { | ||
235 | errorMsg = (string)responseData["error"]; | ||
236 | return false; | ||
237 | } | ||
238 | |||
239 | uint regX = Convert.ToUInt32((string)responseData["region_locx"]); | ||
240 | uint regY = Convert.ToUInt32((string)responseData["region_locy"]); | ||
241 | string externalHostName = (string)responseData["sim_ip"]; | ||
242 | uint simPort = Convert.ToUInt32(responseData["sim_port"]); | ||
243 | string regionName = (string)responseData["region_name"]; | ||
244 | UUID regionID = new UUID((string)responseData["region_UUID"]); | ||
245 | uint remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); | ||
246 | |||
247 | uint httpPort = 9000; | ||
248 | if (responseData.ContainsKey("http_port")) | ||
249 | { | ||
250 | httpPort = Convert.ToUInt32((string)responseData["http_port"]); | ||
251 | } | ||
252 | |||
253 | // Ok, so this is definitively the wrong place to do this, way too hard coded, but it doesn't seem we GET this info? | ||
254 | |||
255 | string simURI = "http://" + externalHostName + ":" + simPort; | ||
256 | |||
257 | // string externalUri = (string) responseData["sim_uri"]; | ||
258 | |||
259 | //IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port); | ||
260 | regionInfo = RegionInfo.Create(regionID, regionName, regX, regY, externalHostName, httpPort, simPort, remotingPort, simURI); | ||
261 | } | ||
262 | catch (Exception e) | ||
263 | { | ||
264 | errorMsg = e.Message; | ||
265 | return false; | ||
266 | } | ||
267 | |||
268 | return true; | ||
269 | } | ||
270 | |||
271 | public bool RequestClosestRegion( | ||
272 | string gridServerURL, string sendKey, string receiveKey, string regionName, | ||
273 | out RegionInfo regionInfo, out string errorMsg) | ||
274 | { | ||
275 | regionInfo = null; | ||
276 | errorMsg = string.Empty; | ||
277 | try | ||
278 | { | ||
279 | Hashtable requestData = new Hashtable(); | ||
280 | requestData["region_name_search"] = regionName; | ||
281 | requestData["authkey"] = sendKey; | ||
282 | ArrayList SendParams = new ArrayList(); | ||
283 | SendParams.Add(requestData); | ||
284 | XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); | ||
285 | XmlRpcResponse GridResp = GridReq.Send(gridServerURL, 3000); | ||
286 | |||
287 | Hashtable responseData = (Hashtable)GridResp.Value; | ||
288 | |||
289 | if (responseData.ContainsKey("error")) | ||
290 | { | ||
291 | errorMsg = (string)responseData["error"]; | ||
292 | return false; | ||
293 | } | ||
294 | |||
295 | regionInfo = BuildRegionInfo(responseData, ""); | ||
296 | |||
297 | } | ||
298 | catch (Exception e) | ||
299 | { | ||
300 | errorMsg = e.Message; | ||
301 | return false; | ||
302 | } | ||
303 | return true; | ||
304 | } | ||
305 | |||
306 | /// <summary> | ||
307 | /// Performs a XML-RPC query against the grid server returning mapblock information in the specified coordinates | ||
308 | /// </summary> | ||
309 | /// <remarks>REDUNDANT - OGS1 is to be phased out in favour of OGS2</remarks> | ||
310 | /// <param name="minX">Minimum X value</param> | ||
311 | /// <param name="minY">Minimum Y value</param> | ||
312 | /// <param name="maxX">Maximum X value</param> | ||
313 | /// <param name="maxY">Maximum Y value</param> | ||
314 | /// <returns>Hashtable of hashtables containing map data elements</returns> | ||
315 | public bool MapBlockQuery( | ||
316 | string gridServerURL, int minX, int minY, int maxX, int maxY, out Hashtable respData, out string errorMsg) | ||
317 | { | ||
318 | respData = new Hashtable(); | ||
319 | errorMsg = string.Empty; | ||
320 | |||
321 | Hashtable param = new Hashtable(); | ||
322 | param["xmin"] = minX; | ||
323 | param["ymin"] = minY; | ||
324 | param["xmax"] = maxX; | ||
325 | param["ymax"] = maxY; | ||
326 | IList parameters = new ArrayList(); | ||
327 | parameters.Add(param); | ||
328 | |||
329 | try | ||
330 | { | ||
331 | XmlRpcRequest req = new XmlRpcRequest("map_block", parameters); | ||
332 | XmlRpcResponse resp = req.Send(gridServerURL, 10000); | ||
333 | respData = (Hashtable)resp.Value; | ||
334 | return true; | ||
335 | } | ||
336 | catch (Exception e) | ||
337 | { | ||
338 | errorMsg = e.Message; | ||
339 | return false; | ||
340 | } | ||
341 | } | ||
342 | |||
343 | public bool SearchRegionByName(string gridServerURL, IList parameters, out Hashtable respData, out string errorMsg) | ||
344 | { | ||
345 | respData = null; | ||
346 | errorMsg = string.Empty; | ||
347 | try | ||
348 | { | ||
349 | XmlRpcRequest request = new XmlRpcRequest("search_for_region_by_name", parameters); | ||
350 | XmlRpcResponse resp = request.Send(gridServerURL, 10000); | ||
351 | respData = (Hashtable)resp.Value; | ||
352 | if (respData != null && respData.Contains("faultCode")) | ||
353 | { | ||
354 | errorMsg = (string)respData["faultString"]; | ||
355 | return false; | ||
356 | } | ||
357 | |||
358 | return true; | ||
359 | } | ||
360 | catch (Exception e) | ||
361 | { | ||
362 | errorMsg = e.Message; | ||
363 | return false; | ||
364 | } | ||
365 | } | ||
366 | |||
367 | public RegionInfo BuildRegionInfo(Hashtable responseData, string prefix) | ||
368 | { | ||
369 | uint regX = Convert.ToUInt32((string)responseData[prefix + "region_locx"]); | ||
370 | uint regY = Convert.ToUInt32((string)responseData[prefix + "region_locy"]); | ||
371 | string internalIpStr = (string)responseData[prefix + "sim_ip"]; | ||
372 | uint port = Convert.ToUInt32(responseData[prefix + "sim_port"]); | ||
373 | |||
374 | IPEndPoint neighbourInternalEndPoint = new IPEndPoint(Util.GetHostFromDNS(internalIpStr), (int)port); | ||
375 | |||
376 | RegionInfo regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); | ||
377 | regionInfo.RemotingPort = Convert.ToUInt32((string)responseData[prefix + "remoting_port"]); | ||
378 | regionInfo.RemotingAddress = internalIpStr; | ||
379 | |||
380 | if (responseData.ContainsKey(prefix + "http_port")) | ||
381 | { | ||
382 | regionInfo.HttpPort = Convert.ToUInt32((string)responseData[prefix + "http_port"]); | ||
383 | } | ||
384 | |||
385 | regionInfo.RegionID = new UUID((string)responseData[prefix + "region_UUID"]); | ||
386 | regionInfo.RegionName = (string)responseData[prefix + "region_name"]; | ||
387 | |||
388 | regionInfo.RegionSettings.TerrainImageID = new UUID((string)responseData[prefix + "map_UUID"]); | ||
389 | return regionInfo; | ||
390 | } | ||
391 | } | ||
392 | } | ||
diff --git a/OpenSim/Framework/Communications/Clients/InventoryClient.cs b/OpenSim/Framework/Communications/Clients/InventoryClient.cs deleted file mode 100644 index e4f5e2a..0000000 --- a/OpenSim/Framework/Communications/Clients/InventoryClient.cs +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
1 | /** | ||
2 | * Copyright (c), Contributors. All rights reserved. | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without modification, | ||
6 | * are permitted provided that the following conditions are met: | ||
7 | * | ||
8 | * * Redistributions of source code must retain the above copyright notice, | ||
9 | * this list of conditions and the following disclaimer. | ||
10 | * * Redistributions in binary form must reproduce the above copyright notice, | ||
11 | * this list of conditions and the following disclaimer in the documentation | ||
12 | * and/or other materials provided with the distribution. | ||
13 | * * Neither the name of the Organizations nor the names of Individual | ||
14 | * Contributors may be used to endorse or promote products derived from | ||
15 | * this software without specific prior written permission. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | ||
20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | ||
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
25 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | |||
29 | using System; | ||
30 | using OpenSim.Framework.Servers; | ||
31 | using OpenSim.Framework.Servers.HttpServer; | ||
32 | |||
33 | using OpenMetaverse; | ||
34 | |||
35 | namespace OpenSim.Framework.Communications.Clients | ||
36 | { | ||
37 | public class InventoryClient | ||
38 | { | ||
39 | private string ServerURL; | ||
40 | |||
41 | public InventoryClient(string url) | ||
42 | { | ||
43 | ServerURL = url; | ||
44 | } | ||
45 | |||
46 | public void GetInventoryItemAsync(InventoryItemBase item, ReturnResponse<InventoryItemBase> callBack) | ||
47 | { | ||
48 | System.Console.WriteLine("[HGrid] GetInventory from " + ServerURL); | ||
49 | try | ||
50 | { | ||
51 | RestSessionObjectPosterResponse<InventoryItemBase, InventoryItemBase> requester | ||
52 | = new RestSessionObjectPosterResponse<InventoryItemBase, InventoryItemBase>(); | ||
53 | requester.ResponseCallback = callBack; | ||
54 | |||
55 | requester.BeginPostObject(ServerURL + "/GetItem/", item, string.Empty, string.Empty); | ||
56 | } | ||
57 | catch (Exception e) | ||
58 | { | ||
59 | System.Console.WriteLine("[HGrid]: Exception posting to inventory: " + e); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | public InventoryItemBase GetInventoryItem(InventoryItemBase item) | ||
64 | { | ||
65 | System.Console.WriteLine("[HGrid] GetInventory " + item.ID + " from " + ServerURL); | ||
66 | try | ||
67 | { | ||
68 | item = SynchronousRestSessionObjectPoster<Guid, InventoryItemBase>.BeginPostObject("POST", ServerURL + "/GetItem/", item.ID.Guid, "", ""); | ||
69 | return item; | ||
70 | } | ||
71 | catch (Exception e) | ||
72 | { | ||
73 | System.Console.WriteLine("[HGrid]: Exception posting to inventory: " + e); | ||
74 | } | ||
75 | return null; | ||
76 | } | ||
77 | |||
78 | } | ||
79 | } | ||
diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs deleted file mode 100644 index ee7dec8..0000000 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ /dev/null | |||
@@ -1,755 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Text; | ||
34 | |||
35 | using OpenMetaverse; | ||
36 | using OpenMetaverse.StructuredData; | ||
37 | |||
38 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
39 | |||
40 | using log4net; | ||
41 | |||
42 | namespace OpenSim.Framework.Communications.Clients | ||
43 | { | ||
44 | public class RegionClient | ||
45 | { | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | public bool DoCreateChildAgentCall(GridRegion region, AgentCircuitData aCircuit, string authKey, uint teleportFlags, out string reason) | ||
49 | { | ||
50 | reason = String.Empty; | ||
51 | |||
52 | // Eventually, we want to use a caps url instead of the agentID | ||
53 | string uri = string.Empty; | ||
54 | try | ||
55 | { | ||
56 | uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + aCircuit.AgentID + "/"; | ||
57 | } | ||
58 | catch (Exception e) | ||
59 | { | ||
60 | m_log.Debug("[REST COMMS]: Unable to resolve external endpoint on agent create. Reason: " + e.Message); | ||
61 | reason = e.Message; | ||
62 | return false; | ||
63 | } | ||
64 | |||
65 | //Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri); | ||
66 | |||
67 | HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri); | ||
68 | AgentCreateRequest.Method = "POST"; | ||
69 | AgentCreateRequest.ContentType = "application/json"; | ||
70 | AgentCreateRequest.Timeout = 10000; | ||
71 | //AgentCreateRequest.KeepAlive = false; | ||
72 | AgentCreateRequest.Headers.Add("Authorization", authKey); | ||
73 | |||
74 | // Fill it in | ||
75 | OSDMap args = null; | ||
76 | try | ||
77 | { | ||
78 | args = aCircuit.PackAgentCircuitData(); | ||
79 | } | ||
80 | catch (Exception e) | ||
81 | { | ||
82 | m_log.Debug("[REST COMMS]: PackAgentCircuitData failed with exception: " + e.Message); | ||
83 | } | ||
84 | // Add the regionhandle of the destination region | ||
85 | ulong regionHandle = GetRegionHandle(region.RegionHandle); | ||
86 | args["destination_handle"] = OSD.FromString(regionHandle.ToString()); | ||
87 | args["teleport_flags"] = OSD.FromString(teleportFlags.ToString()); | ||
88 | |||
89 | string strBuffer = ""; | ||
90 | byte[] buffer = new byte[1]; | ||
91 | try | ||
92 | { | ||
93 | strBuffer = OSDParser.SerializeJsonString(args); | ||
94 | Encoding str = Util.UTF8; | ||
95 | buffer = str.GetBytes(strBuffer); | ||
96 | |||
97 | } | ||
98 | catch (Exception e) | ||
99 | { | ||
100 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of ChildCreate: {0}", e.Message); | ||
101 | // ignore. buffer will be empty, caller should check. | ||
102 | } | ||
103 | |||
104 | Stream os = null; | ||
105 | try | ||
106 | { // send the Post | ||
107 | AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send | ||
108 | os = AgentCreateRequest.GetRequestStream(); | ||
109 | os.Write(buffer, 0, strBuffer.Length); //Send it | ||
110 | //m_log.InfoFormat("[REST COMMS]: Posted CreateChildAgent request to remote sim {0}", uri); | ||
111 | } | ||
112 | //catch (WebException ex) | ||
113 | catch | ||
114 | { | ||
115 | //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); | ||
116 | reason = "cannot contact remote region"; | ||
117 | return false; | ||
118 | } | ||
119 | finally | ||
120 | { | ||
121 | if (os != null) | ||
122 | os.Close(); | ||
123 | } | ||
124 | |||
125 | // Let's wait for the response | ||
126 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); | ||
127 | |||
128 | WebResponse webResponse = null; | ||
129 | StreamReader sr = null; | ||
130 | try | ||
131 | { | ||
132 | webResponse = AgentCreateRequest.GetResponse(); | ||
133 | if (webResponse == null) | ||
134 | { | ||
135 | m_log.Info("[REST COMMS]: Null reply on DoCreateChildAgentCall post"); | ||
136 | } | ||
137 | else | ||
138 | { | ||
139 | |||
140 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
141 | string response = sr.ReadToEnd().Trim(); | ||
142 | m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", response); | ||
143 | |||
144 | if (!String.IsNullOrEmpty(response)) | ||
145 | { | ||
146 | try | ||
147 | { | ||
148 | // we assume we got an OSDMap back | ||
149 | OSDMap r = GetOSDMap(response); | ||
150 | bool success = r["success"].AsBoolean(); | ||
151 | reason = r["reason"].AsString(); | ||
152 | return success; | ||
153 | } | ||
154 | catch (NullReferenceException e) | ||
155 | { | ||
156 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", e.Message); | ||
157 | |||
158 | // check for old style response | ||
159 | if (response.ToLower().StartsWith("true")) | ||
160 | return true; | ||
161 | |||
162 | return false; | ||
163 | } | ||
164 | } | ||
165 | } | ||
166 | } | ||
167 | catch (WebException ex) | ||
168 | { | ||
169 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); | ||
170 | // ignore, really | ||
171 | } | ||
172 | finally | ||
173 | { | ||
174 | if (sr != null) | ||
175 | sr.Close(); | ||
176 | } | ||
177 | |||
178 | return true; | ||
179 | |||
180 | } | ||
181 | |||
182 | public bool DoChildAgentUpdateCall(GridRegion region, IAgentData cAgentData) | ||
183 | { | ||
184 | // Eventually, we want to use a caps url instead of the agentID | ||
185 | string uri = string.Empty; | ||
186 | try | ||
187 | { | ||
188 | uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + cAgentData.AgentID + "/"; | ||
189 | } | ||
190 | catch (Exception e) | ||
191 | { | ||
192 | m_log.Debug("[REST COMMS]: Unable to resolve external endpoint on agent update. Reason: " + e.Message); | ||
193 | return false; | ||
194 | } | ||
195 | //Console.WriteLine(" >>> DoChildAgentUpdateCall <<< " + uri); | ||
196 | |||
197 | HttpWebRequest ChildUpdateRequest = (HttpWebRequest)WebRequest.Create(uri); | ||
198 | ChildUpdateRequest.Method = "PUT"; | ||
199 | ChildUpdateRequest.ContentType = "application/json"; | ||
200 | ChildUpdateRequest.Timeout = 10000; | ||
201 | //ChildUpdateRequest.KeepAlive = false; | ||
202 | |||
203 | // Fill it in | ||
204 | OSDMap args = null; | ||
205 | try | ||
206 | { | ||
207 | args = cAgentData.Pack(); | ||
208 | } | ||
209 | catch (Exception e) | ||
210 | { | ||
211 | m_log.Debug("[REST COMMS]: PackUpdateMessage failed with exception: " + e.Message); | ||
212 | } | ||
213 | // Add the regionhandle of the destination region | ||
214 | ulong regionHandle = GetRegionHandle(region.RegionHandle); | ||
215 | args["destination_handle"] = OSD.FromString(regionHandle.ToString()); | ||
216 | |||
217 | string strBuffer = ""; | ||
218 | byte[] buffer = new byte[1]; | ||
219 | try | ||
220 | { | ||
221 | strBuffer = OSDParser.SerializeJsonString(args); | ||
222 | Encoding str = Util.UTF8; | ||
223 | buffer = str.GetBytes(strBuffer); | ||
224 | |||
225 | } | ||
226 | catch (Exception e) | ||
227 | { | ||
228 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of ChildUpdate: {0}", e.Message); | ||
229 | // ignore. buffer will be empty, caller should check. | ||
230 | } | ||
231 | |||
232 | Stream os = null; | ||
233 | try | ||
234 | { // send the Post | ||
235 | ChildUpdateRequest.ContentLength = buffer.Length; //Count bytes to send | ||
236 | os = ChildUpdateRequest.GetRequestStream(); | ||
237 | os.Write(buffer, 0, strBuffer.Length); //Send it | ||
238 | //m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); | ||
239 | } | ||
240 | //catch (WebException ex) | ||
241 | catch | ||
242 | { | ||
243 | //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); | ||
244 | |||
245 | return false; | ||
246 | } | ||
247 | finally | ||
248 | { | ||
249 | if (os != null) | ||
250 | os.Close(); | ||
251 | } | ||
252 | |||
253 | // Let's wait for the response | ||
254 | //m_log.Info("[REST COMMS]: Waiting for a reply after ChildAgentUpdate"); | ||
255 | |||
256 | WebResponse webResponse = null; | ||
257 | StreamReader sr = null; | ||
258 | try | ||
259 | { | ||
260 | webResponse = ChildUpdateRequest.GetResponse(); | ||
261 | if (webResponse == null) | ||
262 | { | ||
263 | m_log.Info("[REST COMMS]: Null reply on ChilAgentUpdate post"); | ||
264 | } | ||
265 | |||
266 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
267 | //reply = sr.ReadToEnd().Trim(); | ||
268 | sr.ReadToEnd().Trim(); | ||
269 | sr.Close(); | ||
270 | //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); | ||
271 | |||
272 | } | ||
273 | catch (WebException ex) | ||
274 | { | ||
275 | m_log.InfoFormat("[REST COMMS]: exception on reply of ChilAgentUpdate {0}", ex.Message); | ||
276 | // ignore, really | ||
277 | } | ||
278 | finally | ||
279 | { | ||
280 | if (sr != null) | ||
281 | sr.Close(); | ||
282 | } | ||
283 | |||
284 | return true; | ||
285 | } | ||
286 | |||
287 | public bool DoRetrieveRootAgentCall(GridRegion region, UUID id, out IAgentData agent) | ||
288 | { | ||
289 | agent = null; | ||
290 | // Eventually, we want to use a caps url instead of the agentID | ||
291 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; | ||
292 | //Console.WriteLine(" >>> DoRetrieveRootAgentCall <<< " + uri); | ||
293 | |||
294 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); | ||
295 | request.Method = "GET"; | ||
296 | request.Timeout = 10000; | ||
297 | //request.Headers.Add("authorization", ""); // coming soon | ||
298 | |||
299 | HttpWebResponse webResponse = null; | ||
300 | string reply = string.Empty; | ||
301 | StreamReader sr = null; | ||
302 | try | ||
303 | { | ||
304 | webResponse = (HttpWebResponse)request.GetResponse(); | ||
305 | if (webResponse == null) | ||
306 | { | ||
307 | m_log.Info("[REST COMMS]: Null reply on agent get "); | ||
308 | } | ||
309 | |||
310 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
311 | reply = sr.ReadToEnd().Trim(); | ||
312 | |||
313 | //Console.WriteLine("[REST COMMS]: ChilAgentUpdate reply was " + reply); | ||
314 | |||
315 | } | ||
316 | catch (WebException ex) | ||
317 | { | ||
318 | m_log.InfoFormat("[REST COMMS]: exception on reply of agent get {0}", ex.Message); | ||
319 | // ignore, really | ||
320 | return false; | ||
321 | } | ||
322 | finally | ||
323 | { | ||
324 | if (sr != null) | ||
325 | sr.Close(); | ||
326 | } | ||
327 | |||
328 | if (webResponse.StatusCode == HttpStatusCode.OK) | ||
329 | { | ||
330 | // we know it's jason | ||
331 | OSDMap args = GetOSDMap(reply); | ||
332 | if (args == null) | ||
333 | { | ||
334 | //Console.WriteLine("[REST COMMS]: Error getting OSDMap from reply"); | ||
335 | return false; | ||
336 | } | ||
337 | |||
338 | agent = new CompleteAgentData(); | ||
339 | agent.Unpack(args); | ||
340 | return true; | ||
341 | } | ||
342 | |||
343 | //Console.WriteLine("[REST COMMS]: DoRetrieveRootAgentCall returned status " + webResponse.StatusCode); | ||
344 | return false; | ||
345 | } | ||
346 | |||
347 | public bool DoReleaseAgentCall(ulong regionHandle, UUID id, string uri) | ||
348 | { | ||
349 | //m_log.Debug(" >>> DoReleaseAgentCall <<< " + uri); | ||
350 | |||
351 | WebRequest request = WebRequest.Create(uri); | ||
352 | request.Method = "DELETE"; | ||
353 | request.Timeout = 10000; | ||
354 | |||
355 | StreamReader sr = null; | ||
356 | try | ||
357 | { | ||
358 | WebResponse webResponse = request.GetResponse(); | ||
359 | if (webResponse == null) | ||
360 | { | ||
361 | m_log.Info("[REST COMMS]: Null reply on agent delete "); | ||
362 | } | ||
363 | |||
364 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
365 | //reply = sr.ReadToEnd().Trim(); | ||
366 | sr.ReadToEnd().Trim(); | ||
367 | sr.Close(); | ||
368 | //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); | ||
369 | |||
370 | } | ||
371 | catch (WebException ex) | ||
372 | { | ||
373 | m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); | ||
374 | // ignore, really | ||
375 | } | ||
376 | finally | ||
377 | { | ||
378 | if (sr != null) | ||
379 | sr.Close(); | ||
380 | } | ||
381 | |||
382 | return true; | ||
383 | } | ||
384 | |||
385 | |||
386 | public bool DoCloseAgentCall(GridRegion region, UUID id) | ||
387 | { | ||
388 | string uri = string.Empty; | ||
389 | try | ||
390 | { | ||
391 | uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; | ||
392 | } | ||
393 | catch (Exception e) | ||
394 | { | ||
395 | m_log.Debug("[REST COMMS]: Unable to resolve external endpoint on agent close. Reason: " + e.Message); | ||
396 | return false; | ||
397 | } | ||
398 | |||
399 | //Console.WriteLine(" >>> DoCloseAgentCall <<< " + uri); | ||
400 | |||
401 | WebRequest request = WebRequest.Create(uri); | ||
402 | request.Method = "DELETE"; | ||
403 | request.Timeout = 10000; | ||
404 | |||
405 | StreamReader sr = null; | ||
406 | try | ||
407 | { | ||
408 | WebResponse webResponse = request.GetResponse(); | ||
409 | if (webResponse == null) | ||
410 | { | ||
411 | m_log.Info("[REST COMMS]: Null reply on agent delete "); | ||
412 | } | ||
413 | |||
414 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
415 | //reply = sr.ReadToEnd().Trim(); | ||
416 | sr.ReadToEnd().Trim(); | ||
417 | sr.Close(); | ||
418 | //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); | ||
419 | |||
420 | } | ||
421 | catch (WebException ex) | ||
422 | { | ||
423 | m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); | ||
424 | // ignore, really | ||
425 | } | ||
426 | finally | ||
427 | { | ||
428 | if (sr != null) | ||
429 | sr.Close(); | ||
430 | } | ||
431 | |||
432 | return true; | ||
433 | } | ||
434 | |||
435 | public bool DoCreateObjectCall(GridRegion region, ISceneObject sog, string sogXml2, bool allowScriptCrossing) | ||
436 | { | ||
437 | ulong regionHandle = GetRegionHandle(region.RegionHandle); | ||
438 | string uri | ||
439 | = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort | ||
440 | + "/object/" + sog.UUID + "/" + regionHandle.ToString() + "/"; | ||
441 | //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); | ||
442 | |||
443 | WebRequest ObjectCreateRequest = WebRequest.Create(uri); | ||
444 | ObjectCreateRequest.Method = "POST"; | ||
445 | ObjectCreateRequest.ContentType = "application/json"; | ||
446 | ObjectCreateRequest.Timeout = 10000; | ||
447 | |||
448 | OSDMap args = new OSDMap(2); | ||
449 | args["sog"] = OSD.FromString(sogXml2); | ||
450 | args["extra"] = OSD.FromString(sog.ExtraToXmlString()); | ||
451 | if (allowScriptCrossing) | ||
452 | { | ||
453 | string state = sog.GetStateSnapshot(); | ||
454 | if (state.Length > 0) | ||
455 | args["state"] = OSD.FromString(state); | ||
456 | } | ||
457 | |||
458 | string strBuffer = ""; | ||
459 | byte[] buffer = new byte[1]; | ||
460 | try | ||
461 | { | ||
462 | strBuffer = OSDParser.SerializeJsonString(args); | ||
463 | Encoding str = Util.UTF8; | ||
464 | buffer = str.GetBytes(strBuffer); | ||
465 | |||
466 | } | ||
467 | catch (Exception e) | ||
468 | { | ||
469 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message); | ||
470 | // ignore. buffer will be empty, caller should check. | ||
471 | } | ||
472 | |||
473 | Stream os = null; | ||
474 | try | ||
475 | { // send the Post | ||
476 | ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send | ||
477 | os = ObjectCreateRequest.GetRequestStream(); | ||
478 | os.Write(buffer, 0, strBuffer.Length); //Send it | ||
479 | m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); | ||
480 | } | ||
481 | //catch (WebException ex) | ||
482 | catch | ||
483 | { | ||
484 | // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message); | ||
485 | |||
486 | return false; | ||
487 | } | ||
488 | finally | ||
489 | { | ||
490 | if (os != null) | ||
491 | os.Close(); | ||
492 | } | ||
493 | |||
494 | // Let's wait for the response | ||
495 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); | ||
496 | |||
497 | StreamReader sr = null; | ||
498 | try | ||
499 | { | ||
500 | WebResponse webResponse = ObjectCreateRequest.GetResponse(); | ||
501 | if (webResponse == null) | ||
502 | { | ||
503 | m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); | ||
504 | } | ||
505 | |||
506 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
507 | //reply = sr.ReadToEnd().Trim(); | ||
508 | sr.ReadToEnd().Trim(); | ||
509 | //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); | ||
510 | |||
511 | } | ||
512 | catch (WebException ex) | ||
513 | { | ||
514 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); | ||
515 | // ignore, really | ||
516 | } | ||
517 | finally | ||
518 | { | ||
519 | if (sr != null) | ||
520 | sr.Close(); | ||
521 | } | ||
522 | |||
523 | return true; | ||
524 | |||
525 | } | ||
526 | |||
527 | public bool DoCreateObjectCall(GridRegion region, UUID userID, UUID itemID) | ||
528 | { | ||
529 | ulong regionHandle = GetRegionHandle(region.RegionHandle); | ||
530 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + UUID.Zero + "/" + regionHandle.ToString() + "/"; | ||
531 | //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); | ||
532 | |||
533 | WebRequest ObjectCreateRequest = WebRequest.Create(uri); | ||
534 | ObjectCreateRequest.Method = "PUT"; | ||
535 | ObjectCreateRequest.ContentType = "application/json"; | ||
536 | ObjectCreateRequest.Timeout = 10000; | ||
537 | |||
538 | OSDMap args = new OSDMap(2); | ||
539 | args["userid"] = OSD.FromUUID(userID); | ||
540 | args["itemid"] = OSD.FromUUID(itemID); | ||
541 | |||
542 | string strBuffer = ""; | ||
543 | byte[] buffer = new byte[1]; | ||
544 | try | ||
545 | { | ||
546 | strBuffer = OSDParser.SerializeJsonString(args); | ||
547 | Encoding str = Util.UTF8; | ||
548 | buffer = str.GetBytes(strBuffer); | ||
549 | |||
550 | } | ||
551 | catch (Exception e) | ||
552 | { | ||
553 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message); | ||
554 | // ignore. buffer will be empty, caller should check. | ||
555 | } | ||
556 | |||
557 | Stream os = null; | ||
558 | try | ||
559 | { // send the Post | ||
560 | ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send | ||
561 | os = ObjectCreateRequest.GetRequestStream(); | ||
562 | os.Write(buffer, 0, strBuffer.Length); //Send it | ||
563 | //m_log.InfoFormat("[REST COMMS]: Posted CreateObject request to remote sim {0}", uri); | ||
564 | } | ||
565 | //catch (WebException ex) | ||
566 | catch | ||
567 | { | ||
568 | // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message); | ||
569 | |||
570 | return false; | ||
571 | } | ||
572 | finally | ||
573 | { | ||
574 | if (os != null) | ||
575 | os.Close(); | ||
576 | } | ||
577 | |||
578 | // Let's wait for the response | ||
579 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); | ||
580 | |||
581 | StreamReader sr = null; | ||
582 | try | ||
583 | { | ||
584 | WebResponse webResponse = ObjectCreateRequest.GetResponse(); | ||
585 | if (webResponse == null) | ||
586 | { | ||
587 | m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); | ||
588 | } | ||
589 | |||
590 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
591 | sr.ReadToEnd().Trim(); | ||
592 | sr.ReadToEnd().Trim(); | ||
593 | |||
594 | //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); | ||
595 | |||
596 | } | ||
597 | catch (WebException ex) | ||
598 | { | ||
599 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); | ||
600 | // ignore, really | ||
601 | } | ||
602 | finally | ||
603 | { | ||
604 | if (sr != null) | ||
605 | sr.Close(); | ||
606 | } | ||
607 | |||
608 | return true; | ||
609 | |||
610 | } | ||
611 | |||
612 | public bool DoHelloNeighbourCall(RegionInfo region, RegionInfo thisRegion) | ||
613 | { | ||
614 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/"; | ||
615 | //m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri); | ||
616 | |||
617 | WebRequest HelloNeighbourRequest = WebRequest.Create(uri); | ||
618 | HelloNeighbourRequest.Method = "POST"; | ||
619 | HelloNeighbourRequest.ContentType = "application/json"; | ||
620 | HelloNeighbourRequest.Timeout = 10000; | ||
621 | |||
622 | // Fill it in | ||
623 | OSDMap args = null; | ||
624 | try | ||
625 | { | ||
626 | args = thisRegion.PackRegionInfoData(); | ||
627 | } | ||
628 | catch (Exception e) | ||
629 | { | ||
630 | m_log.Debug("[REST COMMS]: PackRegionInfoData failed with exception: " + e.Message); | ||
631 | } | ||
632 | // Add the regionhandle of the destination region | ||
633 | ulong regionHandle = GetRegionHandle(region.RegionHandle); | ||
634 | args["destination_handle"] = OSD.FromString(regionHandle.ToString()); | ||
635 | |||
636 | string strBuffer = ""; | ||
637 | byte[] buffer = new byte[1]; | ||
638 | try | ||
639 | { | ||
640 | strBuffer = OSDParser.SerializeJsonString(args); | ||
641 | Encoding str = Util.UTF8; | ||
642 | buffer = str.GetBytes(strBuffer); | ||
643 | |||
644 | } | ||
645 | catch (Exception e) | ||
646 | { | ||
647 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of HelloNeighbour: {0}", e.Message); | ||
648 | // ignore. buffer will be empty, caller should check. | ||
649 | } | ||
650 | |||
651 | Stream os = null; | ||
652 | try | ||
653 | { // send the Post | ||
654 | HelloNeighbourRequest.ContentLength = buffer.Length; //Count bytes to send | ||
655 | os = HelloNeighbourRequest.GetRequestStream(); | ||
656 | os.Write(buffer, 0, strBuffer.Length); //Send it | ||
657 | //m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri); | ||
658 | } | ||
659 | //catch (WebException ex) | ||
660 | catch | ||
661 | { | ||
662 | //m_log.InfoFormat("[REST COMMS]: Bad send on HelloNeighbour {0}", ex.Message); | ||
663 | |||
664 | return false; | ||
665 | } | ||
666 | finally | ||
667 | { | ||
668 | if (os != null) | ||
669 | os.Close(); | ||
670 | } | ||
671 | // Let's wait for the response | ||
672 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall"); | ||
673 | |||
674 | StreamReader sr = null; | ||
675 | try | ||
676 | { | ||
677 | WebResponse webResponse = HelloNeighbourRequest.GetResponse(); | ||
678 | if (webResponse == null) | ||
679 | { | ||
680 | m_log.Info("[REST COMMS]: Null reply on DoHelloNeighbourCall post"); | ||
681 | } | ||
682 | |||
683 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
684 | //reply = sr.ReadToEnd().Trim(); | ||
685 | sr.ReadToEnd().Trim(); | ||
686 | //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); | ||
687 | |||
688 | } | ||
689 | catch (WebException ex) | ||
690 | { | ||
691 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoHelloNeighbourCall {0}", ex.Message); | ||
692 | // ignore, really | ||
693 | } | ||
694 | finally | ||
695 | { | ||
696 | if (sr != null) | ||
697 | sr.Close(); | ||
698 | } | ||
699 | |||
700 | return true; | ||
701 | |||
702 | } | ||
703 | |||
704 | #region Hyperlinks | ||
705 | |||
706 | public virtual ulong GetRegionHandle(ulong handle) | ||
707 | { | ||
708 | return handle; | ||
709 | } | ||
710 | |||
711 | public virtual bool IsHyperlink(ulong handle) | ||
712 | { | ||
713 | return false; | ||
714 | } | ||
715 | |||
716 | public virtual void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit) | ||
717 | { | ||
718 | } | ||
719 | |||
720 | public virtual void AdjustUserInformation(AgentCircuitData aCircuit) | ||
721 | { | ||
722 | } | ||
723 | |||
724 | #endregion /* Hyperlinks */ | ||
725 | |||
726 | public static OSDMap GetOSDMap(string data) | ||
727 | { | ||
728 | OSDMap args = null; | ||
729 | try | ||
730 | { | ||
731 | OSD buffer; | ||
732 | // We should pay attention to the content-type, but let's assume we know it's Json | ||
733 | buffer = OSDParser.DeserializeJson(data); | ||
734 | if (buffer.Type == OSDType.Map) | ||
735 | { | ||
736 | args = (OSDMap)buffer; | ||
737 | return args; | ||
738 | } | ||
739 | else | ||
740 | { | ||
741 | // uh? | ||
742 | System.Console.WriteLine("[REST COMMS]: Got OSD of type " + buffer.Type.ToString()); | ||
743 | return null; | ||
744 | } | ||
745 | } | ||
746 | catch (Exception ex) | ||
747 | { | ||
748 | System.Console.WriteLine("[REST COMMS]: exception on parse of REST message " + ex.Message); | ||
749 | return null; | ||
750 | } | ||
751 | } | ||
752 | |||
753 | |||
754 | } | ||
755 | } | ||
diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs deleted file mode 100644 index 4bf9018..0000000 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ /dev/null | |||
@@ -1,264 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework.Communications.Cache; | ||
32 | |||
33 | namespace OpenSim.Framework.Communications | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// This class manages references to OpenSim non-region services (inventory, user, etc.) | ||
37 | /// </summary> | ||
38 | /// | ||
39 | /// TODO: Service retrieval needs to be managed via plugin and interfaces requests, as happens for region | ||
40 | /// modules from scene. Among other things, this will allow this class to be used in many different contexts | ||
41 | /// (from a grid service executable, to provide services on a region) without lots of messy nulls and confusion. | ||
42 | /// Also, a post initialize step on the plugins will be needed so that we don't get tortuous problems with | ||
43 | /// circular dependencies between plugins. | ||
44 | public class CommunicationsManager | ||
45 | { | ||
46 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | protected Dictionary<UUID, string[]> m_nameRequestCache = new Dictionary<UUID, string[]>(); | ||
49 | |||
50 | public IUserService UserService | ||
51 | { | ||
52 | get { return m_userService; } | ||
53 | } | ||
54 | protected IUserService m_userService; | ||
55 | |||
56 | public IMessagingService MessageService | ||
57 | { | ||
58 | get { return m_messageService; } | ||
59 | } | ||
60 | protected IMessagingService m_messageService; | ||
61 | |||
62 | |||
63 | public UserProfileCacheService UserProfileCacheService | ||
64 | { | ||
65 | get { return m_userProfileCacheService; } | ||
66 | } | ||
67 | protected UserProfileCacheService m_userProfileCacheService; | ||
68 | |||
69 | public IAvatarService AvatarService | ||
70 | { | ||
71 | get { return m_avatarService; } | ||
72 | } | ||
73 | protected IAvatarService m_avatarService; | ||
74 | |||
75 | public IInterServiceInventoryServices InterServiceInventoryService | ||
76 | { | ||
77 | get { return m_interServiceInventoryService; } | ||
78 | } | ||
79 | protected IInterServiceInventoryServices m_interServiceInventoryService; | ||
80 | |||
81 | public NetworkServersInfo NetworkServersInfo | ||
82 | { | ||
83 | get { return m_networkServersInfo; } | ||
84 | } | ||
85 | protected NetworkServersInfo m_networkServersInfo; | ||
86 | |||
87 | /// <summary> | ||
88 | /// Interface to user service for administrating users. | ||
89 | /// </summary> | ||
90 | public IUserAdminService UserAdminService | ||
91 | { | ||
92 | get { return m_userAdminService; } | ||
93 | } | ||
94 | protected IUserAdminService m_userAdminService; | ||
95 | |||
96 | /// <summary> | ||
97 | /// Constructor | ||
98 | /// </summary> | ||
99 | /// <param name="serversInfo"></param> | ||
100 | public CommunicationsManager(NetworkServersInfo serversInfo, | ||
101 | LibraryRootFolder libraryRootFolder) | ||
102 | { | ||
103 | m_networkServersInfo = serversInfo; | ||
104 | m_userProfileCacheService = new UserProfileCacheService(this, libraryRootFolder); | ||
105 | } | ||
106 | |||
107 | |||
108 | #region Friend Methods | ||
109 | |||
110 | /// <summary> | ||
111 | /// Adds a new friend to the database for XUser | ||
112 | /// </summary> | ||
113 | /// <param name="friendlistowner">The agent that who's friends list is being added to</param> | ||
114 | /// <param name="friend">The agent that being added to the friends list of the friends list owner</param> | ||
115 | /// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param> | ||
116 | public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) | ||
117 | { | ||
118 | m_userService.AddNewUserFriend(friendlistowner, friend, perms); | ||
119 | } | ||
120 | |||
121 | /// <summary> | ||
122 | /// Logs off a user and does the appropriate communications | ||
123 | /// </summary> | ||
124 | /// <param name="userid"></param> | ||
125 | /// <param name="regionid"></param> | ||
126 | /// <param name="regionhandle"></param> | ||
127 | /// <param name="position"></param> | ||
128 | /// <param name="lookat"></param> | ||
129 | public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) | ||
130 | { | ||
131 | m_userService.LogOffUser(userid, regionid, regionhandle, position, lookat); | ||
132 | } | ||
133 | |||
134 | /// <summary> | ||
135 | /// Logs off a user and does the appropriate communications (deprecated as of 2008-08-27) | ||
136 | /// </summary> | ||
137 | /// <param name="userid"></param> | ||
138 | /// <param name="regionid"></param> | ||
139 | /// <param name="regionhandle"></param> | ||
140 | /// <param name="posx"></param> | ||
141 | /// <param name="posy"></param> | ||
142 | /// <param name="posz"></param> | ||
143 | public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) | ||
144 | { | ||
145 | m_userService.LogOffUser(userid, regionid, regionhandle, posx, posy, posz); | ||
146 | } | ||
147 | |||
148 | /// <summary> | ||
149 | /// Delete friend on friendlistowner's friendlist. | ||
150 | /// </summary> | ||
151 | /// <param name="friendlistowner">The agent that who's friends list is being updated</param> | ||
152 | /// <param name="friend">The Ex-friend agent</param> | ||
153 | public void RemoveUserFriend(UUID friendlistowner, UUID friend) | ||
154 | { | ||
155 | m_userService.RemoveUserFriend(friendlistowner, friend); | ||
156 | } | ||
157 | |||
158 | /// <summary> | ||
159 | /// Update permissions for friend on friendlistowner's friendlist. | ||
160 | /// </summary> | ||
161 | /// <param name="friendlistowner">The agent that who's friends list is being updated</param> | ||
162 | /// <param name="friend">The agent that is getting or loosing permissions</param> | ||
163 | /// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param> | ||
164 | public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) | ||
165 | { | ||
166 | m_userService.UpdateUserFriendPerms(friendlistowner, friend, perms); | ||
167 | } | ||
168 | |||
169 | /// <summary> | ||
170 | /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for UUID friendslistowner | ||
171 | /// </summary> | ||
172 | /// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param> | ||
173 | public List<FriendListItem> GetUserFriendList(UUID friendlistowner) | ||
174 | { | ||
175 | return m_userService.GetUserFriendList(friendlistowner); | ||
176 | } | ||
177 | |||
178 | public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids) | ||
179 | { | ||
180 | return m_messageService.GetFriendRegionInfos(uuids); | ||
181 | } | ||
182 | |||
183 | #endregion | ||
184 | |||
185 | #region Packet Handlers | ||
186 | |||
187 | public void UpdateAvatarPropertiesRequest(IClientAPI remote_client, UserProfileData UserProfile) | ||
188 | { | ||
189 | m_userService.UpdateUserProfile(UserProfile); | ||
190 | return; | ||
191 | } | ||
192 | |||
193 | public void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client) | ||
194 | { | ||
195 | if (uuid == m_userProfileCacheService.LibraryRoot.Owner) | ||
196 | { | ||
197 | remote_client.SendNameReply(uuid, "Mr", "OpenSim"); | ||
198 | } | ||
199 | else | ||
200 | { | ||
201 | string[] names = doUUIDNameRequest(uuid); | ||
202 | if (names.Length == 2) | ||
203 | { | ||
204 | remote_client.SendNameReply(uuid, names[0], names[1]); | ||
205 | } | ||
206 | |||
207 | } | ||
208 | } | ||
209 | |||
210 | private string[] doUUIDNameRequest(UUID uuid) | ||
211 | { | ||
212 | lock (m_nameRequestCache) | ||
213 | { | ||
214 | if (m_nameRequestCache.ContainsKey(uuid)) | ||
215 | return m_nameRequestCache[uuid]; | ||
216 | } | ||
217 | |||
218 | string[] returnstring = new string[0]; | ||
219 | CachedUserInfo uinfo = UserProfileCacheService.GetUserDetails(uuid); | ||
220 | |||
221 | if ((uinfo != null) && (uinfo.UserProfile != null)) | ||
222 | { | ||
223 | returnstring = new string[2]; | ||
224 | returnstring[0] = uinfo.UserProfile.FirstName; | ||
225 | returnstring[1] = uinfo.UserProfile.SurName; | ||
226 | lock (m_nameRequestCache) | ||
227 | { | ||
228 | if (!m_nameRequestCache.ContainsKey(uuid)) | ||
229 | m_nameRequestCache.Add(uuid, returnstring); | ||
230 | } | ||
231 | } | ||
232 | |||
233 | return returnstring; | ||
234 | } | ||
235 | |||
236 | public bool UUIDNameCachedTest(UUID uuid) | ||
237 | { | ||
238 | lock (m_nameRequestCache) | ||
239 | return m_nameRequestCache.ContainsKey(uuid); | ||
240 | } | ||
241 | |||
242 | public string UUIDNameRequestString(UUID uuid) | ||
243 | { | ||
244 | string[] names = doUUIDNameRequest(uuid); | ||
245 | if (names.Length == 2) | ||
246 | { | ||
247 | string firstname = names[0]; | ||
248 | string lastname = names[1]; | ||
249 | |||
250 | return firstname + " " + lastname; | ||
251 | |||
252 | } | ||
253 | return "(hippos)"; | ||
254 | } | ||
255 | |||
256 | public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query) | ||
257 | { | ||
258 | List<AvatarPickerAvatar> pickerlist = m_userService.GenerateAgentPickerRequestResponse(queryID, query); | ||
259 | return pickerlist; | ||
260 | } | ||
261 | |||
262 | #endregion | ||
263 | } | ||
264 | } | ||
diff --git a/OpenSim/Framework/Communications/IAuthentication.cs b/OpenSim/Framework/Communications/IAuthentication.cs deleted file mode 100644 index bd568e4..0000000 --- a/OpenSim/Framework/Communications/IAuthentication.cs +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using OpenMetaverse; | ||
30 | |||
31 | namespace OpenSim.Framework.Communications | ||
32 | { | ||
33 | public interface IAuthentication | ||
34 | { | ||
35 | string GetNewKey(string url, UUID userID, UUID authToken); | ||
36 | bool VerifyKey(UUID userID, string key); | ||
37 | bool VerifySession(UUID iserID, UUID sessionID); | ||
38 | } | ||
39 | } | ||
diff --git a/OpenSim/Framework/Communications/IAvatarService.cs b/OpenSim/Framework/Communications/IAvatarService.cs deleted file mode 100644 index 760aa62..0000000 --- a/OpenSim/Framework/Communications/IAvatarService.cs +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using OpenMetaverse; | ||
29 | |||
30 | namespace OpenSim.Framework.Communications | ||
31 | { | ||
32 | public interface IAvatarService | ||
33 | { | ||
34 | /// <summary> | ||
35 | /// Get avatar appearance information | ||
36 | /// </summary> | ||
37 | /// <param name="user"></param> | ||
38 | /// <returns></returns> | ||
39 | AvatarAppearance GetUserAppearance(UUID user); | ||
40 | |||
41 | /// <summary> | ||
42 | /// Update avatar appearance information | ||
43 | /// </summary> | ||
44 | /// <param name="user"></param> | ||
45 | /// <param name="appearance"></param> | ||
46 | void UpdateUserAppearance(UUID user, AvatarAppearance appearance); | ||
47 | } | ||
48 | } | ||
diff --git a/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs b/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs deleted file mode 100644 index 7f17872..0000000 --- a/OpenSim/Framework/Communications/IInterServiceInventoryServices.cs +++ /dev/null | |||
@@ -1,64 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System.Collections.Generic; | ||
29 | using OpenMetaverse; | ||
30 | |||
31 | namespace OpenSim.Framework.Communications | ||
32 | { | ||
33 | /// <summary> | ||
34 | /// Inventory operations used between grid services. | ||
35 | /// </summary> | ||
36 | public interface IInterServiceInventoryServices | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// Create a new inventory for the given user. | ||
40 | /// </summary> | ||
41 | /// <param name="user"></param> | ||
42 | /// <returns>true if the inventory was successfully created, false otherwise</returns> | ||
43 | bool CreateNewUserInventory(UUID user); | ||
44 | |||
45 | /// <summary> | ||
46 | /// Returns a list of all the folders in a given user's inventory. | ||
47 | /// </summary> | ||
48 | /// <param name="userId"></param> | ||
49 | /// <returns>A flat list of the user's inventory folder tree, | ||
50 | /// null if there is no inventory for this user</returns> | ||
51 | List<InventoryFolderBase> GetInventorySkeleton(UUID userId); | ||
52 | |||
53 | /// <summary> | ||
54 | /// Returns a list of all the active gestures in a user's inventory. | ||
55 | /// </summary> | ||
56 | /// <param name="userId"> | ||
57 | /// The <see cref="UUID"/> of the user | ||
58 | /// </param> | ||
59 | /// <returns> | ||
60 | /// A flat list of the gesture items. | ||
61 | /// </returns> | ||
62 | List<InventoryItemBase> GetActiveGestures(UUID userId); | ||
63 | } | ||
64 | } | ||
diff --git a/OpenSim/Framework/Communications/IUserAdminService.cs b/OpenSim/Framework/Communications/IUserAdminService.cs deleted file mode 100644 index 423b49b..0000000 --- a/OpenSim/Framework/Communications/IUserAdminService.cs +++ /dev/null | |||
@@ -1,71 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using OpenMetaverse; | ||
29 | |||
30 | namespace OpenSim.Framework.Communications | ||
31 | { | ||
32 | /// <summary> | ||
33 | /// Interface for the service for administrating users | ||
34 | /// </summary> | ||
35 | public interface IUserAdminService | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// Add a new user | ||
39 | /// </summary> | ||
40 | /// <param name="firstName">The first name</param> | ||
41 | /// <param name="lastName">The last name</param> | ||
42 | /// <param name="pass">password of avatar</param> | ||
43 | /// <param name="email">email of user</param> | ||
44 | /// <param name="regX">region X</param> | ||
45 | /// <param name="regY">region Y</param> | ||
46 | /// <returns>The UUID of the created user profile. On failure, returns UUID.Zero</returns> | ||
47 | UUID AddUser(string firstName, string lastName, string pass, string email, uint regX, uint regY); | ||
48 | |||
49 | /// <summary> | ||
50 | /// Add a new user with a specified UUID. SHOULD ONLY BE USED in very special circumstances from modules! | ||
51 | /// </summary> | ||
52 | /// <param name="firstName">The first name</param> | ||
53 | /// <param name="lastName">The last name</param> | ||
54 | /// <param name="pass">password of avatar</param> | ||
55 | /// <param name="email">email of user</param> | ||
56 | /// <param name="regX">region X</param> | ||
57 | /// <param name="regY">region Y</param> | ||
58 | /// <param name="setUUID">The set UUID</param> | ||
59 | /// <returns>The UUID of the created user profile. On failure, returns UUID.Zero</returns> | ||
60 | UUID AddUser(string firstName, string lastName, string pass, string email, uint regX, uint regY, UUID setUUID); | ||
61 | |||
62 | /// <summary> | ||
63 | /// Reset a user password | ||
64 | /// </summary> | ||
65 | /// <param name="firstName"></param> | ||
66 | /// <param name="lastName"></param> | ||
67 | /// <param name="newPassword"></param> | ||
68 | /// <returns>true if the update was successful, false otherwise</returns> | ||
69 | bool ResetUserPassword(string firstName, string lastName, string newPassword); | ||
70 | } | ||
71 | } | ||
diff --git a/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs b/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs index e96c5e8..bcd1eee 100644 --- a/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs +++ b/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using OpenSim.Data; | 29 | using OpenSim.Data; |
30 | using OpenMetaverse; | 30 | using OpenMetaverse; |
31 | using OpenSim.Services.Interfaces; | ||
31 | 32 | ||
32 | namespace OpenSim.Framework.Communications.Osp | 33 | namespace OpenSim.Framework.Communications.Osp |
33 | { | 34 | { |
@@ -37,12 +38,13 @@ namespace OpenSim.Framework.Communications.Osp | |||
37 | public class OspInventoryWrapperPlugin : IInventoryDataPlugin | 38 | public class OspInventoryWrapperPlugin : IInventoryDataPlugin |
38 | { | 39 | { |
39 | protected IInventoryDataPlugin m_wrappedPlugin; | 40 | protected IInventoryDataPlugin m_wrappedPlugin; |
40 | protected CommunicationsManager m_commsManager; | 41 | //protected CommunicationsManager m_commsManager; |
42 | protected IUserAccountService m_userAccountService; | ||
41 | 43 | ||
42 | public OspInventoryWrapperPlugin(IInventoryDataPlugin wrappedPlugin, CommunicationsManager commsManager) | 44 | public OspInventoryWrapperPlugin(IInventoryDataPlugin wrappedPlugin, IUserAccountService userService) |
43 | { | 45 | { |
44 | m_wrappedPlugin = wrappedPlugin; | 46 | m_wrappedPlugin = wrappedPlugin; |
45 | m_commsManager = commsManager; | 47 | m_userAccountService = userService; |
46 | } | 48 | } |
47 | 49 | ||
48 | public string Name { get { return "OspInventoryWrapperPlugin"; } } | 50 | public string Name { get { return "OspInventoryWrapperPlugin"; } } |
@@ -81,7 +83,7 @@ namespace OpenSim.Framework.Communications.Osp | |||
81 | 83 | ||
82 | protected InventoryItemBase PostProcessItem(InventoryItemBase item) | 84 | protected InventoryItemBase PostProcessItem(InventoryItemBase item) |
83 | { | 85 | { |
84 | item.CreatorIdAsUuid = OspResolver.ResolveOspa(item.CreatorId, m_commsManager); | 86 | item.CreatorIdAsUuid = OspResolver.ResolveOspa(item.CreatorId, m_userAccountService); |
85 | return item; | 87 | return item; |
86 | } | 88 | } |
87 | 89 | ||
diff --git a/OpenSim/Framework/Communications/Osp/OspResolver.cs b/OpenSim/Framework/Communications/Osp/OspResolver.cs index 4013896..2e55f53 100644 --- a/OpenSim/Framework/Communications/Osp/OspResolver.cs +++ b/OpenSim/Framework/Communications/Osp/OspResolver.cs | |||
@@ -30,7 +30,7 @@ using System.Text; | |||
30 | using log4net; | 30 | using log4net; |
31 | using OpenMetaverse; | 31 | using OpenMetaverse; |
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Framework.Communications.Cache; | 33 | using OpenSim.Services.Interfaces; |
34 | 34 | ||
35 | namespace OpenSim.Framework.Communications.Osp | 35 | namespace OpenSim.Framework.Communications.Osp |
36 | { | 36 | { |
@@ -55,11 +55,11 @@ namespace OpenSim.Framework.Communications.Osp | |||
55 | /// <param name="userId"></param> | 55 | /// <param name="userId"></param> |
56 | /// <param name="commsManager"></param> | 56 | /// <param name="commsManager"></param> |
57 | /// <returns>The OSPA. Null if a user with the given UUID could not be found.</returns> | 57 | /// <returns>The OSPA. Null if a user with the given UUID could not be found.</returns> |
58 | public static string MakeOspa(UUID userId, CommunicationsManager commsManager) | 58 | public static string MakeOspa(UUID userId, IUserAccountService userService) |
59 | { | 59 | { |
60 | CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); | 60 | UserAccount account = userService.GetUserAccount(UUID.Zero, userId); |
61 | if (userInfo != null) | 61 | if (account != null) |
62 | return MakeOspa(userInfo.UserProfile.FirstName, userInfo.UserProfile.SurName); | 62 | return MakeOspa(account.FirstName, account.LastName); |
63 | 63 | ||
64 | return null; | 64 | return null; |
65 | } | 65 | } |
@@ -88,7 +88,7 @@ namespace OpenSim.Framework.Communications.Osp | |||
88 | /// A suitable UUID for use in Second Life client communication. If the string was not a valid ospa, then UUID.Zero | 88 | /// A suitable UUID for use in Second Life client communication. If the string was not a valid ospa, then UUID.Zero |
89 | /// is returned. | 89 | /// is returned. |
90 | /// </returns> | 90 | /// </returns> |
91 | public static UUID ResolveOspa(string ospa, CommunicationsManager commsManager) | 91 | public static UUID ResolveOspa(string ospa, IUserAccountService userService) |
92 | { | 92 | { |
93 | if (!ospa.StartsWith(OSPA_PREFIX)) | 93 | if (!ospa.StartsWith(OSPA_PREFIX)) |
94 | return UUID.Zero; | 94 | return UUID.Zero; |
@@ -112,7 +112,7 @@ namespace OpenSim.Framework.Communications.Osp | |||
112 | string value = tuple.Substring(tupleSeparatorIndex + 1).Trim(); | 112 | string value = tuple.Substring(tupleSeparatorIndex + 1).Trim(); |
113 | 113 | ||
114 | if (OSPA_NAME_KEY == key) | 114 | if (OSPA_NAME_KEY == key) |
115 | return ResolveOspaName(value, commsManager); | 115 | return ResolveOspaName(value, userService); |
116 | } | 116 | } |
117 | 117 | ||
118 | return UUID.Zero; | 118 | return UUID.Zero; |
@@ -137,7 +137,7 @@ namespace OpenSim.Framework.Communications.Osp | |||
137 | /// <returns> | 137 | /// <returns> |
138 | /// An OpenSim internal identifier for the name given. Returns null if the name was not valid | 138 | /// An OpenSim internal identifier for the name given. Returns null if the name was not valid |
139 | /// </returns> | 139 | /// </returns> |
140 | protected static UUID ResolveOspaName(string name, CommunicationsManager commsManager) | 140 | protected static UUID ResolveOspaName(string name, IUserAccountService userService) |
141 | { | 141 | { |
142 | int nameSeparatorIndex = name.IndexOf(OSPA_NAME_VALUE_SEPARATOR); | 142 | int nameSeparatorIndex = name.IndexOf(OSPA_NAME_VALUE_SEPARATOR); |
143 | 143 | ||
@@ -150,9 +150,9 @@ namespace OpenSim.Framework.Communications.Osp | |||
150 | string firstName = name.Remove(nameSeparatorIndex).TrimEnd(); | 150 | string firstName = name.Remove(nameSeparatorIndex).TrimEnd(); |
151 | string lastName = name.Substring(nameSeparatorIndex + 1).TrimStart(); | 151 | string lastName = name.Substring(nameSeparatorIndex + 1).TrimStart(); |
152 | 152 | ||
153 | CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); | 153 | UserAccount account = userService.GetUserAccount(UUID.Zero, firstName, lastName); |
154 | if (userInfo != null) | 154 | if (account != null) |
155 | return userInfo.UserProfile.ID; | 155 | return account.PrincipalID; |
156 | 156 | ||
157 | // XXX: Disable temporary user profile creation for now as implementation is incomplete - justincc | 157 | // XXX: Disable temporary user profile creation for now as implementation is incomplete - justincc |
158 | /* | 158 | /* |
diff --git a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs deleted file mode 100644 index d3f813e..0000000 --- a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs +++ /dev/null | |||
@@ -1,339 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Text.RegularExpressions; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Communications.Cache; | ||
36 | using OpenSim.Framework.Capabilities; | ||
37 | using OpenSim.Framework.Servers; | ||
38 | |||
39 | using OpenMetaverse; | ||
40 | |||
41 | using log4net; | ||
42 | using Nini.Config; | ||
43 | using Nwc.XmlRpc; | ||
44 | |||
45 | namespace OpenSim.Framework.Communications.Services | ||
46 | { | ||
47 | public class HGLoginAuthService : LoginService | ||
48 | { | ||
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
51 | protected NetworkServersInfo m_serversInfo; | ||
52 | protected bool m_authUsers = false; | ||
53 | |||
54 | /// <summary> | ||
55 | /// Used by the login service to make requests to the inventory service. | ||
56 | /// </summary> | ||
57 | protected IInterServiceInventoryServices m_interServiceInventoryService; | ||
58 | |||
59 | /// <summary> | ||
60 | /// Used to make requests to the local regions. | ||
61 | /// </summary> | ||
62 | protected ILoginServiceToRegionsConnector m_regionsConnector; | ||
63 | |||
64 | public HGLoginAuthService( | ||
65 | UserManagerBase userManager, string welcomeMess, | ||
66 | IInterServiceInventoryServices interServiceInventoryService, | ||
67 | NetworkServersInfo serversInfo, | ||
68 | bool authenticate, LibraryRootFolder libraryRootFolder, ILoginServiceToRegionsConnector regionsConnector) | ||
69 | : base(userManager, libraryRootFolder, welcomeMess) | ||
70 | { | ||
71 | this.m_serversInfo = serversInfo; | ||
72 | if (m_serversInfo != null) | ||
73 | { | ||
74 | m_defaultHomeX = this.m_serversInfo.DefaultHomeLocX; | ||
75 | m_defaultHomeY = this.m_serversInfo.DefaultHomeLocY; | ||
76 | } | ||
77 | m_authUsers = authenticate; | ||
78 | |||
79 | m_interServiceInventoryService = interServiceInventoryService; | ||
80 | m_regionsConnector = regionsConnector; | ||
81 | m_interInventoryService = interServiceInventoryService; | ||
82 | } | ||
83 | |||
84 | public void SetServersInfo(NetworkServersInfo sinfo) | ||
85 | { | ||
86 | m_serversInfo = sinfo; | ||
87 | } | ||
88 | |||
89 | public override XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request, IPEndPoint remoteClient) | ||
90 | { | ||
91 | m_log.Info("[HGLOGIN]: HGLogin called " + request.MethodName); | ||
92 | XmlRpcResponse response = base.XmlRpcLoginMethod(request, remoteClient); | ||
93 | Hashtable responseData = (Hashtable)response.Value; | ||
94 | |||
95 | responseData["grid_service"] = m_serversInfo.GridURL; | ||
96 | responseData["grid_service_send_key"] = m_serversInfo.GridSendKey; | ||
97 | responseData["inventory_service"] = m_serversInfo.InventoryURL; | ||
98 | responseData["asset_service"] = m_serversInfo.AssetURL; | ||
99 | responseData["asset_service_send_key"] = m_serversInfo.AssetSendKey; | ||
100 | int x = (Int32)responseData["region_x"]; | ||
101 | int y = (Int32)responseData["region_y"]; | ||
102 | uint ux = (uint)(x / Constants.RegionSize); | ||
103 | uint uy = (uint)(y / Constants.RegionSize); | ||
104 | ulong regionHandle = Util.UIntsToLong(ux, uy); | ||
105 | responseData["region_handle"] = regionHandle.ToString(); | ||
106 | |||
107 | // Let's remove the seed cap from the login | ||
108 | //responseData.Remove("seed_capability"); | ||
109 | |||
110 | // Let's add the appearance | ||
111 | UUID userID = UUID.Zero; | ||
112 | UUID.TryParse((string)responseData["agent_id"], out userID); | ||
113 | AvatarAppearance appearance = m_userManager.GetUserAppearance(userID); | ||
114 | if (appearance == null) | ||
115 | { | ||
116 | m_log.WarnFormat("[INTER]: Appearance not found for {0}. Creating default.", userID); | ||
117 | appearance = new AvatarAppearance(); | ||
118 | } | ||
119 | |||
120 | responseData["appearance"] = appearance.ToHashTable(); | ||
121 | |||
122 | // Let's also send the auth token | ||
123 | UUID token = UUID.Random(); | ||
124 | responseData["auth_token"] = token.ToString(); | ||
125 | UserProfileData userProfile = m_userManager.GetUserProfile(userID); | ||
126 | if (userProfile != null) | ||
127 | { | ||
128 | userProfile.WebLoginKey = token; | ||
129 | m_userManager.CommitAgent(ref userProfile); | ||
130 | } | ||
131 | m_log.Warn("[HGLOGIN]: Auth token: " + token); | ||
132 | |||
133 | |||
134 | return response; | ||
135 | } | ||
136 | |||
137 | public XmlRpcResponse XmlRpcGenerateKeyMethod(XmlRpcRequest request, IPEndPoint remoteClient) | ||
138 | { | ||
139 | // Verify the key of who's calling | ||
140 | UUID userID = UUID.Zero; | ||
141 | UUID authKey = UUID.Zero; | ||
142 | UUID.TryParse((string)request.Params[0], out userID); | ||
143 | UUID.TryParse((string)request.Params[1], out authKey); | ||
144 | |||
145 | m_log.InfoFormat("[HGLOGIN] HGGenerateKey called with authToken ", authKey); | ||
146 | string newKey = string.Empty; | ||
147 | |||
148 | if (!(m_userManager is IAuthentication)) | ||
149 | { | ||
150 | m_log.Debug("[HGLOGIN]: UserManager is not IAuthentication service. Returning empty key."); | ||
151 | } | ||
152 | else | ||
153 | { | ||
154 | newKey = ((IAuthentication)m_userManager).GetNewKey(m_serversInfo.UserURL, userID, authKey); | ||
155 | } | ||
156 | |||
157 | XmlRpcResponse response = new XmlRpcResponse(); | ||
158 | response.Value = (string) newKey; | ||
159 | return response; | ||
160 | } | ||
161 | |||
162 | public XmlRpcResponse XmlRpcVerifyKeyMethod(XmlRpcRequest request, IPEndPoint remoteClient) | ||
163 | { | ||
164 | bool success = false; | ||
165 | |||
166 | if (request.Params.Count >= 2) | ||
167 | { | ||
168 | // Verify the key of who's calling | ||
169 | UUID userID = UUID.Zero; | ||
170 | string authKey = string.Empty; | ||
171 | if (UUID.TryParse((string)request.Params[0], out userID)) | ||
172 | { | ||
173 | authKey = (string)request.Params[1]; | ||
174 | |||
175 | m_log.InfoFormat("[HGLOGIN] HGVerifyKey called with key {0}", authKey); | ||
176 | |||
177 | if (!(m_userManager is IAuthentication)) | ||
178 | { | ||
179 | m_log.Debug("[HGLOGIN]: UserManager is not IAuthentication service. Denying."); | ||
180 | } | ||
181 | else | ||
182 | { | ||
183 | success = ((IAuthentication)m_userManager).VerifyKey(userID, authKey); | ||
184 | } | ||
185 | } | ||
186 | } | ||
187 | |||
188 | m_log.DebugFormat("[HGLOGIN]: Response to VerifyKey is {0}", success); | ||
189 | XmlRpcResponse response = new XmlRpcResponse(); | ||
190 | response.Value = success; | ||
191 | return response; | ||
192 | } | ||
193 | |||
194 | public override UserProfileData GetTheUser(string firstname, string lastname) | ||
195 | { | ||
196 | UserProfileData profile = m_userManager.GetUserProfile(firstname, lastname); | ||
197 | if (profile != null) | ||
198 | { | ||
199 | return profile; | ||
200 | } | ||
201 | |||
202 | if (!m_authUsers) | ||
203 | { | ||
204 | //no current user account so make one | ||
205 | m_log.Info("[LOGIN]: No user account found so creating a new one."); | ||
206 | |||
207 | m_userManager.AddUser(firstname, lastname, "test", "", m_defaultHomeX, m_defaultHomeY); | ||
208 | |||
209 | return m_userManager.GetUserProfile(firstname, lastname); | ||
210 | } | ||
211 | |||
212 | return null; | ||
213 | } | ||
214 | |||
215 | public override bool AuthenticateUser(UserProfileData profile, string password) | ||
216 | { | ||
217 | if (!m_authUsers) | ||
218 | { | ||
219 | //for now we will accept any password in sandbox mode | ||
220 | m_log.Info("[LOGIN]: Authorising user (no actual password check)"); | ||
221 | |||
222 | return true; | ||
223 | } | ||
224 | else | ||
225 | { | ||
226 | m_log.Info( | ||
227 | "[LOGIN]: Authenticating " + profile.FirstName + " " + profile.SurName); | ||
228 | |||
229 | if (!password.StartsWith("$1$")) | ||
230 | password = "$1$" + Util.Md5Hash(password); | ||
231 | |||
232 | password = password.Remove(0, 3); //remove $1$ | ||
233 | |||
234 | string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); | ||
235 | |||
236 | bool loginresult = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) | ||
237 | || profile.PasswordHash.Equals(password, StringComparison.InvariantCulture)); | ||
238 | return loginresult; | ||
239 | } | ||
240 | } | ||
241 | |||
242 | protected override RegionInfo RequestClosestRegion(string region) | ||
243 | { | ||
244 | return m_regionsConnector.RequestClosestRegion(region); | ||
245 | } | ||
246 | |||
247 | protected override RegionInfo GetRegionInfo(ulong homeRegionHandle) | ||
248 | { | ||
249 | return m_regionsConnector.RequestNeighbourInfo(homeRegionHandle); | ||
250 | } | ||
251 | |||
252 | protected override RegionInfo GetRegionInfo(UUID homeRegionId) | ||
253 | { | ||
254 | return m_regionsConnector.RequestNeighbourInfo(homeRegionId); | ||
255 | } | ||
256 | |||
257 | /// <summary> | ||
258 | /// Not really informing the region. Just filling out the response fields related to the region. | ||
259 | /// </summary> | ||
260 | /// <param name="sim"></param> | ||
261 | /// <param name="user"></param> | ||
262 | /// <param name="response"></param> | ||
263 | /// <returns>true if the region was successfully contacted, false otherwise</returns> | ||
264 | protected override bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response, IPEndPoint remoteClient) | ||
265 | { | ||
266 | IPEndPoint endPoint = regionInfo.ExternalEndPoint; | ||
267 | response.SimAddress = endPoint.Address.ToString(); | ||
268 | response.SimPort = (uint)endPoint.Port; | ||
269 | response.RegionX = regionInfo.RegionLocX; | ||
270 | response.RegionY = regionInfo.RegionLocY; | ||
271 | response.SimHttpPort = regionInfo.HttpPort; | ||
272 | |||
273 | string capsPath = CapsUtil.GetRandomCapsObjectPath(); | ||
274 | string capsSeedPath = CapsUtil.GetCapsSeedPath(capsPath); | ||
275 | |||
276 | // Don't use the following! It Fails for logging into any region not on the same port as the http server! | ||
277 | // Kept here so it doesn't happen again! | ||
278 | // response.SeedCapability = regionInfo.ServerURI + capsSeedPath; | ||
279 | |||
280 | string seedcap = "http://"; | ||
281 | |||
282 | if (m_serversInfo.HttpUsesSSL) | ||
283 | { | ||
284 | // For NAT | ||
285 | string host = NetworkUtil.GetHostFor(remoteClient.Address, m_serversInfo.HttpSSLCN); | ||
286 | |||
287 | seedcap = "https://" + host + ":" + m_serversInfo.httpSSLPort + capsSeedPath; | ||
288 | } | ||
289 | else | ||
290 | { | ||
291 | // For NAT | ||
292 | string host = NetworkUtil.GetHostFor(remoteClient.Address, regionInfo.ExternalHostName); | ||
293 | |||
294 | seedcap = "http://" + host + ":" + m_serversInfo.HttpListenerPort + capsSeedPath; | ||
295 | } | ||
296 | |||
297 | response.SeedCapability = seedcap; | ||
298 | |||
299 | // Notify the target of an incoming user | ||
300 | m_log.InfoFormat( | ||
301 | "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection", | ||
302 | regionInfo.RegionName, response.RegionX, response.RegionY, regionInfo.ServerURI); | ||
303 | |||
304 | // Update agent with target sim | ||
305 | user.CurrentAgent.Region = regionInfo.RegionID; | ||
306 | user.CurrentAgent.Handle = regionInfo.RegionHandle; | ||
307 | |||
308 | return true; | ||
309 | } | ||
310 | |||
311 | public override void LogOffUser(UserProfileData theUser, string message) | ||
312 | { | ||
313 | RegionInfo SimInfo; | ||
314 | try | ||
315 | { | ||
316 | SimInfo = this.m_regionsConnector.RequestNeighbourInfo(theUser.CurrentAgent.Handle); | ||
317 | |||
318 | if (SimInfo == null) | ||
319 | { | ||
320 | m_log.Error("[LOCAL LOGIN]: Region user was in isn't currently logged in"); | ||
321 | return; | ||
322 | } | ||
323 | } | ||
324 | catch (Exception) | ||
325 | { | ||
326 | m_log.Error("[LOCAL LOGIN]: Unable to look up region to log user off"); | ||
327 | return; | ||
328 | } | ||
329 | |||
330 | m_regionsConnector.LogOffUserFromGrid(SimInfo.RegionHandle, theUser.ID, theUser.CurrentAgent.SecureSessionID, "Logging you off"); | ||
331 | } | ||
332 | |||
333 | protected override bool AllowLoginWithoutInventory() | ||
334 | { | ||
335 | return true; | ||
336 | } | ||
337 | |||
338 | } | ||
339 | } | ||
diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs deleted file mode 100644 index 824cc57..0000000 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ /dev/null | |||
@@ -1,1241 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.IO; | ||
32 | using System.Net; | ||
33 | using System.Reflection; | ||
34 | using System.Text.RegularExpressions; | ||
35 | using System.Threading; | ||
36 | using System.Web; | ||
37 | using log4net; | ||
38 | using Nwc.XmlRpc; | ||
39 | using OpenMetaverse; | ||
40 | using OpenMetaverse.StructuredData; | ||
41 | using OpenSim.Framework; | ||
42 | using OpenSim.Framework.Communications.Cache; | ||
43 | using OpenSim.Framework.Statistics; | ||
44 | using OpenSim.Services.Interfaces; | ||
45 | |||
46 | namespace OpenSim.Framework.Communications.Services | ||
47 | { | ||
48 | public abstract class LoginService | ||
49 | { | ||
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | |||
52 | protected string m_welcomeMessage = "Welcome to OpenSim"; | ||
53 | protected int m_minLoginLevel = 0; | ||
54 | protected UserManagerBase m_userManager = null; | ||
55 | protected Mutex m_loginMutex = new Mutex(false); | ||
56 | |||
57 | /// <summary> | ||
58 | /// Used during login to send the skeleton of the OpenSim Library to the client. | ||
59 | /// </summary> | ||
60 | protected LibraryRootFolder m_libraryRootFolder; | ||
61 | |||
62 | protected uint m_defaultHomeX; | ||
63 | protected uint m_defaultHomeY; | ||
64 | |||
65 | protected bool m_warn_already_logged = true; | ||
66 | |||
67 | /// <summary> | ||
68 | /// Used by the login service to make requests to the inventory service. | ||
69 | /// </summary> | ||
70 | protected IInterServiceInventoryServices m_interInventoryService; | ||
71 | // Hack | ||
72 | protected IInventoryService m_InventoryService; | ||
73 | |||
74 | /// <summary> | ||
75 | /// Constructor | ||
76 | /// </summary> | ||
77 | /// <param name="userManager"></param> | ||
78 | /// <param name="libraryRootFolder"></param> | ||
79 | /// <param name="welcomeMess"></param> | ||
80 | public LoginService(UserManagerBase userManager, LibraryRootFolder libraryRootFolder, | ||
81 | string welcomeMess) | ||
82 | { | ||
83 | m_userManager = userManager; | ||
84 | m_libraryRootFolder = libraryRootFolder; | ||
85 | |||
86 | if (welcomeMess != String.Empty) | ||
87 | { | ||
88 | m_welcomeMessage = welcomeMess; | ||
89 | } | ||
90 | } | ||
91 | |||
92 | /// <summary> | ||
93 | /// Called when we receive the client's initial XMLRPC login_to_simulator request message | ||
94 | /// </summary> | ||
95 | /// <param name="request">The XMLRPC request</param> | ||
96 | /// <returns>The response to send</returns> | ||
97 | public virtual XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request, IPEndPoint remoteClient) | ||
98 | { | ||
99 | // Temporary fix | ||
100 | m_loginMutex.WaitOne(); | ||
101 | |||
102 | try | ||
103 | { | ||
104 | //CFK: CustomizeResponse contains sufficient strings to alleviate the need for this. | ||
105 | //CKF: m_log.Info("[LOGIN]: Attempting login now..."); | ||
106 | XmlRpcResponse response = new XmlRpcResponse(); | ||
107 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
108 | |||
109 | SniffLoginKey((Uri)request.Params[2], requestData); | ||
110 | |||
111 | bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && | ||
112 | (requestData.Contains("passwd") || requestData.Contains("web_login_key"))); | ||
113 | |||
114 | string startLocationRequest = "last"; | ||
115 | |||
116 | UserProfileData userProfile; | ||
117 | LoginResponse logResponse = new LoginResponse(); | ||
118 | |||
119 | string firstname; | ||
120 | string lastname; | ||
121 | |||
122 | if (GoodXML) | ||
123 | { | ||
124 | if (requestData.Contains("start")) | ||
125 | { | ||
126 | startLocationRequest = (string)requestData["start"]; | ||
127 | } | ||
128 | |||
129 | firstname = (string)requestData["first"]; | ||
130 | lastname = (string)requestData["last"]; | ||
131 | |||
132 | m_log.InfoFormat( | ||
133 | "[LOGIN BEGIN]: XMLRPC Received login request message from user '{0}' '{1}'", | ||
134 | firstname, lastname); | ||
135 | |||
136 | string clientVersion = "Unknown"; | ||
137 | |||
138 | if (requestData.Contains("version")) | ||
139 | { | ||
140 | clientVersion = (string)requestData["version"]; | ||
141 | } | ||
142 | |||
143 | m_log.DebugFormat( | ||
144 | "[LOGIN]: XMLRPC Client is {0}, start location is {1}", clientVersion, startLocationRequest); | ||
145 | |||
146 | if (!TryAuthenticateXmlRpcLogin(request, firstname, lastname, out userProfile)) | ||
147 | { | ||
148 | return logResponse.CreateLoginFailedResponse(); | ||
149 | } | ||
150 | } | ||
151 | else | ||
152 | { | ||
153 | m_log.Info( | ||
154 | "[LOGIN END]: XMLRPC login_to_simulator login message did not contain all the required data"); | ||
155 | |||
156 | return logResponse.CreateGridErrorResponse(); | ||
157 | } | ||
158 | |||
159 | if (userProfile.GodLevel < m_minLoginLevel) | ||
160 | { | ||
161 | return logResponse.CreateLoginBlockedResponse(); | ||
162 | } | ||
163 | else | ||
164 | { | ||
165 | // If we already have a session... | ||
166 | if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.AgentOnline) | ||
167 | { | ||
168 | //TODO: The following statements can cause trouble: | ||
169 | // If agentOnline could not turn from true back to false normally | ||
170 | // because of some problem, for instance, the crashment of server or client, | ||
171 | // the user cannot log in any longer. | ||
172 | userProfile.CurrentAgent.AgentOnline = false; | ||
173 | |||
174 | m_userManager.CommitAgent(ref userProfile); | ||
175 | |||
176 | // try to tell the region that their user is dead. | ||
177 | LogOffUser(userProfile, " XMLRPC You were logged off because you logged in from another location"); | ||
178 | |||
179 | if (m_warn_already_logged) | ||
180 | { | ||
181 | // This is behavior for for grid, reject login | ||
182 | m_log.InfoFormat( | ||
183 | "[LOGIN END]: XMLRPC Notifying user {0} {1} that they are already logged in", | ||
184 | firstname, lastname); | ||
185 | |||
186 | return logResponse.CreateAlreadyLoggedInResponse(); | ||
187 | } | ||
188 | else | ||
189 | { | ||
190 | // This is behavior for standalone (silent logout of last hung session) | ||
191 | m_log.InfoFormat( | ||
192 | "[LOGIN]: XMLRPC User {0} {1} is already logged in, not notifying user, kicking old presence and starting new login.", | ||
193 | firstname, lastname); | ||
194 | } | ||
195 | } | ||
196 | |||
197 | // Otherwise... | ||
198 | // Create a new agent session | ||
199 | |||
200 | // XXYY we don't need this | ||
201 | //m_userManager.ResetAttachments(userProfile.ID); | ||
202 | |||
203 | CreateAgent(userProfile, request); | ||
204 | |||
205 | // We need to commit the agent right here, even though the userProfile info is not complete | ||
206 | // at this point. There is another commit further down. | ||
207 | // This is for the new sessionID to be stored so that the region can check it for session authentication. | ||
208 | // CustomiseResponse->PrepareLoginToRegion | ||
209 | CommitAgent(ref userProfile); | ||
210 | |||
211 | try | ||
212 | { | ||
213 | UUID agentID = userProfile.ID; | ||
214 | InventoryData inventData = null; | ||
215 | |||
216 | try | ||
217 | { | ||
218 | inventData = GetInventorySkeleton(agentID); | ||
219 | } | ||
220 | catch (Exception e) | ||
221 | { | ||
222 | m_log.ErrorFormat( | ||
223 | "[LOGIN END]: Error retrieving inventory skeleton of agent {0} - {1}", | ||
224 | agentID, e); | ||
225 | |||
226 | // Let's not panic | ||
227 | if (!AllowLoginWithoutInventory()) | ||
228 | return logResponse.CreateLoginInventoryFailedResponse(); | ||
229 | } | ||
230 | |||
231 | if (inventData != null) | ||
232 | { | ||
233 | ArrayList AgentInventoryArray = inventData.InventoryArray; | ||
234 | |||
235 | Hashtable InventoryRootHash = new Hashtable(); | ||
236 | InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); | ||
237 | ArrayList InventoryRoot = new ArrayList(); | ||
238 | InventoryRoot.Add(InventoryRootHash); | ||
239 | |||
240 | logResponse.InventoryRoot = InventoryRoot; | ||
241 | logResponse.InventorySkeleton = AgentInventoryArray; | ||
242 | } | ||
243 | |||
244 | // Inventory Library Section | ||
245 | Hashtable InventoryLibRootHash = new Hashtable(); | ||
246 | InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; | ||
247 | ArrayList InventoryLibRoot = new ArrayList(); | ||
248 | InventoryLibRoot.Add(InventoryLibRootHash); | ||
249 | |||
250 | logResponse.InventoryLibRoot = InventoryLibRoot; | ||
251 | logResponse.InventoryLibraryOwner = GetLibraryOwner(); | ||
252 | logResponse.InventoryLibrary = GetInventoryLibrary(); | ||
253 | |||
254 | logResponse.CircuitCode = Util.RandomClass.Next(); | ||
255 | logResponse.Lastname = userProfile.SurName; | ||
256 | logResponse.Firstname = userProfile.FirstName; | ||
257 | logResponse.AgentID = agentID; | ||
258 | logResponse.SessionID = userProfile.CurrentAgent.SessionID; | ||
259 | logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID; | ||
260 | logResponse.Message = GetMessage(); | ||
261 | logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); | ||
262 | logResponse.StartLocation = startLocationRequest; | ||
263 | |||
264 | if (CustomiseResponse(logResponse, userProfile, startLocationRequest, remoteClient)) | ||
265 | { | ||
266 | userProfile.LastLogin = userProfile.CurrentAgent.LoginTime; | ||
267 | CommitAgent(ref userProfile); | ||
268 | |||
269 | // If we reach this point, then the login has successfully logged onto the grid | ||
270 | if (StatsManager.UserStats != null) | ||
271 | StatsManager.UserStats.AddSuccessfulLogin(); | ||
272 | |||
273 | m_log.DebugFormat( | ||
274 | "[LOGIN END]: XMLRPC Authentication of user {0} {1} successful. Sending response to client.", | ||
275 | firstname, lastname); | ||
276 | |||
277 | return logResponse.ToXmlRpcResponse(); | ||
278 | } | ||
279 | else | ||
280 | { | ||
281 | m_log.ErrorFormat("[LOGIN END]: XMLRPC informing user {0} {1} that login failed due to an unavailable region", firstname, lastname); | ||
282 | return logResponse.CreateDeadRegionResponse(); | ||
283 | } | ||
284 | } | ||
285 | catch (Exception e) | ||
286 | { | ||
287 | m_log.Error("[LOGIN END]: XMLRPC Login failed, " + e); | ||
288 | m_log.Error(e.StackTrace); | ||
289 | } | ||
290 | } | ||
291 | |||
292 | m_log.Info("[LOGIN END]: XMLRPC Login failed. Sending back blank XMLRPC response"); | ||
293 | return response; | ||
294 | } | ||
295 | finally | ||
296 | { | ||
297 | m_loginMutex.ReleaseMutex(); | ||
298 | } | ||
299 | } | ||
300 | |||
301 | protected virtual bool TryAuthenticateXmlRpcLogin( | ||
302 | XmlRpcRequest request, string firstname, string lastname, out UserProfileData userProfile) | ||
303 | { | ||
304 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
305 | |||
306 | userProfile = GetTheUser(firstname, lastname); | ||
307 | if (userProfile == null) | ||
308 | { | ||
309 | m_log.Debug("[LOGIN END]: XMLRPC Could not find a profile for " + firstname + " " + lastname); | ||
310 | return false; | ||
311 | } | ||
312 | else | ||
313 | { | ||
314 | if (requestData.Contains("passwd")) | ||
315 | { | ||
316 | string passwd = (string)requestData["passwd"]; | ||
317 | bool authenticated = AuthenticateUser(userProfile, passwd); | ||
318 | |||
319 | if (!authenticated) | ||
320 | m_log.DebugFormat("[LOGIN END]: XMLRPC User {0} {1} failed password authentication", | ||
321 | firstname, lastname); | ||
322 | |||
323 | return authenticated; | ||
324 | } | ||
325 | |||
326 | if (requestData.Contains("web_login_key")) | ||
327 | { | ||
328 | try | ||
329 | { | ||
330 | UUID webloginkey = new UUID((string)requestData["web_login_key"]); | ||
331 | bool authenticated = AuthenticateUser(userProfile, webloginkey); | ||
332 | |||
333 | if (!authenticated) | ||
334 | m_log.DebugFormat("[LOGIN END]: XMLRPC User {0} {1} failed web login key authentication", | ||
335 | firstname, lastname); | ||
336 | |||
337 | return authenticated; | ||
338 | } | ||
339 | catch (Exception e) | ||
340 | { | ||
341 | m_log.DebugFormat( | ||
342 | "[LOGIN END]: XMLRPC Bad web_login_key: {0} for user {1} {2}, exception {3}", | ||
343 | requestData["web_login_key"], firstname, lastname, e); | ||
344 | |||
345 | return false; | ||
346 | } | ||
347 | } | ||
348 | |||
349 | m_log.DebugFormat( | ||
350 | "[LOGIN END]: XMLRPC login request for {0} {1} contained neither a password nor a web login key", | ||
351 | firstname, lastname); | ||
352 | } | ||
353 | |||
354 | return false; | ||
355 | } | ||
356 | |||
357 | protected virtual bool TryAuthenticateLLSDLogin(string firstname, string lastname, string passwd, out UserProfileData userProfile) | ||
358 | { | ||
359 | bool GoodLogin = false; | ||
360 | userProfile = GetTheUser(firstname, lastname); | ||
361 | if (userProfile == null) | ||
362 | { | ||
363 | m_log.Info("[LOGIN]: LLSD Could not find a profile for " + firstname + " " + lastname); | ||
364 | |||
365 | return false; | ||
366 | } | ||
367 | |||
368 | GoodLogin = AuthenticateUser(userProfile, passwd); | ||
369 | return GoodLogin; | ||
370 | } | ||
371 | |||
372 | /// <summary> | ||
373 | /// Called when we receive the client's initial LLSD login_to_simulator request message | ||
374 | /// </summary> | ||
375 | /// <param name="request">The LLSD request</param> | ||
376 | /// <returns>The response to send</returns> | ||
377 | public OSD LLSDLoginMethod(OSD request, IPEndPoint remoteClient) | ||
378 | { | ||
379 | // Temporary fix | ||
380 | m_loginMutex.WaitOne(); | ||
381 | |||
382 | try | ||
383 | { | ||
384 | // bool GoodLogin = false; | ||
385 | |||
386 | string startLocationRequest = "last"; | ||
387 | |||
388 | UserProfileData userProfile = null; | ||
389 | LoginResponse logResponse = new LoginResponse(); | ||
390 | |||
391 | if (request.Type == OSDType.Map) | ||
392 | { | ||
393 | OSDMap map = (OSDMap)request; | ||
394 | |||
395 | if (map.ContainsKey("first") && map.ContainsKey("last") && map.ContainsKey("passwd")) | ||
396 | { | ||
397 | string firstname = map["first"].AsString(); | ||
398 | string lastname = map["last"].AsString(); | ||
399 | string passwd = map["passwd"].AsString(); | ||
400 | |||
401 | if (map.ContainsKey("start")) | ||
402 | { | ||
403 | m_log.Info("[LOGIN]: LLSD StartLocation Requested: " + map["start"].AsString()); | ||
404 | startLocationRequest = map["start"].AsString(); | ||
405 | } | ||
406 | m_log.Info("[LOGIN]: LLSD Login Requested for: '" + firstname + "' '" + lastname + "' / " + passwd); | ||
407 | |||
408 | if (!TryAuthenticateLLSDLogin(firstname, lastname, passwd, out userProfile)) | ||
409 | { | ||
410 | return logResponse.CreateLoginFailedResponseLLSD(); | ||
411 | } | ||
412 | } | ||
413 | else | ||
414 | return logResponse.CreateLoginFailedResponseLLSD(); | ||
415 | } | ||
416 | else | ||
417 | return logResponse.CreateLoginFailedResponseLLSD(); | ||
418 | |||
419 | |||
420 | if (userProfile.GodLevel < m_minLoginLevel) | ||
421 | { | ||
422 | return logResponse.CreateLoginBlockedResponseLLSD(); | ||
423 | } | ||
424 | else | ||
425 | { | ||
426 | // If we already have a session... | ||
427 | if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.AgentOnline) | ||
428 | { | ||
429 | userProfile.CurrentAgent.AgentOnline = false; | ||
430 | |||
431 | m_userManager.CommitAgent(ref userProfile); | ||
432 | // try to tell the region that their user is dead. | ||
433 | LogOffUser(userProfile, " LLSD You were logged off because you logged in from another location"); | ||
434 | |||
435 | if (m_warn_already_logged) | ||
436 | { | ||
437 | // This is behavior for for grid, reject login | ||
438 | m_log.InfoFormat( | ||
439 | "[LOGIN END]: LLSD Notifying user {0} {1} that they are already logged in", | ||
440 | userProfile.FirstName, userProfile.SurName); | ||
441 | |||
442 | userProfile.CurrentAgent = null; | ||
443 | return logResponse.CreateAlreadyLoggedInResponseLLSD(); | ||
444 | } | ||
445 | else | ||
446 | { | ||
447 | // This is behavior for standalone (silent logout of last hung session) | ||
448 | m_log.InfoFormat( | ||
449 | "[LOGIN]: LLSD User {0} {1} is already logged in, not notifying user, kicking old presence and starting new login.", | ||
450 | userProfile.FirstName, userProfile.SurName); | ||
451 | } | ||
452 | } | ||
453 | |||
454 | // Otherwise... | ||
455 | // Create a new agent session | ||
456 | |||
457 | // XXYY We don't need this | ||
458 | //m_userManager.ResetAttachments(userProfile.ID); | ||
459 | |||
460 | CreateAgent(userProfile, request); | ||
461 | |||
462 | // We need to commit the agent right here, even though the userProfile info is not complete | ||
463 | // at this point. There is another commit further down. | ||
464 | // This is for the new sessionID to be stored so that the region can check it for session authentication. | ||
465 | // CustomiseResponse->PrepareLoginToRegion | ||
466 | CommitAgent(ref userProfile); | ||
467 | |||
468 | try | ||
469 | { | ||
470 | UUID agentID = userProfile.ID; | ||
471 | |||
472 | //InventoryData inventData = GetInventorySkeleton(agentID); | ||
473 | InventoryData inventData = null; | ||
474 | |||
475 | try | ||
476 | { | ||
477 | inventData = GetInventorySkeleton(agentID); | ||
478 | } | ||
479 | catch (Exception e) | ||
480 | { | ||
481 | m_log.ErrorFormat( | ||
482 | "[LOGIN END]: LLSD Error retrieving inventory skeleton of agent {0}, {1} - {2}", | ||
483 | agentID, e.GetType(), e.Message); | ||
484 | |||
485 | return logResponse.CreateLoginFailedResponseLLSD();// .CreateLoginInventoryFailedResponseLLSD (); | ||
486 | } | ||
487 | |||
488 | |||
489 | ArrayList AgentInventoryArray = inventData.InventoryArray; | ||
490 | |||
491 | Hashtable InventoryRootHash = new Hashtable(); | ||
492 | InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); | ||
493 | ArrayList InventoryRoot = new ArrayList(); | ||
494 | InventoryRoot.Add(InventoryRootHash); | ||
495 | |||
496 | |||
497 | // Inventory Library Section | ||
498 | Hashtable InventoryLibRootHash = new Hashtable(); | ||
499 | InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; | ||
500 | ArrayList InventoryLibRoot = new ArrayList(); | ||
501 | InventoryLibRoot.Add(InventoryLibRootHash); | ||
502 | |||
503 | logResponse.InventoryLibRoot = InventoryLibRoot; | ||
504 | logResponse.InventoryLibraryOwner = GetLibraryOwner(); | ||
505 | logResponse.InventoryRoot = InventoryRoot; | ||
506 | logResponse.InventorySkeleton = AgentInventoryArray; | ||
507 | logResponse.InventoryLibrary = GetInventoryLibrary(); | ||
508 | |||
509 | logResponse.CircuitCode = (Int32)Util.RandomClass.Next(); | ||
510 | logResponse.Lastname = userProfile.SurName; | ||
511 | logResponse.Firstname = userProfile.FirstName; | ||
512 | logResponse.AgentID = agentID; | ||
513 | logResponse.SessionID = userProfile.CurrentAgent.SessionID; | ||
514 | logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID; | ||
515 | logResponse.Message = GetMessage(); | ||
516 | logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); | ||
517 | logResponse.StartLocation = startLocationRequest; | ||
518 | |||
519 | try | ||
520 | { | ||
521 | CustomiseResponse(logResponse, userProfile, startLocationRequest, remoteClient); | ||
522 | } | ||
523 | catch (Exception ex) | ||
524 | { | ||
525 | m_log.Info("[LOGIN]: LLSD " + ex.ToString()); | ||
526 | return logResponse.CreateDeadRegionResponseLLSD(); | ||
527 | } | ||
528 | |||
529 | userProfile.LastLogin = userProfile.CurrentAgent.LoginTime; | ||
530 | CommitAgent(ref userProfile); | ||
531 | |||
532 | // If we reach this point, then the login has successfully logged onto the grid | ||
533 | if (StatsManager.UserStats != null) | ||
534 | StatsManager.UserStats.AddSuccessfulLogin(); | ||
535 | |||
536 | m_log.DebugFormat( | ||
537 | "[LOGIN END]: LLSD Authentication of user {0} {1} successful. Sending response to client.", | ||
538 | userProfile.FirstName, userProfile.SurName); | ||
539 | |||
540 | return logResponse.ToLLSDResponse(); | ||
541 | } | ||
542 | catch (Exception ex) | ||
543 | { | ||
544 | m_log.Info("[LOGIN]: LLSD " + ex.ToString()); | ||
545 | return logResponse.CreateFailedResponseLLSD(); | ||
546 | } | ||
547 | } | ||
548 | } | ||
549 | finally | ||
550 | { | ||
551 | m_loginMutex.ReleaseMutex(); | ||
552 | } | ||
553 | } | ||
554 | |||
555 | public Hashtable ProcessHTMLLogin(Hashtable keysvals) | ||
556 | { | ||
557 | // Matches all unspecified characters | ||
558 | // Currently specified,; lowercase letters, upper case letters, numbers, underline | ||
559 | // period, space, parens, and dash. | ||
560 | |||
561 | Regex wfcut = new Regex("[^a-zA-Z0-9_\\.\\$ \\(\\)\\-]"); | ||
562 | |||
563 | Hashtable returnactions = new Hashtable(); | ||
564 | int statuscode = 200; | ||
565 | |||
566 | string firstname = String.Empty; | ||
567 | string lastname = String.Empty; | ||
568 | string location = String.Empty; | ||
569 | string region = String.Empty; | ||
570 | string grid = String.Empty; | ||
571 | string channel = String.Empty; | ||
572 | string version = String.Empty; | ||
573 | string lang = String.Empty; | ||
574 | string password = String.Empty; | ||
575 | string errormessages = String.Empty; | ||
576 | |||
577 | // the client requires the HTML form field be named 'username' | ||
578 | // however, the data it sends when it loads the first time is 'firstname' | ||
579 | // another one of those little nuances. | ||
580 | |||
581 | if (keysvals.Contains("firstname")) | ||
582 | firstname = wfcut.Replace((string)keysvals["firstname"], String.Empty, 99999); | ||
583 | |||
584 | if (keysvals.Contains("username")) | ||
585 | firstname = wfcut.Replace((string)keysvals["username"], String.Empty, 99999); | ||
586 | |||
587 | if (keysvals.Contains("lastname")) | ||
588 | lastname = wfcut.Replace((string)keysvals["lastname"], String.Empty, 99999); | ||
589 | |||
590 | if (keysvals.Contains("location")) | ||
591 | location = wfcut.Replace((string)keysvals["location"], String.Empty, 99999); | ||
592 | |||
593 | if (keysvals.Contains("region")) | ||
594 | region = wfcut.Replace((string)keysvals["region"], String.Empty, 99999); | ||
595 | |||
596 | if (keysvals.Contains("grid")) | ||
597 | grid = wfcut.Replace((string)keysvals["grid"], String.Empty, 99999); | ||
598 | |||
599 | if (keysvals.Contains("channel")) | ||
600 | channel = wfcut.Replace((string)keysvals["channel"], String.Empty, 99999); | ||
601 | |||
602 | if (keysvals.Contains("version")) | ||
603 | version = wfcut.Replace((string)keysvals["version"], String.Empty, 99999); | ||
604 | |||
605 | if (keysvals.Contains("lang")) | ||
606 | lang = wfcut.Replace((string)keysvals["lang"], String.Empty, 99999); | ||
607 | |||
608 | if (keysvals.Contains("password")) | ||
609 | password = wfcut.Replace((string)keysvals["password"], String.Empty, 99999); | ||
610 | |||
611 | // load our login form. | ||
612 | string loginform = GetLoginForm(firstname, lastname, location, region, grid, channel, version, lang, password, errormessages); | ||
613 | |||
614 | if (keysvals.ContainsKey("show_login_form")) | ||
615 | { | ||
616 | UserProfileData user = GetTheUser(firstname, lastname); | ||
617 | bool goodweblogin = false; | ||
618 | |||
619 | if (user != null) | ||
620 | goodweblogin = AuthenticateUser(user, password); | ||
621 | |||
622 | if (goodweblogin) | ||
623 | { | ||
624 | UUID webloginkey = UUID.Random(); | ||
625 | m_userManager.StoreWebLoginKey(user.ID, webloginkey); | ||
626 | //statuscode = 301; | ||
627 | |||
628 | // string redirectURL = "about:blank?redirect-http-hack=" + | ||
629 | // HttpUtility.UrlEncode("secondlife:///app/login?first_name=" + firstname + "&last_name=" + | ||
630 | // lastname + | ||
631 | // "&location=" + location + "&grid=Other&web_login_key=" + webloginkey.ToString()); | ||
632 | //m_log.Info("[WEB]: R:" + redirectURL); | ||
633 | returnactions["int_response_code"] = statuscode; | ||
634 | //returnactions["str_redirect_location"] = redirectURL; | ||
635 | //returnactions["str_response_string"] = "<HTML><BODY>GoodLogin</BODY></HTML>"; | ||
636 | returnactions["str_response_string"] = webloginkey.ToString(); | ||
637 | } | ||
638 | else | ||
639 | { | ||
640 | errormessages = "The Username and password supplied did not match our records. Check your caps lock and try again"; | ||
641 | |||
642 | loginform = GetLoginForm(firstname, lastname, location, region, grid, channel, version, lang, password, errormessages); | ||
643 | returnactions["int_response_code"] = statuscode; | ||
644 | returnactions["str_response_string"] = loginform; | ||
645 | } | ||
646 | } | ||
647 | else | ||
648 | { | ||
649 | returnactions["int_response_code"] = statuscode; | ||
650 | returnactions["str_response_string"] = loginform; | ||
651 | } | ||
652 | return returnactions; | ||
653 | } | ||
654 | |||
655 | public string GetLoginForm(string firstname, string lastname, string location, string region, | ||
656 | string grid, string channel, string version, string lang, | ||
657 | string password, string errormessages) | ||
658 | { | ||
659 | // inject our values in the form at the markers | ||
660 | |||
661 | string loginform = String.Empty; | ||
662 | string file = Path.Combine(Util.configDir(), "http_loginform.html"); | ||
663 | if (!File.Exists(file)) | ||
664 | { | ||
665 | loginform = GetDefaultLoginForm(); | ||
666 | } | ||
667 | else | ||
668 | { | ||
669 | StreamReader sr = File.OpenText(file); | ||
670 | loginform = sr.ReadToEnd(); | ||
671 | sr.Close(); | ||
672 | } | ||
673 | |||
674 | loginform = loginform.Replace("[$firstname]", firstname); | ||
675 | loginform = loginform.Replace("[$lastname]", lastname); | ||
676 | loginform = loginform.Replace("[$location]", location); | ||
677 | loginform = loginform.Replace("[$region]", region); | ||
678 | loginform = loginform.Replace("[$grid]", grid); | ||
679 | loginform = loginform.Replace("[$channel]", channel); | ||
680 | loginform = loginform.Replace("[$version]", version); | ||
681 | loginform = loginform.Replace("[$lang]", lang); | ||
682 | loginform = loginform.Replace("[$password]", password); | ||
683 | loginform = loginform.Replace("[$errors]", errormessages); | ||
684 | |||
685 | return loginform; | ||
686 | } | ||
687 | |||
688 | public string GetDefaultLoginForm() | ||
689 | { | ||
690 | string responseString = | ||
691 | "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"; | ||
692 | responseString += "<html xmlns=\"http://www.w3.org/1999/xhtml\">"; | ||
693 | responseString += "<head>"; | ||
694 | responseString += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"; | ||
695 | responseString += "<meta http-equiv=\"cache-control\" content=\"no-cache\">"; | ||
696 | responseString += "<meta http-equiv=\"Pragma\" content=\"no-cache\">"; | ||
697 | responseString += "<title>OpenSim Login</title>"; | ||
698 | responseString += "<body><br />"; | ||
699 | responseString += "<div id=\"login_box\">"; | ||
700 | |||
701 | responseString += "<form action=\"/go.cgi\" method=\"GET\" id=\"login-form\">"; | ||
702 | |||
703 | responseString += "<div id=\"message\">[$errors]</div>"; | ||
704 | responseString += "<fieldset id=\"firstname\">"; | ||
705 | responseString += "<legend>First Name:</legend>"; | ||
706 | responseString += "<input type=\"text\" id=\"firstname_input\" size=\"15\" maxlength=\"100\" name=\"username\" value=\"[$firstname]\" />"; | ||
707 | responseString += "</fieldset>"; | ||
708 | responseString += "<fieldset id=\"lastname\">"; | ||
709 | responseString += "<legend>Last Name:</legend>"; | ||
710 | responseString += "<input type=\"text\" size=\"15\" maxlength=\"100\" name=\"lastname\" value=\"[$lastname]\" />"; | ||
711 | responseString += "</fieldset>"; | ||
712 | responseString += "<fieldset id=\"password\">"; | ||
713 | responseString += "<legend>Password:</legend>"; | ||
714 | responseString += "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">"; | ||
715 | responseString += "<tr>"; | ||
716 | responseString += "<td colspan=\"2\"><input type=\"password\" size=\"15\" maxlength=\"100\" name=\"password\" value=\"[$password]\" /></td>"; | ||
717 | responseString += "</tr>"; | ||
718 | responseString += "<tr>"; | ||
719 | responseString += "<td valign=\"middle\"><input type=\"checkbox\" name=\"remember_password\" id=\"remember_password\" [$remember_password] style=\"margin-left:0px;\"/></td>"; | ||
720 | responseString += "<td><label for=\"remember_password\">Remember password</label></td>"; | ||
721 | responseString += "</tr>"; | ||
722 | responseString += "</table>"; | ||
723 | responseString += "</fieldset>"; | ||
724 | responseString += "<input type=\"hidden\" name=\"show_login_form\" value=\"FALSE\" />"; | ||
725 | responseString += "<input type=\"hidden\" name=\"method\" value=\"login\" />"; | ||
726 | responseString += "<input type=\"hidden\" id=\"grid\" name=\"grid\" value=\"[$grid]\" />"; | ||
727 | responseString += "<input type=\"hidden\" id=\"region\" name=\"region\" value=\"[$region]\" />"; | ||
728 | responseString += "<input type=\"hidden\" id=\"location\" name=\"location\" value=\"[$location]\" />"; | ||
729 | responseString += "<input type=\"hidden\" id=\"channel\" name=\"channel\" value=\"[$channel]\" />"; | ||
730 | responseString += "<input type=\"hidden\" id=\"version\" name=\"version\" value=\"[$version]\" />"; | ||
731 | responseString += "<input type=\"hidden\" id=\"lang\" name=\"lang\" value=\"[$lang]\" />"; | ||
732 | responseString += "<div id=\"submitbtn\">"; | ||
733 | responseString += "<input class=\"input_over\" type=\"submit\" value=\"Connect\" />"; | ||
734 | responseString += "</div>"; | ||
735 | responseString += "<div id=\"connecting\" style=\"visibility:hidden\"> Connecting...</div>"; | ||
736 | |||
737 | responseString += "<div id=\"helplinks\"><!---"; | ||
738 | responseString += "<a href=\"#join now link\" target=\"_blank\"></a> | "; | ||
739 | responseString += "<a href=\"#forgot password link\" target=\"_blank\"></a>"; | ||
740 | responseString += "---></div>"; | ||
741 | |||
742 | responseString += "<div id=\"channelinfo\"> [$channel] | [$version]=[$lang]</div>"; | ||
743 | responseString += "</form>"; | ||
744 | responseString += "<script language=\"JavaScript\">"; | ||
745 | responseString += "document.getElementById('firstname_input').focus();"; | ||
746 | responseString += "</script>"; | ||
747 | responseString += "</div>"; | ||
748 | responseString += "</div>"; | ||
749 | responseString += "</body>"; | ||
750 | responseString += "</html>"; | ||
751 | |||
752 | return responseString; | ||
753 | } | ||
754 | |||
755 | /// <summary> | ||
756 | /// Saves a target agent to the database | ||
757 | /// </summary> | ||
758 | /// <param name="profile">The users profile</param> | ||
759 | /// <returns>Successful?</returns> | ||
760 | public bool CommitAgent(ref UserProfileData profile) | ||
761 | { | ||
762 | return m_userManager.CommitAgent(ref profile); | ||
763 | } | ||
764 | |||
765 | /// <summary> | ||
766 | /// Checks a user against it's password hash | ||
767 | /// </summary> | ||
768 | /// <param name="profile">The users profile</param> | ||
769 | /// <param name="password">The supplied password</param> | ||
770 | /// <returns>Authenticated?</returns> | ||
771 | public virtual bool AuthenticateUser(UserProfileData profile, string password) | ||
772 | { | ||
773 | bool passwordSuccess = false; | ||
774 | //m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.ID); | ||
775 | |||
776 | // Web Login method seems to also occasionally send the hashed password itself | ||
777 | |||
778 | // we do this to get our hash in a form that the server password code can consume | ||
779 | // when the web-login-form submits the password in the clear (supposed to be over SSL!) | ||
780 | if (!password.StartsWith("$1$")) | ||
781 | password = "$1$" + Util.Md5Hash(password); | ||
782 | |||
783 | password = password.Remove(0, 3); //remove $1$ | ||
784 | |||
785 | string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); | ||
786 | // Testing... | ||
787 | //m_log.Info("[LOGIN]: SubHash:" + s + " userprofile:" + profile.passwordHash); | ||
788 | //m_log.Info("[LOGIN]: userprofile:" + profile.passwordHash + " SubCT:" + password); | ||
789 | |||
790 | passwordSuccess = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) | ||
791 | || profile.PasswordHash.Equals(password, StringComparison.InvariantCulture)); | ||
792 | |||
793 | return passwordSuccess; | ||
794 | } | ||
795 | |||
796 | public virtual bool AuthenticateUser(UserProfileData profile, UUID webloginkey) | ||
797 | { | ||
798 | bool passwordSuccess = false; | ||
799 | m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.ID); | ||
800 | |||
801 | // Match web login key unless it's the default weblogin key UUID.Zero | ||
802 | passwordSuccess = ((profile.WebLoginKey == webloginkey) && profile.WebLoginKey != UUID.Zero); | ||
803 | |||
804 | return passwordSuccess; | ||
805 | } | ||
806 | |||
807 | /// <summary> | ||
808 | /// | ||
809 | /// </summary> | ||
810 | /// <param name="profile"></param> | ||
811 | /// <param name="request"></param> | ||
812 | public void CreateAgent(UserProfileData profile, XmlRpcRequest request) | ||
813 | { | ||
814 | m_userManager.CreateAgent(profile, request); | ||
815 | } | ||
816 | |||
817 | public void CreateAgent(UserProfileData profile, OSD request) | ||
818 | { | ||
819 | m_userManager.CreateAgent(profile, request); | ||
820 | } | ||
821 | |||
822 | /// <summary> | ||
823 | /// | ||
824 | /// </summary> | ||
825 | /// <param name="firstname"></param> | ||
826 | /// <param name="lastname"></param> | ||
827 | /// <returns></returns> | ||
828 | public virtual UserProfileData GetTheUser(string firstname, string lastname) | ||
829 | { | ||
830 | return m_userManager.GetUserProfile(firstname, lastname); | ||
831 | } | ||
832 | |||
833 | /// <summary> | ||
834 | /// | ||
835 | /// </summary> | ||
836 | /// <returns></returns> | ||
837 | public virtual string GetMessage() | ||
838 | { | ||
839 | return m_welcomeMessage; | ||
840 | } | ||
841 | |||
842 | private static LoginResponse.BuddyList ConvertFriendListItem(List<FriendListItem> LFL) | ||
843 | { | ||
844 | LoginResponse.BuddyList buddylistreturn = new LoginResponse.BuddyList(); | ||
845 | foreach (FriendListItem fl in LFL) | ||
846 | { | ||
847 | LoginResponse.BuddyList.BuddyInfo buddyitem = new LoginResponse.BuddyList.BuddyInfo(fl.Friend); | ||
848 | buddyitem.BuddyID = fl.Friend; | ||
849 | buddyitem.BuddyRightsHave = (int)fl.FriendListOwnerPerms; | ||
850 | buddyitem.BuddyRightsGiven = (int)fl.FriendPerms; | ||
851 | buddylistreturn.AddNewBuddy(buddyitem); | ||
852 | } | ||
853 | return buddylistreturn; | ||
854 | } | ||
855 | |||
856 | /// <summary> | ||
857 | /// Converts the inventory library skeleton into the form required by the rpc request. | ||
858 | /// </summary> | ||
859 | /// <returns></returns> | ||
860 | protected virtual ArrayList GetInventoryLibrary() | ||
861 | { | ||
862 | Dictionary<UUID, InventoryFolderImpl> rootFolders | ||
863 | = m_libraryRootFolder.RequestSelfAndDescendentFolders(); | ||
864 | ArrayList folderHashes = new ArrayList(); | ||
865 | |||
866 | foreach (InventoryFolderBase folder in rootFolders.Values) | ||
867 | { | ||
868 | Hashtable TempHash = new Hashtable(); | ||
869 | TempHash["name"] = folder.Name; | ||
870 | TempHash["parent_id"] = folder.ParentID.ToString(); | ||
871 | TempHash["version"] = (Int32)folder.Version; | ||
872 | TempHash["type_default"] = (Int32)folder.Type; | ||
873 | TempHash["folder_id"] = folder.ID.ToString(); | ||
874 | folderHashes.Add(TempHash); | ||
875 | } | ||
876 | |||
877 | return folderHashes; | ||
878 | } | ||
879 | |||
880 | /// <summary> | ||
881 | /// | ||
882 | /// </summary> | ||
883 | /// <returns></returns> | ||
884 | protected virtual ArrayList GetLibraryOwner() | ||
885 | { | ||
886 | //for now create random inventory library owner | ||
887 | Hashtable TempHash = new Hashtable(); | ||
888 | TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; | ||
889 | ArrayList inventoryLibOwner = new ArrayList(); | ||
890 | inventoryLibOwner.Add(TempHash); | ||
891 | return inventoryLibOwner; | ||
892 | } | ||
893 | |||
894 | public class InventoryData | ||
895 | { | ||
896 | public ArrayList InventoryArray = null; | ||
897 | public UUID RootFolderID = UUID.Zero; | ||
898 | |||
899 | public InventoryData(ArrayList invList, UUID rootID) | ||
900 | { | ||
901 | InventoryArray = invList; | ||
902 | RootFolderID = rootID; | ||
903 | } | ||
904 | } | ||
905 | |||
906 | protected void SniffLoginKey(Uri uri, Hashtable requestData) | ||
907 | { | ||
908 | string uri_str = uri.ToString(); | ||
909 | string[] parts = uri_str.Split(new char[] { '=' }); | ||
910 | if (parts.Length > 1) | ||
911 | { | ||
912 | string web_login_key = parts[1]; | ||
913 | requestData.Add("web_login_key", web_login_key); | ||
914 | m_log.InfoFormat("[LOGIN]: Login with web_login_key {0}", web_login_key); | ||
915 | } | ||
916 | } | ||
917 | |||
918 | /// <summary> | ||
919 | /// Customises the login response and fills in missing values. This method also tells the login region to | ||
920 | /// expect a client connection. | ||
921 | /// </summary> | ||
922 | /// <param name="response">The existing response</param> | ||
923 | /// <param name="theUser">The user profile</param> | ||
924 | /// <param name="startLocationRequest">The requested start location</param> | ||
925 | /// <returns>true on success, false if the region was not successfully told to expect a user connection</returns> | ||
926 | public bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest, IPEndPoint client) | ||
927 | { | ||
928 | // add active gestures to login-response | ||
929 | AddActiveGestures(response, theUser); | ||
930 | |||
931 | // HomeLocation | ||
932 | RegionInfo homeInfo = null; | ||
933 | |||
934 | // use the homeRegionID if it is stored already. If not, use the regionHandle as before | ||
935 | UUID homeRegionId = theUser.HomeRegionID; | ||
936 | ulong homeRegionHandle = theUser.HomeRegion; | ||
937 | if (homeRegionId != UUID.Zero) | ||
938 | { | ||
939 | homeInfo = GetRegionInfo(homeRegionId); | ||
940 | } | ||
941 | else | ||
942 | { | ||
943 | homeInfo = GetRegionInfo(homeRegionHandle); | ||
944 | } | ||
945 | |||
946 | if (homeInfo != null) | ||
947 | { | ||
948 | response.Home = | ||
949 | string.Format( | ||
950 | "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", | ||
951 | (homeInfo.RegionLocX * Constants.RegionSize), | ||
952 | (homeInfo.RegionLocY * Constants.RegionSize), | ||
953 | theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, | ||
954 | theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); | ||
955 | } | ||
956 | else | ||
957 | { | ||
958 | m_log.InfoFormat("not found the region at {0} {1}", theUser.HomeRegionX, theUser.HomeRegionY); | ||
959 | // Emergency mode: Home-region isn't available, so we can't request the region info. | ||
960 | // Use the stored home regionHandle instead. | ||
961 | // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again | ||
962 | ulong regionX = homeRegionHandle >> 32; | ||
963 | ulong regionY = homeRegionHandle & 0xffffffff; | ||
964 | response.Home = | ||
965 | string.Format( | ||
966 | "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", | ||
967 | regionX, regionY, | ||
968 | theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, | ||
969 | theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); | ||
970 | |||
971 | m_log.InfoFormat("[LOGIN] Home region of user {0} {1} is not available; using computed region position {2} {3}", | ||
972 | theUser.FirstName, theUser.SurName, | ||
973 | regionX, regionY); | ||
974 | } | ||
975 | |||
976 | // StartLocation | ||
977 | RegionInfo regionInfo = null; | ||
978 | if (startLocationRequest == "home") | ||
979 | { | ||
980 | regionInfo = homeInfo; | ||
981 | theUser.CurrentAgent.Position = theUser.HomeLocation; | ||
982 | response.LookAt = String.Format("[r{0},r{1},r{2}]", theUser.HomeLookAt.X.ToString(), | ||
983 | theUser.HomeLookAt.Y.ToString(), theUser.HomeLookAt.Z.ToString()); | ||
984 | } | ||
985 | else if (startLocationRequest == "last") | ||
986 | { | ||
987 | UUID lastRegion = theUser.CurrentAgent.Region; | ||
988 | regionInfo = GetRegionInfo(lastRegion); | ||
989 | response.LookAt = String.Format("[r{0},r{1},r{2}]", theUser.CurrentAgent.LookAt.X.ToString(), | ||
990 | theUser.CurrentAgent.LookAt.Y.ToString(), theUser.CurrentAgent.LookAt.Z.ToString()); | ||
991 | } | ||
992 | else | ||
993 | { | ||
994 | Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$"); | ||
995 | Match uriMatch = reURI.Match(startLocationRequest); | ||
996 | if (uriMatch == null) | ||
997 | { | ||
998 | m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, but can't process it", startLocationRequest); | ||
999 | } | ||
1000 | else | ||
1001 | { | ||
1002 | string region = uriMatch.Groups["region"].ToString(); | ||
1003 | regionInfo = RequestClosestRegion(region); | ||
1004 | if (regionInfo == null) | ||
1005 | { | ||
1006 | m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, can't locate region {1}", startLocationRequest, region); | ||
1007 | } | ||
1008 | else | ||
1009 | { | ||
1010 | theUser.CurrentAgent.Position = new Vector3(float.Parse(uriMatch.Groups["x"].Value, Culture.NumberFormatInfo), | ||
1011 | float.Parse(uriMatch.Groups["y"].Value, Culture.NumberFormatInfo), float.Parse(uriMatch.Groups["z"].Value, Culture.NumberFormatInfo)); | ||
1012 | } | ||
1013 | } | ||
1014 | response.LookAt = "[r0,r1,r0]"; | ||
1015 | // can be: last, home, safe, url | ||
1016 | response.StartLocation = "url"; | ||
1017 | } | ||
1018 | |||
1019 | if ((regionInfo != null) && (PrepareLoginToRegion(regionInfo, theUser, response, client))) | ||
1020 | { | ||
1021 | return true; | ||
1022 | } | ||
1023 | |||
1024 | // Get the default region handle | ||
1025 | ulong defaultHandle = Utils.UIntsToLong(m_defaultHomeX * Constants.RegionSize, m_defaultHomeY * Constants.RegionSize); | ||
1026 | |||
1027 | // If we haven't already tried the default region, reset regionInfo | ||
1028 | if (regionInfo != null && defaultHandle != regionInfo.RegionHandle) | ||
1029 | regionInfo = null; | ||
1030 | |||
1031 | if (regionInfo == null) | ||
1032 | { | ||
1033 | m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); | ||
1034 | regionInfo = GetRegionInfo(defaultHandle); | ||
1035 | } | ||
1036 | |||
1037 | if (regionInfo == null) | ||
1038 | { | ||
1039 | m_log.ErrorFormat("[LOGIN]: Sending user to any region"); | ||
1040 | regionInfo = RequestClosestRegion(String.Empty); | ||
1041 | } | ||
1042 | |||
1043 | theUser.CurrentAgent.Position = new Vector3(128f, 128f, 0f); | ||
1044 | response.StartLocation = "safe"; | ||
1045 | |||
1046 | return PrepareLoginToRegion(regionInfo, theUser, response, client); | ||
1047 | } | ||
1048 | |||
1049 | protected abstract RegionInfo RequestClosestRegion(string region); | ||
1050 | protected abstract RegionInfo GetRegionInfo(ulong homeRegionHandle); | ||
1051 | protected abstract RegionInfo GetRegionInfo(UUID homeRegionId); | ||
1052 | |||
1053 | /// <summary> | ||
1054 | /// If the user is already logged in, try to notify the region that the user they've got is dead. | ||
1055 | /// </summary> | ||
1056 | /// <param name="theUser"></param> | ||
1057 | public abstract void LogOffUser(UserProfileData theUser, string message); | ||
1058 | |||
1059 | /// <summary> | ||
1060 | /// Prepare a login to the given region. This involves both telling the region to expect a connection | ||
1061 | /// and appropriately customising the response to the user. | ||
1062 | /// </summary> | ||
1063 | /// <param name="sim"></param> | ||
1064 | /// <param name="user"></param> | ||
1065 | /// <param name="response"></param> | ||
1066 | /// <param name="remoteClient"></param> | ||
1067 | /// <returns>true if the region was successfully contacted, false otherwise</returns> | ||
1068 | protected abstract bool PrepareLoginToRegion( | ||
1069 | RegionInfo regionInfo, UserProfileData user, LoginResponse response, IPEndPoint client); | ||
1070 | |||
1071 | /// <summary> | ||
1072 | /// Add active gestures of the user to the login response. | ||
1073 | /// </summary> | ||
1074 | /// <param name="response"> | ||
1075 | /// A <see cref="LoginResponse"/> | ||
1076 | /// </param> | ||
1077 | /// <param name="theUser"> | ||
1078 | /// A <see cref="UserProfileData"/> | ||
1079 | /// </param> | ||
1080 | protected void AddActiveGestures(LoginResponse response, UserProfileData theUser) | ||
1081 | { | ||
1082 | List<InventoryItemBase> gestures = null; | ||
1083 | try | ||
1084 | { | ||
1085 | if (m_InventoryService != null) | ||
1086 | gestures = m_InventoryService.GetActiveGestures(theUser.ID); | ||
1087 | else | ||
1088 | gestures = m_interInventoryService.GetActiveGestures(theUser.ID); | ||
1089 | } | ||
1090 | catch (Exception e) | ||
1091 | { | ||
1092 | m_log.Debug("[LOGIN]: Unable to retrieve active gestures from inventory server. Reason: " + e.Message); | ||
1093 | } | ||
1094 | //m_log.DebugFormat("[LOGIN]: AddActiveGestures, found {0}", gestures == null ? 0 : gestures.Count); | ||
1095 | ArrayList list = new ArrayList(); | ||
1096 | if (gestures != null) | ||
1097 | { | ||
1098 | foreach (InventoryItemBase gesture in gestures) | ||
1099 | { | ||
1100 | Hashtable item = new Hashtable(); | ||
1101 | item["item_id"] = gesture.ID.ToString(); | ||
1102 | item["asset_id"] = gesture.AssetID.ToString(); | ||
1103 | list.Add(item); | ||
1104 | } | ||
1105 | } | ||
1106 | response.ActiveGestures = list; | ||
1107 | } | ||
1108 | |||
1109 | /// <summary> | ||
1110 | /// Get the initial login inventory skeleton (in other words, the folder structure) for the given user. | ||
1111 | /// </summary> | ||
1112 | /// <param name="userID"></param> | ||
1113 | /// <returns></returns> | ||
1114 | /// <exception cref='System.Exception'>This will be thrown if there is a problem with the inventory service</exception> | ||
1115 | protected InventoryData GetInventorySkeleton(UUID userID) | ||
1116 | { | ||
1117 | List<InventoryFolderBase> folders = null; | ||
1118 | if (m_InventoryService != null) | ||
1119 | { | ||
1120 | folders = m_InventoryService.GetInventorySkeleton(userID); | ||
1121 | } | ||
1122 | else | ||
1123 | { | ||
1124 | folders = m_interInventoryService.GetInventorySkeleton(userID); | ||
1125 | } | ||
1126 | |||
1127 | // If we have user auth but no inventory folders for some reason, create a new set of folders. | ||
1128 | if (folders == null || folders.Count == 0) | ||
1129 | { | ||
1130 | m_log.InfoFormat( | ||
1131 | "[LOGIN]: A root inventory folder for user {0} was not found. Requesting creation.", userID); | ||
1132 | |||
1133 | // Although the create user function creates a new agent inventory along with a new user profile, some | ||
1134 | // tools are creating the user profile directly in the database without creating the inventory. At | ||
1135 | // this time we'll accomodate them by lazily creating the user inventory now if it doesn't already | ||
1136 | // exist. | ||
1137 | if (m_interInventoryService != null) | ||
1138 | { | ||
1139 | if (!m_interInventoryService.CreateNewUserInventory(userID)) | ||
1140 | { | ||
1141 | throw new Exception( | ||
1142 | String.Format( | ||
1143 | "The inventory creation request for user {0} did not succeed." | ||
1144 | + " Please contact your inventory service provider for more information.", | ||
1145 | userID)); | ||
1146 | } | ||
1147 | } | ||
1148 | else if ((m_InventoryService != null) && !m_InventoryService.CreateUserInventory(userID)) | ||
1149 | { | ||
1150 | throw new Exception( | ||
1151 | String.Format( | ||
1152 | "The inventory creation request for user {0} did not succeed." | ||
1153 | + " Please contact your inventory service provider for more information.", | ||
1154 | userID)); | ||
1155 | } | ||
1156 | |||
1157 | |||
1158 | m_log.InfoFormat("[LOGIN]: A new inventory skeleton was successfully created for user {0}", userID); | ||
1159 | |||
1160 | if (m_InventoryService != null) | ||
1161 | folders = m_InventoryService.GetInventorySkeleton(userID); | ||
1162 | else | ||
1163 | folders = m_interInventoryService.GetInventorySkeleton(userID); | ||
1164 | |||
1165 | if (folders == null || folders.Count == 0) | ||
1166 | { | ||
1167 | throw new Exception( | ||
1168 | String.Format( | ||
1169 | "A root inventory folder for user {0} could not be retrieved from the inventory service", | ||
1170 | userID)); | ||
1171 | } | ||
1172 | } | ||
1173 | |||
1174 | UUID rootID = UUID.Zero; | ||
1175 | ArrayList AgentInventoryArray = new ArrayList(); | ||
1176 | Hashtable TempHash; | ||
1177 | foreach (InventoryFolderBase InvFolder in folders) | ||
1178 | { | ||
1179 | if (InvFolder.ParentID == UUID.Zero) | ||
1180 | { | ||
1181 | rootID = InvFolder.ID; | ||
1182 | } | ||
1183 | TempHash = new Hashtable(); | ||
1184 | TempHash["name"] = InvFolder.Name; | ||
1185 | TempHash["parent_id"] = InvFolder.ParentID.ToString(); | ||
1186 | TempHash["version"] = (Int32)InvFolder.Version; | ||
1187 | TempHash["type_default"] = (Int32)InvFolder.Type; | ||
1188 | TempHash["folder_id"] = InvFolder.ID.ToString(); | ||
1189 | AgentInventoryArray.Add(TempHash); | ||
1190 | } | ||
1191 | |||
1192 | return new InventoryData(AgentInventoryArray, rootID); | ||
1193 | } | ||
1194 | |||
1195 | protected virtual bool AllowLoginWithoutInventory() | ||
1196 | { | ||
1197 | return false; | ||
1198 | } | ||
1199 | |||
1200 | public XmlRpcResponse XmlRPCCheckAuthSession(XmlRpcRequest request, IPEndPoint remoteClient) | ||
1201 | { | ||
1202 | XmlRpcResponse response = new XmlRpcResponse(); | ||
1203 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
1204 | |||
1205 | string authed = "FALSE"; | ||
1206 | if (requestData.Contains("avatar_uuid") && requestData.Contains("session_id")) | ||
1207 | { | ||
1208 | UUID guess_aid; | ||
1209 | UUID guess_sid; | ||
1210 | |||
1211 | UUID.TryParse((string)requestData["avatar_uuid"], out guess_aid); | ||
1212 | if (guess_aid == UUID.Zero) | ||
1213 | { | ||
1214 | return Util.CreateUnknownUserErrorResponse(); | ||
1215 | } | ||
1216 | |||
1217 | UUID.TryParse((string)requestData["session_id"], out guess_sid); | ||
1218 | if (guess_sid == UUID.Zero) | ||
1219 | { | ||
1220 | return Util.CreateUnknownUserErrorResponse(); | ||
1221 | } | ||
1222 | |||
1223 | if (m_userManager.VerifySession(guess_aid, guess_sid)) | ||
1224 | { | ||
1225 | authed = "TRUE"; | ||
1226 | m_log.InfoFormat("[UserManager]: CheckAuthSession TRUE for user {0}", guess_aid); | ||
1227 | } | ||
1228 | else | ||
1229 | { | ||
1230 | m_log.InfoFormat("[UserManager]: CheckAuthSession FALSE"); | ||
1231 | return Util.CreateUnknownUserErrorResponse(); | ||
1232 | } | ||
1233 | } | ||
1234 | |||
1235 | Hashtable responseData = new Hashtable(); | ||
1236 | responseData["auth_session"] = authed; | ||
1237 | response.Value = responseData; | ||
1238 | return response; | ||
1239 | } | ||
1240 | } | ||
1241 | } \ No newline at end of file | ||
diff --git a/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs b/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs deleted file mode 100644 index 2413055..0000000 --- a/OpenSim/Framework/Communications/TemporaryUserProfilePlugin.cs +++ /dev/null | |||
@@ -1,104 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Data; | ||
34 | |||
35 | namespace OpenSim.Framework.Communications | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// Plugin for managing temporary user profiles. | ||
39 | /// </summary> | ||
40 | public class TemporaryUserProfilePlugin : IUserDataPlugin | ||
41 | { | ||
42 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | protected Dictionary<UUID, UserProfileData> m_profiles = new Dictionary<UUID, UserProfileData>(); | ||
45 | |||
46 | public string Name { get { return "TemporaryUserProfilePlugin"; } } | ||
47 | public string Version { get { return "0.1"; } } | ||
48 | public void Initialise() {} | ||
49 | public void Initialise(string connect) {} | ||
50 | public void Dispose() {} | ||
51 | |||
52 | public UserProfileData GetUserByUUID(UUID user) | ||
53 | { | ||
54 | //m_log.DebugFormat("[TEMP USER PROFILE]: Received request for {0}", user); | ||
55 | |||
56 | lock (m_profiles) | ||
57 | { | ||
58 | if (m_profiles.ContainsKey(user)) | ||
59 | return m_profiles[user]; | ||
60 | else | ||
61 | return null; | ||
62 | } | ||
63 | } | ||
64 | |||
65 | public UserProfileData GetUserByName(string fname, string lname) | ||
66 | { | ||
67 | // We deliberately don't look up a temporary profile by name so that we don't obscure non-temporary | ||
68 | // profiles. | ||
69 | |||
70 | return null; | ||
71 | } | ||
72 | |||
73 | public virtual void AddTemporaryUserProfile(UserProfileData userProfile) | ||
74 | { | ||
75 | //m_log.DebugFormat("[TEMP USER PROFILE]: Adding {0} {1}", userProfile.Name, userProfile.ID); | ||
76 | |||
77 | lock (m_profiles) | ||
78 | { | ||
79 | m_profiles[userProfile.ID] = userProfile; | ||
80 | } | ||
81 | } | ||
82 | |||
83 | public UserProfileData GetUserByUri(Uri uri) { return null; } | ||
84 | public List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query) { return null; } | ||
85 | public UserAgentData GetAgentByUUID(UUID user) { return null; } | ||
86 | public UserAgentData GetAgentByName(string name) { return null; } | ||
87 | public UserAgentData GetAgentByName(string fname, string lname) { return null; } | ||
88 | public void StoreWebLoginKey(UUID agentID, UUID webLoginKey) {} | ||
89 | public void AddNewUserProfile(UserProfileData user) {} | ||
90 | public bool UpdateUserProfile(UserProfileData user) { return false; } | ||
91 | public void AddNewUserAgent(UserAgentData agent) {} | ||
92 | public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) {} | ||
93 | public void RemoveUserFriend(UUID friendlistowner, UUID friend) {} | ||
94 | public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) {} | ||
95 | public List<FriendListItem> GetUserFriendList(UUID friendlistowner) { return null; } | ||
96 | public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids) { return null; } | ||
97 | public bool MoneyTransferRequest(UUID from, UUID to, uint amount) { return false; } | ||
98 | public bool InventoryTransferRequest(UUID from, UUID to, UUID inventory) { return false; } | ||
99 | public AvatarAppearance GetUserAppearance(UUID user) { return null; } | ||
100 | public void UpdateUserAppearance(UUID user, AvatarAppearance appearance) {} | ||
101 | public void ResetAttachments(UUID userID) {} | ||
102 | public void LogoutUsers(UUID regionID) {} | ||
103 | } | ||
104 | } | ||
diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs deleted file mode 100644 index 830c877..0000000 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ /dev/null | |||
@@ -1,345 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using NUnit.Framework; | ||
29 | using NUnit.Framework.SyntaxHelpers; | ||
30 | using System.Threading; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Data; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Communications.Cache; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | using OpenSim.Region.Communications.Local; | ||
37 | using OpenSim.Tests.Common.Mock; | ||
38 | using OpenSim.Tests.Common.Setup; | ||
39 | using OpenSim.Tests.Common; | ||
40 | |||
41 | namespace OpenSim.Framework.Communications.Tests | ||
42 | { | ||
43 | [TestFixture] | ||
44 | public class UserProfileCacheServiceTests | ||
45 | { | ||
46 | /// <value>Used by tests to indicate whether an async operation timed out</value> | ||
47 | private bool timedOut; | ||
48 | |||
49 | private void InventoryReceived(UUID userId) | ||
50 | { | ||
51 | lock (this) | ||
52 | { | ||
53 | timedOut = false; | ||
54 | Monitor.PulseAll(this); | ||
55 | } | ||
56 | } | ||
57 | |||
58 | [Test] | ||
59 | public void TestGetUserDetails() | ||
60 | { | ||
61 | TestHelper.InMethod(); | ||
62 | |||
63 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000002"); | ||
64 | string firstName = "Bill"; | ||
65 | string lastName = "Bailey"; | ||
66 | CachedUserInfo nonExistingUserInfo; | ||
67 | |||
68 | TestCommunicationsManager commsManager = new TestCommunicationsManager(); | ||
69 | // Scene myScene = SceneSetupHelpers.SetupScene(commsManager, ""); | ||
70 | |||
71 | // Check we can't retrieve info before it exists by uuid | ||
72 | nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); | ||
73 | Assert.That(nonExistingUserInfo, Is.Null, "User info found by uuid before user creation"); | ||
74 | |||
75 | // Check we can't retrieve info before it exists by name | ||
76 | nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); | ||
77 | Assert.That(nonExistingUserInfo, Is.Null, "User info found by name before user creation"); | ||
78 | |||
79 | LocalUserServices lus = (LocalUserServices)commsManager.UserService; | ||
80 | lus.AddUser(firstName, lastName, "troll", "bill@bailey.com", 1000, 1000, userId); | ||
81 | |||
82 | CachedUserInfo existingUserInfo; | ||
83 | |||
84 | // Check we can retrieve info by uuid | ||
85 | existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); | ||
86 | Assert.That(existingUserInfo, Is.Not.Null, "User info not found by uuid"); | ||
87 | |||
88 | // Check we can retrieve info by name | ||
89 | existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); | ||
90 | Assert.That(existingUserInfo, Is.Not.Null, "User info not found by name"); | ||
91 | } | ||
92 | |||
93 | /** | ||
94 | * Disabled as not fully implemented | ||
95 | [Test] | ||
96 | public void TestUpdateProfile() | ||
97 | { | ||
98 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000292"); | ||
99 | string firstName = "Inspector"; | ||
100 | string originalLastName = "Morse"; | ||
101 | string newLastName = "Gadget"; | ||
102 | |||
103 | UserProfileData newProfile = new UserProfileData(); | ||
104 | newProfile.ID = userId; | ||
105 | newProfile.FirstName = firstName; | ||
106 | newProfile.SurName = newLastName; | ||
107 | |||
108 | TestCommunicationsManager commsManager = new TestCommunicationsManager(); | ||
109 | UserProfileCacheService userCacheService = commsManager.UserProfileCacheService; | ||
110 | IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; | ||
111 | |||
112 | // Check that we can't update info before it exists | ||
113 | Assert.That(userCacheService.StoreProfile(newProfile), Is.False); | ||
114 | Assert.That(userDataPlugin.GetUserByUUID(userId), Is.Null); | ||
115 | |||
116 | // Check that we can update a profile once it exists | ||
117 | LocalUserServices lus = (LocalUserServices)commsManager.UserService; | ||
118 | lus.AddUser(firstName, originalLastName, "pingu", "ted@excellentadventure.com", 1000, 1000, userId); | ||
119 | |||
120 | Assert.That(userCacheService.StoreProfile(newProfile), Is.True); | ||
121 | UserProfileData retrievedProfile = userCacheService.GetUserDetails(userId).UserProfile; | ||
122 | Assert.That(retrievedProfile.SurName, Is.EqualTo(newLastName)); | ||
123 | Assert.That(userDataPlugin.GetUserByUUID(userId).SurName, Is.EqualTo(newLastName)); | ||
124 | } | ||
125 | */ | ||
126 | |||
127 | [Test] | ||
128 | public void TestFetchInventory() | ||
129 | { | ||
130 | TestHelper.InMethod(); | ||
131 | |||
132 | Scene myScene = SceneSetupHelpers.SetupScene("inventory"); | ||
133 | |||
134 | timedOut = true; | ||
135 | lock (this) | ||
136 | { | ||
137 | UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); | ||
138 | Monitor.Wait(this, 60000); | ||
139 | } | ||
140 | |||
141 | Assert.That(timedOut, Is.False, "Timed out"); | ||
142 | } | ||
143 | |||
144 | [Test] | ||
145 | public void TestGetChildFolder() | ||
146 | { | ||
147 | TestHelper.InMethod(); | ||
148 | |||
149 | Scene myScene = SceneSetupHelpers.SetupScene("inventory"); | ||
150 | CachedUserInfo userInfo; | ||
151 | |||
152 | lock (this) | ||
153 | { | ||
154 | userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); | ||
155 | Monitor.Wait(this, 60000); | ||
156 | } | ||
157 | |||
158 | UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); | ||
159 | Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null); | ||
160 | userInfo.CreateFolder("testFolder", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID); | ||
161 | |||
162 | Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Not.Null); | ||
163 | } | ||
164 | |||
165 | [Test] | ||
166 | public void TestCreateFolder() | ||
167 | { | ||
168 | TestHelper.InMethod(); | ||
169 | |||
170 | Scene myScene = SceneSetupHelpers.SetupScene("inventory"); | ||
171 | CachedUserInfo userInfo; | ||
172 | |||
173 | lock (this) | ||
174 | { | ||
175 | userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); | ||
176 | Monitor.Wait(this, 60000); | ||
177 | } | ||
178 | |||
179 | UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); | ||
180 | Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False); | ||
181 | |||
182 | // 1: Try a folder create that should fail because the parent id given does not exist | ||
183 | UUID missingFolderId = UUID.Random(); | ||
184 | InventoryFolderBase myFolder = new InventoryFolderBase(); | ||
185 | myFolder.ID = folderId; | ||
186 | |||
187 | Assert.That( | ||
188 | userInfo.CreateFolder("testFolder1", folderId, (ushort)AssetType.Animation, missingFolderId), Is.False); | ||
189 | Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Null); | ||
190 | Assert.That(userInfo.RootFolder.ContainsChildFolder(missingFolderId), Is.False); | ||
191 | Assert.That(userInfo.RootFolder.FindFolder(folderId), Is.Null); | ||
192 | |||
193 | // 2: Try a folder create that should work | ||
194 | Assert.That( | ||
195 | userInfo.CreateFolder("testFolder2", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID), Is.True); | ||
196 | Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Not.Null); | ||
197 | Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.True); | ||
198 | } | ||
199 | |||
200 | //[Test] | ||
201 | public void TestUpdateFolder() | ||
202 | { | ||
203 | TestHelper.InMethod(); | ||
204 | |||
205 | Scene myScene = SceneSetupHelpers.SetupScene("inventory"); | ||
206 | CachedUserInfo userInfo; | ||
207 | |||
208 | lock (this) | ||
209 | { | ||
210 | userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); | ||
211 | Monitor.Wait(this, 60000); | ||
212 | } | ||
213 | |||
214 | UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | ||
215 | InventoryFolderImpl rootFolder = userInfo.RootFolder; | ||
216 | InventoryFolderBase myFolder = new InventoryFolderBase(); | ||
217 | myFolder.ID = folder1Id; | ||
218 | |||
219 | userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID); | ||
220 | |||
221 | // 1: Test updates that don't involve moving the folder | ||
222 | { | ||
223 | string newFolderName1 = "newFolderName1"; | ||
224 | ushort folderType1 = (ushort)AssetType.Texture; | ||
225 | userInfo.UpdateFolder(newFolderName1, folder1Id, folderType1, rootFolder.ID); | ||
226 | |||
227 | InventoryFolderImpl folder1 = rootFolder.GetChildFolder(folder1Id); | ||
228 | Assert.That(newFolderName1, Is.EqualTo(folder1.Name)); | ||
229 | Assert.That(folderType1, Is.EqualTo((ushort)folder1.Type)); | ||
230 | |||
231 | InventoryFolderBase dataFolder1 = myScene.InventoryService.GetFolder(myFolder); | ||
232 | Assert.That(newFolderName1, Is.EqualTo(dataFolder1.Name)); | ||
233 | Assert.That(folderType1, Is.EqualTo((ushort)dataFolder1.Type)); | ||
234 | } | ||
235 | |||
236 | // 2: Test an update that also involves moving the folder | ||
237 | { | ||
238 | UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000061"); | ||
239 | userInfo.CreateFolder("folder2", folder2Id, (ushort)AssetType.Animation, rootFolder.ID); | ||
240 | InventoryFolderImpl folder2 = rootFolder.GetChildFolder(folder2Id); | ||
241 | |||
242 | InventoryFolderBase myFolder2 = new InventoryFolderBase(); | ||
243 | myFolder2.ID = folder2Id; | ||
244 | |||
245 | string newFolderName2 = "newFolderName2"; | ||
246 | ushort folderType2 = (ushort)AssetType.Bodypart; | ||
247 | userInfo.UpdateFolder(newFolderName2, folder1Id, folderType2, folder2Id); | ||
248 | |||
249 | InventoryFolderImpl folder1 = folder2.GetChildFolder(folder1Id); | ||
250 | Assert.That(newFolderName2, Is.EqualTo(folder1.Name)); | ||
251 | Assert.That(folderType2, Is.EqualTo((ushort)folder1.Type)); | ||
252 | Assert.That(folder2Id, Is.EqualTo(folder1.ParentID)); | ||
253 | |||
254 | Assert.That(folder2.ContainsChildFolder(folder1Id), Is.True); | ||
255 | Assert.That(rootFolder.ContainsChildFolder(folder1Id), Is.False); | ||
256 | |||
257 | InventoryFolderBase dataFolder1 = myScene.InventoryService.GetFolder(myFolder2); | ||
258 | Assert.That(newFolderName2, Is.EqualTo(dataFolder1.Name)); | ||
259 | Assert.That(folderType2, Is.EqualTo((ushort)dataFolder1.Type)); | ||
260 | Assert.That(folder2Id, Is.EqualTo(dataFolder1.ParentID)); | ||
261 | } | ||
262 | |||
263 | } | ||
264 | |||
265 | [Test] | ||
266 | public void TestMoveFolder() | ||
267 | { | ||
268 | TestHelper.InMethod(); | ||
269 | |||
270 | Scene myScene = SceneSetupHelpers.SetupScene("inventory"); | ||
271 | CachedUserInfo userInfo; | ||
272 | |||
273 | lock (this) | ||
274 | { | ||
275 | userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); | ||
276 | Monitor.Wait(this, 60000); | ||
277 | } | ||
278 | |||
279 | UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020"); | ||
280 | UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021"); | ||
281 | UUID folderToMoveId = UUID.Parse("00000000-0000-0000-0000-000000000030"); | ||
282 | InventoryFolderImpl rootFolder = userInfo.RootFolder; | ||
283 | |||
284 | userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID); | ||
285 | InventoryFolderImpl folder1 = rootFolder.GetChildFolder(folder1Id); | ||
286 | userInfo.CreateFolder("folder2", folder2Id, (ushort)AssetType.Animation, rootFolder.ID); | ||
287 | InventoryFolderImpl folder2 = rootFolder.GetChildFolder(folder2Id); | ||
288 | |||
289 | // Check folder is currently in folder1 | ||
290 | userInfo.CreateFolder("folderToMove", folderToMoveId, (ushort)AssetType.Animation, folder1Id); | ||
291 | Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.True); | ||
292 | |||
293 | userInfo.MoveFolder(folderToMoveId, folder2Id); | ||
294 | |||
295 | // Check folder is now in folder2 and no trace remains in folder1 | ||
296 | InventoryFolderBase myFolder = new InventoryFolderBase(); | ||
297 | myFolder.ID = folderToMoveId; | ||
298 | Assert.That(folder2.ContainsChildFolder(folderToMoveId), Is.True); | ||
299 | Assert.That(myScene.InventoryService.GetFolder(myFolder).ParentID, Is.EqualTo(folder2Id)); | ||
300 | |||
301 | Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.False); | ||
302 | } | ||
303 | |||
304 | [Test] | ||
305 | public void TestPurgeFolder() | ||
306 | { | ||
307 | TestHelper.InMethod(); | ||
308 | //log4net.Config.XmlConfigurator.Configure(); | ||
309 | |||
310 | Scene myScene = SceneSetupHelpers.SetupScene("inventory"); | ||
311 | CachedUserInfo userInfo; | ||
312 | |||
313 | lock (this) | ||
314 | { | ||
315 | userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived); | ||
316 | Monitor.Wait(this, 60000); | ||
317 | } | ||
318 | |||
319 | UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070"); | ||
320 | InventoryFolderImpl rootFolder = userInfo.RootFolder; | ||
321 | InventoryFolderBase myFolder = new InventoryFolderBase(); | ||
322 | myFolder.ID = folder1Id; | ||
323 | |||
324 | userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID); | ||
325 | Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Not.Null); | ||
326 | |||
327 | // Test purge | ||
328 | userInfo.PurgeFolder(rootFolder.ID); | ||
329 | |||
330 | Assert.That(rootFolder.RequestListOfFolders(), Is.Empty); | ||
331 | Assert.That(myScene.InventoryService.GetFolder(myFolder), Is.Null); | ||
332 | } | ||
333 | |||
334 | [TearDown] | ||
335 | public void TearDown() | ||
336 | { | ||
337 | try | ||
338 | { | ||
339 | if (MainServer.Instance != null) MainServer.Instance.Stop(); | ||
340 | } | ||
341 | catch (System.NullReferenceException) | ||
342 | { } | ||
343 | } | ||
344 | } | ||
345 | } \ No newline at end of file | ||
diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs deleted file mode 100644 index a274ae7..0000000 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ /dev/null | |||
@@ -1,453 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Text.RegularExpressions; | ||
33 | using NUnit.Framework; | ||
34 | using NUnit.Framework.SyntaxHelpers; | ||
35 | using Nwc.XmlRpc; | ||
36 | using OpenSim.Framework.Communications.Cache; | ||
37 | using OpenSim.Framework.Communications.Services; | ||
38 | using OpenSim.Region.Communications.Local; | ||
39 | using OpenSim.Tests.Common.Setup; | ||
40 | using OpenSim.Tests.Common.Mock; | ||
41 | using OpenSim.Client.Linden; | ||
42 | using OpenSim.Tests.Common; | ||
43 | using OpenSim.Services.Interfaces; | ||
44 | using OpenMetaverse; | ||
45 | |||
46 | namespace OpenSim.Framework.Communications.Tests | ||
47 | { | ||
48 | /// <summary> | ||
49 | /// Test the login service. For now, most of this will be done through the LocalLoginService as LoginService | ||
50 | /// is abstract | ||
51 | /// </summary> | ||
52 | |||
53 | [TestFixture] | ||
54 | public class LoginServiceTests | ||
55 | { | ||
56 | private string m_firstName = "Adam"; | ||
57 | private string m_lastName = "West"; | ||
58 | private string m_regionExternalName = "localhost"; | ||
59 | |||
60 | private IPEndPoint m_capsEndPoint; | ||
61 | private TestCommunicationsManager m_commsManager; | ||
62 | private TestLoginToRegionConnector m_regionConnector; | ||
63 | private LocalUserServices m_localUserServices; | ||
64 | private LoginService m_loginService; | ||
65 | private UserProfileData m_userProfileData; | ||
66 | private TestScene m_testScene; | ||
67 | |||
68 | [SetUp] | ||
69 | public void SetUpLoginEnviroment() | ||
70 | { | ||
71 | m_capsEndPoint = new IPEndPoint(IPAddress.Loopback, 9123); | ||
72 | m_commsManager = new TestCommunicationsManager(new NetworkServersInfo(42, 43)); | ||
73 | m_regionConnector = new TestLoginToRegionConnector(); | ||
74 | m_testScene = SceneSetupHelpers.SetupScene(m_commsManager, ""); | ||
75 | |||
76 | m_regionConnector.AddRegion(new RegionInfo(42, 43, m_capsEndPoint, m_regionExternalName)); | ||
77 | |||
78 | //IInventoryService m_inventoryService = new MockInventoryService(); | ||
79 | |||
80 | m_localUserServices = (LocalUserServices) m_commsManager.UserService; | ||
81 | m_localUserServices.AddUser(m_firstName,m_lastName,"boingboing","abc@ftw.com",42,43); | ||
82 | |||
83 | m_loginService = new LLStandaloneLoginService((UserManagerBase) m_localUserServices, "Hello folks", m_testScene.InventoryService, | ||
84 | m_commsManager.NetworkServersInfo, true, new LibraryRootFolder(String.Empty), m_regionConnector); | ||
85 | |||
86 | m_userProfileData = m_localUserServices.GetUserProfile(m_firstName, m_lastName); | ||
87 | } | ||
88 | |||
89 | /// <summary> | ||
90 | /// Test the normal response to a login. Does not test authentication. | ||
91 | /// </summary> | ||
92 | [Test] | ||
93 | public void T010_TestUnauthenticatedLogin() | ||
94 | { | ||
95 | TestHelper.InMethod(); | ||
96 | // We want to use our own LoginService for this test, one that | ||
97 | // doesn't require authentication. | ||
98 | new LLStandaloneLoginService( | ||
99 | (UserManagerBase)m_commsManager.UserService, "Hello folks", new MockInventoryService(), | ||
100 | m_commsManager.NetworkServersInfo, false, new LibraryRootFolder(String.Empty), m_regionConnector); | ||
101 | |||
102 | Hashtable loginParams = new Hashtable(); | ||
103 | loginParams["first"] = m_firstName; | ||
104 | loginParams["last"] = m_lastName; | ||
105 | loginParams["passwd"] = "boingboing"; | ||
106 | |||
107 | ArrayList sendParams = new ArrayList(); | ||
108 | sendParams.Add(loginParams); | ||
109 | sendParams.Add(m_capsEndPoint); // is this parameter correct? | ||
110 | sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? | ||
111 | |||
112 | XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); | ||
113 | |||
114 | IPAddress tmpLocal = Util.GetLocalHost(); | ||
115 | IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); | ||
116 | XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); | ||
117 | |||
118 | Hashtable responseData = (Hashtable)response.Value; | ||
119 | |||
120 | Assert.That(responseData["first_name"], Is.EqualTo(m_firstName)); | ||
121 | Assert.That(responseData["last_name"], Is.EqualTo(m_lastName)); | ||
122 | Assert.That( | ||
123 | responseData["circuit_code"], Is.GreaterThanOrEqualTo(0) & Is.LessThanOrEqualTo(Int32.MaxValue)); | ||
124 | |||
125 | Regex capsSeedPattern | ||
126 | = new Regex("^http://" | ||
127 | + NetworkUtil.GetHostFor(tmpLocal, m_regionExternalName) | ||
128 | + ":9000/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}0000/$"); | ||
129 | |||
130 | Assert.That(capsSeedPattern.IsMatch((string)responseData["seed_capability"]), Is.True); | ||
131 | } | ||
132 | |||
133 | [Test] | ||
134 | public void T011_TestAuthenticatedLoginSuccess() | ||
135 | { | ||
136 | TestHelper.InMethod(); | ||
137 | // TODO: Not check inventory part of response yet. | ||
138 | // TODO: Not checking all of login response thoroughly yet. | ||
139 | |||
140 | // 1) Test for positive authentication | ||
141 | |||
142 | Hashtable loginParams = new Hashtable(); | ||
143 | loginParams["first"] = m_firstName; | ||
144 | loginParams["last"] = m_lastName; | ||
145 | loginParams["passwd"] = "boingboing"; | ||
146 | |||
147 | ArrayList sendParams = new ArrayList(); | ||
148 | sendParams.Add(loginParams); | ||
149 | sendParams.Add(m_capsEndPoint); // is this parameter correct? | ||
150 | sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? | ||
151 | |||
152 | XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); | ||
153 | |||
154 | IPAddress tmpLocal = Util.GetLocalHost(); | ||
155 | IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); | ||
156 | XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); | ||
157 | |||
158 | Hashtable responseData = (Hashtable)response.Value; | ||
159 | |||
160 | UserAgentData uagent = m_userProfileData.CurrentAgent; | ||
161 | Assert.That(uagent,Is.Not.Null); | ||
162 | |||
163 | Assert.That(responseData["first_name"], Is.Not.Null); | ||
164 | Assert.That(responseData["first_name"], Is.EqualTo(m_firstName)); | ||
165 | Assert.That(responseData["last_name"], Is.EqualTo(m_lastName)); | ||
166 | Assert.That(responseData["agent_id"], Is.EqualTo(uagent.ProfileID.ToString())); | ||
167 | Assert.That(responseData["session_id"], Is.EqualTo(uagent.SessionID.ToString())); | ||
168 | Assert.That(responseData["secure_session_id"], Is.EqualTo(uagent.SecureSessionID.ToString())); | ||
169 | ArrayList invlibroot = (ArrayList) responseData["inventory-lib-root"]; | ||
170 | Hashtable invlibroothash = (Hashtable) invlibroot[0]; | ||
171 | Assert.That(invlibroothash["folder_id"],Is.EqualTo("00000112-000f-0000-0000-000100bba000")); | ||
172 | Assert.That( | ||
173 | responseData["circuit_code"], Is.GreaterThanOrEqualTo(0) & Is.LessThanOrEqualTo(Int32.MaxValue)); | ||
174 | Assert.That(responseData["message"], Is.EqualTo("Hello folks")); | ||
175 | Assert.That(responseData["buddy-list"], Is.Empty); | ||
176 | Assert.That(responseData["start_location"], Is.EqualTo("last")); | ||
177 | |||
178 | Regex capsSeedPattern | ||
179 | = new Regex("^http://" | ||
180 | + NetworkUtil.GetHostFor(tmpLocal, m_regionExternalName) | ||
181 | + ":9000/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}0000/$"); | ||
182 | |||
183 | Assert.That(capsSeedPattern.IsMatch((string)responseData["seed_capability"]), Is.True); | ||
184 | } | ||
185 | |||
186 | [Test] | ||
187 | public void T012_TestAuthenticatedLoginForBuddies() | ||
188 | { | ||
189 | TestHelper.InMethod(); | ||
190 | // 1.1) Test for budddies! | ||
191 | m_localUserServices.AddUser("Friend","Number1","boingboing","abc@ftw.com",42,43); | ||
192 | m_localUserServices.AddUser("Friend","Number2","boingboing","abc@ftw.com",42,43); | ||
193 | |||
194 | UserProfileData friend1 = m_localUserServices.GetUserProfile("Friend","Number1"); | ||
195 | UserProfileData friend2 = m_localUserServices.GetUserProfile("Friend","Number2"); | ||
196 | m_localUserServices.AddNewUserFriend(friend1.ID,m_userProfileData.ID,1); | ||
197 | m_localUserServices.AddNewUserFriend(friend1.ID,friend2.ID,2); | ||
198 | |||
199 | Hashtable loginParams = new Hashtable(); | ||
200 | loginParams["first"] = "Friend"; | ||
201 | loginParams["last"] = "Number1"; | ||
202 | loginParams["passwd"] = "boingboing"; | ||
203 | |||
204 | ArrayList sendParams = new ArrayList(); | ||
205 | sendParams.Add(loginParams); | ||
206 | sendParams.Add(m_capsEndPoint); // is this parameter correct? | ||
207 | sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? | ||
208 | |||
209 | XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); | ||
210 | |||
211 | IPAddress tmpLocal = Util.GetLocalHost(); | ||
212 | IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); | ||
213 | XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); | ||
214 | |||
215 | Hashtable responseData = (Hashtable)response.Value; | ||
216 | |||
217 | ArrayList friendslist = (ArrayList) responseData["buddy-list"]; | ||
218 | |||
219 | Assert.That(friendslist,Is.Not.Null); | ||
220 | |||
221 | Hashtable buddy1 = (Hashtable) friendslist[0]; | ||
222 | Hashtable buddy2 = (Hashtable) friendslist[1]; | ||
223 | Assert.That(friendslist.Count, Is.EqualTo(2)); | ||
224 | Assert.That(m_userProfileData.ID.ToString(), Is.EqualTo(buddy1["buddy_id"]) | Is.EqualTo(buddy2["buddy_id"])); | ||
225 | Assert.That(friend2.ID.ToString(), Is.EqualTo(buddy1["buddy_id"]) | Is.EqualTo(buddy2["buddy_id"])); | ||
226 | } | ||
227 | |||
228 | [Test] | ||
229 | public void T020_TestAuthenticatedLoginBadUsername() | ||
230 | { | ||
231 | TestHelper.InMethod(); | ||
232 | |||
233 | // 2) Test for negative authentication | ||
234 | // | ||
235 | string error_auth_message = "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist."; | ||
236 | //string error_region_unavailable = "The region you are attempting to log into is not responding. Please select another region and try again."; | ||
237 | // 2.1) Test for wrong user name | ||
238 | Hashtable loginParams = new Hashtable(); | ||
239 | loginParams["first"] = m_lastName; | ||
240 | loginParams["last"] = m_firstName; | ||
241 | loginParams["passwd"] = "boingboing"; | ||
242 | |||
243 | ArrayList sendParams = new ArrayList(); | ||
244 | sendParams.Add(loginParams); | ||
245 | sendParams.Add(m_capsEndPoint); // is this parameter correct? | ||
246 | sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? | ||
247 | |||
248 | XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); | ||
249 | |||
250 | IPAddress tmpLocal = Util.GetLocalHost(); | ||
251 | IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); | ||
252 | XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); | ||
253 | |||
254 | Hashtable responseData = (Hashtable)response.Value; | ||
255 | Assert.That(responseData["message"], Is.EqualTo(error_auth_message)); | ||
256 | |||
257 | } | ||
258 | |||
259 | [Test] | ||
260 | public void T021_TestAuthenticatedLoginBadPassword() | ||
261 | { | ||
262 | TestHelper.InMethod(); | ||
263 | |||
264 | string error_auth_message = "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist."; | ||
265 | // 2.2) Test for wrong password | ||
266 | Hashtable loginParams = new Hashtable(); | ||
267 | loginParams["first"] = "Friend"; | ||
268 | loginParams["last"] = "Number2"; | ||
269 | loginParams["passwd"] = "boing"; | ||
270 | |||
271 | ArrayList sendParams = new ArrayList(); | ||
272 | sendParams.Add(loginParams); | ||
273 | sendParams.Add(m_capsEndPoint); // is this parameter correct? | ||
274 | sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? | ||
275 | |||
276 | XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); | ||
277 | |||
278 | IPAddress tmpLocal = Util.GetLocalHost(); | ||
279 | IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); | ||
280 | XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); | ||
281 | |||
282 | Hashtable responseData = (Hashtable)response.Value; | ||
283 | Assert.That(responseData["message"], Is.EqualTo(error_auth_message)); | ||
284 | |||
285 | } | ||
286 | |||
287 | [Test] | ||
288 | public void T022_TestAuthenticatedLoginBadXml() | ||
289 | { | ||
290 | TestHelper.InMethod(); | ||
291 | |||
292 | string error_xml_message = "Error connecting to grid. Could not percieve credentials from login XML."; | ||
293 | // 2.3) Bad XML | ||
294 | Hashtable loginParams = new Hashtable(); | ||
295 | loginParams["first"] = "Friend"; | ||
296 | loginParams["banana"] = "Banana"; | ||
297 | loginParams["passwd"] = "boingboing"; | ||
298 | |||
299 | ArrayList sendParams = new ArrayList(); | ||
300 | sendParams.Add(loginParams); | ||
301 | sendParams.Add(m_capsEndPoint); // is this parameter correct? | ||
302 | sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? | ||
303 | |||
304 | XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); | ||
305 | |||
306 | IPAddress tmpLocal = Util.GetLocalHost(); | ||
307 | IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); | ||
308 | XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); | ||
309 | |||
310 | Hashtable responseData = (Hashtable)response.Value; | ||
311 | Assert.That(responseData["message"], Is.EqualTo(error_xml_message)); | ||
312 | |||
313 | } | ||
314 | |||
315 | // [Test] | ||
316 | // Commenting out test now that LLStandAloneLoginService no longer replies with message in this case. | ||
317 | // Kept the code for future test with grid mode, which will keep this behavior. | ||
318 | public void T023_TestAuthenticatedLoginAlreadyLoggedIn() | ||
319 | { | ||
320 | TestHelper.InMethod(); | ||
321 | |||
322 | //Console.WriteLine("Starting T023_TestAuthenticatedLoginAlreadyLoggedIn()"); | ||
323 | //log4net.Config.XmlConfigurator.Configure(); | ||
324 | |||
325 | string error_already_logged = "You appear to be already logged in. " + | ||
326 | "If this is not the case please wait for your session to timeout. " + | ||
327 | "If this takes longer than a few minutes please contact the grid owner. " + | ||
328 | "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously."; | ||
329 | // 2.4) Already logged in and sucessfull post login | ||
330 | Hashtable loginParams = new Hashtable(); | ||
331 | loginParams["first"] = "Adam"; | ||
332 | loginParams["last"] = "West"; | ||
333 | loginParams["passwd"] = "boingboing"; | ||
334 | |||
335 | ArrayList sendParams = new ArrayList(); | ||
336 | sendParams.Add(loginParams); | ||
337 | sendParams.Add(m_capsEndPoint); // is this parameter correct? | ||
338 | sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct? | ||
339 | |||
340 | // First we log in. | ||
341 | XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); | ||
342 | |||
343 | IPAddress tmpLocal = Util.GetLocalHost(); | ||
344 | IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); | ||
345 | XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); | ||
346 | |||
347 | Hashtable responseData = (Hashtable)response.Value; | ||
348 | Assert.That(responseData["message"], Is.EqualTo("Hello folks")); | ||
349 | |||
350 | // Then we try again, this time expecting failure. | ||
351 | request = new XmlRpcRequest("login_to_simulator", sendParams); | ||
352 | response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); | ||
353 | responseData = (Hashtable)response.Value; | ||
354 | Assert.That(responseData["message"], Is.EqualTo(error_already_logged)); | ||
355 | |||
356 | // Finally the third time we should be able to get right back in. | ||
357 | request = new XmlRpcRequest("login_to_simulator", sendParams); | ||
358 | |||
359 | response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); | ||
360 | responseData = (Hashtable)response.Value; | ||
361 | Assert.That(responseData["message"], Is.EqualTo("Hello folks")); | ||
362 | |||
363 | //Console.WriteLine("Finished T023_TestAuthenticatedLoginAlreadyLoggedIn()"); | ||
364 | } | ||
365 | |||
366 | [TearDown] | ||
367 | public void TearDown() | ||
368 | { | ||
369 | try | ||
370 | { | ||
371 | if (MainServer.Instance != null) MainServer.Instance.Stop(); | ||
372 | } catch (NullReferenceException) | ||
373 | {} | ||
374 | } | ||
375 | |||
376 | public class TestLoginToRegionConnector : ILoginServiceToRegionsConnector | ||
377 | { | ||
378 | private List<RegionInfo> m_regionsList = new List<RegionInfo>(); | ||
379 | |||
380 | public void AddRegion(RegionInfo regionInfo) | ||
381 | { | ||
382 | lock (m_regionsList) | ||
383 | { | ||
384 | if (!m_regionsList.Contains(regionInfo)) | ||
385 | { | ||
386 | m_regionsList.Add(regionInfo); | ||
387 | } | ||
388 | } | ||
389 | } | ||
390 | |||
391 | public void LogOffUserFromGrid(ulong regionHandle, OpenMetaverse.UUID AvatarID, OpenMetaverse.UUID RegionSecret, string message) | ||
392 | { | ||
393 | } | ||
394 | |||
395 | public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent, out string reason) | ||
396 | { | ||
397 | reason = String.Empty; | ||
398 | lock (m_regionsList) | ||
399 | { | ||
400 | foreach (RegionInfo regInfo in m_regionsList) | ||
401 | { | ||
402 | if (regInfo.RegionHandle == regionHandle) | ||
403 | return true; | ||
404 | } | ||
405 | } | ||
406 | reason = "Region not found"; | ||
407 | return false; | ||
408 | } | ||
409 | |||
410 | public RegionInfo RequestClosestRegion(string region) | ||
411 | { | ||
412 | lock (m_regionsList) | ||
413 | { | ||
414 | foreach (RegionInfo regInfo in m_regionsList) | ||
415 | { | ||
416 | if (regInfo.RegionName == region) | ||
417 | return regInfo; | ||
418 | } | ||
419 | } | ||
420 | |||
421 | return null; | ||
422 | } | ||
423 | |||
424 | public RegionInfo RequestNeighbourInfo(OpenMetaverse.UUID regionID) | ||
425 | { | ||
426 | lock (m_regionsList) | ||
427 | { | ||
428 | foreach (RegionInfo regInfo in m_regionsList) | ||
429 | { | ||
430 | if (regInfo.RegionID == regionID) | ||
431 | return regInfo; | ||
432 | } | ||
433 | } | ||
434 | |||
435 | return null; | ||
436 | } | ||
437 | |||
438 | public RegionInfo RequestNeighbourInfo(ulong regionHandle) | ||
439 | { | ||
440 | lock (m_regionsList) | ||
441 | { | ||
442 | foreach (RegionInfo regInfo in m_regionsList) | ||
443 | { | ||
444 | if (regInfo.RegionHandle == regionHandle) | ||
445 | return regInfo; | ||
446 | } | ||
447 | } | ||
448 | |||
449 | return null; | ||
450 | } | ||
451 | } | ||
452 | } | ||
453 | } | ||
diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs deleted file mode 100644 index 02be141..0000000 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ /dev/null | |||
@@ -1,930 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Net; | ||
31 | using System.Reflection; | ||
32 | using System.Security.Cryptography; | ||
33 | using log4net; | ||
34 | using Nwc.XmlRpc; | ||
35 | using OpenMetaverse; | ||
36 | using OpenMetaverse.StructuredData; | ||
37 | using OpenSim.Data; | ||
38 | using OpenSim.Framework.Communications; | ||
39 | using OpenSim.Framework.Statistics; | ||
40 | using OpenSim.Services.Interfaces; | ||
41 | |||
42 | namespace OpenSim.Framework.Communications | ||
43 | { | ||
44 | /// <summary> | ||
45 | /// Base class for user management (create, read, etc) | ||
46 | /// </summary> | ||
47 | public abstract class UserManagerBase | ||
48 | : IUserService, IUserAdminService, IAvatarService, IMessagingService, IAuthentication | ||
49 | { | ||
50 | private static readonly ILog m_log | ||
51 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | |||
53 | /// <value> | ||
54 | /// List of plugins to search for user data | ||
55 | /// </value> | ||
56 | private List<IUserDataPlugin> m_plugins = new List<IUserDataPlugin>(); | ||
57 | |||
58 | protected CommunicationsManager m_commsManager; | ||
59 | protected IInventoryService m_InventoryService; | ||
60 | |||
61 | /// <summary> | ||
62 | /// Constructor | ||
63 | /// </summary> | ||
64 | /// <param name="commsManager"></param> | ||
65 | public UserManagerBase(CommunicationsManager commsManager) | ||
66 | { | ||
67 | m_commsManager = commsManager; | ||
68 | } | ||
69 | |||
70 | public virtual void SetInventoryService(IInventoryService invService) | ||
71 | { | ||
72 | m_InventoryService = invService; | ||
73 | } | ||
74 | |||
75 | /// <summary> | ||
76 | /// Add a new user data plugin - plugins will be requested in the order they were added. | ||
77 | /// </summary> | ||
78 | /// <param name="plugin">The plugin that will provide user data</param> | ||
79 | public void AddPlugin(IUserDataPlugin plugin) | ||
80 | { | ||
81 | m_plugins.Add(plugin); | ||
82 | } | ||
83 | |||
84 | /// <summary> | ||
85 | /// Adds a list of user data plugins, as described by `provider' and | ||
86 | /// `connect', to `_plugins'. | ||
87 | /// </summary> | ||
88 | /// <param name="provider"> | ||
89 | /// The filename of the inventory server plugin DLL. | ||
90 | /// </param> | ||
91 | /// <param name="connect"> | ||
92 | /// The connection string for the storage backend. | ||
93 | /// </param> | ||
94 | public void AddPlugin(string provider, string connect) | ||
95 | { | ||
96 | m_plugins.AddRange(DataPluginFactory.LoadDataPlugins<IUserDataPlugin>(provider, connect)); | ||
97 | } | ||
98 | |||
99 | #region UserProfile | ||
100 | |||
101 | public virtual void AddTemporaryUserProfile(UserProfileData userProfile) | ||
102 | { | ||
103 | foreach (IUserDataPlugin plugin in m_plugins) | ||
104 | { | ||
105 | plugin.AddTemporaryUserProfile(userProfile); | ||
106 | } | ||
107 | } | ||
108 | |||
109 | public virtual UserProfileData GetUserProfile(string fname, string lname) | ||
110 | { | ||
111 | foreach (IUserDataPlugin plugin in m_plugins) | ||
112 | { | ||
113 | UserProfileData profile = plugin.GetUserByName(fname, lname); | ||
114 | |||
115 | if (profile != null) | ||
116 | { | ||
117 | profile.CurrentAgent = GetUserAgent(profile.ID); | ||
118 | return profile; | ||
119 | } | ||
120 | } | ||
121 | |||
122 | return null; | ||
123 | } | ||
124 | |||
125 | public void LogoutUsers(UUID regionID) | ||
126 | { | ||
127 | foreach (IUserDataPlugin plugin in m_plugins) | ||
128 | { | ||
129 | plugin.LogoutUsers(regionID); | ||
130 | } | ||
131 | } | ||
132 | |||
133 | public void ResetAttachments(UUID userID) | ||
134 | { | ||
135 | foreach (IUserDataPlugin plugin in m_plugins) | ||
136 | { | ||
137 | plugin.ResetAttachments(userID); | ||
138 | } | ||
139 | } | ||
140 | |||
141 | public UserProfileData GetUserProfile(Uri uri) | ||
142 | { | ||
143 | foreach (IUserDataPlugin plugin in m_plugins) | ||
144 | { | ||
145 | UserProfileData profile = plugin.GetUserByUri(uri); | ||
146 | |||
147 | if (null != profile) | ||
148 | return profile; | ||
149 | } | ||
150 | |||
151 | return null; | ||
152 | } | ||
153 | |||
154 | public virtual UserAgentData GetAgentByUUID(UUID userId) | ||
155 | { | ||
156 | foreach (IUserDataPlugin plugin in m_plugins) | ||
157 | { | ||
158 | UserAgentData agent = plugin.GetAgentByUUID(userId); | ||
159 | |||
160 | if (agent != null) | ||
161 | { | ||
162 | return agent; | ||
163 | } | ||
164 | } | ||
165 | |||
166 | return null; | ||
167 | } | ||
168 | |||
169 | public Uri GetUserUri(UserProfileData userProfile) | ||
170 | { | ||
171 | throw new NotImplementedException(); | ||
172 | } | ||
173 | |||
174 | // see IUserService | ||
175 | public virtual UserProfileData GetUserProfile(UUID uuid) | ||
176 | { | ||
177 | foreach (IUserDataPlugin plugin in m_plugins) | ||
178 | { | ||
179 | UserProfileData profile = plugin.GetUserByUUID(uuid); | ||
180 | |||
181 | if (null != profile) | ||
182 | { | ||
183 | profile.CurrentAgent = GetUserAgent(profile.ID); | ||
184 | return profile; | ||
185 | } | ||
186 | } | ||
187 | |||
188 | return null; | ||
189 | } | ||
190 | |||
191 | public virtual List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query) | ||
192 | { | ||
193 | List<AvatarPickerAvatar> allPickerList = new List<AvatarPickerAvatar>(); | ||
194 | |||
195 | foreach (IUserDataPlugin plugin in m_plugins) | ||
196 | { | ||
197 | try | ||
198 | { | ||
199 | List<AvatarPickerAvatar> pickerList = plugin.GeneratePickerResults(queryID, query); | ||
200 | if (pickerList != null) | ||
201 | allPickerList.AddRange(pickerList); | ||
202 | } | ||
203 | catch (Exception) | ||
204 | { | ||
205 | m_log.Error( | ||
206 | "[USERSTORAGE]: Unable to generate AgentPickerData via " + plugin.Name + "(" + query + ")"); | ||
207 | } | ||
208 | } | ||
209 | |||
210 | return allPickerList; | ||
211 | } | ||
212 | |||
213 | public virtual bool UpdateUserProfile(UserProfileData data) | ||
214 | { | ||
215 | bool result = false; | ||
216 | |||
217 | foreach (IUserDataPlugin plugin in m_plugins) | ||
218 | { | ||
219 | try | ||
220 | { | ||
221 | plugin.UpdateUserProfile(data); | ||
222 | result = true; | ||
223 | } | ||
224 | catch (Exception e) | ||
225 | { | ||
226 | m_log.ErrorFormat( | ||
227 | "[USERSTORAGE]: Unable to set user {0} {1} via {2}: {3}", | ||
228 | data.FirstName, data.SurName, plugin.Name, e.ToString()); | ||
229 | } | ||
230 | } | ||
231 | |||
232 | return result; | ||
233 | } | ||
234 | |||
235 | #endregion | ||
236 | |||
237 | #region Get UserAgent | ||
238 | |||
239 | /// <summary> | ||
240 | /// Loads a user agent by uuid (not called directly) | ||
241 | /// </summary> | ||
242 | /// <param name="uuid">The agent's UUID</param> | ||
243 | /// <returns>Agent profiles</returns> | ||
244 | public UserAgentData GetUserAgent(UUID uuid) | ||
245 | { | ||
246 | foreach (IUserDataPlugin plugin in m_plugins) | ||
247 | { | ||
248 | try | ||
249 | { | ||
250 | UserAgentData result = plugin.GetAgentByUUID(uuid); | ||
251 | |||
252 | if (result != null) | ||
253 | return result; | ||
254 | } | ||
255 | catch (Exception e) | ||
256 | { | ||
257 | m_log.Error("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); | ||
258 | } | ||
259 | } | ||
260 | |||
261 | return null; | ||
262 | } | ||
263 | |||
264 | /// <summary> | ||
265 | /// Loads a user agent by name (not called directly) | ||
266 | /// </summary> | ||
267 | /// <param name="name">The agent's name</param> | ||
268 | /// <returns>A user agent</returns> | ||
269 | public UserAgentData GetUserAgent(string name) | ||
270 | { | ||
271 | foreach (IUserDataPlugin plugin in m_plugins) | ||
272 | { | ||
273 | try | ||
274 | { | ||
275 | UserAgentData result = plugin.GetAgentByName(name); | ||
276 | |||
277 | if (result != null) | ||
278 | return result; | ||
279 | } | ||
280 | catch (Exception e) | ||
281 | { | ||
282 | m_log.Error("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); | ||
283 | } | ||
284 | } | ||
285 | |||
286 | return null; | ||
287 | } | ||
288 | |||
289 | /// <summary> | ||
290 | /// Loads a user agent by name (not called directly) | ||
291 | /// </summary> | ||
292 | /// <param name="fname">The agent's firstname</param> | ||
293 | /// <param name="lname">The agent's lastname</param> | ||
294 | /// <returns>A user agent</returns> | ||
295 | public UserAgentData GetUserAgent(string fname, string lname) | ||
296 | { | ||
297 | foreach (IUserDataPlugin plugin in m_plugins) | ||
298 | { | ||
299 | try | ||
300 | { | ||
301 | UserAgentData result = plugin.GetAgentByName(fname, lname); | ||
302 | |||
303 | if (result != null) | ||
304 | return result; | ||
305 | } | ||
306 | catch (Exception e) | ||
307 | { | ||
308 | m_log.Error("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")"); | ||
309 | } | ||
310 | } | ||
311 | |||
312 | return null; | ||
313 | } | ||
314 | |||
315 | public virtual List<FriendListItem> GetUserFriendList(UUID ownerID) | ||
316 | { | ||
317 | List<FriendListItem> allFriends = new List<FriendListItem>(); | ||
318 | |||
319 | foreach (IUserDataPlugin plugin in m_plugins) | ||
320 | { | ||
321 | try | ||
322 | { | ||
323 | List<FriendListItem> friends = plugin.GetUserFriendList(ownerID); | ||
324 | |||
325 | if (friends != null) | ||
326 | allFriends.AddRange(friends); | ||
327 | } | ||
328 | catch (Exception e) | ||
329 | { | ||
330 | m_log.Error("[USERSTORAGE]: Unable to GetUserFriendList via " + plugin.Name + "(" + e.ToString() + ")"); | ||
331 | } | ||
332 | } | ||
333 | |||
334 | return allFriends; | ||
335 | } | ||
336 | |||
337 | public virtual Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids) | ||
338 | { | ||
339 | //Dictionary<UUID, FriendRegionInfo> allFriendRegions = new Dictionary<UUID, FriendRegionInfo>(); | ||
340 | |||
341 | foreach (IUserDataPlugin plugin in m_plugins) | ||
342 | { | ||
343 | try | ||
344 | { | ||
345 | Dictionary<UUID, FriendRegionInfo> friendRegions = plugin.GetFriendRegionInfos(uuids); | ||
346 | |||
347 | if (friendRegions != null) | ||
348 | return friendRegions; | ||
349 | } | ||
350 | catch (Exception e) | ||
351 | { | ||
352 | m_log.Error("[USERSTORAGE]: Unable to GetFriendRegionInfos via " + plugin.Name + "(" + e.ToString() + ")"); | ||
353 | } | ||
354 | } | ||
355 | |||
356 | return new Dictionary<UUID, FriendRegionInfo>(); | ||
357 | } | ||
358 | |||
359 | public void StoreWebLoginKey(UUID agentID, UUID webLoginKey) | ||
360 | { | ||
361 | foreach (IUserDataPlugin plugin in m_plugins) | ||
362 | { | ||
363 | try | ||
364 | { | ||
365 | plugin.StoreWebLoginKey(agentID, webLoginKey); | ||
366 | } | ||
367 | catch (Exception e) | ||
368 | { | ||
369 | m_log.Error("[USERSTORAGE]: Unable to Store WebLoginKey via " + plugin.Name + "(" + e.ToString() + ")"); | ||
370 | } | ||
371 | } | ||
372 | } | ||
373 | |||
374 | public virtual void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) | ||
375 | { | ||
376 | foreach (IUserDataPlugin plugin in m_plugins) | ||
377 | { | ||
378 | try | ||
379 | { | ||
380 | plugin.AddNewUserFriend(friendlistowner, friend, perms); | ||
381 | } | ||
382 | catch (Exception e) | ||
383 | { | ||
384 | m_log.Error("[USERSTORAGE]: Unable to AddNewUserFriend via " + plugin.Name + "(" + e.ToString() + ")"); | ||
385 | } | ||
386 | } | ||
387 | } | ||
388 | |||
389 | public virtual void RemoveUserFriend(UUID friendlistowner, UUID friend) | ||
390 | { | ||
391 | foreach (IUserDataPlugin plugin in m_plugins) | ||
392 | { | ||
393 | try | ||
394 | { | ||
395 | plugin.RemoveUserFriend(friendlistowner, friend); | ||
396 | } | ||
397 | catch (Exception e) | ||
398 | { | ||
399 | m_log.Error("[USERSTORAGE]: Unable to RemoveUserFriend via " + plugin.Name + "(" + e.ToString() + ")"); | ||
400 | } | ||
401 | } | ||
402 | } | ||
403 | |||
404 | public virtual void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) | ||
405 | { | ||
406 | foreach (IUserDataPlugin plugin in m_plugins) | ||
407 | { | ||
408 | try | ||
409 | { | ||
410 | plugin.UpdateUserFriendPerms(friendlistowner, friend, perms); | ||
411 | } | ||
412 | catch (Exception e) | ||
413 | { | ||
414 | m_log.Error("[USERSTORAGE]: Unable to UpdateUserFriendPerms via " + plugin.Name + "(" + e.ToString() + ")"); | ||
415 | } | ||
416 | } | ||
417 | } | ||
418 | |||
419 | /// <summary> | ||
420 | /// Resets the currentAgent in the user profile | ||
421 | /// </summary> | ||
422 | /// <param name="agentID">The agent's ID</param> | ||
423 | public virtual void ClearUserAgent(UUID agentID) | ||
424 | { | ||
425 | UserProfileData profile = GetUserProfile(agentID); | ||
426 | |||
427 | if (profile == null) | ||
428 | { | ||
429 | return; | ||
430 | } | ||
431 | |||
432 | profile.CurrentAgent = null; | ||
433 | |||
434 | UpdateUserProfile(profile); | ||
435 | } | ||
436 | |||
437 | #endregion | ||
438 | |||
439 | #region CreateAgent | ||
440 | |||
441 | /// <summary> | ||
442 | /// Creates and initialises a new user agent - make sure to use CommitAgent when done to submit to the DB | ||
443 | /// </summary> | ||
444 | /// <param name="profile">The users profile</param> | ||
445 | /// <param name="request">The users loginrequest</param> | ||
446 | public void CreateAgent(UserProfileData profile, XmlRpcRequest request) | ||
447 | { | ||
448 | //m_log.DebugFormat("[USER MANAGER]: Creating agent {0} {1}", profile.Name, profile.ID); | ||
449 | |||
450 | UserAgentData agent = new UserAgentData(); | ||
451 | |||
452 | // User connection | ||
453 | agent.AgentOnline = true; | ||
454 | |||
455 | if (request.Params.Count > 1) | ||
456 | { | ||
457 | if (request.Params[1] != null) | ||
458 | { | ||
459 | IPEndPoint RemoteIPEndPoint = (IPEndPoint)request.Params[1]; | ||
460 | agent.AgentIP = RemoteIPEndPoint.Address.ToString(); | ||
461 | agent.AgentPort = (uint)RemoteIPEndPoint.Port; | ||
462 | } | ||
463 | } | ||
464 | |||
465 | // Generate sessions | ||
466 | RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider(); | ||
467 | byte[] randDataS = new byte[16]; | ||
468 | byte[] randDataSS = new byte[16]; | ||
469 | rand.GetBytes(randDataS); | ||
470 | rand.GetBytes(randDataSS); | ||
471 | |||
472 | agent.SecureSessionID = new UUID(randDataSS, 0); | ||
473 | agent.SessionID = new UUID(randDataS, 0); | ||
474 | |||
475 | // Profile UUID | ||
476 | agent.ProfileID = profile.ID; | ||
477 | |||
478 | // Current location/position/alignment | ||
479 | if (profile.CurrentAgent != null) | ||
480 | { | ||
481 | agent.Region = profile.CurrentAgent.Region; | ||
482 | agent.Handle = profile.CurrentAgent.Handle; | ||
483 | agent.Position = profile.CurrentAgent.Position; | ||
484 | agent.LookAt = profile.CurrentAgent.LookAt; | ||
485 | } | ||
486 | else | ||
487 | { | ||
488 | agent.Region = profile.HomeRegionID; | ||
489 | agent.Handle = profile.HomeRegion; | ||
490 | agent.Position = profile.HomeLocation; | ||
491 | agent.LookAt = profile.HomeLookAt; | ||
492 | } | ||
493 | |||
494 | // What time did the user login? | ||
495 | agent.LoginTime = Util.UnixTimeSinceEpoch(); | ||
496 | agent.LogoutTime = 0; | ||
497 | |||
498 | profile.CurrentAgent = agent; | ||
499 | } | ||
500 | |||
501 | public void CreateAgent(UserProfileData profile, OSD request) | ||
502 | { | ||
503 | //m_log.DebugFormat("[USER MANAGER]: Creating agent {0} {1}", profile.Name, profile.ID); | ||
504 | |||
505 | UserAgentData agent = new UserAgentData(); | ||
506 | |||
507 | // User connection | ||
508 | agent.AgentOnline = true; | ||
509 | |||
510 | //if (request.Params.Count > 1) | ||
511 | //{ | ||
512 | // IPEndPoint RemoteIPEndPoint = (IPEndPoint)request.Params[1]; | ||
513 | // agent.AgentIP = RemoteIPEndPoint.Address.ToString(); | ||
514 | // agent.AgentPort = (uint)RemoteIPEndPoint.Port; | ||
515 | //} | ||
516 | |||
517 | // Generate sessions | ||
518 | RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider(); | ||
519 | byte[] randDataS = new byte[16]; | ||
520 | byte[] randDataSS = new byte[16]; | ||
521 | rand.GetBytes(randDataS); | ||
522 | rand.GetBytes(randDataSS); | ||
523 | |||
524 | agent.SecureSessionID = new UUID(randDataSS, 0); | ||
525 | agent.SessionID = new UUID(randDataS, 0); | ||
526 | |||
527 | // Profile UUID | ||
528 | agent.ProfileID = profile.ID; | ||
529 | |||
530 | // Current location/position/alignment | ||
531 | if (profile.CurrentAgent != null) | ||
532 | { | ||
533 | agent.Region = profile.CurrentAgent.Region; | ||
534 | agent.Handle = profile.CurrentAgent.Handle; | ||
535 | agent.Position = profile.CurrentAgent.Position; | ||
536 | agent.LookAt = profile.CurrentAgent.LookAt; | ||
537 | } | ||
538 | else | ||
539 | { | ||
540 | agent.Region = profile.HomeRegionID; | ||
541 | agent.Handle = profile.HomeRegion; | ||
542 | agent.Position = profile.HomeLocation; | ||
543 | agent.LookAt = profile.HomeLookAt; | ||
544 | } | ||
545 | |||
546 | // What time did the user login? | ||
547 | agent.LoginTime = Util.UnixTimeSinceEpoch(); | ||
548 | agent.LogoutTime = 0; | ||
549 | |||
550 | profile.CurrentAgent = agent; | ||
551 | } | ||
552 | |||
553 | /// <summary> | ||
554 | /// Saves a target agent to the database | ||
555 | /// </summary> | ||
556 | /// <param name="profile">The users profile</param> | ||
557 | /// <returns>Successful?</returns> | ||
558 | public bool CommitAgent(ref UserProfileData profile) | ||
559 | { | ||
560 | //m_log.DebugFormat("[USER MANAGER]: Committing agent {0} {1}", profile.Name, profile.ID); | ||
561 | |||
562 | // TODO: how is this function different from setUserProfile? -> Add AddUserAgent() here and commit both tables "users" and "agents" | ||
563 | // TODO: what is the logic should be? | ||
564 | bool ret = false; | ||
565 | ret = AddUserAgent(profile.CurrentAgent); | ||
566 | ret = ret & UpdateUserProfile(profile); | ||
567 | return ret; | ||
568 | } | ||
569 | |||
570 | /// <summary> | ||
571 | /// Process a user logoff from OpenSim. | ||
572 | /// </summary> | ||
573 | /// <param name="userid"></param> | ||
574 | /// <param name="regionid"></param> | ||
575 | /// <param name="regionhandle"></param> | ||
576 | /// <param name="position"></param> | ||
577 | /// <param name="lookat"></param> | ||
578 | public virtual void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) | ||
579 | { | ||
580 | if (StatsManager.UserStats != null) | ||
581 | StatsManager.UserStats.AddLogout(); | ||
582 | |||
583 | UserProfileData userProfile = GetUserProfile(userid); | ||
584 | |||
585 | if (userProfile != null) | ||
586 | { | ||
587 | UserAgentData userAgent = userProfile.CurrentAgent; | ||
588 | if (userAgent != null) | ||
589 | { | ||
590 | userAgent.AgentOnline = false; | ||
591 | userAgent.LogoutTime = Util.UnixTimeSinceEpoch(); | ||
592 | //userAgent.sessionID = UUID.Zero; | ||
593 | if (regionid != UUID.Zero) | ||
594 | { | ||
595 | userAgent.Region = regionid; | ||
596 | } | ||
597 | userAgent.Handle = regionhandle; | ||
598 | userAgent.Position = position; | ||
599 | userAgent.LookAt = lookat; | ||
600 | //userProfile.CurrentAgent = userAgent; | ||
601 | userProfile.LastLogin = userAgent.LogoutTime; | ||
602 | |||
603 | CommitAgent(ref userProfile); | ||
604 | } | ||
605 | else | ||
606 | { | ||
607 | // If currentagent is null, we can't reference it here or the UserServer crashes! | ||
608 | m_log.Info("[LOGOUT]: didn't save logout position: " + userid.ToString()); | ||
609 | } | ||
610 | } | ||
611 | else | ||
612 | { | ||
613 | m_log.Warn("[LOGOUT]: Unknown User logged out"); | ||
614 | } | ||
615 | } | ||
616 | |||
617 | public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) | ||
618 | { | ||
619 | LogOffUser(userid, regionid, regionhandle, new Vector3(posx, posy, posz), new Vector3()); | ||
620 | } | ||
621 | |||
622 | #endregion | ||
623 | |||
624 | /// <summary> | ||
625 | /// Add a new user | ||
626 | /// </summary> | ||
627 | /// <param name="firstName">first name</param> | ||
628 | /// <param name="lastName">last name</param> | ||
629 | /// <param name="password">password</param> | ||
630 | /// <param name="email">email</param> | ||
631 | /// <param name="regX">location X</param> | ||
632 | /// <param name="regY">location Y</param> | ||
633 | /// <returns>The UUID of the created user profile. On failure, returns UUID.Zero</returns> | ||
634 | public virtual UUID AddUser(string firstName, string lastName, string password, string email, uint regX, uint regY) | ||
635 | { | ||
636 | return AddUser(firstName, lastName, password, email, regX, regY, UUID.Random()); | ||
637 | } | ||
638 | |||
639 | /// <summary> | ||
640 | /// Add a new user | ||
641 | /// </summary> | ||
642 | /// <param name="firstName">first name</param> | ||
643 | /// <param name="lastName">last name</param> | ||
644 | /// <param name="password">password</param> | ||
645 | /// <param name="email">email</param> | ||
646 | /// <param name="regX">location X</param> | ||
647 | /// <param name="regY">location Y</param> | ||
648 | /// <param name="SetUUID">UUID of avatar.</param> | ||
649 | /// <returns>The UUID of the created user profile. On failure, returns UUID.Zero</returns> | ||
650 | public virtual UUID AddUser( | ||
651 | string firstName, string lastName, string password, string email, uint regX, uint regY, UUID SetUUID) | ||
652 | { | ||
653 | |||
654 | UserProfileData user = new UserProfileData(); | ||
655 | |||
656 | user.PasswordSalt = Util.Md5Hash(UUID.Random().ToString()); | ||
657 | string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + user.PasswordSalt); | ||
658 | |||
659 | user.HomeLocation = new Vector3(128, 128, 100); | ||
660 | user.ID = SetUUID; | ||
661 | user.FirstName = firstName; | ||
662 | user.SurName = lastName; | ||
663 | user.PasswordHash = md5PasswdHash; | ||
664 | user.Created = Util.UnixTimeSinceEpoch(); | ||
665 | user.HomeLookAt = new Vector3(100, 100, 100); | ||
666 | user.HomeRegionX = regX; | ||
667 | user.HomeRegionY = regY; | ||
668 | user.Email = email; | ||
669 | |||
670 | foreach (IUserDataPlugin plugin in m_plugins) | ||
671 | { | ||
672 | try | ||
673 | { | ||
674 | plugin.AddNewUserProfile(user); | ||
675 | } | ||
676 | catch (Exception e) | ||
677 | { | ||
678 | m_log.Error("[USERSTORAGE]: Unable to add user via " + plugin.Name + "(" + e.ToString() + ")"); | ||
679 | } | ||
680 | } | ||
681 | |||
682 | UserProfileData userProf = GetUserProfile(firstName, lastName); | ||
683 | if (userProf == null) | ||
684 | { | ||
685 | return UUID.Zero; | ||
686 | } | ||
687 | else | ||
688 | { | ||
689 | // | ||
690 | // WARNING: This is a horrible hack | ||
691 | // The purpose here is to avoid touching the user server at this point. | ||
692 | // There are dragons there that I can't deal with right now. | ||
693 | // diva 06/09/09 | ||
694 | // | ||
695 | if (m_InventoryService != null) | ||
696 | { | ||
697 | // local service (standalone) | ||
698 | m_log.Debug("[USERSTORAGE]: using IInventoryService to create user's inventory"); | ||
699 | m_InventoryService.CreateUserInventory(userProf.ID); | ||
700 | } | ||
701 | else if (m_commsManager.InterServiceInventoryService != null) | ||
702 | { | ||
703 | // used by the user server | ||
704 | m_log.Debug("[USERSTORAGE]: using m_commsManager.InterServiceInventoryService to create user's inventory"); | ||
705 | m_commsManager.InterServiceInventoryService.CreateNewUserInventory(userProf.ID); | ||
706 | } | ||
707 | |||
708 | return userProf.ID; | ||
709 | } | ||
710 | } | ||
711 | |||
712 | /// <summary> | ||
713 | /// Reset a user password. | ||
714 | /// </summary> | ||
715 | /// <param name="firstName"></param> | ||
716 | /// <param name="lastName"></param> | ||
717 | /// <param name="newPassword"></param> | ||
718 | /// <returns>true if the update was successful, false otherwise</returns> | ||
719 | public virtual bool ResetUserPassword(string firstName, string lastName, string newPassword) | ||
720 | { | ||
721 | string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(newPassword) + ":" + String.Empty); | ||
722 | |||
723 | UserProfileData profile = GetUserProfile(firstName, lastName); | ||
724 | |||
725 | if (null == profile) | ||
726 | { | ||
727 | m_log.ErrorFormat("[USERSTORAGE]: Could not find user {0} {1}", firstName, lastName); | ||
728 | return false; | ||
729 | } | ||
730 | |||
731 | profile.PasswordHash = md5PasswdHash; | ||
732 | profile.PasswordSalt = String.Empty; | ||
733 | |||
734 | UpdateUserProfile(profile); | ||
735 | |||
736 | return true; | ||
737 | } | ||
738 | |||
739 | public abstract UserProfileData SetupMasterUser(string firstName, string lastName); | ||
740 | public abstract UserProfileData SetupMasterUser(string firstName, string lastName, string password); | ||
741 | public abstract UserProfileData SetupMasterUser(UUID uuid); | ||
742 | |||
743 | /// <summary> | ||
744 | /// Add an agent using data plugins. | ||
745 | /// </summary> | ||
746 | /// <param name="agentdata">The agent data to be added</param> | ||
747 | /// <returns> | ||
748 | /// true if at least one plugin added the user agent. false if no plugin successfully added the agent | ||
749 | /// </returns> | ||
750 | public virtual bool AddUserAgent(UserAgentData agentdata) | ||
751 | { | ||
752 | bool result = false; | ||
753 | |||
754 | foreach (IUserDataPlugin plugin in m_plugins) | ||
755 | { | ||
756 | try | ||
757 | { | ||
758 | plugin.AddNewUserAgent(agentdata); | ||
759 | result = true; | ||
760 | } | ||
761 | catch (Exception e) | ||
762 | { | ||
763 | m_log.Error("[USERSTORAGE]: Unable to add agent via " + plugin.Name + "(" + e.ToString() + ")"); | ||
764 | } | ||
765 | } | ||
766 | |||
767 | return result; | ||
768 | } | ||
769 | |||
770 | /// <summary> | ||
771 | /// Get avatar appearance information | ||
772 | /// </summary> | ||
773 | /// <param name="user"></param> | ||
774 | /// <returns></returns> | ||
775 | public virtual AvatarAppearance GetUserAppearance(UUID user) | ||
776 | { | ||
777 | foreach (IUserDataPlugin plugin in m_plugins) | ||
778 | { | ||
779 | try | ||
780 | { | ||
781 | AvatarAppearance appearance = plugin.GetUserAppearance(user); | ||
782 | |||
783 | if (appearance != null) | ||
784 | return appearance; | ||
785 | } | ||
786 | catch (Exception e) | ||
787 | { | ||
788 | m_log.ErrorFormat( | ||
789 | "[USERSTORAGE]: Unable to find user appearance {0} via {1} ({2})", user, plugin.Name, e); | ||
790 | } | ||
791 | } | ||
792 | |||
793 | return null; | ||
794 | } | ||
795 | |||
796 | public virtual void UpdateUserAppearance(UUID user, AvatarAppearance appearance) | ||
797 | { | ||
798 | foreach (IUserDataPlugin plugin in m_plugins) | ||
799 | { | ||
800 | try | ||
801 | { | ||
802 | plugin.UpdateUserAppearance(user, appearance); | ||
803 | } | ||
804 | catch (Exception e) | ||
805 | { | ||
806 | m_log.ErrorFormat("[USERSTORAGE]: Unable to update user appearance {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString()); | ||
807 | } | ||
808 | } | ||
809 | } | ||
810 | |||
811 | #region IAuthentication | ||
812 | |||
813 | protected Dictionary<UUID, List<string>> m_userKeys = new Dictionary<UUID, List<string>>(); | ||
814 | |||
815 | /// <summary> | ||
816 | /// This generates authorization keys in the form | ||
817 | /// http://userserver/uuid | ||
818 | /// after verifying that the caller is, indeed, authorized to request a key | ||
819 | /// </summary> | ||
820 | /// <param name="url">URL of the user server</param> | ||
821 | /// <param name="userID">The user ID requesting the new key</param> | ||
822 | /// <param name="authToken">The original authorization token for that user, obtained during login</param> | ||
823 | /// <returns></returns> | ||
824 | public string GetNewKey(string url, UUID userID, UUID authToken) | ||
825 | { | ||
826 | UserProfileData profile = GetUserProfile(userID); | ||
827 | string newKey = string.Empty; | ||
828 | if (!url.EndsWith("/")) | ||
829 | url = url + "/"; | ||
830 | |||
831 | if (profile != null) | ||
832 | { | ||
833 | // I'm overloading webloginkey for this, so that no changes are needed in the DB | ||
834 | // The uses of webloginkey are fairly mutually exclusive | ||
835 | if (profile.WebLoginKey.Equals(authToken)) | ||
836 | { | ||
837 | newKey = UUID.Random().ToString(); | ||
838 | List<string> keys; | ||
839 | lock (m_userKeys) | ||
840 | { | ||
841 | if (m_userKeys.ContainsKey(userID)) | ||
842 | { | ||
843 | keys = m_userKeys[userID]; | ||
844 | } | ||
845 | else | ||
846 | { | ||
847 | keys = new List<string>(); | ||
848 | m_userKeys.Add(userID, keys); | ||
849 | } | ||
850 | keys.Add(newKey); | ||
851 | } | ||
852 | m_log.InfoFormat("[USERAUTH]: Successfully generated new auth key for user {0}", userID); | ||
853 | } | ||
854 | else | ||
855 | m_log.Warn("[USERAUTH]: Unauthorized key generation request. Denying new key."); | ||
856 | } | ||
857 | else | ||
858 | m_log.Warn("[USERAUTH]: User not found."); | ||
859 | |||
860 | return url + newKey; | ||
861 | } | ||
862 | |||
863 | /// <summary> | ||
864 | /// This verifies the uuid portion of the key given out by GenerateKey | ||
865 | /// </summary> | ||
866 | /// <param name="userID"></param> | ||
867 | /// <param name="key"></param> | ||
868 | /// <returns></returns> | ||
869 | public bool VerifyKey(UUID userID, string key) | ||
870 | { | ||
871 | lock (m_userKeys) | ||
872 | { | ||
873 | if (m_userKeys.ContainsKey(userID)) | ||
874 | { | ||
875 | List<string> keys = m_userKeys[userID]; | ||
876 | if (keys.Contains(key)) | ||
877 | { | ||
878 | // Keys are one-time only, so remove it | ||
879 | keys.Remove(key); | ||
880 | return true; | ||
881 | } | ||
882 | return false; | ||
883 | } | ||
884 | else | ||
885 | return false; | ||
886 | } | ||
887 | } | ||
888 | |||
889 | public virtual bool VerifySession(UUID userID, UUID sessionID) | ||
890 | { | ||
891 | UserProfileData userProfile = GetUserProfile(userID); | ||
892 | |||
893 | if (userProfile != null && userProfile.CurrentAgent != null) | ||
894 | { | ||
895 | m_log.DebugFormat( | ||
896 | "[USER AUTH]: Verifying session {0} for {1}; current session {2}", | ||
897 | sessionID, userID, userProfile.CurrentAgent.SessionID); | ||
898 | |||
899 | if (userProfile.CurrentAgent.SessionID == sessionID) | ||
900 | { | ||
901 | return true; | ||
902 | } | ||
903 | } | ||
904 | |||
905 | return false; | ||
906 | } | ||
907 | |||
908 | public virtual bool AuthenticateUserByPassword(UUID userID, string password) | ||
909 | { | ||
910 | // m_log.DebugFormat("[USER AUTH]: Authenticating user {0} given password {1}", userID, password); | ||
911 | |||
912 | UserProfileData userProfile = GetUserProfile(userID); | ||
913 | |||
914 | if (null == userProfile) | ||
915 | return false; | ||
916 | |||
917 | string md5PasswordHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + userProfile.PasswordSalt); | ||
918 | |||
919 | // m_log.DebugFormat( | ||
920 | // "[USER AUTH]: Submitted hash {0}, stored hash {1}", md5PasswordHash, userProfile.PasswordHash); | ||
921 | |||
922 | if (md5PasswordHash == userProfile.PasswordHash) | ||
923 | return true; | ||
924 | else | ||
925 | return false; | ||
926 | } | ||
927 | |||
928 | #endregion | ||
929 | } | ||
930 | } | ||
diff --git a/OpenSim/Framework/ConfigSettings.cs b/OpenSim/Framework/ConfigSettings.cs index 32415e0..8feaa37 100644 --- a/OpenSim/Framework/ConfigSettings.cs +++ b/OpenSim/Framework/ConfigSettings.cs | |||
@@ -44,14 +44,6 @@ namespace OpenSim.Framework | |||
44 | set { m_meshEngineName = value; } | 44 | set { m_meshEngineName = value; } |
45 | } | 45 | } |
46 | 46 | ||
47 | private bool m_standalone; | ||
48 | |||
49 | public bool Standalone | ||
50 | { | ||
51 | get { return m_standalone; } | ||
52 | set { m_standalone = value; } | ||
53 | } | ||
54 | |||
55 | private bool m_see_into_region_from_neighbor; | 47 | private bool m_see_into_region_from_neighbor; |
56 | 48 | ||
57 | public bool See_into_region_from_neighbor | 49 | public bool See_into_region_from_neighbor |
@@ -163,7 +155,6 @@ namespace OpenSim.Framework | |||
163 | 155 | ||
164 | public const uint DefaultAssetServerHttpPort = 8003; | 156 | public const uint DefaultAssetServerHttpPort = 8003; |
165 | public const uint DefaultRegionHttpPort = 9000; | 157 | public const uint DefaultRegionHttpPort = 9000; |
166 | public static uint DefaultRegionRemotingPort = 8895; // This is actually assigned to, but then again, the remoting is obsolete, right? | ||
167 | public const uint DefaultUserServerHttpPort = 8002; | 158 | public const uint DefaultUserServerHttpPort = 8002; |
168 | public const bool DefaultUserServerHttpSSL = false; | 159 | public const bool DefaultUserServerHttpSSL = false; |
169 | public const uint DefaultMessageServerHttpPort = 8006; | 160 | public const uint DefaultMessageServerHttpPort = 8006; |
diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index b7e191b..be936b6 100644 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs | |||
@@ -38,7 +38,7 @@ namespace OpenSim.Framework.Console | |||
38 | { | 38 | { |
39 | /// <summary> | 39 | /// <summary> |
40 | /// A console that uses cursor control and color | 40 | /// A console that uses cursor control and color |
41 | /// </summary> | 41 | /// </summary> |
42 | public class LocalConsole : CommandConsole | 42 | public class LocalConsole : CommandConsole |
43 | { | 43 | { |
44 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -100,8 +100,8 @@ namespace OpenSim.Framework.Console | |||
100 | private int SetCursorTop(int top) | 100 | private int SetCursorTop(int top) |
101 | { | 101 | { |
102 | // From at least mono 2.4.2.3, window resizing can give mono an invalid row and column values. If we try | 102 | // From at least mono 2.4.2.3, window resizing can give mono an invalid row and column values. If we try |
103 | // to set a cursor row position with a currently invalid column, mono will throw an exception. | 103 | // to set a cursor row position with a currently invalid column, mono will throw an exception. |
104 | // Therefore, we need to make sure that the column position is valid first. | 104 | // Therefore, we need to make sure that the column position is valid first. |
105 | int left = System.Console.CursorLeft; | 105 | int left = System.Console.CursorLeft; |
106 | 106 | ||
107 | if (left < 0) | 107 | if (left < 0) |
@@ -129,12 +129,12 @@ namespace OpenSim.Framework.Console | |||
129 | /// </param> | 129 | /// </param> |
130 | /// <returns> | 130 | /// <returns> |
131 | /// The new cursor column. | 131 | /// The new cursor column. |
132 | /// </returns> | 132 | /// </returns> |
133 | private int SetCursorLeft(int left) | 133 | private int SetCursorLeft(int left) |
134 | { | 134 | { |
135 | // From at least mono 2.4.2.3, window resizing can give mono an invalid row and column values. If we try | 135 | // From at least mono 2.4.2.3, window resizing can give mono an invalid row and column values. If we try |
136 | // to set a cursor column position with a currently invalid row, mono will throw an exception. | 136 | // to set a cursor column position with a currently invalid row, mono will throw an exception. |
137 | // Therefore, we need to make sure that the row position is valid first. | 137 | // Therefore, we need to make sure that the row position is valid first. |
138 | int top = System.Console.CursorTop; | 138 | int top = System.Console.CursorTop; |
139 | 139 | ||
140 | if (top < 0) | 140 | if (top < 0) |
@@ -183,7 +183,7 @@ namespace OpenSim.Framework.Console | |||
183 | System.Console.Write("{0}", prompt); | 183 | System.Console.Write("{0}", prompt); |
184 | 184 | ||
185 | SetCursorTop(new_y); | 185 | SetCursorTop(new_y); |
186 | SetCursorLeft(new_x); | 186 | SetCursorLeft(new_x); |
187 | } | 187 | } |
188 | } | 188 | } |
189 | 189 | ||
diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index 9fdd1b8..6f8348d 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs | |||
@@ -302,9 +302,9 @@ namespace OpenSim.Framework.Console | |||
302 | if (!UUID.TryParse(post["ID"].ToString(), out id)) | 302 | if (!UUID.TryParse(post["ID"].ToString(), out id)) |
303 | return reply; | 303 | return reply; |
304 | 304 | ||
305 | lock(m_Connections) | 305 | lock (m_Connections) |
306 | { | 306 | { |
307 | if(!m_Connections.ContainsKey(id)) | 307 | if (!m_Connections.ContainsKey(id)) |
308 | return reply; | 308 | return reply; |
309 | } | 309 | } |
310 | 310 | ||
diff --git a/OpenSim/Framework/FriendListItem.cs b/OpenSim/Framework/FriendListItem.cs index 39e2363..a02ec7f 100644 --- a/OpenSim/Framework/FriendListItem.cs +++ b/OpenSim/Framework/FriendListItem.cs | |||
@@ -39,7 +39,5 @@ namespace OpenSim.Framework | |||
39 | 39 | ||
40 | // These are what the friend gives the listowner permission to do | 40 | // These are what the friend gives the listowner permission to do |
41 | public uint FriendPerms; | 41 | public uint FriendPerms; |
42 | |||
43 | public bool onlinestatus = false; | ||
44 | } | 42 | } |
45 | } | 43 | } |
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 9127054..7219bf8 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs | |||
@@ -93,6 +93,8 @@ namespace OpenSim.Framework | |||
93 | 93 | ||
94 | public delegate void SetAlwaysRun(IClientAPI remoteClient, bool SetAlwaysRun); | 94 | public delegate void SetAlwaysRun(IClientAPI remoteClient, bool SetAlwaysRun); |
95 | 95 | ||
96 | public delegate void GenericCall1(IClientAPI remoteClient); | ||
97 | |||
96 | public delegate void GenericCall2(); | 98 | public delegate void GenericCall2(); |
97 | 99 | ||
98 | // really don't want to be passing packets in these events, so this is very temporary. | 100 | // really don't want to be passing packets in these events, so this is very temporary. |
@@ -152,6 +154,8 @@ namespace OpenSim.Framework | |||
152 | 154 | ||
153 | public delegate void AgentSit(IClientAPI remoteClient, UUID agentID); | 155 | public delegate void AgentSit(IClientAPI remoteClient, UUID agentID); |
154 | 156 | ||
157 | public delegate void LandUndo(IClientAPI remoteClient); | ||
158 | |||
155 | public delegate void AvatarPickerRequest(IClientAPI remoteClient, UUID agentdata, UUID queryID, string UserQuery); | 159 | public delegate void AvatarPickerRequest(IClientAPI remoteClient, UUID agentdata, UUID queryID, string UserQuery); |
156 | 160 | ||
157 | public delegate void GrabObject( | 161 | public delegate void GrabObject( |
@@ -419,9 +423,9 @@ namespace OpenSim.Framework | |||
419 | public delegate void AcceptCallingCard(IClientAPI remoteClient, UUID transactionID, UUID folderID); | 423 | public delegate void AcceptCallingCard(IClientAPI remoteClient, UUID transactionID, UUID folderID); |
420 | 424 | ||
421 | public delegate void DeclineCallingCard(IClientAPI remoteClient, UUID transactionID); | 425 | public delegate void DeclineCallingCard(IClientAPI remoteClient, UUID transactionID); |
422 | 426 | ||
423 | public delegate void SoundTrigger( | 427 | public delegate void SoundTrigger( |
424 | UUID soundId, UUID ownerid, UUID objid, UUID parentid, double Gain, Vector3 Position, UInt64 Handle); | 428 | UUID soundId, UUID ownerid, UUID objid, UUID parentid, double Gain, Vector3 Position, UInt64 Handle, float radius); |
425 | 429 | ||
426 | public delegate void StartLure(byte lureType, string message, UUID targetID, IClientAPI client); | 430 | public delegate void StartLure(byte lureType, string message, UUID targetID, IClientAPI client); |
427 | public delegate void TeleportLureRequest(UUID lureID, uint teleportFlags, IClientAPI client); | 431 | public delegate void TeleportLureRequest(UUID lureID, uint teleportFlags, IClientAPI client); |
@@ -826,6 +830,11 @@ namespace OpenSim.Framework | |||
826 | /// </value> | 830 | /// </value> |
827 | bool IsActive { get; set; } | 831 | bool IsActive { get; set; } |
828 | 832 | ||
833 | /// <value> | ||
834 | /// Determines whether the client is logging out or not. | ||
835 | /// </value> | ||
836 | bool IsLoggingOut { get; set; } | ||
837 | |||
829 | bool SendLogoutPacketWhenClosing { set; } | 838 | bool SendLogoutPacketWhenClosing { set; } |
830 | 839 | ||
831 | // [Obsolete("LLClientView Specific - Circuits are unique to LLClientView")] | 840 | // [Obsolete("LLClientView Specific - Circuits are unique to LLClientView")] |
@@ -871,7 +880,7 @@ namespace OpenSim.Framework | |||
871 | event DeRezObject OnDeRezObject; | 880 | event DeRezObject OnDeRezObject; |
872 | event Action<IClientAPI> OnRegionHandShakeReply; | 881 | event Action<IClientAPI> OnRegionHandShakeReply; |
873 | event GenericCall2 OnRequestWearables; | 882 | event GenericCall2 OnRequestWearables; |
874 | event GenericCall2 OnCompleteMovementToRegion; | 883 | event GenericCall1 OnCompleteMovementToRegion; |
875 | event UpdateAgent OnAgentUpdate; | 884 | event UpdateAgent OnAgentUpdate; |
876 | event AgentRequestSit OnAgentRequestSit; | 885 | event AgentRequestSit OnAgentRequestSit; |
877 | event AgentSit OnAgentSit; | 886 | event AgentSit OnAgentSit; |
@@ -988,6 +997,8 @@ namespace OpenSim.Framework | |||
988 | event ScriptAnswer OnScriptAnswer; | 997 | event ScriptAnswer OnScriptAnswer; |
989 | 998 | ||
990 | event AgentSit OnUndo; | 999 | event AgentSit OnUndo; |
1000 | event AgentSit OnRedo; | ||
1001 | event LandUndo OnLandUndo; | ||
991 | 1002 | ||
992 | event ForceReleaseControls OnForceReleaseControls; | 1003 | event ForceReleaseControls OnForceReleaseControls; |
993 | event GodLandStatRequest OnLandStatRequest; | 1004 | event GodLandStatRequest OnLandStatRequest; |
@@ -1467,5 +1478,6 @@ namespace OpenSim.Framework | |||
1467 | 1478 | ||
1468 | void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID,int amt); | 1479 | void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID,int amt); |
1469 | 1480 | ||
1481 | void SendChangeUserRights(UUID agentID, UUID friendID, int rights); | ||
1470 | } | 1482 | } |
1471 | } | 1483 | } |
diff --git a/OpenSim/Framework/IProfileModule.cs b/OpenSim/Framework/IProfileModule.cs deleted file mode 100644 index f54810e..0000000 --- a/OpenSim/Framework/IProfileModule.cs +++ /dev/null | |||
@@ -1,37 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System.Collections; | ||
29 | using OpenMetaverse; | ||
30 | |||
31 | namespace OpenSim.Framework | ||
32 | { | ||
33 | public interface IProfileModule | ||
34 | { | ||
35 | Hashtable GetProfileData(UUID userID); | ||
36 | } | ||
37 | } | ||
diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs index 8067052..27b3d47 100644 --- a/OpenSim/Framework/IScene.cs +++ b/OpenSim/Framework/IScene.cs | |||
@@ -66,6 +66,8 @@ namespace OpenSim.Framework | |||
66 | 66 | ||
67 | float TimeDilation { get; } | 67 | float TimeDilation { get; } |
68 | 68 | ||
69 | bool AllowScriptCrossings { get; } | ||
70 | |||
69 | event restart OnRestart; | 71 | event restart OnRestart; |
70 | 72 | ||
71 | void AddNewClient(IClientAPI client); | 73 | void AddNewClient(IClientAPI client); |
@@ -96,5 +98,7 @@ namespace OpenSim.Framework | |||
96 | void StackModuleInterface<M>(M mod); | 98 | void StackModuleInterface<M>(M mod); |
97 | 99 | ||
98 | void AddCommand(object module, string command, string shorthelp, string longhelp, CommandDelegate callback); | 100 | void AddCommand(object module, string command, string shorthelp, string longhelp, CommandDelegate callback); |
101 | |||
102 | ISceneObject DeserializeObject(string representation); | ||
99 | } | 103 | } |
100 | } | 104 | } |
diff --git a/OpenSim/Framework/LandData.cs b/OpenSim/Framework/LandData.cs index 071a667..060e886 100644 --- a/OpenSim/Framework/LandData.cs +++ b/OpenSim/Framework/LandData.cs | |||
@@ -358,6 +358,32 @@ namespace OpenSim.Framework | |||
358 | } | 358 | } |
359 | } | 359 | } |
360 | 360 | ||
361 | private int[] _mediaSize = new int[2]; | ||
362 | public int[] MediaSize | ||
363 | { | ||
364 | get | ||
365 | { | ||
366 | return _mediaSize; | ||
367 | } | ||
368 | set | ||
369 | { | ||
370 | _mediaSize = value; | ||
371 | } | ||
372 | } | ||
373 | |||
374 | private string _mediaType = ""; | ||
375 | public string MediaType | ||
376 | { | ||
377 | get | ||
378 | { | ||
379 | return _mediaType; | ||
380 | } | ||
381 | set | ||
382 | { | ||
383 | _mediaType = value; | ||
384 | } | ||
385 | } | ||
386 | |||
361 | /// <summary> | 387 | /// <summary> |
362 | /// URL to the shoutcast music stream to play on the parcel | 388 | /// URL to the shoutcast music stream to play on the parcel |
363 | /// </summary> | 389 | /// </summary> |
diff --git a/OpenSim/Framework/NetworkServersInfo.cs b/OpenSim/Framework/NetworkServersInfo.cs index f720222..b25f8b9 100644 --- a/OpenSim/Framework/NetworkServersInfo.cs +++ b/OpenSim/Framework/NetworkServersInfo.cs | |||
@@ -42,8 +42,6 @@ namespace OpenSim.Framework | |||
42 | public string InventoryURL = String.Empty; | 42 | public string InventoryURL = String.Empty; |
43 | public bool secureInventoryServer = false; | 43 | public bool secureInventoryServer = false; |
44 | public bool isSandbox; | 44 | public bool isSandbox; |
45 | private uint? m_defaultHomeLocX; | ||
46 | private uint? m_defaultHomeLocY; | ||
47 | public string UserRecvKey = String.Empty; | 45 | public string UserRecvKey = String.Empty; |
48 | public string UserSendKey = String.Empty; | 46 | public string UserSendKey = String.Empty; |
49 | public string UserURL = String.Empty; | 47 | public string UserURL = String.Empty; |
@@ -59,24 +57,11 @@ namespace OpenSim.Framework | |||
59 | 57 | ||
60 | public NetworkServersInfo(uint defaultHomeLocX, uint defaultHomeLocY) | 58 | public NetworkServersInfo(uint defaultHomeLocX, uint defaultHomeLocY) |
61 | { | 59 | { |
62 | m_defaultHomeLocX = defaultHomeLocX; | ||
63 | m_defaultHomeLocY = defaultHomeLocY; | ||
64 | } | 60 | } |
65 | 61 | ||
66 | public uint DefaultHomeLocX | ||
67 | { | ||
68 | get { return m_defaultHomeLocX.Value; } | ||
69 | } | ||
70 | |||
71 | public uint DefaultHomeLocY | ||
72 | { | ||
73 | get { return m_defaultHomeLocY.Value; } | ||
74 | } | ||
75 | 62 | ||
76 | public void loadFromConfiguration(IConfigSource config) | 63 | public void loadFromConfiguration(IConfigSource config) |
77 | { | 64 | { |
78 | m_defaultHomeLocX = (uint) config.Configs["StandAlone"].GetInt("default_location_x", 1000); | ||
79 | m_defaultHomeLocY = (uint) config.Configs["StandAlone"].GetInt("default_location_y", 1000); | ||
80 | 65 | ||
81 | HttpListenerPort = | 66 | HttpListenerPort = |
82 | (uint) config.Configs["Network"].GetInt("http_listener_port", (int) ConfigSettings.DefaultRegionHttpPort); | 67 | (uint) config.Configs["Network"].GetInt("http_listener_port", (int) ConfigSettings.DefaultRegionHttpPort); |
@@ -84,8 +69,6 @@ namespace OpenSim.Framework | |||
84 | (uint)config.Configs["Network"].GetInt("http_listener_sslport", ((int)ConfigSettings.DefaultRegionHttpPort+1)); | 69 | (uint)config.Configs["Network"].GetInt("http_listener_sslport", ((int)ConfigSettings.DefaultRegionHttpPort+1)); |
85 | HttpUsesSSL = config.Configs["Network"].GetBoolean("http_listener_ssl", false); | 70 | HttpUsesSSL = config.Configs["Network"].GetBoolean("http_listener_ssl", false); |
86 | HttpSSLCN = config.Configs["Network"].GetString("http_listener_cn", "localhost"); | 71 | HttpSSLCN = config.Configs["Network"].GetString("http_listener_cn", "localhost"); |
87 | ConfigSettings.DefaultRegionRemotingPort = | ||
88 | (uint) config.Configs["Network"].GetInt("remoting_listener_port", (int) ConfigSettings.DefaultRegionRemotingPort); | ||
89 | GridURL = | 72 | GridURL = |
90 | config.Configs["Network"].GetString("grid_server_url", | 73 | config.Configs["Network"].GetString("grid_server_url", |
91 | "http://127.0.0.1:" + ConfigSettings.DefaultGridServerHttpPort.ToString()); | 74 | "http://127.0.0.1:" + ConfigSettings.DefaultGridServerHttpPort.ToString()); |
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index fe8f020..6a38278 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs | |||
@@ -188,6 +188,40 @@ namespace OpenSim.Framework | |||
188 | m_textureEntry = DEFAULT_TEXTURE; | 188 | m_textureEntry = DEFAULT_TEXTURE; |
189 | } | 189 | } |
190 | 190 | ||
191 | public PrimitiveBaseShape(Primitive prim) | ||
192 | { | ||
193 | PCode = (byte)prim.PrimData.PCode; | ||
194 | ExtraParams = new byte[1]; | ||
195 | |||
196 | State = prim.PrimData.State; | ||
197 | PathBegin = Primitive.PackBeginCut(prim.PrimData.PathBegin); | ||
198 | PathEnd = Primitive.PackEndCut(prim.PrimData.PathEnd); | ||
199 | PathScaleX = Primitive.PackPathScale(prim.PrimData.PathScaleX); | ||
200 | PathScaleY = Primitive.PackPathScale(prim.PrimData.PathScaleY); | ||
201 | PathShearX = (byte)Primitive.PackPathShear(prim.PrimData.PathShearX); | ||
202 | PathShearY = (byte)Primitive.PackPathShear(prim.PrimData.PathShearY); | ||
203 | PathSkew = Primitive.PackPathTwist(prim.PrimData.PathSkew); | ||
204 | ProfileBegin = Primitive.PackBeginCut(prim.PrimData.ProfileBegin); | ||
205 | ProfileEnd = Primitive.PackEndCut(prim.PrimData.ProfileEnd); | ||
206 | Scale = prim.Scale; | ||
207 | PathCurve = (byte)prim.PrimData.PathCurve; | ||
208 | ProfileCurve = (byte)prim.PrimData.ProfileCurve; | ||
209 | ProfileHollow = Primitive.PackProfileHollow(prim.PrimData.ProfileHollow); | ||
210 | PathRadiusOffset = Primitive.PackPathTwist(prim.PrimData.PathRadiusOffset); | ||
211 | PathRevolutions = Primitive.PackPathRevolutions(prim.PrimData.PathRevolutions); | ||
212 | PathTaperX = Primitive.PackPathTaper(prim.PrimData.PathTaperX); | ||
213 | PathTaperY = Primitive.PackPathTaper(prim.PrimData.PathTaperY); | ||
214 | PathTwist = Primitive.PackPathTwist(prim.PrimData.PathTwist); | ||
215 | PathTwistBegin = Primitive.PackPathTwist(prim.PrimData.PathTwistBegin); | ||
216 | |||
217 | m_textureEntry = prim.Textures.GetBytes(); | ||
218 | |||
219 | SculptEntry = (prim.Sculpt.Type != OpenMetaverse.SculptType.None); | ||
220 | SculptData = prim.Sculpt.GetBytes(); | ||
221 | SculptTexture = prim.Sculpt.SculptTexture; | ||
222 | SculptType = (byte)prim.Sculpt.Type; | ||
223 | } | ||
224 | |||
191 | [XmlIgnore] | 225 | [XmlIgnore] |
192 | public Primitive.TextureEntry Textures | 226 | public Primitive.TextureEntry Textures |
193 | { | 227 | { |
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 1ea08f9..828bbfc 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs | |||
@@ -341,10 +341,6 @@ namespace OpenSim.Framework | |||
341 | private RegionSettings m_regionSettings; | 341 | private RegionSettings m_regionSettings; |
342 | // private IConfigSource m_configSource = null; | 342 | // private IConfigSource m_configSource = null; |
343 | 343 | ||
344 | public UUID MasterAvatarAssignedUUID = UUID.Zero; | ||
345 | public string MasterAvatarFirstName = String.Empty; | ||
346 | public string MasterAvatarLastName = String.Empty; | ||
347 | public string MasterAvatarSandboxPassword = String.Empty; | ||
348 | public UUID originRegionID = UUID.Zero; | 344 | public UUID originRegionID = UUID.Zero; |
349 | public string proxyUrl = ""; | 345 | public string proxyUrl = ""; |
350 | public int ProxyOffset = 0; | 346 | public int ProxyOffset = 0; |
@@ -790,41 +786,6 @@ namespace OpenSim.Framework | |||
790 | else | 786 | else |
791 | m_externalHostName = externalName; | 787 | m_externalHostName = externalName; |
792 | 788 | ||
793 | |||
794 | // Master avatar cruft | ||
795 | // | ||
796 | string masterAvatarUUID; | ||
797 | if (!creatingNew) | ||
798 | { | ||
799 | masterAvatarUUID = config.GetString("MasterAvatarUUID", UUID.Zero.ToString()); | ||
800 | MasterAvatarFirstName = config.GetString("MasterAvatarFirstName", String.Empty); | ||
801 | MasterAvatarLastName = config.GetString("MasterAvatarLastName", String.Empty); | ||
802 | MasterAvatarSandboxPassword = config.GetString("MasterAvatarSandboxPassword", String.Empty); | ||
803 | } | ||
804 | else | ||
805 | { | ||
806 | masterAvatarUUID = MainConsole.Instance.CmdPrompt("Master Avatar UUID", UUID.Zero.ToString()); | ||
807 | if (masterAvatarUUID != UUID.Zero.ToString()) | ||
808 | { | ||
809 | config.Set("MasterAvatarUUID", masterAvatarUUID); | ||
810 | } | ||
811 | else | ||
812 | { | ||
813 | MasterAvatarFirstName = MainConsole.Instance.CmdPrompt("Master Avatar first name (enter for no master avatar)", String.Empty); | ||
814 | if (MasterAvatarFirstName != String.Empty) | ||
815 | { | ||
816 | MasterAvatarLastName = MainConsole.Instance.CmdPrompt("Master Avatar last name", String.Empty); | ||
817 | MasterAvatarSandboxPassword = MainConsole.Instance.CmdPrompt("Master Avatar sandbox password", String.Empty); | ||
818 | |||
819 | config.Set("MasterAvatarFirstName", MasterAvatarFirstName); | ||
820 | config.Set("MasterAvatarLastName", MasterAvatarLastName); | ||
821 | config.Set("MasterAvatarSandboxPassword", MasterAvatarSandboxPassword); | ||
822 | } | ||
823 | } | ||
824 | } | ||
825 | |||
826 | MasterAvatarAssignedUUID = new UUID(masterAvatarUUID); | ||
827 | |||
828 | m_regionType = config.GetString("RegionType", String.Empty); | 789 | m_regionType = config.GetString("RegionType", String.Empty); |
829 | 790 | ||
830 | // Prim stuff | 791 | // Prim stuff |
@@ -867,20 +828,6 @@ namespace OpenSim.Framework | |||
867 | 828 | ||
868 | config.Set("ExternalHostName", m_externalHostName); | 829 | config.Set("ExternalHostName", m_externalHostName); |
869 | 830 | ||
870 | if (MasterAvatarAssignedUUID != UUID.Zero) | ||
871 | { | ||
872 | config.Set("MasterAvatarUUID", MasterAvatarAssignedUUID.ToString()); | ||
873 | } | ||
874 | else if (MasterAvatarFirstName != String.Empty && MasterAvatarLastName != String.Empty) | ||
875 | { | ||
876 | config.Set("MasterAvatarFirstName", MasterAvatarFirstName); | ||
877 | config.Set("MasterAvatarLastName", MasterAvatarLastName); | ||
878 | } | ||
879 | if (MasterAvatarSandboxPassword != String.Empty) | ||
880 | { | ||
881 | config.Set("MasterAvatarSandboxPassword", MasterAvatarSandboxPassword); | ||
882 | } | ||
883 | |||
884 | if (m_nonphysPrimMax != 0) | 831 | if (m_nonphysPrimMax != 0) |
885 | config.Set("NonphysicalPrimMax", m_nonphysPrimMax); | 832 | config.Set("NonphysicalPrimMax", m_nonphysPrimMax); |
886 | if (m_physPrimMax != 0) | 833 | if (m_physPrimMax != 0) |
@@ -954,17 +901,6 @@ namespace OpenSim.Framework | |||
954 | configMember.addConfigurationOption("external_host_name", | 901 | configMember.addConfigurationOption("external_host_name", |
955 | ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | 902 | ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, |
956 | "External Host Name", m_externalHostName, true); | 903 | "External Host Name", m_externalHostName, true); |
957 | configMember.addConfigurationOption("master_avatar_uuid", ConfigurationOption.ConfigurationTypes.TYPE_UUID, | ||
958 | "Master Avatar UUID", MasterAvatarAssignedUUID.ToString(), true); | ||
959 | configMember.addConfigurationOption("master_avatar_first", | ||
960 | ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | ||
961 | "First Name of Master Avatar", MasterAvatarFirstName, true); | ||
962 | configMember.addConfigurationOption("master_avatar_last", | ||
963 | ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | ||
964 | "Last Name of Master Avatar", MasterAvatarLastName, true); | ||
965 | configMember.addConfigurationOption("master_avatar_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING, | ||
966 | "(Sandbox Mode Only)Password for Master Avatar account", | ||
967 | MasterAvatarSandboxPassword, true); | ||
968 | configMember.addConfigurationOption("lastmap_uuid", ConfigurationOption.ConfigurationTypes.TYPE_UUID, | 904 | configMember.addConfigurationOption("lastmap_uuid", ConfigurationOption.ConfigurationTypes.TYPE_UUID, |
969 | "Last Map UUID", lastMapUUID.ToString(), true); | 905 | "Last Map UUID", lastMapUUID.ToString(), true); |
970 | configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | 906 | configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, |
@@ -1014,22 +950,6 @@ namespace OpenSim.Framework | |||
1014 | configMember.addConfigurationOption("external_host_name", | 950 | configMember.addConfigurationOption("external_host_name", |
1015 | ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | 951 | ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, |
1016 | "External Host Name", "127.0.0.1", false); | 952 | "External Host Name", "127.0.0.1", false); |
1017 | configMember.addConfigurationOption("master_avatar_uuid", ConfigurationOption.ConfigurationTypes.TYPE_UUID, | ||
1018 | "Master Avatar UUID", UUID.Zero.ToString(), true); | ||
1019 | configMember.addConfigurationOption("master_avatar_first", | ||
1020 | ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | ||
1021 | "First Name of Master Avatar", "Test", false, | ||
1022 | (ConfigurationOption.ConfigurationOptionShouldBeAsked) | ||
1023 | shouldMasterAvatarDetailsBeAsked); | ||
1024 | configMember.addConfigurationOption("master_avatar_last", | ||
1025 | ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | ||
1026 | "Last Name of Master Avatar", "User", false, | ||
1027 | (ConfigurationOption.ConfigurationOptionShouldBeAsked) | ||
1028 | shouldMasterAvatarDetailsBeAsked); | ||
1029 | configMember.addConfigurationOption("master_avatar_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING, | ||
1030 | "(Sandbox Mode Only)Password for Master Avatar account", "test", false, | ||
1031 | (ConfigurationOption.ConfigurationOptionShouldBeAsked) | ||
1032 | shouldMasterAvatarDetailsBeAsked); | ||
1033 | configMember.addConfigurationOption("lastmap_uuid", ConfigurationOption.ConfigurationTypes.TYPE_UUID, | 953 | configMember.addConfigurationOption("lastmap_uuid", ConfigurationOption.ConfigurationTypes.TYPE_UUID, |
1034 | "Last Map UUID", lastMapUUID.ToString(), true); | 954 | "Last Map UUID", lastMapUUID.ToString(), true); |
1035 | 955 | ||
@@ -1055,11 +975,6 @@ namespace OpenSim.Framework | |||
1055 | "Region Type", String.Empty, true); | 975 | "Region Type", String.Empty, true); |
1056 | } | 976 | } |
1057 | 977 | ||
1058 | public bool shouldMasterAvatarDetailsBeAsked(string configuration_key) | ||
1059 | { | ||
1060 | return MasterAvatarAssignedUUID == UUID.Zero; | ||
1061 | } | ||
1062 | |||
1063 | public bool handleIncomingConfiguration(string configuration_key, object configuration_result) | 978 | public bool handleIncomingConfiguration(string configuration_key, object configuration_result) |
1064 | { | 979 | { |
1065 | switch (configuration_key) | 980 | switch (configuration_key) |
@@ -1100,18 +1015,6 @@ namespace OpenSim.Framework | |||
1100 | m_externalHostName = Util.GetLocalHost().ToString(); | 1015 | m_externalHostName = Util.GetLocalHost().ToString(); |
1101 | } | 1016 | } |
1102 | break; | 1017 | break; |
1103 | case "master_avatar_uuid": | ||
1104 | MasterAvatarAssignedUUID = (UUID) configuration_result; | ||
1105 | break; | ||
1106 | case "master_avatar_first": | ||
1107 | MasterAvatarFirstName = (string) configuration_result; | ||
1108 | break; | ||
1109 | case "master_avatar_last": | ||
1110 | MasterAvatarLastName = (string) configuration_result; | ||
1111 | break; | ||
1112 | case "master_avatar_pass": | ||
1113 | MasterAvatarSandboxPassword = (string)configuration_result; | ||
1114 | break; | ||
1115 | case "lastmap_uuid": | 1018 | case "lastmap_uuid": |
1116 | lastMapUUID = (UUID)configuration_result; | 1019 | lastMapUUID = (UUID)configuration_result; |
1117 | break; | 1020 | break; |
diff --git a/OpenSim/Framework/SLUtil.cs b/OpenSim/Framework/SLUtil.cs new file mode 100644 index 0000000..9d5c30a --- /dev/null +++ b/OpenSim/Framework/SLUtil.cs | |||
@@ -0,0 +1,185 @@ | |||
1 | using System; | ||
2 | using OpenMetaverse; | ||
3 | |||
4 | namespace OpenSim.Framework | ||
5 | { | ||
6 | public static class SLUtil | ||
7 | { | ||
8 | #region SL / file extension / content-type conversions | ||
9 | |||
10 | public static string SLAssetTypeToContentType(int assetType) | ||
11 | { | ||
12 | switch ((AssetType)assetType) | ||
13 | { | ||
14 | case AssetType.Texture: | ||
15 | return "image/x-j2c"; | ||
16 | case AssetType.Sound: | ||
17 | return "application/ogg"; | ||
18 | case AssetType.CallingCard: | ||
19 | return "application/vnd.ll.callingcard"; | ||
20 | case AssetType.Landmark: | ||
21 | return "application/vnd.ll.landmark"; | ||
22 | case AssetType.Clothing: | ||
23 | return "application/vnd.ll.clothing"; | ||
24 | case AssetType.Object: | ||
25 | return "application/vnd.ll.primitive"; | ||
26 | case AssetType.Notecard: | ||
27 | return "application/vnd.ll.notecard"; | ||
28 | case AssetType.Folder: | ||
29 | return "application/vnd.ll.folder"; | ||
30 | case AssetType.RootFolder: | ||
31 | return "application/vnd.ll.rootfolder"; | ||
32 | case AssetType.LSLText: | ||
33 | return "application/vnd.ll.lsltext"; | ||
34 | case AssetType.LSLBytecode: | ||
35 | return "application/vnd.ll.lslbyte"; | ||
36 | case AssetType.TextureTGA: | ||
37 | case AssetType.ImageTGA: | ||
38 | return "image/tga"; | ||
39 | case AssetType.Bodypart: | ||
40 | return "application/vnd.ll.bodypart"; | ||
41 | case AssetType.TrashFolder: | ||
42 | return "application/vnd.ll.trashfolder"; | ||
43 | case AssetType.SnapshotFolder: | ||
44 | return "application/vnd.ll.snapshotfolder"; | ||
45 | case AssetType.LostAndFoundFolder: | ||
46 | return "application/vnd.ll.lostandfoundfolder"; | ||
47 | case AssetType.SoundWAV: | ||
48 | return "audio/x-wav"; | ||
49 | case AssetType.ImageJPEG: | ||
50 | return "image/jpeg"; | ||
51 | case AssetType.Animation: | ||
52 | return "application/vnd.ll.animation"; | ||
53 | case AssetType.Gesture: | ||
54 | return "application/vnd.ll.gesture"; | ||
55 | case AssetType.Simstate: | ||
56 | return "application/x-metaverse-simstate"; | ||
57 | case AssetType.Unknown: | ||
58 | default: | ||
59 | return "application/octet-stream"; | ||
60 | } | ||
61 | } | ||
62 | |||
63 | public static sbyte ContentTypeToSLAssetType(string contentType) | ||
64 | { | ||
65 | switch (contentType) | ||
66 | { | ||
67 | case "image/x-j2c": | ||
68 | case "image/jp2": | ||
69 | return (sbyte)AssetType.Texture; | ||
70 | case "application/ogg": | ||
71 | return (sbyte)AssetType.Sound; | ||
72 | case "application/vnd.ll.callingcard": | ||
73 | case "application/x-metaverse-callingcard": | ||
74 | return (sbyte)AssetType.CallingCard; | ||
75 | case "application/vnd.ll.landmark": | ||
76 | case "application/x-metaverse-landmark": | ||
77 | return (sbyte)AssetType.Landmark; | ||
78 | case "application/vnd.ll.clothing": | ||
79 | case "application/x-metaverse-clothing": | ||
80 | return (sbyte)AssetType.Clothing; | ||
81 | case "application/vnd.ll.primitive": | ||
82 | case "application/x-metaverse-primitive": | ||
83 | return (sbyte)AssetType.Object; | ||
84 | case "application/vnd.ll.notecard": | ||
85 | case "application/x-metaverse-notecard": | ||
86 | return (sbyte)AssetType.Notecard; | ||
87 | case "application/vnd.ll.folder": | ||
88 | return (sbyte)AssetType.Folder; | ||
89 | case "application/vnd.ll.rootfolder": | ||
90 | return (sbyte)AssetType.RootFolder; | ||
91 | case "application/vnd.ll.lsltext": | ||
92 | case "application/x-metaverse-lsl": | ||
93 | return (sbyte)AssetType.LSLText; | ||
94 | case "application/vnd.ll.lslbyte": | ||
95 | case "application/x-metaverse-lso": | ||
96 | return (sbyte)AssetType.LSLBytecode; | ||
97 | case "image/tga": | ||
98 | // Note that AssetType.TextureTGA will be converted to AssetType.ImageTGA | ||
99 | return (sbyte)AssetType.ImageTGA; | ||
100 | case "application/vnd.ll.bodypart": | ||
101 | case "application/x-metaverse-bodypart": | ||
102 | return (sbyte)AssetType.Bodypart; | ||
103 | case "application/vnd.ll.trashfolder": | ||
104 | return (sbyte)AssetType.TrashFolder; | ||
105 | case "application/vnd.ll.snapshotfolder": | ||
106 | return (sbyte)AssetType.SnapshotFolder; | ||
107 | case "application/vnd.ll.lostandfoundfolder": | ||
108 | return (sbyte)AssetType.LostAndFoundFolder; | ||
109 | case "audio/x-wav": | ||
110 | return (sbyte)AssetType.SoundWAV; | ||
111 | case "image/jpeg": | ||
112 | return (sbyte)AssetType.ImageJPEG; | ||
113 | case "application/vnd.ll.animation": | ||
114 | case "application/x-metaverse-animation": | ||
115 | return (sbyte)AssetType.Animation; | ||
116 | case "application/vnd.ll.gesture": | ||
117 | case "application/x-metaverse-gesture": | ||
118 | return (sbyte)AssetType.Gesture; | ||
119 | case "application/x-metaverse-simstate": | ||
120 | return (sbyte)AssetType.Simstate; | ||
121 | case "application/octet-stream": | ||
122 | default: | ||
123 | return (sbyte)AssetType.Unknown; | ||
124 | } | ||
125 | } | ||
126 | |||
127 | public static sbyte ContentTypeToSLInvType(string contentType) | ||
128 | { | ||
129 | switch (contentType) | ||
130 | { | ||
131 | case "image/x-j2c": | ||
132 | case "image/jp2": | ||
133 | case "image/tga": | ||
134 | case "image/jpeg": | ||
135 | return (sbyte)InventoryType.Texture; | ||
136 | case "application/ogg": | ||
137 | case "audio/x-wav": | ||
138 | return (sbyte)InventoryType.Sound; | ||
139 | case "application/vnd.ll.callingcard": | ||
140 | case "application/x-metaverse-callingcard": | ||
141 | return (sbyte)InventoryType.CallingCard; | ||
142 | case "application/vnd.ll.landmark": | ||
143 | case "application/x-metaverse-landmark": | ||
144 | return (sbyte)InventoryType.Landmark; | ||
145 | case "application/vnd.ll.clothing": | ||
146 | case "application/x-metaverse-clothing": | ||
147 | case "application/vnd.ll.bodypart": | ||
148 | case "application/x-metaverse-bodypart": | ||
149 | return (sbyte)InventoryType.Wearable; | ||
150 | case "application/vnd.ll.primitive": | ||
151 | case "application/x-metaverse-primitive": | ||
152 | return (sbyte)InventoryType.Object; | ||
153 | case "application/vnd.ll.notecard": | ||
154 | case "application/x-metaverse-notecard": | ||
155 | return (sbyte)InventoryType.Notecard; | ||
156 | case "application/vnd.ll.folder": | ||
157 | return (sbyte)InventoryType.Folder; | ||
158 | case "application/vnd.ll.rootfolder": | ||
159 | return (sbyte)InventoryType.RootCategory; | ||
160 | case "application/vnd.ll.lsltext": | ||
161 | case "application/x-metaverse-lsl": | ||
162 | case "application/vnd.ll.lslbyte": | ||
163 | case "application/x-metaverse-lso": | ||
164 | return (sbyte)InventoryType.LSL; | ||
165 | case "application/vnd.ll.trashfolder": | ||
166 | case "application/vnd.ll.snapshotfolder": | ||
167 | case "application/vnd.ll.lostandfoundfolder": | ||
168 | return (sbyte)InventoryType.Folder; | ||
169 | case "application/vnd.ll.animation": | ||
170 | case "application/x-metaverse-animation": | ||
171 | return (sbyte)InventoryType.Animation; | ||
172 | case "application/vnd.ll.gesture": | ||
173 | case "application/x-metaverse-gesture": | ||
174 | return (sbyte)InventoryType.Gesture; | ||
175 | case "application/x-metaverse-simstate": | ||
176 | return (sbyte)InventoryType.Snapshot; | ||
177 | case "application/octet-stream": | ||
178 | default: | ||
179 | return (sbyte)InventoryType.Unknown; | ||
180 | } | ||
181 | } | ||
182 | |||
183 | #endregion SL / file extension / content-type conversions | ||
184 | } | ||
185 | } | ||
diff --git a/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs b/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs index fb269b7..f50b49a 100644 --- a/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs +++ b/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs | |||
@@ -40,7 +40,7 @@ namespace OpenSim.Framework.Serialization.External | |||
40 | public const int MAJOR_VERSION = 0; | 40 | public const int MAJOR_VERSION = 0; |
41 | public const int MINOR_VERSION = 1; | 41 | public const int MINOR_VERSION = 1; |
42 | 42 | ||
43 | public static string Serialize(UserProfileData profile) | 43 | public static string Serialize(UUID userID, string firstName, string lastName) |
44 | { | 44 | { |
45 | StringWriter sw = new StringWriter(); | 45 | StringWriter sw = new StringWriter(); |
46 | XmlTextWriter xtw = new XmlTextWriter(sw); | 46 | XmlTextWriter xtw = new XmlTextWriter(sw); |
@@ -51,9 +51,9 @@ namespace OpenSim.Framework.Serialization.External | |||
51 | xtw.WriteAttributeString("major_version", MAJOR_VERSION.ToString()); | 51 | xtw.WriteAttributeString("major_version", MAJOR_VERSION.ToString()); |
52 | xtw.WriteAttributeString("minor_version", MINOR_VERSION.ToString()); | 52 | xtw.WriteAttributeString("minor_version", MINOR_VERSION.ToString()); |
53 | 53 | ||
54 | xtw.WriteElementString("name", profile.Name); | 54 | xtw.WriteElementString("name", firstName + " " + lastName); |
55 | xtw.WriteElementString("id", profile.ID.ToString()); | 55 | xtw.WriteElementString("id", userID.ToString()); |
56 | xtw.WriteElementString("about", profile.AboutText); | 56 | xtw.WriteElementString("about", ""); |
57 | 57 | ||
58 | // Not sure if we're storing this yet, need to take a look | 58 | // Not sure if we're storing this yet, need to take a look |
59 | // xtw.WriteElementString("Url", profile.Url); | 59 | // xtw.WriteElementString("Url", profile.Url); |
diff --git a/OpenSim/Framework/Tests/AssetBaseTest.cs b/OpenSim/Framework/Tests/AssetBaseTest.cs index 18a3e01..6db1aa0 100644 --- a/OpenSim/Framework/Tests/AssetBaseTest.cs +++ b/OpenSim/Framework/Tests/AssetBaseTest.cs | |||
@@ -67,7 +67,7 @@ namespace OpenSim.Framework.Tests | |||
67 | 67 | ||
68 | private void CheckContainsReferences(AssetType assetType, bool expected) | 68 | private void CheckContainsReferences(AssetType assetType, bool expected) |
69 | { | 69 | { |
70 | AssetBase asset = new AssetBase(UUID.Zero, String.Empty, (sbyte)assetType); | 70 | AssetBase asset = new AssetBase(UUID.Zero, String.Empty, (sbyte)assetType, UUID.Zero.ToString()); |
71 | bool actual = asset.ContainsReferences; | 71 | bool actual = asset.ContainsReferences; |
72 | Assert.AreEqual(expected, actual, "Expected "+assetType+".ContainsReferences to be "+expected+" but was "+actual+"."); | 72 | Assert.AreEqual(expected, actual, "Expected "+assetType+".ContainsReferences to be "+expected+" but was "+actual+"."); |
73 | } | 73 | } |
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 58a0d77..0ccc193 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -553,7 +553,7 @@ namespace OpenSim.Framework | |||
553 | } | 553 | } |
554 | catch (Exception e) | 554 | catch (Exception e) |
555 | { | 555 | { |
556 | m_log.ErrorFormat("[UTIL]: An error occurred while resolving {0}, {1}", dnsAddress, e); | 556 | m_log.WarnFormat("[UTIL]: An error occurred while resolving host name {0}, {1}", dnsAddress, e); |
557 | 557 | ||
558 | // Still going to throw the exception on for now, since this was what was happening in the first place | 558 | // Still going to throw the exception on for now, since this was what was happening in the first place |
559 | throw e; | 559 | throw e; |
@@ -589,11 +589,17 @@ namespace OpenSim.Framework | |||
589 | 589 | ||
590 | public static IPAddress GetLocalHost() | 590 | public static IPAddress GetLocalHost() |
591 | { | 591 | { |
592 | string dnsAddress = "localhost"; | 592 | IPAddress[] iplist = GetLocalHosts(); |
593 | 593 | ||
594 | IPAddress[] hosts = Dns.GetHostEntry(dnsAddress).AddressList; | 594 | if (iplist.Length == 0) // No accessible external interfaces |
595 | { | ||
596 | IPAddress[] loopback = Dns.GetHostAddresses("localhost"); | ||
597 | IPAddress localhost = loopback[0]; | ||
595 | 598 | ||
596 | foreach (IPAddress host in hosts) | 599 | return localhost; |
600 | } | ||
601 | |||
602 | foreach (IPAddress host in iplist) | ||
597 | { | 603 | { |
598 | if (!IPAddress.IsLoopback(host) && host.AddressFamily == AddressFamily.InterNetwork) | 604 | if (!IPAddress.IsLoopback(host) && host.AddressFamily == AddressFamily.InterNetwork) |
599 | { | 605 | { |
@@ -601,15 +607,15 @@ namespace OpenSim.Framework | |||
601 | } | 607 | } |
602 | } | 608 | } |
603 | 609 | ||
604 | if (hosts.Length > 0) | 610 | if (iplist.Length > 0) |
605 | { | 611 | { |
606 | foreach (IPAddress host in hosts) | 612 | foreach (IPAddress host in iplist) |
607 | { | 613 | { |
608 | if (host.AddressFamily == AddressFamily.InterNetwork) | 614 | if (host.AddressFamily == AddressFamily.InterNetwork) |
609 | return host; | 615 | return host; |
610 | } | 616 | } |
611 | // Well all else failed... | 617 | // Well all else failed... |
612 | return hosts[0]; | 618 | return iplist[0]; |
613 | } | 619 | } |
614 | 620 | ||
615 | return null; | 621 | return null; |
@@ -1186,6 +1192,33 @@ namespace OpenSim.Framework | |||
1186 | return null; | 1192 | return null; |
1187 | } | 1193 | } |
1188 | 1194 | ||
1195 | public static OSDMap GetOSDMap(string data) | ||
1196 | { | ||
1197 | OSDMap args = null; | ||
1198 | try | ||
1199 | { | ||
1200 | OSD buffer; | ||
1201 | // We should pay attention to the content-type, but let's assume we know it's Json | ||
1202 | buffer = OSDParser.DeserializeJson(data); | ||
1203 | if (buffer.Type == OSDType.Map) | ||
1204 | { | ||
1205 | args = (OSDMap)buffer; | ||
1206 | return args; | ||
1207 | } | ||
1208 | else | ||
1209 | { | ||
1210 | // uh? | ||
1211 | m_log.Debug(("[UTILS]: Got OSD of unexpected type " + buffer.Type.ToString())); | ||
1212 | return null; | ||
1213 | } | ||
1214 | } | ||
1215 | catch (Exception ex) | ||
1216 | { | ||
1217 | m_log.Debug("[UTILS]: exception on GetOSDMap " + ex.Message); | ||
1218 | return null; | ||
1219 | } | ||
1220 | } | ||
1221 | |||
1189 | public static string[] Glob(string path) | 1222 | public static string[] Glob(string path) |
1190 | { | 1223 | { |
1191 | string vol=String.Empty; | 1224 | string vol=String.Empty; |
diff --git a/OpenSim/Framework/Communications/Services/GridInfoService.cs b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs index cd2a152..d1233dc 100644 --- a/OpenSim/Framework/Communications/Services/GridInfoService.cs +++ b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs | |||
@@ -34,11 +34,12 @@ using System.Text; | |||
34 | using log4net; | 34 | using log4net; |
35 | using Nini.Config; | 35 | using Nini.Config; |
36 | using Nwc.XmlRpc; | 36 | using Nwc.XmlRpc; |
37 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Servers.HttpServer; | 38 | using OpenSim.Framework.Servers.HttpServer; |
38 | 39 | ||
39 | namespace OpenSim.Framework.Communications.Services | 40 | namespace OpenSim.Server.Handlers.Grid |
40 | { | 41 | { |
41 | public class GridInfoService | 42 | public class GridInfoHandlers |
42 | { | 43 | { |
43 | private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
44 | 45 | ||
@@ -55,45 +56,22 @@ namespace OpenSim.Framework.Communications.Services | |||
55 | /// anything else requires a general redesign of the config | 56 | /// anything else requires a general redesign of the config |
56 | /// system. | 57 | /// system. |
57 | /// </remarks> | 58 | /// </remarks> |
58 | public GridInfoService(IConfigSource configSource) | 59 | public GridInfoHandlers(IConfigSource configSource) |
59 | { | 60 | { |
60 | loadGridInfo(configSource); | 61 | loadGridInfo(configSource); |
61 | } | 62 | } |
62 | 63 | ||
63 | /// <summary> | ||
64 | /// Default constructor, uses OpenSim.ini. | ||
65 | /// </summary> | ||
66 | public GridInfoService() | ||
67 | { | ||
68 | try | ||
69 | { | ||
70 | IConfigSource configSource = new IniConfigSource(Path.Combine(Util.configDir(), "OpenSim.ini")); | ||
71 | loadGridInfo(configSource); | ||
72 | } | ||
73 | catch (FileNotFoundException) | ||
74 | { | ||
75 | _log.Warn( | ||
76 | "[GRID INFO SERVICE]: No OpenSim.ini file found --- GridInfoServices WILL NOT BE AVAILABLE to your users"); | ||
77 | } | ||
78 | } | ||
79 | |||
80 | private void loadGridInfo(IConfigSource configSource) | 64 | private void loadGridInfo(IConfigSource configSource) |
81 | { | 65 | { |
82 | _info["platform"] = "OpenSim"; | 66 | _info["platform"] = "OpenSim"; |
83 | try | 67 | try |
84 | { | 68 | { |
85 | IConfig startupCfg = configSource.Configs["Startup"]; | 69 | IConfig startupCfg = configSource.Configs["Startup"]; |
86 | IConfig gridCfg = configSource.Configs["GridInfo"]; | 70 | IConfig gridCfg = configSource.Configs["GridInfoService"]; |
87 | IConfig netCfg = configSource.Configs["Network"]; | 71 | IConfig netCfg = configSource.Configs["Network"]; |
88 | 72 | ||
89 | bool grid = startupCfg.GetBoolean("gridmode", false); | 73 | bool grid = startupCfg.GetBoolean("gridmode", false); |
90 | 74 | ||
91 | if (grid) | ||
92 | _info["mode"] = "grid"; | ||
93 | else | ||
94 | _info["mode"] = "standalone"; | ||
95 | |||
96 | |||
97 | if (null != gridCfg) | 75 | if (null != gridCfg) |
98 | { | 76 | { |
99 | foreach (string k in gridCfg.GetKeys()) | 77 | foreach (string k in gridCfg.GetKeys()) |
diff --git a/OpenSim/Framework/Communications/IMessagingService.cs b/OpenSim/Services/Interfaces/ILibraryService.cs index 5d65f19..861cf0e 100644 --- a/OpenSim/Framework/Communications/IMessagingService.cs +++ b/OpenSim/Services/Interfaces/ILibraryService.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -25,13 +25,19 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | ||
28 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | |||
31 | using OpenSim.Framework; | ||
29 | using OpenMetaverse; | 32 | using OpenMetaverse; |
30 | 33 | ||
31 | namespace OpenSim.Framework.Communications | 34 | namespace OpenSim.Services.Interfaces |
32 | { | 35 | { |
33 | public interface IMessagingService | 36 | public interface ILibraryService |
34 | { | 37 | { |
35 | Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids); | 38 | InventoryFolderImpl LibraryRootFolder { get; } |
39 | |||
40 | Dictionary<UUID, InventoryFolderImpl> GetAllFolders(); | ||
36 | } | 41 | } |
42 | |||
37 | } | 43 | } |
diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Services/InventoryService/LibraryService.cs index 74ba0a5..383f311 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Services/InventoryService/LibraryService.cs | |||
@@ -30,20 +30,32 @@ using System.Collections.Generic; | |||
30 | using System.IO; | 30 | using System.IO; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Xml; | 32 | using System.Xml; |
33 | |||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Services.Base; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | |||
33 | using log4net; | 38 | using log4net; |
34 | using Nini.Config; | 39 | using Nini.Config; |
35 | using OpenMetaverse; | 40 | using OpenMetaverse; |
36 | 41 | ||
37 | namespace OpenSim.Framework.Communications.Cache | 42 | namespace OpenSim.Services.InventoryService |
38 | { | 43 | { |
39 | /// <summary> | 44 | /// <summary> |
40 | /// Basically a hack to give us a Inventory library while we don't have a inventory server | 45 | /// Basically a hack to give us a Inventory library while we don't have a inventory server |
41 | /// once the server is fully implemented then should read the data from that | 46 | /// once the server is fully implemented then should read the data from that |
42 | /// </summary> | 47 | /// </summary> |
43 | public class LibraryRootFolder : InventoryFolderImpl | 48 | public class LibraryService : ServiceBase, ILibraryService |
44 | { | 49 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 51 | ||
52 | private InventoryFolderImpl m_LibraryRootFolder; | ||
53 | |||
54 | public InventoryFolderImpl LibraryRootFolder | ||
55 | { | ||
56 | get { return m_LibraryRootFolder; } | ||
57 | } | ||
58 | |||
47 | private UUID libOwner = new UUID("11111111-1111-0000-0000-000100bba000"); | 59 | private UUID libOwner = new UUID("11111111-1111-0000-0000-000100bba000"); |
48 | 60 | ||
49 | /// <summary> | 61 | /// <summary> |
@@ -52,17 +64,31 @@ namespace OpenSim.Framework.Communications.Cache | |||
52 | /// </summary> | 64 | /// </summary> |
53 | protected Dictionary<UUID, InventoryFolderImpl> libraryFolders | 65 | protected Dictionary<UUID, InventoryFolderImpl> libraryFolders |
54 | = new Dictionary<UUID, InventoryFolderImpl>(); | 66 | = new Dictionary<UUID, InventoryFolderImpl>(); |
55 | 67 | ||
56 | public LibraryRootFolder(string pLibrariesLocation) | 68 | public LibraryService(IConfigSource config) |
69 | : base(config) | ||
57 | { | 70 | { |
58 | Owner = libOwner; | 71 | string pLibrariesLocation = Path.Combine("inventory", "Libraries.xml"); |
59 | ID = new UUID("00000112-000f-0000-0000-000100bba000"); | 72 | string pLibName = "OpenSim Library"; |
60 | Name = "OpenSim Library"; | 73 | |
61 | ParentID = UUID.Zero; | 74 | IConfig libConfig = config.Configs["LibraryService"]; |
62 | Type = (short) 8; | 75 | if (libConfig != null) |
63 | Version = (ushort) 1; | 76 | { |
77 | pLibrariesLocation = libConfig.GetString("DefaultLibrary", pLibrariesLocation); | ||
78 | pLibName = libConfig.GetString("LibraryName", pLibName); | ||
79 | } | ||
80 | |||
81 | m_log.Debug("[LIBRARY]: Starting library service..."); | ||
82 | |||
83 | m_LibraryRootFolder = new InventoryFolderImpl(); | ||
84 | m_LibraryRootFolder.Owner = libOwner; | ||
85 | m_LibraryRootFolder.ID = new UUID("00000112-000f-0000-0000-000100bba000"); | ||
86 | m_LibraryRootFolder.Name = pLibName; | ||
87 | m_LibraryRootFolder.ParentID = UUID.Zero; | ||
88 | m_LibraryRootFolder.Type = (short)8; | ||
89 | m_LibraryRootFolder.Version = (ushort)1; | ||
64 | 90 | ||
65 | libraryFolders.Add(ID, this); | 91 | libraryFolders.Add(m_LibraryRootFolder.ID, m_LibraryRootFolder); |
66 | 92 | ||
67 | LoadLibraries(pLibrariesLocation); | 93 | LoadLibraries(pLibrariesLocation); |
68 | } | 94 | } |
@@ -126,9 +152,9 @@ namespace OpenSim.Framework.Communications.Cache | |||
126 | { | 152 | { |
127 | InventoryFolderImpl folderInfo = new InventoryFolderImpl(); | 153 | InventoryFolderImpl folderInfo = new InventoryFolderImpl(); |
128 | 154 | ||
129 | folderInfo.ID = new UUID(config.GetString("folderID", ID.ToString())); | 155 | folderInfo.ID = new UUID(config.GetString("folderID", m_LibraryRootFolder.ID.ToString())); |
130 | folderInfo.Name = config.GetString("name", "unknown"); | 156 | folderInfo.Name = config.GetString("name", "unknown"); |
131 | folderInfo.ParentID = new UUID(config.GetString("parentFolderID", ID.ToString())); | 157 | folderInfo.ParentID = new UUID(config.GetString("parentFolderID", m_LibraryRootFolder.ID.ToString())); |
132 | folderInfo.Type = (short)config.GetInt("type", 8); | 158 | folderInfo.Type = (short)config.GetInt("type", 8); |
133 | 159 | ||
134 | folderInfo.Owner = libOwner; | 160 | folderInfo.Owner = libOwner; |
@@ -160,9 +186,9 @@ namespace OpenSim.Framework.Communications.Cache | |||
160 | InventoryItemBase item = new InventoryItemBase(); | 186 | InventoryItemBase item = new InventoryItemBase(); |
161 | item.Owner = libOwner; | 187 | item.Owner = libOwner; |
162 | item.CreatorId = libOwner.ToString(); | 188 | item.CreatorId = libOwner.ToString(); |
163 | item.ID = new UUID(config.GetString("inventoryID", ID.ToString())); | 189 | item.ID = new UUID(config.GetString("inventoryID", m_LibraryRootFolder.ID.ToString())); |
164 | item.AssetID = new UUID(config.GetString("assetID", item.ID.ToString())); | 190 | item.AssetID = new UUID(config.GetString("assetID", item.ID.ToString())); |
165 | item.Folder = new UUID(config.GetString("folderID", ID.ToString())); | 191 | item.Folder = new UUID(config.GetString("folderID", m_LibraryRootFolder.ID.ToString())); |
166 | item.Name = config.GetString("name", String.Empty); | 192 | item.Name = config.GetString("name", String.Empty); |
167 | item.Description = config.GetString("description", item.Name); | 193 | item.Description = config.GetString("description", item.Name); |
168 | item.InvType = config.GetInt("inventoryType", 0); | 194 | item.InvType = config.GetInt("inventoryType", 0); |
@@ -230,11 +256,11 @@ namespace OpenSim.Framework.Communications.Cache | |||
230 | /// methods in the superclass | 256 | /// methods in the superclass |
231 | /// </summary> | 257 | /// </summary> |
232 | /// <returns></returns> | 258 | /// <returns></returns> |
233 | public Dictionary<UUID, InventoryFolderImpl> RequestSelfAndDescendentFolders() | 259 | public Dictionary<UUID, InventoryFolderImpl> GetAllFolders() |
234 | { | 260 | { |
235 | Dictionary<UUID, InventoryFolderImpl> fs = new Dictionary<UUID, InventoryFolderImpl>(); | 261 | Dictionary<UUID, InventoryFolderImpl> fs = new Dictionary<UUID, InventoryFolderImpl>(); |
236 | fs.Add(ID, this); | 262 | fs.Add(m_LibraryRootFolder.ID, m_LibraryRootFolder); |
237 | List<InventoryFolderImpl> fis = TraverseFolder(this); | 263 | List<InventoryFolderImpl> fis = TraverseFolder(m_LibraryRootFolder); |
238 | foreach (InventoryFolderImpl f in fis) | 264 | foreach (InventoryFolderImpl f in fis) |
239 | { | 265 | { |
240 | fs.Add(f.ID, f); | 266 | fs.Add(f.ID, f); |
diff --git a/OpenSim/Framework/Communications/Services/LoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs index ec5f428..05f5b4c 100644 --- a/OpenSim/Framework/Communications/Services/LoginResponse.cs +++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs | |||
@@ -28,25 +28,108 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Net; | ||
31 | using System.Reflection; | 32 | using System.Reflection; |
33 | |||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Capabilities; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
38 | using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; | ||
39 | |||
32 | using log4net; | 40 | using log4net; |
33 | using Nwc.XmlRpc; | ||
34 | using OpenMetaverse; | 41 | using OpenMetaverse; |
35 | using OpenMetaverse.StructuredData; | 42 | using OpenMetaverse.StructuredData; |
43 | using OSDArray = OpenMetaverse.StructuredData.OSDArray; | ||
44 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; | ||
36 | 45 | ||
37 | namespace OpenSim.Framework.Communications.Services | 46 | namespace OpenSim.Services.LLLoginService |
38 | { | 47 | { |
48 | public class LLFailedLoginResponse : OpenSim.Services.Interfaces.FailedLoginResponse | ||
49 | { | ||
50 | string m_key; | ||
51 | string m_value; | ||
52 | string m_login; | ||
53 | |||
54 | public static LLFailedLoginResponse UserProblem; | ||
55 | public static LLFailedLoginResponse AuthorizationProblem; | ||
56 | public static LLFailedLoginResponse GridProblem; | ||
57 | public static LLFailedLoginResponse InventoryProblem; | ||
58 | public static LLFailedLoginResponse DeadRegionProblem; | ||
59 | public static LLFailedLoginResponse LoginBlockedProblem; | ||
60 | public static LLFailedLoginResponse AlreadyLoggedInProblem; | ||
61 | public static LLFailedLoginResponse InternalError; | ||
62 | |||
63 | static LLFailedLoginResponse() | ||
64 | { | ||
65 | UserProblem = new LLFailedLoginResponse("key", | ||
66 | "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", | ||
67 | "false"); | ||
68 | AuthorizationProblem = new LLFailedLoginResponse("key", | ||
69 | "Error connecting to grid. Unable to authorize your session into the region.", | ||
70 | "false"); | ||
71 | GridProblem = new LLFailedLoginResponse("key", | ||
72 | "Error connecting to the desired location. Try connecting to another region.", | ||
73 | "false"); | ||
74 | InventoryProblem = new LLFailedLoginResponse("key", | ||
75 | "The inventory service is not responding. Please notify your login region operator.", | ||
76 | "false"); | ||
77 | DeadRegionProblem = new LLFailedLoginResponse("key", | ||
78 | "The region you are attempting to log into is not responding. Please select another region and try again.", | ||
79 | "false"); | ||
80 | LoginBlockedProblem = new LLFailedLoginResponse("presence", | ||
81 | "Logins are currently restricted. Please try again later.", | ||
82 | "false"); | ||
83 | AlreadyLoggedInProblem = new LLFailedLoginResponse("presence", | ||
84 | "You appear to be already logged in. " + | ||
85 | "If this is not the case please wait for your session to timeout. " + | ||
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"); | ||
89 | InternalError = new LLFailedLoginResponse("Internal Error", "Error generating Login Response", "false"); | ||
90 | } | ||
91 | |||
92 | public LLFailedLoginResponse(string key, string value, string login) | ||
93 | { | ||
94 | m_key = key; | ||
95 | m_value = value; | ||
96 | m_login = login; | ||
97 | } | ||
98 | |||
99 | public override Hashtable ToHashtable() | ||
100 | { | ||
101 | Hashtable loginError = new Hashtable(); | ||
102 | loginError["reason"] = m_key; | ||
103 | loginError["message"] = m_value; | ||
104 | loginError["login"] = m_login; | ||
105 | return loginError; | ||
106 | } | ||
107 | |||
108 | public override OSD ToOSDMap() | ||
109 | { | ||
110 | OSDMap map = new OSDMap(); | ||
111 | |||
112 | map["reason"] = OSD.FromString(m_key); | ||
113 | map["message"] = OSD.FromString(m_value); | ||
114 | map["login"] = OSD.FromString(m_login); | ||
115 | |||
116 | return map; | ||
117 | } | ||
118 | } | ||
119 | |||
39 | /// <summary> | 120 | /// <summary> |
40 | /// A temp class to handle login response. | 121 | /// A class to handle LL login response. |
41 | /// Should make use of UserProfileManager where possible. | ||
42 | /// </summary> | 122 | /// </summary> |
43 | public class LoginResponse | 123 | public class LLLoginResponse : OpenSim.Services.Interfaces.LoginResponse |
44 | { | 124 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 125 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
126 | private static Hashtable globalTexturesHash; | ||
127 | // Global Textures | ||
128 | private static string sunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271"; | ||
129 | private static string cloudTexture = "dc4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
130 | private static string moonTexture = "ec4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
46 | 131 | ||
47 | private Hashtable loginFlagsHash; | 132 | private Hashtable loginFlagsHash; |
48 | private Hashtable globalTexturesHash; | ||
49 | private Hashtable loginError; | ||
50 | private Hashtable uiConfigHash; | 133 | private Hashtable uiConfigHash; |
51 | 134 | ||
52 | private ArrayList loginFlags; | 135 | private ArrayList loginFlags; |
@@ -87,19 +170,10 @@ namespace OpenSim.Framework.Communications.Services | |||
87 | private string firstname; | 170 | private string firstname; |
88 | private string lastname; | 171 | private string lastname; |
89 | 172 | ||
90 | // Global Textures | ||
91 | private string sunTexture; | ||
92 | private string cloudTexture; | ||
93 | private string moonTexture; | ||
94 | |||
95 | // Error Flags | 173 | // Error Flags |
96 | private string errorReason; | 174 | private string errorReason; |
97 | private string errorMessage; | 175 | private string errorMessage; |
98 | 176 | ||
99 | // Response | ||
100 | private XmlRpcResponse xmlRpcResponse; | ||
101 | // private XmlRpcResponse defaultXmlRpcResponse; | ||
102 | |||
103 | private string welcomeMessage; | 177 | private string welcomeMessage; |
104 | private string startLocation; | 178 | private string startLocation; |
105 | private string allowFirstLife; | 179 | private string allowFirstLife; |
@@ -109,7 +183,17 @@ namespace OpenSim.Framework.Communications.Services | |||
109 | 183 | ||
110 | private BuddyList m_buddyList = null; | 184 | private BuddyList m_buddyList = null; |
111 | 185 | ||
112 | public LoginResponse() | 186 | static LLLoginResponse() |
187 | { | ||
188 | // This is being set, but it's not used | ||
189 | // not sure why. | ||
190 | globalTexturesHash = new Hashtable(); | ||
191 | globalTexturesHash["sun_texture_id"] = sunTexture; | ||
192 | globalTexturesHash["cloud_texture_id"] = cloudTexture; | ||
193 | globalTexturesHash["moon_texture_id"] = moonTexture; | ||
194 | } | ||
195 | |||
196 | public LLLoginResponse() | ||
113 | { | 197 | { |
114 | loginFlags = new ArrayList(); | 198 | loginFlags = new ArrayList(); |
115 | globalTextures = new ArrayList(); | 199 | globalTextures = new ArrayList(); |
@@ -117,7 +201,6 @@ namespace OpenSim.Framework.Communications.Services | |||
117 | uiConfig = new ArrayList(); | 201 | uiConfig = new ArrayList(); |
118 | classifiedCategories = new ArrayList(); | 202 | classifiedCategories = new ArrayList(); |
119 | 203 | ||
120 | loginError = new Hashtable(); | ||
121 | uiConfigHash = new Hashtable(); | 204 | uiConfigHash = new Hashtable(); |
122 | 205 | ||
123 | // defaultXmlRpcResponse = new XmlRpcResponse(); | 206 | // defaultXmlRpcResponse = new XmlRpcResponse(); |
@@ -129,12 +212,136 @@ namespace OpenSim.Framework.Communications.Services | |||
129 | inventoryLibraryOwner = new ArrayList(); | 212 | inventoryLibraryOwner = new ArrayList(); |
130 | activeGestures = new ArrayList(); | 213 | activeGestures = new ArrayList(); |
131 | 214 | ||
132 | xmlRpcResponse = new XmlRpcResponse(); | ||
133 | // defaultXmlRpcResponse = new XmlRpcResponse(); | ||
134 | |||
135 | SetDefaultValues(); | 215 | SetDefaultValues(); |
136 | } | 216 | } |
137 | 217 | ||
218 | public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, PresenceInfo pinfo, | ||
219 | GridRegion destination, List<InventoryFolderBase> invSkel, FriendInfo[] friendsList, ILibraryService libService, | ||
220 | string where, string startlocation, Vector3 position, Vector3 lookAt, string message, | ||
221 | GridRegion home, IPEndPoint clientIP) | ||
222 | : this() | ||
223 | { | ||
224 | FillOutInventoryData(invSkel, libService); | ||
225 | |||
226 | CircuitCode = (int)aCircuit.circuitcode; | ||
227 | Lastname = account.LastName; | ||
228 | Firstname = account.FirstName; | ||
229 | AgentID = account.PrincipalID; | ||
230 | SessionID = aCircuit.SessionID; | ||
231 | SecureSessionID = aCircuit.SecureSessionID; | ||
232 | Message = message; | ||
233 | BuddList = ConvertFriendListItem(friendsList); | ||
234 | StartLocation = where; | ||
235 | |||
236 | FillOutHomeData(pinfo, home); | ||
237 | LookAt = String.Format("[r{0},r{1},r{2}]", lookAt.X, lookAt.Y, lookAt.Z); | ||
238 | |||
239 | FillOutRegionData(destination); | ||
240 | |||
241 | FillOutSeedCap(aCircuit, destination, clientIP); | ||
242 | |||
243 | } | ||
244 | |||
245 | private void FillOutInventoryData(List<InventoryFolderBase> invSkel, ILibraryService libService) | ||
246 | { | ||
247 | InventoryData inventData = null; | ||
248 | |||
249 | try | ||
250 | { | ||
251 | inventData = GetInventorySkeleton(invSkel); | ||
252 | } | ||
253 | catch (Exception e) | ||
254 | { | ||
255 | m_log.WarnFormat( | ||
256 | "[LLLOGIN SERVICE]: Error processing inventory skeleton of agent {0} - {1}", | ||
257 | agentID, e); | ||
258 | |||
259 | // ignore and continue | ||
260 | } | ||
261 | |||
262 | if (inventData != null) | ||
263 | { | ||
264 | ArrayList AgentInventoryArray = inventData.InventoryArray; | ||
265 | |||
266 | Hashtable InventoryRootHash = new Hashtable(); | ||
267 | InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); | ||
268 | InventoryRoot = new ArrayList(); | ||
269 | InventoryRoot.Add(InventoryRootHash); | ||
270 | InventorySkeleton = AgentInventoryArray; | ||
271 | } | ||
272 | |||
273 | // Inventory Library Section | ||
274 | if (libService != null && libService.LibraryRootFolder != null) | ||
275 | { | ||
276 | Hashtable InventoryLibRootHash = new Hashtable(); | ||
277 | InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; | ||
278 | InventoryLibRoot = new ArrayList(); | ||
279 | InventoryLibRoot.Add(InventoryLibRootHash); | ||
280 | |||
281 | InventoryLibraryOwner = GetLibraryOwner(libService.LibraryRootFolder); | ||
282 | InventoryLibrary = GetInventoryLibrary(libService); | ||
283 | } | ||
284 | } | ||
285 | |||
286 | private void FillOutHomeData(PresenceInfo pinfo, GridRegion home) | ||
287 | { | ||
288 | int x = 1000 * (int)Constants.RegionSize, y = 1000 * (int)Constants.RegionSize; | ||
289 | if (home != null) | ||
290 | { | ||
291 | x = home.RegionLocX; | ||
292 | y = home.RegionLocY; | ||
293 | } | ||
294 | |||
295 | Home = string.Format( | ||
296 | "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", | ||
297 | x, | ||
298 | y, | ||
299 | pinfo.HomePosition.X, pinfo.HomePosition.Y, pinfo.HomePosition.Z, | ||
300 | pinfo.HomeLookAt.X, pinfo.HomeLookAt.Y, pinfo.HomeLookAt.Z); | ||
301 | |||
302 | } | ||
303 | |||
304 | private void FillOutRegionData(GridRegion destination) | ||
305 | { | ||
306 | IPEndPoint endPoint = destination.ExternalEndPoint; | ||
307 | SimAddress = endPoint.Address.ToString(); | ||
308 | SimPort = (uint)endPoint.Port; | ||
309 | RegionX = (uint)destination.RegionLocX; | ||
310 | RegionY = (uint)destination.RegionLocY; | ||
311 | } | ||
312 | |||
313 | private void FillOutSeedCap(AgentCircuitData aCircuit, GridRegion destination, IPEndPoint ipepClient) | ||
314 | { | ||
315 | string capsSeedPath = String.Empty; | ||
316 | |||
317 | // Don't use the following! It Fails for logging into any region not on the same port as the http server! | ||
318 | // Kept here so it doesn't happen again! | ||
319 | // response.SeedCapability = regionInfo.ServerURI + capsSeedPath; | ||
320 | |||
321 | #region IP Translation for NAT | ||
322 | if (ipepClient != null) | ||
323 | { | ||
324 | capsSeedPath | ||
325 | = "http://" | ||
326 | + NetworkUtil.GetHostFor(ipepClient.Address, destination.ExternalHostName) | ||
327 | + ":" | ||
328 | + destination.HttpPort | ||
329 | + CapsUtil.GetCapsSeedPath(aCircuit.CapsPath); | ||
330 | } | ||
331 | else | ||
332 | { | ||
333 | capsSeedPath | ||
334 | = "http://" | ||
335 | + destination.ExternalHostName | ||
336 | + ":" | ||
337 | + destination.HttpPort | ||
338 | + CapsUtil.GetCapsSeedPath(aCircuit.CapsPath); | ||
339 | } | ||
340 | #endregion | ||
341 | |||
342 | SeedCapability = capsSeedPath; | ||
343 | } | ||
344 | |||
138 | private void SetDefaultValues() | 345 | private void SetDefaultValues() |
139 | { | 346 | { |
140 | DST = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; | 347 | DST = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; |
@@ -149,10 +356,6 @@ namespace OpenSim.Framework.Communications.Services | |||
149 | startLocation = "last"; | 356 | startLocation = "last"; |
150 | allowFirstLife = "Y"; | 357 | allowFirstLife = "Y"; |
151 | 358 | ||
152 | SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271"; | ||
153 | CloudTexture = "dc4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
154 | MoonTexture = "ec4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
155 | |||
156 | ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock."; | 359 | ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock."; |
157 | ErrorReason = "key"; | 360 | ErrorReason = "key"; |
158 | welcomeMessage = "Welcome to OpenSim!"; | 361 | welcomeMessage = "Welcome to OpenSim!"; |
@@ -186,149 +389,8 @@ namespace OpenSim.Framework.Communications.Services | |||
186 | initialOutfit.Add(InitialOutfitHash); | 389 | initialOutfit.Add(InitialOutfitHash); |
187 | } | 390 | } |
188 | 391 | ||
189 | #region Login Failure Methods | ||
190 | |||
191 | public XmlRpcResponse GenerateFailureResponse(string reason, string message, string login) | ||
192 | { | ||
193 | // Overwrite any default values; | ||
194 | xmlRpcResponse = new XmlRpcResponse(); | ||
195 | |||
196 | // Ensure Login Failed message/reason; | ||
197 | ErrorMessage = message; | ||
198 | ErrorReason = reason; | ||
199 | |||
200 | loginError["reason"] = ErrorReason; | ||
201 | loginError["message"] = ErrorMessage; | ||
202 | loginError["login"] = login; | ||
203 | xmlRpcResponse.Value = loginError; | ||
204 | return (xmlRpcResponse); | ||
205 | } | ||
206 | 392 | ||
207 | public OSD GenerateFailureResponseLLSD(string reason, string message, string login) | 393 | public override Hashtable ToHashtable() |
208 | { | ||
209 | OSDMap map = new OSDMap(); | ||
210 | |||
211 | // Ensure Login Failed message/reason; | ||
212 | ErrorMessage = message; | ||
213 | ErrorReason = reason; | ||
214 | |||
215 | map["reason"] = OSD.FromString(ErrorReason); | ||
216 | map["message"] = OSD.FromString(ErrorMessage); | ||
217 | map["login"] = OSD.FromString(login); | ||
218 | |||
219 | return map; | ||
220 | } | ||
221 | |||
222 | public XmlRpcResponse CreateFailedResponse() | ||
223 | { | ||
224 | return (CreateLoginFailedResponse()); | ||
225 | } | ||
226 | |||
227 | public OSD CreateFailedResponseLLSD() | ||
228 | { | ||
229 | return CreateLoginFailedResponseLLSD(); | ||
230 | } | ||
231 | |||
232 | public XmlRpcResponse CreateLoginFailedResponse() | ||
233 | { | ||
234 | return | ||
235 | (GenerateFailureResponse("key", | ||
236 | "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", | ||
237 | "false")); | ||
238 | } | ||
239 | |||
240 | public OSD CreateLoginFailedResponseLLSD() | ||
241 | { | ||
242 | return GenerateFailureResponseLLSD( | ||
243 | "key", | ||
244 | "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", | ||
245 | "false"); | ||
246 | } | ||
247 | |||
248 | /// <summary> | ||
249 | /// Response to indicate that login failed because the agent's inventory was not available. | ||
250 | /// </summary> | ||
251 | /// <returns></returns> | ||
252 | public XmlRpcResponse CreateLoginInventoryFailedResponse() | ||
253 | { | ||
254 | return GenerateFailureResponse( | ||
255 | "key", | ||
256 | "The avatar inventory service is not responding. Please notify your login region operator.", | ||
257 | "false"); | ||
258 | } | ||
259 | |||
260 | public XmlRpcResponse CreateAlreadyLoggedInResponse() | ||
261 | { | ||
262 | return | ||
263 | (GenerateFailureResponse("presence", | ||
264 | "You appear to be already logged in. " + | ||
265 | "If this is not the case please wait for your session to timeout. " + | ||
266 | "If this takes longer than a few minutes please contact the grid owner. " + | ||
267 | "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.", | ||
268 | "false")); | ||
269 | } | ||
270 | |||
271 | public OSD CreateAlreadyLoggedInResponseLLSD() | ||
272 | { | ||
273 | return GenerateFailureResponseLLSD( | ||
274 | "presence", | ||
275 | "You appear to be already logged in. " + | ||
276 | "If this is not the case please wait for your session to timeout. " + | ||
277 | "If this takes longer than a few minutes please contact the grid owner", | ||
278 | "false"); | ||
279 | } | ||
280 | |||
281 | public XmlRpcResponse CreateLoginBlockedResponse() | ||
282 | { | ||
283 | return | ||
284 | (GenerateFailureResponse("presence", | ||
285 | "Logins are currently restricted. Please try again later", | ||
286 | "false")); | ||
287 | } | ||
288 | |||
289 | public OSD CreateLoginBlockedResponseLLSD() | ||
290 | { | ||
291 | return GenerateFailureResponseLLSD( | ||
292 | "presence", | ||
293 | "Logins are currently restricted. Please try again later", | ||
294 | "false"); | ||
295 | } | ||
296 | |||
297 | public XmlRpcResponse CreateDeadRegionResponse() | ||
298 | { | ||
299 | return | ||
300 | (GenerateFailureResponse("key", | ||
301 | "The region you are attempting to log into is not responding. Please select another region and try again.", | ||
302 | "false")); | ||
303 | } | ||
304 | |||
305 | public OSD CreateDeadRegionResponseLLSD() | ||
306 | { | ||
307 | return GenerateFailureResponseLLSD( | ||
308 | "key", | ||
309 | "The region you are attempting to log into is not responding. Please select another region and try again.", | ||
310 | "false"); | ||
311 | } | ||
312 | |||
313 | public XmlRpcResponse CreateGridErrorResponse() | ||
314 | { | ||
315 | return | ||
316 | (GenerateFailureResponse("key", | ||
317 | "Error connecting to grid. Could not percieve credentials from login XML.", | ||
318 | "false")); | ||
319 | } | ||
320 | |||
321 | public OSD CreateGridErrorResponseLLSD() | ||
322 | { | ||
323 | return GenerateFailureResponseLLSD( | ||
324 | "key", | ||
325 | "Error connecting to grid. Could not perceive credentials from login XML.", | ||
326 | "false"); | ||
327 | } | ||
328 | |||
329 | #endregion | ||
330 | |||
331 | public virtual XmlRpcResponse ToXmlRpcResponse() | ||
332 | { | 394 | { |
333 | try | 395 | try |
334 | { | 396 | { |
@@ -346,10 +408,6 @@ namespace OpenSim.Framework.Communications.Services | |||
346 | responseData["agent_access"] = agentAccess; | 408 | responseData["agent_access"] = agentAccess; |
347 | responseData["agent_access_max"] = agentAccessMax; | 409 | responseData["agent_access_max"] = agentAccessMax; |
348 | 410 | ||
349 | globalTexturesHash = new Hashtable(); | ||
350 | globalTexturesHash["sun_texture_id"] = SunTexture; | ||
351 | globalTexturesHash["cloud_texture_id"] = CloudTexture; | ||
352 | globalTexturesHash["moon_texture_id"] = MoonTexture; | ||
353 | globalTextures.Add(globalTexturesHash); | 411 | globalTextures.Add(globalTexturesHash); |
354 | // this.eventCategories.Add(this.eventCategoriesHash); | 412 | // this.eventCategories.Add(this.eventCategoriesHash); |
355 | 413 | ||
@@ -389,8 +447,8 @@ namespace OpenSim.Framework.Communications.Services | |||
389 | responseData["home"] = home; | 447 | responseData["home"] = home; |
390 | responseData["look_at"] = lookAt; | 448 | responseData["look_at"] = lookAt; |
391 | responseData["message"] = welcomeMessage; | 449 | responseData["message"] = welcomeMessage; |
392 | responseData["region_x"] = (Int32)(RegionX * Constants.RegionSize); | 450 | responseData["region_x"] = (Int32)(RegionX); |
393 | responseData["region_y"] = (Int32)(RegionY * Constants.RegionSize); | 451 | responseData["region_y"] = (Int32)(RegionY); |
394 | 452 | ||
395 | if (m_buddyList != null) | 453 | if (m_buddyList != null) |
396 | { | 454 | { |
@@ -398,19 +456,18 @@ namespace OpenSim.Framework.Communications.Services | |||
398 | } | 456 | } |
399 | 457 | ||
400 | responseData["login"] = "true"; | 458 | responseData["login"] = "true"; |
401 | xmlRpcResponse.Value = responseData; | ||
402 | 459 | ||
403 | return (xmlRpcResponse); | 460 | return responseData; |
404 | } | 461 | } |
405 | catch (Exception e) | 462 | catch (Exception e) |
406 | { | 463 | { |
407 | m_log.Warn("[CLIENT]: LoginResponse: Error creating XML-RPC Response: " + e.Message); | 464 | m_log.Warn("[CLIENT]: LoginResponse: Error creating Hashtable Response: " + e.Message); |
408 | 465 | ||
409 | return (GenerateFailureResponse("Internal Error", "Error generating Login Response", "false")); | 466 | return LLFailedLoginResponse.InternalError.ToHashtable(); |
410 | } | 467 | } |
411 | } | 468 | } |
412 | 469 | ||
413 | public OSD ToLLSDResponse() | 470 | public override OSD ToOSDMap() |
414 | { | 471 | { |
415 | try | 472 | try |
416 | { | 473 | { |
@@ -486,8 +543,8 @@ namespace OpenSim.Framework.Communications.Services | |||
486 | map["home"] = OSD.FromString(home); | 543 | map["home"] = OSD.FromString(home); |
487 | map["look_at"] = OSD.FromString(lookAt); | 544 | map["look_at"] = OSD.FromString(lookAt); |
488 | map["message"] = OSD.FromString(welcomeMessage); | 545 | map["message"] = OSD.FromString(welcomeMessage); |
489 | map["region_x"] = OSD.FromInteger(RegionX * Constants.RegionSize); | 546 | map["region_x"] = OSD.FromInteger(RegionX); |
490 | map["region_y"] = OSD.FromInteger(RegionY * Constants.RegionSize); | 547 | map["region_y"] = OSD.FromInteger(RegionY); |
491 | 548 | ||
492 | if (m_buddyList != null) | 549 | if (m_buddyList != null) |
493 | { | 550 | { |
@@ -502,7 +559,7 @@ namespace OpenSim.Framework.Communications.Services | |||
502 | { | 559 | { |
503 | m_log.Warn("[CLIENT]: LoginResponse: Error creating LLSD Response: " + e.Message); | 560 | m_log.Warn("[CLIENT]: LoginResponse: Error creating LLSD Response: " + e.Message); |
504 | 561 | ||
505 | return GenerateFailureResponseLLSD("Internal Error", "Error generating Login Response", "false"); | 562 | return LLFailedLoginResponse.InternalError.ToOSDMap(); |
506 | } | 563 | } |
507 | } | 564 | } |
508 | 565 | ||
@@ -548,6 +605,98 @@ namespace OpenSim.Framework.Communications.Services | |||
548 | // this.classifiedCategoriesHash.Clear(); | 605 | // this.classifiedCategoriesHash.Clear(); |
549 | } | 606 | } |
550 | 607 | ||
608 | |||
609 | private static LLLoginResponse.BuddyList ConvertFriendListItem(FriendInfo[] friendsList) | ||
610 | { | ||
611 | LLLoginResponse.BuddyList buddylistreturn = new LLLoginResponse.BuddyList(); | ||
612 | foreach (FriendInfo finfo in friendsList) | ||
613 | { | ||
614 | if (finfo.TheirFlags == -1) | ||
615 | continue; | ||
616 | LLLoginResponse.BuddyList.BuddyInfo buddyitem = new LLLoginResponse.BuddyList.BuddyInfo(finfo.Friend); | ||
617 | buddyitem.BuddyID = finfo.Friend; | ||
618 | buddyitem.BuddyRightsHave = (int)finfo.TheirFlags; | ||
619 | buddyitem.BuddyRightsGiven = (int)finfo.MyFlags; | ||
620 | buddylistreturn.AddNewBuddy(buddyitem); | ||
621 | } | ||
622 | return buddylistreturn; | ||
623 | } | ||
624 | |||
625 | private InventoryData GetInventorySkeleton(List<InventoryFolderBase> folders) | ||
626 | { | ||
627 | UUID rootID = UUID.Zero; | ||
628 | ArrayList AgentInventoryArray = new ArrayList(); | ||
629 | Hashtable TempHash; | ||
630 | foreach (InventoryFolderBase InvFolder in folders) | ||
631 | { | ||
632 | if (InvFolder.ParentID == UUID.Zero) | ||
633 | { | ||
634 | rootID = InvFolder.ID; | ||
635 | } | ||
636 | TempHash = new Hashtable(); | ||
637 | TempHash["name"] = InvFolder.Name; | ||
638 | TempHash["parent_id"] = InvFolder.ParentID.ToString(); | ||
639 | TempHash["version"] = (Int32)InvFolder.Version; | ||
640 | TempHash["type_default"] = (Int32)InvFolder.Type; | ||
641 | TempHash["folder_id"] = InvFolder.ID.ToString(); | ||
642 | AgentInventoryArray.Add(TempHash); | ||
643 | } | ||
644 | |||
645 | return new InventoryData(AgentInventoryArray, rootID); | ||
646 | |||
647 | } | ||
648 | |||
649 | /// <summary> | ||
650 | /// Converts the inventory library skeleton into the form required by the rpc request. | ||
651 | /// </summary> | ||
652 | /// <returns></returns> | ||
653 | protected virtual ArrayList GetInventoryLibrary(ILibraryService library) | ||
654 | { | ||
655 | Dictionary<UUID, InventoryFolderImpl> rootFolders = library.GetAllFolders(); | ||
656 | m_log.DebugFormat("[LLOGIN]: Library has {0} folders", rootFolders.Count); | ||
657 | //Dictionary<UUID, InventoryFolderImpl> rootFolders = new Dictionary<UUID,InventoryFolderImpl>(); | ||
658 | ArrayList folderHashes = new ArrayList(); | ||
659 | |||
660 | foreach (InventoryFolderBase folder in rootFolders.Values) | ||
661 | { | ||
662 | Hashtable TempHash = new Hashtable(); | ||
663 | TempHash["name"] = folder.Name; | ||
664 | TempHash["parent_id"] = folder.ParentID.ToString(); | ||
665 | TempHash["version"] = (Int32)folder.Version; | ||
666 | TempHash["type_default"] = (Int32)folder.Type; | ||
667 | TempHash["folder_id"] = folder.ID.ToString(); | ||
668 | folderHashes.Add(TempHash); | ||
669 | } | ||
670 | |||
671 | return folderHashes; | ||
672 | } | ||
673 | |||
674 | /// <summary> | ||
675 | /// | ||
676 | /// </summary> | ||
677 | /// <returns></returns> | ||
678 | protected virtual ArrayList GetLibraryOwner(InventoryFolderImpl libFolder) | ||
679 | { | ||
680 | //for now create random inventory library owner | ||
681 | Hashtable TempHash = new Hashtable(); | ||
682 | TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; // libFolder.Owner | ||
683 | ArrayList inventoryLibOwner = new ArrayList(); | ||
684 | inventoryLibOwner.Add(TempHash); | ||
685 | return inventoryLibOwner; | ||
686 | } | ||
687 | |||
688 | public class InventoryData | ||
689 | { | ||
690 | public ArrayList InventoryArray = null; | ||
691 | public UUID RootFolderID = UUID.Zero; | ||
692 | |||
693 | public InventoryData(ArrayList invList, UUID rootID) | ||
694 | { | ||
695 | InventoryArray = invList; | ||
696 | RootFolderID = rootID; | ||
697 | } | ||
698 | } | ||
699 | |||
551 | #region Properties | 700 | #region Properties |
552 | 701 | ||
553 | public string Login | 702 | public string Login |
@@ -797,16 +946,16 @@ namespace OpenSim.Framework.Communications.Services | |||
797 | { | 946 | { |
798 | public int BuddyRightsHave = 1; | 947 | public int BuddyRightsHave = 1; |
799 | public int BuddyRightsGiven = 1; | 948 | public int BuddyRightsGiven = 1; |
800 | public UUID BuddyID; | 949 | public string BuddyID; |
801 | 950 | ||
802 | public BuddyInfo(string buddyID) | 951 | public BuddyInfo(string buddyID) |
803 | { | 952 | { |
804 | BuddyID = new UUID(buddyID); | 953 | BuddyID = buddyID; |
805 | } | 954 | } |
806 | 955 | ||
807 | public BuddyInfo(UUID buddyID) | 956 | public BuddyInfo(UUID buddyID) |
808 | { | 957 | { |
809 | BuddyID = buddyID; | 958 | BuddyID = buddyID.ToString(); |
810 | } | 959 | } |
811 | 960 | ||
812 | public Hashtable ToHashTable() | 961 | public Hashtable ToHashTable() |
@@ -814,7 +963,7 @@ namespace OpenSim.Framework.Communications.Services | |||
814 | Hashtable hTable = new Hashtable(); | 963 | Hashtable hTable = new Hashtable(); |
815 | hTable["buddy_rights_has"] = BuddyRightsHave; | 964 | hTable["buddy_rights_has"] = BuddyRightsHave; |
816 | hTable["buddy_rights_given"] = BuddyRightsGiven; | 965 | hTable["buddy_rights_given"] = BuddyRightsGiven; |
817 | hTable["buddy_id"] = BuddyID.ToString(); | 966 | hTable["buddy_id"] = BuddyID; |
818 | return hTable; | 967 | return hTable; |
819 | } | 968 | } |
820 | } | 969 | } |