From 64f9f03e9a3cb345ef85e1990bebc3a7cca41c9e Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 24 Oct 2008 23:04:55 +0000 Subject: Plumb some more --- OpenSim/Framework/GroupData.cs | 6 +- OpenSim/Framework/IClientAPI.cs | 1 + .../Region/ClientStack/LindenUDP/LLClientView.cs | 170 ++++++++++++++++++--- .../Currency/SampleMoney/SampleMoneyModule.cs | 12 ++ .../Modules/Framework/EventQueueHelper.cs | 2 +- .../Environment/Modules/World/NPC/NPCAvatar.cs | 4 + .../Region/Examples/SimpleModule/MyNpcCharacter.cs | 4 + OpenSim/Region/Interfaces/IGroupsModule.cs | 9 ++ OpenSim/Region/Interfaces/IMoneyModule.cs | 2 + 9 files changed, 186 insertions(+), 24 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/GroupData.cs b/OpenSim/Framework/GroupData.cs index 76034c0..9626553 100644 --- a/OpenSim/Framework/GroupData.cs +++ b/OpenSim/Framework/GroupData.cs @@ -42,11 +42,12 @@ namespace OpenSim.Framework public string GroupName; public bool AllowPublish = true; public bool MaturePublish = true; - public UUID Charter = UUID.Zero; + public string Charter; public UUID FounderID = UUID.Zero; public UUID GroupPicture = UUID.Zero; public int MembershipFee = 0; public bool OpenEnrollment = true; + public bool ShowInList = true; // Per user data // @@ -55,6 +56,8 @@ namespace OpenSim.Framework public ulong GroupPowers = 0; public bool Active = false; public UUID ActiveRole = UUID.Zero; + public bool ListInProfile = false; + public string GroupTitle; } public struct GroupTitlesData @@ -92,6 +95,7 @@ namespace OpenSim.Framework public ulong AgentPowers; public string Title; public bool IsOwner; + public bool ListInProfile; } public struct GroupRolesData diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index a8813c9..f38b57f 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -902,6 +902,7 @@ namespace OpenSim.Framework void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags); + void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data); void SendOfferCallingCard(UUID srcID, UUID transactionID); void SendAcceptCallingCard(UUID transactionID); void SendDeclineCallingCard(UUID transactionID); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index b517c13..d40faac 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -273,6 +273,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP private MapItemRequest handlerMapItemRequest = null; + private IGroupsModule m_GroupsModule = null; + //private TerrainUnacked handlerUnackedTerrain = null; //** @@ -411,6 +413,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP AuthenticateResponse sessionInfo, UUID agentId, UUID sessionId, uint circuitCode, EndPoint proxyEP, ClientStackUserSettings userSettings) { + m_GroupsModule = scene.RequestModuleInterface(); m_moneyBalance = 1000; m_channelVersion = Utils.StringToBytes(scene.GetSimulatorVersion()); @@ -6286,10 +6289,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP //m_log.Warn("[CLIENT]: unhandled ViewerStats packet"); break; - case PacketType.CreateGroupRequest: - // TODO: handle this packet - //m_log.Warn("[CLIENT]: unhandled CreateGroupRequest packet"); - break; //case PacketType.GenericMessage: // TODO: handle this packet //m_log.Warn("[CLIENT]: unhandled GenericMessage packet"); @@ -6462,10 +6461,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP case PacketType.ActivateGroup: ActivateGroupPacket activateGroupPacket = (ActivateGroupPacket)Pack; - IGroupsModule grps = m_scene.RequestModuleInterface(); - if (grps != null) + if (m_GroupsModule != null) { - grps.ActivateGroup(this, activateGroupPacket.AgentData.GroupID); + m_GroupsModule.ActivateGroup(this, activateGroupPacket.AgentData.GroupID); + m_GroupsModule.SendAgentGroupDataUpdate(this); } break; @@ -6473,8 +6472,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP GroupTitlesRequestPacket groupTitlesRequest = (GroupTitlesRequestPacket)Pack; - IGroupsModule grps2 = m_scene.RequestModuleInterface(); - if (grps2 != null) + if (m_GroupsModule != null) { GroupTitlesReplyPacket groupTitlesReply = (GroupTitlesReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupTitlesReply); @@ -6489,7 +6487,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP groupTitlesRequest.AgentData.RequestID; List titles = - grps2.GroupTitlesRequest(this, + m_GroupsModule.GroupTitlesRequest(this, groupTitlesRequest.AgentData.GroupID); groupTitlesReply.GroupData = @@ -6520,8 +6518,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP GroupProfileRequestPacket groupProfileRequest = (GroupProfileRequestPacket)Pack; - IGroupsModule grps3 = m_scene.RequestModuleInterface(); - if (grps3 != null) + if (m_GroupsModule != null) { GroupProfileReplyPacket groupProfileReply = (GroupProfileReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupProfileReply); @@ -6529,7 +6526,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP groupProfileReply.GroupData = new GroupProfileReplyPacket.GroupDataBlock(); groupProfileReply.AgentData.AgentID = AgentId; - GroupProfileData d = grps3.GroupProfileRequest(this, + GroupProfileData d = m_GroupsModule.GroupProfileRequest(this, groupProfileRequest.GroupData.GroupID); groupProfileReply.GroupData.GroupID = d.GroupID; @@ -6557,11 +6554,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP GroupMembersRequestPacket groupMembersRequestPacket = (GroupMembersRequestPacket)Pack; - IGroupsModule grps4 = m_scene.RequestModuleInterface(); List members = - grps4.GroupMembersRequest(this, groupMembersRequestPacket.GroupData.GroupID); + m_GroupsModule.GroupMembersRequest(this, groupMembersRequestPacket.GroupData.GroupID); - if (grps4 != null) + if (m_GroupsModule != null) { GroupMembersReplyPacket groupMembersReply = (GroupMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupMembersReply); @@ -6608,8 +6604,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP GroupRoleDataRequestPacket groupRolesRequest = (GroupRoleDataRequestPacket)Pack; - IGroupsModule grps5 = m_scene.RequestModuleInterface(); - if (grps5 != null) + if (m_GroupsModule != null) { GroupRoleDataReplyPacket groupRolesReply = (GroupRoleDataReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleDataReply); @@ -6629,7 +6624,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP groupRolesRequest.GroupData.RequestID; List titles = - grps5.GroupRoleDataRequest(this, + m_GroupsModule.GroupRoleDataRequest(this, groupRolesRequest.GroupData.GroupID); groupRolesReply.GroupData.RoleCount = @@ -6670,8 +6665,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP GroupRoleMembersRequestPacket groupRoleMembersRequest = (GroupRoleMembersRequestPacket)Pack; - IGroupsModule grps6 = m_scene.RequestModuleInterface(); - if (grps6 != null) + if (m_GroupsModule != null) { GroupRoleMembersReplyPacket groupRoleMembersReply = (GroupRoleMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleMembersReply); groupRoleMembersReply.AgentData = @@ -6684,7 +6678,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP groupRoleMembersRequest.GroupData.RequestID; List mappings = - grps6.GroupRoleMembersRequest(this, + m_GroupsModule.GroupRoleMembersRequest(this, groupRoleMembersRequest.GroupData.GroupID); groupRoleMembersReply.AgentData.TotalPairs = @@ -6713,6 +6707,108 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; + case PacketType.CreateGroupRequest: + CreateGroupRequestPacket createGroupRequest = + (CreateGroupRequestPacket)Pack; + + if (m_GroupsModule != null) + { + CreateGroupReplyPacket createGroupReply = (CreateGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.CreateGroupReply); + + createGroupReply.AgentData = + new CreateGroupReplyPacket.AgentDataBlock(); + createGroupReply.ReplyData = + new CreateGroupReplyPacket.ReplyDataBlock(); + + createGroupReply.AgentData.AgentID = AgentId; + createGroupReply.ReplyData.GroupID = UUID.Zero; + + IMoneyModule money = m_scene.RequestModuleInterface(); + if (money != null && !money.GroupCreationCovered(this)) + { + createGroupReply.ReplyData.Success = false; + createGroupReply.ReplyData.Message = Utils.StringToBytes("You do not have sufficient funds to create a group"); + OutPacket(createGroupReply, ThrottleOutPacketType.Task); + break; + } + + UUID groupID = m_GroupsModule.CreateGroup(this, + Utils.BytesToString(createGroupRequest.GroupData.Name), + Utils.BytesToString(createGroupRequest.GroupData.Charter), + createGroupRequest.GroupData.ShowInList, + createGroupRequest.GroupData.InsigniaID, + createGroupRequest.GroupData.MembershipFee, + createGroupRequest.GroupData.OpenEnrollment, + createGroupRequest.GroupData.AllowPublish, + createGroupRequest.GroupData.MaturePublish); + if (groupID == UUID.Zero) + { + createGroupReply.ReplyData.Success = false; + createGroupReply.ReplyData.Message = Utils.StringToBytes("We're sorry, but we could not create the requested group. Please try another name"); + OutPacket(createGroupReply, ThrottleOutPacketType.Task); + break; + } + + if (money != null) + money.ApplyGroupCreationCharge(AgentId); + + createGroupReply.ReplyData.Success = true; + createGroupReply.ReplyData.GroupID = groupID; + createGroupReply.ReplyData.Message = Utils.StringToBytes("Group created"); + OutPacket(createGroupReply, ThrottleOutPacketType.Task); + + // Sync with event queue + System.Threading.Thread.Sleep(1000); + + m_GroupsModule.SendAgentGroupDataUpdate(this); + } + break; + + case PacketType.UpdateGroupInfo: + UpdateGroupInfoPacket updateGroupInfo = + (UpdateGroupInfoPacket)Pack; + + if (m_GroupsModule != null) + { + m_GroupsModule.UpdateGroupInfo(this, + updateGroupInfo.GroupData.GroupID, + Utils.BytesToString(updateGroupInfo.GroupData.Charter), + updateGroupInfo.GroupData.ShowInList, + updateGroupInfo.GroupData.InsigniaID, + updateGroupInfo.GroupData.MembershipFee, + updateGroupInfo.GroupData.OpenEnrollment, + updateGroupInfo.GroupData.AllowPublish, + updateGroupInfo.GroupData.MaturePublish); + } + + break; + + case PacketType.SetGroupAcceptNotices: + SetGroupAcceptNoticesPacket setGroupAcceptNotices = + (SetGroupAcceptNoticesPacket)Pack; + + if (m_GroupsModule != null) + { + m_GroupsModule.SetGroupAcceptNotices(this, + setGroupAcceptNotices.Data.GroupID, + setGroupAcceptNotices.Data.AcceptNotices, + setGroupAcceptNotices.NewData.ListInProfile); + } + + break; + + case PacketType.GroupTitleUpdate: + GroupTitleUpdatePacket groupTitleUpdate = + (GroupTitleUpdatePacket)Pack; + + if (m_GroupsModule != null) + { + m_GroupsModule.GroupTitleUpdate(this, + groupTitleUpdate.AgentData.GroupID, + groupTitleUpdate.AgentData.TitleRoleID); + } + + break; default: m_log.Warn("[CLIENT]: unhandled packet " + Pack.ToString()); break; @@ -7459,6 +7555,36 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(p, ThrottleOutPacketType.Task); } + public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data) + { + int i; + + AvatarGroupsReplyPacket p = (AvatarGroupsReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarGroupsReply); + + p.AgentData = new AvatarGroupsReplyPacket.AgentDataBlock(); + p.AgentData.AgentID = AgentId; + p.AgentData.AvatarID = avatarID; + + p.GroupData = new AvatarGroupsReplyPacket.GroupDataBlock[data.Length]; + i = 0; + foreach (GroupMembershipData m in data) + { + p.GroupData[i] = new AvatarGroupsReplyPacket.GroupDataBlock(); + p.GroupData[i].GroupPowers = m.GroupPowers; + p.GroupData[i].AcceptNotices = m.AcceptNotices; + p.GroupData[i].GroupTitle = Utils.StringToBytes(m.GroupTitle); + p.GroupData[i].GroupID = m.GroupID; + p.GroupData[i].GroupName = Utils.StringToBytes(m.GroupName); + p.GroupData[i].GroupInsigniaID = m.GroupPicture; + i++; + } + + p.NewGroupData = new AvatarGroupsReplyPacket.NewGroupDataBlock(); + p.NewGroupData.ListInProfile = true; + + OutPacket(p, ThrottleOutPacketType.Task); + } + public void KillEndDone() { KillPacket kp = new KillPacket(); diff --git a/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs index 4de6fa2..fc1decf 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs @@ -187,6 +187,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney { } + public void ApplyGroupCreationCharge(UUID agentID) + { + } + public bool ObjectGiveMoney(UUID objectID, UUID fromID, UUID toID, int amount) { string description = String.Format("Object {0} pays {1}", resolveObjectName(objectID), resolveAgentName(toID)); @@ -1512,6 +1516,14 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney return true; } + public bool GroupCreationCovered(IClientAPI client) + { + if (GetBalance(client) < PriceGroupCreate) + return false; + + return true; + } + #endregion public void ObjectBuy(IClientAPI remoteClient, UUID agentID, diff --git a/OpenSim/Region/Environment/Modules/Framework/EventQueueHelper.cs b/OpenSim/Region/Environment/Modules/Framework/EventQueueHelper.cs index 1e7eb59..0d0eed2 100644 --- a/OpenSim/Region/Environment/Modules/Framework/EventQueueHelper.cs +++ b/OpenSim/Region/Environment/Modules/Framework/EventQueueHelper.cs @@ -52,7 +52,7 @@ namespace OpenSim.Region.Environment }; } - private static LLSD buildEvent(string eventName, LLSD eventBody) + public static LLSD buildEvent(string eventName, LLSD eventBody) { LLSDMap llsdEvent = new LLSDMap(2); llsdEvent.Add("message", new LLSDString(eventName)); diff --git a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs index 8617605..e2b035a 100644 --- a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs @@ -955,5 +955,9 @@ namespace OpenSim.Region.Environment.Modules.World.NPC public void SendDeclineCallingCard (UUID transactionID) { } + + public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data) + { + } } } diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index 2d479be..d61d649 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -954,5 +954,9 @@ namespace OpenSim.Region.Examples.SimpleModule public void SendDeclineCallingCard (UUID transactionID) { } + + public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data) + { + } } } diff --git a/OpenSim/Region/Interfaces/IGroupsModule.cs b/OpenSim/Region/Interfaces/IGroupsModule.cs index 17daf3e..8565e04 100644 --- a/OpenSim/Region/Interfaces/IGroupsModule.cs +++ b/OpenSim/Region/Interfaces/IGroupsModule.cs @@ -40,6 +40,15 @@ namespace OpenSim.Region.Interfaces List GroupRoleDataRequest(IClientAPI remoteClient, UUID groupID); List GroupRoleMembersRequest(IClientAPI remoteClient, UUID groupID); GroupProfileData GroupProfileRequest(IClientAPI remoteClient, UUID groupID); + GroupMembershipData[] GetMembershipData(UUID UserID); + void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish); + + void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile); + + void GroupTitleUpdate(IClientAPI remoteClient, UUID GroupID, UUID TitleRoleID); + UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish); + + void SendAgentGroupDataUpdate(IClientAPI remoteClient); } } diff --git a/OpenSim/Region/Interfaces/IMoneyModule.cs b/OpenSim/Region/Interfaces/IMoneyModule.cs index 37caa39..5797af0 100644 --- a/OpenSim/Region/Interfaces/IMoneyModule.cs +++ b/OpenSim/Region/Interfaces/IMoneyModule.cs @@ -40,6 +40,8 @@ namespace OpenSim.Region.Interfaces int GetBalance(IClientAPI client); void ApplyUploadCharge(UUID agentID); bool UploadCovered(IClientAPI client); + void ApplyGroupCreationCharge(UUID agentID); + bool GroupCreationCovered(IClientAPI client); event ObjectPaid OnObjectPaid; } -- cgit v1.1