diff options
Diffstat (limited to 'OpenSim/Region')
33 files changed, 2429 insertions, 1654 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 9944852..3a802df 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | |||
@@ -6962,7 +6962,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6962 | assetRequestItem = invService.GetItem(assetRequestItem); | 6962 | assetRequestItem = invService.GetItem(assetRequestItem); |
6963 | if (assetRequestItem == null) | 6963 | if (assetRequestItem == null) |
6964 | { | 6964 | { |
6965 | assetRequestItem = ((Scene)m_scene).CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); | 6965 | ILibraryService lib = m_scene.RequestModuleInterface<ILibraryService>(); |
6966 | if (lib != null) | ||
6967 | assetRequestItem = lib.LibraryRootFolder.FindItem(itemID); | ||
6966 | if (assetRequestItem == null) | 6968 | if (assetRequestItem == null) |
6967 | return true; | 6969 | return true; |
6968 | } | 6970 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index a4a649c..123e2dd 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -44,1111 +44,49 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
44 | 44 | ||
45 | namespace OpenSim.Region.CoreModules.Avatar.Friends | 45 | namespace OpenSim.Region.CoreModules.Avatar.Friends |
46 | { | 46 | { |
47 | /* | 47 | public class FriendsModule : ISharedRegionModule, IFriendsModule |
48 | This module handles adding/removing friends, and the the presence | ||
49 | notification process for login/logoff of friends. | ||
50 | |||
51 | The presence notification works as follows: | ||
52 | - After the user initially connects to a region (so we now have a UDP | ||
53 | connection to work with), this module fetches the friends of user | ||
54 | (those are cached), their on-/offline status, and info about the | ||
55 | region they are in from the MessageServer. | ||
56 | - (*) It then informs the user about the on-/offline status of her friends. | ||
57 | - It then informs all online friends currently on this region-server about | ||
58 | user's new online status (this will save some network traffic, as local | ||
59 | messages don't have to be transferred inter-region, and it will be all | ||
60 | that has to be done in Standalone Mode). | ||
61 | - For the rest of the online friends (those not on this region-server), | ||
62 | this module uses the provided region-information to map users to | ||
63 | regions, and sends one notification to every region containing the | ||
64 | friends to inform on that server. | ||
65 | - The region-server will handle that in the following way: | ||
66 | - If it finds the friend, it informs her about the user being online. | ||
67 | - If it doesn't find the friend (maybe she TPed away in the meantime), | ||
68 | it stores that information. | ||
69 | - After it processed all friends, it returns the list of friends it | ||
70 | couldn't find. | ||
71 | - If this list isn't empty, the FriendsModule re-requests information | ||
72 | about those online friends that have been missed and starts at (*) | ||
73 | again until all friends have been found, or until it tried 3 times | ||
74 | (to prevent endless loops due to some uncaught error). | ||
75 | |||
76 | NOTE: Online/Offline notifications don't need to be sent on region change. | ||
77 | |||
78 | We implement two XMLRpc handlers here, handling all the inter-region things | ||
79 | we have to handle: | ||
80 | - On-/Offline-Notifications (bulk) | ||
81 | - Terminate Friendship messages (single) | ||
82 | */ | ||
83 | |||
84 | public class FriendsModule : IRegionModule, IFriendsModule | ||
85 | { | 48 | { |
86 | private class Transaction | 49 | public void Initialise(IConfigSource config) |
87 | { | 50 | { |
88 | public UUID agentID; | ||
89 | public string agentName; | ||
90 | public uint count; | ||
91 | |||
92 | public Transaction(UUID agentID, string agentName) | ||
93 | { | ||
94 | this.agentID = agentID; | ||
95 | this.agentName = agentName; | ||
96 | this.count = 1; | ||
97 | } | ||
98 | } | ||
99 | |||
100 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
101 | |||
102 | private Cache m_friendLists = new Cache(CacheFlags.AllowUpdate); | ||
103 | |||
104 | private Dictionary<UUID, ulong> m_rootAgents = new Dictionary<UUID, ulong>(); | ||
105 | |||
106 | private Dictionary<UUID, UUID> m_pendingCallingcardRequests = new Dictionary<UUID,UUID>(); | ||
107 | |||
108 | private Scene m_initialScene; // saves a lookup if we don't have a specific scene | ||
109 | private Dictionary<ulong, Scene> m_scenes = new Dictionary<ulong,Scene>(); | ||
110 | private IMessageTransferModule m_TransferModule = null; | ||
111 | |||
112 | private IGridService m_gridServices = null; | ||
113 | |||
114 | #region IRegionModule Members | ||
115 | |||
116 | public void Initialise(Scene scene, IConfigSource config) | ||
117 | { | ||
118 | lock (m_scenes) | ||
119 | { | ||
120 | if (m_scenes.Count == 0) | ||
121 | { | ||
122 | MainServer.Instance.AddXmlRPCHandler("presence_update_bulk", processPresenceUpdateBulk); | ||
123 | MainServer.Instance.AddXmlRPCHandler("terminate_friend", processTerminateFriend); | ||
124 | m_friendLists.DefaultTTL = new TimeSpan(1, 0, 0); // store entries for one hour max | ||
125 | m_initialScene = scene; | ||
126 | } | ||
127 | |||
128 | if (!m_scenes.ContainsKey(scene.RegionInfo.RegionHandle)) | ||
129 | m_scenes[scene.RegionInfo.RegionHandle] = scene; | ||
130 | } | ||
131 | |||
132 | scene.RegisterModuleInterface<IFriendsModule>(this); | ||
133 | |||
134 | scene.EventManager.OnNewClient += OnNewClient; | ||
135 | scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; | ||
136 | scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; | ||
137 | scene.EventManager.OnMakeChildAgent += MakeChildAgent; | ||
138 | scene.EventManager.OnClientClosed += ClientClosed; | ||
139 | } | 51 | } |
140 | 52 | ||
141 | public void PostInitialise() | 53 | public void PostInitialise() |
142 | { | 54 | { |
143 | if (m_scenes.Count > 0) | ||
144 | { | ||
145 | m_TransferModule = m_initialScene.RequestModuleInterface<IMessageTransferModule>(); | ||
146 | m_gridServices = m_initialScene.GridService; | ||
147 | } | ||
148 | if (m_TransferModule == null) | ||
149 | m_log.Error("[FRIENDS]: Unable to find a message transfer module, friendship offers will not work"); | ||
150 | } | 55 | } |
151 | 56 | ||
152 | public void Close() | 57 | public void Close() |
153 | { | 58 | { |
154 | } | 59 | } |
155 | 60 | ||
156 | public string Name | 61 | public void AddRegion(Scene scene) |
157 | { | ||
158 | get { return "FriendsModule"; } | ||
159 | } | ||
160 | |||
161 | public bool IsSharedModule | ||
162 | { | ||
163 | get { return true; } | ||
164 | } | ||
165 | |||
166 | #endregion | ||
167 | |||
168 | #region IInterregionFriendsComms | ||
169 | |||
170 | public List<UUID> InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List<UUID> friends, bool online) | ||
171 | { | 62 | { |
172 | List<UUID> tpdAway = new List<UUID>(); | ||
173 | |||
174 | // destRegionHandle is a region on another server | ||
175 | uint x = 0, y = 0; | ||
176 | Utils.LongToUInts(destRegionHandle, out x, out y); | ||
177 | GridRegion info = m_gridServices.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, (int)x, (int)y); | ||
178 | if (info != null) | ||
179 | { | ||
180 | string httpServer = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/presence_update_bulk"; | ||
181 | |||
182 | Hashtable reqParams = new Hashtable(); | ||
183 | reqParams["agentID"] = agentId.ToString(); | ||
184 | reqParams["agentOnline"] = online; | ||
185 | int count = 0; | ||
186 | foreach (UUID uuid in friends) | ||
187 | { | ||
188 | reqParams["friendID_" + count++] = uuid.ToString(); | ||
189 | } | ||
190 | reqParams["friendCount"] = count; | ||
191 | |||
192 | IList parameters = new ArrayList(); | ||
193 | parameters.Add(reqParams); | ||
194 | try | ||
195 | { | ||
196 | XmlRpcRequest request = new XmlRpcRequest("presence_update_bulk", parameters); | ||
197 | XmlRpcResponse response = request.Send(httpServer, 5000); | ||
198 | Hashtable respData = (Hashtable)response.Value; | ||
199 | |||
200 | count = (int)respData["friendCount"]; | ||
201 | for (int i = 0; i < count; ++i) | ||
202 | { | ||
203 | UUID uuid; | ||
204 | if (UUID.TryParse((string)respData["friendID_" + i], out uuid)) tpdAway.Add(uuid); | ||
205 | } | ||
206 | } | ||
207 | catch (WebException e) | ||
208 | { | ||
209 | // Ignore connect failures, simulators come and go | ||
210 | // | ||
211 | if (!e.Message.Contains("ConnectFailure")) | ||
212 | { | ||
213 | m_log.Error("[OGS1 GRID SERVICES]: InformFriendsInOtherRegion XMLRPC failure: ", e); | ||
214 | } | ||
215 | } | ||
216 | catch (Exception e) | ||
217 | { | ||
218 | m_log.Error("[OGS1 GRID SERVICES]: InformFriendsInOtherRegion XMLRPC failure: ", e); | ||
219 | } | ||
220 | } | ||
221 | else m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}???", destRegionHandle); | ||
222 | |||
223 | return tpdAway; | ||
224 | } | 63 | } |
225 | 64 | ||
226 | public bool TriggerTerminateFriend(ulong destRegionHandle, UUID agentID, UUID exFriendID) | 65 | public void RegionLoaded(Scene scene) |
227 | { | 66 | { |
228 | // destRegionHandle is a region on another server | ||
229 | uint x = 0, y = 0; | ||
230 | Utils.LongToUInts(destRegionHandle, out x, out y); | ||
231 | GridRegion info = m_gridServices.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, (int)x, (int)y); | ||
232 | if (info == null) | ||
233 | { | ||
234 | m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}", destRegionHandle); | ||
235 | return false; // region not found??? | ||
236 | } | ||
237 | |||
238 | string httpServer = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/presence_update_bulk"; | ||
239 | |||
240 | Hashtable reqParams = new Hashtable(); | ||
241 | reqParams["agentID"] = agentID.ToString(); | ||
242 | reqParams["friendID"] = exFriendID.ToString(); | ||
243 | |||
244 | IList parameters = new ArrayList(); | ||
245 | parameters.Add(reqParams); | ||
246 | try | ||
247 | { | ||
248 | XmlRpcRequest request = new XmlRpcRequest("terminate_friend", parameters); | ||
249 | XmlRpcResponse response = request.Send(httpServer, 5000); | ||
250 | Hashtable respData = (Hashtable)response.Value; | ||
251 | |||
252 | return (bool)respData["success"]; | ||
253 | } | ||
254 | catch (Exception e) | ||
255 | { | ||
256 | m_log.Error("[OGS1 GRID SERVICES]: InformFriendsInOtherRegion XMLRPC failure: ", e); | ||
257 | return false; | ||
258 | } | ||
259 | } | 67 | } |
260 | 68 | ||
261 | #endregion | 69 | public void RemoveRegion(Scene scene) |
262 | |||
263 | #region Incoming XMLRPC messages | ||
264 | /// <summary> | ||
265 | /// Receive presence information changes about clients in other regions. | ||
266 | /// </summary> | ||
267 | /// <param name="req"></param> | ||
268 | /// <returns></returns> | ||
269 | public XmlRpcResponse processPresenceUpdateBulk(XmlRpcRequest req, IPEndPoint remoteClient) | ||
270 | { | 70 | { |
271 | Hashtable requestData = (Hashtable)req.Params[0]; | ||
272 | |||
273 | List<UUID> friendsNotHere = new List<UUID>(); | ||
274 | |||
275 | // this is called with the expectation that all the friends in the request are on this region-server. | ||
276 | // But as some time passed since we checked (on the other region-server, via the MessagingServer), | ||
277 | // some of the friends might have teleported away. | ||
278 | // Actually, even now, between this line and the sending below, some people could TP away. So, | ||
279 | // we'll have to lock the m_rootAgents list for the duration to prevent/delay that. | ||
280 | lock (m_rootAgents) | ||
281 | { | ||
282 | List<ScenePresence> friendsHere = new List<ScenePresence>(); | ||
283 | |||
284 | try | ||
285 | { | ||
286 | UUID agentID = new UUID((string)requestData["agentID"]); | ||
287 | bool agentOnline = (bool)requestData["agentOnline"]; | ||
288 | int count = (int)requestData["friendCount"]; | ||
289 | for (int i = 0; i < count; ++i) | ||
290 | { | ||
291 | UUID uuid; | ||
292 | if (UUID.TryParse((string)requestData["friendID_" + i], out uuid)) | ||
293 | { | ||
294 | if (m_rootAgents.ContainsKey(uuid)) friendsHere.Add(GetRootPresenceFromAgentID(uuid)); | ||
295 | else friendsNotHere.Add(uuid); | ||
296 | } | ||
297 | } | ||
298 | |||
299 | // now send, as long as they are still here... | ||
300 | UUID[] agentUUID = new UUID[] { agentID }; | ||
301 | if (agentOnline) | ||
302 | { | ||
303 | foreach (ScenePresence agent in friendsHere) | ||
304 | { | ||
305 | agent.ControllingClient.SendAgentOnline(agentUUID); | ||
306 | } | ||
307 | } | ||
308 | else | ||
309 | { | ||
310 | foreach (ScenePresence agent in friendsHere) | ||
311 | { | ||
312 | agent.ControllingClient.SendAgentOffline(agentUUID); | ||
313 | } | ||
314 | } | ||
315 | } | ||
316 | catch(Exception e) | ||
317 | { | ||
318 | m_log.Warn("[FRIENDS]: Got exception while parsing presence_update_bulk request:", e); | ||
319 | } | ||
320 | } | ||
321 | |||
322 | // no need to lock anymore; if TPs happen now, worst case is that we have an additional agent in this region, | ||
323 | // which should be caught on the next iteration... | ||
324 | Hashtable result = new Hashtable(); | ||
325 | int idx = 0; | ||
326 | foreach (UUID uuid in friendsNotHere) | ||
327 | { | ||
328 | result["friendID_" + idx++] = uuid.ToString(); | ||
329 | } | ||
330 | result["friendCount"] = idx; | ||
331 | |||
332 | XmlRpcResponse response = new XmlRpcResponse(); | ||
333 | response.Value = result; | ||
334 | |||
335 | return response; | ||
336 | } | 71 | } |
337 | 72 | ||
338 | public XmlRpcResponse processTerminateFriend(XmlRpcRequest req, IPEndPoint remoteClient) | 73 | public string Name |
339 | { | ||
340 | Hashtable requestData = (Hashtable)req.Params[0]; | ||
341 | |||
342 | bool success = false; | ||
343 | |||
344 | UUID agentID; | ||
345 | UUID friendID; | ||
346 | if (requestData.ContainsKey("agentID") && UUID.TryParse((string)requestData["agentID"], out agentID) && | ||
347 | requestData.ContainsKey("friendID") && UUID.TryParse((string)requestData["friendID"], out friendID)) | ||
348 | { | ||
349 | // try to find it and if it is there, prevent it to vanish before we sent the message | ||
350 | lock (m_rootAgents) | ||
351 | { | ||
352 | if (m_rootAgents.ContainsKey(agentID)) | ||
353 | { | ||
354 | m_log.DebugFormat("[FRIEND]: Sending terminate friend {0} to agent {1}", friendID, agentID); | ||
355 | GetRootPresenceFromAgentID(agentID).ControllingClient.SendTerminateFriend(friendID); | ||
356 | success = true; | ||
357 | } | ||
358 | } | ||
359 | } | ||
360 | |||
361 | // return whether we were successful | ||
362 | Hashtable result = new Hashtable(); | ||
363 | result["success"] = success; | ||
364 | |||
365 | XmlRpcResponse response = new XmlRpcResponse(); | ||
366 | response.Value = result; | ||
367 | return response; | ||
368 | } | ||
369 | |||
370 | #endregion | ||
371 | |||
372 | #region Scene events | ||
373 | |||
374 | private void OnNewClient(IClientAPI client) | ||
375 | { | ||
376 | // All friends establishment protocol goes over instant message | ||
377 | // There's no way to send a message from the sim | ||
378 | // to a user to 'add a friend' without causing dialog box spam | ||
379 | |||
380 | // Subscribe to instant messages | ||
381 | client.OnInstantMessage += OnInstantMessage; | ||
382 | |||
383 | // Friend list management | ||
384 | client.OnApproveFriendRequest += OnApproveFriendRequest; | ||
385 | client.OnDenyFriendRequest += OnDenyFriendRequest; | ||
386 | client.OnTerminateFriendship += OnTerminateFriendship; | ||
387 | |||
388 | // ... calling card handling... | ||
389 | client.OnOfferCallingCard += OnOfferCallingCard; | ||
390 | client.OnAcceptCallingCard += OnAcceptCallingCard; | ||
391 | client.OnDeclineCallingCard += OnDeclineCallingCard; | ||
392 | |||
393 | // we need this one exactly once per agent session (see comments in the handler below) | ||
394 | client.OnEconomyDataRequest += OnEconomyDataRequest; | ||
395 | |||
396 | // if it leaves, we want to know, too | ||
397 | client.OnLogout += OnLogout; | ||
398 | |||
399 | client.OnGrantUserRights += GrantUserFriendRights; | ||
400 | client.OnTrackAgentEvent += FindAgent; | ||
401 | client.OnFindAgentEvent += FindAgent; | ||
402 | |||
403 | } | ||
404 | |||
405 | private void ClientClosed(UUID AgentId, Scene scene) | ||
406 | { | ||
407 | // agent's client was closed. As we handle logout in OnLogout, this here has only to handle | ||
408 | // TPing away (root agent is closed) or TPing/crossing in a region far enough away (client | ||
409 | // agent is closed). | ||
410 | // NOTE: In general, this doesn't mean that the agent logged out, just that it isn't around | ||
411 | // in one of the regions here anymore. | ||
412 | lock (m_rootAgents) | ||
413 | { | ||
414 | if (m_rootAgents.ContainsKey(AgentId)) | ||
415 | { | ||
416 | m_rootAgents.Remove(AgentId); | ||
417 | } | ||
418 | } | ||
419 | } | ||
420 | |||
421 | private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID) | ||
422 | { | ||
423 | lock (m_rootAgents) | ||
424 | { | ||
425 | m_rootAgents[avatar.UUID] = avatar.RegionHandle; | ||
426 | // Claim User! my user! Mine mine mine! | ||
427 | } | ||
428 | } | ||
429 | |||
430 | private void MakeChildAgent(ScenePresence avatar) | ||
431 | { | 74 | { |
432 | lock (m_rootAgents) | 75 | get { return "FriendsModule"; } |
433 | { | ||
434 | if (m_rootAgents.ContainsKey(avatar.UUID)) | ||
435 | { | ||
436 | // only delete if the region matches. As this is a shared module, the avatar could be | ||
437 | // root agent in another region on this server. | ||
438 | if (m_rootAgents[avatar.UUID] == avatar.RegionHandle) | ||
439 | { | ||
440 | m_rootAgents.Remove(avatar.UUID); | ||
441 | // m_log.Debug("[FRIEND]: Removing " + avatar.Firstname + " " + avatar.Lastname + " as a root agent"); | ||
442 | } | ||
443 | } | ||
444 | } | ||
445 | } | 76 | } |
446 | #endregion | ||
447 | 77 | ||
448 | private ScenePresence GetRootPresenceFromAgentID(UUID AgentID) | 78 | public Type ReplaceableInterface |
449 | { | 79 | { |
450 | ScenePresence returnAgent = null; | 80 | get { return null; } |
451 | lock (m_scenes) | ||
452 | { | ||
453 | ScenePresence queryagent = null; | ||
454 | foreach (Scene scene in m_scenes.Values) | ||
455 | { | ||
456 | queryagent = scene.GetScenePresence(AgentID); | ||
457 | if (queryagent != null) | ||
458 | { | ||
459 | if (!queryagent.IsChildAgent) | ||
460 | { | ||
461 | returnAgent = queryagent; | ||
462 | break; | ||
463 | } | ||
464 | } | ||
465 | } | ||
466 | } | ||
467 | return returnAgent; | ||
468 | } | 81 | } |
469 | 82 | ||
470 | private ScenePresence GetAnyPresenceFromAgentID(UUID AgentID) | ||
471 | { | ||
472 | ScenePresence returnAgent = null; | ||
473 | lock (m_scenes) | ||
474 | { | ||
475 | ScenePresence queryagent = null; | ||
476 | foreach (Scene scene in m_scenes.Values) | ||
477 | { | ||
478 | queryagent = scene.GetScenePresence(AgentID); | ||
479 | if (queryagent != null) | ||
480 | { | ||
481 | returnAgent = queryagent; | ||
482 | break; | ||
483 | } | ||
484 | } | ||
485 | } | ||
486 | return returnAgent; | ||
487 | } | ||
488 | |||
489 | public void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, string offerMessage) | 83 | public void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, string offerMessage) |
490 | { | 84 | { |
491 | CachedUserInfo userInfo = m_initialScene.CommsManager.UserProfileCacheService.GetUserDetails(fromUserId); | ||
492 | |||
493 | if (userInfo != null) | ||
494 | { | ||
495 | GridInstantMessage msg = new GridInstantMessage( | ||
496 | toUserClient.Scene, fromUserId, userInfo.UserProfile.Name, toUserClient.AgentId, | ||
497 | (byte)InstantMessageDialog.FriendshipOffered, offerMessage, false, Vector3.Zero); | ||
498 | |||
499 | FriendshipOffered(msg); | ||
500 | } | ||
501 | else | ||
502 | { | ||
503 | m_log.ErrorFormat("[FRIENDS]: No user found for id {0} in OfferFriendship()", fromUserId); | ||
504 | } | ||
505 | } | ||
506 | |||
507 | #region FriendRequestHandling | ||
508 | |||
509 | private void OnInstantMessage(IClientAPI client, GridInstantMessage im) | ||
510 | { | ||
511 | // Friend Requests go by Instant Message.. using the dialog param | ||
512 | // https://wiki.secondlife.com/wiki/ImprovedInstantMessage | ||
513 | |||
514 | if (im.dialog == (byte)InstantMessageDialog.FriendshipOffered) // 38 | ||
515 | { | ||
516 | // fromAgentName is the *destination* name (the friend we offer friendship to) | ||
517 | ScenePresence initiator = GetAnyPresenceFromAgentID(new UUID(im.fromAgentID)); | ||
518 | im.fromAgentName = initiator != null ? initiator.Name : "(hippo)"; | ||
519 | |||
520 | FriendshipOffered(im); | ||
521 | } | ||
522 | else if (im.dialog == (byte)InstantMessageDialog.FriendshipAccepted) // 39 | ||
523 | { | ||
524 | FriendshipAccepted(client, im); | ||
525 | } | ||
526 | else if (im.dialog == (byte)InstantMessageDialog.FriendshipDeclined) // 40 | ||
527 | { | ||
528 | FriendshipDeclined(client, im); | ||
529 | } | ||
530 | } | ||
531 | |||
532 | /// <summary> | ||
533 | /// Invoked when a user offers a friendship. | ||
534 | /// </summary> | ||
535 | /// | ||
536 | /// <param name="im"></param> | ||
537 | /// <param name="client"></param> | ||
538 | private void FriendshipOffered(GridInstantMessage im) | ||
539 | { | ||
540 | // this is triggered by the initiating agent: | ||
541 | // A local agent offers friendship to some possibly remote friend. | ||
542 | // A IM is triggered, processed here and sent to the friend (possibly in a remote region). | ||
543 | |||
544 | m_log.DebugFormat("[FRIEND]: Offer(38) - From: {0}, FromName: {1} To: {2}, Session: {3}, Message: {4}, Offline {5}", | ||
545 | im.fromAgentID, im.fromAgentName, im.toAgentID, im.imSessionID, im.message, im.offline); | ||
546 | |||
547 | // 1.20 protocol sends an UUID in the message field, instead of the friendship offer text. | ||
548 | // For interoperability, we have to clear that | ||
549 | if (Util.isUUID(im.message)) im.message = ""; | ||
550 | |||
551 | // be sneeky and use the initiator-UUID as transactionID. This means we can be stateless. | ||
552 | // we have to look up the agent name on friendship-approval, though. | ||
553 | im.imSessionID = im.fromAgentID; | ||
554 | |||
555 | if (m_TransferModule != null) | ||
556 | { | ||
557 | // Send it to whoever is the destination. | ||
558 | // If new friend is local, it will send an IM to the viewer. | ||
559 | // If new friend is remote, it will cause a OnGridInstantMessage on the remote server | ||
560 | m_TransferModule.SendInstantMessage( | ||
561 | im, | ||
562 | delegate(bool success) | ||
563 | { | ||
564 | m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success); | ||
565 | } | ||
566 | ); | ||
567 | } | ||
568 | } | ||
569 | |||
570 | /// <summary> | ||
571 | /// Invoked when a user accepts a friendship offer. | ||
572 | /// </summary> | ||
573 | /// <param name="im"></param> | ||
574 | /// <param name="client"></param> | ||
575 | private void FriendshipAccepted(IClientAPI client, GridInstantMessage im) | ||
576 | { | ||
577 | m_log.DebugFormat("[FRIEND]: 39 - from client {0}, agent {2} {3}, imsession {4} to {5}: {6} (dialog {7})", | ||
578 | client.AgentId, im.fromAgentID, im.fromAgentName, im.imSessionID, im.toAgentID, im.message, im.dialog); | ||
579 | } | ||
580 | |||
581 | /// <summary> | ||
582 | /// Invoked when a user declines a friendship offer. | ||
583 | /// </summary> | ||
584 | /// May not currently be used - see OnDenyFriendRequest() instead | ||
585 | /// <param name="im"></param> | ||
586 | /// <param name="client"></param> | ||
587 | private void FriendshipDeclined(IClientAPI client, GridInstantMessage im) | ||
588 | { | ||
589 | UUID fromAgentID = new UUID(im.fromAgentID); | ||
590 | UUID toAgentID = new UUID(im.toAgentID); | ||
591 | |||
592 | // declining the friendship offer causes a type 40 IM being sent to the (possibly remote) initiator | ||
593 | // toAgentID is initiator, fromAgentID declined friendship | ||
594 | m_log.DebugFormat("[FRIEND]: 40 - from client {0}, agent {1} {2}, imsession {3} to {4}: {5} (dialog {6})", | ||
595 | client != null ? client.AgentId.ToString() : "<null>", | ||
596 | fromAgentID, im.fromAgentName, im.imSessionID, im.toAgentID, im.message, im.dialog); | ||
597 | |||
598 | // Send the decline to whoever is the destination. | ||
599 | GridInstantMessage msg | ||
600 | = new GridInstantMessage( | ||
601 | client.Scene, fromAgentID, client.Name, toAgentID, | ||
602 | im.dialog, im.message, im.offline != 0, im.Position); | ||
603 | |||
604 | // If new friend is local, it will send an IM to the viewer. | ||
605 | // If new friend is remote, it will cause a OnGridInstantMessage on the remote server | ||
606 | m_TransferModule.SendInstantMessage(msg, | ||
607 | delegate(bool success) { | ||
608 | m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success); | ||
609 | } | ||
610 | ); | ||
611 | } | ||
612 | |||
613 | private void OnGridInstantMessage(GridInstantMessage msg) | ||
614 | { | ||
615 | // This event won't be raised unless we have that agent, | ||
616 | // so we can depend on the above not trying to send | ||
617 | // via grid again | ||
618 | //m_log.DebugFormat("[FRIEND]: Got GridIM from {0}, to {1}, imSession {2}, message {3}, dialog {4}", | ||
619 | // msg.fromAgentID, msg.toAgentID, msg.imSessionID, msg.message, msg.dialog); | ||
620 | |||
621 | if (msg.dialog == (byte)InstantMessageDialog.FriendshipOffered || | ||
622 | msg.dialog == (byte)InstantMessageDialog.FriendshipAccepted || | ||
623 | msg.dialog == (byte)InstantMessageDialog.FriendshipDeclined) | ||
624 | { | ||
625 | // this should succeed as we *know* the root agent is here. | ||
626 | m_TransferModule.SendInstantMessage(msg, | ||
627 | delegate(bool success) { | ||
628 | //m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success); | ||
629 | } | ||
630 | ); | ||
631 | } | ||
632 | |||
633 | if (msg.dialog == (byte)InstantMessageDialog.FriendshipAccepted) | ||
634 | { | ||
635 | // for accept friendship, we have to do a bit more | ||
636 | ApproveFriendship(new UUID(msg.fromAgentID), new UUID(msg.toAgentID), msg.fromAgentName); | ||
637 | } | ||
638 | } | ||
639 | |||
640 | private void ApproveFriendship(UUID fromAgentID, UUID toAgentID, string fromName) | ||
641 | { | ||
642 | m_log.DebugFormat("[FRIEND]: Approve friendship from {0} (ID: {1}) to {2}", | ||
643 | fromAgentID, fromName, toAgentID); | ||
644 | |||
645 | // a new friend was added in the initiator's and friend's data, so the cache entries are wrong now. | ||
646 | lock (m_friendLists) | ||
647 | { | ||
648 | m_friendLists.Invalidate(fromAgentID.ToString()); | ||
649 | m_friendLists.Invalidate(toAgentID.ToString()); | ||
650 | } | ||
651 | |||
652 | // now send presence update and add a calling card for the new friend | ||
653 | |||
654 | ScenePresence initiator = GetAnyPresenceFromAgentID(toAgentID); | ||
655 | if (initiator == null) | ||
656 | { | ||
657 | // quite wrong. Shouldn't happen. | ||
658 | m_log.WarnFormat("[FRIEND]: Coudn't find initiator of friend request {0}", toAgentID); | ||
659 | return; | ||
660 | } | ||
661 | |||
662 | m_log.DebugFormat("[FRIEND]: Tell {0} that {1} is online", | ||
663 | initiator.Name, fromName); | ||
664 | // tell initiator that friend is online | ||
665 | initiator.ControllingClient.SendAgentOnline(new UUID[] { fromAgentID }); | ||
666 | |||
667 | // find the folder for the friend... | ||
668 | //InventoryFolderImpl folder = | ||
669 | // initiator.Scene.CommsManager.UserProfileCacheService.GetUserDetails(toAgentID).FindFolderForType((int)InventoryType.CallingCard); | ||
670 | IInventoryService invService = initiator.Scene.InventoryService; | ||
671 | InventoryFolderBase folder = invService.GetFolderForType(toAgentID, AssetType.CallingCard); | ||
672 | if (folder != null) | ||
673 | { | ||
674 | // ... and add the calling card | ||
675 | CreateCallingCard(initiator.ControllingClient, fromAgentID, folder.ID, fromName); | ||
676 | } | ||
677 | } | ||
678 | |||
679 | private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders) | ||
680 | { | ||
681 | m_log.DebugFormat("[FRIEND]: Got approve friendship from {0} {1}, agentID {2}, tid {3}", | ||
682 | client.Name, client.AgentId, agentID, friendID); | ||
683 | |||
684 | // store the new friend persistently for both avatars | ||
685 | m_initialScene.StoreAddFriendship(friendID, agentID, (uint) FriendRights.CanSeeOnline); | ||
686 | |||
687 | // The cache entries aren't valid anymore either, as we just added a friend to both sides. | ||
688 | lock (m_friendLists) | ||
689 | { | ||
690 | m_friendLists.Invalidate(agentID.ToString()); | ||
691 | m_friendLists.Invalidate(friendID.ToString()); | ||
692 | } | ||
693 | |||
694 | // if it's a local friend, we don't have to do the lookup | ||
695 | ScenePresence friendPresence = GetAnyPresenceFromAgentID(friendID); | ||
696 | |||
697 | if (friendPresence != null) | ||
698 | { | ||
699 | m_log.Debug("[FRIEND]: Local agent detected."); | ||
700 | |||
701 | // create calling card | ||
702 | CreateCallingCard(client, friendID, callingCardFolders[0], friendPresence.Name); | ||
703 | |||
704 | // local message means OnGridInstantMessage won't be triggered, so do the work here. | ||
705 | friendPresence.ControllingClient.SendInstantMessage( | ||
706 | new GridInstantMessage(client.Scene, agentID, | ||
707 | client.Name, friendID, | ||
708 | (byte)InstantMessageDialog.FriendshipAccepted, | ||
709 | agentID.ToString(), false, Vector3.Zero)); | ||
710 | ApproveFriendship(agentID, friendID, client.Name); | ||
711 | } | ||
712 | else | ||
713 | { | ||
714 | m_log.Debug("[FRIEND]: Remote agent detected."); | ||
715 | |||
716 | // fetch the friend's name for the calling card. | ||
717 | CachedUserInfo info = m_initialScene.CommsManager.UserProfileCacheService.GetUserDetails(friendID); | ||
718 | |||
719 | // create calling card | ||
720 | CreateCallingCard(client, friendID, callingCardFolders[0], | ||
721 | info.UserProfile.FirstName + " " + info.UserProfile.SurName); | ||
722 | |||
723 | // Compose (remote) response to friend. | ||
724 | GridInstantMessage msg = new GridInstantMessage(client.Scene, agentID, client.Name, friendID, | ||
725 | (byte)InstantMessageDialog.FriendshipAccepted, | ||
726 | agentID.ToString(), false, Vector3.Zero); | ||
727 | if (m_TransferModule != null) | ||
728 | { | ||
729 | m_TransferModule.SendInstantMessage(msg, | ||
730 | delegate(bool success) { | ||
731 | m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success); | ||
732 | } | ||
733 | ); | ||
734 | } | ||
735 | } | ||
736 | |||
737 | // tell client that new friend is online | ||
738 | client.SendAgentOnline(new UUID[] { friendID }); | ||
739 | } | ||
740 | |||
741 | private void OnDenyFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders) | ||
742 | { | ||
743 | m_log.DebugFormat("[FRIEND]: Got deny friendship from {0} {1}, agentID {2}, tid {3}", | ||
744 | client.Name, client.AgentId, agentID, friendID); | ||
745 | |||
746 | // Compose response to other agent. | ||
747 | GridInstantMessage msg = new GridInstantMessage(client.Scene, agentID, client.Name, friendID, | ||
748 | (byte)InstantMessageDialog.FriendshipDeclined, | ||
749 | agentID.ToString(), false, Vector3.Zero); | ||
750 | // send decline to initiator | ||
751 | if (m_TransferModule != null) | ||
752 | { | ||
753 | m_TransferModule.SendInstantMessage(msg, | ||
754 | delegate(bool success) { | ||
755 | m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success); | ||
756 | } | ||
757 | ); | ||
758 | } | ||
759 | } | ||
760 | |||
761 | private void OnTerminateFriendship(IClientAPI client, UUID agentID, UUID exfriendID) | ||
762 | { | ||
763 | // client.AgentId == agentID! | ||
764 | |||
765 | // this removes the friends from the stored friendlists. After the next login, they will be gone... | ||
766 | m_initialScene.StoreRemoveFriendship(agentID, exfriendID); | ||
767 | |||
768 | // ... now tell the two involved clients that they aren't friends anymore. | ||
769 | |||
770 | // I don't know why we have to tell <agent>, as this was caused by her, but that's how it works in SL... | ||
771 | client.SendTerminateFriend(exfriendID); | ||
772 | |||
773 | // now send the friend, if online | ||
774 | ScenePresence presence = GetAnyPresenceFromAgentID(exfriendID); | ||
775 | if (presence != null) | ||
776 | { | ||
777 | m_log.DebugFormat("[FRIEND]: Sending terminate friend {0} to agent {1}", agentID, exfriendID); | ||
778 | presence.ControllingClient.SendTerminateFriend(agentID); | ||
779 | } | ||
780 | else | ||
781 | { | ||
782 | // retry 3 times, in case the agent TPed from the last known region... | ||
783 | for (int retry = 0; retry < 3; ++retry) | ||
784 | { | ||
785 | // wasn't sent, so ex-friend wasn't around on this region-server. Fetch info and try to send | ||
786 | UserAgentData data = m_initialScene.CommsManager.UserService.GetAgentByUUID(exfriendID); | ||
787 | |||
788 | if (null == data) | ||
789 | break; | ||
790 | |||
791 | if (!data.AgentOnline) | ||
792 | { | ||
793 | m_log.DebugFormat("[FRIEND]: {0} is offline, so not sending TerminateFriend", exfriendID); | ||
794 | break; // if ex-friend isn't online, we don't need to send | ||
795 | } | ||
796 | |||
797 | m_log.DebugFormat("[FRIEND]: Sending remote terminate friend {0} to agent {1}@{2}", | ||
798 | agentID, exfriendID, data.Handle); | ||
799 | |||
800 | // try to send to foreign region, retry if it fails (friend TPed away, for example) | ||
801 | if (TriggerTerminateFriend(data.Handle, exfriendID, agentID)) break; | ||
802 | } | ||
803 | } | ||
804 | |||
805 | // clean up cache: FriendList is wrong now... | ||
806 | lock (m_friendLists) | ||
807 | { | ||
808 | m_friendLists.Invalidate(agentID.ToString()); | ||
809 | m_friendLists.Invalidate(exfriendID.ToString()); | ||
810 | } | ||
811 | } | ||
812 | |||
813 | #endregion | ||
814 | |||
815 | #region CallingCards | ||
816 | |||
817 | private void OnOfferCallingCard(IClientAPI client, UUID destID, UUID transactionID) | ||
818 | { | ||
819 | m_log.DebugFormat("[CALLING CARD]: got offer from {0} for {1}, transaction {2}", | ||
820 | client.AgentId, destID, transactionID); | ||
821 | // This might be slightly wrong. On a multi-region server, we might get the child-agent instead of the root-agent | ||
822 | // (or the root instead of the child) | ||
823 | ScenePresence destAgent = GetAnyPresenceFromAgentID(destID); | ||
824 | if (destAgent == null) | ||
825 | { | ||
826 | client.SendAlertMessage("The person you have offered a card to can't be found anymore."); | ||
827 | return; | ||
828 | } | ||
829 | |||
830 | lock (m_pendingCallingcardRequests) | ||
831 | { | ||
832 | m_pendingCallingcardRequests[transactionID] = client.AgentId; | ||
833 | } | ||
834 | // inform the destination agent about the offer | ||
835 | destAgent.ControllingClient.SendOfferCallingCard(client.AgentId, transactionID); | ||
836 | } | ||
837 | |||
838 | private void CreateCallingCard(IClientAPI client, UUID creator, UUID folder, string name) | ||
839 | { | ||
840 | InventoryItemBase item = new InventoryItemBase(); | ||
841 | item.AssetID = UUID.Zero; | ||
842 | item.AssetType = (int)AssetType.CallingCard; | ||
843 | item.BasePermissions = (uint)PermissionMask.Copy; | ||
844 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
845 | item.CreatorId = creator.ToString(); | ||
846 | item.CurrentPermissions = item.BasePermissions; | ||
847 | item.Description = ""; | ||
848 | item.EveryOnePermissions = (uint)PermissionMask.None; | ||
849 | item.Flags = 0; | ||
850 | item.Folder = folder; | ||
851 | item.GroupID = UUID.Zero; | ||
852 | item.GroupOwned = false; | ||
853 | item.ID = UUID.Random(); | ||
854 | item.InvType = (int)InventoryType.CallingCard; | ||
855 | item.Name = name; | ||
856 | item.NextPermissions = item.EveryOnePermissions; | ||
857 | item.Owner = client.AgentId; | ||
858 | item.SalePrice = 10; | ||
859 | item.SaleType = (byte)SaleType.Not; | ||
860 | ((Scene)client.Scene).AddInventoryItem(client, item); | ||
861 | } | ||
862 | |||
863 | private void OnAcceptCallingCard(IClientAPI client, UUID transactionID, UUID folderID) | ||
864 | { | ||
865 | m_log.DebugFormat("[CALLING CARD]: User {0} ({1} {2}) accepted tid {3}, folder {4}", | ||
866 | client.AgentId, | ||
867 | client.FirstName, client.LastName, | ||
868 | transactionID, folderID); | ||
869 | UUID destID; | ||
870 | lock (m_pendingCallingcardRequests) | ||
871 | { | ||
872 | if (!m_pendingCallingcardRequests.TryGetValue(transactionID, out destID)) | ||
873 | { | ||
874 | m_log.WarnFormat("[CALLING CARD]: Got a AcceptCallingCard from {0} without an offer before.", | ||
875 | client.Name); | ||
876 | return; | ||
877 | } | ||
878 | // else found pending calling card request with that transaction. | ||
879 | m_pendingCallingcardRequests.Remove(transactionID); | ||
880 | } | ||
881 | |||
882 | |||
883 | ScenePresence destAgent = GetAnyPresenceFromAgentID(destID); | ||
884 | // inform sender of the card that destination declined the offer | ||
885 | if (destAgent != null) destAgent.ControllingClient.SendAcceptCallingCard(transactionID); | ||
886 | |||
887 | // put a calling card into the inventory of receiver | ||
888 | CreateCallingCard(client, destID, folderID, destAgent.Name); | ||
889 | } | ||
890 | |||
891 | private void OnDeclineCallingCard(IClientAPI client, UUID transactionID) | ||
892 | { | ||
893 | m_log.DebugFormat("[CALLING CARD]: User {0} (ID:{1}) declined card, tid {2}", | ||
894 | client.Name, client.AgentId, transactionID); | ||
895 | UUID destID; | ||
896 | lock (m_pendingCallingcardRequests) | ||
897 | { | ||
898 | if (!m_pendingCallingcardRequests.TryGetValue(transactionID, out destID)) | ||
899 | { | ||
900 | m_log.WarnFormat("[CALLING CARD]: Got a AcceptCallingCard from {0} without an offer before.", | ||
901 | client.Name); | ||
902 | return; | ||
903 | } | ||
904 | // else found pending calling card request with that transaction. | ||
905 | m_pendingCallingcardRequests.Remove(transactionID); | ||
906 | } | ||
907 | |||
908 | ScenePresence destAgent = GetAnyPresenceFromAgentID(destID); | ||
909 | // inform sender of the card that destination declined the offer | ||
910 | if (destAgent != null) destAgent.ControllingClient.SendDeclineCallingCard(transactionID); | ||
911 | } | ||
912 | |||
913 | /// <summary> | ||
914 | /// Send presence information about a client to other clients in both this region and others. | ||
915 | /// </summary> | ||
916 | /// <param name="client"></param> | ||
917 | /// <param name="friendList"></param> | ||
918 | /// <param name="iAmOnline"></param> | ||
919 | private void SendPresenceState(IClientAPI client, List<FriendListItem> friendList, bool iAmOnline) | ||
920 | { | ||
921 | //m_log.DebugFormat("[FRIEND]: {0} logged {1}; sending presence updates", client.Name, iAmOnline ? "in" : "out"); | ||
922 | |||
923 | if (friendList == null || friendList.Count == 0) | ||
924 | { | ||
925 | //m_log.DebugFormat("[FRIEND]: {0} doesn't have friends.", client.Name); | ||
926 | return; // nothing we can do if she doesn't have friends... | ||
927 | } | ||
928 | |||
929 | // collect sets of friendIDs; to send to (online and offline), and to receive from | ||
930 | // TODO: If we ever switch to .NET >= 3, replace those Lists with HashSets. | ||
931 | // I can't believe that we have Dictionaries, but no Sets, considering Java introduced them years ago... | ||
932 | List<UUID> friendIDsToSendTo = new List<UUID>(); | ||
933 | List<UUID> candidateFriendIDsToReceive = new List<UUID>(); | ||
934 | |||
935 | foreach (FriendListItem item in friendList) | ||
936 | { | ||
937 | if (((item.FriendListOwnerPerms | item.FriendPerms) & (uint)FriendRights.CanSeeOnline) != 0) | ||
938 | { | ||
939 | // friend is allowed to see my presence => add | ||
940 | if ((item.FriendListOwnerPerms & (uint)FriendRights.CanSeeOnline) != 0) | ||
941 | friendIDsToSendTo.Add(item.Friend); | ||
942 | |||
943 | if ((item.FriendPerms & (uint)FriendRights.CanSeeOnline) != 0) | ||
944 | candidateFriendIDsToReceive.Add(item.Friend); | ||
945 | } | ||
946 | } | ||
947 | |||
948 | // we now have a list of "interesting" friends (which we have to find out on-/offline state for), | ||
949 | // friends we want to send our online state to (if *they* are online, too), and | ||
950 | // friends we want to receive online state for (currently unknown whether online or not) | ||
951 | |||
952 | // as this processing might take some time and friends might TP away, we try up to three times to | ||
953 | // reach them. Most of the time, we *will* reach them, and this loop won't loop | ||
954 | int retry = 0; | ||
955 | do | ||
956 | { | ||
957 | // build a list of friends to look up region-information and on-/offline-state for | ||
958 | List<UUID> friendIDsToLookup = new List<UUID>(friendIDsToSendTo); | ||
959 | foreach (UUID uuid in candidateFriendIDsToReceive) | ||
960 | { | ||
961 | if (!friendIDsToLookup.Contains(uuid)) friendIDsToLookup.Add(uuid); | ||
962 | } | ||
963 | |||
964 | m_log.DebugFormat( | ||
965 | "[FRIEND]: {0} to lookup, {1} to send to, {2} candidates to receive from for agent {3}", | ||
966 | friendIDsToLookup.Count, friendIDsToSendTo.Count, candidateFriendIDsToReceive.Count, client.Name); | ||
967 | |||
968 | // we have to fetch FriendRegionInfos, as the (cached) FriendListItems don't | ||
969 | // necessarily contain the correct online state... | ||
970 | Dictionary<UUID, FriendRegionInfo> friendRegions = m_initialScene.GetFriendRegionInfos(friendIDsToLookup); | ||
971 | m_log.DebugFormat( | ||
972 | "[FRIEND]: Found {0} regionInfos for {1} friends of {2}", | ||
973 | friendRegions.Count, friendIDsToLookup.Count, client.Name); | ||
974 | |||
975 | // argument for SendAgentOn/Offline; we shouldn't generate that repeatedly within loops. | ||
976 | UUID[] agentArr = new UUID[] { client.AgentId }; | ||
977 | |||
978 | // first, send to friend presence state to me, if I'm online... | ||
979 | if (iAmOnline) | ||
980 | { | ||
981 | List<UUID> friendIDsToReceive = new List<UUID>(); | ||
982 | |||
983 | for (int i = candidateFriendIDsToReceive.Count - 1; i >= 0; --i) | ||
984 | { | ||
985 | UUID uuid = candidateFriendIDsToReceive[i]; | ||
986 | FriendRegionInfo info; | ||
987 | if (friendRegions.TryGetValue(uuid, out info) && info != null && info.isOnline) | ||
988 | { | ||
989 | friendIDsToReceive.Add(uuid); | ||
990 | } | ||
991 | } | ||
992 | |||
993 | m_log.DebugFormat( | ||
994 | "[FRIEND]: Sending {0} online friends to {1}", friendIDsToReceive.Count, client.Name); | ||
995 | |||
996 | if (friendIDsToReceive.Count > 0) | ||
997 | client.SendAgentOnline(friendIDsToReceive.ToArray()); | ||
998 | |||
999 | // clear them for a possible second iteration; we don't have to repeat this | ||
1000 | candidateFriendIDsToReceive.Clear(); | ||
1001 | } | ||
1002 | |||
1003 | // now, send my presence state to my friends | ||
1004 | for (int i = friendIDsToSendTo.Count - 1; i >= 0; --i) | ||
1005 | { | ||
1006 | UUID uuid = friendIDsToSendTo[i]; | ||
1007 | FriendRegionInfo info; | ||
1008 | if (friendRegions.TryGetValue(uuid, out info) && info != null && info.isOnline) | ||
1009 | { | ||
1010 | // any client is good enough, root or child... | ||
1011 | ScenePresence agent = GetAnyPresenceFromAgentID(uuid); | ||
1012 | if (agent != null) | ||
1013 | { | ||
1014 | //m_log.DebugFormat("[FRIEND]: Found local agent {0}", agent.Name); | ||
1015 | |||
1016 | // friend is online and on this server... | ||
1017 | if (iAmOnline) agent.ControllingClient.SendAgentOnline(agentArr); | ||
1018 | else agent.ControllingClient.SendAgentOffline(agentArr); | ||
1019 | |||
1020 | // done, remove it | ||
1021 | friendIDsToSendTo.RemoveAt(i); | ||
1022 | } | ||
1023 | } | ||
1024 | else | ||
1025 | { | ||
1026 | //m_log.DebugFormat("[FRIEND]: Friend {0} ({1}) is offline; not sending.", uuid, i); | ||
1027 | |||
1028 | // friend is offline => no need to try sending | ||
1029 | friendIDsToSendTo.RemoveAt(i); | ||
1030 | } | ||
1031 | } | ||
1032 | |||
1033 | m_log.DebugFormat("[FRIEND]: Have {0} friends to contact via inter-region comms.", friendIDsToSendTo.Count); | ||
1034 | |||
1035 | // we now have all the friends left that are online (we think), but not on this region-server | ||
1036 | if (friendIDsToSendTo.Count > 0) | ||
1037 | { | ||
1038 | // sort them into regions | ||
1039 | Dictionary<ulong, List<UUID>> friendsInRegion = new Dictionary<ulong,List<UUID>>(); | ||
1040 | foreach (UUID uuid in friendIDsToSendTo) | ||
1041 | { | ||
1042 | ulong handle = friendRegions[uuid].regionHandle; // this can't fail as we filtered above already | ||
1043 | List<UUID> friends; | ||
1044 | if (!friendsInRegion.TryGetValue(handle, out friends)) | ||
1045 | { | ||
1046 | friends = new List<UUID>(); | ||
1047 | friendsInRegion[handle] = friends; | ||
1048 | } | ||
1049 | friends.Add(uuid); | ||
1050 | } | ||
1051 | m_log.DebugFormat("[FRIEND]: Found {0} regions to send to.", friendRegions.Count); | ||
1052 | |||
1053 | // clear uuids list and collect missed friends in it for the next retry | ||
1054 | friendIDsToSendTo.Clear(); | ||
1055 | |||
1056 | // send bulk updates to the region | ||
1057 | foreach (KeyValuePair<ulong, List<UUID>> pair in friendsInRegion) | ||
1058 | { | ||
1059 | //m_log.DebugFormat("[FRIEND]: Inform {0} friends in region {1} that user {2} is {3}line", | ||
1060 | // pair.Value.Count, pair.Key, client.Name, iAmOnline ? "on" : "off"); | ||
1061 | |||
1062 | friendIDsToSendTo.AddRange(InformFriendsInOtherRegion(client.AgentId, pair.Key, pair.Value, iAmOnline)); | ||
1063 | } | ||
1064 | } | ||
1065 | // now we have in friendIDsToSendTo only the agents left that TPed away while we tried to contact them. | ||
1066 | // In most cases, it will be empty, and it won't loop here. But sometimes, we have to work harder and try again... | ||
1067 | } | ||
1068 | while (++retry < 3 && friendIDsToSendTo.Count > 0); | ||
1069 | } | ||
1070 | |||
1071 | private void OnEconomyDataRequest(UUID agentID) | ||
1072 | { | ||
1073 | // KLUDGE: This is the only way I found to get a message (only) after login was completed and the | ||
1074 | // client is connected enough to receive UDP packets). | ||
1075 | // This packet seems to be sent only once, just after connection was established to the first | ||
1076 | // region after login. | ||
1077 | // We use it here to trigger a presence update; the old update-on-login was never be heard by | ||
1078 | // the freshly logged in viewer, as it wasn't connected to the region at that time. | ||
1079 | // TODO: Feel free to replace this by a better solution if you find one. | ||
1080 | |||
1081 | // get the agent. This should work every time, as we just got a packet from it | ||
1082 | //ScenePresence agent = GetRootPresenceFromAgentID(agentID); | ||
1083 | // KLUDGE 2: As this is sent quite early, the avatar isn't here as root agent yet. So, we have to cheat a bit | ||
1084 | ScenePresence agent = GetAnyPresenceFromAgentID(agentID); | ||
1085 | |||
1086 | // just to be paranoid... | ||
1087 | if (agent == null) | ||
1088 | { | ||
1089 | m_log.ErrorFormat("[FRIEND]: Got a packet from agent {0} who can't be found anymore!?", agentID); | ||
1090 | return; | ||
1091 | } | ||
1092 | |||
1093 | List<FriendListItem> fl; | ||
1094 | lock (m_friendLists) | ||
1095 | { | ||
1096 | fl = (List<FriendListItem>)m_friendLists.Get(agent.ControllingClient.AgentId.ToString(), | ||
1097 | m_initialScene.GetFriendList); | ||
1098 | } | ||
1099 | |||
1100 | // tell everyone that we are online | ||
1101 | SendPresenceState(agent.ControllingClient, fl, true); | ||
1102 | } | ||
1103 | |||
1104 | private void OnLogout(IClientAPI remoteClient) | ||
1105 | { | ||
1106 | List<FriendListItem> fl; | ||
1107 | lock (m_friendLists) | ||
1108 | { | ||
1109 | fl = (List<FriendListItem>)m_friendLists.Get(remoteClient.AgentId.ToString(), | ||
1110 | m_initialScene.GetFriendList); | ||
1111 | } | ||
1112 | |||
1113 | // tell everyone that we are offline | ||
1114 | SendPresenceState(remoteClient, fl, false); | ||
1115 | } | ||
1116 | private void GrantUserFriendRights(IClientAPI remoteClient, UUID requester, UUID target, int rights) | ||
1117 | { | ||
1118 | ((Scene)remoteClient.Scene).CommsManager.UpdateUserFriendPerms(requester, target, (uint)rights); | ||
1119 | } | ||
1120 | public void FindAgent(IClientAPI remoteClient, UUID hunter, UUID target) | ||
1121 | { | ||
1122 | List<FriendListItem> friendList = GetUserFriends(hunter); | ||
1123 | foreach (FriendListItem item in friendList) | ||
1124 | { | ||
1125 | if (item.onlinestatus == true) | ||
1126 | { | ||
1127 | if (item.Friend == target && (item.FriendPerms & (uint)FriendRights.CanSeeOnMap) != 0) | ||
1128 | { | ||
1129 | ScenePresence SPTarget = ((Scene)remoteClient.Scene).GetScenePresence(target); | ||
1130 | string regionname = SPTarget.Scene.RegionInfo.RegionName; | ||
1131 | remoteClient.SendScriptTeleportRequest("FindAgent", regionname,new Vector3(SPTarget.AbsolutePosition),new Vector3(SPTarget.Lookat)); | ||
1132 | } | ||
1133 | } | ||
1134 | else | ||
1135 | { | ||
1136 | remoteClient.SendAgentAlertMessage("The agent you are looking for is not online.", false); | ||
1137 | } | ||
1138 | } | ||
1139 | } | 85 | } |
1140 | 86 | ||
1141 | public List<FriendListItem> GetUserFriends(UUID agentID) | 87 | public List<FriendListItem> GetUserFriends(UUID agentID) |
1142 | { | 88 | { |
1143 | List<FriendListItem> fl; | 89 | return null; |
1144 | lock (m_friendLists) | ||
1145 | { | ||
1146 | fl = (List<FriendListItem>)m_friendLists.Get(agentID.ToString(), | ||
1147 | m_initialScene.GetFriendList); | ||
1148 | } | ||
1149 | |||
1150 | return fl; | ||
1151 | } | 90 | } |
1152 | } | 91 | } |
1153 | #endregion | ||
1154 | } | 92 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs index 9a68749..ab141eb 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs | |||
@@ -24,6 +24,7 @@ | |||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using System; | ||
27 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
28 | using System.Reflection; | 29 | using System.Reflection; |
29 | using log4net; | 30 | using log4net; |
@@ -36,9 +37,10 @@ using OpenSim.Region.Framework.Scenes; | |||
36 | 37 | ||
37 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | 38 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
38 | { | 39 | { |
39 | public class InstantMessageModule : IRegionModule | 40 | public class InstantMessageModule : ISharedRegionModule |
40 | { | 41 | { |
41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 42 | private static readonly ILog m_log = LogManager.GetLogger( |
43 | MethodBase.GetCurrentMethod().DeclaringType); | ||
42 | 44 | ||
43 | /// <value> | 45 | /// <value> |
44 | /// Is this module enabled? | 46 | /// Is this module enabled? |
@@ -51,7 +53,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
51 | 53 | ||
52 | private IMessageTransferModule m_TransferModule = null; | 54 | private IMessageTransferModule m_TransferModule = null; |
53 | 55 | ||
54 | public void Initialise(Scene scene, IConfigSource config) | 56 | public void Initialise(IConfigSource config) |
55 | { | 57 | { |
56 | if (config.Configs["Messaging"] != null) | 58 | if (config.Configs["Messaging"] != null) |
57 | { | 59 | { |
@@ -62,6 +64,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
62 | } | 64 | } |
63 | 65 | ||
64 | m_enabled = true; | 66 | m_enabled = true; |
67 | } | ||
68 | |||
69 | public void AddRegion(Scene scene) | ||
70 | { | ||
71 | if (!m_enabled) | ||
72 | return; | ||
65 | 73 | ||
66 | lock (m_scenes) | 74 | lock (m_scenes) |
67 | { | 75 | { |
@@ -74,6 +82,39 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
74 | } | 82 | } |
75 | } | 83 | } |
76 | 84 | ||
85 | public void RegionLoaded(Scene scene) | ||
86 | { | ||
87 | if (!m_enabled) | ||
88 | return; | ||
89 | |||
90 | if (m_TransferModule == null) | ||
91 | { | ||
92 | m_TransferModule = | ||
93 | scene.RequestModuleInterface<IMessageTransferModule>(); | ||
94 | |||
95 | if (m_TransferModule == null) | ||
96 | { | ||
97 | m_log.Error("[INSTANT MESSAGE]: No message transfer module, IM will not work!"); | ||
98 | scene.EventManager.OnClientConnect -= OnClientConnect; | ||
99 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; | ||
100 | |||
101 | m_scenes.Clear(); | ||
102 | m_enabled = false; | ||
103 | } | ||
104 | } | ||
105 | } | ||
106 | |||
107 | public void RemoveRegion(Scene scene) | ||
108 | { | ||
109 | if (!m_enabled) | ||
110 | return; | ||
111 | |||
112 | lock (m_scenes) | ||
113 | { | ||
114 | m_scenes.Remove(scene); | ||
115 | } | ||
116 | } | ||
117 | |||
77 | void OnClientConnect(IClientCore client) | 118 | void OnClientConnect(IClientCore client) |
78 | { | 119 | { |
79 | IClientIM clientIM; | 120 | IClientIM clientIM; |
@@ -85,15 +126,6 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
85 | 126 | ||
86 | public void PostInitialise() | 127 | public void PostInitialise() |
87 | { | 128 | { |
88 | if (!m_enabled) | ||
89 | return; | ||
90 | |||
91 | m_TransferModule = | ||
92 | m_scenes[0].RequestModuleInterface<IMessageTransferModule>(); | ||
93 | |||
94 | if (m_TransferModule == null) | ||
95 | m_log.Error("[INSTANT MESSAGE]: No message transfer module, "+ | ||
96 | "IM will not work!"); | ||
97 | } | 129 | } |
98 | 130 | ||
99 | public void Close() | 131 | public void Close() |
@@ -105,9 +137,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
105 | get { return "InstantMessageModule"; } | 137 | get { return "InstantMessageModule"; } |
106 | } | 138 | } |
107 | 139 | ||
108 | public bool IsSharedModule | 140 | public Type ReplaceableInterface |
109 | { | 141 | { |
110 | get { return true; } | 142 | get { return null; } |
111 | } | 143 | } |
112 | 144 | ||
113 | #endregion | 145 | #endregion |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index e5159b3..2d4b421 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs | |||
@@ -40,18 +40,17 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
40 | 40 | ||
41 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | 41 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
42 | { | 42 | { |
43 | public class MessageTransferModule : IRegionModule, IMessageTransferModule | 43 | public class MessageTransferModule : ISharedRegionModule, IMessageTransferModule |
44 | { | 44 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | // private bool m_Enabled = false; | 47 | private bool m_Enabled = false; |
48 | protected bool m_Gridmode = false; | ||
49 | protected List<Scene> m_Scenes = new List<Scene>(); | 48 | protected List<Scene> m_Scenes = new List<Scene>(); |
50 | protected Dictionary<UUID, ulong> m_UserRegionMap = new Dictionary<UUID, ulong>(); | 49 | protected Dictionary<UUID, ulong> m_UserRegionMap = new Dictionary<UUID, ulong>(); |
51 | 50 | ||
52 | public event UndeliveredMessage OnUndeliveredMessage; | 51 | public event UndeliveredMessage OnUndeliveredMessage; |
53 | 52 | ||
54 | public virtual void Initialise(Scene scene, IConfigSource config) | 53 | public virtual void Initialise(IConfigSource config) |
55 | { | 54 | { |
56 | IConfig cnf = config.Configs["Messaging"]; | 55 | IConfig cnf = config.Configs["Messaging"]; |
57 | if (cnf != null && cnf.GetString( | 56 | if (cnf != null && cnf.GetString( |
@@ -62,20 +61,16 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
62 | return; | 61 | return; |
63 | } | 62 | } |
64 | 63 | ||
65 | cnf = config.Configs["Startup"]; | 64 | m_Enabled = true; |
66 | if (cnf != null) | 65 | } |
67 | m_Gridmode = cnf.GetBoolean("gridmode", false); | ||
68 | 66 | ||
69 | // m_Enabled = true; | 67 | public virtual void AddRegion(Scene scene) |
68 | { | ||
69 | if (!m_Enabled) | ||
70 | return; | ||
70 | 71 | ||
71 | lock (m_Scenes) | 72 | lock (m_Scenes) |
72 | { | 73 | { |
73 | if (m_Scenes.Count == 0) | ||
74 | { | ||
75 | MainServer.Instance.AddXmlRPCHandler( | ||
76 | "grid_instant_message", processXMLRPCGridInstantMessage); | ||
77 | } | ||
78 | |||
79 | m_log.Debug("[MESSAGE TRANSFER]: Message transfer module active"); | 74 | m_log.Debug("[MESSAGE TRANSFER]: Message transfer module active"); |
80 | scene.RegisterModuleInterface<IMessageTransferModule>(this); | 75 | scene.RegisterModuleInterface<IMessageTransferModule>(this); |
81 | m_Scenes.Add(scene); | 76 | m_Scenes.Add(scene); |
@@ -84,6 +79,26 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
84 | 79 | ||
85 | public virtual void PostInitialise() | 80 | public virtual void PostInitialise() |
86 | { | 81 | { |
82 | if (!m_Enabled) | ||
83 | return; | ||
84 | |||
85 | MainServer.Instance.AddXmlRPCHandler( | ||
86 | "grid_instant_message", processXMLRPCGridInstantMessage); | ||
87 | } | ||
88 | |||
89 | public virtual void RegionLoaded(Scene scene) | ||
90 | { | ||
91 | } | ||
92 | |||
93 | public virtual void RemoveRegion(Scene scene) | ||
94 | { | ||
95 | if (!m_Enabled) | ||
96 | return; | ||
97 | |||
98 | lock(m_Scenes) | ||
99 | { | ||
100 | m_Scenes.Remove(scene); | ||
101 | } | ||
87 | } | 102 | } |
88 | 103 | ||
89 | public virtual void Close() | 104 | public virtual void Close() |
@@ -95,9 +110,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
95 | get { return "MessageTransferModule"; } | 110 | get { return "MessageTransferModule"; } |
96 | } | 111 | } |
97 | 112 | ||
98 | public virtual bool IsSharedModule | 113 | public virtual Type ReplaceableInterface |
99 | { | 114 | { |
100 | get { return true; } | 115 | get { return null; } |
101 | } | 116 | } |
102 | 117 | ||
103 | public virtual void SendInstantMessage(GridInstantMessage im, MessageResultNotification result) | 118 | public virtual void SendInstantMessage(GridInstantMessage im, MessageResultNotification result) |
@@ -148,15 +163,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
148 | } | 163 | } |
149 | } | 164 | } |
150 | 165 | ||
151 | if (m_Gridmode) | 166 | SendGridInstantMessageViaXMLRPC(im, result); |
152 | { | ||
153 | //m_log.DebugFormat("[INSTANT MESSAGE]: Delivering via grid"); | ||
154 | // Still here, try send via Grid | ||
155 | SendGridInstantMessageViaXMLRPC(im, result); | ||
156 | return; | ||
157 | } | ||
158 | |||
159 | HandleUndeliveredMessage(im, result); | ||
160 | 167 | ||
161 | return; | 168 | return; |
162 | } | 169 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs index 2d4a635..24cbaeb 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs | |||
@@ -37,9 +37,9 @@ using OpenSim.Framework.Client; | |||
37 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
38 | using OpenSim.Region.Framework.Scenes; | 38 | using OpenSim.Region.Framework.Scenes; |
39 | 39 | ||
40 | namespace OpenSim.Region.CoreModules.Avatar.MuteList | 40 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
41 | { | 41 | { |
42 | public class MuteListModule : IRegionModule | 42 | public class MuteListModule : ISharedRegionModule |
43 | { | 43 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 45 | ||
@@ -47,11 +47,8 @@ namespace OpenSim.Region.CoreModules.Avatar.MuteList | |||
47 | private List<Scene> m_SceneList = new List<Scene>(); | 47 | private List<Scene> m_SceneList = new List<Scene>(); |
48 | private string m_RestURL = String.Empty; | 48 | private string m_RestURL = String.Empty; |
49 | 49 | ||
50 | public void Initialise(Scene scene, IConfigSource config) | 50 | public void Initialise(IConfigSource config) |
51 | { | 51 | { |
52 | if (!enabled) | ||
53 | return; | ||
54 | |||
55 | IConfig cnf = config.Configs["Messaging"]; | 52 | IConfig cnf = config.Configs["Messaging"]; |
56 | if (cnf == null) | 53 | if (cnf == null) |
57 | { | 54 | { |
@@ -59,39 +56,53 @@ namespace OpenSim.Region.CoreModules.Avatar.MuteList | |||
59 | return; | 56 | return; |
60 | } | 57 | } |
61 | 58 | ||
62 | if (cnf != null && cnf.GetString( | 59 | if (cnf != null && cnf.GetString("MuteListModule", "None") != |
63 | "MuteListModule", "None") != | ||
64 | "MuteListModule") | 60 | "MuteListModule") |
65 | { | 61 | { |
66 | enabled = false; | 62 | enabled = false; |
67 | return; | 63 | return; |
68 | } | 64 | } |
69 | 65 | ||
66 | m_RestURL = cnf.GetString("MuteListURL", ""); | ||
67 | if (m_RestURL == "") | ||
68 | { | ||
69 | m_log.Error("[MUTE LIST] Module was enabled, but no URL is given, disabling"); | ||
70 | enabled = false; | ||
71 | return; | ||
72 | } | ||
73 | } | ||
74 | |||
75 | public void AddRegion(Scene scene) | ||
76 | { | ||
77 | if (!enabled) | ||
78 | return; | ||
79 | |||
70 | lock (m_SceneList) | 80 | lock (m_SceneList) |
71 | { | 81 | { |
72 | if (m_SceneList.Count == 0) | 82 | m_SceneList.Add(scene); |
73 | { | ||
74 | m_RestURL = cnf.GetString("MuteListURL", ""); | ||
75 | if (m_RestURL == "") | ||
76 | { | ||
77 | m_log.Error("[MUTE LIST] Module was enabled, but no URL is given, disabling"); | ||
78 | enabled = false; | ||
79 | return; | ||
80 | } | ||
81 | } | ||
82 | if (!m_SceneList.Contains(scene)) | ||
83 | m_SceneList.Add(scene); | ||
84 | 83 | ||
85 | scene.EventManager.OnNewClient += OnNewClient; | 84 | scene.EventManager.OnNewClient += OnNewClient; |
86 | } | 85 | } |
87 | } | 86 | } |
88 | 87 | ||
89 | public void PostInitialise() | 88 | public void RegionLoaded(Scene scene) |
89 | { | ||
90 | } | ||
91 | |||
92 | public void RemoveRegion(Scene scene) | ||
90 | { | 93 | { |
91 | if (!enabled) | 94 | if (!enabled) |
92 | return; | 95 | return; |
93 | 96 | ||
94 | if (m_SceneList.Count == 0) | 97 | lock (m_SceneList) |
98 | { | ||
99 | m_SceneList.Remove(scene); | ||
100 | } | ||
101 | } | ||
102 | |||
103 | public void PostInitialise() | ||
104 | { | ||
105 | if (!enabled) | ||
95 | return; | 106 | return; |
96 | 107 | ||
97 | m_log.Debug("[MUTE LIST] Mute list enabled"); | 108 | m_log.Debug("[MUTE LIST] Mute list enabled"); |
@@ -102,26 +113,15 @@ namespace OpenSim.Region.CoreModules.Avatar.MuteList | |||
102 | get { return "MuteListModule"; } | 113 | get { return "MuteListModule"; } |
103 | } | 114 | } |
104 | 115 | ||
105 | public bool IsSharedModule | 116 | public Type ReplaceableInterface |
106 | { | 117 | { |
107 | get { return true; } | 118 | get { return null; } |
108 | } | 119 | } |
109 | 120 | ||
110 | public void Close() | 121 | public void Close() |
111 | { | 122 | { |
112 | } | 123 | } |
113 | 124 | ||
114 | // private IClientAPI FindClient(UUID agentID) | ||
115 | // { | ||
116 | // foreach (Scene s in m_SceneList) | ||
117 | // { | ||
118 | // ScenePresence presence = s.GetScenePresence(agentID); | ||
119 | // if (presence != null && !presence.IsChildAgent) | ||
120 | // return presence.ControllingClient; | ||
121 | // } | ||
122 | // return null; | ||
123 | // } | ||
124 | |||
125 | private void OnNewClient(IClientAPI client) | 125 | private void OnNewClient(IClientAPI client) |
126 | { | 126 | { |
127 | client.OnMuteListRequest += OnMuteListRequest; | 127 | client.OnMuteListRequest += OnMuteListRequest; |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs index 1614b70..a835c52 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs | |||
@@ -40,78 +40,88 @@ using OpenSim.Region.Framework.Scenes; | |||
40 | 40 | ||
41 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | 41 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
42 | { | 42 | { |
43 | public class OfflineMessageModule : IRegionModule | 43 | public class OfflineMessageModule : ISharedRegionModule |
44 | { | 44 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | private bool enabled = true; | 47 | private bool enabled = true; |
48 | private List<Scene> m_SceneList = new List<Scene>(); | 48 | private List<Scene> m_SceneList = new List<Scene>(); |
49 | private string m_RestURL = String.Empty; | 49 | private string m_RestURL = String.Empty; |
50 | IMessageTransferModule m_TransferModule = null; | ||
50 | 51 | ||
51 | public void Initialise(Scene scene, IConfigSource config) | 52 | public void Initialise(IConfigSource config) |
52 | { | 53 | { |
53 | if (!enabled) | ||
54 | return; | ||
55 | |||
56 | IConfig cnf = config.Configs["Messaging"]; | 54 | IConfig cnf = config.Configs["Messaging"]; |
57 | if (cnf == null) | 55 | if (cnf == null) |
58 | { | 56 | { |
59 | enabled = false; | 57 | enabled = false; |
60 | return; | 58 | return; |
61 | } | 59 | } |
62 | if (cnf != null && cnf.GetString( | 60 | if (cnf != null && cnf.GetString("OfflineMessageModule", "None") != |
63 | "OfflineMessageModule", "None") != | ||
64 | "OfflineMessageModule") | 61 | "OfflineMessageModule") |
65 | { | 62 | { |
66 | enabled = false; | 63 | enabled = false; |
67 | return; | 64 | return; |
68 | } | 65 | } |
69 | 66 | ||
67 | m_RestURL = cnf.GetString("OfflineMessageURL", ""); | ||
68 | if (m_RestURL == "") | ||
69 | { | ||
70 | m_log.Error("[OFFLINE MESSAGING] Module was enabled, but no URL is given, disabling"); | ||
71 | enabled = false; | ||
72 | return; | ||
73 | } | ||
74 | } | ||
75 | |||
76 | public void AddRegion(Scene scene) | ||
77 | { | ||
78 | if (!enabled) | ||
79 | return; | ||
80 | |||
70 | lock (m_SceneList) | 81 | lock (m_SceneList) |
71 | { | 82 | { |
72 | if (m_SceneList.Count == 0) | 83 | m_SceneList.Add(scene); |
73 | { | ||
74 | m_RestURL = cnf.GetString("OfflineMessageURL", ""); | ||
75 | if (m_RestURL == "") | ||
76 | { | ||
77 | m_log.Error("[OFFLINE MESSAGING] Module was enabled, but no URL is given, disabling"); | ||
78 | enabled = false; | ||
79 | return; | ||
80 | } | ||
81 | } | ||
82 | if (!m_SceneList.Contains(scene)) | ||
83 | m_SceneList.Add(scene); | ||
84 | 84 | ||
85 | scene.EventManager.OnNewClient += OnNewClient; | 85 | scene.EventManager.OnNewClient += OnNewClient; |
86 | } | 86 | } |
87 | } | 87 | } |
88 | 88 | ||
89 | public void PostInitialise() | 89 | public void RegionLoaded(Scene scene) |
90 | { | 90 | { |
91 | if (!enabled) | 91 | if (!enabled) |
92 | return; | 92 | return; |
93 | 93 | ||
94 | if (m_SceneList.Count == 0) | 94 | if (m_TransferModule == null) |
95 | return; | ||
96 | |||
97 | IMessageTransferModule trans = m_SceneList[0].RequestModuleInterface<IMessageTransferModule>(); | ||
98 | if (trans == null) | ||
99 | { | 95 | { |
100 | enabled = false; | 96 | m_TransferModule = scene.RequestModuleInterface<IMessageTransferModule>(); |
101 | 97 | if (m_TransferModule == null) | |
102 | lock (m_SceneList) | ||
103 | { | 98 | { |
104 | foreach (Scene s in m_SceneList) | 99 | scene.EventManager.OnNewClient -= OnNewClient; |
105 | s.EventManager.OnNewClient -= OnNewClient; | ||
106 | 100 | ||
101 | enabled = false; | ||
107 | m_SceneList.Clear(); | 102 | m_SceneList.Clear(); |
103 | |||
104 | m_log.Error("[OFFLINE MESSAGING] No message transfer module is enabled. Diabling offline messages"); | ||
108 | } | 105 | } |
106 | m_TransferModule.OnUndeliveredMessage += UndeliveredMessage; | ||
107 | } | ||
108 | } | ||
109 | 109 | ||
110 | m_log.Error("[OFFLINE MESSAGING] No message transfer module is enabled. Diabling offline messages"); | 110 | public void RemoveRegion(Scene scene) |
111 | { | ||
112 | if (!enabled) | ||
111 | return; | 113 | return; |
114 | |||
115 | lock (m_SceneList) | ||
116 | { | ||
117 | m_SceneList.Remove(scene); | ||
112 | } | 118 | } |
119 | } | ||
113 | 120 | ||
114 | trans.OnUndeliveredMessage += UndeliveredMessage; | 121 | public void PostInitialise() |
122 | { | ||
123 | if (!enabled) | ||
124 | return; | ||
115 | 125 | ||
116 | m_log.Debug("[OFFLINE MESSAGING] Offline messages enabled"); | 126 | m_log.Debug("[OFFLINE MESSAGING] Offline messages enabled"); |
117 | } | 127 | } |
@@ -121,9 +131,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
121 | get { return "OfflineMessageModule"; } | 131 | get { return "OfflineMessageModule"; } |
122 | } | 132 | } |
123 | 133 | ||
124 | public bool IsSharedModule | 134 | public Type ReplaceableInterface |
125 | { | 135 | { |
126 | get { return true; } | 136 | get { return null; } |
127 | } | 137 | } |
128 | 138 | ||
129 | public void Close() | 139 | public void Close() |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs index f5ab454..267a90a 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs | |||
@@ -24,6 +24,7 @@ | |||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using System; | ||
27 | using System.Collections; | 28 | using System.Collections; |
28 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using System.Net; | 30 | using System.Net; |
@@ -39,404 +40,54 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
39 | 40 | ||
40 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | 41 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
41 | { | 42 | { |
42 | public class PresenceModule : IRegionModule, IPresenceModule | 43 | public class PresenceModule : ISharedRegionModule, IPresenceModule |
43 | { | 44 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger( |
45 | 46 | MethodBase.GetCurrentMethod().DeclaringType); | |
46 | private bool m_Enabled = false; | ||
47 | private bool m_Gridmode = false; | ||
48 | |||
49 | // some default scene for doing things that aren't connected to a specific scene. Avoids locking. | ||
50 | private Scene m_initialScene; | ||
51 | |||
52 | private List<Scene> m_Scenes = new List<Scene>(); | ||
53 | |||
54 | // we currently are only interested in root-agents. If the root isn't here, we don't know the region the | ||
55 | // user is in, so we have to ask the messaging server anyway. | ||
56 | private Dictionary<UUID, Scene> m_RootAgents = | ||
57 | new Dictionary<UUID, Scene>(); | ||
58 | 47 | ||
59 | public event PresenceChange OnPresenceChange; | 48 | public event PresenceChange OnPresenceChange; |
60 | public event BulkPresenceData OnBulkPresenceData; | 49 | public event BulkPresenceData OnBulkPresenceData; |
61 | 50 | ||
62 | public void Initialise(Scene scene, IConfigSource config) | 51 | public void Initialise(IConfigSource config) |
63 | { | 52 | { |
64 | lock (m_Scenes) | ||
65 | { | ||
66 | // This is a shared module; Initialise will be called for every region on this server. | ||
67 | // Only check config once for the first region. | ||
68 | if (m_Scenes.Count == 0) | ||
69 | { | ||
70 | IConfig cnf = config.Configs["Messaging"]; | ||
71 | if (cnf != null && cnf.GetString( | ||
72 | "PresenceModule", "PresenceModule") != | ||
73 | "PresenceModule") | ||
74 | return; | ||
75 | |||
76 | cnf = config.Configs["Startup"]; | ||
77 | if (cnf != null) | ||
78 | m_Gridmode = cnf.GetBoolean("gridmode", false); | ||
79 | |||
80 | m_Enabled = true; | ||
81 | |||
82 | m_initialScene = scene; | ||
83 | } | ||
84 | |||
85 | if (m_Gridmode) | ||
86 | NotifyMessageServerOfStartup(scene); | ||
87 | |||
88 | m_Scenes.Add(scene); | ||
89 | } | ||
90 | |||
91 | scene.RegisterModuleInterface<IPresenceModule>(this); | ||
92 | |||
93 | scene.EventManager.OnNewClient += OnNewClient; | ||
94 | scene.EventManager.OnSetRootAgentScene += OnSetRootAgentScene; | ||
95 | scene.EventManager.OnMakeChildAgent += OnMakeChildAgent; | ||
96 | } | 53 | } |
97 | 54 | ||
98 | public void PostInitialise() | 55 | public void AddRegion(Scene scene) |
99 | { | 56 | { |
100 | } | 57 | } |
101 | 58 | ||
102 | public void Close() | 59 | public void RegionLoaded(Scene scene) |
103 | { | 60 | { |
104 | if (!m_Gridmode || !m_Enabled) | ||
105 | return; | ||
106 | |||
107 | if (OnPresenceChange != null) | ||
108 | { | ||
109 | lock (m_RootAgents) | ||
110 | { | ||
111 | // on shutdown, users are kicked, too | ||
112 | foreach (KeyValuePair<UUID, Scene> pair in m_RootAgents) | ||
113 | { | ||
114 | OnPresenceChange(new PresenceInfo(pair.Key, UUID.Zero)); | ||
115 | } | ||
116 | } | ||
117 | } | ||
118 | |||
119 | lock (m_Scenes) | ||
120 | { | ||
121 | foreach (Scene scene in m_Scenes) | ||
122 | NotifyMessageServerOfShutdown(scene); | ||
123 | } | ||
124 | } | 61 | } |
125 | 62 | ||
126 | public string Name | 63 | public void RemoveRegion(Scene scene) |
127 | { | 64 | { |
128 | get { return "PresenceModule"; } | ||
129 | } | ||
130 | |||
131 | public bool IsSharedModule | ||
132 | { | ||
133 | get { return true; } | ||
134 | } | ||
135 | |||
136 | public void RequestBulkPresenceData(UUID[] users) | ||
137 | { | ||
138 | if (OnBulkPresenceData != null) | ||
139 | { | ||
140 | PresenceInfo[] result = new PresenceInfo[users.Length]; | ||
141 | if (m_Gridmode) | ||
142 | { | ||
143 | // first check the local information | ||
144 | List<UUID> uuids = new List<UUID>(); // the uuids to check remotely | ||
145 | List<int> indices = new List<int>(); // just for performance. | ||
146 | lock (m_RootAgents) | ||
147 | { | ||
148 | for (int i = 0; i < uuids.Count; ++i) | ||
149 | { | ||
150 | Scene scene; | ||
151 | if (m_RootAgents.TryGetValue(users[i], out scene)) | ||
152 | { | ||
153 | result[i] = new PresenceInfo(users[i], scene.RegionInfo.RegionID); | ||
154 | } | ||
155 | else | ||
156 | { | ||
157 | uuids.Add(users[i]); | ||
158 | indices.Add(i); | ||
159 | } | ||
160 | } | ||
161 | } | ||
162 | |||
163 | // now we have filtered out all the local root agents. The rest we have to request info about | ||
164 | Dictionary<UUID, FriendRegionInfo> infos = m_initialScene.GetFriendRegionInfos(uuids); | ||
165 | for (int i = 0; i < uuids.Count; ++i) | ||
166 | { | ||
167 | FriendRegionInfo info; | ||
168 | if (infos.TryGetValue(uuids[i], out info) && info.isOnline) | ||
169 | { | ||
170 | UUID regionID = info.regionID; | ||
171 | if (regionID == UUID.Zero) | ||
172 | { | ||
173 | // TODO this is the old messaging-server protocol; only the regionHandle is available. | ||
174 | // Fetch region-info to get the id | ||
175 | uint x = 0, y = 0; | ||
176 | Utils.LongToUInts(info.regionHandle, out x, out y); | ||
177 | GridRegion regionInfo = m_initialScene.GridService.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, | ||
178 | (int)x, (int)y); | ||
179 | regionID = regionInfo.RegionID; | ||
180 | } | ||
181 | result[indices[i]] = new PresenceInfo(uuids[i], regionID); | ||
182 | } | ||
183 | else result[indices[i]] = new PresenceInfo(uuids[i], UUID.Zero); | ||
184 | } | ||
185 | } | ||
186 | else | ||
187 | { | ||
188 | // in standalone mode, we have all the info locally available. | ||
189 | lock (m_RootAgents) | ||
190 | { | ||
191 | for (int i = 0; i < users.Length; ++i) | ||
192 | { | ||
193 | Scene scene; | ||
194 | if (m_RootAgents.TryGetValue(users[i], out scene)) | ||
195 | { | ||
196 | result[i] = new PresenceInfo(users[i], scene.RegionInfo.RegionID); | ||
197 | } | ||
198 | else | ||
199 | { | ||
200 | result[i] = new PresenceInfo(users[i], UUID.Zero); | ||
201 | } | ||
202 | } | ||
203 | } | ||
204 | } | ||
205 | |||
206 | // tell everyone | ||
207 | OnBulkPresenceData(result); | ||
208 | } | ||
209 | } | ||
210 | |||
211 | // new client doesn't mean necessarily that user logged in, it just means it entered one of the | ||
212 | // the regions on this server | ||
213 | public void OnNewClient(IClientAPI client) | ||
214 | { | ||
215 | client.OnConnectionClosed += OnConnectionClosed; | ||
216 | client.OnLogout += OnLogout; | ||
217 | |||
218 | // KLUDGE: See handler for details. | ||
219 | client.OnEconomyDataRequest += OnEconomyDataRequest; | ||
220 | } | 65 | } |
221 | 66 | ||
222 | // connection closed just means *one* client connection has been closed. It doesn't mean that the | 67 | public void PostInitialise() |
223 | // user has logged off; it might have just TPed away. | ||
224 | public void OnConnectionClosed(IClientAPI client) | ||
225 | { | ||
226 | // TODO: Have to think what we have to do here... | ||
227 | // Should we just remove the root from the list (if scene matches)? | ||
228 | if (!(client.Scene is Scene)) | ||
229 | return; | ||
230 | Scene scene = (Scene)client.Scene; | ||
231 | |||
232 | lock (m_RootAgents) | ||
233 | { | ||
234 | Scene rootScene; | ||
235 | if (!(m_RootAgents.TryGetValue(client.AgentId, out rootScene)) || scene != rootScene) | ||
236 | return; | ||
237 | |||
238 | m_RootAgents.Remove(client.AgentId); | ||
239 | } | ||
240 | |||
241 | // Should it have logged off, we'll do the logout part in OnLogout, even if no root is stored | ||
242 | // anymore. It logged off, after all... | ||
243 | } | ||
244 | |||
245 | // Triggered when the user logs off. | ||
246 | public void OnLogout(IClientAPI client) | ||
247 | { | ||
248 | if (!(client.Scene is Scene)) | ||
249 | return; | ||
250 | Scene scene = (Scene)client.Scene; | ||
251 | |||
252 | // On logout, we really remove the client from rootAgents, even if the scene doesn't match | ||
253 | lock (m_RootAgents) | ||
254 | { | ||
255 | if (m_RootAgents.ContainsKey(client.AgentId)) m_RootAgents.Remove(client.AgentId); | ||
256 | } | ||
257 | |||
258 | // now inform the messaging server and anyone who is interested | ||
259 | NotifyMessageServerOfAgentLeaving(client.AgentId, scene.RegionInfo.RegionID, scene.RegionInfo.RegionHandle); | ||
260 | if (OnPresenceChange != null) OnPresenceChange(new PresenceInfo(client.AgentId, UUID.Zero)); | ||
261 | } | ||
262 | |||
263 | public void OnSetRootAgentScene(UUID agentID, Scene scene) | ||
264 | { | ||
265 | // OnSetRootAgentScene can be called from several threads at once (with different agentID). | ||
266 | // Concurrent access to m_RootAgents is prone to failure on multi-core/-processor systems without | ||
267 | // correct locking). | ||
268 | lock (m_RootAgents) | ||
269 | { | ||
270 | Scene rootScene; | ||
271 | if (m_RootAgents.TryGetValue(agentID, out rootScene) && scene == rootScene) | ||
272 | { | ||
273 | return; | ||
274 | } | ||
275 | m_RootAgents[agentID] = scene; | ||
276 | } | ||
277 | |||
278 | // inform messaging server that agent changed the region | ||
279 | Util.FireAndForget( | ||
280 | delegate(object o) | ||
281 | { | ||
282 | NotifyMessageServerOfAgentLocation(agentID, scene.RegionInfo.RegionID, scene.RegionInfo.RegionHandle); | ||
283 | } | ||
284 | ); | ||
285 | } | ||
286 | |||
287 | private void OnEconomyDataRequest(UUID agentID) | ||
288 | { | 68 | { |
289 | // KLUDGE: This is the only way I found to get a message (only) after login was completed and the | ||
290 | // client is connected enough to receive UDP packets. | ||
291 | // This packet seems to be sent only once, just after connection was established to the first | ||
292 | // region after login. | ||
293 | // We use it here to trigger a presence update; the old update-on-login was never be heard by | ||
294 | // the freshly logged in viewer, as it wasn't connected to the region at that time. | ||
295 | // TODO: Feel free to replace this by a better solution if you find one. | ||
296 | |||
297 | // get the agent. This should work every time, as we just got a packet from it | ||
298 | ScenePresence agent = null; | ||
299 | lock (m_Scenes) | ||
300 | { | ||
301 | foreach (Scene scene in m_Scenes) | ||
302 | { | ||
303 | agent = scene.GetScenePresence(agentID); | ||
304 | if (agent != null) break; | ||
305 | } | ||
306 | } | ||
307 | |||
308 | // just to be paranoid... | ||
309 | if (agent == null) | ||
310 | { | ||
311 | m_log.ErrorFormat("[PRESENCE]: Got a packet from agent {0} who can't be found anymore!?", agentID); | ||
312 | return; | ||
313 | } | ||
314 | |||
315 | // we are a bit premature here, but the next packet will switch this child agent to root. | ||
316 | if (OnPresenceChange != null) OnPresenceChange(new PresenceInfo(agentID, agent.Scene.RegionInfo.RegionID)); | ||
317 | } | 69 | } |
318 | 70 | ||
319 | public void OnMakeChildAgent(ScenePresence agent) | 71 | public void Close() |
320 | { | 72 | { |
321 | // OnMakeChildAgent can be called from several threads at once (with different agent). | ||
322 | // Concurrent access to m_RootAgents is prone to failure on multi-core/-processor systems without | ||
323 | // correct locking). | ||
324 | lock (m_RootAgents) | ||
325 | { | ||
326 | Scene rootScene; | ||
327 | if (m_RootAgents.TryGetValue(agent.UUID, out rootScene) && agent.Scene == rootScene) | ||
328 | { | ||
329 | m_RootAgents.Remove(agent.UUID); | ||
330 | } | ||
331 | } | ||
332 | // don't notify the messaging-server; either this agent just had been downgraded and another one will be upgraded | ||
333 | // to root momentarily (which will notify the messaging-server), or possibly it will be closed in a moment, | ||
334 | // which will update the messaging-server, too. | ||
335 | } | 73 | } |
336 | 74 | ||
337 | private void NotifyMessageServerOfStartup(Scene scene) | 75 | public string Name |
338 | { | 76 | { |
339 | Hashtable xmlrpcdata = new Hashtable(); | 77 | get { return "PresenceModule"; } |
340 | xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString(); | ||
341 | ArrayList SendParams = new ArrayList(); | ||
342 | SendParams.Add(xmlrpcdata); | ||
343 | try | ||
344 | { | ||
345 | XmlRpcRequest UpRequest = new XmlRpcRequest("region_startup", SendParams); | ||
346 | XmlRpcResponse resp = UpRequest.Send(scene.CommsManager.NetworkServersInfo.MessagingURL, 5000); | ||
347 | |||
348 | Hashtable responseData = (Hashtable)resp.Value; | ||
349 | if (responseData == null || (!responseData.ContainsKey("success")) || (string)responseData["success"] != "TRUE") | ||
350 | { | ||
351 | m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of region startup for region {0}", scene.RegionInfo.RegionName); | ||
352 | } | ||
353 | } | ||
354 | catch (WebException) | ||
355 | { | ||
356 | m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of region startup for region {0}", scene.RegionInfo.RegionName); | ||
357 | } | ||
358 | } | 78 | } |
359 | 79 | ||
360 | private void NotifyMessageServerOfShutdown(Scene scene) | 80 | public Type ReplaceableInterface |
361 | { | 81 | { |
362 | if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty) | 82 | get { return null; } |
363 | return; | ||
364 | |||
365 | Hashtable xmlrpcdata = new Hashtable(); | ||
366 | xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString(); | ||
367 | ArrayList SendParams = new ArrayList(); | ||
368 | SendParams.Add(xmlrpcdata); | ||
369 | try | ||
370 | { | ||
371 | XmlRpcRequest DownRequest = new XmlRpcRequest("region_shutdown", SendParams); | ||
372 | XmlRpcResponse resp = DownRequest.Send(scene.CommsManager.NetworkServersInfo.MessagingURL, 5000); | ||
373 | |||
374 | Hashtable responseData = (Hashtable)resp.Value; | ||
375 | if ((!responseData.ContainsKey("success")) || (string)responseData["success"] != "TRUE") | ||
376 | { | ||
377 | m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of region shutdown for region {0}", scene.RegionInfo.RegionName); | ||
378 | } | ||
379 | } | ||
380 | catch (WebException) | ||
381 | { | ||
382 | m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of region shutdown for region {0}", scene.RegionInfo.RegionName); | ||
383 | } | ||
384 | } | 83 | } |
385 | 84 | ||
386 | private void NotifyMessageServerOfAgentLocation(UUID agentID, UUID region, ulong regionHandle) | 85 | public void RequestBulkPresenceData(UUID[] users) |
387 | { | 86 | { |
388 | if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty) | ||
389 | return; | ||
390 | |||
391 | Hashtable xmlrpcdata = new Hashtable(); | ||
392 | xmlrpcdata["AgentID"] = agentID.ToString(); | ||
393 | xmlrpcdata["RegionUUID"] = region.ToString(); | ||
394 | xmlrpcdata["RegionHandle"] = regionHandle.ToString(); | ||
395 | ArrayList SendParams = new ArrayList(); | ||
396 | SendParams.Add(xmlrpcdata); | ||
397 | try | ||
398 | { | ||
399 | XmlRpcRequest LocationRequest = new XmlRpcRequest("agent_location", SendParams); | ||
400 | XmlRpcResponse resp = LocationRequest.Send(m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL, 5000); | ||
401 | |||
402 | Hashtable responseData = (Hashtable)resp.Value; | ||
403 | if ((!responseData.ContainsKey("success")) || (string)responseData["success"] != "TRUE") | ||
404 | { | ||
405 | m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of agent location for {0}", agentID.ToString()); | ||
406 | } | ||
407 | } | ||
408 | catch (WebException) | ||
409 | { | ||
410 | m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of agent location for {0}", agentID.ToString()); | ||
411 | } | ||
412 | } | 87 | } |
413 | 88 | ||
414 | private void NotifyMessageServerOfAgentLeaving(UUID agentID, UUID region, ulong regionHandle) | 89 | public void OnNewClient(IClientAPI client) |
415 | { | 90 | { |
416 | if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty) | ||
417 | return; | ||
418 | |||
419 | Hashtable xmlrpcdata = new Hashtable(); | ||
420 | xmlrpcdata["AgentID"] = agentID.ToString(); | ||
421 | xmlrpcdata["RegionUUID"] = region.ToString(); | ||
422 | xmlrpcdata["RegionHandle"] = regionHandle.ToString(); | ||
423 | ArrayList SendParams = new ArrayList(); | ||
424 | SendParams.Add(xmlrpcdata); | ||
425 | try | ||
426 | { | ||
427 | XmlRpcRequest LeavingRequest = new XmlRpcRequest("agent_leaving", SendParams); | ||
428 | XmlRpcResponse resp = LeavingRequest.Send(m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL, 5000); | ||
429 | |||
430 | Hashtable responseData = (Hashtable)resp.Value; | ||
431 | if ((!responseData.ContainsKey("success")) || (string)responseData["success"] != "TRUE") | ||
432 | { | ||
433 | m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of agent leaving for {0}", agentID.ToString()); | ||
434 | } | ||
435 | } | ||
436 | catch (WebException) | ||
437 | { | ||
438 | m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of agent leaving for {0}", agentID.ToString()); | ||
439 | } | ||
440 | } | 91 | } |
441 | } | 92 | } |
442 | } | 93 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index d9a021f..55d4f14 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | |||
@@ -39,7 +39,7 @@ using OpenSim.Services.Interfaces; | |||
39 | 39 | ||
40 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | 40 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer |
41 | { | 41 | { |
42 | public class InventoryTransferModule : IInventoryTransferModule, IRegionModule | 42 | public class InventoryTransferModule : IInventoryTransferModule, ISharedRegionModule |
43 | { | 43 | { |
44 | private static readonly ILog m_log | 44 | private static readonly ILog m_log |
45 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -50,10 +50,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
50 | new Dictionary<UUID, Scene>(); | 50 | new Dictionary<UUID, Scene>(); |
51 | 51 | ||
52 | private IMessageTransferModule m_TransferModule = null; | 52 | private IMessageTransferModule m_TransferModule = null; |
53 | private bool m_Enabled = true; | ||
53 | 54 | ||
54 | #region IRegionModule Members | 55 | #region IRegionModule Members |
55 | 56 | ||
56 | public void Initialise(Scene scene, IConfigSource config) | 57 | public void Initialise(IConfigSource config) |
57 | { | 58 | { |
58 | if (config.Configs["Messaging"] != null) | 59 | if (config.Configs["Messaging"] != null) |
59 | { | 60 | { |
@@ -62,29 +63,56 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
62 | if (config.Configs["Messaging"].GetString( | 63 | if (config.Configs["Messaging"].GetString( |
63 | "InventoryTransferModule", "InventoryTransferModule") != | 64 | "InventoryTransferModule", "InventoryTransferModule") != |
64 | "InventoryTransferModule") | 65 | "InventoryTransferModule") |
66 | { | ||
67 | m_Enabled = false; | ||
65 | return; | 68 | return; |
69 | } | ||
66 | } | 70 | } |
71 | } | ||
67 | 72 | ||
68 | if (!m_Scenelist.Contains(scene)) | 73 | public void AddRegion(Scene scene) |
69 | { | 74 | { |
70 | m_Scenelist.Add(scene); | 75 | if (!m_Enabled) |
76 | return; | ||
71 | 77 | ||
72 | scene.RegisterModuleInterface<IInventoryTransferModule>(this); | 78 | m_Scenelist.Add(scene); |
73 | 79 | ||
74 | scene.EventManager.OnNewClient += OnNewClient; | 80 | scene.RegisterModuleInterface<IInventoryTransferModule>(this); |
75 | scene.EventManager.OnClientClosed += ClientLoggedOut; | 81 | |
76 | scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; | 82 | scene.EventManager.OnNewClient += OnNewClient; |
77 | } | 83 | scene.EventManager.OnClientClosed += ClientLoggedOut; |
84 | scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; | ||
78 | } | 85 | } |
79 | 86 | ||
80 | public void PostInitialise() | 87 | public void RegionLoaded(Scene scene) |
81 | { | 88 | { |
82 | if (m_Scenelist.Count > 0) | 89 | if (m_TransferModule == null) |
83 | { | 90 | { |
84 | m_TransferModule = m_Scenelist[0].RequestModuleInterface<IMessageTransferModule>(); | 91 | m_TransferModule = m_Scenelist[0].RequestModuleInterface<IMessageTransferModule>(); |
85 | if (m_TransferModule == null) | 92 | if (m_TransferModule == null) |
93 | { | ||
86 | m_log.Error("[INVENTORY TRANSFER] No Message transfer module found, transfers will be local only"); | 94 | m_log.Error("[INVENTORY TRANSFER] No Message transfer module found, transfers will be local only"); |
95 | m_Enabled = false; | ||
96 | |||
97 | m_Scenelist.Clear(); | ||
98 | scene.EventManager.OnNewClient -= OnNewClient; | ||
99 | scene.EventManager.OnClientClosed -= ClientLoggedOut; | ||
100 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; | ||
101 | } | ||
87 | } | 102 | } |
103 | |||
104 | } | ||
105 | |||
106 | public void RemoveRegion(Scene scene) | ||
107 | { | ||
108 | scene.EventManager.OnNewClient -= OnNewClient; | ||
109 | scene.EventManager.OnClientClosed -= ClientLoggedOut; | ||
110 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; | ||
111 | m_Scenelist.Remove(scene); | ||
112 | } | ||
113 | |||
114 | public void PostInitialise() | ||
115 | { | ||
88 | } | 116 | } |
89 | 117 | ||
90 | public void Close() | 118 | public void Close() |
@@ -96,9 +124,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
96 | get { return "InventoryModule"; } | 124 | get { return "InventoryModule"; } |
97 | } | 125 | } |
98 | 126 | ||
99 | public bool IsSharedModule | 127 | public Type ReplaceableInterface |
100 | { | 128 | { |
101 | get { return true; } | 129 | get { return null; } |
102 | } | 130 | } |
103 | 131 | ||
104 | #endregion | 132 | #endregion |
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs index 261bd6c..d1d7df2 100644 --- a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs | |||
@@ -37,34 +37,72 @@ using OpenSim.Region.Framework.Scenes; | |||
37 | 37 | ||
38 | namespace OpenSim.Region.CoreModules.Avatar.Lure | 38 | namespace OpenSim.Region.CoreModules.Avatar.Lure |
39 | { | 39 | { |
40 | public class LureModule : IRegionModule | 40 | public class LureModule : ISharedRegionModule |
41 | { | 41 | { |
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 42 | private static readonly ILog m_log = LogManager.GetLogger( |
43 | MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | 44 | ||
44 | private readonly List<Scene> m_scenes = new List<Scene>(); | 45 | private readonly List<Scene> m_scenes = new List<Scene>(); |
45 | 46 | ||
46 | private IMessageTransferModule m_TransferModule = null; | 47 | private IMessageTransferModule m_TransferModule = null; |
48 | private bool m_Enabled = true; | ||
47 | 49 | ||
48 | public void Initialise(Scene scene, IConfigSource config) | 50 | public void Initialise(IConfigSource config) |
49 | { | 51 | { |
50 | if (config.Configs["Messaging"] != null) | 52 | if (config.Configs["Messaging"] != null) |
51 | { | 53 | { |
52 | if (config.Configs["Messaging"].GetString( | 54 | if (config.Configs["Messaging"].GetString( |
53 | "LureModule", "LureModule") != | 55 | "LureModule", "LureModule") != |
54 | "LureModule") | 56 | "LureModule") |
55 | return; | 57 | m_Enabled = false; |
56 | } | 58 | } |
59 | } | ||
60 | |||
61 | public void AddRegion(Scene scene) | ||
62 | { | ||
63 | if (!m_Enabled) | ||
64 | return; | ||
57 | 65 | ||
58 | lock (m_scenes) | 66 | lock (m_scenes) |
59 | { | 67 | { |
60 | if (!m_scenes.Contains(scene)) | 68 | m_scenes.Add(scene); |
69 | scene.EventManager.OnNewClient += OnNewClient; | ||
70 | scene.EventManager.OnIncomingInstantMessage += | ||
71 | OnGridInstantMessage; | ||
72 | } | ||
73 | } | ||
74 | |||
75 | public void RegionLoaded(Scene scene) | ||
76 | { | ||
77 | if (m_TransferModule == null) | ||
78 | { | ||
79 | m_TransferModule = | ||
80 | scene.RequestModuleInterface<IMessageTransferModule>(); | ||
81 | |||
82 | if (m_TransferModule == null) | ||
61 | { | 83 | { |
62 | m_scenes.Add(scene); | 84 | m_log.Error("[INSTANT MESSAGE]: No message transfer module, "+ |
63 | scene.EventManager.OnNewClient += OnNewClient; | 85 | "lures will not work!"); |
64 | scene.EventManager.OnIncomingInstantMessage += | 86 | |
87 | m_Enabled = false; | ||
88 | m_scenes.Clear(); | ||
89 | scene.EventManager.OnNewClient -= OnNewClient; | ||
90 | scene.EventManager.OnIncomingInstantMessage -= | ||
65 | OnGridInstantMessage; | 91 | OnGridInstantMessage; |
66 | } | 92 | } |
67 | } | 93 | } |
94 | |||
95 | } | ||
96 | |||
97 | public void RemoveRegion(Scene scene) | ||
98 | { | ||
99 | lock (m_scenes) | ||
100 | { | ||
101 | m_scenes.Remove(scene); | ||
102 | scene.EventManager.OnNewClient -= OnNewClient; | ||
103 | scene.EventManager.OnIncomingInstantMessage -= | ||
104 | OnGridInstantMessage; | ||
105 | } | ||
68 | } | 106 | } |
69 | 107 | ||
70 | void OnNewClient(IClientAPI client) | 108 | void OnNewClient(IClientAPI client) |
@@ -76,12 +114,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
76 | 114 | ||
77 | public void PostInitialise() | 115 | public void PostInitialise() |
78 | { | 116 | { |
79 | m_TransferModule = | ||
80 | m_scenes[0].RequestModuleInterface<IMessageTransferModule>(); | ||
81 | |||
82 | if (m_TransferModule == null) | ||
83 | m_log.Error("[INSTANT MESSAGE]: No message transfer module, "+ | ||
84 | "lures will not work!"); | ||
85 | } | 117 | } |
86 | 118 | ||
87 | public void Close() | 119 | public void Close() |
@@ -93,9 +125,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
93 | get { return "LureModule"; } | 125 | get { return "LureModule"; } |
94 | } | 126 | } |
95 | 127 | ||
96 | public bool IsSharedModule | 128 | public Type ReplaceableInterface |
97 | { | 129 | { |
98 | get { return true; } | 130 | get { return null; } |
99 | } | 131 | } |
100 | 132 | ||
101 | public void OnInstantMessage(IClientAPI client, GridInstantMessage im) | 133 | public void OnInstantMessage(IClientAPI client, GridInstantMessage im) |
diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs index 6941e00..f1022fd 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs | |||
@@ -37,6 +37,7 @@ using OpenSim.Region.Framework; | |||
37 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
38 | using OpenSim.Region.Framework.Scenes; | 38 | using OpenSim.Region.Framework.Scenes; |
39 | using OpenSim.Services.Interfaces; | 39 | using OpenSim.Services.Interfaces; |
40 | using OpenSim.Server.Base; | ||
40 | 41 | ||
41 | using OpenMetaverse; | 42 | using OpenMetaverse; |
42 | using log4net; | 43 | using log4net; |
@@ -53,6 +54,8 @@ namespace OpenSim.Region.CoreModules.Framework.Library | |||
53 | private string m_LibraryName = "OpenSim Library"; | 54 | private string m_LibraryName = "OpenSim Library"; |
54 | private Scene m_Scene; | 55 | private Scene m_Scene; |
55 | 56 | ||
57 | private ILibraryService m_Library; | ||
58 | |||
56 | #region ISharedRegionModule | 59 | #region ISharedRegionModule |
57 | 60 | ||
58 | public void Initialise(IConfigSource config) | 61 | public void Initialise(IConfigSource config) |
@@ -60,9 +63,22 @@ namespace OpenSim.Region.CoreModules.Framework.Library | |||
60 | m_Enabled = config.Configs["Modules"].GetBoolean("LibraryModule", m_Enabled); | 63 | m_Enabled = config.Configs["Modules"].GetBoolean("LibraryModule", m_Enabled); |
61 | if (m_Enabled) | 64 | if (m_Enabled) |
62 | { | 65 | { |
63 | IConfig libConfig = config.Configs["LibraryModule"]; | 66 | IConfig libConfig = config.Configs["LibraryService"]; |
64 | if (libConfig != null) | 67 | if (libConfig != null) |
65 | m_LibraryName = libConfig.GetString("LibraryName", m_LibraryName); | 68 | { |
69 | string dllName = libConfig.GetString("LocalServiceModule", string.Empty); | ||
70 | m_log.Debug("[LIBRARY MODULE]: Library service dll is " + dllName); | ||
71 | if (dllName != string.Empty) | ||
72 | { | ||
73 | Object[] args = new Object[] { config }; | ||
74 | m_Library = ServerUtils.LoadPlugin<ILibraryService>(dllName, args); | ||
75 | } | ||
76 | } | ||
77 | } | ||
78 | if (m_Library == null) | ||
79 | { | ||
80 | m_log.Warn("[LIBRARY MODULE]: No local library service. Module will be disabled."); | ||
81 | m_Enabled = false; | ||
66 | } | 82 | } |
67 | } | 83 | } |
68 | 84 | ||
@@ -91,10 +107,15 @@ namespace OpenSim.Region.CoreModules.Framework.Library | |||
91 | { | 107 | { |
92 | m_Scene = scene; | 108 | m_Scene = scene; |
93 | } | 109 | } |
110 | scene.RegisterModuleInterface<ILibraryService>(m_Library); | ||
94 | } | 111 | } |
95 | 112 | ||
96 | public void RemoveRegion(Scene scene) | 113 | public void RemoveRegion(Scene scene) |
97 | { | 114 | { |
115 | if (!m_Enabled) | ||
116 | return; | ||
117 | |||
118 | scene.UnregisterModuleInterface<ILibraryService>(m_Library); | ||
98 | } | 119 | } |
99 | 120 | ||
100 | public void RegionLoaded(Scene scene) | 121 | public void RegionLoaded(Scene scene) |
@@ -127,19 +148,17 @@ namespace OpenSim.Region.CoreModules.Framework.Library | |||
127 | 148 | ||
128 | protected void LoadLibrariesFromArchives() | 149 | protected void LoadLibrariesFromArchives() |
129 | { | 150 | { |
130 | InventoryFolderImpl lib = m_Scene.CommsManager.UserProfileCacheService.LibraryRoot; | 151 | InventoryFolderImpl lib = m_Library.LibraryRootFolder; |
131 | if (lib == null) | 152 | if (lib == null) |
132 | { | 153 | { |
133 | m_log.Debug("[LIBRARY MODULE]: No library. Ignoring Library Module"); | 154 | m_log.Debug("[LIBRARY MODULE]: No library. Ignoring Library Module"); |
134 | return; | 155 | return; |
135 | } | 156 | } |
136 | 157 | ||
137 | lib.Name = m_LibraryName; | ||
138 | |||
139 | RegionInfo regInfo = new RegionInfo(); | 158 | RegionInfo regInfo = new RegionInfo(); |
140 | Scene m_MockScene = new Scene(regInfo); | 159 | Scene m_MockScene = new Scene(regInfo); |
141 | m_MockScene.CommsManager = m_Scene.CommsManager; | 160 | m_MockScene.CommsManager = m_Scene.CommsManager; |
142 | LocalInventoryService invService = new LocalInventoryService((LibraryRootFolder)lib); | 161 | LocalInventoryService invService = new LocalInventoryService(lib); |
143 | m_MockScene.RegisterModuleInterface<IInventoryService>(invService); | 162 | m_MockScene.RegisterModuleInterface<IInventoryService>(invService); |
144 | m_MockScene.RegisterModuleInterface<IAssetService>(m_Scene.AssetService); | 163 | m_MockScene.RegisterModuleInterface<IAssetService>(m_Scene.AssetService); |
145 | 164 | ||
@@ -181,7 +200,7 @@ namespace OpenSim.Region.CoreModules.Framework.Library | |||
181 | 200 | ||
182 | private void DumpLibrary() | 201 | private void DumpLibrary() |
183 | { | 202 | { |
184 | InventoryFolderImpl lib = m_Scene.CommsManager.UserProfileCacheService.LibraryRoot; | 203 | InventoryFolderImpl lib = m_Library.LibraryRootFolder; |
185 | 204 | ||
186 | m_log.DebugFormat(" - folder {0}", lib.Name); | 205 | m_log.DebugFormat(" - folder {0}", lib.Name); |
187 | DumpFolder(lib); | 206 | DumpFolder(lib); |
diff --git a/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs b/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs index 2c95b5a..685c031 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs | |||
@@ -41,9 +41,9 @@ namespace OpenSim.Region.CoreModules.Framework.Library | |||
41 | { | 41 | { |
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
43 | 43 | ||
44 | private LibraryRootFolder m_Library; | 44 | private InventoryFolderImpl m_Library; |
45 | 45 | ||
46 | public LocalInventoryService(LibraryRootFolder lib) | 46 | public LocalInventoryService(InventoryFolderImpl lib) |
47 | { | 47 | { |
48 | m_Library = lib; | 48 | m_Library = lib; |
49 | } | 49 | } |
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index beb2307..7b9fdee 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml | |||
@@ -17,15 +17,25 @@ | |||
17 | <RegionModule id="HGWorldMapModule" type="OpenSim.Region.CoreModules.Hypergrid.HGWorldMapModule" /> | 17 | <RegionModule id="HGWorldMapModule" type="OpenSim.Region.CoreModules.Hypergrid.HGWorldMapModule" /> |
18 | <RegionModule id="UrlModule" type="OpenSim.Region.CoreModules.Scripting.LSLHttp.UrlModule" /> | 18 | <RegionModule id="UrlModule" type="OpenSim.Region.CoreModules.Scripting.LSLHttp.UrlModule" /> |
19 | <RegionModule id="Chat" type="OpenSim.Region.CoreModules.Avatar.Chat.ChatModule" /> | 19 | <RegionModule id="Chat" type="OpenSim.Region.CoreModules.Avatar.Chat.ChatModule" /> |
20 | <RegionModule id="FriendsModule" type="OpenSim.Region.CoreModules.Avatar.Friends.FriendsModule" /> | ||
21 | <RegionModule id="PresenceModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.PresenceModule" /> | ||
22 | <RegionModule id="MuteListModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.MuteListModule" /> | ||
23 | <RegionModule id="OfflineMessageModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.OfflineMessageModule" /> | ||
24 | <RegionModule id="InstantMessageModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.InstantMessageModule" /> | ||
25 | <RegionModule id="MessageTransferModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.MessageTransferModule" /> | ||
26 | <RegionModule id="LureModule" type="OpenSim.Region.CoreModules.Avatar.Lure.LureModule" /> | ||
27 | <RegionModule id="InventoryTransferModule" type="OpenSim.Region.CoreModules.Avatar.Inventory.Transfer.InventoryTransferModule" /> | ||
20 | <RegionModule id="CoreAssetCache" type="OpenSim.Region.CoreModules.Asset.CoreAssetCache" /> | 28 | <RegionModule id="CoreAssetCache" type="OpenSim.Region.CoreModules.Asset.CoreAssetCache" /> |
21 | <RegionModule id="GlynnTuckerAssetCache" type="OpenSim.Region.CoreModules.Asset.GlynnTuckerAssetCache" /> | 29 | <RegionModule id="GlynnTuckerAssetCache" type="OpenSim.Region.CoreModules.Asset.GlynnTuckerAssetCache" /> |
22 | <RegionModule id="CenomeMemoryAssetCache" type="OpenSim.Region.CoreModules.Asset.CenomeMemoryAssetCache"/> | 30 | <RegionModule id="CenomeMemoryAssetCache" type="OpenSim.Region.CoreModules.Asset.CenomeMemoryAssetCache"/> |
23 | <RegionModule id="LibraryModule" type="OpenSim.Region.CoreModules.Framework.Library.LibraryModule"/> | 31 | <RegionModule id="LibraryModule" type="OpenSim.Region.CoreModules.Framework.Library.LibraryModule"/> |
24 | <!-- Service connectors OUT modules --> | 32 | <!-- Service connectors OUT modules --> |
25 | <RegionModule id="LocalUserServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.User.LocalUserServicesConnector" /> | ||
26 | <RegionModule id="RemoteUserServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.User.RemoteUserServicesConnector" /> | ||
27 | <RegionModule id="LocalAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.LocalAssetServicesConnector" /> | 33 | <RegionModule id="LocalAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.LocalAssetServicesConnector" /> |
28 | <RegionModule id="RemoteAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.RemoteAssetServicesConnector" /> | 34 | <RegionModule id="RemoteAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.RemoteAssetServicesConnector" /> |
35 | <RegionModule id="LocalAvatarServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar.LocalAvatarServicesConnector" /> | ||
36 | <RegionModule id="RemoteAvatarServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar.RemoteAvatarServicesConnector" /> | ||
37 | <RegionModule id="LocalAuthenticationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication.LocalAuthenticationServicesConnector" /> | ||
38 | <RegionModule id="RemoteAuthenticationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication.RemoteAuthenticationServicesConnector" /> | ||
29 | <RegionModule id="LocalAuthorizationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization.LocalAuthorizationServicesConnector" /> | 39 | <RegionModule id="LocalAuthorizationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization.LocalAuthorizationServicesConnector" /> |
30 | <RegionModule id="RemoteAuthorizationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization.RemoteAuthorizationServicesConnector" /> | 40 | <RegionModule id="RemoteAuthorizationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization.RemoteAuthorizationServicesConnector" /> |
31 | <RegionModule id="HGAssetBroker" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.HGAssetBroker" /> | 41 | <RegionModule id="HGAssetBroker" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.HGAssetBroker" /> |
@@ -41,12 +51,20 @@ | |||
41 | <RegionModule id="LocalGridServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.LocalGridServicesConnector" /> | 51 | <RegionModule id="LocalGridServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.LocalGridServicesConnector" /> |
42 | <RegionModule id="RemoteGridServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.RemoteGridServicesConnector" /> | 52 | <RegionModule id="RemoteGridServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.RemoteGridServicesConnector" /> |
43 | <RegionModule id="HGGridConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.HGGridConnector" /> | 53 | <RegionModule id="HGGridConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.HGGridConnector" /> |
54 | <RegionModule id="LocalPresenceServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.LocalPresenceServicesConnector" /> | ||
55 | <RegionModule id="RemotePresenceServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.RemotePresenceServicesConnector" /> | ||
56 | <RegionModule id="LocalUserAccountServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts.LocalUserAccountServicesConnector" /> | ||
57 | <RegionModule id="RemoteUserAccountServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts.RemoteUserAccountServicesConnector" /> | ||
58 | <RegionModule id="LocalSimulationConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation.LocalSimulationConnectorModule" /> | ||
59 | <RegionModule id="RemoteSimulationConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation.RemoteSimulationConnectorModule" /> | ||
44 | <!-- Service connectors IN modules --> | 60 | <!-- Service connectors IN modules --> |
45 | <RegionModule id="AssetServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset.AssetServiceInConnectorModule" /> | 61 | <RegionModule id="AssetServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset.AssetServiceInConnectorModule" /> |
46 | <RegionModule id="InventoryServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory.InventoryServiceInConnectorModule" /> | 62 | <RegionModule id="InventoryServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory.InventoryServiceInConnectorModule" /> |
47 | <RegionModule id="LandServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Land.LandServiceInConnectorModule" /> | 63 | <RegionModule id="LandServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Land.LandServiceInConnectorModule" /> |
48 | <RegionModule id="NeighbourServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour.NeighbourServiceInConnectorModule" /> \ | 64 | <RegionModule id="NeighbourServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour.NeighbourServiceInConnectorModule" /> \ |
49 | <RegionModule id="HypergridServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid.HypergridServiceInConnectorModule" /> \ | 65 | <RegionModule id="HypergridServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid.HypergridServiceInConnectorModule" /> \ |
66 | <RegionModule id="LLLoginServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Login.LLLoginServiceInConnectorModule" /> \ | ||
67 | <RegionModule id="SimulationServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation.SimulationServiceInConnectorModule" /> \ | ||
50 | 68 | ||
51 | </Extension> | 69 | </Extension> |
52 | 70 | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs new file mode 100644 index 0000000..2a9366c --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs | |||
@@ -0,0 +1,128 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using System.Collections.Generic; | ||
31 | using log4net; | ||
32 | using Nini.Config; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Servers.HttpServer; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | using OpenSim.Region.Framework.Interfaces; | ||
37 | using OpenSim.Server.Base; | ||
38 | using OpenSim.Server.Handlers.Base; | ||
39 | using OpenSim.Server.Handlers.Login; | ||
40 | using OpenSim.Services.Interfaces; | ||
41 | |||
42 | |||
43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Login | ||
44 | { | ||
45 | public class LLLoginServiceInConnectorModule : ISharedRegionModule | ||
46 | { | ||
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | private static bool m_Enabled = false; | ||
49 | private static bool m_Registered = false; | ||
50 | |||
51 | private IConfigSource m_Config; | ||
52 | private List<Scene> m_Scenes = new List<Scene>(); | ||
53 | |||
54 | #region IRegionModule interface | ||
55 | |||
56 | public void Initialise(IConfigSource config) | ||
57 | { | ||
58 | m_Config = config; | ||
59 | |||
60 | IConfig moduleConfig = config.Configs["Modules"]; | ||
61 | if (moduleConfig != null) | ||
62 | { | ||
63 | m_Enabled = moduleConfig.GetBoolean("LLLoginServiceInConnector", false); | ||
64 | if (m_Enabled) | ||
65 | { | ||
66 | m_log.Info("[LLLOGIN IN CONNECTOR]: LLLoginerviceInConnector enabled"); | ||
67 | } | ||
68 | |||
69 | } | ||
70 | |||
71 | } | ||
72 | |||
73 | public void PostInitialise() | ||
74 | { | ||
75 | if (!m_Enabled) | ||
76 | return; | ||
77 | |||
78 | m_log.Info("[LLLOGIN IN CONNECTOR]: Starting..."); | ||
79 | } | ||
80 | |||
81 | public void Close() | ||
82 | { | ||
83 | } | ||
84 | |||
85 | public Type ReplaceableInterface | ||
86 | { | ||
87 | get { return null; } | ||
88 | } | ||
89 | |||
90 | public string Name | ||
91 | { | ||
92 | get { return "LLLoginServiceInConnectorModule"; } | ||
93 | } | ||
94 | |||
95 | public void AddRegion(Scene scene) | ||
96 | { | ||
97 | if (!m_Enabled) | ||
98 | return; | ||
99 | |||
100 | m_Scenes.Add(scene); | ||
101 | |||
102 | } | ||
103 | |||
104 | public void RemoveRegion(Scene scene) | ||
105 | { | ||
106 | if (m_Enabled && m_Scenes.Contains(scene)) | ||
107 | m_Scenes.Remove(scene); | ||
108 | } | ||
109 | |||
110 | public void RegionLoaded(Scene scene) | ||
111 | { | ||
112 | if (!m_Enabled) | ||
113 | return; | ||
114 | |||
115 | if (!m_Registered) | ||
116 | { | ||
117 | m_Registered = true; | ||
118 | new LLLoginServiceInConnector(m_Config, MainServer.Instance, scene); | ||
119 | //Object[] args = new Object[] { m_Config, MainServer.Instance, this, scene }; | ||
120 | //ServerUtils.LoadPlugin<IServiceConnector>("OpenSim.Server.Handlers.dll:LLLoginServiceInConnector", args); | ||
121 | } | ||
122 | |||
123 | } | ||
124 | |||
125 | #endregion | ||
126 | |||
127 | } | ||
128 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs index f28a318..5ee1c97 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs | |||
@@ -58,11 +58,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation | |||
58 | IConfig moduleConfig = config.Configs["Modules"]; | 58 | IConfig moduleConfig = config.Configs["Modules"]; |
59 | if (moduleConfig != null) | 59 | if (moduleConfig != null) |
60 | { | 60 | { |
61 | string name = moduleConfig.GetString("SimulationService", ""); | 61 | m_Enabled = moduleConfig.GetBoolean("SimulationServiceInConnector", false); |
62 | if (name == Name) | 62 | if (m_Enabled) |
63 | { | 63 | { |
64 | m_Enabled = true; | 64 | m_log.Info("[SIM SERVICE]: SimulationService IN connector enabled"); |
65 | m_log.Info("[SIM SERVICE]: SimulationService enabled"); | ||
66 | 65 | ||
67 | } | 66 | } |
68 | } | 67 | } |
@@ -84,7 +83,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation | |||
84 | 83 | ||
85 | public string Name | 84 | public string Name |
86 | { | 85 | { |
87 | get { return "SimulationService"; } | 86 | get { return "SimulationServiceInConnectorModule"; } |
88 | } | 87 | } |
89 | 88 | ||
90 | public void AddRegion(Scene scene) | 89 | public void AddRegion(Scene scene) |
@@ -92,6 +91,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation | |||
92 | if (!m_Enabled) | 91 | if (!m_Enabled) |
93 | return; | 92 | return; |
94 | 93 | ||
94 | } | ||
95 | |||
96 | public void RemoveRegion(Scene scene) | ||
97 | { | ||
98 | } | ||
99 | |||
100 | public void RegionLoaded(Scene scene) | ||
101 | { | ||
102 | if (!m_Enabled) | ||
103 | return; | ||
104 | |||
95 | if (!m_Registered) | 105 | if (!m_Registered) |
96 | { | 106 | { |
97 | m_Registered = true; | 107 | m_Registered = true; |
@@ -104,14 +114,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation | |||
104 | } | 114 | } |
105 | } | 115 | } |
106 | 116 | ||
107 | public void RemoveRegion(Scene scene) | ||
108 | { | ||
109 | } | ||
110 | |||
111 | public void RegionLoaded(Scene scene) | ||
112 | { | ||
113 | } | ||
114 | |||
115 | #endregion | 117 | #endregion |
116 | 118 | ||
117 | } | 119 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs new file mode 100644 index 0000000..4c65722 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs | |||
@@ -0,0 +1,159 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using Nini.Config; | ||
33 | using OpenSim.Region.Framework.Interfaces; | ||
34 | using OpenSim.Region.Framework.Scenes; | ||
35 | using OpenSim.Server.Base; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | |||
38 | using OpenMetaverse; | ||
39 | |||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication | ||
41 | { | ||
42 | public class LocalAuthenticationServicesConnector : ISharedRegionModule, IAuthenticationService | ||
43 | { | ||
44 | private static readonly ILog m_log = | ||
45 | LogManager.GetLogger( | ||
46 | MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | private IAuthenticationService m_AuthenticationService; | ||
49 | |||
50 | private bool m_Enabled = false; | ||
51 | |||
52 | #region ISharedRegionModule | ||
53 | |||
54 | public Type ReplaceableInterface | ||
55 | { | ||
56 | get { return null; } | ||
57 | } | ||
58 | |||
59 | public string Name | ||
60 | { | ||
61 | get { return "LocalAuthenticationServicesConnector"; } | ||
62 | } | ||
63 | |||
64 | public void Initialise(IConfigSource source) | ||
65 | { | ||
66 | IConfig moduleConfig = source.Configs["Modules"]; | ||
67 | if (moduleConfig != null) | ||
68 | { | ||
69 | string name = moduleConfig.GetString("AuthenticationServices", ""); | ||
70 | if (name == Name) | ||
71 | { | ||
72 | IConfig userConfig = source.Configs["AuthenticationService"]; | ||
73 | if (userConfig == null) | ||
74 | { | ||
75 | m_log.Error("[AUTH CONNECTOR]: AuthenticationService missing from OpenSim.ini"); | ||
76 | return; | ||
77 | } | ||
78 | |||
79 | string serviceDll = userConfig.GetString("LocalServiceModule", | ||
80 | String.Empty); | ||
81 | |||
82 | if (serviceDll == String.Empty) | ||
83 | { | ||
84 | m_log.Error("[AUTH CONNECTOR]: No LocalServiceModule named in section AuthenticationService"); | ||
85 | return; | ||
86 | } | ||
87 | |||
88 | Object[] args = new Object[] { source }; | ||
89 | m_AuthenticationService = | ||
90 | ServerUtils.LoadPlugin<IAuthenticationService>(serviceDll, | ||
91 | args); | ||
92 | |||
93 | if (m_AuthenticationService == null) | ||
94 | { | ||
95 | m_log.Error("[AUTH CONNECTOR]: Can't load Authentication service"); | ||
96 | return; | ||
97 | } | ||
98 | m_Enabled = true; | ||
99 | m_log.Info("[AUTH CONNECTOR]: Local Authentication connector enabled"); | ||
100 | } | ||
101 | } | ||
102 | } | ||
103 | |||
104 | public void PostInitialise() | ||
105 | { | ||
106 | if (!m_Enabled) | ||
107 | return; | ||
108 | } | ||
109 | |||
110 | public void Close() | ||
111 | { | ||
112 | if (!m_Enabled) | ||
113 | return; | ||
114 | } | ||
115 | |||
116 | public void AddRegion(Scene scene) | ||
117 | { | ||
118 | if (!m_Enabled) | ||
119 | return; | ||
120 | |||
121 | scene.RegisterModuleInterface<IAuthenticationService>(m_AuthenticationService); | ||
122 | } | ||
123 | |||
124 | public void RemoveRegion(Scene scene) | ||
125 | { | ||
126 | if (!m_Enabled) | ||
127 | return; | ||
128 | } | ||
129 | |||
130 | public void RegionLoaded(Scene scene) | ||
131 | { | ||
132 | if (!m_Enabled) | ||
133 | return; | ||
134 | } | ||
135 | |||
136 | #endregion | ||
137 | |||
138 | #region IAuthenticationService | ||
139 | |||
140 | public string Authenticate(UUID principalID, string password, int lifetime) | ||
141 | { | ||
142 | // Not implemented at the regions | ||
143 | return string.Empty; | ||
144 | } | ||
145 | |||
146 | public bool Verify(UUID principalID, string token, int lifetime) | ||
147 | { | ||
148 | return m_AuthenticationService.Verify(principalID, token, lifetime); | ||
149 | } | ||
150 | |||
151 | public bool Release(UUID principalID, string token) | ||
152 | { | ||
153 | return m_AuthenticationService.Release(principalID, token); | ||
154 | } | ||
155 | |||
156 | #endregion | ||
157 | |||
158 | } | ||
159 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/RemoteAuthenticationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/RemoteAuthenticationServiceConnector.cs new file mode 100644 index 0000000..a053bc2 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/RemoteAuthenticationServiceConnector.cs | |||
@@ -0,0 +1,114 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using Nini.Config; | ||
30 | using log4net; | ||
31 | using System.Reflection; | ||
32 | using OpenSim.Region.Framework.Interfaces; | ||
33 | using OpenSim.Region.Framework.Scenes; | ||
34 | using OpenSim.Services.Interfaces; | ||
35 | using OpenSim.Services.Connectors; | ||
36 | |||
37 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication | ||
38 | { | ||
39 | public class RemoteAuthenticationServicesConnector : AuthenticationServicesConnector, | ||
40 | ISharedRegionModule, IAuthenticationService | ||
41 | { | ||
42 | private static readonly ILog m_log = | ||
43 | LogManager.GetLogger( | ||
44 | MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | |||
46 | private bool m_Enabled = false; | ||
47 | |||
48 | public Type ReplaceableInterface | ||
49 | { | ||
50 | get { return null; } | ||
51 | } | ||
52 | |||
53 | public string Name | ||
54 | { | ||
55 | get { return "RemoteAuthenticationServicesConnector"; } | ||
56 | } | ||
57 | |||
58 | public override void Initialise(IConfigSource source) | ||
59 | { | ||
60 | IConfig moduleConfig = source.Configs["Modules"]; | ||
61 | if (moduleConfig != null) | ||
62 | { | ||
63 | string name = moduleConfig.GetString("AuthenticationServices", ""); | ||
64 | if (name == Name) | ||
65 | { | ||
66 | IConfig userConfig = source.Configs["AuthenticationService"]; | ||
67 | if (userConfig == null) | ||
68 | { | ||
69 | m_log.Error("[AUTH CONNECTOR]: AuthenticationService missing from OpenSim.ini"); | ||
70 | return; | ||
71 | } | ||
72 | |||
73 | m_Enabled = true; | ||
74 | |||
75 | base.Initialise(source); | ||
76 | |||
77 | m_log.Info("[AUTH CONNECTOR]: Remote Authentication enabled"); | ||
78 | } | ||
79 | } | ||
80 | } | ||
81 | |||
82 | public void PostInitialise() | ||
83 | { | ||
84 | if (!m_Enabled) | ||
85 | return; | ||
86 | } | ||
87 | |||
88 | public void Close() | ||
89 | { | ||
90 | if (!m_Enabled) | ||
91 | return; | ||
92 | } | ||
93 | |||
94 | public void AddRegion(Scene scene) | ||
95 | { | ||
96 | if (!m_Enabled) | ||
97 | return; | ||
98 | |||
99 | scene.RegisterModuleInterface<IAuthenticationService>(this); | ||
100 | } | ||
101 | |||
102 | public void RemoveRegion(Scene scene) | ||
103 | { | ||
104 | if (!m_Enabled) | ||
105 | return; | ||
106 | } | ||
107 | |||
108 | public void RegionLoaded(Scene scene) | ||
109 | { | ||
110 | if (!m_Enabled) | ||
111 | return; | ||
112 | } | ||
113 | } | ||
114 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs new file mode 100644 index 0000000..0c8ee61 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs | |||
@@ -0,0 +1,168 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using Nini.Config; | ||
33 | using OpenSim.Region.Framework.Interfaces; | ||
34 | using OpenSim.Region.Framework.Scenes; | ||
35 | using OpenSim.Server.Base; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | |||
38 | using OpenMetaverse; | ||
39 | |||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar | ||
41 | { | ||
42 | public class LocalAvatarServicesConnector : ISharedRegionModule, IAvatarService | ||
43 | { | ||
44 | private static readonly ILog m_log = | ||
45 | LogManager.GetLogger( | ||
46 | MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | private IAvatarService m_AvatarService; | ||
49 | |||
50 | private bool m_Enabled = false; | ||
51 | |||
52 | #region ISharedRegionModule | ||
53 | |||
54 | public Type ReplaceableInterface | ||
55 | { | ||
56 | get { return null; } | ||
57 | } | ||
58 | |||
59 | public string Name | ||
60 | { | ||
61 | get { return "LocalAvatarServicesConnector"; } | ||
62 | } | ||
63 | |||
64 | public void Initialise(IConfigSource source) | ||
65 | { | ||
66 | IConfig moduleConfig = source.Configs["Modules"]; | ||
67 | if (moduleConfig != null) | ||
68 | { | ||
69 | string name = moduleConfig.GetString("AvatarServices", ""); | ||
70 | if (name == Name) | ||
71 | { | ||
72 | IConfig userConfig = source.Configs["AvatarService"]; | ||
73 | if (userConfig == null) | ||
74 | { | ||
75 | m_log.Error("[USER CONNECTOR]: AvatarService missing from OpenSim.ini"); | ||
76 | return; | ||
77 | } | ||
78 | |||
79 | string serviceDll = userConfig.GetString("LocalServiceModule", | ||
80 | String.Empty); | ||
81 | |||
82 | if (serviceDll == String.Empty) | ||
83 | { | ||
84 | m_log.Error("[USER CONNECTOR]: No LocalServiceModule named in section AvatarService"); | ||
85 | return; | ||
86 | } | ||
87 | |||
88 | Object[] args = new Object[] { source }; | ||
89 | m_AvatarService = | ||
90 | ServerUtils.LoadPlugin<IAvatarService>(serviceDll, | ||
91 | args); | ||
92 | |||
93 | if (m_AvatarService == null) | ||
94 | { | ||
95 | m_log.Error("[USER CONNECTOR]: Can't load user account service"); | ||
96 | return; | ||
97 | } | ||
98 | m_Enabled = true; | ||
99 | m_log.Info("[USER CONNECTOR]: Local avatar connector enabled"); | ||
100 | } | ||
101 | } | ||
102 | } | ||
103 | |||
104 | public void PostInitialise() | ||
105 | { | ||
106 | if (!m_Enabled) | ||
107 | return; | ||
108 | } | ||
109 | |||
110 | public void Close() | ||
111 | { | ||
112 | if (!m_Enabled) | ||
113 | return; | ||
114 | } | ||
115 | |||
116 | public void AddRegion(Scene scene) | ||
117 | { | ||
118 | if (!m_Enabled) | ||
119 | return; | ||
120 | |||
121 | scene.RegisterModuleInterface<IAvatarService>(m_AvatarService); | ||
122 | } | ||
123 | |||
124 | public void RemoveRegion(Scene scene) | ||
125 | { | ||
126 | if (!m_Enabled) | ||
127 | return; | ||
128 | } | ||
129 | |||
130 | public void RegionLoaded(Scene scene) | ||
131 | { | ||
132 | if (!m_Enabled) | ||
133 | return; | ||
134 | } | ||
135 | |||
136 | #endregion | ||
137 | |||
138 | #region IAvatarService | ||
139 | |||
140 | public AvatarData GetAvatar(UUID userID) | ||
141 | { | ||
142 | return m_AvatarService.GetAvatar(userID); | ||
143 | } | ||
144 | |||
145 | public bool SetAvatar(UUID userID, AvatarData avatar) | ||
146 | { | ||
147 | return m_AvatarService.SetAvatar(userID, avatar); | ||
148 | } | ||
149 | |||
150 | public bool ResetAvatar(UUID userID) | ||
151 | { | ||
152 | return m_AvatarService.ResetAvatar(userID); | ||
153 | } | ||
154 | |||
155 | public bool SetItems(UUID userID, string[] names, string[] values) | ||
156 | { | ||
157 | return m_AvatarService.SetItems(userID, names, values); | ||
158 | } | ||
159 | |||
160 | public bool RemoveItems(UUID userID, string[] names) | ||
161 | { | ||
162 | return m_AvatarService.RemoveItems(userID, names); | ||
163 | } | ||
164 | |||
165 | #endregion | ||
166 | |||
167 | } | ||
168 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs new file mode 100644 index 0000000..48759b5 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs | |||
@@ -0,0 +1,114 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using Nini.Config; | ||
30 | using log4net; | ||
31 | using System.Reflection; | ||
32 | using OpenSim.Region.Framework.Interfaces; | ||
33 | using OpenSim.Region.Framework.Scenes; | ||
34 | using OpenSim.Services.Interfaces; | ||
35 | using OpenSim.Services.Connectors; | ||
36 | |||
37 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar | ||
38 | { | ||
39 | public class RemoteAvatarServicesConnector : AvatarServicesConnector, | ||
40 | ISharedRegionModule, IAvatarService | ||
41 | { | ||
42 | private static readonly ILog m_log = | ||
43 | LogManager.GetLogger( | ||
44 | MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | |||
46 | private bool m_Enabled = false; | ||
47 | |||
48 | public Type ReplaceableInterface | ||
49 | { | ||
50 | get { return null; } | ||
51 | } | ||
52 | |||
53 | public string Name | ||
54 | { | ||
55 | get { return "RemoteAvatarServicesConnector"; } | ||
56 | } | ||
57 | |||
58 | public override void Initialise(IConfigSource source) | ||
59 | { | ||
60 | IConfig moduleConfig = source.Configs["Modules"]; | ||
61 | if (moduleConfig != null) | ||
62 | { | ||
63 | string name = moduleConfig.GetString("AvatarServices", ""); | ||
64 | if (name == Name) | ||
65 | { | ||
66 | IConfig userConfig = source.Configs["AvatarService"]; | ||
67 | if (userConfig == null) | ||
68 | { | ||
69 | m_log.Error("[AVATAR CONNECTOR]: AvatarService missing from OpanSim.ini"); | ||
70 | return; | ||
71 | } | ||
72 | |||
73 | m_Enabled = true; | ||
74 | |||
75 | base.Initialise(source); | ||
76 | |||
77 | m_log.Info("[AVATAR CONNECTOR]: Remote avatars enabled"); | ||
78 | } | ||
79 | } | ||
80 | } | ||
81 | |||
82 | public void PostInitialise() | ||
83 | { | ||
84 | if (!m_Enabled) | ||
85 | return; | ||
86 | } | ||
87 | |||
88 | public void Close() | ||
89 | { | ||
90 | if (!m_Enabled) | ||
91 | return; | ||
92 | } | ||
93 | |||
94 | public void AddRegion(Scene scene) | ||
95 | { | ||
96 | if (!m_Enabled) | ||
97 | return; | ||
98 | |||
99 | scene.RegisterModuleInterface<IAvatarService>(this); | ||
100 | } | ||
101 | |||
102 | public void RemoveRegion(Scene scene) | ||
103 | { | ||
104 | if (!m_Enabled) | ||
105 | return; | ||
106 | } | ||
107 | |||
108 | public void RegionLoaded(Scene scene) | ||
109 | { | ||
110 | if (!m_Enabled) | ||
111 | return; | ||
112 | } | ||
113 | } | ||
114 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs index 44458d1..fa3681a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs | |||
@@ -436,12 +436,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
436 | } | 436 | } |
437 | 437 | ||
438 | OSDMap resp = new OSDMap(2); | 438 | OSDMap resp = new OSDMap(2); |
439 | string reason = String.Empty; | 439 | string reason = String.Empty; |
440 | uint teleportFlags = 0; | 440 | uint teleportFlags = 0; |
441 | if (args.ContainsKey("teleport_flags")) | 441 | if (args.ContainsKey("teleport_flags")) |
442 | { | 442 | { |
443 | teleportFlags = args["teleport_flags"].AsUInteger(); | 443 | teleportFlags = args["teleport_flags"].AsUInteger(); |
444 | } | 444 | } |
445 | 445 | ||
446 | // This is the meaning of POST agent | 446 | // This is the meaning of POST agent |
447 | m_regionClient.AdjustUserInformation(aCircuit); | 447 | m_regionClient.AdjustUserInformation(aCircuit); |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs new file mode 100644 index 0000000..2cb18c7 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs | |||
@@ -0,0 +1,200 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | |||
31 | using OpenSim.Region.Framework.Interfaces; | ||
32 | using OpenSim.Region.Framework.Scenes; | ||
33 | using OpenSim.Server.Base; | ||
34 | using OpenSim.Services.Interfaces; | ||
35 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | ||
36 | |||
37 | using OpenMetaverse; | ||
38 | using log4net; | ||
39 | using Nini.Config; | ||
40 | |||
41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | ||
42 | { | ||
43 | public class LocalPresenceServicesConnector : ISharedRegionModule, IPresenceService | ||
44 | { | ||
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | private bool m_Enabled = false; | ||
48 | |||
49 | private PresenceDetector m_PresenceDetector; | ||
50 | private IPresenceService m_PresenceService; | ||
51 | |||
52 | public LocalPresenceServicesConnector() | ||
53 | { | ||
54 | } | ||
55 | |||
56 | public LocalPresenceServicesConnector(IConfigSource source) | ||
57 | { | ||
58 | Initialise(source); | ||
59 | } | ||
60 | |||
61 | #region ISharedRegionModule | ||
62 | |||
63 | public Type ReplaceableInterface | ||
64 | { | ||
65 | get { return null; } | ||
66 | } | ||
67 | |||
68 | public string Name | ||
69 | { | ||
70 | get { return "LocalPresenceServicesConnector"; } | ||
71 | } | ||
72 | |||
73 | public void Initialise(IConfigSource source) | ||
74 | { | ||
75 | IConfig moduleConfig = source.Configs["Modules"]; | ||
76 | if (moduleConfig != null) | ||
77 | { | ||
78 | string name = moduleConfig.GetString("PresenceServices", ""); | ||
79 | if (name == Name) | ||
80 | { | ||
81 | IConfig inventoryConfig = source.Configs["PresenceService"]; | ||
82 | if (inventoryConfig == null) | ||
83 | { | ||
84 | m_log.Error("[LOCAL PRESENCE CONNECTOR]: PresenceService missing from OpenSim.ini"); | ||
85 | return; | ||
86 | } | ||
87 | |||
88 | string serviceDll = inventoryConfig.GetString("LocalServiceModule", String.Empty); | ||
89 | |||
90 | if (serviceDll == String.Empty) | ||
91 | { | ||
92 | m_log.Error("[LOCAL PRESENCE CONNECTOR]: No LocalServiceModule named in section PresenceService"); | ||
93 | return; | ||
94 | } | ||
95 | |||
96 | Object[] args = new Object[] { source }; | ||
97 | m_log.DebugFormat("[LOCAL PRESENCE CONNECTOR]: Service dll = {0}", serviceDll); | ||
98 | |||
99 | m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(serviceDll, args); | ||
100 | |||
101 | if (m_PresenceService == null) | ||
102 | { | ||
103 | m_log.Error("[LOCAL PRESENCE CONNECTOR]: Can't load presence service"); | ||
104 | //return; | ||
105 | throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); | ||
106 | } | ||
107 | |||
108 | //Init(source); | ||
109 | |||
110 | m_PresenceDetector = new PresenceDetector(this); | ||
111 | |||
112 | m_Enabled = true; | ||
113 | m_log.Info("[LOCAL PRESENCE CONNECTOR]: Local presence connector enabled"); | ||
114 | } | ||
115 | } | ||
116 | } | ||
117 | |||
118 | public void PostInitialise() | ||
119 | { | ||
120 | } | ||
121 | |||
122 | public void Close() | ||
123 | { | ||
124 | } | ||
125 | |||
126 | public void AddRegion(Scene scene) | ||
127 | { | ||
128 | if (!m_Enabled) | ||
129 | return; | ||
130 | |||
131 | // m_log.DebugFormat( | ||
132 | // "[LOCAL PRESENCE CONNECTOR]: Registering IPresenceService to scene {0}", scene.RegionInfo.RegionName); | ||
133 | |||
134 | scene.RegisterModuleInterface<IPresenceService>(this); | ||
135 | m_PresenceDetector.AddRegion(scene); | ||
136 | |||
137 | m_log.InfoFormat("[LOCAL PRESENCE CONNECTOR]: Enabled local presence for region {0}", scene.RegionInfo.RegionName); | ||
138 | |||
139 | } | ||
140 | |||
141 | public void RemoveRegion(Scene scene) | ||
142 | { | ||
143 | if (!m_Enabled) | ||
144 | return; | ||
145 | |||
146 | m_PresenceDetector.RemoveRegion(scene); | ||
147 | } | ||
148 | |||
149 | public void RegionLoaded(Scene scene) | ||
150 | { | ||
151 | if (!m_Enabled) | ||
152 | return; | ||
153 | |||
154 | } | ||
155 | |||
156 | #endregion | ||
157 | |||
158 | #region IPresenceService | ||
159 | |||
160 | public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) | ||
161 | { | ||
162 | m_log.Warn("[LOCAL PRESENCE CONNECTOR]: LoginAgent connector not implemented at the simulators"); | ||
163 | return false; | ||
164 | } | ||
165 | |||
166 | public bool LogoutAgent(UUID sessionID) | ||
167 | { | ||
168 | return m_PresenceService.LogoutAgent(sessionID); | ||
169 | } | ||
170 | |||
171 | |||
172 | public bool LogoutRegionAgents(UUID regionID) | ||
173 | { | ||
174 | return m_PresenceService.LogoutRegionAgents(regionID); | ||
175 | } | ||
176 | |||
177 | public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
178 | { | ||
179 | return m_PresenceService.ReportAgent(sessionID, regionID, position, lookAt); | ||
180 | } | ||
181 | |||
182 | public PresenceInfo GetAgent(UUID sessionID) | ||
183 | { | ||
184 | return m_PresenceService.GetAgent(sessionID); | ||
185 | } | ||
186 | |||
187 | public PresenceInfo[] GetAgents(string[] userIDs) | ||
188 | { | ||
189 | return m_PresenceService.GetAgents(userIDs); | ||
190 | } | ||
191 | |||
192 | public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
193 | { | ||
194 | return m_PresenceService.SetHomeLocation(userID, regionID, position, lookAt); | ||
195 | } | ||
196 | |||
197 | #endregion | ||
198 | |||
199 | } | ||
200 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs new file mode 100644 index 0000000..3ca5560 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs | |||
@@ -0,0 +1,84 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | |||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Framework.Scenes; | ||
33 | using OpenSim.Services.Interfaces; | ||
34 | |||
35 | using OpenMetaverse; | ||
36 | using log4net; | ||
37 | |||
38 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | ||
39 | { | ||
40 | public class PresenceDetector | ||
41 | { | ||
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | private IPresenceService m_PresenceService; | ||
45 | |||
46 | public PresenceDetector(IPresenceService presenceservice) | ||
47 | { | ||
48 | m_PresenceService = presenceservice; | ||
49 | } | ||
50 | |||
51 | public void AddRegion(Scene scene) | ||
52 | { | ||
53 | scene.EventManager.OnMakeRootAgent += OnMakeRootAgent; | ||
54 | scene.EventManager.OnNewClient += OnNewClient; | ||
55 | |||
56 | m_PresenceService.LogoutRegionAgents(scene.RegionInfo.RegionID); | ||
57 | } | ||
58 | |||
59 | public void RemoveRegion(Scene scene) | ||
60 | { | ||
61 | scene.EventManager.OnMakeRootAgent -= OnMakeRootAgent; | ||
62 | scene.EventManager.OnNewClient -= OnNewClient; | ||
63 | |||
64 | m_PresenceService.LogoutRegionAgents(scene.RegionInfo.RegionID); | ||
65 | } | ||
66 | |||
67 | public void OnMakeRootAgent(ScenePresence sp) | ||
68 | { | ||
69 | m_log.DebugFormat("[PRESENCE DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName); | ||
70 | m_PresenceService.ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); | ||
71 | } | ||
72 | |||
73 | public void OnNewClient(IClientAPI client) | ||
74 | { | ||
75 | client.OnLogout += OnLogout; | ||
76 | } | ||
77 | |||
78 | public void OnLogout(IClientAPI client) | ||
79 | { | ||
80 | client.OnLogout -= OnLogout; | ||
81 | m_PresenceService.LogoutAgent(client.SessionId); | ||
82 | } | ||
83 | } | ||
84 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs new file mode 100644 index 0000000..e8e140a --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs | |||
@@ -0,0 +1,164 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | |||
31 | using OpenSim.Region.Framework.Interfaces; | ||
32 | using OpenSim.Region.Framework.Scenes; | ||
33 | using OpenSim.Server.Base; | ||
34 | using OpenSim.Services.Interfaces; | ||
35 | using OpenSim.Services.Connectors; | ||
36 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | ||
37 | |||
38 | using OpenMetaverse; | ||
39 | using log4net; | ||
40 | using Nini.Config; | ||
41 | |||
42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | ||
43 | { | ||
44 | public class RemotePresenceServicesConnector : ISharedRegionModule, IPresenceService | ||
45 | { | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | #region ISharedRegionModule | ||
49 | |||
50 | private bool m_Enabled = false; | ||
51 | |||
52 | private PresenceDetector m_PresenceDetector; | ||
53 | private IPresenceService m_RemoteConnector; | ||
54 | |||
55 | public Type ReplaceableInterface | ||
56 | { | ||
57 | get { return null; } | ||
58 | } | ||
59 | |||
60 | public string Name | ||
61 | { | ||
62 | get { return "RemotePresenceServiceConnector"; } | ||
63 | } | ||
64 | |||
65 | public void Initialise(IConfigSource source) | ||
66 | { | ||
67 | IConfig moduleConfig = source.Configs["Modules"]; | ||
68 | if (moduleConfig != null) | ||
69 | { | ||
70 | string name = moduleConfig.GetString("PresenceServices", ""); | ||
71 | if (name == Name) | ||
72 | { | ||
73 | m_RemoteConnector = new PresenceServicesConnector(source); | ||
74 | |||
75 | m_Enabled = true; | ||
76 | |||
77 | m_PresenceDetector = new PresenceDetector(this); | ||
78 | |||
79 | m_log.Info("[INVENTORY CONNECTOR]: Remote presence enabled"); | ||
80 | } | ||
81 | } | ||
82 | |||
83 | } | ||
84 | |||
85 | public void PostInitialise() | ||
86 | { | ||
87 | } | ||
88 | |||
89 | public void Close() | ||
90 | { | ||
91 | } | ||
92 | |||
93 | public void AddRegion(Scene scene) | ||
94 | { | ||
95 | if (!m_Enabled) | ||
96 | return; | ||
97 | |||
98 | scene.RegisterModuleInterface<IPresenceService>(this); | ||
99 | m_PresenceDetector.AddRegion(scene); | ||
100 | |||
101 | m_log.InfoFormat("[REMOTE PRESENCE CONNECTOR]: Enabled remote presence for region {0}", scene.RegionInfo.RegionName); | ||
102 | |||
103 | } | ||
104 | |||
105 | public void RemoveRegion(Scene scene) | ||
106 | { | ||
107 | if (!m_Enabled) | ||
108 | return; | ||
109 | |||
110 | m_PresenceDetector.RemoveRegion(scene); | ||
111 | } | ||
112 | |||
113 | public void RegionLoaded(Scene scene) | ||
114 | { | ||
115 | if (!m_Enabled) | ||
116 | return; | ||
117 | |||
118 | } | ||
119 | |||
120 | #endregion | ||
121 | |||
122 | #region IPresenceService | ||
123 | |||
124 | public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) | ||
125 | { | ||
126 | m_log.Warn("[REMOTE PRESENCE CONNECTOR]: LoginAgent connector not implemented at the simulators"); | ||
127 | return false; | ||
128 | } | ||
129 | |||
130 | public bool LogoutAgent(UUID sessionID) | ||
131 | { | ||
132 | return m_RemoteConnector.LogoutAgent(sessionID); | ||
133 | } | ||
134 | |||
135 | |||
136 | public bool LogoutRegionAgents(UUID regionID) | ||
137 | { | ||
138 | return m_RemoteConnector.LogoutRegionAgents(regionID); | ||
139 | } | ||
140 | |||
141 | public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
142 | { | ||
143 | return m_RemoteConnector.ReportAgent(sessionID, regionID, position, lookAt); | ||
144 | } | ||
145 | |||
146 | public PresenceInfo GetAgent(UUID sessionID) | ||
147 | { | ||
148 | return m_RemoteConnector.GetAgent(sessionID); | ||
149 | } | ||
150 | |||
151 | public PresenceInfo[] GetAgents(string[] userIDs) | ||
152 | { | ||
153 | return m_RemoteConnector.GetAgents(userIDs); | ||
154 | } | ||
155 | |||
156 | public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
157 | { | ||
158 | return m_RemoteConnector.SetHomeLocation(userID, regionID, position, lookAt); | ||
159 | } | ||
160 | |||
161 | #endregion | ||
162 | |||
163 | } | ||
164 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs new file mode 100644 index 0000000..ebb2c3e --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs | |||
@@ -0,0 +1,104 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using log4net.Config; | ||
34 | using NUnit.Framework; | ||
35 | using NUnit.Framework.SyntaxHelpers; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Framework; | ||
38 | using Nini.Config; | ||
39 | |||
40 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | ||
43 | using OpenSim.Tests.Common; | ||
44 | using OpenSim.Tests.Common.Setup; | ||
45 | |||
46 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests | ||
47 | { | ||
48 | [TestFixture] | ||
49 | public class PresenceConnectorsTests | ||
50 | { | ||
51 | LocalPresenceServicesConnector m_LocalConnector; | ||
52 | private void SetUp() | ||
53 | { | ||
54 | IConfigSource config = new IniConfigSource(); | ||
55 | config.AddConfig("Modules"); | ||
56 | config.AddConfig("PresenceService"); | ||
57 | config.Configs["Modules"].Set("PresenceServices", "LocalPresenceServicesConnector"); | ||
58 | config.Configs["PresenceService"].Set("LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService"); | ||
59 | config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullPresenceData"); | ||
60 | |||
61 | m_LocalConnector = new LocalPresenceServicesConnector(config); | ||
62 | } | ||
63 | |||
64 | /// <summary> | ||
65 | /// Test OpenSim Presence. | ||
66 | /// </summary> | ||
67 | [Test] | ||
68 | public void TestPresenceV0_1() | ||
69 | { | ||
70 | SetUp(); | ||
71 | |||
72 | string user1 = UUID.Zero.ToString(); | ||
73 | UUID session1 = UUID.Zero; | ||
74 | |||
75 | // this is not implemented by this connector | ||
76 | //m_LocalConnector.LoginAgent(user1, session1, UUID.Zero); | ||
77 | PresenceInfo result = m_LocalConnector.GetAgent(session1); | ||
78 | Assert.IsNotNull(result, "Retrieved GetAgent is null"); | ||
79 | Assert.That(result.UserID, Is.EqualTo(user1), "Retrieved userID does not match"); | ||
80 | Assert.IsTrue(result.Online, "Agent just logged in but is offline"); | ||
81 | |||
82 | UUID region1 = UUID.Random(); | ||
83 | bool r = m_LocalConnector.ReportAgent(session1, region1, Vector3.Zero, Vector3.Zero); | ||
84 | Assert.IsTrue(r, "First ReportAgent returned false"); | ||
85 | result = m_LocalConnector.GetAgent(session1); | ||
86 | Assert.That(result.RegionID, Is.EqualTo(region1), "Agent is not in the right region (region1)"); | ||
87 | |||
88 | UUID region2 = UUID.Random(); | ||
89 | r = m_LocalConnector.ReportAgent(session1, region2, Vector3.Zero, Vector3.Zero); | ||
90 | Assert.IsTrue(r, "Second ReportAgent returned false"); | ||
91 | result = m_LocalConnector.GetAgent(session1); | ||
92 | Assert.That(result.RegionID, Is.EqualTo(region2), "Agent is not in the right region (region2)"); | ||
93 | |||
94 | r = m_LocalConnector.LogoutAgent(session1); | ||
95 | Assert.IsTrue(r, "LogoutAgent returned false"); | ||
96 | result = m_LocalConnector.GetAgent(session1); | ||
97 | Assert.IsNotNull(result, "Agent session disappeared from storage after logout"); | ||
98 | Assert.IsFalse(result.Online, "Agent is reported to be Online after logout"); | ||
99 | |||
100 | r = m_LocalConnector.ReportAgent(session1, region1, Vector3.Zero, Vector3.Zero); | ||
101 | Assert.IsFalse(r, "ReportAgent of non-logged in user returned true"); | ||
102 | } | ||
103 | } | ||
104 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs new file mode 100644 index 0000000..074bfb5 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs | |||
@@ -0,0 +1,339 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | using log4net; | ||
31 | using Nini.Config; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Region.Framework.Interfaces; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
38 | |||
39 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | ||
40 | { | ||
41 | public class LocalSimulationConnectorModule : ISharedRegionModule, ISimulationService | ||
42 | { | ||
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | private List<Scene> m_sceneList = new List<Scene>(); | ||
45 | |||
46 | private bool m_ModuleEnabled = false; | ||
47 | |||
48 | #region IRegionModule | ||
49 | |||
50 | public void Initialise(IConfigSource config) | ||
51 | { | ||
52 | IConfig moduleConfig = config.Configs["Modules"]; | ||
53 | if (moduleConfig != null) | ||
54 | { | ||
55 | string name = moduleConfig.GetString("SimulationServices", ""); | ||
56 | if (name == Name) | ||
57 | { | ||
58 | //IConfig userConfig = config.Configs["SimulationService"]; | ||
59 | //if (userConfig == null) | ||
60 | //{ | ||
61 | // m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpanSim.ini"); | ||
62 | // return; | ||
63 | //} | ||
64 | |||
65 | m_ModuleEnabled = true; | ||
66 | |||
67 | m_log.Info("[SIMULATION CONNECTOR]: Local simulation enabled"); | ||
68 | } | ||
69 | } | ||
70 | } | ||
71 | |||
72 | public void PostInitialise() | ||
73 | { | ||
74 | } | ||
75 | |||
76 | public void AddRegion(Scene scene) | ||
77 | { | ||
78 | if (!m_ModuleEnabled) | ||
79 | return; | ||
80 | |||
81 | Init(scene); | ||
82 | scene.RegisterModuleInterface<ISimulationService>(this); | ||
83 | } | ||
84 | |||
85 | public void RemoveRegion(Scene scene) | ||
86 | { | ||
87 | if (!m_ModuleEnabled) | ||
88 | return; | ||
89 | |||
90 | RemoveScene(scene); | ||
91 | scene.UnregisterModuleInterface<ISimulationService>(this); | ||
92 | } | ||
93 | |||
94 | public void RegionLoaded(Scene scene) | ||
95 | { | ||
96 | } | ||
97 | |||
98 | public void Close() | ||
99 | { | ||
100 | } | ||
101 | |||
102 | public Type ReplaceableInterface | ||
103 | { | ||
104 | get { return null; } | ||
105 | } | ||
106 | |||
107 | public string Name | ||
108 | { | ||
109 | get { return "LocalSimulationConnectorModule"; } | ||
110 | } | ||
111 | |||
112 | /// <summary> | ||
113 | /// Can be called from other modules. | ||
114 | /// </summary> | ||
115 | /// <param name="scene"></param> | ||
116 | public void RemoveScene(Scene scene) | ||
117 | { | ||
118 | lock (m_sceneList) | ||
119 | { | ||
120 | if (m_sceneList.Contains(scene)) | ||
121 | { | ||
122 | m_sceneList.Remove(scene); | ||
123 | } | ||
124 | } | ||
125 | } | ||
126 | |||
127 | /// <summary> | ||
128 | /// Can be called from other modules. | ||
129 | /// </summary> | ||
130 | /// <param name="scene"></param> | ||
131 | public void Init(Scene scene) | ||
132 | { | ||
133 | if (!m_sceneList.Contains(scene)) | ||
134 | { | ||
135 | lock (m_sceneList) | ||
136 | { | ||
137 | m_sceneList.Add(scene); | ||
138 | } | ||
139 | |||
140 | } | ||
141 | } | ||
142 | |||
143 | #endregion /* IRegionModule */ | ||
144 | |||
145 | #region ISimulation | ||
146 | |||
147 | public IScene GetScene(ulong regionhandle) | ||
148 | { | ||
149 | foreach (Scene s in m_sceneList) | ||
150 | { | ||
151 | if (s.RegionInfo.RegionHandle == regionhandle) | ||
152 | return s; | ||
153 | } | ||
154 | // ? weird. should not happen | ||
155 | return m_sceneList[0]; | ||
156 | } | ||
157 | |||
158 | /** | ||
159 | * Agent-related communications | ||
160 | */ | ||
161 | |||
162 | public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason) | ||
163 | { | ||
164 | if (destination == null) | ||
165 | { | ||
166 | reason = "Given destination was null"; | ||
167 | m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: CreateAgent was given a null destination"); | ||
168 | return false; | ||
169 | } | ||
170 | |||
171 | foreach (Scene s in m_sceneList) | ||
172 | { | ||
173 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
174 | { | ||
175 | // m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle); | ||
176 | return s.NewUserConnection(aCircuit, teleportFlags, out reason); | ||
177 | } | ||
178 | } | ||
179 | |||
180 | // m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle); | ||
181 | reason = "Did not find region " + destination.RegionName; | ||
182 | return false; | ||
183 | } | ||
184 | |||
185 | public bool UpdateAgent(GridRegion destination, AgentData cAgentData) | ||
186 | { | ||
187 | if (destination == null) | ||
188 | return false; | ||
189 | |||
190 | foreach (Scene s in m_sceneList) | ||
191 | { | ||
192 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
193 | { | ||
194 | //m_log.DebugFormat( | ||
195 | // "[LOCAL COMMS]: Found region {0} {1} to send ChildAgentUpdate", | ||
196 | // s.RegionInfo.RegionName, regionHandle); | ||
197 | |||
198 | s.IncomingChildAgentDataUpdate(cAgentData); | ||
199 | return true; | ||
200 | } | ||
201 | } | ||
202 | |||
203 | // m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for ChildAgentUpdate", regionHandle); | ||
204 | return false; | ||
205 | } | ||
206 | |||
207 | public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData) | ||
208 | { | ||
209 | if (destination == null) | ||
210 | return false; | ||
211 | |||
212 | foreach (Scene s in m_sceneList) | ||
213 | { | ||
214 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
215 | { | ||
216 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); | ||
217 | s.IncomingChildAgentDataUpdate(cAgentData); | ||
218 | return true; | ||
219 | } | ||
220 | } | ||
221 | //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); | ||
222 | return false; | ||
223 | } | ||
224 | |||
225 | public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) | ||
226 | { | ||
227 | agent = null; | ||
228 | |||
229 | if (destination == null) | ||
230 | return false; | ||
231 | |||
232 | foreach (Scene s in m_sceneList) | ||
233 | { | ||
234 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
235 | { | ||
236 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); | ||
237 | return s.IncomingRetrieveRootAgent(id, out agent); | ||
238 | } | ||
239 | } | ||
240 | //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); | ||
241 | return false; | ||
242 | } | ||
243 | |||
244 | public bool ReleaseAgent(GridRegion destination, UUID id, string uri) | ||
245 | { | ||
246 | if (destination == null) | ||
247 | return false; | ||
248 | |||
249 | foreach (Scene s in m_sceneList) | ||
250 | { | ||
251 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
252 | { | ||
253 | //m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); | ||
254 | return s.IncomingReleaseAgent(id); | ||
255 | } | ||
256 | } | ||
257 | //m_log.Debug("[LOCAL COMMS]: region not found in SendReleaseAgent"); | ||
258 | return false; | ||
259 | } | ||
260 | |||
261 | public bool CloseAgent(GridRegion destination, UUID id) | ||
262 | { | ||
263 | if (destination == null) | ||
264 | return false; | ||
265 | |||
266 | foreach (Scene s in m_sceneList) | ||
267 | { | ||
268 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
269 | { | ||
270 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent"); | ||
271 | return s.IncomingCloseAgent(id); | ||
272 | } | ||
273 | } | ||
274 | //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent"); | ||
275 | return false; | ||
276 | } | ||
277 | |||
278 | /** | ||
279 | * Object-related communications | ||
280 | */ | ||
281 | |||
282 | public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) | ||
283 | { | ||
284 | if (destination == null) | ||
285 | return false; | ||
286 | |||
287 | foreach (Scene s in m_sceneList) | ||
288 | { | ||
289 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
290 | { | ||
291 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); | ||
292 | if (isLocalCall) | ||
293 | { | ||
294 | // We need to make a local copy of the object | ||
295 | ISceneObject sogClone = sog.CloneForNewScene(); | ||
296 | sogClone.SetState(sog.GetStateSnapshot(), s); | ||
297 | return s.IncomingCreateObject(sogClone); | ||
298 | } | ||
299 | else | ||
300 | { | ||
301 | // Use the object as it came through the wire | ||
302 | return s.IncomingCreateObject(sog); | ||
303 | } | ||
304 | } | ||
305 | } | ||
306 | return false; | ||
307 | } | ||
308 | |||
309 | public bool CreateObject(GridRegion destination, UUID userID, UUID itemID) | ||
310 | { | ||
311 | if (destination == null) | ||
312 | return false; | ||
313 | |||
314 | foreach (Scene s in m_sceneList) | ||
315 | { | ||
316 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | ||
317 | { | ||
318 | return s.IncomingCreateObject(userID, itemID); | ||
319 | } | ||
320 | } | ||
321 | return false; | ||
322 | } | ||
323 | |||
324 | |||
325 | #endregion /* IInterregionComms */ | ||
326 | |||
327 | #region Misc | ||
328 | |||
329 | public bool IsLocalRegion(ulong regionhandle) | ||
330 | { | ||
331 | foreach (Scene s in m_sceneList) | ||
332 | if (s.RegionInfo.RegionHandle == regionhandle) | ||
333 | return true; | ||
334 | return false; | ||
335 | } | ||
336 | |||
337 | #endregion | ||
338 | } | ||
339 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs new file mode 100644 index 0000000..c9cc368 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs | |||
@@ -0,0 +1,360 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.IO; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Text; | ||
34 | using log4net; | ||
35 | using Nini.Config; | ||
36 | using OpenMetaverse; | ||
37 | using OpenMetaverse.StructuredData; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Framework.Communications; | ||
40 | using OpenSim.Framework.Communications.Clients; | ||
41 | using OpenSim.Region.Framework.Interfaces; | ||
42 | using OpenSim.Region.Framework.Scenes; | ||
43 | using OpenSim.Region.Framework.Scenes.Hypergrid; | ||
44 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
45 | using OpenSim.Services.Interfaces; | ||
46 | using OpenSim.Services.Connectors.Simulation; | ||
47 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
48 | |||
49 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | ||
50 | { | ||
51 | public class RemoteSimulationConnectorModule : ISharedRegionModule, ISimulationService | ||
52 | { | ||
53 | private bool initialized = false; | ||
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
55 | |||
56 | protected bool m_enabled = false; | ||
57 | protected Scene m_aScene; | ||
58 | // RemoteSimulationConnector does not care about local regions; it delegates that to the Local module | ||
59 | protected LocalSimulationConnectorModule m_localBackend; | ||
60 | protected SimulationServiceConnector m_remoteConnector; | ||
61 | |||
62 | protected CommunicationsManager m_commsManager; | ||
63 | |||
64 | protected IHyperlinkService m_hyperlinkService; | ||
65 | |||
66 | protected bool m_safemode; | ||
67 | protected IPAddress m_thisIP; | ||
68 | |||
69 | #region IRegionModule | ||
70 | |||
71 | public virtual void Initialise(IConfigSource config) | ||
72 | { | ||
73 | |||
74 | IConfig moduleConfig = config.Configs["Modules"]; | ||
75 | if (moduleConfig != null) | ||
76 | { | ||
77 | string name = moduleConfig.GetString("SimulationServices", ""); | ||
78 | if (name == Name) | ||
79 | { | ||
80 | //IConfig userConfig = config.Configs["SimulationService"]; | ||
81 | //if (userConfig == null) | ||
82 | //{ | ||
83 | // m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpanSim.ini"); | ||
84 | // return; | ||
85 | //} | ||
86 | |||
87 | m_remoteConnector = new SimulationServiceConnector(); | ||
88 | |||
89 | m_enabled = true; | ||
90 | |||
91 | m_log.Info("[SIMULATION CONNECTOR]: Remote simulation enabled"); | ||
92 | } | ||
93 | } | ||
94 | } | ||
95 | |||
96 | public virtual void PostInitialise() | ||
97 | { | ||
98 | } | ||
99 | |||
100 | public virtual void Close() | ||
101 | { | ||
102 | } | ||
103 | |||
104 | public void AddRegion(Scene scene) | ||
105 | { | ||
106 | if (!m_enabled) | ||
107 | return; | ||
108 | |||
109 | if (!initialized) | ||
110 | { | ||
111 | InitOnce(scene); | ||
112 | initialized = true; | ||
113 | } | ||
114 | InitEach(scene); | ||
115 | } | ||
116 | |||
117 | public void RemoveRegion(Scene scene) | ||
118 | { | ||
119 | if (m_enabled) | ||
120 | { | ||
121 | m_localBackend.RemoveScene(scene); | ||
122 | scene.UnregisterModuleInterface<ISimulationService>(this); | ||
123 | } | ||
124 | } | ||
125 | |||
126 | public void RegionLoaded(Scene scene) | ||
127 | { | ||
128 | if (!m_enabled) | ||
129 | return; | ||
130 | |||
131 | m_hyperlinkService = m_aScene.RequestModuleInterface<IHyperlinkService>(); | ||
132 | |||
133 | } | ||
134 | |||
135 | public Type ReplaceableInterface | ||
136 | { | ||
137 | get { return null; } | ||
138 | } | ||
139 | |||
140 | public virtual string Name | ||
141 | { | ||
142 | get { return "RemoteSimulationConnectorModule"; } | ||
143 | } | ||
144 | |||
145 | protected virtual void InitEach(Scene scene) | ||
146 | { | ||
147 | m_localBackend.Init(scene); | ||
148 | scene.RegisterModuleInterface<ISimulationService>(this); | ||
149 | } | ||
150 | |||
151 | protected virtual void InitOnce(Scene scene) | ||
152 | { | ||
153 | m_localBackend = new LocalSimulationConnectorModule(); | ||
154 | m_commsManager = scene.CommsManager; | ||
155 | m_aScene = scene; | ||
156 | //m_regionClient = new RegionToRegionClient(m_aScene, m_hyperlinkService); | ||
157 | m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName); | ||
158 | } | ||
159 | |||
160 | #endregion /* IRegionModule */ | ||
161 | |||
162 | #region IInterregionComms | ||
163 | |||
164 | public IScene GetScene(ulong handle) | ||
165 | { | ||
166 | return m_localBackend.GetScene(handle); | ||
167 | } | ||
168 | |||
169 | /** | ||
170 | * Agent-related communications | ||
171 | */ | ||
172 | |||
173 | public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason) | ||
174 | { | ||
175 | if (destination == null) | ||
176 | { | ||
177 | reason = "Given destination was null"; | ||
178 | m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CreateAgent was given a null destination"); | ||
179 | return false; | ||
180 | } | ||
181 | |||
182 | // Try local first | ||
183 | if (m_localBackend.CreateAgent(destination, aCircuit, teleportFlags, out reason)) | ||
184 | return true; | ||
185 | |||
186 | // else do the remote thing | ||
187 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
188 | { | ||
189 | //m_regionClient.SendUserInformation(regInfo, aCircuit); | ||
190 | return m_remoteConnector.CreateAgent(destination, aCircuit, teleportFlags, out reason); | ||
191 | } | ||
192 | return false; | ||
193 | } | ||
194 | |||
195 | public bool UpdateAgent(GridRegion destination, AgentData cAgentData) | ||
196 | { | ||
197 | if (destination == null) | ||
198 | return false; | ||
199 | |||
200 | // Try local first | ||
201 | if (m_localBackend.UpdateAgent(destination, cAgentData)) | ||
202 | return true; | ||
203 | |||
204 | // else do the remote thing | ||
205 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
206 | return m_remoteConnector.UpdateAgent(destination, cAgentData); | ||
207 | |||
208 | return false; | ||
209 | |||
210 | } | ||
211 | |||
212 | public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData) | ||
213 | { | ||
214 | if (destination == null) | ||
215 | return false; | ||
216 | |||
217 | // Try local first | ||
218 | if (m_localBackend.UpdateAgent(destination, cAgentData)) | ||
219 | return true; | ||
220 | |||
221 | // else do the remote thing | ||
222 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
223 | return m_remoteConnector.UpdateAgent(destination, cAgentData); | ||
224 | |||
225 | return false; | ||
226 | |||
227 | } | ||
228 | |||
229 | public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) | ||
230 | { | ||
231 | agent = null; | ||
232 | |||
233 | if (destination == null) | ||
234 | return false; | ||
235 | |||
236 | // Try local first | ||
237 | if (m_localBackend.RetrieveAgent(destination, id, out agent)) | ||
238 | return true; | ||
239 | |||
240 | // else do the remote thing | ||
241 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
242 | return m_remoteConnector.RetrieveAgent(destination, id, out agent); | ||
243 | |||
244 | return false; | ||
245 | |||
246 | } | ||
247 | |||
248 | public bool ReleaseAgent(GridRegion destination, UUID id, string uri) | ||
249 | { | ||
250 | if (destination == null) | ||
251 | return false; | ||
252 | |||
253 | // Try local first | ||
254 | if (m_localBackend.ReleaseAgent(destination, id, uri)) | ||
255 | return true; | ||
256 | |||
257 | // else do the remote thing | ||
258 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
259 | return m_remoteConnector.ReleaseAgent(destination, id, uri); | ||
260 | |||
261 | return false; | ||
262 | } | ||
263 | |||
264 | |||
265 | public bool CloseAgent(GridRegion destination, UUID id) | ||
266 | { | ||
267 | if (destination == null) | ||
268 | return false; | ||
269 | |||
270 | // Try local first | ||
271 | if (m_localBackend.CloseAgent(destination, id)) | ||
272 | return true; | ||
273 | |||
274 | // else do the remote thing | ||
275 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
276 | return m_remoteConnector.CloseAgent(destination, id); | ||
277 | |||
278 | return false; | ||
279 | } | ||
280 | |||
281 | /** | ||
282 | * Object-related communications | ||
283 | */ | ||
284 | |||
285 | public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) | ||
286 | { | ||
287 | if (destination == null) | ||
288 | return false; | ||
289 | |||
290 | // Try local first | ||
291 | if (m_localBackend.CreateObject(destination, sog, true)) | ||
292 | { | ||
293 | //m_log.Debug("[REST COMMS]: LocalBackEnd SendCreateObject succeeded"); | ||
294 | return true; | ||
295 | } | ||
296 | |||
297 | // else do the remote thing | ||
298 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
299 | return m_remoteConnector.CreateObject(destination, sog, isLocalCall); | ||
300 | |||
301 | return false; | ||
302 | } | ||
303 | |||
304 | public bool CreateObject(GridRegion destination, UUID userID, UUID itemID) | ||
305 | { | ||
306 | // Not Implemented | ||
307 | return false; | ||
308 | } | ||
309 | |||
310 | #endregion /* IInterregionComms */ | ||
311 | |||
312 | |||
313 | protected class RegionToRegionClient : RegionClient | ||
314 | { | ||
315 | Scene m_aScene = null; | ||
316 | IHyperlinkService m_hyperlinkService; | ||
317 | |||
318 | public RegionToRegionClient(Scene s, IHyperlinkService hyperService) | ||
319 | { | ||
320 | m_aScene = s; | ||
321 | m_hyperlinkService = hyperService; | ||
322 | } | ||
323 | |||
324 | public override ulong GetRegionHandle(ulong handle) | ||
325 | { | ||
326 | if (m_aScene.SceneGridService is HGSceneCommunicationService) | ||
327 | { | ||
328 | if (m_hyperlinkService != null) | ||
329 | return m_hyperlinkService.FindRegionHandle(handle); | ||
330 | } | ||
331 | |||
332 | return handle; | ||
333 | } | ||
334 | |||
335 | public override bool IsHyperlink(ulong handle) | ||
336 | { | ||
337 | if (m_aScene.SceneGridService is HGSceneCommunicationService) | ||
338 | { | ||
339 | if ((m_hyperlinkService != null) && (m_hyperlinkService.GetHyperlinkRegion(handle) != null)) | ||
340 | return true; | ||
341 | } | ||
342 | return false; | ||
343 | } | ||
344 | |||
345 | public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit) | ||
346 | { | ||
347 | if (m_hyperlinkService != null) | ||
348 | m_hyperlinkService.SendUserInformation(regInfo, aCircuit); | ||
349 | |||
350 | } | ||
351 | |||
352 | public override void AdjustUserInformation(AgentCircuitData aCircuit) | ||
353 | { | ||
354 | if (m_hyperlinkService != null) | ||
355 | m_hyperlinkService.AdjustUserInformation(aCircuit); | ||
356 | } | ||
357 | } | ||
358 | |||
359 | } | ||
360 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs index cca5bb4..f55de5a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | using log4net; | 31 | using log4net; |
31 | using Nini.Config; | 32 | using Nini.Config; |
@@ -34,9 +35,11 @@ using OpenSim.Region.Framework.Scenes; | |||
34 | using OpenSim.Server.Base; | 35 | using OpenSim.Server.Base; |
35 | using OpenSim.Services.Interfaces; | 36 | using OpenSim.Services.Interfaces; |
36 | 37 | ||
37 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | 38 | using OpenMetaverse; |
39 | |||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | ||
38 | { | 41 | { |
39 | public class LocalUserServicesConnector : ISharedRegionModule | 42 | public class LocalUserAccountServicesConnector : ISharedRegionModule, IUserAccountService |
40 | { | 43 | { |
41 | private static readonly ILog m_log = | 44 | private static readonly ILog m_log = |
42 | LogManager.GetLogger( | 45 | LogManager.GetLogger( |
@@ -46,6 +49,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
46 | 49 | ||
47 | private bool m_Enabled = false; | 50 | private bool m_Enabled = false; |
48 | 51 | ||
52 | #region ISharedRegionModule | ||
53 | |||
49 | public Type ReplaceableInterface | 54 | public Type ReplaceableInterface |
50 | { | 55 | { |
51 | get { return null; } | 56 | get { return null; } |
@@ -53,7 +58,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
53 | 58 | ||
54 | public string Name | 59 | public string Name |
55 | { | 60 | { |
56 | get { return "LocalUserServicesConnector"; } | 61 | get { return "LocalUserAccountServicesConnector"; } |
57 | } | 62 | } |
58 | 63 | ||
59 | public void Initialise(IConfigSource source) | 64 | public void Initialise(IConfigSource source) |
@@ -61,13 +66,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
61 | IConfig moduleConfig = source.Configs["Modules"]; | 66 | IConfig moduleConfig = source.Configs["Modules"]; |
62 | if (moduleConfig != null) | 67 | if (moduleConfig != null) |
63 | { | 68 | { |
64 | string name = moduleConfig.GetString("UserServices", ""); | 69 | string name = moduleConfig.GetString("UserAccountServices", ""); |
65 | if (name == Name) | 70 | if (name == Name) |
66 | { | 71 | { |
67 | IConfig userConfig = source.Configs["UserService"]; | 72 | IConfig userConfig = source.Configs["UserAccountService"]; |
68 | if (userConfig == null) | 73 | if (userConfig == null) |
69 | { | 74 | { |
70 | m_log.Error("[USER CONNECTOR]: UserService missing from OpenSim.ini"); | 75 | m_log.Error("[USER CONNECTOR]: UserAccountService missing from OpenSim.ini"); |
71 | return; | 76 | return; |
72 | } | 77 | } |
73 | 78 | ||
@@ -87,7 +92,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
87 | 92 | ||
88 | if (m_UserService == null) | 93 | if (m_UserService == null) |
89 | { | 94 | { |
90 | m_log.Error("[USER CONNECTOR]: Can't load user service"); | 95 | m_log.Error("[USER CONNECTOR]: Can't load user account service"); |
91 | return; | 96 | return; |
92 | } | 97 | } |
93 | m_Enabled = true; | 98 | m_Enabled = true; |
@@ -127,5 +132,39 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
127 | if (!m_Enabled) | 132 | if (!m_Enabled) |
128 | return; | 133 | return; |
129 | } | 134 | } |
135 | |||
136 | #endregion | ||
137 | |||
138 | #region IUserAccountService | ||
139 | |||
140 | public UserAccount GetUserAccount(UUID scopeID, UUID userID) | ||
141 | { | ||
142 | return m_UserService.GetUserAccount(scopeID, userID); | ||
143 | } | ||
144 | |||
145 | public UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName) | ||
146 | { | ||
147 | return m_UserService.GetUserAccount(scopeID, FirstName, LastName); | ||
148 | } | ||
149 | |||
150 | public UserAccount GetUserAccount(UUID scopeID, string Email) | ||
151 | { | ||
152 | return m_UserService.GetUserAccount(scopeID, Email); | ||
153 | } | ||
154 | |||
155 | public List<UserAccount> GetUserAccounts(UUID scopeID, string query) | ||
156 | { | ||
157 | return m_UserService.GetUserAccounts(scopeID, query); | ||
158 | } | ||
159 | |||
160 | // Update all updatable fields | ||
161 | // | ||
162 | public bool StoreUserAccount(UserAccount data) | ||
163 | { | ||
164 | return m_UserService.StoreUserAccount(data); | ||
165 | } | ||
166 | |||
167 | #endregion | ||
168 | |||
130 | } | 169 | } |
131 | } | 170 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs index cef9129..7d61b20 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs | |||
@@ -34,9 +34,9 @@ using OpenSim.Region.Framework.Scenes; | |||
34 | using OpenSim.Services.Interfaces; | 34 | using OpenSim.Services.Interfaces; |
35 | using OpenSim.Services.Connectors; | 35 | using OpenSim.Services.Connectors; |
36 | 36 | ||
37 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | 37 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts |
38 | { | 38 | { |
39 | public class RemoteUserServicesConnector : UserServicesConnector, | 39 | public class RemoteUserAccountServicesConnector : UserAccountServicesConnector, |
40 | ISharedRegionModule, IUserAccountService | 40 | ISharedRegionModule, IUserAccountService |
41 | { | 41 | { |
42 | private static readonly ILog m_log = | 42 | private static readonly ILog m_log = |
@@ -52,7 +52,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
52 | 52 | ||
53 | public string Name | 53 | public string Name |
54 | { | 54 | { |
55 | get { return "RemoteUserServicesConnector"; } | 55 | get { return "RemoteUserAccountServicesConnector"; } |
56 | } | 56 | } |
57 | 57 | ||
58 | public override void Initialise(IConfigSource source) | 58 | public override void Initialise(IConfigSource source) |
@@ -60,13 +60,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
60 | IConfig moduleConfig = source.Configs["Modules"]; | 60 | IConfig moduleConfig = source.Configs["Modules"]; |
61 | if (moduleConfig != null) | 61 | if (moduleConfig != null) |
62 | { | 62 | { |
63 | string name = moduleConfig.GetString("UserServices", ""); | 63 | string name = moduleConfig.GetString("UserAccountServices", ""); |
64 | if (name == Name) | 64 | if (name == Name) |
65 | { | 65 | { |
66 | IConfig userConfig = source.Configs["UserService"]; | 66 | IConfig userConfig = source.Configs["UserAccountService"]; |
67 | if (userConfig == null) | 67 | if (userConfig == null) |
68 | { | 68 | { |
69 | m_log.Error("[USER CONNECTOR]: UserService missing from OpanSim.ini"); | 69 | m_log.Error("[USER CONNECTOR]: UserAccountService missing from OpanSim.ini"); |
70 | return; | 70 | return; |
71 | } | 71 | } |
72 | 72 | ||
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index e837e9a..ae3dc2e 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | |||
@@ -95,6 +95,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
95 | 95 | ||
96 | protected Scene m_scene; | 96 | protected Scene m_scene; |
97 | 97 | ||
98 | private InventoryFolderImpl m_libraryRootFolder; | ||
99 | protected InventoryFolderImpl LibraryRootFolder | ||
100 | { | ||
101 | get | ||
102 | { | ||
103 | if (m_libraryRootFolder != null) | ||
104 | return m_libraryRootFolder; | ||
105 | |||
106 | ILibraryService lib = m_scene.RequestModuleInterface<ILibraryService>(); | ||
107 | if (lib != null) | ||
108 | { | ||
109 | m_libraryRootFolder = lib.LibraryRootFolder; | ||
110 | } | ||
111 | return m_libraryRootFolder; | ||
112 | } | ||
113 | } | ||
114 | |||
98 | #region Constants | 115 | #region Constants |
99 | // These are here for testing. They will be taken out | 116 | // These are here for testing. They will be taken out |
100 | 117 | ||
@@ -1005,9 +1022,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1005 | IInventoryService invService = m_scene.InventoryService; | 1022 | IInventoryService invService = m_scene.InventoryService; |
1006 | InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user); | 1023 | InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user); |
1007 | assetRequestItem = invService.GetItem(assetRequestItem); | 1024 | assetRequestItem = invService.GetItem(assetRequestItem); |
1008 | if (assetRequestItem == null) // Library item | 1025 | if (assetRequestItem == null && LibraryRootFolder != null) // Library item |
1009 | { | 1026 | { |
1010 | assetRequestItem = scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard); | 1027 | assetRequestItem = LibraryRootFolder.FindItem(notecard); |
1011 | 1028 | ||
1012 | if (assetRequestItem != null) // Implicitly readable | 1029 | if (assetRequestItem != null) // Implicitly readable |
1013 | return true; | 1030 | return true; |
@@ -1425,9 +1442,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1425 | IInventoryService invService = m_scene.InventoryService; | 1442 | IInventoryService invService = m_scene.InventoryService; |
1426 | InventoryItemBase assetRequestItem = new InventoryItemBase(script, user); | 1443 | InventoryItemBase assetRequestItem = new InventoryItemBase(script, user); |
1427 | assetRequestItem = invService.GetItem(assetRequestItem); | 1444 | assetRequestItem = invService.GetItem(assetRequestItem); |
1428 | if (assetRequestItem == null) // Library item | 1445 | if (assetRequestItem == null && LibraryRootFolder != null) // Library item |
1429 | { | 1446 | { |
1430 | assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(script); | 1447 | assetRequestItem = LibraryRootFolder.FindItem(script); |
1431 | 1448 | ||
1432 | if (assetRequestItem != null) // Implicitly readable | 1449 | if (assetRequestItem != null) // Implicitly readable |
1433 | return true; | 1450 | return true; |
@@ -1520,9 +1537,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1520 | IInventoryService invService = m_scene.InventoryService; | 1537 | IInventoryService invService = m_scene.InventoryService; |
1521 | InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user); | 1538 | InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user); |
1522 | assetRequestItem = invService.GetItem(assetRequestItem); | 1539 | assetRequestItem = invService.GetItem(assetRequestItem); |
1523 | if (assetRequestItem == null) // Library item | 1540 | if (assetRequestItem == null && LibraryRootFolder != null) // Library item |
1524 | { | 1541 | { |
1525 | assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard); | 1542 | assetRequestItem = LibraryRootFolder.FindItem(notecard); |
1526 | 1543 | ||
1527 | if (assetRequestItem != null) // Implicitly readable | 1544 | if (assetRequestItem != null) // Implicitly readable |
1528 | return true; | 1545 | return true; |
diff --git a/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs b/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs index 630c6a3..d44c1e1 100644 --- a/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs | |||
@@ -31,13 +31,13 @@ namespace OpenSim.Region.Framework.Interfaces | |||
31 | { | 31 | { |
32 | public struct PresenceInfo | 32 | public struct PresenceInfo |
33 | { | 33 | { |
34 | public UUID userID; | 34 | public string UserID; |
35 | public UUID regionID; | 35 | public UUID RegionID; |
36 | 36 | ||
37 | public PresenceInfo(UUID userID, UUID regionID) | 37 | public PresenceInfo(string userID, UUID regionID) |
38 | { | 38 | { |
39 | this.userID = userID; | 39 | UserID = userID; |
40 | this.regionID = regionID; | 40 | RegionID = regionID; |
41 | } | 41 | } |
42 | } | 42 | } |
43 | 43 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 3044017..a14c853 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -573,7 +573,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
573 | "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}", | 573 | "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}", |
574 | remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName); | 574 | remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName); |
575 | 575 | ||
576 | InventoryItemBase item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(oldItemID); | 576 | InventoryItemBase item = null; |
577 | if (LibraryService != null && LibraryService.LibraryRootFolder != null) | ||
578 | item = LibraryService.LibraryRootFolder.FindItem(oldItemID); | ||
577 | 579 | ||
578 | if (item == null) | 580 | if (item == null) |
579 | { | 581 | { |
@@ -1211,9 +1213,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1211 | item = InventoryService.GetItem(item); | 1213 | item = InventoryService.GetItem(item); |
1212 | 1214 | ||
1213 | // Try library | 1215 | // Try library |
1214 | if (null == item) | 1216 | if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) |
1215 | { | 1217 | { |
1216 | item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); | 1218 | item = LibraryService.LibraryRootFolder.FindItem(itemID); |
1217 | } | 1219 | } |
1218 | 1220 | ||
1219 | if (item != null) | 1221 | if (item != null) |
@@ -1280,9 +1282,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1280 | 1282 | ||
1281 | // Try library | 1283 | // Try library |
1282 | // XXX clumsy, possibly should be one call | 1284 | // XXX clumsy, possibly should be one call |
1283 | if (null == item) | 1285 | if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) |
1284 | { | 1286 | { |
1285 | item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); | 1287 | item = LibraryService.LibraryRootFolder.FindItem(itemID); |
1286 | } | 1288 | } |
1287 | 1289 | ||
1288 | if (item != null) | 1290 | if (item != null) |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 47fbeb4..022d79d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | |||
@@ -424,7 +424,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
424 | /// <param name="ownerID"></param> | 424 | /// <param name="ownerID"></param> |
425 | public void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID) | 425 | public void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID) |
426 | { | 426 | { |
427 | if (ownerID == CommsManager.UserProfileCacheService.LibraryRoot.Owner) | 427 | if (LibraryService != null && LibraryService.LibraryRootFolder != null && ownerID == LibraryService.LibraryRootFolder.Owner) |
428 | { | 428 | { |
429 | //m_log.Debug("request info for library item"); | 429 | //m_log.Debug("request info for library item"); |
430 | return; | 430 | return; |
@@ -458,13 +458,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
458 | // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. | 458 | // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. |
459 | // can be handled transparently). | 459 | // can be handled transparently). |
460 | InventoryFolderImpl fold = null; | 460 | InventoryFolderImpl fold = null; |
461 | if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null) | 461 | if (LibraryService != null && LibraryService.LibraryRootFolder != null) |
462 | { | 462 | if ((fold = LibraryService.LibraryRootFolder.FindFolder(folderID)) != null) |
463 | remoteClient.SendInventoryFolderDetails( | 463 | { |
464 | fold.Owner, folderID, fold.RequestListOfItems(), | 464 | remoteClient.SendInventoryFolderDetails( |
465 | fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems); | 465 | fold.Owner, folderID, fold.RequestListOfItems(), |
466 | return; | 466 | fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems); |
467 | } | 467 | return; |
468 | } | ||
468 | 469 | ||
469 | // We're going to send the reply async, because there may be | 470 | // We're going to send the reply async, because there may be |
470 | // an enormous quantity of packets -- basically the entire inventory! | 471 | // an enormous quantity of packets -- basically the entire inventory! |
@@ -512,15 +513,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
512 | // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. | 513 | // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. |
513 | // can be handled transparently). | 514 | // can be handled transparently). |
514 | InventoryFolderImpl fold; | 515 | InventoryFolderImpl fold; |
515 | if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null) | 516 | if (LibraryService != null && LibraryService.LibraryRootFolder != null) |
516 | { | 517 | if ((fold = LibraryService.LibraryRootFolder.FindFolder(folderID)) != null) |
517 | version = 0; | 518 | { |
518 | InventoryCollection ret = new InventoryCollection(); | 519 | version = 0; |
519 | ret.Folders = new List<InventoryFolderBase>(); | 520 | InventoryCollection ret = new InventoryCollection(); |
520 | ret.Items = fold.RequestListOfItems(); | 521 | ret.Folders = new List<InventoryFolderBase>(); |
522 | ret.Items = fold.RequestListOfItems(); | ||
521 | 523 | ||
522 | return ret; | 524 | return ret; |
523 | } | 525 | } |
524 | 526 | ||
525 | InventoryCollection contents = new InventoryCollection(); | 527 | InventoryCollection contents = new InventoryCollection(); |
526 | 528 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 764ac60..20c0622 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -240,6 +240,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
240 | } | 240 | } |
241 | } | 241 | } |
242 | 242 | ||
243 | protected ILibraryService m_LibraryService; | ||
244 | |||
245 | public ILibraryService LibraryService | ||
246 | { | ||
247 | get | ||
248 | { | ||
249 | if (m_LibraryService == null) | ||
250 | m_LibraryService = RequestModuleInterface<ILibraryService>(); | ||
251 | |||
252 | return m_LibraryService; | ||
253 | } | ||
254 | } | ||
255 | |||
243 | protected IXMLRPC m_xmlrpcModule; | 256 | protected IXMLRPC m_xmlrpcModule; |
244 | protected IWorldComm m_worldCommModule; | 257 | protected IWorldComm m_worldCommModule; |
245 | protected IAvatarFactory m_AvatarFactory; | 258 | protected IAvatarFactory m_AvatarFactory; |
@@ -3483,10 +3496,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
3483 | { | 3496 | { |
3484 | reason = String.Empty; | 3497 | reason = String.Empty; |
3485 | 3498 | ||
3486 | bool result = CommsManager.UserService.VerifySession(agent.AgentID, agent.SessionID); | 3499 | IAuthenticationService auth = RequestModuleInterface<IAuthenticationService>(); |
3487 | m_log.Debug("[CONNECTION BEGIN]: User authentication returned " + result); | 3500 | if (auth == null) |
3501 | { | ||
3502 | reason = String.Format("Failed to authenticate user {0} {1} in region {2}. Authentication service does not exist.", agent.firstname, agent.lastname, RegionInfo.RegionName); | ||
3503 | return false; | ||
3504 | } | ||
3505 | |||
3506 | bool result = auth.Verify(agent.AgentID, agent.SecureSessionID.ToString(), 30); | ||
3507 | |||
3508 | m_log.Debug("[CONNECTION BEGIN]: Session authentication returned " + result); | ||
3488 | if (!result) | 3509 | if (!result) |
3489 | reason = String.Format("Failed to authenticate user {0} {1}, access denied.", agent.firstname, agent.lastname); | 3510 | reason = String.Format("Failed to authenticate user {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName); |
3490 | 3511 | ||
3491 | return result; | 3512 | return result; |
3492 | } | 3513 | } |
@@ -4889,5 +4910,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
4889 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4910 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) |
4890 | StartTimer(); | 4911 | StartTimer(); |
4891 | } | 4912 | } |
4913 | |||
4914 | public override ISceneObject DeserializeObject(string representation) | ||
4915 | { | ||
4916 | return SceneObjectSerializer.FromXml2Format(representation); | ||
4917 | } | ||
4918 | |||
4919 | public override bool AllowScriptCrossings | ||
4920 | { | ||
4921 | get { return m_allowScriptCrossings; } | ||
4922 | } | ||
4892 | } | 4923 | } |
4893 | } | 4924 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index 1547f9a..19eea1e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs | |||
@@ -510,5 +510,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
510 | 510 | ||
511 | MainConsole.Instance.Commands.AddCommand(modulename, shared, command, shorthelp, longhelp, callback); | 511 | MainConsole.Instance.Commands.AddCommand(modulename, shared, command, shorthelp, longhelp, callback); |
512 | } | 512 | } |
513 | |||
514 | public virtual ISceneObject DeserializeObject(string representation) | ||
515 | { | ||
516 | return null; | ||
517 | } | ||
518 | |||
519 | public virtual bool AllowScriptCrossings | ||
520 | { | ||
521 | get { return false; } | ||
522 | } | ||
523 | |||
513 | } | 524 | } |
514 | } | 525 | } |