aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Avatar
diff options
context:
space:
mode:
authorCharles Krinke2009-04-29 22:31:00 +0000
committerCharles Krinke2009-04-29 22:31:00 +0000
commit8944ab910cc8f62dc6ce567046a92e50b1e2813f (patch)
treeb8042c6ff8bd2598280368cf87d535f8a22af362 /OpenSim/Region/OptionalModules/Avatar
parentCatch another j2k decode exception that can be caused by a bad asset (diff)
downloadopensim-SC-8944ab910cc8f62dc6ce567046a92e50b1e2813f.zip
opensim-SC-8944ab910cc8f62dc6ce567046a92e50b1e2813f.tar.gz
opensim-SC-8944ab910cc8f62dc6ce567046a92e50b1e2813f.tar.bz2
opensim-SC-8944ab910cc8f62dc6ce567046a92e50b1e2813f.tar.xz
Thank you kindly, MCortez for a patch that:
The attached patch provides the necessary infrastructure to support security and authentication features of the xmlrpc server. * Read/Write keys for accessing a Group's xmlrpc service. * Requiring user session verification for write operations.
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar')
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupDataProvider.cs60
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupData.cs163
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsModule.cs213
3 files changed, 280 insertions, 156 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupDataProvider.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupDataProvider.cs
index 3fd6116..43cccf4 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupDataProvider.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupDataProvider.cs
@@ -36,42 +36,42 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
36{ 36{
37 interface IGroupDataProvider 37 interface IGroupDataProvider
38 { 38 {
39 UUID CreateGroup(string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish, UUID founderID); 39 UUID CreateGroup(GroupRequestID requestID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish, UUID founderID);
40 void UpdateGroup(UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish); 40 void UpdateGroup(GroupRequestID requestID, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish);
41 GroupRecord GetGroupRecord(UUID GroupID, string GroupName); 41 GroupRecord GetGroupRecord(GroupRequestID requestID, UUID GroupID, string GroupName);
42 List<DirGroupsReplyData> FindGroups(string search); 42 List<DirGroupsReplyData> FindGroups(GroupRequestID requestID, string search);
43 List<GroupMembersData> GetGroupMembers(UUID GroupID); 43 List<GroupMembersData> GetGroupMembers(GroupRequestID requestID, UUID GroupID);
44 44
45 void AddGroupRole(UUID groupID, UUID roleID, string name, string description, string title, ulong powers); 45 void AddGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers);
46 void UpdateGroupRole(UUID groupID, UUID roleID, string name, string description, string title, ulong powers); 46 void UpdateGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers);
47 void RemoveGroupRole(UUID groupID, UUID roleID); 47 void RemoveGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID);
48 List<GroupRolesData> GetGroupRoles(UUID GroupID); 48 List<GroupRolesData> GetGroupRoles(GroupRequestID requestID, UUID GroupID);
49 List<GroupRoleMembersData> GetGroupRoleMembers(UUID GroupID); 49 List<GroupRoleMembersData> GetGroupRoleMembers(GroupRequestID requestID, UUID GroupID);
50 50
51 void AddAgentToGroup(UUID AgentID, UUID GroupID, UUID RoleID); 51 void AddAgentToGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID);
52 void RemoveAgentFromGroup(UUID AgentID, UUID GroupID); 52 void RemoveAgentFromGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID);
53 53
54 void AddAgentToGroupInvite(UUID inviteID, UUID groupID, UUID roleID, UUID agentID); 54 void AddAgentToGroupInvite(GroupRequestID requestID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID);
55 GroupInviteInfo GetAgentToGroupInvite(UUID inviteID); 55 GroupInviteInfo GetAgentToGroupInvite(GroupRequestID requestID, UUID inviteID);
56 void RemoveAgentToGroupInvite(UUID inviteID); 56 void RemoveAgentToGroupInvite(GroupRequestID requestID, UUID inviteID);
57 57
58 58
59 void AddAgentToGroupRole(UUID AgentID, UUID GroupID, UUID RoleID); 59 void AddAgentToGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID);
60 void RemoveAgentFromGroupRole(UUID AgentID, UUID GroupID, UUID RoleID); 60 void RemoveAgentFromGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID);
61 List<GroupRolesData> GetAgentGroupRoles(UUID AgentID, UUID GroupID); 61 List<GroupRolesData> GetAgentGroupRoles(GroupRequestID requestID, UUID AgentID, UUID GroupID);
62 62
63 void SetAgentActiveGroup(UUID AgentID, UUID GroupID); 63 void SetAgentActiveGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID);
64 GroupMembershipData GetAgentActiveMembership(UUID AgentID); 64 GroupMembershipData GetAgentActiveMembership(GroupRequestID requestID, UUID AgentID);
65 65
66 void SetAgentActiveGroupRole(UUID AgentID, UUID GroupID, UUID RoleID); 66 void SetAgentActiveGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID);
67 void SetAgentGroupInfo(UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile); 67 void SetAgentGroupInfo(GroupRequestID requestID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile);
68 68
69 GroupMembershipData GetAgentGroupMembership(UUID AgentID, UUID GroupID); 69 GroupMembershipData GetAgentGroupMembership(GroupRequestID requestID, UUID AgentID, UUID GroupID);
70 List<GroupMembershipData> GetAgentGroupMemberships(UUID AgentID); 70 List<GroupMembershipData> GetAgentGroupMemberships(GroupRequestID requestID, UUID AgentID);
71 71
72 void AddGroupNotice(UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket); 72 void AddGroupNotice(GroupRequestID requestID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket);
73 GroupNoticeInfo GetGroupNotice(UUID noticeID); 73 GroupNoticeInfo GetGroupNotice(GroupRequestID requestID, UUID noticeID);
74 List<GroupNoticeData> GetGroupNotices(UUID GroupID); 74 List<GroupNoticeData> GetGroupNotices(GroupRequestID requestID, UUID GroupID);
75 } 75 }
76 76
77 public class GroupInviteInfo 77 public class GroupInviteInfo
@@ -82,4 +82,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
82 public UUID InviteID = UUID.Zero; 82 public UUID InviteID = UUID.Zero;
83 } 83 }
84 84
85 public class GroupRequestID
86 {
87 public UUID AgentID = UUID.Zero;
88 public string UserServiceURL = string.Empty;
89 public UUID SessionID = UUID.Zero;
90 }
85} 91}
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupData.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupData.cs
index d941118..a7ef40a 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupData.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupData.cs
@@ -61,7 +61,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
61 61
62 private bool m_disableKeepAlive = false; 62 private bool m_disableKeepAlive = false;
63 63
64 public XmlRpcGroupDataProvider(string serviceURL, bool disableKeepAlive) 64 private string m_groupReadKey = string.Empty;
65 private string m_groupWriteKey = string.Empty;
66
67 public XmlRpcGroupDataProvider(string serviceURL, bool disableKeepAlive, string groupReadKey, string groupWriteKey)
65 { 68 {
66 m_serviceURL = serviceURL.Trim(); 69 m_serviceURL = serviceURL.Trim();
67 m_disableKeepAlive = disableKeepAlive; 70 m_disableKeepAlive = disableKeepAlive;
@@ -71,12 +74,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
71 { 74 {
72 throw new Exception("Please specify a valid ServiceURL for XmlRpcGroupDataProvider in OpenSim.ini, [Groups], XmlRpcServiceURL"); 75 throw new Exception("Please specify a valid ServiceURL for XmlRpcGroupDataProvider in OpenSim.ini, [Groups], XmlRpcServiceURL");
73 } 76 }
77
78 m_groupReadKey = groupReadKey;
79 m_groupWriteKey = groupWriteKey;
74 } 80 }
75 81
76 /// <summary> 82 /// <summary>
77 /// 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. 83 /// 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.
78 /// </summary> 84 /// </summary>
79 public UUID CreateGroup(string name, string charter, bool showInList, UUID insigniaID, 85 public UUID CreateGroup(GroupRequestID requestID, string name, string charter, bool showInList, UUID insigniaID,
80 int membershipFee, bool openEnrollment, bool allowPublish, 86 int membershipFee, bool openEnrollment, bool allowPublish,
81 bool maturePublish, UUID founderID) 87 bool maturePublish, UUID founderID)
82 { 88 {
@@ -145,7 +151,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
145 | GroupPowers.VoteOnProposal; 151 | GroupPowers.VoteOnProposal;
146 param["OwnersPowers"] = ((ulong)OwnerPowers).ToString(); 152 param["OwnersPowers"] = ((ulong)OwnerPowers).ToString();
147 153
148 Hashtable respData = XmlRpcCall("groups.createGroup", param); 154
155
156
157 Hashtable respData = XmlRpcCall(requestID, "groups.createGroup", param);
149 158
150 if (respData.Contains("error")) 159 if (respData.Contains("error"))
151 { 160 {
@@ -157,7 +166,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
157 return UUID.Parse((string)respData["GroupID"]); 166 return UUID.Parse((string)respData["GroupID"]);
158 } 167 }
159 168
160 public void UpdateGroup(UUID groupID, string charter, bool showInList, 169 public void UpdateGroup(GroupRequestID requestID, UUID groupID, string charter, bool showInList,
161 UUID insigniaID, int membershipFee, bool openEnrollment, 170 UUID insigniaID, int membershipFee, bool openEnrollment,
162 bool allowPublish, bool maturePublish) 171 bool allowPublish, bool maturePublish)
163 { 172 {
@@ -171,10 +180,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
171 param["AllowPublish"] = allowPublish == true ? 1 : 0; 180 param["AllowPublish"] = allowPublish == true ? 1 : 0;
172 param["MaturePublish"] = maturePublish == true ? 1 : 0; 181 param["MaturePublish"] = maturePublish == true ? 1 : 0;
173 182
174 XmlRpcCall("groups.updateGroup", param); 183 XmlRpcCall(requestID, "groups.updateGroup", param);
175 } 184 }
176 185
177 public void AddGroupRole(UUID groupID, UUID roleID, string name, string description, 186 public void AddGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description,
178 string title, ulong powers) 187 string title, ulong powers)
179 { 188 {
180 Hashtable param = new Hashtable(); 189 Hashtable param = new Hashtable();
@@ -185,19 +194,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
185 param["Title"] = title; 194 param["Title"] = title;
186 param["Powers"] = powers.ToString(); 195 param["Powers"] = powers.ToString();
187 196
188 XmlRpcCall("groups.addRoleToGroup", param); 197 XmlRpcCall(requestID, "groups.addRoleToGroup", param);
189 } 198 }
190 199
191 public void RemoveGroupRole(UUID groupID, UUID roleID) 200 public void RemoveGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID)
192 { 201 {
193 Hashtable param = new Hashtable(); 202 Hashtable param = new Hashtable();
194 param["GroupID"] = groupID.ToString(); 203 param["GroupID"] = groupID.ToString();
195 param["RoleID"] = roleID.ToString(); 204 param["RoleID"] = roleID.ToString();
196 205
197 XmlRpcCall("groups.removeRoleFromGroup", param); 206 XmlRpcCall(requestID, "groups.removeRoleFromGroup", param);
198 } 207 }
199 208
200 public void UpdateGroupRole(UUID groupID, UUID roleID, string name, string description, 209 public void UpdateGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description,
201 string title, ulong powers) 210 string title, ulong powers)
202 { 211 {
203 Hashtable param = new Hashtable(); 212 Hashtable param = new Hashtable();
@@ -217,10 +226,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
217 } 226 }
218 param["Powers"] = powers.ToString(); 227 param["Powers"] = powers.ToString();
219 228
220 XmlRpcCall("groups.updateGroupRole", param); 229 XmlRpcCall(requestID, "groups.updateGroupRole", param);
221 } 230 }
222 231
223 public GroupRecord GetGroupRecord(UUID GroupID, string GroupName) 232 public GroupRecord GetGroupRecord(GroupRequestID requestID, UUID GroupID, string GroupName)
224 { 233 {
225 Hashtable param = new Hashtable(); 234 Hashtable param = new Hashtable();
226 if (GroupID != UUID.Zero) 235 if (GroupID != UUID.Zero)
@@ -232,8 +241,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
232 param["Name"] = GroupName.ToString(); 241 param["Name"] = GroupName.ToString();
233 } 242 }
234 243
235 244 Hashtable respData = XmlRpcCall(requestID, "groups.getGroup", param);
236 Hashtable respData = XmlRpcCall("groups.getGroup", param);
237 245
238 if (respData.Contains("error")) 246 if (respData.Contains("error"))
239 { 247 {
@@ -241,15 +249,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
241 } 249 }
242 250
243 return GroupProfileHashtableToGroupRecord(respData); 251 return GroupProfileHashtableToGroupRecord(respData);
252
244 } 253 }
245 254
246 public GroupProfileData GetMemberGroupProfile(UUID GroupID, UUID AgentID) 255 public GroupProfileData GetMemberGroupProfile(GroupRequestID requestID, UUID GroupID, UUID AgentID)
247 { 256 {
248 Hashtable param = new Hashtable(); 257 Hashtable param = new Hashtable();
249 param["GroupID"] = GroupID.ToString(); 258 param["GroupID"] = GroupID.ToString();
250 259
251 260 Hashtable respData = XmlRpcCall(requestID, "groups.getGroup", param);
252 Hashtable respData = XmlRpcCall("groups.getGroup", param);
253 261
254 if (respData.Contains("error")) 262 if (respData.Contains("error"))
255 { 263 {
@@ -257,13 +265,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
257 return new GroupProfileData(); 265 return new GroupProfileData();
258 } 266 }
259 267
260 GroupMembershipData MemberInfo = GetAgentGroupMembership(AgentID, GroupID); 268 GroupMembershipData MemberInfo = GetAgentGroupMembership(requestID, AgentID, GroupID);
261 GroupProfileData MemberGroupProfile = GroupProfileHashtableToGroupProfileData(respData); 269 GroupProfileData MemberGroupProfile = GroupProfileHashtableToGroupProfileData(respData);
262 270
263 MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle; 271 MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle;
264 MemberGroupProfile.PowersMask = MemberInfo.GroupPowers; 272 MemberGroupProfile.PowersMask = MemberInfo.GroupPowers;
265 273
266 return MemberGroupProfile; 274 return MemberGroupProfile;
275
267 } 276 }
268 277
269 private GroupProfileData GroupProfileHashtableToGroupProfileData(Hashtable groupProfile) 278 private GroupProfileData GroupProfileHashtableToGroupProfileData(Hashtable groupProfile)
@@ -314,26 +323,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
314 return group; 323 return group;
315 } 324 }
316 325
317 public void SetAgentActiveGroup(UUID AgentID, UUID GroupID) 326 public void SetAgentActiveGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID)
318 { 327 {
319 Hashtable param = new Hashtable(); 328 Hashtable param = new Hashtable();
320 param["AgentID"] = AgentID.ToString(); 329 param["AgentID"] = AgentID.ToString();
321 param["GroupID"] = GroupID.ToString(); 330 param["GroupID"] = GroupID.ToString();
322 331
323 XmlRpcCall("groups.setAgentActiveGroup", param); 332 XmlRpcCall(requestID, "groups.setAgentActiveGroup", param);
324 } 333 }
325 334
326 public void SetAgentActiveGroupRole(UUID AgentID, UUID GroupID, UUID RoleID) 335 public void SetAgentActiveGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID)
327 { 336 {
328 Hashtable param = new Hashtable(); 337 Hashtable param = new Hashtable();
329 param["AgentID"] = AgentID.ToString(); 338 param["AgentID"] = AgentID.ToString();
330 param["GroupID"] = GroupID.ToString(); 339 param["GroupID"] = GroupID.ToString();
331 param["SelectedRoleID"] = RoleID.ToString(); 340 param["SelectedRoleID"] = RoleID.ToString();
332 341
333 XmlRpcCall("groups.setAgentGroupInfo", param); 342 XmlRpcCall(requestID, "groups.setAgentGroupInfo", param);
334 } 343 }
335 344
336 public void SetAgentGroupInfo(UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile) 345 public void SetAgentGroupInfo(GroupRequestID requestID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile)
337 { 346 {
338 Hashtable param = new Hashtable(); 347 Hashtable param = new Hashtable();
339 param["AgentID"] = AgentID.ToString(); 348 param["AgentID"] = AgentID.ToString();
@@ -341,10 +350,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
341 param["AcceptNotices"] = AcceptNotices ? "1" : "0"; 350 param["AcceptNotices"] = AcceptNotices ? "1" : "0";
342 param["ListInProfile"] = ListInProfile ? "1" : "0"; 351 param["ListInProfile"] = ListInProfile ? "1" : "0";
343 352
344 XmlRpcCall("groups.setAgentGroupInfo", param); 353 XmlRpcCall(requestID, "groups.setAgentGroupInfo", param);
354
345 } 355 }
346 356
347 public void AddAgentToGroupInvite(UUID inviteID, UUID groupID, UUID roleID, UUID agentID) 357 public void AddAgentToGroupInvite(GroupRequestID requestID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID)
348 { 358 {
349 Hashtable param = new Hashtable(); 359 Hashtable param = new Hashtable();
350 param["InviteID"] = inviteID.ToString(); 360 param["InviteID"] = inviteID.ToString();
@@ -352,15 +362,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
352 param["RoleID"] = roleID.ToString(); 362 param["RoleID"] = roleID.ToString();
353 param["GroupID"] = groupID.ToString(); 363 param["GroupID"] = groupID.ToString();
354 364
355 XmlRpcCall("groups.addAgentToGroupInvite", param); 365 XmlRpcCall(requestID, "groups.addAgentToGroupInvite", param);
366
356 } 367 }
357 368
358 public GroupInviteInfo GetAgentToGroupInvite(UUID inviteID) 369 public GroupInviteInfo GetAgentToGroupInvite(GroupRequestID requestID, UUID inviteID)
359 { 370 {
360 Hashtable param = new Hashtable(); 371 Hashtable param = new Hashtable();
361 param["InviteID"] = inviteID.ToString(); 372 param["InviteID"] = inviteID.ToString();
362 373
363 Hashtable respData = XmlRpcCall("groups.getAgentToGroupInvite", param); 374 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentToGroupInvite", param);
364 375
365 if (respData.Contains("error")) 376 if (respData.Contains("error"))
366 { 377 {
@@ -376,59 +387,60 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
376 return inviteInfo; 387 return inviteInfo;
377 } 388 }
378 389
379 public void RemoveAgentToGroupInvite(UUID inviteID) 390 public void RemoveAgentToGroupInvite(GroupRequestID requestID, UUID inviteID)
380 { 391 {
381 Hashtable param = new Hashtable(); 392 Hashtable param = new Hashtable();
382 param["InviteID"] = inviteID.ToString(); 393 param["InviteID"] = inviteID.ToString();
383 394
384 XmlRpcCall("groups.removeAgentToGroupInvite", param); 395 XmlRpcCall(requestID, "groups.removeAgentToGroupInvite", param);
385 } 396 }
386 397
387 public void AddAgentToGroup(UUID AgentID, UUID GroupID, UUID RoleID) 398 public void AddAgentToGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID)
388 { 399 {
389 Hashtable param = new Hashtable(); 400 Hashtable param = new Hashtable();
390 param["AgentID"] = AgentID.ToString(); 401 param["AgentID"] = AgentID.ToString();
391 param["GroupID"] = GroupID.ToString(); 402 param["GroupID"] = GroupID.ToString();
392 param["RoleID"] = RoleID.ToString(); 403 param["RoleID"] = RoleID.ToString();
393 404
394 XmlRpcCall("groups.addAgentToGroup", param); 405 XmlRpcCall(requestID, "groups.addAgentToGroup", param);
395 } 406 }
396 407
397 public void RemoveAgentFromGroup(UUID AgentID, UUID GroupID) 408 public void RemoveAgentFromGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID)
398 { 409 {
399 Hashtable param = new Hashtable(); 410 Hashtable param = new Hashtable();
400 param["AgentID"] = AgentID.ToString(); 411 param["AgentID"] = AgentID.ToString();
401 param["GroupID"] = GroupID.ToString(); 412 param["GroupID"] = GroupID.ToString();
402 413
403 XmlRpcCall("groups.removeAgentFromGroup", param); 414 XmlRpcCall(requestID, "groups.removeAgentFromGroup", param);
404 } 415 }
405 416
406 public void AddAgentToGroupRole(UUID AgentID, UUID GroupID, UUID RoleID) 417 public void AddAgentToGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID)
407 { 418 {
408 Hashtable param = new Hashtable(); 419 Hashtable param = new Hashtable();
409 param["AgentID"] = AgentID.ToString(); 420 param["AgentID"] = AgentID.ToString();
410 param["GroupID"] = GroupID.ToString(); 421 param["GroupID"] = GroupID.ToString();
411 param["RoleID"] = RoleID.ToString(); 422 param["RoleID"] = RoleID.ToString();
412 423
413 XmlRpcCall("groups.addAgentToGroupRole", param); 424 XmlRpcCall(requestID, "groups.addAgentToGroupRole", param);
414 } 425 }
415 426
416 public void RemoveAgentFromGroupRole(UUID AgentID, UUID GroupID, UUID RoleID) 427 public void RemoveAgentFromGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID)
417 { 428 {
418 Hashtable param = new Hashtable(); 429 Hashtable param = new Hashtable();
419 param["AgentID"] = AgentID.ToString(); 430 param["AgentID"] = AgentID.ToString();
420 param["GroupID"] = GroupID.ToString(); 431 param["GroupID"] = GroupID.ToString();
421 param["RoleID"] = RoleID.ToString(); 432 param["RoleID"] = RoleID.ToString();
422 433
423 XmlRpcCall("groups.removeAgentFromGroupRole", param); 434 XmlRpcCall(requestID, "groups.removeAgentFromGroupRole", param);
424 } 435 }
425 436
426 public List<DirGroupsReplyData> FindGroups(string search) 437
438 public List<DirGroupsReplyData> FindGroups(GroupRequestID requestID, string search)
427 { 439 {
428 Hashtable param = new Hashtable(); 440 Hashtable param = new Hashtable();
429 param["Search"] = search; 441 param["Search"] = search;
430 442
431 Hashtable respData = XmlRpcCall("groups.findGroups", param); 443 Hashtable respData = XmlRpcCall(requestID, "groups.findGroups", param);
432 444
433 List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>(); 445 List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>();
434 446
@@ -450,13 +462,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
450 return findings; 462 return findings;
451 } 463 }
452 464
453 public GroupMembershipData GetAgentGroupMembership(UUID AgentID, UUID GroupID) 465 public GroupMembershipData GetAgentGroupMembership(GroupRequestID requestID, UUID AgentID, UUID GroupID)
454 { 466 {
455 Hashtable param = new Hashtable(); 467 Hashtable param = new Hashtable();
456 param["AgentID"] = AgentID.ToString(); 468 param["AgentID"] = AgentID.ToString();
457 param["GroupID"] = GroupID.ToString(); 469 param["GroupID"] = GroupID.ToString();
458 470
459 Hashtable respData = XmlRpcCall("groups.getAgentGroupMembership", param); 471 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentGroupMembership", param);
460 472
461 if (respData.Contains("error")) 473 if (respData.Contains("error"))
462 { 474 {
@@ -468,12 +480,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
468 return data; 480 return data;
469 } 481 }
470 482
471 public GroupMembershipData GetAgentActiveMembership(UUID AgentID) 483 public GroupMembershipData GetAgentActiveMembership(GroupRequestID requestID, UUID AgentID)
472 { 484 {
473 Hashtable param = new Hashtable(); 485 Hashtable param = new Hashtable();
474 param["AgentID"] = AgentID.ToString(); 486 param["AgentID"] = AgentID.ToString();
475 487
476 Hashtable respData = XmlRpcCall("groups.getAgentActiveMembership", param); 488 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentActiveMembership", param);
477 489
478 if (respData.Contains("error")) 490 if (respData.Contains("error"))
479 { 491 {
@@ -483,12 +495,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
483 return HashTableToGroupMembershipData(respData); 495 return HashTableToGroupMembershipData(respData);
484 } 496 }
485 497
486 public List<GroupMembershipData> GetAgentGroupMemberships(UUID AgentID) 498
499 public List<GroupMembershipData> GetAgentGroupMemberships(GroupRequestID requestID, UUID AgentID)
487 { 500 {
488 Hashtable param = new Hashtable(); 501 Hashtable param = new Hashtable();
489 param["AgentID"] = AgentID.ToString(); 502 param["AgentID"] = AgentID.ToString();
490 503
491 Hashtable respData = XmlRpcCall("groups.getAgentGroupMemberships", param); 504 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentGroupMemberships", param);
492 505
493 List<GroupMembershipData> memberships = new List<GroupMembershipData>(); 506 List<GroupMembershipData> memberships = new List<GroupMembershipData>();
494 507
@@ -503,13 +516,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
503 return memberships; 516 return memberships;
504 } 517 }
505 518
506 public List<GroupRolesData> GetAgentGroupRoles(UUID AgentID, UUID GroupID) 519 public List<GroupRolesData> GetAgentGroupRoles(GroupRequestID requestID, UUID AgentID, UUID GroupID)
507 { 520 {
508 Hashtable param = new Hashtable(); 521 Hashtable param = new Hashtable();
509 param["AgentID"] = AgentID.ToString(); 522 param["AgentID"] = AgentID.ToString();
510 param["GroupID"] = GroupID.ToString(); 523 param["GroupID"] = GroupID.ToString();
511 524
512 Hashtable respData = XmlRpcCall("groups.getAgentRoles", param); 525 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentRoles", param);
513 526
514 List<GroupRolesData> Roles = new List<GroupRolesData>(); 527 List<GroupRolesData> Roles = new List<GroupRolesData>();
515 528
@@ -531,14 +544,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
531 } 544 }
532 545
533 return Roles; 546 return Roles;
547
548
534 } 549 }
535 550
536 public List<GroupRolesData> GetGroupRoles(UUID GroupID) 551 public List<GroupRolesData> GetGroupRoles(GroupRequestID requestID, UUID GroupID)
537 { 552 {
538 Hashtable param = new Hashtable(); 553 Hashtable param = new Hashtable();
539 param["GroupID"] = GroupID.ToString(); 554 param["GroupID"] = GroupID.ToString();
540 555
541 Hashtable respData = XmlRpcCall("groups.getGroupRoles", param); 556 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupRoles", param);
542 557
543 List<GroupRolesData> Roles = new List<GroupRolesData>(); 558 List<GroupRolesData> Roles = new List<GroupRolesData>();
544 559
@@ -561,6 +576,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
561 } 576 }
562 577
563 return Roles; 578 return Roles;
579
564 } 580 }
565 581
566 private static GroupMembershipData HashTableToGroupMembershipData(Hashtable respData) 582 private static GroupMembershipData HashTableToGroupMembershipData(Hashtable respData)
@@ -598,12 +614,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
598 return data; 614 return data;
599 } 615 }
600 616
601 public List<GroupMembersData> GetGroupMembers(UUID GroupID) 617 public List<GroupMembersData> GetGroupMembers(GroupRequestID requestID, UUID GroupID)
602 { 618 {
603 Hashtable param = new Hashtable(); 619 Hashtable param = new Hashtable();
604 param["GroupID"] = GroupID.ToString(); 620 param["GroupID"] = GroupID.ToString();
605 621
606 Hashtable respData = XmlRpcCall("groups.getGroupMembers", param); 622 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupMembers", param);
607 623
608 List<GroupMembersData> members = new List<GroupMembersData>(); 624 List<GroupMembersData> members = new List<GroupMembersData>();
609 625
@@ -628,14 +644,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
628 } 644 }
629 645
630 return members; 646 return members;
647
631 } 648 }
632 649
633 public List<GroupRoleMembersData> GetGroupRoleMembers(UUID GroupID) 650 public List<GroupRoleMembersData> GetGroupRoleMembers(GroupRequestID requestID, UUID GroupID)
634 { 651 {
635 Hashtable param = new Hashtable(); 652 Hashtable param = new Hashtable();
636 param["GroupID"] = GroupID.ToString(); 653 param["GroupID"] = GroupID.ToString();
637 654
638 Hashtable respData = XmlRpcCall("groups.getGroupRoleMembers", param); 655 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupRoleMembers", param);
639 656
640 List<GroupRoleMembersData> members = new List<GroupRoleMembersData>(); 657 List<GroupRoleMembersData> members = new List<GroupRoleMembersData>();
641 658
@@ -651,16 +668,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
651 members.Add(data); 668 members.Add(data);
652 } 669 }
653 } 670 }
654
655 return members; 671 return members;
656 } 672 }
657 673
658 public List<GroupNoticeData> GetGroupNotices(UUID GroupID) 674 public List<GroupNoticeData> GetGroupNotices(GroupRequestID requestID, UUID GroupID)
659 { 675 {
660 Hashtable param = new Hashtable(); 676 Hashtable param = new Hashtable();
661 param["GroupID"] = GroupID.ToString(); 677 param["GroupID"] = GroupID.ToString();
662 678
663 Hashtable respData = XmlRpcCall("groups.getGroupNotices", param); 679 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupNotices", param);
664 680
665 List<GroupNoticeData> values = new List<GroupNoticeData>(); 681 List<GroupNoticeData> values = new List<GroupNoticeData>();
666 682
@@ -679,16 +695,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
679 values.Add(data); 695 values.Add(data);
680 } 696 }
681 } 697 }
682
683 return values; 698 return values;
699
684 } 700 }
685 701 public GroupNoticeInfo GetGroupNotice(GroupRequestID requestID, UUID noticeID)
686 public GroupNoticeInfo GetGroupNotice(UUID noticeID)
687 { 702 {
688 Hashtable param = new Hashtable(); 703 Hashtable param = new Hashtable();
689 param["NoticeID"] = noticeID.ToString(); 704 param["NoticeID"] = noticeID.ToString();
690 705
691 Hashtable respData = XmlRpcCall("groups.getGroupNotice", param); 706 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupNotice", param);
692 707
693 708
694 if (respData.Contains("error")) 709 if (respData.Contains("error"))
@@ -714,8 +729,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
714 729
715 return data; 730 return data;
716 } 731 }
717 732 public void AddGroupNotice(GroupRequestID requestID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
718 public void AddGroupNotice(UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
719 { 733 {
720 string binBucket = OpenMetaverse.Utils.BytesToHexString(binaryBucket, ""); 734 string binBucket = OpenMetaverse.Utils.BytesToHexString(binaryBucket, "");
721 735
@@ -728,11 +742,24 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
728 param["BinaryBucket"] = binBucket; 742 param["BinaryBucket"] = binBucket;
729 param["TimeStamp"] = ((uint)Util.UnixTimeSinceEpoch()).ToString(); 743 param["TimeStamp"] = ((uint)Util.UnixTimeSinceEpoch()).ToString();
730 744
731 XmlRpcCall("groups.addGroupNotice", param); 745 XmlRpcCall(requestID, "groups.addGroupNotice", param);
732 } 746 }
733 747
734 private Hashtable XmlRpcCall(string function, Hashtable param) 748 private Hashtable XmlRpcCall(GroupRequestID requestID, string function, Hashtable param)
735 { 749 {
750 if (requestID == null)
751 {
752 requestID = new GroupRequestID();
753 }
754 param.Add("RequestingAgentID", requestID.AgentID.ToString());
755 param.Add("RequestingAgentUserService", requestID.UserServiceURL);
756 param.Add("RequestingSessionID", requestID.SessionID.ToString());
757
758
759 param.Add("ReadKey", m_groupReadKey);
760 param.Add("WriteKey", m_groupWriteKey);
761
762
736 IList parameters = new ArrayList(); 763 IList parameters = new ArrayList();
737 parameters.Add(param); 764 parameters.Add(param);
738 765
@@ -758,9 +785,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
758 m_log.ErrorFormat("[XMLRPCGROUPDATA]: An error has occured while attempting to access the XmlRpcGroups server method: {0}", function); 785 m_log.ErrorFormat("[XMLRPCGROUPDATA]: An error has occured while attempting to access the XmlRpcGroups server method: {0}", function);
759 m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", e.ToString()); 786 m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", e.ToString());
760 787
761 foreach (KeyValuePair<object, object> kvp in param) 788
789 foreach (string key in param.Keys)
762 { 790 {
763 m_log.WarnFormat("[XMLRPCGROUPDATA]: {0} :: {1}", kvp.Key.ToString(), kvp.Value.ToString()); 791 m_log.WarnFormat("[XMLRPCGROUPDATA]: {0} :: {1}", key, param[key].ToString());
764 } 792 }
765 793
766 Hashtable respData = new Hashtable(); 794 Hashtable respData = new Hashtable();
@@ -817,6 +845,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
817 845
818 } 846 }
819 } 847 }
848
820 } 849 }
821 850
822 public class GroupNoticeInfo 851 public class GroupNoticeInfo
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsModule.cs
index 3337ccd..5ba7eff 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsModule.cs
@@ -28,8 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31 31using System.Timers;
32using System.Collections;
33 32
34using log4net; 33using log4net;
35using Nini.Config; 34using Nini.Config;
@@ -61,6 +60,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
61 /// XmlRpcMessagingEnabled = true 60 /// XmlRpcMessagingEnabled = true
62 /// XmlRpcNoticesEnabled = true 61 /// XmlRpcNoticesEnabled = true
63 /// XmlRpcDebugEnabled = true 62 /// XmlRpcDebugEnabled = true
63 /// XmlRpcServiceReadKey = 1234
64 /// XmlRpcServiceWriteKey = 1234
64 /// 65 ///
65 /// ; Disables HTTP Keep-Alive for Groups Module HTTP Requests, work around for 66 /// ; Disables HTTP Keep-Alive for Groups Module HTTP Requests, work around for
66 /// ; a problem discovered on some Windows based region servers. Only disable 67 /// ; a problem discovered on some Windows based region servers. Only disable
@@ -79,6 +80,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
79 80
80 private IGroupDataProvider m_groupData = null; 81 private IGroupDataProvider m_groupData = null;
81 82
83 class GroupRequestIDInfo
84 {
85 public GroupRequestID RequestID = new GroupRequestID();
86 public DateTime LastUsedTMStamp = DateTime.MinValue;
87 }
88 private Dictionary<UUID, GroupRequestIDInfo> m_clientRequestIDInfo = new Dictionary<UUID, GroupRequestIDInfo>();
89 private const int m_clientRequestIDFlushTimeOut = 300000; // Every 5 minutes
90 private Timer m_clientRequestIDFlushTimer = new Timer();
91
92
82 // Configuration settings 93 // Configuration settings
83 private const string m_defaultXmlRpcServiceURL = "http://osflotsam.org/xmlrpc.php"; 94 private const string m_defaultXmlRpcServiceURL = "http://osflotsam.org/xmlrpc.php";
84 private bool m_groupsEnabled = false; 95 private bool m_groupsEnabled = false;
@@ -119,12 +130,34 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
119 string ServiceURL = groupsConfig.GetString("XmlRpcServiceURL", m_defaultXmlRpcServiceURL); 130 string ServiceURL = groupsConfig.GetString("XmlRpcServiceURL", m_defaultXmlRpcServiceURL);
120 bool DisableKeepAlive = groupsConfig.GetBoolean("XmlRpcDisableKeepAlive", false); 131 bool DisableKeepAlive = groupsConfig.GetBoolean("XmlRpcDisableKeepAlive", false);
121 132
122 m_groupData = new XmlRpcGroupDataProvider(ServiceURL, DisableKeepAlive); 133 string ServiceReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty);
134 string ServiceWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty);
135
136 m_groupData = new XmlRpcGroupDataProvider(ServiceURL, DisableKeepAlive, ServiceReadKey, ServiceWriteKey);
123 m_log.InfoFormat("[GROUPS]: XmlRpc Service URL set to: {0}", ServiceURL); 137 m_log.InfoFormat("[GROUPS]: XmlRpc Service URL set to: {0}", ServiceURL);
124 138
125 m_groupNoticesEnabled = groupsConfig.GetBoolean("XmlRpcNoticesEnabled", true); 139 m_groupNoticesEnabled = groupsConfig.GetBoolean("XmlRpcNoticesEnabled", true);
126 m_debugEnabled = groupsConfig.GetBoolean("XmlRpcDebugEnabled", true); 140 m_debugEnabled = groupsConfig.GetBoolean("XmlRpcDebugEnabled", true);
127 141
142 m_clientRequestIDFlushTimer.Interval = m_clientRequestIDFlushTimeOut;
143 m_clientRequestIDFlushTimer.Elapsed += FlushClientRequestIDInfoCache;
144 m_clientRequestIDFlushTimer.Start();
145 }
146 }
147
148 void FlushClientRequestIDInfoCache(object sender, ElapsedEventArgs e)
149 {
150 lock (m_clientRequestIDInfo)
151 {
152 TimeSpan cacheTimeout = new TimeSpan(0,0, m_clientRequestIDFlushTimeOut / 1000);
153 UUID[] CurrentKeys = new UUID[m_clientRequestIDInfo.Count];
154 foreach (UUID key in CurrentKeys)
155 {
156 if (DateTime.Now - m_clientRequestIDInfo[key].LastUsedTMStamp > cacheTimeout)
157 {
158 m_clientRequestIDInfo.Remove(key);
159 }
160 }
128 } 161 }
129 } 162 }
130 163
@@ -188,6 +221,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
188 return; 221 return;
189 222
190 if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down XmlRpcGroups module."); 223 if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down XmlRpcGroups module.");
224
225 m_clientRequestIDFlushTimer.Stop();
191 } 226 }
192 227
193 public string Name 228 public string Name
@@ -218,13 +253,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
218 253
219 // Used for Notices and Group Invites/Accept/Reject 254 // Used for Notices and Group Invites/Accept/Reject
220 client.OnInstantMessage += OnInstantMessage; 255 client.OnInstantMessage += OnInstantMessage;
221 256
257 lock (m_clientRequestIDInfo)
258 {
259 if (m_clientRequestIDInfo.ContainsKey(client.AgentId))
260 {
261 // flush any old RequestID information
262 m_clientRequestIDInfo.Remove(client.AgentId);
263 }
264 }
222 SendAgentGroupDataUpdate(client, client.AgentId); 265 SendAgentGroupDataUpdate(client, client.AgentId);
223 } 266 }
224 267
225 private void OnRequestAvatarProperties(IClientAPI remoteClient, UUID avatarID) 268 private void OnRequestAvatarProperties(IClientAPI remoteClient, UUID avatarID)
226 { 269 {
227 GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(avatarID).ToArray(); 270 GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(remoteClient), avatarID).ToArray();
228 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups); 271 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups);
229 } 272 }
230 273
@@ -270,7 +313,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
270 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called with queryText({1}) queryFlags({2}) queryStart({3})", System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart); 313 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called with queryText({1}) queryFlags({2}) queryStart({3})", System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart);
271 314
272 // TODO: This currently ignores pretty much all the query flags including Mature and sort order 315 // TODO: This currently ignores pretty much all the query flags including Mature and sort order
273 remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(queryText).ToArray()); 316 remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetClientGroupRequestID(remoteClient), queryText).ToArray());
274 } 317 }
275 318
276 } 319 }
@@ -284,7 +327,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
284 string activeGroupName = string.Empty; 327 string activeGroupName = string.Empty;
285 ulong activeGroupPowers = (ulong)GroupPowers.None; 328 ulong activeGroupPowers = (ulong)GroupPowers.None;
286 329
287 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(dataForAgentID); 330 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetClientGroupRequestID(remoteClient), dataForAgentID);
288 if (membership != null) 331 if (membership != null)
289 { 332 {
290 activeGroupID = membership.GroupID; 333 activeGroupID = membership.GroupID;
@@ -297,13 +340,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
297 SendScenePresenceUpdate(dataForAgentID, activeGroupTitle); 340 SendScenePresenceUpdate(dataForAgentID, activeGroupTitle);
298 } 341 }
299 342
300 private void HandleUUIDGroupNameRequest(UUID GroupID,IClientAPI remote_client) 343 private void HandleUUIDGroupNameRequest(UUID GroupID,IClientAPI remoteClient)
301 { 344 {
302 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 345 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
303 346
304 string GroupName; 347 string GroupName;
305 348
306 GroupRecord group = m_groupData.GetGroupRecord(GroupID, null); 349 GroupRecord group = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), GroupID, null);
307 if (group != null) 350 if (group != null)
308 { 351 {
309 GroupName = group.GroupName; 352 GroupName = group.GroupName;
@@ -313,7 +356,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
313 GroupName = "Unknown"; 356 GroupName = "Unknown";
314 } 357 }
315 358
316 remote_client.SendGroupNameReply(GroupID, GroupName); 359 remoteClient.SendGroupNameReply(GroupID, GroupName);
317 } 360 }
318 361
319 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) 362 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im)
@@ -324,7 +367,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
324 if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)) 367 if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline))
325 { 368 {
326 UUID inviteID = new UUID(im.imSessionID); 369 UUID inviteID = new UUID(im.imSessionID);
327 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(inviteID); 370 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID);
328 371
329 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Invite is for Agent {0} to Group {1}.", inviteInfo.AgentID, inviteInfo.GroupID); 372 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Invite is for Agent {0} to Group {1}.", inviteInfo.AgentID, inviteInfo.GroupID);
330 373
@@ -337,7 +380,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
337 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received an accept invite notice."); 380 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received an accept invite notice.");
338 381
339 // and the sessionid is the role 382 // and the sessionid is the role
340 m_groupData.AddAgentToGroup(inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID); 383 m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID);
341 384
342 GridInstantMessage msg = new GridInstantMessage(); 385 GridInstantMessage msg = new GridInstantMessage();
343 msg.imSessionID = UUID.Zero.Guid; 386 msg.imSessionID = UUID.Zero.Guid;
@@ -361,14 +404,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
361 // TODO: If the inviter is still online, they need an agent dataupdate 404 // TODO: If the inviter is still online, they need an agent dataupdate
362 // and maybe group membership updates for the invitee 405 // and maybe group membership updates for the invitee
363 406
364 m_groupData.RemoveAgentToGroupInvite(inviteID); 407 m_groupData.RemoveAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID);
365 } 408 }
366 409
367 // Reject 410 // Reject
368 if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline) 411 if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)
369 { 412 {
370 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received a reject invite notice."); 413 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received a reject invite notice.");
371 m_groupData.RemoveAgentToGroupInvite(inviteID); 414 m_groupData.RemoveAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID);
372 } 415 }
373 } 416 }
374 } 417 }
@@ -382,7 +425,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
382 } 425 }
383 426
384 UUID GroupID = new UUID(im.toAgentID); 427 UUID GroupID = new UUID(im.toAgentID);
385 if (m_groupData.GetGroupRecord(GroupID, null) != null) 428 if (m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), GroupID, null) != null)
386 { 429 {
387 UUID NoticeID = UUID.Random(); 430 UUID NoticeID = UUID.Random();
388 string Subject = im.message.Substring(0, im.message.IndexOf('|')); 431 string Subject = im.message.Substring(0, im.message.IndexOf('|'));
@@ -422,14 +465,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
422 bucket[18] = 0; //dunno 465 bucket[18] = 0; //dunno
423 } 466 }
424 467
425 m_groupData.AddGroupNotice(GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket); 468 m_groupData.AddGroupNotice(GetClientGroupRequestID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket);
426 if (OnNewGroupNotice != null) 469 if (OnNewGroupNotice != null)
427 { 470 {
428 OnNewGroupNotice(GroupID, NoticeID); 471 OnNewGroupNotice(GroupID, NoticeID);
429 } 472 }
430 473
431 // Send notice out to everyone that wants notices 474 // Send notice out to everyone that wants notices
432 foreach (GroupMembersData member in m_groupData.GetGroupMembers(GroupID)) 475 foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetClientGroupRequestID(remoteClient), GroupID))
433 { 476 {
434 if (member.AcceptNotices) 477 if (member.AcceptNotices)
435 { 478 {
@@ -501,14 +544,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
501 544
502 public GroupRecord GetGroupRecord(UUID GroupID) 545 public GroupRecord GetGroupRecord(UUID GroupID)
503 { 546 {
504 return m_groupData.GetGroupRecord(GroupID, null); 547 return m_groupData.GetGroupRecord(null, GroupID, null);
505 } 548 }
506 549
507 public void ActivateGroup(IClientAPI remoteClient, UUID groupID) 550 public void ActivateGroup(IClientAPI remoteClient, UUID groupID)
508 { 551 {
509 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 552 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
510 553
511 m_groupData.SetAgentActiveGroup(remoteClient.AgentId, groupID); 554 m_groupData.SetAgentActiveGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID);
512 555
513 // Changing active group changes title, active powers, all kinds of things 556 // Changing active group changes title, active powers, all kinds of things
514 // anyone who is in any region that can see this client, should probably be 557 // anyone who is in any region that can see this client, should probably be
@@ -524,8 +567,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
524 { 567 {
525 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 568 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
526 569
527 List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(remoteClient.AgentId, groupID); 570 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
528 GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(remoteClient.AgentId, groupID); 571
572 List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(grID, remoteClient.AgentId, groupID);
573 GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID);
529 574
530 List<GroupTitlesData> titles = new List<GroupTitlesData>(); 575 List<GroupTitlesData> titles = new List<GroupTitlesData>();
531 foreach (GroupRolesData role in agentRoles) 576 foreach (GroupRolesData role in agentRoles)
@@ -548,7 +593,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
548 { 593 {
549 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 594 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
550 595
551 List<GroupMembersData> data = m_groupData.GetGroupMembers(groupID); 596 List<GroupMembersData> data = m_groupData.GetGroupMembers(GetClientGroupRequestID(remoteClient), groupID);
552 if (m_debugEnabled) 597 if (m_debugEnabled)
553 { 598 {
554 foreach (GroupMembersData member in data) 599 foreach (GroupMembersData member in data)
@@ -565,7 +610,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
565 { 610 {
566 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 611 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
567 612
568 List<GroupRolesData> data = m_groupData.GetGroupRoles(groupID); 613 List<GroupRolesData> data = m_groupData.GetGroupRoles(GetClientGroupRequestID(remoteClient), groupID);
569 614
570 if (m_debugEnabled) 615 if (m_debugEnabled)
571 { 616 {
@@ -583,7 +628,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
583 { 628 {
584 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 629 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
585 630
586 List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(groupID); 631 List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetClientGroupRequestID(remoteClient), groupID);
587 632
588 if (m_debugEnabled) 633 if (m_debugEnabled)
589 { 634 {
@@ -604,15 +649,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
604 649
605 GroupProfileData profile = new GroupProfileData(); 650 GroupProfileData profile = new GroupProfileData();
606 651
607 GroupRecord groupInfo = m_groupData.GetGroupRecord(groupID, null); 652 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
653
654 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), groupID, null);
608 if (groupInfo != null) 655 if (groupInfo != null)
609 { 656 {
610 profile.AllowPublish = groupInfo.AllowPublish; 657 profile.AllowPublish = groupInfo.AllowPublish;
611 profile.Charter = groupInfo.Charter; 658 profile.Charter = groupInfo.Charter;
612 profile.FounderID = groupInfo.FounderID; 659 profile.FounderID = groupInfo.FounderID;
613 profile.GroupID = groupID; 660 profile.GroupID = groupID;
614 profile.GroupMembershipCount = m_groupData.GetGroupMembers(groupID).Count; 661 profile.GroupMembershipCount = m_groupData.GetGroupMembers(grID, groupID).Count;
615 profile.GroupRolesCount = m_groupData.GetGroupRoles(groupID).Count; 662 profile.GroupRolesCount = m_groupData.GetGroupRoles(grID, groupID).Count;
616 profile.InsigniaID = groupInfo.GroupPicture; 663 profile.InsigniaID = groupInfo.GroupPicture;
617 profile.MaturePublish = groupInfo.MaturePublish; 664 profile.MaturePublish = groupInfo.MaturePublish;
618 profile.MembershipFee = groupInfo.MembershipFee; 665 profile.MembershipFee = groupInfo.MembershipFee;
@@ -623,7 +670,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
623 profile.ShowInList = groupInfo.ShowInList; 670 profile.ShowInList = groupInfo.ShowInList;
624 } 671 }
625 672
626 GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(remoteClient.AgentId, groupID); 673 GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID);
627 if (memberInfo != null) 674 if (memberInfo != null)
628 { 675 {
629 profile.MemberTitle = memberInfo.GroupTitle; 676 profile.MemberTitle = memberInfo.GroupTitle;
@@ -637,14 +684,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
637 { 684 {
638 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 685 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
639 686
640 return m_groupData.GetAgentGroupMemberships(agentID).ToArray(); 687 return m_groupData.GetAgentGroupMemberships(null, agentID).ToArray();
641 } 688 }
642 689
643 public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID) 690 public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID)
644 { 691 {
645 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 692 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
646 693
647 return m_groupData.GetAgentGroupMembership(agentID, groupID); 694 return m_groupData.GetAgentGroupMembership(null, agentID, groupID);
648 } 695 }
649 696
650 public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) 697 public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
@@ -653,7 +700,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
653 700
654 // TODO: Security Check? 701 // TODO: Security Check?
655 702
656 m_groupData.UpdateGroup(groupID, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish); 703 m_groupData.UpdateGroup(GetClientGroupRequestID(remoteClient), groupID, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish);
657 } 704 }
658 705
659 public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile) 706 public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile)
@@ -661,20 +708,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
661 // TODO: Security Check? 708 // TODO: Security Check?
662 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 709 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
663 710
664 m_groupData.SetAgentGroupInfo(remoteClient.AgentId, groupID, acceptNotices, listInProfile); 711 m_groupData.SetAgentGroupInfo(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, acceptNotices, listInProfile);
665 } 712 }
666 713
667 public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) 714 public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
668 { 715 {
669 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 716 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
670 717
671 if (m_groupData.GetGroupRecord(UUID.Zero, name) != null) 718 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
719
720 if (m_groupData.GetGroupRecord(grID, UUID.Zero, name) != null)
672 { 721 {
673 remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists."); 722 remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists.");
674 return UUID.Zero; 723 return UUID.Zero;
675 } 724 }
676 725
677 UUID groupID = m_groupData.CreateGroup(name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, remoteClient.AgentId); 726 UUID groupID = m_groupData.CreateGroup(grID, name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, remoteClient.AgentId);
678 727
679 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly"); 728 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly");
680 729
@@ -689,8 +738,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
689 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 738 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
690 739
691 // ToDo: check if agent is a member of group and is allowed to see notices? 740 // ToDo: check if agent is a member of group and is allowed to see notices?
692 741
693 return m_groupData.GetGroupNotices(groupID).ToArray(); 742 return m_groupData.GetGroupNotices(GetClientGroupRequestID(remoteClient), groupID).ToArray();
694 } 743 }
695 744
696 /// <summary> 745 /// <summary>
@@ -700,7 +749,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
700 { 749 {
701 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 750 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
702 751
703 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(avatarID); 752 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(null, avatarID);
704 if (membership != null) 753 if (membership != null)
705 { 754 {
706 return membership.GroupTitle; 755 return membership.GroupTitle;
@@ -715,7 +764,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
715 { 764 {
716 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 765 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
717 766
718 m_groupData.SetAgentActiveGroupRole(remoteClient.AgentId, groupID, titleRoleID); 767 m_groupData.SetAgentActiveGroupRole(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, titleRoleID);
719 768
720 // TODO: Not sure what all is needed here, but if the active group role change is for the group 769 // TODO: Not sure what all is needed here, but if the active group role change is for the group
721 // the client currently has set active, then we need to do a scene presence update too 770 // the client currently has set active, then we need to do a scene presence update too
@@ -731,20 +780,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
731 780
732 // TODO: Security Checks? 781 // TODO: Security Checks?
733 782
783 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
784
734 switch ((OpenMetaverse.GroupRoleUpdate)updateType) 785 switch ((OpenMetaverse.GroupRoleUpdate)updateType)
735 { 786 {
736 case OpenMetaverse.GroupRoleUpdate.Create: 787 case OpenMetaverse.GroupRoleUpdate.Create:
737 m_groupData.AddGroupRole(groupID, UUID.Random(), name, description, title, powers); 788 m_groupData.AddGroupRole(grID, groupID, UUID.Random(), name, description, title, powers);
738 break; 789 break;
739 790
740 case OpenMetaverse.GroupRoleUpdate.Delete: 791 case OpenMetaverse.GroupRoleUpdate.Delete:
741 m_groupData.RemoveGroupRole(groupID, roleID); 792 m_groupData.RemoveGroupRole(grID, groupID, roleID);
742 break; 793 break;
743 794
744 case OpenMetaverse.GroupRoleUpdate.UpdateAll: 795 case OpenMetaverse.GroupRoleUpdate.UpdateAll:
745 case OpenMetaverse.GroupRoleUpdate.UpdateData: 796 case OpenMetaverse.GroupRoleUpdate.UpdateData:
746 case OpenMetaverse.GroupRoleUpdate.UpdatePowers: 797 case OpenMetaverse.GroupRoleUpdate.UpdatePowers:
747 m_groupData.UpdateGroupRole(groupID, roleID, name, description, title, powers); 798 m_groupData.UpdateGroupRole(grID, groupID, roleID, name, description, title, powers);
748 break; 799 break;
749 800
750 case OpenMetaverse.GroupRoleUpdate.NoUpdate: 801 case OpenMetaverse.GroupRoleUpdate.NoUpdate:
@@ -763,16 +814,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
763 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 814 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
764 // Todo: Security check 815 // Todo: Security check
765 816
817 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
818
766 switch (changes) 819 switch (changes)
767 { 820 {
768 case 0: 821 case 0:
769 // Add 822 // Add
770 m_groupData.AddAgentToGroupRole(memberID, groupID, roleID); 823 m_groupData.AddAgentToGroupRole(grID, memberID, groupID, roleID);
771 824
772 break; 825 break;
773 case 1: 826 case 1:
774 // Remove 827 // Remove
775 m_groupData.RemoveAgentFromGroupRole(memberID, groupID, roleID); 828 m_groupData.RemoveAgentFromGroupRole(grID, memberID, groupID, roleID);
776 829
777 break; 830 break;
778 default: 831 default:
@@ -788,12 +841,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
788 { 841 {
789 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 842 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
790 843
791 844 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
792 GroupNoticeInfo data = m_groupData.GetGroupNotice(groupNoticeID); 845
846 GroupNoticeInfo data = m_groupData.GetGroupNotice(grID, groupNoticeID);
793 847
794 if (data != null) 848 if (data != null)
795 { 849 {
796 GroupRecord groupInfo = m_groupData.GetGroupRecord(data.GroupID, null); 850 GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, data.GroupID, null);
797 851
798 GridInstantMessage msg = new GridInstantMessage(); 852 GridInstantMessage msg = new GridInstantMessage();
799 msg.imSessionID = UUID.Zero.Guid; 853 msg.imSessionID = UUID.Zero.Guid;
@@ -825,12 +879,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
825 msg.dialog = dialog; 879 msg.dialog = dialog;
826 // msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.GroupNotice; 880 // msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.GroupNotice;
827 msg.fromGroup = true; 881 msg.fromGroup = true;
828 msg.offline = (byte)0; 882 msg.offline = (byte)1; // Allow this message to be stored for offline use
829 msg.ParentEstateID = 0; 883 msg.ParentEstateID = 0;
830 msg.Position = Vector3.Zero; 884 msg.Position = Vector3.Zero;
831 msg.RegionID = UUID.Zero.Guid; 885 msg.RegionID = UUID.Zero.Guid;
832 886
833 GroupNoticeInfo info = m_groupData.GetGroupNotice(groupNoticeID); 887 GroupNoticeInfo info = m_groupData.GetGroupNotice(null, groupNoticeID);
834 if (info != null) 888 if (info != null)
835 { 889 {
836 msg.fromAgentID = info.GroupID.Guid; 890 msg.fromAgentID = info.GroupID.Guid;
@@ -865,7 +919,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
865 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 919 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
866 920
867 // Should check to see if OpenEnrollment, or if there's an outstanding invitation 921 // Should check to see if OpenEnrollment, or if there's an outstanding invitation
868 m_groupData.AddAgentToGroup(remoteClient.AgentId, groupID, UUID.Zero); 922 m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, UUID.Zero);
869 923
870 remoteClient.SendJoinGroupReply(groupID, true); 924 remoteClient.SendJoinGroupReply(groupID, true);
871 925
@@ -877,7 +931,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
877 { 931 {
878 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 932 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
879 933
880 m_groupData.RemoveAgentFromGroup(remoteClient.AgentId, groupID); 934 m_groupData.RemoveAgentFromGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID);
881 935
882 remoteClient.SendLeaveGroupReply(groupID, true); 936 remoteClient.SendLeaveGroupReply(groupID, true);
883 937
@@ -892,12 +946,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
892 { 946 {
893 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 947 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
894 948
949 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
950
895 // Todo: Security check? 951 // Todo: Security check?
896 m_groupData.RemoveAgentFromGroup(ejecteeID, groupID); 952 m_groupData.RemoveAgentFromGroup(grID, ejecteeID, groupID);
897 953
898 remoteClient.SendEjectGroupMemberReply(remoteClient.AgentId, groupID, true); 954 remoteClient.SendEjectGroupMemberReply(remoteClient.AgentId, groupID, true);
899 955
900 GroupRecord groupInfo = m_groupData.GetGroupRecord(groupID, null); 956 GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, groupID, null);
901 UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(ejecteeID); 957 UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(ejecteeID);
902 958
903 if ((groupInfo == null) || (userProfile == null)) 959 if ((groupInfo == null) || (userProfile == null))
@@ -969,7 +1025,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
969 1025
970 // Todo: Security check, probably also want to send some kind of notification 1026 // Todo: Security check, probably also want to send some kind of notification
971 UUID InviteID = UUID.Random(); 1027 UUID InviteID = UUID.Random();
972 m_groupData.AddAgentToGroupInvite(InviteID, groupID, roleID, invitedAgentID); 1028 m_groupData.AddAgentToGroupInvite(GetClientGroupRequestID(remoteClient), InviteID, groupID, roleID, invitedAgentID);
973 1029
974 if (m_msgTransferModule != null) 1030 if (m_msgTransferModule != null)
975 { 1031 {
@@ -1031,6 +1087,37 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1031 return child; 1087 return child;
1032 } 1088 }
1033 1089
1090 private GroupRequestID GetClientGroupRequestID(IClientAPI client)
1091 {
1092 lock (m_clientRequestIDInfo)
1093 {
1094 if (!m_clientRequestIDInfo.ContainsKey(client.AgentId))
1095 {
1096 GroupRequestIDInfo info = new GroupRequestIDInfo();
1097 info.RequestID.AgentID = client.AgentId;
1098 info.RequestID.SessionID = client.SessionId;
1099
1100 UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(client.AgentId);
1101 if (userProfile is ForeignUserProfileData)
1102 {
1103 // They aren't from around here
1104 ForeignUserProfileData fupd = (ForeignUserProfileData)userProfile;
1105 info.RequestID.UserServiceURL = fupd.UserServerURI;
1106 }
1107 else
1108 {
1109 // They're a local user, use this:
1110 info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;
1111 }
1112
1113 m_clientRequestIDInfo.Add(client.AgentId, info);
1114 }
1115
1116 m_clientRequestIDInfo[client.AgentId].LastUsedTMStamp = DateTime.Now;
1117 }
1118 return m_clientRequestIDInfo[client.AgentId].RequestID;
1119 }
1120
1034 /// <summary> 1121 /// <summary>
1035 /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'. 1122 /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'.
1036 /// </summary> 1123 /// </summary>
@@ -1120,23 +1207,25 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1120 /// <summary> 1207 /// <summary>
1121 /// Update remoteClient with group information about dataForAgentID 1208 /// Update remoteClient with group information about dataForAgentID
1122 /// </summary> 1209 /// </summary>
1123 private void SendAgentGroupDataUpdate(IClientAPI client, UUID dataForAgentID) 1210 private void SendAgentGroupDataUpdate(IClientAPI remoteClient, UUID dataForAgentID)
1124 { 1211 {
1125 if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: {0} called for {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, client.Name); 1212 if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: {0} called for {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, remoteClient.Name);
1126 1213
1127 // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff 1214 // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff
1128 1215
1129 OnAgentDataUpdateRequest(client, dataForAgentID, UUID.Zero); 1216 OnAgentDataUpdateRequest(remoteClient, dataForAgentID, UUID.Zero);
1130 1217
1131 1218
1132 // Need to send a group membership update to the client 1219 // Need to send a group membership update to the client
1133 // UDP version doesn't seem to behave nicely 1220 // UDP version doesn't seem to behave nicely. But we're going to send it out here
1134 // client.SendGroupMembership(GetMembershipData(client.AgentId)); 1221 // with an empty group membership to hopefully remove groups being displayed due
1222 // to the core Groups Stub
1223 remoteClient.SendGroupMembership( new GroupMembershipData[0] );
1135 1224
1136 GroupMembershipData[] membershipData = m_groupData.GetAgentGroupMemberships(dataForAgentID).ToArray(); 1225 GroupMembershipData[] membershipData = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(remoteClient), dataForAgentID).ToArray();
1137 1226
1138 SendGroupMembershipInfoViaCaps(client, dataForAgentID, membershipData); 1227 SendGroupMembershipInfoViaCaps(remoteClient, dataForAgentID, membershipData);
1139 client.SendAvatarGroupsReply(dataForAgentID, membershipData); 1228 remoteClient.SendAvatarGroupsReply(dataForAgentID, membershipData);
1140 1229
1141 } 1230 }
1142 1231