Example #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;
         });
 }
Example #2
0
        /// <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.RegionHandle);
        }
        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;
        }
        public GroupMembershipData GetGroupMembershipData(UUID requestingAgentID, UUID GroupID, UUID AgentID)
        {
            Dictionary<string, object> sendData = new Dictionary<string, object>();

            sendData["METHOD"] = "GetGroupMembershipData";
            sendData["requestingAgentID"] = requestingAgentID;
            sendData["GroupID"] = GroupID;
            sendData["AgentID"] = AgentID;

            string reqString = WebUtils.BuildXmlResponse(sendData);

            try
            {
                List<string> m_ServerURIs =
                    m_registry.RequestModuleInterface<IConfigurationService>().FindValueOf(
                        requestingAgentID.ToString(), "RemoteServerURI", false);
                foreach (string m_ServerURI in m_ServerURIs)
                {
                    string reply = SynchronousRestFormsRequester.MakeRequest("POST",
                                                                             m_ServerURI,
                                                                             reqString);
                    if (reply != string.Empty)
                    {
                        Dictionary<string, object> replyData = WebUtils.ParseXmlResponse(reply);

                        if (replyData != null)
                        {
                            Dictionary<string, object>.ValueCollection replyvalues = replyData.Values;
                            GroupMembershipData group = null;
#if (!ISWIN)
                            foreach (object replyvalue in replyvalues)
                            {
                                Dictionary<string, object> f = replyvalue as Dictionary<string, object>;
                                if (f != null)
                                {
                                    group = new GroupMembershipData(f);
                                }
                            }
#else
                            foreach (Dictionary<string, object> f in replyvalues.OfType<Dictionary<string, object>>())
                            {
                                group = new GroupMembershipData(f);
                            }
#endif
                            // Success
                            return group;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MainConsole.Instance.DebugFormat("[AuroraRemoteGroupsServiceConnector]: Exception when contacting server: {0}", e);
            }

            return null;
        }
        private static GroupMembershipData HashTableToGroupMembershipData(Hashtable respData)
        {
            GroupMembershipData data = new GroupMembershipData
                                           {
                                               AcceptNotices = ((string) respData["AcceptNotices"] == "1"),
                                               Contribution = int.Parse((string) respData["Contribution"]),
                                               ListInProfile = ((string) respData["ListInProfile"] == "1"),
                                               ActiveRole = new UUID((string) respData["SelectedRoleID"]),
                                               GroupTitle = (string) respData["Title"],
                                               GroupPowers = ulong.Parse((string) respData["GroupPowers"]),
                                               GroupID = new UUID((string) respData["GroupID"])
                                           };



            // Is this group the agent's active group


            UUID ActiveGroup = new UUID((string) respData["ActiveGroupID"]);
            data.Active = data.GroupID.Equals(ActiveGroup);

            data.AllowPublish = ((string) respData["AllowPublish"] == "1");
            if (respData["Charter"] != null)
            {
                data.Charter = (string) respData["Charter"];
            }
            data.FounderID = new UUID((string) respData["FounderID"]);
            data.GroupID = new UUID((string) respData["GroupID"]);
            data.GroupName = (string) respData["GroupName"];
            data.GroupPicture = new UUID((string) respData["InsigniaID"]);
            data.MaturePublish = ((string) respData["MaturePublish"] == "1");
            data.MembershipFee = int.Parse((string) respData["MembershipFee"]);
            data.OpenEnrollment = ((string) respData["OpenEnrollment"] == "1");
            data.ShowInList = ((string) respData["ShowInList"] == "1");

            return data;
        }
        public GroupMembershipData GetGroupMembershipData(UUID requestingAgentID, UUID GroupID, UUID AgentID)
        {
            object remoteValue = DoRemote(requestingAgentID, GroupID, AgentID);
            if (remoteValue != null || m_doRemoteOnly)
                return (GroupMembershipData)remoteValue;

            GroupMembershipData GMD = new GroupMembershipData();
            if (GroupID == UUID.Zero)
                GroupID = GetAgentActiveGroup(requestingAgentID, AgentID);

            GroupRecord record = GetGroupRecord(requestingAgentID, GroupID, null);
            if (record == null)
                return null;

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

            List<string> Membership = data.Query(new string[]{
                "AcceptNotices",
                "Contribution",
                "ListInProfile",
                "SelectedRoleID"
            }, "osgroupmembership", filter, null, null, null);

            if (Membership.Count != 4)
            {
                return null;
            }
            filter.andFilters.Remove("AgentID");
            filter.andFilters["RoleID"] = Membership[3];

            List<string> GroupRole = data.Query(new string[]{
                "Title",
                "Powers"
            }, "osrole", filter, null, null, null);

            if (GroupRole.Count != 2)
            {
                return null;
            }

            GMD.AcceptNotices = int.Parse(Membership[0]) == 1;
            //TODO: Figure out what this is and its effects if false
            GMD.Active = true;
            GMD.ActiveRole = UUID.Parse(Membership[3]);
            GMD.AllowPublish = record.AllowPublish;
            GMD.Charter = record.Charter;
            GMD.Contribution = int.Parse(Membership[1]);
            GMD.FounderID = record.FounderID;
            GMD.GroupID = record.GroupID;
            GMD.GroupName = record.GroupName;
            GMD.GroupPicture = record.GroupPicture;
            GMD.GroupPowers = ulong.Parse(GroupRole[1]);
            GMD.GroupTitle = GroupRole[0];
            GMD.ListInProfile = int.Parse(Membership[2]) == 1;
            GMD.MaturePublish = record.MaturePublish;
            GMD.MembershipFee = record.MembershipFee;
            GMD.OpenEnrollment = record.OpenEnrollment;
            GMD.ShowInList = record.ShowInList;

            return GMD;
        }
        public GroupMembershipData GetAgentGroupMembership(UUID requestingAgentID, UUID agentID, UUID groupID)
        {
            if (m_debugEnabled)
                MainConsole.Instance.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", MethodBase.GetCurrentMethod().Name);

            GroupMembershipData data = new GroupMembershipData();

            ///////////////////////////////
            // Agent Specific Information:
            //
            OSDMap UserActiveGroup;
            if (SimianGetGenericEntry(agentID, "Group", "ActiveGroup", out UserActiveGroup))
            {
                data.Active = UserActiveGroup["GroupID"].AsUUID().Equals(groupID);
            }

            OSDMap UserGroupMemberInfo;
            if (SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out UserGroupMemberInfo))
            {
                data.AcceptNotices = UserGroupMemberInfo["AcceptNotices"].AsBoolean();
                data.Contribution = UserGroupMemberInfo["Contribution"].AsInteger();
                data.ListInProfile = UserGroupMemberInfo["ListInProfile"].AsBoolean();
                data.ActiveRole = UserGroupMemberInfo["SelectedRoleID"].AsUUID();

                ///////////////////////////////
                // Role Specific Information:
                //

                OSDMap GroupRoleInfo;
                if (SimianGetGenericEntry(groupID, "GroupRole", data.ActiveRole.ToString(), out GroupRoleInfo))
                {
                    data.GroupTitle = GroupRoleInfo["Title"].AsString();
                    data.GroupPowers = GroupRoleInfo["Powers"].AsULong();
                }
            }

            ///////////////////////////////
            // Group Specific Information:
            //
            OSDMap GroupInfo;
            string GroupName;
            if (SimianGetFirstGenericEntry(groupID, "Group", out GroupName, out GroupInfo))
            {
                data.GroupID = groupID;
                data.AllowPublish = GroupInfo["AllowPublish"].AsBoolean();
                data.Charter = GroupInfo["Charter"].AsString();
                data.FounderID = GroupInfo["FounderID"].AsUUID();
                data.GroupName = GroupName;
                data.GroupPicture = GroupInfo["InsigniaID"].AsUUID();
                data.MaturePublish = GroupInfo["MaturePublish"].AsBoolean();
                data.MembershipFee = GroupInfo["MembershipFee"].AsInteger();
                data.OpenEnrollment = GroupInfo["OpenEnrollment"].AsBoolean();
                data.ShowInList = GroupInfo["ShowInList"].AsBoolean();
            }

            return data;
        }