aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs')
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs299
1 files changed, 206 insertions, 93 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
index 964d0bb..8e7aa68 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
@@ -40,16 +40,16 @@ using OpenMetaverse;
40using OpenMetaverse.StructuredData; 40using OpenMetaverse.StructuredData;
41 41
42using OpenSim.Framework; 42using OpenSim.Framework;
43using OpenSim.Framework.Communications;
43using OpenSim.Region.Framework.Interfaces; 44using OpenSim.Region.Framework.Interfaces;
45using OpenSim.Services.Interfaces;
44 46
45namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups 47namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
46{ 48{
47 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 49 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
48 public class XmlRpcGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector 50 public class XmlRpcGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector
49 { 51 {
50 private static readonly ILog m_log = 52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52
53 53
54 public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome | 54 public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome |
55 GroupPowers.Accountable | 55 GroupPowers.Accountable |
@@ -61,13 +61,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
61 61
62 private bool m_connectorEnabled = false; 62 private bool m_connectorEnabled = false;
63 63
64 private string m_serviceURL = string.Empty; 64 private string m_groupsServerURI = string.Empty;
65 65
66 private bool m_disableKeepAlive = false; 66 private bool m_disableKeepAlive = false;
67 67
68 private string m_groupReadKey = string.Empty; 68 private string m_groupReadKey = string.Empty;
69 private string m_groupWriteKey = string.Empty; 69 private string m_groupWriteKey = string.Empty;
70 70
71 private IUserAccountService m_accountService = null;
72
73 // Used to track which agents are have dropped from a group chat session
74 // Should be reset per agent, on logon
75 // TODO: move this to Flotsam XmlRpc Service
76 // SessionID, List<AgentID>
77 private Dictionary<UUID, List<UUID>> m_groupsAgentsDroppedFromChatSession = new Dictionary<UUID, List<UUID>>();
78 private Dictionary<UUID, List<UUID>> m_groupsAgentsInvitedToChatSession = new Dictionary<UUID, List<UUID>>();
79
71 80
72 #region IRegionModuleBase Members 81 #region IRegionModuleBase Members
73 82
@@ -102,13 +111,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
102 return; 111 return;
103 } 112 }
104 113
105 m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name); 114 m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name);
106 115
107 m_serviceURL = groupsConfig.GetString("XmlRpcServiceURL", string.Empty); 116 m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty);
108 if ((m_serviceURL == null) || 117 if ((m_groupsServerURI == null) ||
109 (m_serviceURL == string.Empty)) 118 (m_groupsServerURI == string.Empty))
110 { 119 {
111 m_log.ErrorFormat("Please specify a valid URL for XmlRpcServiceURL in OpenSim.ini, [Groups]"); 120 m_log.ErrorFormat("Please specify a valid URL for GroupsServerURI in OpenSim.ini, [Groups]");
112 m_connectorEnabled = false; 121 m_connectorEnabled = false;
113 return; 122 return;
114 } 123 }
@@ -118,6 +127,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
118 m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty); 127 m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty);
119 m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty); 128 m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty);
120 129
130
131
132
121 // If we got all the config options we need, lets start'er'up 133 // If we got all the config options we need, lets start'er'up
122 m_connectorEnabled = true; 134 m_connectorEnabled = true;
123 } 135 }
@@ -131,13 +143,24 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
131 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) 143 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene)
132 { 144 {
133 if (m_connectorEnabled) 145 if (m_connectorEnabled)
146 {
147
148 if (m_accountService == null)
149 {
150 m_accountService = scene.UserAccountService;
151 }
152
153
134 scene.RegisterModuleInterface<IGroupsServicesConnector>(this); 154 scene.RegisterModuleInterface<IGroupsServicesConnector>(this);
155 }
135 } 156 }
136 157
137 public void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene) 158 public void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene)
138 { 159 {
139 if (scene.RequestModuleInterface<IGroupsServicesConnector>() == this) 160 if (scene.RequestModuleInterface<IGroupsServicesConnector>() == this)
161 {
140 scene.UnregisterModuleInterface<IGroupsServicesConnector>(this); 162 scene.UnregisterModuleInterface<IGroupsServicesConnector>(this);
163 }
141 } 164 }
142 165
143 public void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene) 166 public void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene)
@@ -157,14 +180,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
157 180
158 #endregion 181 #endregion
159 182
160
161
162 #region IGroupsServicesConnector Members 183 #region IGroupsServicesConnector Members
163 184
164 /// <summary> 185 /// <summary>
165 /// Create a Group, including Everyone and Owners Role, place FounderID in both groups, select Owner as selected role, and newly created group as agent's active role. 186 /// Create a Group, including Everyone and Owners Role, place FounderID in both groups, select Owner as selected role, and newly created group as agent's active role.
166 /// </summary> 187 /// </summary>
167 public UUID CreateGroup(GroupRequestID requestID, string name, string charter, bool showInList, UUID insigniaID, 188 public UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID,
168 int membershipFee, bool openEnrollment, bool allowPublish, 189 int membershipFee, bool openEnrollment, bool allowPublish,
169 bool maturePublish, UUID founderID) 190 bool maturePublish, UUID founderID)
170 { 191 {
@@ -236,7 +257,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
236 257
237 258
238 259
239 Hashtable respData = XmlRpcCall(requestID, "groups.createGroup", param); 260 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.createGroup", param);
240 261
241 if (respData.Contains("error")) 262 if (respData.Contains("error"))
242 { 263 {
@@ -248,7 +269,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
248 return UUID.Parse((string)respData["GroupID"]); 269 return UUID.Parse((string)respData["GroupID"]);
249 } 270 }
250 271
251 public void UpdateGroup(GroupRequestID requestID, UUID groupID, string charter, bool showInList, 272 public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList,
252 UUID insigniaID, int membershipFee, bool openEnrollment, 273 UUID insigniaID, int membershipFee, bool openEnrollment,
253 bool allowPublish, bool maturePublish) 274 bool allowPublish, bool maturePublish)
254 { 275 {
@@ -262,10 +283,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
262 param["AllowPublish"] = allowPublish == true ? 1 : 0; 283 param["AllowPublish"] = allowPublish == true ? 1 : 0;
263 param["MaturePublish"] = maturePublish == true ? 1 : 0; 284 param["MaturePublish"] = maturePublish == true ? 1 : 0;
264 285
265 XmlRpcCall(requestID, "groups.updateGroup", param); 286 XmlRpcCall(requestingAgentID, "groups.updateGroup", param);
266 } 287 }
267 288
268 public void AddGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, 289 public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
269 string title, ulong powers) 290 string title, ulong powers)
270 { 291 {
271 Hashtable param = new Hashtable(); 292 Hashtable param = new Hashtable();
@@ -276,19 +297,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
276 param["Title"] = title; 297 param["Title"] = title;
277 param["Powers"] = powers.ToString(); 298 param["Powers"] = powers.ToString();
278 299
279 XmlRpcCall(requestID, "groups.addRoleToGroup", param); 300 XmlRpcCall(requestingAgentID, "groups.addRoleToGroup", param);
280 } 301 }
281 302
282 public void RemoveGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID) 303 public void RemoveGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID)
283 { 304 {
284 Hashtable param = new Hashtable(); 305 Hashtable param = new Hashtable();
285 param["GroupID"] = groupID.ToString(); 306 param["GroupID"] = groupID.ToString();
286 param["RoleID"] = roleID.ToString(); 307 param["RoleID"] = roleID.ToString();
287 308
288 XmlRpcCall(requestID, "groups.removeRoleFromGroup", param); 309 XmlRpcCall(requestingAgentID, "groups.removeRoleFromGroup", param);
289 } 310 }
290 311
291 public void UpdateGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, 312 public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
292 string title, ulong powers) 313 string title, ulong powers)
293 { 314 {
294 Hashtable param = new Hashtable(); 315 Hashtable param = new Hashtable();
@@ -308,10 +329,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
308 } 329 }
309 param["Powers"] = powers.ToString(); 330 param["Powers"] = powers.ToString();
310 331
311 XmlRpcCall(requestID, "groups.updateGroupRole", param); 332 XmlRpcCall(requestingAgentID, "groups.updateGroupRole", param);
312 } 333 }
313 334
314 public GroupRecord GetGroupRecord(GroupRequestID requestID, UUID GroupID, string GroupName) 335 public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID GroupID, string GroupName)
315 { 336 {
316 Hashtable param = new Hashtable(); 337 Hashtable param = new Hashtable();
317 if (GroupID != UUID.Zero) 338 if (GroupID != UUID.Zero)
@@ -323,7 +344,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
323 param["Name"] = GroupName.ToString(); 344 param["Name"] = GroupName.ToString();
324 } 345 }
325 346
326 Hashtable respData = XmlRpcCall(requestID, "groups.getGroup", param); 347 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroup", param);
327 348
328 if (respData.Contains("error")) 349 if (respData.Contains("error"))
329 { 350 {
@@ -334,12 +355,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
334 355
335 } 356 }
336 357
337 public GroupProfileData GetMemberGroupProfile(GroupRequestID requestID, UUID GroupID, UUID AgentID) 358 public GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID GroupID, UUID AgentID)
338 { 359 {
339 Hashtable param = new Hashtable(); 360 Hashtable param = new Hashtable();
340 param["GroupID"] = GroupID.ToString(); 361 param["GroupID"] = GroupID.ToString();
341 362
342 Hashtable respData = XmlRpcCall(requestID, "groups.getGroup", param); 363 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroup", param);
343 364
344 if (respData.Contains("error")) 365 if (respData.Contains("error"))
345 { 366 {
@@ -347,38 +368,35 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
347 return new GroupProfileData(); 368 return new GroupProfileData();
348 } 369 }
349 370
350 GroupMembershipData MemberInfo = GetAgentGroupMembership(requestID, AgentID, GroupID); 371 GroupMembershipData MemberInfo = GetAgentGroupMembership(requestingAgentID, AgentID, GroupID);
351 GroupProfileData MemberGroupProfile = GroupProfileHashtableToGroupProfileData(respData); 372 GroupProfileData MemberGroupProfile = GroupProfileHashtableToGroupProfileData(respData);
352 373
353 MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle; 374 MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle;
354 MemberGroupProfile.PowersMask = MemberInfo.GroupPowers; 375 MemberGroupProfile.PowersMask = MemberInfo.GroupPowers;
355 376
356 return MemberGroupProfile; 377 return MemberGroupProfile;
357
358 } 378 }
359 379
360 380 public void SetAgentActiveGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
361
362 public void SetAgentActiveGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID)
363 { 381 {
364 Hashtable param = new Hashtable(); 382 Hashtable param = new Hashtable();
365 param["AgentID"] = AgentID.ToString(); 383 param["AgentID"] = AgentID.ToString();
366 param["GroupID"] = GroupID.ToString(); 384 param["GroupID"] = GroupID.ToString();
367 385
368 XmlRpcCall(requestID, "groups.setAgentActiveGroup", param); 386 XmlRpcCall(requestingAgentID, "groups.setAgentActiveGroup", param);
369 } 387 }
370 388
371 public void SetAgentActiveGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID) 389 public void SetAgentActiveGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
372 { 390 {
373 Hashtable param = new Hashtable(); 391 Hashtable param = new Hashtable();
374 param["AgentID"] = AgentID.ToString(); 392 param["AgentID"] = AgentID.ToString();
375 param["GroupID"] = GroupID.ToString(); 393 param["GroupID"] = GroupID.ToString();
376 param["SelectedRoleID"] = RoleID.ToString(); 394 param["SelectedRoleID"] = RoleID.ToString();
377 395
378 XmlRpcCall(requestID, "groups.setAgentGroupInfo", param); 396 XmlRpcCall(requestingAgentID, "groups.setAgentGroupInfo", param);
379 } 397 }
380 398
381 public void SetAgentGroupInfo(GroupRequestID requestID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile) 399 public void SetAgentGroupInfo(UUID requestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile)
382 { 400 {
383 Hashtable param = new Hashtable(); 401 Hashtable param = new Hashtable();
384 param["AgentID"] = AgentID.ToString(); 402 param["AgentID"] = AgentID.ToString();
@@ -386,11 +404,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
386 param["AcceptNotices"] = AcceptNotices ? "1" : "0"; 404 param["AcceptNotices"] = AcceptNotices ? "1" : "0";
387 param["ListInProfile"] = ListInProfile ? "1" : "0"; 405 param["ListInProfile"] = ListInProfile ? "1" : "0";
388 406
389 XmlRpcCall(requestID, "groups.setAgentGroupInfo", param); 407 XmlRpcCall(requestingAgentID, "groups.setAgentGroupInfo", param);
390 408
391 } 409 }
392 410
393 public void AddAgentToGroupInvite(GroupRequestID requestID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID) 411 public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID)
394 { 412 {
395 Hashtable param = new Hashtable(); 413 Hashtable param = new Hashtable();
396 param["InviteID"] = inviteID.ToString(); 414 param["InviteID"] = inviteID.ToString();
@@ -398,16 +416,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
398 param["RoleID"] = roleID.ToString(); 416 param["RoleID"] = roleID.ToString();
399 param["GroupID"] = groupID.ToString(); 417 param["GroupID"] = groupID.ToString();
400 418
401 XmlRpcCall(requestID, "groups.addAgentToGroupInvite", param); 419 XmlRpcCall(requestingAgentID, "groups.addAgentToGroupInvite", param);
402 420
403 } 421 }
404 422
405 public GroupInviteInfo GetAgentToGroupInvite(GroupRequestID requestID, UUID inviteID) 423 public GroupInviteInfo GetAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
406 { 424 {
407 Hashtable param = new Hashtable(); 425 Hashtable param = new Hashtable();
408 param["InviteID"] = inviteID.ToString(); 426 param["InviteID"] = inviteID.ToString();
409 427
410 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentToGroupInvite", param); 428 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentToGroupInvite", param);
411 429
412 if (respData.Contains("error")) 430 if (respData.Contains("error"))
413 { 431 {
@@ -423,60 +441,59 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
423 return inviteInfo; 441 return inviteInfo;
424 } 442 }
425 443
426 public void RemoveAgentToGroupInvite(GroupRequestID requestID, UUID inviteID) 444 public void RemoveAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
427 { 445 {
428 Hashtable param = new Hashtable(); 446 Hashtable param = new Hashtable();
429 param["InviteID"] = inviteID.ToString(); 447 param["InviteID"] = inviteID.ToString();
430 448
431 XmlRpcCall(requestID, "groups.removeAgentToGroupInvite", param); 449 XmlRpcCall(requestingAgentID, "groups.removeAgentToGroupInvite", param);
432 } 450 }
433 451
434 public void AddAgentToGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID) 452 public void AddAgentToGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
435 { 453 {
436 Hashtable param = new Hashtable(); 454 Hashtable param = new Hashtable();
437 param["AgentID"] = AgentID.ToString(); 455 param["AgentID"] = AgentID.ToString();
438 param["GroupID"] = GroupID.ToString(); 456 param["GroupID"] = GroupID.ToString();
439 param["RoleID"] = RoleID.ToString(); 457 param["RoleID"] = RoleID.ToString();
440 458
441 XmlRpcCall(requestID, "groups.addAgentToGroup", param); 459 XmlRpcCall(requestingAgentID, "groups.addAgentToGroup", param);
442 } 460 }
443 461
444 public void RemoveAgentFromGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID) 462 public void RemoveAgentFromGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
445 { 463 {
446 Hashtable param = new Hashtable(); 464 Hashtable param = new Hashtable();
447 param["AgentID"] = AgentID.ToString(); 465 param["AgentID"] = AgentID.ToString();
448 param["GroupID"] = GroupID.ToString(); 466 param["GroupID"] = GroupID.ToString();
449 467
450 XmlRpcCall(requestID, "groups.removeAgentFromGroup", param); 468 XmlRpcCall(requestingAgentID, "groups.removeAgentFromGroup", param);
451 } 469 }
452 470
453 public void AddAgentToGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID) 471 public void AddAgentToGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
454 { 472 {
455 Hashtable param = new Hashtable(); 473 Hashtable param = new Hashtable();
456 param["AgentID"] = AgentID.ToString(); 474 param["AgentID"] = AgentID.ToString();
457 param["GroupID"] = GroupID.ToString(); 475 param["GroupID"] = GroupID.ToString();
458 param["RoleID"] = RoleID.ToString(); 476 param["RoleID"] = RoleID.ToString();
459 477
460 XmlRpcCall(requestID, "groups.addAgentToGroupRole", param); 478 XmlRpcCall(requestingAgentID, "groups.addAgentToGroupRole", param);
461 } 479 }
462 480
463 public void RemoveAgentFromGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID) 481 public void RemoveAgentFromGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
464 { 482 {
465 Hashtable param = new Hashtable(); 483 Hashtable param = new Hashtable();
466 param["AgentID"] = AgentID.ToString(); 484 param["AgentID"] = AgentID.ToString();
467 param["GroupID"] = GroupID.ToString(); 485 param["GroupID"] = GroupID.ToString();
468 param["RoleID"] = RoleID.ToString(); 486 param["RoleID"] = RoleID.ToString();
469 487
470 XmlRpcCall(requestID, "groups.removeAgentFromGroupRole", param); 488 XmlRpcCall(requestingAgentID, "groups.removeAgentFromGroupRole", param);
471 } 489 }
472 490
473 491 public List<DirGroupsReplyData> FindGroups(UUID requestingAgentID, string search)
474 public List<DirGroupsReplyData> FindGroups(GroupRequestID requestID, string search)
475 { 492 {
476 Hashtable param = new Hashtable(); 493 Hashtable param = new Hashtable();
477 param["Search"] = search; 494 param["Search"] = search;
478 495
479 Hashtable respData = XmlRpcCall(requestID, "groups.findGroups", param); 496 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.findGroups", param);
480 497
481 List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>(); 498 List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>();
482 499
@@ -498,13 +515,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
498 return findings; 515 return findings;
499 } 516 }
500 517
501 public GroupMembershipData GetAgentGroupMembership(GroupRequestID requestID, UUID AgentID, UUID GroupID) 518 public GroupMembershipData GetAgentGroupMembership(UUID requestingAgentID, UUID AgentID, UUID GroupID)
502 { 519 {
503 Hashtable param = new Hashtable(); 520 Hashtable param = new Hashtable();
504 param["AgentID"] = AgentID.ToString(); 521 param["AgentID"] = AgentID.ToString();
505 param["GroupID"] = GroupID.ToString(); 522 param["GroupID"] = GroupID.ToString();
506 523
507 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentGroupMembership", param); 524 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentGroupMembership", param);
508 525
509 if (respData.Contains("error")) 526 if (respData.Contains("error"))
510 { 527 {
@@ -516,12 +533,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
516 return data; 533 return data;
517 } 534 }
518 535
519 public GroupMembershipData GetAgentActiveMembership(GroupRequestID requestID, UUID AgentID) 536 public GroupMembershipData GetAgentActiveMembership(UUID requestingAgentID, UUID AgentID)
520 { 537 {
521 Hashtable param = new Hashtable(); 538 Hashtable param = new Hashtable();
522 param["AgentID"] = AgentID.ToString(); 539 param["AgentID"] = AgentID.ToString();
523 540
524 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentActiveMembership", param); 541 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentActiveMembership", param);
525 542
526 if (respData.Contains("error")) 543 if (respData.Contains("error"))
527 { 544 {
@@ -531,13 +548,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
531 return HashTableToGroupMembershipData(respData); 548 return HashTableToGroupMembershipData(respData);
532 } 549 }
533 550
534 551 public List<GroupMembershipData> GetAgentGroupMemberships(UUID requestingAgentID, UUID AgentID)
535 public List<GroupMembershipData> GetAgentGroupMemberships(GroupRequestID requestID, UUID AgentID)
536 { 552 {
537 Hashtable param = new Hashtable(); 553 Hashtable param = new Hashtable();
538 param["AgentID"] = AgentID.ToString(); 554 param["AgentID"] = AgentID.ToString();
539 555
540 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentGroupMemberships", param); 556 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentGroupMemberships", param);
541 557
542 List<GroupMembershipData> memberships = new List<GroupMembershipData>(); 558 List<GroupMembershipData> memberships = new List<GroupMembershipData>();
543 559
@@ -552,13 +568,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
552 return memberships; 568 return memberships;
553 } 569 }
554 570
555 public List<GroupRolesData> GetAgentGroupRoles(GroupRequestID requestID, UUID AgentID, UUID GroupID) 571 public List<GroupRolesData> GetAgentGroupRoles(UUID requestingAgentID, UUID AgentID, UUID GroupID)
556 { 572 {
557 Hashtable param = new Hashtable(); 573 Hashtable param = new Hashtable();
558 param["AgentID"] = AgentID.ToString(); 574 param["AgentID"] = AgentID.ToString();
559 param["GroupID"] = GroupID.ToString(); 575 param["GroupID"] = GroupID.ToString();
560 576
561 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentRoles", param); 577 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentRoles", param);
562 578
563 List<GroupRolesData> Roles = new List<GroupRolesData>(); 579 List<GroupRolesData> Roles = new List<GroupRolesData>();
564 580
@@ -584,12 +600,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
584 600
585 } 601 }
586 602
587 public List<GroupRolesData> GetGroupRoles(GroupRequestID requestID, UUID GroupID) 603 public List<GroupRolesData> GetGroupRoles(UUID requestingAgentID, UUID GroupID)
588 { 604 {
589 Hashtable param = new Hashtable(); 605 Hashtable param = new Hashtable();
590 param["GroupID"] = GroupID.ToString(); 606 param["GroupID"] = GroupID.ToString();
591 607
592 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupRoles", param); 608 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupRoles", param);
593 609
594 List<GroupRolesData> Roles = new List<GroupRolesData>(); 610 List<GroupRolesData> Roles = new List<GroupRolesData>();
595 611
@@ -617,12 +633,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
617 633
618 634
619 635
620 public List<GroupMembersData> GetGroupMembers(GroupRequestID requestID, UUID GroupID) 636 public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID GroupID)
621 { 637 {
622 Hashtable param = new Hashtable(); 638 Hashtable param = new Hashtable();
623 param["GroupID"] = GroupID.ToString(); 639 param["GroupID"] = GroupID.ToString();
624 640
625 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupMembers", param); 641 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupMembers", param);
626 642
627 List<GroupMembersData> members = new List<GroupMembersData>(); 643 List<GroupMembersData> members = new List<GroupMembersData>();
628 644
@@ -650,12 +666,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
650 666
651 } 667 }
652 668
653 public List<GroupRoleMembersData> GetGroupRoleMembers(GroupRequestID requestID, UUID GroupID) 669 public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID)
654 { 670 {
655 Hashtable param = new Hashtable(); 671 Hashtable param = new Hashtable();
656 param["GroupID"] = GroupID.ToString(); 672 param["GroupID"] = GroupID.ToString();
657 673
658 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupRoleMembers", param); 674 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupRoleMembers", param);
659 675
660 List<GroupRoleMembersData> members = new List<GroupRoleMembersData>(); 676 List<GroupRoleMembersData> members = new List<GroupRoleMembersData>();
661 677
@@ -674,12 +690,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
674 return members; 690 return members;
675 } 691 }
676 692
677 public List<GroupNoticeData> GetGroupNotices(GroupRequestID requestID, UUID GroupID) 693 public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID GroupID)
678 { 694 {
679 Hashtable param = new Hashtable(); 695 Hashtable param = new Hashtable();
680 param["GroupID"] = GroupID.ToString(); 696 param["GroupID"] = GroupID.ToString();
681 697
682 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupNotices", param); 698 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupNotices", param);
683 699
684 List<GroupNoticeData> values = new List<GroupNoticeData>(); 700 List<GroupNoticeData> values = new List<GroupNoticeData>();
685 701
@@ -701,12 +717,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
701 return values; 717 return values;
702 718
703 } 719 }
704 public GroupNoticeInfo GetGroupNotice(GroupRequestID requestID, UUID noticeID) 720 public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID)
705 { 721 {
706 Hashtable param = new Hashtable(); 722 Hashtable param = new Hashtable();
707 param["NoticeID"] = noticeID.ToString(); 723 param["NoticeID"] = noticeID.ToString();
708 724
709 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupNotice", param); 725 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupNotice", param);
710 726
711 727
712 if (respData.Contains("error")) 728 if (respData.Contains("error"))
@@ -732,7 +748,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
732 748
733 return data; 749 return data;
734 } 750 }
735 public void AddGroupNotice(GroupRequestID requestID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket) 751 public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
736 { 752 {
737 string binBucket = OpenMetaverse.Utils.BytesToHexString(binaryBucket, ""); 753 string binBucket = OpenMetaverse.Utils.BytesToHexString(binaryBucket, "");
738 754
@@ -745,9 +761,72 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
745 param["BinaryBucket"] = binBucket; 761 param["BinaryBucket"] = binBucket;
746 param["TimeStamp"] = ((uint)Util.UnixTimeSinceEpoch()).ToString(); 762 param["TimeStamp"] = ((uint)Util.UnixTimeSinceEpoch()).ToString();
747 763
748 XmlRpcCall(requestID, "groups.addGroupNotice", param); 764 XmlRpcCall(requestingAgentID, "groups.addGroupNotice", param);
749 } 765 }
750 #endregion 766
767
768
769 #endregion
770
771 #region GroupSessionTracking
772
773 public void ResetAgentGroupChatSessions(UUID agentID)
774 {
775 foreach (List<UUID> agentList in m_groupsAgentsDroppedFromChatSession.Values)
776 {
777 agentList.Remove(agentID);
778 }
779 }
780
781 public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID)
782 {
783 // If we're tracking this group, and we can find them in the tracking, then they've been invited
784 return m_groupsAgentsInvitedToChatSession.ContainsKey(groupID)
785 && m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID);
786 }
787
788 public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID)
789 {
790 // If we're tracking drops for this group,
791 // and we find them, well... then they've dropped
792 return m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID)
793 && m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID);
794 }
795
796 public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID)
797 {
798 if (m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
799 {
800 // If not in dropped list, add
801 if (!m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
802 {
803 m_groupsAgentsDroppedFromChatSession[groupID].Add(agentID);
804 }
805 }
806 }
807
808 public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID)
809 {
810 // Add Session Status if it doesn't exist for this session
811 CreateGroupChatSessionTracking(groupID);
812
813 // If nessesary, remove from dropped list
814 if (m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
815 {
816 m_groupsAgentsDroppedFromChatSession[groupID].Remove(agentID);
817 }
818 }
819
820 private void CreateGroupChatSessionTracking(UUID groupID)
821 {
822 if (!m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
823 {
824 m_groupsAgentsDroppedFromChatSession.Add(groupID, new List<UUID>());
825 m_groupsAgentsInvitedToChatSession.Add(groupID, new List<UUID>());
826 }
827
828 }
829 #endregion
751 830
752 #region XmlRpcHashtableMarshalling 831 #region XmlRpcHashtableMarshalling
753 private GroupProfileData GroupProfileHashtableToGroupProfileData(Hashtable groupProfile) 832 private GroupProfileData GroupProfileHashtableToGroupProfileData(Hashtable groupProfile)
@@ -778,7 +857,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
778 857
779 private GroupRecord GroupProfileHashtableToGroupRecord(Hashtable groupProfile) 858 private GroupRecord GroupProfileHashtableToGroupRecord(Hashtable groupProfile)
780 { 859 {
781
782 GroupRecord group = new GroupRecord(); 860 GroupRecord group = new GroupRecord();
783 group.GroupID = UUID.Parse((string)groupProfile["GroupID"]); 861 group.GroupID = UUID.Parse((string)groupProfile["GroupID"]);
784 group.GroupName = groupProfile["Name"].ToString(); 862 group.GroupName = groupProfile["Name"].ToString();
@@ -797,6 +875,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
797 875
798 return group; 876 return group;
799 } 877 }
878
800 private static GroupMembershipData HashTableToGroupMembershipData(Hashtable respData) 879 private static GroupMembershipData HashTableToGroupMembershipData(Hashtable respData)
801 { 880 {
802 GroupMembershipData data = new GroupMembershipData(); 881 GroupMembershipData data = new GroupMembershipData();
@@ -829,6 +908,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
829 data.MembershipFee = int.Parse((string)respData["MembershipFee"]); 908 data.MembershipFee = int.Parse((string)respData["MembershipFee"]);
830 data.OpenEnrollment = ((string)respData["OpenEnrollment"] == "1"); 909 data.OpenEnrollment = ((string)respData["OpenEnrollment"] == "1");
831 data.ShowInList = ((string)respData["ShowInList"] == "1"); 910 data.ShowInList = ((string)respData["ShowInList"] == "1");
911
832 return data; 912 return data;
833 } 913 }
834 914
@@ -837,15 +917,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
837 /// <summary> 917 /// <summary>
838 /// Encapsulate the XmlRpc call to standardize security and error handling. 918 /// Encapsulate the XmlRpc call to standardize security and error handling.
839 /// </summary> 919 /// </summary>
840 private Hashtable XmlRpcCall(GroupRequestID requestID, string function, Hashtable param) 920 private Hashtable XmlRpcCall(UUID requestingAgentID, string function, Hashtable param)
841 { 921 {
842 if (requestID == null) 922 string UserService;
843 { 923 UUID SessionID;
844 requestID = new GroupRequestID(); 924 GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID);
845 } 925 param.Add("requestingAgentID", requestingAgentID.ToString());
846 param.Add("RequestingAgentID", requestID.AgentID.ToString()); 926 param.Add("RequestingAgentUserService", UserService);
847 param.Add("RequestingAgentUserService", requestID.UserServiceURL); 927 param.Add("RequestingSessionID", SessionID.ToString());
848 param.Add("RequestingSessionID", requestID.SessionID.ToString());
849 928
850 929
851 param.Add("ReadKey", m_groupReadKey); 930 param.Add("ReadKey", m_groupReadKey);
@@ -862,7 +941,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
862 941
863 try 942 try
864 { 943 {
865 resp = req.Send(m_serviceURL, 10000); 944 resp = req.Send(m_groupsServerURI, 10000);
866 } 945 }
867 catch (Exception e) 946 catch (Exception e)
868 { 947 {
@@ -936,15 +1015,49 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
936 } 1015 }
937 } 1016 }
938 1017
1018
1019 /// <summary>
1020 /// Group Request Tokens are an attempt to allow the groups service to authenticate
1021 /// requests.
1022 /// TODO: This broke after the big grid refactor, either find a better way, or discard this
1023 /// </summary>
1024 /// <param name="client"></param>
1025 /// <returns></returns>
1026 private void GetClientGroupRequestID(UUID AgentID, out string UserServiceURL, out UUID SessionID)
1027 {
1028 UserServiceURL = "";
1029 SessionID = UUID.Zero;
939 1030
940 }
941 1031
942 public class GroupNoticeInfo 1032 // Need to rework this based on changes to User Services
943 { 1033 /*
944 public GroupNoticeData noticeData = new GroupNoticeData(); 1034 UserAccount userAccount = m_accountService.GetUserAccount(UUID.Zero,AgentID);
945 public UUID GroupID = UUID.Zero; 1035 if (userAccount == null)
946 public string Message = string.Empty; 1036 {
947 public byte[] BinaryBucket = new byte[0]; 1037 // This should be impossible. If I've been passed a reference to a client
1038 // that client should be registered with the UserService. So something
1039 // is horribly wrong somewhere.
1040
1041 m_log.WarnFormat("[GROUPS]: Could not find a UserServiceURL for {0}", AgentID);
1042
1043 }
1044 else if (userProfile is ForeignUserProfileData)
1045 {
1046 // They aren't from around here
1047 ForeignUserProfileData fupd = (ForeignUserProfileData)userProfile;
1048 UserServiceURL = fupd.UserServerURI;
1049 SessionID = fupd.CurrentAgent.SessionID;
1050
1051 }
1052 else
1053 {
1054 // They're a local user, use this:
1055 UserServiceURL = m_commManager.NetworkServersInfo.UserURL;
1056 SessionID = userProfile.CurrentAgent.SessionID;
1057 }
1058 */
1059 }
1060
948 } 1061 }
949} 1062}
950 1063