예제 #1
0
        public override void FromOSD(OSDMap map)
        {
            AgentInfo = new IAgentInfo();
            AgentInfo.FromOSD((OSDMap) (map["AgentInfo"]));
            UserAccount = new UserAccount();
            UserAccount.FromOSD((OSDMap) (map["UserAccount"]));
            if (!map.ContainsKey("ActiveGroup"))
                ActiveGroup = null;
            else
            {
                ActiveGroup = new GroupMembershipData();
                ActiveGroup.FromOSD((OSDMap) (map["ActiveGroup"]));
            }
            GroupMemberships = ((OSDArray) map["GroupMemberships"]).ConvertAll<GroupMembershipData>((o) =>
                                                                                                        {
                                                                                                            GroupMembershipData
                                                                                                                group =
                                                                                                                    new GroupMembershipData
                                                                                                                        ();
                                                                                                            group
                                                                                                                .FromOSD
                                                                                                                ((OSDMap
                                                                                                                 ) o);
                                                                                                            return group;
                                                                                                        });
            OfflineMessages = ((OSDArray) map["OfflineMessages"]).ConvertAll<GridInstantMessage>((o) =>
                                                                                                     {
                                                                                                         GridInstantMessage
                                                                                                             group =
                                                                                                                 new GridInstantMessage
                                                                                                                     ();
                                                                                                         group.FromOSD(
                                                                                                             (OSDMap) o);
                                                                                                         return group;
                                                                                                     });
            MuteList = ((OSDArray) map["MuteList"]).ConvertAll<MuteList>((o) =>
                                                                             {
                                                                                 MuteList group = new MuteList();
                                                                                 group.FromOSD((OSDMap) o);
                                                                                 return group;
                                                                             });

            if (map.ContainsKey("Appearance"))
            {
                Appearance = new AvatarAppearance();
                Appearance.FromOSD((OSDMap)map["Appearance"]);
            }
        }
        public GroupMembershipData GetGroupMembershipData(UUID requestingAgentID, UUID GroupID, UUID AgentID)
        {
            object remoteValue = DoRemote(requestingAgentID, GroupID, AgentID);
            if (remoteValue != null || m_doRemoteOnly)
                return (GroupMembershipData) remoteValue;

            if (GroupID == UUID.Zero)
                GroupID = GetAgentActiveGroup(requestingAgentID, AgentID);
            if (GroupID == UUID.Zero)
                return null;

            QueryTables tables = new QueryTables();
            tables.AddTable("osgroup", "osg");
            tables.AddTable("osgroupmembership", "osgm", JoinType.Inner, new[,] {{"osg.GroupID", "osgm.GroupID"}});
            tables.AddTable("osrole", "osr", JoinType.Inner,
                            new[,] {{"osgm.SelectedRoleID", "osr.RoleID"}, {"osr.GroupID", "osg.GroupID"}});

            QueryFilter filter = new QueryFilter();
            filter.andFilters["osg.GroupID"] = GroupID;
            filter.andFilters["osgm.AgentID"] = AgentID;

            string[] fields = new[]
                                  {
                                      "osgm.AcceptNotices",
                                      "osgm.Contribution",
                                      "osgm.ListInProfile",
                                      "osgm.SelectedRoleID",
                                      "osr.Title",
                                      "osr.Powers",
                                      "osg.AllowPublish",
                                      "osg.Charter",
                                      "osg.FounderID",
                                      "osg.Name",
                                      "osg.InsigniaID",
                                      "osg.MaturePublish",
                                      "osg.MembershipFee",
                                      "osg.OpenEnrollment",
                                      "osg.ShowInList"
                                  };
            List<string> Membership = data.Query(fields, tables, filter, null, null, null);

            if (fields.Length != Membership.Count)
                return null;

            GroupMembershipData GMD = new GroupMembershipData
                                          {
                                              AcceptNotices = int.Parse(Membership[0]) == 1,
                                              Active = true, //TODO: Figure out what this is and its effects if false
                                              ActiveRole = UUID.Parse(Membership[3]),
                                              AllowPublish = int.Parse(Membership[6]) == 1,
                                              Charter = Membership[7],
                                              Contribution = int.Parse(Membership[1]),
                                              FounderID = UUID.Parse(Membership[8]),
                                              GroupID = GroupID,
                                              GroupName = Membership[9],
                                              GroupPicture = UUID.Parse(Membership[10]),
                                              GroupPowers = ulong.Parse(Membership[5]),
                                              GroupTitle = Membership[4],
                                              ListInProfile = int.Parse(Membership[2]) == 1,
                                              MaturePublish = int.Parse(Membership[11]) == 1,
                                              MembershipFee = int.Parse(Membership[12]),
                                              OpenEnrollment = int.Parse(Membership[13]) == 1,
                                              ShowInList = int.Parse(Membership[14]) == 1
                                          };

            return GMD;
        }
        /// <summary>
        ///     Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'.
        /// </summary>
        private void SendGroupMembershipInfoViaCaps(IClientAPI remoteClient, UUID dataForAgentID,
                                                    GroupMembershipData[] data)
        {
            if (m_debugEnabled)
                MainConsole.Instance.InfoFormat("[GROUPS]: {0} called", MethodBase.GetCurrentMethod().Name);

            OSDArray AgentData = new OSDArray(1);
            OSDMap AgentDataMap = new OSDMap(1) {{"AgentID", OSD.FromUUID(dataForAgentID)}};
            AgentData.Add(AgentDataMap);

            OSDArray GroupData = new OSDArray(data.Length);
            OSDArray NewGroupData = new OSDArray(data.Length);

            foreach (GroupMembershipData membership in data)
            {
                if (GetRequestingAgentID(remoteClient) != dataForAgentID)
                {
                    if (!membership.ListInProfile)
                    {
                        // If we're sending group info to remoteclient about another agent,
                        // filter out groups the other agent doesn't want to share.
                        continue;
                    }
                }

                OSDMap GroupDataMap = new OSDMap(6);
                OSDMap NewGroupDataMap = new OSDMap(1);

                GroupDataMap.Add("GroupID", OSD.FromUUID(membership.GroupID));
                GroupDataMap.Add("GroupPowers", OSD.FromULong(membership.GroupPowers));
                GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(membership.AcceptNotices));
                GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(membership.GroupPicture));
                GroupDataMap.Add("Contribution", OSD.FromInteger(membership.Contribution));
                GroupDataMap.Add("GroupName", OSD.FromString(membership.GroupName));
                NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(membership.ListInProfile));

                GroupData.Add(GroupDataMap);
                NewGroupData.Add(NewGroupDataMap);
            }

            OSDMap llDataStruct = new OSDMap(3)
                                      {
                                          {"AgentData", AgentData},
                                          {"GroupData", GroupData},
                                          {"NewGroupData", NewGroupData}
                                      };

            if (m_debugEnabled)
                MainConsole.Instance.InfoFormat("[GROUPS]: {0}", OSDParser.SerializeJsonString(llDataStruct));

            IEventQueueService queue = remoteClient.Scene.RequestModuleInterface<IEventQueueService>();

            if (queue != null)
                queue.Enqueue(buildEvent("AgentGroupDataUpdate", llDataStruct), GetRequestingAgentID(remoteClient),
                              remoteClient.Scene.RegionInfo.RegionID);
        }