opensim – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 eva 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.Linq;
31 using System.Reflection;
32 using System.Text;
33  
34 using OpenSim.Framework;
35 using OpenSim.Framework.Servers;
36 using OpenSim.Region.Framework.Scenes;
37 using OpenSim.Region.Framework.Interfaces;
38 using OpenSim.Services.Interfaces;
39  
40 using OpenMetaverse;
41 using Mono.Addins;
42 using log4net;
43 using Nini.Config;
44  
45 namespace OpenSim.Groups
46 {
47 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GroupsServiceHGConnectorModule")]
48 public class GroupsServiceHGConnectorModule : ISharedRegionModule, IGroupsServicesConnector
49 {
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51  
52 private bool m_Enabled = false;
53 private IGroupsServicesConnector m_LocalGroupsConnector;
54 private string m_LocalGroupsServiceLocation;
55 private IUserManagement m_UserManagement;
56 private IOfflineIMService m_OfflineIM;
57 private IMessageTransferModule m_Messaging;
58 private List<Scene> m_Scenes;
59 private ForeignImporter m_ForeignImporter;
60 private string m_ServiceLocation;
61 private IConfigSource m_Config;
62  
63 private Dictionary<string, GroupsServiceHGConnector> m_NetworkConnectors = new Dictionary<string, GroupsServiceHGConnector>();
64 private RemoteConnectorCacheWrapper m_CacheWrapper; // for caching info of external group services
65  
66 #region ISharedRegionModule
67  
68 public void Initialise(IConfigSource config)
69 {
70 IConfig groupsConfig = config.Configs["Groups"];
71 if (groupsConfig == null)
72 return;
73  
74 if ((groupsConfig.GetBoolean("Enabled", false) == false)
75 || (groupsConfig.GetString("ServicesConnectorModule", string.Empty) != Name))
76 {
77 return;
78 }
79  
80 m_Config = config;
81 m_ServiceLocation = groupsConfig.GetString("LocalService", "local"); // local or remote
82 m_LocalGroupsServiceLocation = groupsConfig.GetString("GroupsExternalURI", "http://127.0.0.1");
83 m_Scenes = new List<Scene>();
84  
85 m_Enabled = true;
86  
87 m_log.DebugFormat("[Groups]: Initializing {0} with LocalService {1}", this.Name, m_ServiceLocation);
88 }
89  
90 public string Name
91 {
92 get { return "Groups HG Service Connector"; }
93 }
94  
95 public Type ReplaceableInterface
96 {
97 get { return null; }
98 }
99  
100 public void AddRegion(Scene scene)
101 {
102 if (!m_Enabled)
103 return;
104  
105 m_log.DebugFormat("[Groups]: Registering {0} with {1}", this.Name, scene.RegionInfo.RegionName);
106 scene.RegisterModuleInterface<IGroupsServicesConnector>(this);
107 m_Scenes.Add(scene);
108  
109 scene.EventManager.OnNewClient += OnNewClient;
110 }
111  
112 public void RemoveRegion(Scene scene)
113 {
114 if (!m_Enabled)
115 return;
116  
117 scene.UnregisterModuleInterface<IGroupsServicesConnector>(this);
118 m_Scenes.Remove(scene);
119 }
120  
121 public void RegionLoaded(Scene scene)
122 {
123 if (!m_Enabled)
124 return;
125  
126 if (m_UserManagement == null)
127 {
128 m_UserManagement = scene.RequestModuleInterface<IUserManagement>();
129 m_OfflineIM = scene.RequestModuleInterface<IOfflineIMService>();
130 m_Messaging = scene.RequestModuleInterface<IMessageTransferModule>();
131 m_ForeignImporter = new ForeignImporter(m_UserManagement);
132  
133 if (m_ServiceLocation.Equals("local"))
134 {
135 m_LocalGroupsConnector = new GroupsServiceLocalConnectorModule(m_Config, m_UserManagement);
136 // Also, if local, create the endpoint for the HGGroupsService
137 new HGGroupsServiceRobustConnector(m_Config, MainServer.Instance, string.Empty,
138 scene.RequestModuleInterface<IOfflineIMService>(), scene.RequestModuleInterface<IUserAccountService>());
139  
140 }
141 else
142 m_LocalGroupsConnector = new GroupsServiceRemoteConnectorModule(m_Config, m_UserManagement);
143  
144 m_CacheWrapper = new RemoteConnectorCacheWrapper(m_UserManagement);
145 }
146  
147 }
148  
149 public void PostInitialise()
150 {
151 }
152  
153 public void Close()
154 {
155 }
156  
157 #endregion
158  
159 private void OnNewClient(IClientAPI client)
160 {
161 client.OnCompleteMovementToRegion += OnCompleteMovementToRegion;
162 }
163  
164 void OnCompleteMovementToRegion(IClientAPI client, bool arg2)
165 {
166 object sp = null;
167 if (client.Scene.TryGetScenePresence(client.AgentId, out sp))
168 {
169 if (sp is ScenePresence && ((ScenePresence)sp).PresenceType != PresenceType.Npc)
170 {
171 AgentCircuitData aCircuit = ((ScenePresence)sp).Scene.AuthenticateHandler.GetAgentCircuitData(client.AgentId);
172 if (aCircuit != null && (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 &&
173 m_OfflineIM != null && m_Messaging != null)
174 {
175 List<GridInstantMessage> ims = m_OfflineIM.GetMessages(aCircuit.AgentID);
176 if (ims != null && ims.Count > 0)
177 foreach (GridInstantMessage im in ims)
178 m_Messaging.SendInstantMessage(im, delegate(bool success) { });
179 }
180 }
181 }
182 }
183  
184 #region IGroupsServicesConnector
185  
186 public UUID CreateGroup(UUID RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment,
187 bool allowPublish, bool maturePublish, UUID founderID, out string reason)
188 {
189 reason = string.Empty;
190 if (m_UserManagement.IsLocalGridUser(RequestingAgentID))
191 return m_LocalGroupsConnector.CreateGroup(RequestingAgentID, name, charter, showInList, insigniaID,
192 membershipFee, openEnrollment, allowPublish, maturePublish, founderID, out reason);
193 else
194 {
195 reason = "Only local grid users are allowed to create a new group";
196 return UUID.Zero;
197 }
198 }
199  
200 public bool UpdateGroup(string RequestingAgentID, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee,
201 bool openEnrollment, bool allowPublish, bool maturePublish, out string reason)
202 {
203 reason = string.Empty;
204 string url = string.Empty;
205 string name = string.Empty;
206 if (IsLocal(groupID, out url, out name))
207 return m_LocalGroupsConnector.UpdateGroup(AgentUUI(RequestingAgentID), groupID, charter, showInList, insigniaID, membershipFee,
208 openEnrollment, allowPublish, maturePublish, out reason);
209 else
210 {
211 reason = "Changes to remote group not allowed. Please go to the group's original world.";
212 return false;
213 }
214 }
215  
216 public ExtendedGroupRecord GetGroupRecord(string RequestingAgentID, UUID GroupID, string GroupName)
217 {
218 string url = string.Empty;
219 string name = string.Empty;
220 if (IsLocal(GroupID, out url, out name))
221 return m_LocalGroupsConnector.GetGroupRecord(AgentUUI(RequestingAgentID), GroupID, GroupName);
222 else if (url != string.Empty)
223 {
224 ExtendedGroupMembershipData membership = m_LocalGroupsConnector.GetAgentGroupMembership(RequestingAgentID, RequestingAgentID, GroupID);
225 string accessToken = string.Empty;
226 if (membership != null)
227 accessToken = membership.AccessToken;
228 else
229 return null;
230  
231 GroupsServiceHGConnector c = GetConnector(url);
232 if (c != null)
233 {
234 ExtendedGroupRecord grec = m_CacheWrapper.GetGroupRecord(RequestingAgentID, GroupID, GroupName, delegate
235 {
236 return c.GetGroupRecord(AgentUUIForOutside(RequestingAgentID), GroupID, GroupName, accessToken);
237 });
238  
239 if (grec != null)
240 ImportForeigner(grec.FounderUUI);
241 return grec;
242 }
243 }
244  
245 return null;
246 }
247  
248 public List<DirGroupsReplyData> FindGroups(string RequestingAgentID, string search)
249 {
250 return m_LocalGroupsConnector.FindGroups(AgentUUI(RequestingAgentID), search);
251 }
252  
253 public List<GroupMembersData> GetGroupMembers(string RequestingAgentID, UUID GroupID)
254 {
255 string url = string.Empty, gname = string.Empty;
256 if (IsLocal(GroupID, out url, out gname))
257 {
258 string agentID = AgentUUI(RequestingAgentID);
259 return m_LocalGroupsConnector.GetGroupMembers(agentID, GroupID);
260 }
261 else if (!string.IsNullOrEmpty(url))
262 {
263 ExtendedGroupMembershipData membership = m_LocalGroupsConnector.GetAgentGroupMembership(RequestingAgentID, RequestingAgentID, GroupID);
264 string accessToken = string.Empty;
265 if (membership != null)
266 accessToken = membership.AccessToken;
267 else
268 return null;
269  
270 GroupsServiceHGConnector c = GetConnector(url);
271 if (c != null)
272 {
273 return m_CacheWrapper.GetGroupMembers(RequestingAgentID, GroupID, delegate
274 {
275 return c.GetGroupMembers(AgentUUIForOutside(RequestingAgentID), GroupID, accessToken);
276 });
277  
278 }
279 }
280 return new List<GroupMembersData>();
281 }
282  
283 public bool AddGroupRole(string RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers, out string reason)
284 {
285 reason = string.Empty;
286 string url = string.Empty, gname = string.Empty;
287  
288 if (IsLocal(groupID, out url, out gname))
289 return m_LocalGroupsConnector.AddGroupRole(AgentUUI(RequestingAgentID), groupID, roleID, name, description, title, powers, out reason);
290 else
291 {
292 reason = "Operation not allowed outside this group's origin world.";
293 return false;
294 }
295 }
296  
297 public bool UpdateGroupRole(string RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers)
298 {
299 string url = string.Empty, gname = string.Empty;
300  
301 if (IsLocal(groupID, out url, out gname))
302 return m_LocalGroupsConnector.UpdateGroupRole(AgentUUI(RequestingAgentID), groupID, roleID, name, description, title, powers);
303 else
304 {
305 return false;
306 }
307  
308 }
309  
310 public void RemoveGroupRole(string RequestingAgentID, UUID groupID, UUID roleID)
311 {
312 string url = string.Empty, gname = string.Empty;
313  
314 if (IsLocal(groupID, out url, out gname))
315 m_LocalGroupsConnector.RemoveGroupRole(AgentUUI(RequestingAgentID), groupID, roleID);
316 else
317 {
318 return;
319 }
320 }
321  
322 public List<GroupRolesData> GetGroupRoles(string RequestingAgentID, UUID groupID)
323 {
324 string url = string.Empty, gname = string.Empty;
325  
326 if (IsLocal(groupID, out url, out gname))
327 return m_LocalGroupsConnector.GetGroupRoles(AgentUUI(RequestingAgentID), groupID);
328 else if (!string.IsNullOrEmpty(url))
329 {
330 ExtendedGroupMembershipData membership = m_LocalGroupsConnector.GetAgentGroupMembership(RequestingAgentID, RequestingAgentID, groupID);
331 string accessToken = string.Empty;
332 if (membership != null)
333 accessToken = membership.AccessToken;
334 else
335 return null;
336  
337 GroupsServiceHGConnector c = GetConnector(url);
338 if (c != null)
339 {
340 return m_CacheWrapper.GetGroupRoles(RequestingAgentID, groupID, delegate
341 {
342 return c.GetGroupRoles(AgentUUIForOutside(RequestingAgentID), groupID, accessToken);
343 });
344  
345 }
346 }
347  
348 return new List<GroupRolesData>();
349 }
350  
351 public List<GroupRoleMembersData> GetGroupRoleMembers(string RequestingAgentID, UUID groupID)
352 {
353 string url = string.Empty, gname = string.Empty;
354  
355 if (IsLocal(groupID, out url, out gname))
356 return m_LocalGroupsConnector.GetGroupRoleMembers(AgentUUI(RequestingAgentID), groupID);
357 else if (!string.IsNullOrEmpty(url))
358 {
359 ExtendedGroupMembershipData membership = m_LocalGroupsConnector.GetAgentGroupMembership(RequestingAgentID, RequestingAgentID, groupID);
360 string accessToken = string.Empty;
361 if (membership != null)
362 accessToken = membership.AccessToken;
363 else
364 return null;
365  
366 GroupsServiceHGConnector c = GetConnector(url);
367 if (c != null)
368 {
369 return m_CacheWrapper.GetGroupRoleMembers(RequestingAgentID, groupID, delegate
370 {
371 return c.GetGroupRoleMembers(AgentUUIForOutside(RequestingAgentID), groupID, accessToken);
372 });
373  
374 }
375 }
376  
377 return new List<GroupRoleMembersData>();
378 }
379  
380 public bool AddAgentToGroup(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID, string token, out string reason)
381 {
382 string url = string.Empty;
383 string name = string.Empty;
384 reason = string.Empty;
385  
386 UUID uid = new UUID(AgentID);
387 if (IsLocal(GroupID, out url, out name))
388 {
389 if (m_UserManagement.IsLocalGridUser(uid)) // local user
390 {
391 // normal case: local group, local user
392 return m_LocalGroupsConnector.AddAgentToGroup(AgentUUI(RequestingAgentID), AgentUUI(AgentID), GroupID, RoleID, token, out reason);
393 }
394 else // local group, foreign user
395 {
396 // the user is accepting the invitation, or joining, where the group resides
397 token = UUID.Random().ToString();
398 bool success = m_LocalGroupsConnector.AddAgentToGroup(AgentUUI(RequestingAgentID), AgentUUI(AgentID), GroupID, RoleID, token, out reason);
399  
400 if (success)
401 {
402 // Here we always return true. The user has been added to the local group,
403 // independent of whether the remote operation succeeds or not
404 url = m_UserManagement.GetUserServerURL(uid, "GroupsServerURI");
405 if (url == string.Empty)
406 {
407 reason = "You don't have an accessible groups server in your home world. You membership to this group in only within this grid.";
408 return true;
409 }
410  
411 GroupsServiceHGConnector c = GetConnector(url);
412 if (c != null)
413 c.CreateProxy(AgentUUI(RequestingAgentID), AgentID, token, GroupID, m_LocalGroupsServiceLocation, name, out reason);
414 return true;
415 }
416 return false;
417 }
418 }
419 else if (m_UserManagement.IsLocalGridUser(uid)) // local user
420 {
421 // foreign group, local user. She's been added already by the HG service.
422 // Let's just check
423 if (m_LocalGroupsConnector.GetAgentGroupMembership(AgentUUI(RequestingAgentID), AgentUUI(AgentID), GroupID) != null)
424 return true;
425 }
426  
427 reason = "Operation not allowed outside this group's origin world";
428 return false;
429 }
430  
431  
432 public void RemoveAgentFromGroup(string RequestingAgentID, string AgentID, UUID GroupID)
433 {
434 string url = string.Empty, name = string.Empty;
435 if (!IsLocal(GroupID, out url, out name) && url != string.Empty)
436 {
437 ExtendedGroupMembershipData membership = m_LocalGroupsConnector.GetAgentGroupMembership(AgentUUI(RequestingAgentID), AgentUUI(AgentID), GroupID);
438 if (membership != null)
439 {
440 GroupsServiceHGConnector c = GetConnector(url);
441 if (c != null)
442 c.RemoveAgentFromGroup(AgentUUIForOutside(AgentID), GroupID, membership.AccessToken);
443 }
444 }
445  
446 // remove from local service
447 m_LocalGroupsConnector.RemoveAgentFromGroup(AgentUUI(RequestingAgentID), AgentUUI(AgentID), GroupID);
448 }
449  
450 public bool AddAgentToGroupInvite(string RequestingAgentID, UUID inviteID, UUID groupID, UUID roleID, string agentID)
451 {
452 string url = string.Empty, gname = string.Empty;
453  
454 if (IsLocal(groupID, out url, out gname))
455 return m_LocalGroupsConnector.AddAgentToGroupInvite(AgentUUI(RequestingAgentID), inviteID, groupID, roleID, AgentUUI(agentID));
456 else
457 return false;
458 }
459  
460 public GroupInviteInfo GetAgentToGroupInvite(string RequestingAgentID, UUID inviteID)
461 {
462 return m_LocalGroupsConnector.GetAgentToGroupInvite(AgentUUI(RequestingAgentID), inviteID); ;
463 }
464  
465 public void RemoveAgentToGroupInvite(string RequestingAgentID, UUID inviteID)
466 {
467 m_LocalGroupsConnector.RemoveAgentToGroupInvite(AgentUUI(RequestingAgentID), inviteID);
468 }
469  
470 public void AddAgentToGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID)
471 {
472 string url = string.Empty, gname = string.Empty;
473  
474 if (IsLocal(GroupID, out url, out gname))
475 m_LocalGroupsConnector.AddAgentToGroupRole(AgentUUI(RequestingAgentID), AgentUUI(AgentID), GroupID, RoleID);
476  
477 }
478  
479 public void RemoveAgentFromGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID)
480 {
481 string url = string.Empty, gname = string.Empty;
482  
483 if (IsLocal(GroupID, out url, out gname))
484 m_LocalGroupsConnector.RemoveAgentFromGroupRole(AgentUUI(RequestingAgentID), AgentUUI(AgentID), GroupID, RoleID);
485 }
486  
487 public List<GroupRolesData> GetAgentGroupRoles(string RequestingAgentID, string AgentID, UUID GroupID)
488 {
489 string url = string.Empty, gname = string.Empty;
490  
491 if (IsLocal(GroupID, out url, out gname))
492 return m_LocalGroupsConnector.GetAgentGroupRoles(AgentUUI(RequestingAgentID), AgentUUI(AgentID), GroupID);
493 else
494 return new List<GroupRolesData>();
495 }
496  
497 public void SetAgentActiveGroup(string RequestingAgentID, string AgentID, UUID GroupID)
498 {
499 string url = string.Empty, gname = string.Empty;
500  
501 if (IsLocal(GroupID, out url, out gname))
502 m_LocalGroupsConnector.SetAgentActiveGroup(AgentUUI(RequestingAgentID), AgentUUI(AgentID), GroupID);
503 }
504  
505 public ExtendedGroupMembershipData GetAgentActiveMembership(string RequestingAgentID, string AgentID)
506 {
507 return m_LocalGroupsConnector.GetAgentActiveMembership(AgentUUI(RequestingAgentID), AgentUUI(AgentID));
508 }
509  
510 public void SetAgentActiveGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID)
511 {
512 string url = string.Empty, gname = string.Empty;
513  
514 if (IsLocal(GroupID, out url, out gname))
515 m_LocalGroupsConnector.SetAgentActiveGroupRole(AgentUUI(RequestingAgentID), AgentUUI(AgentID), GroupID, RoleID);
516 }
517  
518 public void UpdateMembership(string RequestingAgentID, string AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile)
519 {
520 m_LocalGroupsConnector.UpdateMembership(AgentUUI(RequestingAgentID), AgentUUI(AgentID), GroupID, AcceptNotices, ListInProfile);
521 }
522  
523 public ExtendedGroupMembershipData GetAgentGroupMembership(string RequestingAgentID, string AgentID, UUID GroupID)
524 {
525 string url = string.Empty, gname = string.Empty;
526  
527 if (IsLocal(GroupID, out url, out gname))
528 return m_LocalGroupsConnector.GetAgentGroupMembership(AgentUUI(RequestingAgentID), AgentUUI(AgentID), GroupID);
529 else
530 return null;
531 }
532  
533 public List<GroupMembershipData> GetAgentGroupMemberships(string RequestingAgentID, string AgentID)
534 {
535 return m_LocalGroupsConnector.GetAgentGroupMemberships(AgentUUI(RequestingAgentID), AgentUUI(AgentID));
536 }
537  
538 public bool AddGroupNotice(string RequestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message,
539 bool hasAttachment, byte attType, string attName, UUID attItemID, string attOwnerID)
540 {
541 string url = string.Empty, gname = string.Empty;
542  
543 if (IsLocal(groupID, out url, out gname))
544 {
545 if (m_LocalGroupsConnector.AddGroupNotice(AgentUUI(RequestingAgentID), groupID, noticeID, fromName, subject, message,
546 hasAttachment, attType, attName, attItemID, AgentUUI(attOwnerID)))
547 {
548 // then send the notice to every grid for which there are members in this group
549 List<GroupMembersData> members = m_LocalGroupsConnector.GetGroupMembers(AgentUUI(RequestingAgentID), groupID);
550 List<string> urls = new List<string>();
551 foreach (GroupMembersData m in members)
552 {
553 if (!m_UserManagement.IsLocalGridUser(m.AgentID))
554 {
555 string gURL = m_UserManagement.GetUserServerURL(m.AgentID, "GroupsServerURI");
556 if (!urls.Contains(gURL))
557 urls.Add(gURL);
558 }
559 }
560  
561 // so we have the list of urls to send the notice to
562 // this may take a long time...
563 Util.FireAndForget(delegate
564 {
565 foreach (string u in urls)
566 {
567 GroupsServiceHGConnector c = GetConnector(u);
568 if (c != null)
569 {
570 c.AddNotice(AgentUUIForOutside(RequestingAgentID), groupID, noticeID, fromName, subject, message,
571 hasAttachment, attType, attName, attItemID, AgentUUIForOutside(attOwnerID));
572 }
573 }
574 });
575  
576 return true;
577 }
578  
579 return false;
580 }
581 else
582 return false;
583 }
584  
585 public GroupNoticeInfo GetGroupNotice(string RequestingAgentID, UUID noticeID)
586 {
587 GroupNoticeInfo notice = m_LocalGroupsConnector.GetGroupNotice(AgentUUI(RequestingAgentID), noticeID);
588  
589 if (notice != null && notice.noticeData.HasAttachment && notice.noticeData.AttachmentOwnerID != null)
590 ImportForeigner(notice.noticeData.AttachmentOwnerID);
591  
592 return notice;
593 }
594  
595 public List<ExtendedGroupNoticeData> GetGroupNotices(string RequestingAgentID, UUID GroupID)
596 {
597 return m_LocalGroupsConnector.GetGroupNotices(AgentUUI(RequestingAgentID), GroupID);
598 }
599  
600 #endregion
601  
602 #region hypergrid groups
603  
604 private string AgentUUI(string AgentIDStr)
605 {
606 UUID AgentID = UUID.Zero;
607 try
608 {
609 AgentID = new UUID(AgentIDStr);
610 }
611 catch (FormatException)
612 {
613 return AgentID.ToString();
614 }
615  
616 if (m_UserManagement.IsLocalGridUser(AgentID))
617 return AgentID.ToString();
618  
619 AgentCircuitData agent = null;
620 foreach (Scene scene in m_Scenes)
621 {
622 agent = scene.AuthenticateHandler.GetAgentCircuitData(AgentID);
623 if (agent != null)
624 break;
625 }
626 if (agent != null)
627 return Util.ProduceUserUniversalIdentifier(agent);
628  
629 // we don't know anything about this foreign user
630 // try asking the user management module, which may know more
631 return m_UserManagement.GetUserUUI(AgentID);
632  
633 }
634  
635 private string AgentUUIForOutside(string AgentIDStr)
636 {
637 UUID AgentID = UUID.Zero;
638 try
639 {
640 AgentID = new UUID(AgentIDStr);
641 }
642 catch (FormatException)
643 {
644 return AgentID.ToString();
645 }
646  
647 AgentCircuitData agent = null;
648 foreach (Scene scene in m_Scenes)
649 {
650 agent = scene.AuthenticateHandler.GetAgentCircuitData(AgentID);
651 if (agent != null)
652 break;
653 }
654 if (agent == null) // oops
655 return AgentID.ToString();
656  
657 return Util.ProduceUserUniversalIdentifier(agent);
658 }
659  
660 private UUID ImportForeigner(string uID)
661 {
662 UUID userID = UUID.Zero;
663 string url = string.Empty, first = string.Empty, last = string.Empty, tmp = string.Empty;
664 if (Util.ParseUniversalUserIdentifier(uID, out userID, out url, out first, out last, out tmp))
665 m_UserManagement.AddUser(userID, first, last, url);
666  
667 return userID;
668 }
669  
670 private bool IsLocal(UUID groupID, out string serviceLocation, out string name)
671 {
672 serviceLocation = string.Empty;
673 name = string.Empty;
674 if (groupID.Equals(UUID.Zero))
675 return true;
676  
677 ExtendedGroupRecord group = m_LocalGroupsConnector.GetGroupRecord(UUID.Zero.ToString(), groupID, string.Empty);
678 if (group == null)
679 {
680 //m_log.DebugFormat("[XXX]: IsLocal? group {0} not found -- no.", groupID);
681 return false;
682 }
683  
684 serviceLocation = group.ServiceLocation;
685 name = group.GroupName;
686 bool isLocal = (group.ServiceLocation == string.Empty);
687 //m_log.DebugFormat("[XXX]: IsLocal? {0}", isLocal);
688 return isLocal;
689 }
690  
691 private GroupsServiceHGConnector GetConnector(string url)
692 {
693 lock (m_NetworkConnectors)
694 {
695 if (m_NetworkConnectors.ContainsKey(url))
696 return m_NetworkConnectors[url];
697  
698 GroupsServiceHGConnector c = new GroupsServiceHGConnector(url);
699 m_NetworkConnectors[url] = c;
700 }
701  
702 return m_NetworkConnectors[url];
703 }
704 #endregion
705 }
706 }