GroupsModule.cs 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697
  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 System.Timers;
  31. using log4net;
  32. using Mono.Addins;
  33. using Nini.Config;
  34. using OpenMetaverse;
  35. using OpenMetaverse.StructuredData;
  36. using OpenSim.Framework;
  37. using OpenSim.Region.Framework.Interfaces;
  38. using OpenSim.Region.Framework.Scenes;
  39. using OpenSim.Services.Interfaces;
  40. using System.Text;
  41. using PermissionMask = OpenSim.Framework.PermissionMask;
  42. namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
  43. {
  44. [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GroupsModule")]
  45. public class GroupsModule : ISharedRegionModule, IGroupsModule
  46. {
  47. /// <summary>
  48. /// ; To use this module, you must specify the following in your OpenSim.ini
  49. /// [GROUPS]
  50. /// Enabled = true
  51. ///
  52. /// Module = GroupsModule
  53. /// NoticesEnabled = true
  54. /// DebugEnabled = true
  55. ///
  56. /// GroupsServicesConnectorModule = XmlRpcGroupsServicesConnector
  57. /// XmlRpcServiceURL = http://osflotsam.org/xmlrpc.php
  58. /// XmlRpcServiceReadKey = 1234
  59. /// XmlRpcServiceWriteKey = 1234
  60. ///
  61. /// MessagingModule = GroupsMessagingModule
  62. /// MessagingEnabled = true
  63. ///
  64. /// ; Disables HTTP Keep-Alive for Groups Module HTTP Requests, work around for
  65. /// ; a problem discovered on some Windows based region servers. Only disable
  66. /// ; if you see a large number (dozens) of the following Exceptions:
  67. /// ; System.Net.WebException: The request was aborted: The request was canceled.
  68. ///
  69. /// XmlRpcDisableKeepAlive = false
  70. /// </summary>
  71. private static readonly ILog m_log =
  72. LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  73. private List<Scene> m_sceneList = new List<Scene>();
  74. private IMessageTransferModule m_msgTransferModule;
  75. private IGroupsMessagingModule m_groupsMessagingModule;
  76. private IGroupsServicesConnector m_groupData;
  77. // Configuration settings
  78. private bool m_groupsEnabled = false;
  79. private bool m_groupNoticesEnabled = true;
  80. private bool m_debugEnabled = false;
  81. private int m_levelGroupCreate = 0;
  82. #region Region Module interfaceBase Members
  83. public void Initialise(IConfigSource config)
  84. {
  85. IConfig groupsConfig = config.Configs["Groups"];
  86. if (groupsConfig == null)
  87. {
  88. // Do not run this module by default.
  89. return;
  90. }
  91. else
  92. {
  93. m_groupsEnabled = groupsConfig.GetBoolean("Enabled", false);
  94. if (!m_groupsEnabled)
  95. return;
  96. if (groupsConfig.GetString("Module", "Default") != Name)
  97. {
  98. m_groupsEnabled = false;
  99. return;
  100. }
  101. m_log.InfoFormat("[xmlGROUPS]: Initializing {0}", this.Name);
  102. m_groupNoticesEnabled = groupsConfig.GetBoolean("NoticesEnabled", true);
  103. m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", false);
  104. m_levelGroupCreate = groupsConfig.GetInt("LevelGroupCreate", 0);
  105. }
  106. }
  107. public void AddRegion(Scene scene)
  108. {
  109. if (m_groupsEnabled)
  110. {
  111. scene.RegisterModuleInterface<IGroupsModule>(this);
  112. scene.AddCommand(
  113. "Debug",
  114. this,
  115. "debug groups verbose",
  116. "debug groups verbose <true|false>",
  117. "This setting turns on very verbose groups debugging",
  118. HandleDebugGroupsVerbose);
  119. }
  120. }
  121. private void HandleDebugGroupsVerbose(object modules, string[] args)
  122. {
  123. if (args.Length < 4)
  124. {
  125. MainConsole.Instance.Output("Usage: debug groups verbose <true|false>");
  126. return;
  127. }
  128. bool verbose = false;
  129. if (!bool.TryParse(args[3], out verbose))
  130. {
  131. MainConsole.Instance.Output("Usage: debug groups verbose <true|false>");
  132. return;
  133. }
  134. m_debugEnabled = verbose;
  135. MainConsole.Instance.Output("{0} verbose logging set to {1}", Name, m_debugEnabled);
  136. }
  137. public void RegionLoaded(Scene scene)
  138. {
  139. if (!m_groupsEnabled)
  140. return;
  141. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  142. if (m_groupData == null)
  143. {
  144. m_groupData = scene.RequestModuleInterface<IGroupsServicesConnector>();
  145. // No Groups Service Connector, then nothing works...
  146. if (m_groupData == null)
  147. {
  148. m_groupsEnabled = false;
  149. m_log.Error("[GROUPS]: Could not get IGroupsServicesConnector");
  150. Close();
  151. return;
  152. }
  153. }
  154. if (m_msgTransferModule == null)
  155. {
  156. m_msgTransferModule = scene.RequestModuleInterface<IMessageTransferModule>();
  157. // No message transfer module, no notices, group invites, rejects, ejects, etc
  158. if (m_msgTransferModule == null)
  159. {
  160. m_groupsEnabled = false;
  161. m_log.Warn("[GROUPS]: Could not get IMessageTransferModule");
  162. }
  163. }
  164. if (m_groupsMessagingModule == null)
  165. {
  166. m_groupsMessagingModule = scene.RequestModuleInterface<IGroupsMessagingModule>();
  167. // No message transfer module, no notices, group invites, rejects, ejects, etc
  168. if (m_groupsMessagingModule == null)
  169. m_log.Warn("[GROUPS]: Could not get IGroupsMessagingModule");
  170. }
  171. lock (m_sceneList)
  172. {
  173. m_sceneList.Add(scene);
  174. }
  175. scene.EventManager.OnNewClient += OnNewClient;
  176. scene.EventManager.OnMakeRootAgent += OnMakeRoot;
  177. scene.EventManager.OnMakeChildAgent += OnMakeChild;
  178. scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
  179. scene.EventManager.OnClientClosed += OnClientClosed;
  180. }
  181. public void RemoveRegion(Scene scene)
  182. {
  183. if (!m_groupsEnabled)
  184. return;
  185. if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  186. scene.EventManager.OnNewClient -= OnNewClient;
  187. scene.EventManager.OnMakeRootAgent -= OnMakeRoot;
  188. scene.EventManager.OnMakeChildAgent -= OnMakeChild;
  189. scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage;
  190. scene.EventManager.OnClientClosed -= OnClientClosed;
  191. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  192. lock (m_sceneList)
  193. {
  194. m_sceneList.Remove(scene);
  195. }
  196. }
  197. public void Close()
  198. {
  199. if (!m_groupsEnabled)
  200. return;
  201. if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module.");
  202. }
  203. public Type ReplaceableInterface
  204. {
  205. get { return null; }
  206. }
  207. public string Name
  208. {
  209. get { return "GroupsModule"; }
  210. }
  211. #endregion
  212. #region ISharedRegionModule Members
  213. public void PostInitialise()
  214. {
  215. // NoOp
  216. }
  217. #endregion
  218. #region EventHandlers
  219. private void OnMakeRoot(ScenePresence sp)
  220. {
  221. if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  222. sp.ControllingClient.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest;
  223. // Used for Notices and Group Invites/Accept/Reject
  224. sp.ControllingClient.OnInstantMessage += OnInstantMessage;
  225. // comented out because some viewers no longer suport it
  226. // sp.ControllingClient.AddGenericPacketHandler("avatargroupsrequest", AvatarGroupsRequest);
  227. // Send out group data update for compatibility.
  228. // There might be some problem with the thread we're generating this on but not
  229. // doing the update at this time causes problems (Mantis #7920 and #7915)
  230. // TODO: move sending this update to a later time in the rootification of the client.
  231. if(!sp.m_haveGroupInformation)
  232. SendAgentGroupDataUpdate(sp.ControllingClient, false);
  233. }
  234. private void OnMakeChild(ScenePresence sp)
  235. {
  236. if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  237. sp.ControllingClient.OnUUIDGroupNameRequest -= HandleUUIDGroupNameRequest;
  238. sp.ControllingClient.OnInstantMessage -= OnInstantMessage;
  239. }
  240. private void OnNewClient(IClientAPI client)
  241. {
  242. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  243. client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest;
  244. client.OnRequestAvatarProperties += OnRequestAvatarProperties;
  245. }
  246. /* this should be the right message to ask for other avatars groups
  247. private void AvatarGroupsRequest(Object sender, string method, List<String> args)
  248. {
  249. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  250. if (!(sender is IClientAPI))
  251. return;
  252. IClientAPI remoteClient = (IClientAPI)sender;
  253. UUID avatarID;
  254. UUID.TryParse(args[0], out avatarID);
  255. if (avatarID != UUID.Zero)
  256. {
  257. GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID);
  258. remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups);
  259. }
  260. }
  261. */
  262. // this should not be used to send groups memberships, but some viewers do expect it
  263. // it does send unnecessary memberships, when viewers just want other properties information
  264. private void OnRequestAvatarProperties(IClientAPI remoteClient, UUID avatarID)
  265. {
  266. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  267. GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID);
  268. remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups);
  269. }
  270. private void OnClientClosed(UUID AgentId, Scene scene)
  271. {
  272. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  273. if (scene == null)
  274. return;
  275. ScenePresence sp = scene.GetScenePresence(AgentId);
  276. IClientAPI client = sp.ControllingClient;
  277. if (client != null)
  278. {
  279. client.OnAgentDataUpdateRequest -= OnAgentDataUpdateRequest;
  280. client.OnRequestAvatarProperties -= OnRequestAvatarProperties;
  281. // make child possible not called?
  282. client.OnUUIDGroupNameRequest -= HandleUUIDGroupNameRequest;
  283. client.OnInstantMessage -= OnInstantMessage;
  284. }
  285. /*
  286. lock (m_ActiveClients)
  287. {
  288. if (m_ActiveClients.ContainsKey(AgentId))
  289. {
  290. IClientAPI client = m_ActiveClients[AgentId];
  291. client.OnUUIDGroupNameRequest -= HandleUUIDGroupNameRequest;
  292. client.OnAgentDataUpdateRequest -= OnAgentDataUpdateRequest;
  293. client.OnDirFindQuery -= OnDirFindQuery;
  294. client.OnInstantMessage -= OnInstantMessage;
  295. m_ActiveClients.Remove(AgentId);
  296. }
  297. else
  298. {
  299. if (m_debugEnabled) m_log.WarnFormat("[GROUPS]: Client closed that wasn't registered here.");
  300. }
  301. }
  302. */
  303. }
  304. private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID)
  305. {
  306. // this a private message for own agent only
  307. if (dataForAgentID != GetRequestingAgentID(remoteClient))
  308. return;
  309. SendAgentGroupDataUpdate(remoteClient, false);
  310. // its a info request not a change, so nothing is sent to others
  311. // they do get the group title with the avatar object update on arrivel to a region
  312. }
  313. private void HandleUUIDGroupNameRequest(UUID GroupID, IClientAPI remoteClient)
  314. {
  315. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  316. string GroupName;
  317. GroupRecord group = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), GroupID, null);
  318. if (group != null)
  319. {
  320. GroupName = group.GroupName;
  321. }
  322. else
  323. {
  324. GroupName = "Unknown";
  325. }
  326. remoteClient.SendGroupNameReply(GroupID, GroupName);
  327. }
  328. private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im)
  329. {
  330. if (m_debugEnabled)
  331. m_log.DebugFormat("[xmlGROUPS]: OnInstantMessage called for {0}, message type {1}",
  332. remoteClient.Name, (InstantMessageDialog)im.dialog);
  333. if (remoteClient == null || !remoteClient.IsActive || remoteClient.AgentId == UUID.Zero)
  334. return;
  335. Scene scene = (Scene)remoteClient.Scene;
  336. if(scene == null)
  337. return;
  338. UUID remoteAgentID = remoteClient.AgentId;
  339. // Group invitations
  340. if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline))
  341. {
  342. UUID inviteID = new UUID(im.imSessionID);
  343. GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID);
  344. if (inviteInfo == null)
  345. {
  346. if (m_debugEnabled)
  347. m_log.WarnFormat("[xmlGROUPS]: Received an Invite IM for an invite that does not exist {0}.", inviteID);
  348. return;
  349. }
  350. if (m_debugEnabled)
  351. m_log.DebugFormat("[xmlGROUPS]: Invite is for Agent {0} to Group {1}.", inviteInfo.AgentID, inviteInfo.GroupID);
  352. UUID fromAgentID = new UUID(im.fromAgentID);
  353. if ((inviteInfo != null) && (fromAgentID == inviteInfo.AgentID))
  354. {
  355. // Accept
  356. if (im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept)
  357. {
  358. if (m_debugEnabled)
  359. m_log.DebugFormat("[xmlGROUPS]: Received an accept invite notice.");
  360. // and the sessionid is the role
  361. m_groupData.AddAgentToGroup(remoteAgentID, inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID);
  362. GridInstantMessage msg = new GridInstantMessage();
  363. msg.imSessionID = UUID.Zero.Guid;
  364. msg.fromAgentID = UUID.Zero.Guid;
  365. msg.toAgentID = inviteInfo.AgentID.Guid;
  366. msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
  367. msg.fromAgentName = "Groups";
  368. msg.message = string.Format("You have been added to the group.");
  369. msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.MessageBox;
  370. msg.fromGroup = false;
  371. msg.offline = (byte)0;
  372. msg.ParentEstateID = 0;
  373. msg.Position = Vector3.Zero;
  374. msg.RegionID = UUID.Zero.Guid;
  375. msg.binaryBucket = new byte[0];
  376. OutgoingInstantMessage(msg, inviteInfo.AgentID);
  377. IClientAPI inviteeClient = GetActiveRootClient(inviteInfo.AgentID);
  378. if(inviteeClient !=null)
  379. {
  380. SendAgentGroupDataUpdate(inviteeClient,true);
  381. }
  382. m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID);
  383. }
  384. // Reject
  385. if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)
  386. {
  387. if (m_debugEnabled)
  388. m_log.DebugFormat("[xmlGROUPS]: Received a reject invite notice.");
  389. m_groupData.RemoveAgentToGroupInvite(remoteAgentID, inviteID);
  390. }
  391. }
  392. return;
  393. }
  394. // Group notices
  395. if ((im.dialog == (byte)InstantMessageDialog.GroupNotice))
  396. {
  397. if (!m_groupNoticesEnabled)
  398. return;
  399. UUID GroupID = new UUID(im.toAgentID);
  400. GroupMembershipData grpMemberData = m_groupData.GetAgentGroupMembership(remoteAgentID, remoteAgentID, GroupID);
  401. if (grpMemberData == null)
  402. {
  403. remoteClient.SendAgentAlertMessage("Group membership not found", false);
  404. return;
  405. }
  406. if ((grpMemberData.GroupPowers & (ulong)GroupPowers.SendNotices) == 0)
  407. {
  408. remoteClient.SendAgentAlertMessage("No permission to send notice to group", false);
  409. return;
  410. }
  411. int index = im.message.IndexOf('|');
  412. if(index < 0)
  413. return;
  414. string Subject = im.message.Substring(0, index);
  415. string Message = im.message.Substring(index + 1);
  416. InventoryItemBase item = null;
  417. bool hasAttachment = false;
  418. UUID itemID = UUID.Zero;
  419. UUID ownerID = UUID.Zero;
  420. byte[] bucket;
  421. if (im.binaryBucket.Length >= 1 && im.binaryBucket[0] > 0)
  422. {
  423. try
  424. {
  425. string binBucket = Utils.BytesToString(im.binaryBucket);
  426. binBucket = binBucket.Substring(15); // remove extra LLSD pre header
  427. OSDMap binBucketMAP = (OSDMap)OSDParser.DeserializeLLSDXml(binBucket);
  428. itemID = binBucketMAP["item_id"].AsUUID();
  429. ownerID = binBucketMAP["owner_id"].AsUUID();
  430. }
  431. catch
  432. {
  433. m_log.DebugFormat("[xmlGROUPS]: failed to decode group notice bucket");
  434. return;
  435. }
  436. if(itemID != UUID.Zero && ownerID != UUID.Zero)
  437. {
  438. item = scene.InventoryService.GetItem(ownerID, itemID);
  439. if (item != null)
  440. {
  441. if((item.CurrentPermissions & (uint)(PermissionMask.Transfer | PermissionMask.Copy)) !=
  442. (uint)(PermissionMask.Transfer | PermissionMask.Copy))
  443. {
  444. remoteClient.SendAgentAlertMessage("Item must be have Copy and Transfer rights to attach to group notice", false);
  445. return;
  446. }
  447. hasAttachment = true;
  448. }
  449. }
  450. }
  451. if (hasAttachment)
  452. {
  453. //Bucket contains information about attachment.
  454. //
  455. //Byte offset and description of bucket data:
  456. //0: 1 byte indicating if attachment is present
  457. //1: 1 byte indicating the type of attachment
  458. //2: 16 bytes - Group UUID
  459. //18: 16 bytes - UUID of the attachment owner
  460. //34: 16 bytes - UUID of the attachment
  461. //50: variable - Name of the attachment
  462. //??: NUL byte to terminate the attachment name
  463. byte[] name = Encoding.UTF8.GetBytes(item.Name);
  464. bucket = new byte[51 + name.Length];//2 bytes, 3 UUIDs, and name and null
  465. bucket[0] = 1; //Has attachment flag
  466. bucket[1] = (byte)item.AssetType; //Type of Attachment
  467. GroupID.ToBytes(bucket, 2);
  468. ownerID.ToBytes(bucket, 18);
  469. itemID.ToBytes(bucket, 34);
  470. name.CopyTo(bucket, 50);
  471. }
  472. else
  473. {
  474. bucket = new byte[19];
  475. bucket[0] = 0; //Has attachment flag
  476. bucket[1] = 0; //Type of attachment
  477. GroupID.ToBytes(bucket, 2);
  478. bucket[18] = 0; //NUL terminate name of attachment
  479. }
  480. UUID NoticeID = UUID.Random();
  481. m_groupData.AddGroupNotice(remoteAgentID, GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket);
  482. OnNewGroupNotice?.Invoke(GroupID, NoticeID);
  483. if (m_debugEnabled)
  484. {
  485. foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), GroupID))
  486. {
  487. if (m_debugEnabled)
  488. {
  489. UserAccount targetUser = m_sceneList[0].UserAccountService.GetUserAccount(
  490. remoteClient.Scene.RegionInfo.ScopeID, member.AgentID);
  491. if (targetUser != null)
  492. {
  493. m_log.DebugFormat(
  494. "[xmlGROUPS]: Prepping group notice {0} for agent: {1} who Accepts Notices ({2})",
  495. NoticeID, targetUser.FirstName + " " + targetUser.LastName, member.AcceptNotices);
  496. }
  497. else
  498. {
  499. m_log.DebugFormat(
  500. "[xmlGROUPS]: Prepping group notice {0} for agent: {1} who Accepts Notices ({2})",
  501. NoticeID, member.AgentID, member.AcceptNotices);
  502. }
  503. }
  504. }
  505. }
  506. if (m_groupsMessagingModule != null)
  507. {
  508. GridInstantMessage msg
  509. = CreateGroupNoticeIM(UUID.Zero, NoticeID, (byte)InstantMessageDialog.GroupNotice);
  510. m_groupsMessagingModule.SendMessageToGroup(
  511. msg, GroupID, remoteAgentID, gmd => gmd.AcceptNotices);
  512. }
  513. }
  514. else if (im.dialog == (byte)InstantMessageDialog.GroupNoticeInventoryAccepted)
  515. {
  516. if (!m_groupNoticesEnabled)
  517. return;
  518. UUID noticeID = new UUID(im.imSessionID);
  519. if (m_debugEnabled)
  520. m_log.DebugFormat("[xmlGROUPS]: Accepted notice {0} for {1}", noticeID, remoteClient.AgentId);
  521. if (noticeID == UUID.Zero)
  522. return;
  523. UUID folderID = UUID.Zero;
  524. try
  525. {
  526. if (im.binaryBucket != null && im.binaryBucket.Length >= 16)
  527. folderID = new UUID(im.binaryBucket, 0);
  528. }
  529. catch
  530. {
  531. m_log.DebugFormat("[xmlGROUPS]: GroupNoticeInventoryAccepted failed to decode target folder");
  532. return;
  533. }
  534. GroupNoticeInfo notice = m_groupData.GetGroupNotice(remoteAgentID, noticeID);
  535. if (notice == null)
  536. {
  537. if (m_debugEnabled)
  538. m_log.DebugFormat(
  539. "[GROUPS]: Could not find notice {0} for {1} on GroupNoticeInventoryAccepted.",
  540. noticeID, remoteClient.AgentId);
  541. return;
  542. }
  543. UUID giver = UUID.Zero;
  544. UUID attachmentUUID = UUID.Zero;
  545. try
  546. {
  547. giver = new UUID(notice.BinaryBucket, 18);
  548. attachmentUUID = new UUID(notice.BinaryBucket, 34);
  549. }
  550. catch
  551. {
  552. m_log.DebugFormat("[xmlGROUPS]: GroupNoticeInventoryAccepted failed to giver or attachment ID");
  553. return;
  554. }
  555. if (m_debugEnabled)
  556. m_log.DebugFormat("[xmlGroups]: Giving inventory from {0} to {1}", giver, remoteAgentID);
  557. string message = "Could not find group notice attached item";
  558. InventoryItemBase itemCopy = scene.InventoryService.GetItem(giver, attachmentUUID);
  559. if (itemCopy != null)
  560. {
  561. itemCopy = scene.GiveInventoryItem(remoteAgentID, giver, attachmentUUID, folderID, out message);
  562. }
  563. if (itemCopy == null)
  564. {
  565. remoteClient.SendAgentAlertMessage(message, false);
  566. return;
  567. }
  568. remoteClient.SendInventoryItemCreateUpdate(itemCopy, 0);
  569. }
  570. else if (im.dialog == (byte)InstantMessageDialog.GroupNoticeInventoryDeclined)
  571. {
  572. if (!m_groupNoticesEnabled)
  573. return;
  574. UUID noticeID = new UUID(im.imSessionID);
  575. if (m_debugEnabled)
  576. m_log.DebugFormat("[xmlGROUPS]: Accepted notice {0} for {1}", noticeID, remoteAgentID);
  577. if (noticeID == UUID.Zero)
  578. return;
  579. GroupNoticeInfo notice = m_groupData.GetGroupNotice(remoteAgentID, noticeID);
  580. if (notice == null)
  581. {
  582. if (m_debugEnabled)
  583. m_log.DebugFormat(
  584. "[GROUPS]: Could not find notice {0} for {1} on GroupNoticeInventoryAccepted.",
  585. noticeID, remoteClient.AgentId);
  586. return;
  587. }
  588. UUID giver = UUID.Zero;
  589. UUID attachmentUUID = UUID.Zero;
  590. try
  591. {
  592. giver = new UUID(notice.BinaryBucket, 18);
  593. attachmentUUID = new UUID(notice.BinaryBucket, 34);
  594. }
  595. catch
  596. {
  597. m_log.DebugFormat("[xmlGROUPS]: GroupNoticeInventoryAccepted failed to giver or attachment ID");
  598. return;
  599. }
  600. if (m_debugEnabled)
  601. m_log.DebugFormat("[xmlGroups]: Deny inventory from {0} to {1}", giver, remoteAgentID);
  602. string message = String.Empty;
  603. // check if we already have it
  604. InventoryItemBase itemCopy = scene.InventoryService.GetItem(remoteAgentID, attachmentUUID);
  605. if (itemCopy == null)
  606. return;
  607. InventoryFolderBase trash = scene.InventoryService.GetFolderForType(remoteAgentID, FolderType.Trash);
  608. if (trash == null)
  609. {
  610. m_log.DebugFormat("[xmlGROUPS]: failed to find trash folder for {0} ", remoteAgentID);
  611. return;
  612. }
  613. if (itemCopy.Folder == trash.ID || remoteAgentID == giver)
  614. return;
  615. itemCopy.Folder = trash.ID;
  616. scene.InventoryService.MoveItems(itemCopy.Owner, new List<InventoryItemBase>() { itemCopy });
  617. if (itemCopy == null)
  618. {
  619. remoteClient.SendAgentAlertMessage(message, false);
  620. return;
  621. }
  622. remoteClient.SendInventoryItemCreateUpdate(itemCopy, 0);
  623. }
  624. // Interop, received special 210 code for ejecting a group member
  625. // this only works within the comms servers domain, and won't work hypergrid
  626. // TODO:FIXME: Use a presence server of some kind to find out where the
  627. // client actually is, and try contacting that region directly to notify them,
  628. // or provide the notification via xmlrpc update queue
  629. else if ((im.dialog == 210))
  630. {
  631. // This is sent from the region that the ejectee was ejected from
  632. // if it's being delivered here, then the ejectee is here
  633. // so we need to send local updates to the agent.
  634. UUID ejecteeID = new UUID(im.toAgentID);
  635. im.imSessionID = UUID.Zero.Guid;
  636. im.dialog = (byte)InstantMessageDialog.MessageFromAgent;
  637. OutgoingInstantMessage(im, ejecteeID);
  638. IClientAPI ejectee = GetActiveRootClient(ejecteeID);
  639. if (ejectee != null)
  640. {
  641. UUID groupID = new UUID(im.imSessionID);
  642. ejectee.SendAgentDropGroup(groupID);
  643. SendAgentGroupDataUpdate(ejectee,true);
  644. }
  645. }
  646. }
  647. private void OnGridInstantMessage(GridInstantMessage msg)
  648. {
  649. if (m_debugEnabled)
  650. m_log.InfoFormat("[xmlGROUPS]: OnGridInstantMessage called");
  651. // Trigger the above event handler
  652. OnInstantMessage(null, msg);
  653. // If a message from a group arrives here, it may need to be forwarded to a local client
  654. if (msg.fromGroup == true)
  655. {
  656. switch (msg.dialog)
  657. {
  658. case (byte)InstantMessageDialog.GroupInvitation:
  659. case (byte)InstantMessageDialog.GroupNotice:
  660. UUID toAgentID = new UUID(msg.toAgentID);
  661. IClientAPI localClient = GetActiveRootClient(toAgentID);
  662. if (localClient != null)
  663. {
  664. localClient.SendInstantMessage(msg);
  665. }
  666. break;
  667. }
  668. }
  669. }
  670. #endregion
  671. #region IGroupsModule Members
  672. public event NewGroupNotice OnNewGroupNotice;
  673. public GroupRecord GetGroupRecord(UUID GroupID)
  674. {
  675. return m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
  676. }
  677. public GroupRecord GetGroupRecord(string name)
  678. {
  679. return m_groupData.GetGroupRecord(UUID.Zero, UUID.Zero, name);
  680. }
  681. public void ActivateGroup(IClientAPI remoteClient, UUID groupID)
  682. {
  683. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  684. UUID agentID = GetRequestingAgentID(remoteClient);
  685. m_groupData.SetAgentActiveGroup(agentID, agentID, groupID);
  686. // llClientView does this
  687. SendAgentGroupDataUpdate(remoteClient, true);
  688. }
  689. /// <summary>
  690. /// Get the Role Titles for an Agent, for a specific group
  691. /// </summary>
  692. public List<GroupTitlesData> GroupTitlesRequest(IClientAPI remoteClient, UUID groupID)
  693. {
  694. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  695. List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
  696. GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
  697. List<GroupTitlesData> titles = new List<GroupTitlesData>();
  698. foreach (GroupRolesData role in agentRoles)
  699. {
  700. GroupTitlesData title = new GroupTitlesData();
  701. title.Name = role.Name;
  702. if (agentMembership != null)
  703. {
  704. title.Selected = agentMembership.ActiveRole == role.RoleID;
  705. }
  706. title.UUID = role.RoleID;
  707. titles.Add(title);
  708. }
  709. return titles;
  710. }
  711. public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID)
  712. {
  713. if (m_debugEnabled)
  714. m_log.DebugFormat(
  715. "[GROUPS]: GroupMembersRequest called for {0} from client {1}", groupID, remoteClient.Name);
  716. List<GroupMembersData> data = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID);
  717. if (m_debugEnabled)
  718. {
  719. foreach (GroupMembersData member in data)
  720. {
  721. m_log.DebugFormat("[GROUPS]: Member({0}) - IsOwner({1})", member.AgentID, member.IsOwner);
  722. }
  723. }
  724. return data;
  725. }
  726. public List<GroupRolesData> GroupRoleDataRequest(IClientAPI remoteClient, UUID groupID)
  727. {
  728. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  729. List<GroupRolesData> data = m_groupData.GetGroupRoles(GetRequestingAgentID(remoteClient), groupID);
  730. return data;
  731. }
  732. public List<GroupRoleMembersData> GroupRoleMembersRequest(IClientAPI remoteClient, UUID groupID)
  733. {
  734. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  735. List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetRequestingAgentID(remoteClient), groupID);
  736. if (m_debugEnabled)
  737. {
  738. foreach (GroupRoleMembersData member in data)
  739. {
  740. m_log.DebugFormat("[GROUPS]: Member({0}) - Role({1})", member.MemberID, member.RoleID);
  741. }
  742. }
  743. return data;
  744. }
  745. public GroupProfileData GroupProfileRequest(IClientAPI remoteClient, UUID groupID)
  746. {
  747. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  748. GroupProfileData profile = new GroupProfileData();
  749. GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null);
  750. if (groupInfo != null)
  751. {
  752. profile.AllowPublish = groupInfo.AllowPublish;
  753. profile.Charter = groupInfo.Charter;
  754. profile.FounderID = groupInfo.FounderID;
  755. profile.GroupID = groupID;
  756. profile.GroupMembershipCount = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID).Count;
  757. profile.GroupRolesCount = m_groupData.GetGroupRoles(GetRequestingAgentID(remoteClient), groupID).Count;
  758. profile.InsigniaID = groupInfo.GroupPicture;
  759. profile.MaturePublish = groupInfo.MaturePublish;
  760. profile.MembershipFee = groupInfo.MembershipFee;
  761. profile.Money = 0; // TODO: Get this from the currency server?
  762. profile.Name = groupInfo.GroupName;
  763. profile.OpenEnrollment = groupInfo.OpenEnrollment;
  764. profile.OwnerRole = groupInfo.OwnerRoleID;
  765. profile.ShowInList = groupInfo.ShowInList;
  766. }
  767. GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
  768. if (memberInfo != null)
  769. {
  770. profile.MemberTitle = memberInfo.GroupTitle;
  771. profile.PowersMask = memberInfo.GroupPowers;
  772. }
  773. /*
  774. this should save xmlrpc calls, but seems to return wrong GroupMembershipCount and GroupRolesCount
  775. UUID agent = GetRequestingAgentID(remoteClient);
  776. GroupProfileData profile = m_groupData.GetMemberGroupProfile(agent, groupID, agent);
  777. */
  778. return profile;
  779. }
  780. public GroupMembershipData[] GetMembershipData(UUID agentID)
  781. {
  782. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  783. return m_groupData.GetAgentGroupMemberships(UUID.Zero, agentID).ToArray();
  784. }
  785. public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID)
  786. {
  787. if (m_debugEnabled)
  788. m_log.DebugFormat(
  789. "[GROUPS]: {0} called with groupID={1}, agentID={2}",
  790. System.Reflection.MethodBase.GetCurrentMethod().Name, groupID, agentID);
  791. return m_groupData.GetAgentGroupMembership(UUID.Zero, agentID, groupID);
  792. }
  793. public GroupMembershipData GetActiveMembershipData(UUID agentID)
  794. {
  795. return m_groupData.GetAgentActiveMembership(agentID, agentID);
  796. }
  797. public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
  798. {
  799. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  800. // Note: Permissions checking for modification rights is handled by the Groups Server/Service
  801. m_groupData.UpdateGroup(GetRequestingAgentID(remoteClient), groupID, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish);
  802. }
  803. public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile)
  804. {
  805. // Note: Permissions checking for modification rights is handled by the Groups Server/Service
  806. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  807. m_groupData.SetAgentGroupInfo(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, acceptNotices, listInProfile);
  808. }
  809. public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
  810. {
  811. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  812. GroupRecord groupRecord = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), UUID.Zero, name);
  813. if (groupRecord != null)
  814. {
  815. remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists.");
  816. return UUID.Zero;
  817. }
  818. // check user level
  819. ScenePresence avatar = null;
  820. Scene scene = (Scene)remoteClient.Scene;
  821. scene.TryGetScenePresence(remoteClient.AgentId, out avatar);
  822. if (avatar != null)
  823. {
  824. if (avatar.GodController.UserLevel < m_levelGroupCreate)
  825. {
  826. remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have insufficient permissions to create a group.");
  827. return UUID.Zero;
  828. }
  829. }
  830. // check funds
  831. // is there a money module present ?
  832. IMoneyModule money = scene.RequestModuleInterface<IMoneyModule>();
  833. if (money != null && money.GroupCreationCharge > 0)
  834. {
  835. // do the transaction, that is if the agent has sufficient funds
  836. if (!money.AmountCovered(remoteClient.AgentId, money.GroupCreationCharge)) {
  837. remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have insufficient funds to create a group.");
  838. return UUID.Zero;
  839. }
  840. money.ApplyCharge(GetRequestingAgentID(remoteClient), money.GroupCreationCharge, MoneyTransactionType.GroupCreate, name);
  841. }
  842. UUID groupID = m_groupData.CreateGroup(GetRequestingAgentID(remoteClient), name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, GetRequestingAgentID(remoteClient));
  843. remoteClient.SendCreateGroupReply(groupID, true, "Group created successfully");
  844. // Update the founder with new group information.
  845. SendAgentGroupDataUpdate(remoteClient, true);
  846. return groupID;
  847. }
  848. public GroupNoticeData[] GroupNoticesListRequest(IClientAPI remoteClient, UUID groupID)
  849. {
  850. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  851. // ToDo: check if agent is a member of group and is allowed to see notices?
  852. return m_groupData.GetGroupNotices(GetRequestingAgentID(remoteClient), groupID).ToArray();
  853. }
  854. /// <summary>
  855. /// Get the title of the agent's current role.
  856. /// </summary>
  857. public string GetGroupTitle(UUID avatarID)
  858. {
  859. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  860. GroupMembershipData membership = m_groupData.GetAgentActiveMembership(UUID.Zero, avatarID);
  861. if (membership != null)
  862. {
  863. return membership.GroupTitle;
  864. }
  865. return string.Empty;
  866. }
  867. /// <summary>
  868. /// Change the current Active Group Role for Agent
  869. /// </summary>
  870. public void GroupTitleUpdate(IClientAPI remoteClient, UUID groupID, UUID titleRoleID)
  871. {
  872. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  873. m_groupData.SetAgentActiveGroupRole(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, titleRoleID);
  874. // TODO: Not sure what all is needed here, but if the active group role change is for the group
  875. // the client currently has set active, then we need to do a scene presence update too
  876. // if (m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient)).GroupID == GroupID)
  877. SendDataUpdate(remoteClient, true);
  878. }
  879. public void GroupRoleUpdate(IClientAPI remoteClient, UUID groupID, UUID roleID, string name, string description, string title, ulong powers, byte updateType)
  880. {
  881. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  882. // Security Checks are handled in the Groups Service.
  883. switch ((OpenMetaverse.GroupRoleUpdate)updateType)
  884. {
  885. case OpenMetaverse.GroupRoleUpdate.Create:
  886. m_groupData.AddGroupRole(GetRequestingAgentID(remoteClient), groupID, UUID.Random(), name, description, title, powers);
  887. break;
  888. case OpenMetaverse.GroupRoleUpdate.Delete:
  889. m_groupData.RemoveGroupRole(GetRequestingAgentID(remoteClient), groupID, roleID);
  890. break;
  891. case OpenMetaverse.GroupRoleUpdate.UpdateAll:
  892. case OpenMetaverse.GroupRoleUpdate.UpdateData:
  893. case OpenMetaverse.GroupRoleUpdate.UpdatePowers:
  894. if (m_debugEnabled)
  895. {
  896. GroupPowers gp = (GroupPowers)powers;
  897. m_log.DebugFormat("[GROUPS]: Role ({0}) updated with Powers ({1}) ({2})", name, powers.ToString(), gp.ToString());
  898. }
  899. m_groupData.UpdateGroupRole(GetRequestingAgentID(remoteClient), groupID, roleID, name, description, title, powers);
  900. break;
  901. case OpenMetaverse.GroupRoleUpdate.NoUpdate:
  902. default:
  903. // No Op
  904. break;
  905. }
  906. // TODO: This update really should send out updates for everyone in the role that just got changed.
  907. SendAgentGroupDataUpdate(remoteClient, false);
  908. }
  909. public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes)
  910. {
  911. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  912. // Todo: Security check
  913. switch (changes)
  914. {
  915. case 0:
  916. // Add
  917. m_groupData.AddAgentToGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID);
  918. break;
  919. case 1:
  920. // Remove
  921. m_groupData.RemoveAgentFromGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID);
  922. break;
  923. default:
  924. m_log.ErrorFormat("[GROUPS]: {0} does not understand changes == {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, changes);
  925. break;
  926. }
  927. // TODO: This update really should send out updates for everyone in the role that just got changed.
  928. SendAgentGroupDataUpdate(remoteClient, false);
  929. }
  930. public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID)
  931. {
  932. if (m_debugEnabled)
  933. m_log.DebugFormat("[xmlGROUPS]: GroupNoticeRequest {0}", groupNoticeID);
  934. GroupNoticeInfo info = m_groupData.GetGroupNotice(remoteClient.AgentId, groupNoticeID);
  935. if(info == null)
  936. return;
  937. GridInstantMessage msg = CreateGroupNoticeIM(remoteClient.AgentId, groupNoticeID, (byte)InstantMessageDialog.GroupNoticeRequested, info);
  938. OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient));
  939. }
  940. public GridInstantMessage CreateGroupNoticeIM(UUID agentID, UUID groupNoticeID, byte dialog)
  941. {
  942. GroupNoticeInfo info = m_groupData.GetGroupNotice(agentID, groupNoticeID);
  943. return CreateGroupNoticeIM(agentID, groupNoticeID, dialog, info);
  944. }
  945. private GridInstantMessage CreateGroupNoticeIM(UUID agentID, UUID groupNoticeID, byte dialog, GroupNoticeInfo info)
  946. {
  947. GridInstantMessage msg = new GridInstantMessage();
  948. byte[] bucket;
  949. msg.imSessionID = groupNoticeID.Guid;
  950. msg.toAgentID = agentID.Guid;
  951. msg.dialog = dialog;
  952. msg.fromGroup = true;
  953. msg.offline = (byte)1; // Allow this message to be stored for offline use
  954. msg.ParentEstateID = 0;
  955. msg.Position = Vector3.Zero;
  956. msg.RegionID = UUID.Zero.Guid;
  957. if (info != null)
  958. {
  959. msg.fromAgentID = info.GroupID.Guid;
  960. msg.timestamp = info.noticeData.Timestamp;
  961. msg.fromAgentName = info.noticeData.FromName;
  962. msg.message = info.noticeData.Subject + "|" + info.Message;
  963. if (info.BinaryBucket[0] > 0)
  964. {
  965. //32 is due to not needing space for two of the UUIDs.
  966. //(Don't need UUID of attachment or its owner in IM)
  967. //50 offset gets us to start of attachment name.
  968. bucket = new byte[info.BinaryBucket.Length - 32];
  969. Array.Copy(info.BinaryBucket, 0,
  970. bucket, 0, 18);
  971. Array.Copy(info.BinaryBucket, 50,
  972. bucket, 18, info.BinaryBucket.Length - 50);
  973. }
  974. else
  975. {
  976. bucket = new byte[19];
  977. bucket[0] = 0; //No attachment
  978. bucket[1] = 0; //Attachment type
  979. bucket[18] = 0; //NUL terminate name
  980. }
  981. msg.binaryBucket = bucket;
  982. }
  983. else
  984. {
  985. if (m_debugEnabled)
  986. m_log.DebugFormat("[GROUPS]: Group Notice {0} not found, composing empty message.", groupNoticeID);
  987. msg.fromAgentID = UUID.Zero.Guid;
  988. msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
  989. msg.fromAgentName = string.Empty;
  990. msg.message = string.Empty;
  991. msg.binaryBucket = new byte[0];
  992. }
  993. return msg;
  994. }
  995. public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID)
  996. {
  997. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  998. // Should check to see if OpenEnrollment, or if there's an outstanding invitation
  999. m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, UUID.Zero);
  1000. // check funds
  1001. // is there a money module present ?
  1002. GroupRecord groupRecord = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null);
  1003. IMoneyModule money = remoteClient.Scene.RequestModuleInterface<IMoneyModule>();
  1004. if (money != null && groupRecord.MembershipFee > 0)
  1005. {
  1006. // do the transaction, that is if the agent has sufficient funds
  1007. if (!money.AmountCovered(GetRequestingAgentID(remoteClient), groupRecord.MembershipFee)) {
  1008. remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have insufficient funds to join the group.");
  1009. return;
  1010. }
  1011. money.ApplyCharge(GetRequestingAgentID(remoteClient), groupRecord.MembershipFee, MoneyTransactionType.GroupJoin, groupRecord.GroupName);
  1012. }
  1013. remoteClient.SendJoinGroupReply(groupID, true);
  1014. SendAgentGroupDataUpdate(remoteClient, true);
  1015. }
  1016. public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID)
  1017. {
  1018. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  1019. m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
  1020. remoteClient.SendLeaveGroupReply(groupID, true);
  1021. remoteClient.SendAgentDropGroup(groupID);
  1022. // SL sends out notifcations to the group messaging session that the person has left
  1023. // Should this also update everyone who is in the group?
  1024. SendAgentGroupDataUpdate(remoteClient, true);
  1025. }
  1026. public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID)
  1027. {
  1028. EjectGroupMember(remoteClient, GetRequestingAgentID(remoteClient), groupID, ejecteeID);
  1029. }
  1030. public void EjectGroupMember(IClientAPI remoteClient, UUID agentID, UUID groupID, UUID ejecteeID)
  1031. {
  1032. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  1033. // Todo: Security check?
  1034. m_groupData.RemoveAgentFromGroup(agentID, ejecteeID, groupID);
  1035. string agentName;
  1036. RegionInfo regionInfo;
  1037. // remoteClient provided or just agentID?
  1038. if (remoteClient != null)
  1039. {
  1040. agentName = remoteClient.Name;
  1041. regionInfo = remoteClient.Scene.RegionInfo;
  1042. remoteClient.SendEjectGroupMemberReply(agentID, groupID, true);
  1043. }
  1044. else
  1045. {
  1046. IClientAPI client = GetActiveClient(agentID);
  1047. if (client != null)
  1048. {
  1049. agentName = client.Name;
  1050. regionInfo = client.Scene.RegionInfo;
  1051. client.SendEjectGroupMemberReply(agentID, groupID, true);
  1052. }
  1053. else
  1054. {
  1055. regionInfo = m_sceneList[0].RegionInfo;
  1056. UserAccount acc = m_sceneList[0].UserAccountService.GetUserAccount(regionInfo.ScopeID, agentID);
  1057. if (acc != null)
  1058. {
  1059. agentName = acc.FirstName + " " + acc.LastName;
  1060. }
  1061. else
  1062. {
  1063. agentName = "Unknown member";
  1064. }
  1065. }
  1066. }
  1067. GroupRecord groupInfo = m_groupData.GetGroupRecord(agentID, groupID, null);
  1068. if (groupInfo == null)
  1069. return;
  1070. IClientAPI ejecteeClient = GetActiveRootClient(ejecteeID);
  1071. // Send Message to Ejectee
  1072. GridInstantMessage msg = new GridInstantMessage();
  1073. string ejecteeName = "Unknown member";
  1074. // if local send a normal message
  1075. if(ejecteeClient != null)
  1076. {
  1077. msg.imSessionID = UUID.Zero.Guid;
  1078. msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.MessageFromAgent;
  1079. // also execute and send update
  1080. ejecteeClient.SendAgentDropGroup(groupID);
  1081. SendAgentGroupDataUpdate(ejecteeClient,true);
  1082. ejecteeName = ejecteeClient.Name;
  1083. }
  1084. else // send
  1085. {
  1086. // Interop, received special 210 code for ejecting a group member
  1087. // this only works within the comms servers domain, and won't work hypergrid
  1088. // TODO:FIXME: Use a presence server of some kind to find out where the
  1089. // client actually is, and try contacting that region directly to notify them,
  1090. // or provide the notification via xmlrpc update queue
  1091. msg.imSessionID = groupInfo.GroupID.Guid;
  1092. msg.dialog = (byte)210; //interop
  1093. UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(regionInfo.ScopeID, ejecteeID);
  1094. if (account != null)
  1095. ejecteeName = account.FirstName + " " + account.LastName;
  1096. }
  1097. msg.fromAgentID = agentID.Guid;
  1098. // msg.fromAgentID = info.GroupID;
  1099. msg.toAgentID = ejecteeID.Guid;
  1100. //msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
  1101. msg.timestamp = 0;
  1102. msg.fromAgentName = agentName;
  1103. msg.message = string.Format("You have been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName);
  1104. //
  1105. msg.fromGroup = false;
  1106. msg.offline = (byte)0;
  1107. msg.ParentEstateID = 0;
  1108. msg.Position = Vector3.Zero;
  1109. msg.RegionID = regionInfo.RegionID.Guid;
  1110. msg.binaryBucket = new byte[0];
  1111. OutgoingInstantMessage(msg, ejecteeID);
  1112. // Message to ejector
  1113. msg = new GridInstantMessage();
  1114. msg.imSessionID = UUID.Zero.Guid;
  1115. msg.fromAgentID = agentID.Guid;
  1116. msg.toAgentID = agentID.Guid;
  1117. msg.timestamp = 0;
  1118. msg.fromAgentName = agentName;
  1119. msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName, ejecteeName);
  1120. // msg.dialog = (byte)210; //interop
  1121. msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.MessageFromAgent;
  1122. msg.fromGroup = false;
  1123. msg.offline = (byte)0;
  1124. msg.ParentEstateID = 0;
  1125. msg.Position = Vector3.Zero;
  1126. msg.RegionID = regionInfo.RegionID.Guid;
  1127. msg.binaryBucket = new byte[0];
  1128. OutgoingInstantMessage(msg, agentID);
  1129. }
  1130. public void InviteGroupRequest(IClientAPI remoteClient, UUID groupID, UUID invitedAgentID, UUID roleID)
  1131. {
  1132. InviteGroup(remoteClient, GetRequestingAgentID(remoteClient), groupID, invitedAgentID, roleID);
  1133. }
  1134. public void InviteGroup(IClientAPI remoteClient, UUID agentID, UUID groupID, UUID invitedAgentID, UUID roleID)
  1135. {
  1136. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  1137. string agentName;
  1138. RegionInfo regionInfo;
  1139. // remoteClient provided or just agentID?
  1140. if (remoteClient != null)
  1141. {
  1142. agentName = remoteClient.Name;
  1143. regionInfo = remoteClient.Scene.RegionInfo;
  1144. }
  1145. else
  1146. {
  1147. IClientAPI client = GetActiveClient(agentID);
  1148. if (client != null)
  1149. {
  1150. agentName = client.Name;
  1151. regionInfo = client.Scene.RegionInfo;
  1152. }
  1153. else
  1154. {
  1155. regionInfo = m_sceneList[0].RegionInfo;
  1156. UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(regionInfo.ScopeID, agentID);
  1157. if (account != null)
  1158. {
  1159. agentName = account.FirstName + " " + account.LastName;
  1160. }
  1161. else
  1162. {
  1163. agentName = "Unknown member";
  1164. }
  1165. }
  1166. }
  1167. // Todo: Security check, probably also want to send some kind of notification
  1168. UUID InviteID = UUID.Random();
  1169. m_groupData.AddAgentToGroupInvite(agentID, InviteID, groupID, roleID, invitedAgentID);
  1170. // Check to see if the invite went through, if it did not then it's possible
  1171. // the remoteClient did not validate or did not have permission to invite.
  1172. GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(agentID, InviteID);
  1173. if (inviteInfo != null)
  1174. {
  1175. if (m_msgTransferModule != null)
  1176. {
  1177. Guid inviteUUID = InviteID.Guid;
  1178. GridInstantMessage msg = new GridInstantMessage();
  1179. msg.imSessionID = inviteUUID;
  1180. // msg.fromAgentID = agentID.Guid;
  1181. msg.fromAgentID = groupID.Guid;
  1182. msg.toAgentID = invitedAgentID.Guid;
  1183. //msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
  1184. msg.timestamp = 0;
  1185. msg.fromAgentName = agentName;
  1186. msg.message = string.Format("{0} has invited you to join a group. There is no cost to join this group.", agentName);
  1187. msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.GroupInvitation;
  1188. msg.fromGroup = true;
  1189. msg.offline = (byte)0;
  1190. msg.ParentEstateID = 0;
  1191. msg.Position = Vector3.Zero;
  1192. msg.RegionID = regionInfo.RegionID.Guid;
  1193. msg.binaryBucket = new byte[20];
  1194. OutgoingInstantMessage(msg, invitedAgentID);
  1195. }
  1196. }
  1197. }
  1198. public List<DirGroupsReplyData> FindGroups(IClientAPI remoteClient, string query)
  1199. {
  1200. return m_groupData.FindGroups(GetRequestingAgentID(remoteClient), query);
  1201. }
  1202. #endregion
  1203. #region Client/Update Tools
  1204. private IClientAPI GetActiveRootClient(UUID agentID)
  1205. {
  1206. foreach (Scene scene in m_sceneList)
  1207. {
  1208. ScenePresence sp = scene.GetScenePresence(agentID);
  1209. if (sp != null && !sp.IsChildAgent && !sp.IsDeleted)
  1210. {
  1211. return sp.ControllingClient;
  1212. }
  1213. }
  1214. return null;
  1215. }
  1216. /// <summary>
  1217. /// Try to find an active IClientAPI reference for agentID giving preference to root connections
  1218. /// </summary>
  1219. private IClientAPI GetActiveClient(UUID agentID)
  1220. {
  1221. IClientAPI child = null;
  1222. // Try root avatar first
  1223. foreach (Scene scene in m_sceneList)
  1224. {
  1225. ScenePresence sp = scene.GetScenePresence(agentID);
  1226. if (sp != null && !sp.IsDeleted)
  1227. {
  1228. if (!sp.IsChildAgent)
  1229. {
  1230. return sp.ControllingClient;
  1231. }
  1232. else
  1233. {
  1234. child = sp.ControllingClient;
  1235. }
  1236. }
  1237. }
  1238. // If we didn't find a root, then just return whichever child we found, or null if none
  1239. return child;
  1240. }
  1241. private void SendScenePresenceUpdate(UUID AgentID, string Title)
  1242. {
  1243. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Updating scene title for {0} with title: {1}", AgentID, Title);
  1244. ScenePresence presence = null;
  1245. foreach (Scene scene in m_sceneList)
  1246. {
  1247. presence = scene.GetScenePresence(AgentID);
  1248. if (presence != null)
  1249. {
  1250. if (presence.Grouptitle != Title)
  1251. {
  1252. presence.Grouptitle = Title;
  1253. if (! presence.IsChildAgent)
  1254. presence.SendAvatarDataToAllAgents();
  1255. }
  1256. }
  1257. }
  1258. }
  1259. public void SendAgentGroupDataUpdate(IClientAPI remoteClient)
  1260. {
  1261. SendAgentGroupDataUpdate(remoteClient, true);
  1262. }
  1263. /// <summary>
  1264. /// Tell remoteClient about its agent groups, and optionally send title to others
  1265. /// </summary>
  1266. private void SendAgentGroupDataUpdate(IClientAPI remoteClient, bool tellOthers)
  1267. {
  1268. if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: {0} called for {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, remoteClient.Name);
  1269. // NPCs currently don't have a CAPs structure or event queues. There is a strong argument for conveying this information
  1270. // to them anyway since it makes writing server-side bots a lot easier, but for now we don't do anything.
  1271. if (remoteClient.SceneAgent.PresenceType == PresenceType.Npc)
  1272. return;
  1273. // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff
  1274. UUID agentID = GetRequestingAgentID(remoteClient);
  1275. SendDataUpdate(remoteClient, tellOthers);
  1276. GroupMembershipData[] membershipArray = GetProfileListedGroupMemberships(remoteClient, agentID);
  1277. remoteClient.UpdateGroupMembership(membershipArray);
  1278. remoteClient.SendAgentGroupDataUpdate(agentID, membershipArray);
  1279. }
  1280. /// <summary>
  1281. /// Get a list of groups memberships for the agent that are marked "ListInProfile"
  1282. /// (unless that agent has a godLike aspect, in which case get all groups)
  1283. /// </summary>
  1284. /// <param name="dataForAgentID"></param>
  1285. /// <returns></returns>
  1286. private GroupMembershipData[] GetProfileListedGroupMemberships(IClientAPI requestingClient, UUID dataForAgentID)
  1287. {
  1288. List<GroupMembershipData> membershipData = m_groupData.GetAgentGroupMemberships(requestingClient.AgentId, dataForAgentID);
  1289. GroupMembershipData[] membershipArray;
  1290. // cScene and property accessor 'isGod' are in support of the opertions to bypass 'hidden' group attributes for
  1291. // those with a GodLike aspect.
  1292. Scene cScene = (Scene)requestingClient.Scene;
  1293. bool isGod = cScene.Permissions.IsGod(requestingClient.AgentId);
  1294. if (isGod)
  1295. {
  1296. membershipArray = membershipData.ToArray();
  1297. }
  1298. else
  1299. {
  1300. if (requestingClient.AgentId != dataForAgentID)
  1301. {
  1302. Predicate<GroupMembershipData> showInProfile = delegate(GroupMembershipData membership)
  1303. {
  1304. return membership.ListInProfile;
  1305. };
  1306. membershipArray = membershipData.FindAll(showInProfile).ToArray();
  1307. }
  1308. else
  1309. {
  1310. membershipArray = membershipData.ToArray();
  1311. }
  1312. }
  1313. if (m_debugEnabled)
  1314. {
  1315. m_log.InfoFormat("[GROUPS]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId);
  1316. foreach (GroupMembershipData membership in membershipArray)
  1317. {
  1318. m_log.InfoFormat("[GROUPS]: {0} :: {1} - {2} - {3}", dataForAgentID, membership.GroupName, membership.GroupTitle, membership.GroupPowers);
  1319. }
  1320. }
  1321. return membershipArray;
  1322. }
  1323. //tell remoteClient about its agent group info, and optionally send title to others
  1324. private void SendDataUpdate(IClientAPI remoteClient, bool tellOthers)
  1325. {
  1326. if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  1327. UUID activeGroupID = UUID.Zero;
  1328. string activeGroupTitle = string.Empty;
  1329. string activeGroupName = string.Empty;
  1330. ulong activeGroupPowers = (ulong)GroupPowers.None;
  1331. UUID agentID = GetRequestingAgentID(remoteClient);
  1332. GroupMembershipData membership = m_groupData.GetAgentActiveMembership(agentID, agentID);
  1333. if (membership != null)
  1334. {
  1335. activeGroupID = membership.GroupID;
  1336. activeGroupTitle = membership.GroupTitle;
  1337. activeGroupPowers = membership.GroupPowers;
  1338. activeGroupName = membership.GroupName;
  1339. }
  1340. UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, agentID);
  1341. string firstname, lastname;
  1342. if (account != null)
  1343. {
  1344. firstname = account.FirstName;
  1345. lastname = account.LastName;
  1346. }
  1347. else
  1348. {
  1349. firstname = "Unknown";
  1350. lastname = "Unknown";
  1351. }
  1352. remoteClient.SendAgentDataUpdate(agentID, activeGroupID, firstname,
  1353. lastname, activeGroupPowers, activeGroupName,
  1354. activeGroupTitle);
  1355. if (tellOthers)
  1356. SendScenePresenceUpdate(agentID, activeGroupTitle);
  1357. ScenePresence sp = (ScenePresence)remoteClient.SceneAgent;
  1358. if (sp != null)
  1359. sp.Grouptitle = activeGroupTitle;
  1360. }
  1361. #endregion
  1362. #region IM Backed Processes
  1363. private void OutgoingInstantMessage(GridInstantMessage msg, UUID msgTo)
  1364. {
  1365. if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
  1366. IClientAPI localClient = GetActiveRootClient(msgTo);
  1367. if (localClient != null)
  1368. {
  1369. if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: MsgTo ({0}) is local, delivering directly", localClient.Name);
  1370. localClient.SendInstantMessage(msg);
  1371. }
  1372. else if (m_msgTransferModule != null)
  1373. {
  1374. if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: MsgTo ({0}) is not local, delivering via TransferModule", msgTo);
  1375. m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Message Sent: {0}", success?"Succeeded":"Failed"); });
  1376. }
  1377. }
  1378. public void NotifyChange(UUID groupID)
  1379. {
  1380. // Notify all group members of a chnge in group roles and/or
  1381. // permissions
  1382. //
  1383. }
  1384. #endregion
  1385. private UUID GetRequestingAgentID(IClientAPI client)
  1386. {
  1387. UUID requestingAgentID = UUID.Zero;
  1388. if (client != null)
  1389. {
  1390. requestingAgentID = client.AgentId;
  1391. }
  1392. return requestingAgentID;
  1393. }
  1394. }
  1395. public class GroupNoticeInfo
  1396. {
  1397. public GroupNoticeData noticeData = new GroupNoticeData();
  1398. public UUID GroupID = UUID.Zero;
  1399. public string Message = string.Empty;
  1400. public byte[] BinaryBucket = new byte[0];
  1401. }
  1402. }