Пример #1
0
        public List <GroupMembersData> GetGroupMembers(GroupRequestID requestID, UUID GroupID)
        {
            Hashtable param = new Hashtable();

            param["GroupID"] = GroupID.ToString();

            Hashtable respData = XmlRpcCall(requestID, "groups.getGroupMembers", param);

            List <GroupMembersData> members = new List <GroupMembersData>();

            if (respData.Contains("error"))
            {
                return(members);
            }

            foreach (Hashtable membership in respData.Values)
            {
                GroupMembersData data = new GroupMembersData();

                data.AcceptNotices = ((string)membership["AcceptNotices"]) == "1";
                data.AgentID       = new UUID((string)membership["AgentID"]);
                data.Contribution  = int.Parse((string)membership["Contribution"]);
                data.IsOwner       = ((string)membership["IsOwner"]) == "1";
                data.ListInProfile = ((string)membership["ListInProfile"]) == "1";
                data.AgentPowers   = ulong.Parse((string)membership["AgentPowers"]);
                data.Title         = (string)membership["Title"];

                members.Add(data);
            }

            return(members);
        }
Пример #2
0
        public List <GroupRolesData> GetGroupRoles(GroupRequestID requestID, UUID GroupID)
        {
            Hashtable param = new Hashtable();

            param["GroupID"] = GroupID.ToString();

            Hashtable respData = XmlRpcCall(requestID, "groups.getGroupRoles", param);

            List <GroupRolesData> Roles = new List <GroupRolesData>();

            if (respData.Contains("error"))
            {
                return(Roles);
            }

            foreach (Hashtable role in respData.Values)
            {
                GroupRolesData data = new GroupRolesData();
                data.Description = (string)role["Description"];
                data.Members     = int.Parse((string)role["Members"]);
                data.Name        = (string)role["Name"];
                data.Powers      = ulong.Parse((string)role["Powers"]);
                data.RoleID      = new UUID((string)role["RoleID"]);
                data.Title       = (string)role["Title"];

                Roles.Add(data);
            }

            return(Roles);
        }
Пример #3
0
        public List <GroupNoticeData> GetGroupNotices(GroupRequestID requestID, UUID GroupID)
        {
            Hashtable param = new Hashtable();

            param["GroupID"] = GroupID.ToString();

            Hashtable respData = XmlRpcCall(requestID, "groups.getGroupNotices", param);

            List <GroupNoticeData> values = new List <GroupNoticeData>();

            if (!respData.Contains("error"))
            {
                foreach (Hashtable value in respData.Values)
                {
                    GroupNoticeData data = new GroupNoticeData();
                    data.NoticeID      = UUID.Parse((string)value["NoticeID"]);
                    data.Timestamp     = uint.Parse((string)value["Timestamp"]);
                    data.FromName      = (string)value["FromName"];
                    data.Subject       = (string)value["Subject"];
                    data.HasAttachment = false;
                    data.AssetType     = 0;

                    values.Add(data);
                }
            }
            return(values);
        }
Пример #4
0
        public GroupNoticeInfo GetGroupNotice(GroupRequestID requestID, UUID noticeID)
        {
            Hashtable param = new Hashtable();

            param["NoticeID"] = noticeID.ToString();

            Hashtable respData = XmlRpcCall(requestID, "groups.getGroupNotice", param);


            if (respData.Contains("error"))
            {
                return(null);
            }

            GroupNoticeInfo data = new GroupNoticeInfo();

            data.GroupID                  = UUID.Parse((string)respData["GroupID"]);
            data.Message                  = (string)respData["Message"];
            data.BinaryBucket             = Utils.HexStringToBytes((string)respData["BinaryBucket"], true);
            data.noticeData.NoticeID      = UUID.Parse((string)respData["NoticeID"]);
            data.noticeData.Timestamp     = uint.Parse((string)respData["Timestamp"]);
            data.noticeData.FromName      = (string)respData["FromName"];
            data.noticeData.Subject       = (string)respData["Subject"];
            data.noticeData.HasAttachment = false;
            data.noticeData.AssetType     = 0;

            if (data.Message == null)
            {
                data.Message = string.Empty;
            }

            return(data);
        }
Пример #5
0
        public List <DirGroupsReplyData> FindGroups(GroupRequestID requestID, string search)
        {
            Hashtable param = new Hashtable();

            param["Search"] = search;

            Hashtable respData = XmlRpcCall(requestID, "groups.findGroups", param);

            List <DirGroupsReplyData> findings = new List <DirGroupsReplyData>();

            if (!respData.Contains("error"))
            {
                Hashtable results = (Hashtable)respData["results"];
                foreach (Hashtable groupFind in results.Values)
                {
                    DirGroupsReplyData data = new DirGroupsReplyData();
                    data.groupID   = new UUID((string)groupFind["GroupID"]);;
                    data.groupName = (string)groupFind["Name"];
                    data.members   = int.Parse((string)groupFind["Members"]);
                    // data.searchOrder = order;

                    findings.Add(data);
                }
            }

            return(findings);
        }
Пример #6
0
        public void RemoveAgentToGroupInvite(GroupRequestID requestID, UUID inviteID)
        {
            Hashtable param = new Hashtable();

            param["InviteID"] = inviteID.ToString();

            XmlRpcCall(requestID, "groups.removeAgentToGroupInvite", param);
        }
Пример #7
0
        public void RemoveAgentFromGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID)
        {
            Hashtable param = new Hashtable();

            param["AgentID"] = AgentID.ToString();
            param["GroupID"] = GroupID.ToString();

            XmlRpcCall(requestID, "groups.removeAgentFromGroup", param);
        }
Пример #8
0
        public void SetAgentActiveGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID)
        {
            Hashtable param = new Hashtable();

            param["AgentID"] = AgentID.ToString();
            param["GroupID"] = GroupID.ToString();

            XmlRpcCall(requestID, "groups.setAgentActiveGroup", param);
        }
Пример #9
0
        public void RemoveGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID)
        {
            Hashtable param = new Hashtable();

            param["GroupID"] = groupID.ToString();
            param["RoleID"]  = roleID.ToString();

            XmlRpcCall(requestID, "groups.removeRoleFromGroup", param);
        }
Пример #10
0
        public void AddAgentToGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID)
        {
            Hashtable param = new Hashtable();

            param["AgentID"] = AgentID.ToString();
            param["GroupID"] = GroupID.ToString();
            param["RoleID"]  = RoleID.ToString();

            XmlRpcCall(requestID, "groups.addAgentToGroupRole", param);
        }
Пример #11
0
        public void AddAgentToGroupInvite(GroupRequestID requestID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID)
        {
            Hashtable param = new Hashtable();

            param["InviteID"] = inviteID.ToString();
            param["AgentID"]  = agentID.ToString();
            param["RoleID"]   = roleID.ToString();
            param["GroupID"]  = groupID.ToString();

            XmlRpcCall(requestID, "groups.addAgentToGroupInvite", param);
        }
Пример #12
0
        public void SetAgentGroupInfo(GroupRequestID requestID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile)
        {
            Hashtable param = new Hashtable();

            param["AgentID"]       = AgentID.ToString();
            param["GroupID"]       = GroupID.ToString();
            param["AcceptNotices"] = AcceptNotices ? "1" : "0";
            param["ListInProfile"] = ListInProfile ? "1" : "0";

            XmlRpcCall(requestID, "groups.setAgentGroupInfo", param);
        }
Пример #13
0
        public void AddGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description,
                                 string title, ulong powers)
        {
            Hashtable param = new Hashtable();

            param["GroupID"]     = groupID.ToString();
            param["RoleID"]      = roleID.ToString();
            param["Name"]        = name;
            param["Description"] = description;
            param["Title"]       = title;
            param["Powers"]      = powers.ToString();

            XmlRpcCall(requestID, "groups.addRoleToGroup", param);
        }
Пример #14
0
        public GroupMembershipData GetAgentActiveMembership(GroupRequestID requestID, UUID AgentID)
        {
            Hashtable param = new Hashtable();

            param["AgentID"] = AgentID.ToString();

            Hashtable respData = XmlRpcCall(requestID, "groups.getAgentActiveMembership", param);

            if (respData.Contains("error"))
            {
                return(null);
            }

            return(HashTableToGroupMembershipData(respData));
        }
Пример #15
0
        public void AddGroupNotice(GroupRequestID requestID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
        {
            string binBucket = OpenMetaverse.Utils.BytesToHexString(binaryBucket, "");

            Hashtable param = new Hashtable();

            param["GroupID"]      = groupID.ToString();
            param["NoticeID"]     = noticeID.ToString();
            param["FromName"]     = fromName;
            param["Subject"]      = subject;
            param["Message"]      = message;
            param["BinaryBucket"] = binBucket;
            param["TimeStamp"]    = ((uint)Util.UnixTimeSinceEpoch()).ToString();

            XmlRpcCall(requestID, "groups.addGroupNotice", param);
        }
Пример #16
0
        public void UpdateGroup(GroupRequestID requestID, UUID groupID, string charter, bool showInList,
                                UUID insigniaID, int membershipFee, bool openEnrollment,
                                bool allowPublish, bool maturePublish)
        {
            Hashtable param = new Hashtable();

            param["GroupID"]        = groupID.ToString();
            param["Charter"]        = charter;
            param["ShowInList"]     = showInList == true ? 1 : 0;
            param["InsigniaID"]     = insigniaID.ToString();
            param["MembershipFee"]  = membershipFee;
            param["OpenEnrollment"] = openEnrollment == true ? 1 : 0;
            param["AllowPublish"]   = allowPublish == true ? 1 : 0;
            param["MaturePublish"]  = maturePublish == true ? 1 : 0;

            XmlRpcCall(requestID, "groups.updateGroup", param);
        }
Пример #17
0
        public List <GroupMembershipData> GetAgentGroupMemberships(GroupRequestID requestID, UUID AgentID)
        {
            Hashtable param = new Hashtable();

            param["AgentID"] = AgentID.ToString();

            Hashtable respData = XmlRpcCall(requestID, "groups.getAgentGroupMemberships", param);

            List <GroupMembershipData> memberships = new List <GroupMembershipData>();

            if (!respData.Contains("error"))
            {
                foreach (object membership in respData.Values)
                {
                    memberships.Add(HashTableToGroupMembershipData((Hashtable)membership));
                }
            }

            return(memberships);
        }
Пример #18
0
        /// <summary>
        /// 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.
        /// </summary>
        public UUID CreateGroup(GroupRequestID requestID, string name, string charter, bool showInList, UUID insigniaID,
                                int membershipFee, bool openEnrollment, bool allowPublish,
                                bool maturePublish, UUID founderID)
        {
            UUID GroupID     = UUID.Random();
            UUID OwnerRoleID = UUID.Random();

            Hashtable param = new Hashtable();

            param["GroupID"]        = GroupID.ToString();
            param["Name"]           = name;
            param["Charter"]        = charter;
            param["ShowInList"]     = showInList == true ? 1 : 0;
            param["InsigniaID"]     = insigniaID.ToString();
            param["MembershipFee"]  = 0;
            param["OpenEnrollment"] = openEnrollment == true ? 1 : 0;
            param["AllowPublish"]   = allowPublish == true ? 1 : 0;
            param["MaturePublish"]  = maturePublish == true ? 1 : 0;
            param["FounderID"]      = founderID.ToString();
            //param["EveryonePowers"] = ((ulong)m_DefaultEveryonePowers).ToString();
            param["OwnerRoleID"] = OwnerRoleID.ToString();

            // Would this be cleaner as (GroupPowers)ulong.MaxValue;
            GroupPowers OwnerPowers = (GroupPowers)ulong.MaxValue;;

            param["OwnersPowers"] = ((ulong)OwnerPowers).ToString();



            Hashtable respData = XmlRpcCall(requestID, "groups.createGroup", param);

            if (respData.Contains("error"))
            {
                // UUID is not nullable

                return(UUID.Zero);
            }

            return(UUID.Parse((string)respData["GroupID"]));
        }
Пример #19
0
        /// <summary>
        /// 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.
        /// </summary>
        public UUID CreateGroup(GroupRequestID requestID, string name, string charter, bool showInList, UUID insigniaID, 
                                int membershipFee, bool openEnrollment, bool allowPublish, 
                                bool maturePublish, UUID founderID)
        {
            UUID GroupID = UUID.Random();
            UUID OwnerRoleID = UUID.Random();

            Hashtable param = new Hashtable();
            param["GroupID"] = GroupID.ToString();
            param["Name"] = name;
            param["Charter"] = charter;
            param["ShowInList"] = showInList == true ? 1 : 0;
            param["InsigniaID"] = insigniaID.ToString();
            param["MembershipFee"] = 0;
            param["OpenEnrollment"] = openEnrollment == true ? 1 : 0;
            param["AllowPublish"] = allowPublish == true ? 1 : 0;
            param["MaturePublish"] = maturePublish == true ? 1 : 0;
            param["FounderID"] = founderID.ToString();
            //param["EveryonePowers"] = ((ulong)m_DefaultEveryonePowers).ToString();
            param["OwnerRoleID"] = OwnerRoleID.ToString();

            // Would this be cleaner as (GroupPowers)ulong.MaxValue;
            GroupPowers OwnerPowers = (GroupPowers)ulong.MaxValue; ;
            param["OwnersPowers"] = ((ulong)OwnerPowers).ToString();




            Hashtable respData = XmlRpcCall(requestID, "groups.createGroup", param);

            if (respData.Contains("error"))
            {
                // UUID is not nullable

                return UUID.Zero;
            }

            return UUID.Parse((string)respData["GroupID"]);
        }
Пример #20
0
        public GroupRecord GetGroupRecord(GroupRequestID requestID, UUID GroupID, string GroupName)
        {
            Hashtable param = new Hashtable();

            if (GroupID != UUID.Zero)
            {
                param["GroupID"] = GroupID.ToString();
            }
            if ((GroupName != null) && (GroupName != string.Empty))
            {
                param["Name"] = GroupName.ToString();
            }

            Hashtable respData = XmlRpcCall(requestID, "groups.getGroup", param);

            if (respData.Contains("error"))
            {
                return(null);
            }

            return(GroupProfileHashtableToGroupRecord(respData));
        }
Пример #21
0
        public GroupProfileData GetMemberGroupProfile(GroupRequestID requestID, UUID GroupID, UUID AgentID)
        {
            Hashtable param = new Hashtable();

            param["GroupID"] = GroupID.ToString();

            Hashtable respData = XmlRpcCall(requestID, "groups.getGroup", param);

            if (respData.Contains("error"))
            {
                // GroupProfileData is not nullable
                return(new GroupProfileData());
            }

            GroupMembershipData MemberInfo         = GetAgentGroupMembership(requestID, AgentID, GroupID);
            GroupProfileData    MemberGroupProfile = GroupProfileHashtableToGroupProfileData(respData);

            MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle;
            MemberGroupProfile.PowersMask  = MemberInfo.GroupPowers;

            return(MemberGroupProfile);
        }
Пример #22
0
        public GroupInviteInfo GetAgentToGroupInvite(GroupRequestID requestID, UUID inviteID)
        {
            Hashtable param = new Hashtable();

            param["InviteID"] = inviteID.ToString();

            Hashtable respData = XmlRpcCall(requestID, "groups.getAgentToGroupInvite", param);

            if (respData.Contains("error"))
            {
                return(null);
            }

            GroupInviteInfo inviteInfo = new GroupInviteInfo();

            inviteInfo.InviteID = inviteID;
            inviteInfo.GroupID  = UUID.Parse((string)respData["GroupID"]);
            inviteInfo.RoleID   = UUID.Parse((string)respData["RoleID"]);
            inviteInfo.AgentID  = UUID.Parse((string)respData["AgentID"]);

            return(inviteInfo);
        }
Пример #23
0
        public void UpdateGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description,
                                    string title, ulong powers)
        {
            Hashtable param = new Hashtable();

            param["GroupID"] = groupID.ToString();
            param["RoleID"]  = roleID.ToString();
            if (name != null)
            {
                param["Name"] = name;
            }
            if (description != null)
            {
                param["Description"] = description;
            }
            if (title != null)
            {
                param["Title"] = title;
            }
            param["Powers"] = powers.ToString();

            XmlRpcCall(requestID, "groups.updateGroupRole", param);
        }
Пример #24
0
        public List <GroupRoleMembersData> GetGroupRoleMembers(GroupRequestID requestID, UUID GroupID)
        {
            Hashtable param = new Hashtable();

            param["GroupID"] = GroupID.ToString();

            Hashtable respData = XmlRpcCall(requestID, "groups.getGroupRoleMembers", param);

            List <GroupRoleMembersData> members = new List <GroupRoleMembersData>();

            if (!respData.Contains("error"))
            {
                foreach (Hashtable membership in respData.Values)
                {
                    GroupRoleMembersData data = new GroupRoleMembersData();

                    data.MemberID = new UUID((string)membership["AgentID"]);
                    data.RoleID   = new UUID((string)membership["RoleID"]);

                    members.Add(data);
                }
            }
            return(members);
        }
        public GroupInviteInfo GetAgentToGroupInvite(GroupRequestID requestID, UUID inviteID)
        {
            Hashtable param = new Hashtable();
            param["InviteID"] = inviteID.ToString();

            Hashtable respData = XmlRpcCall(requestID, "groups.getAgentToGroupInvite", param);

            if (respData.Contains("error"))
            {
                return null;
            }

            GroupInviteInfo inviteInfo = new GroupInviteInfo();
            inviteInfo.InviteID = inviteID;
            inviteInfo.GroupID = UUID.Parse((string)respData["GroupID"]);
            inviteInfo.RoleID = UUID.Parse((string)respData["RoleID"]);
            inviteInfo.AgentID = UUID.Parse((string)respData["AgentID"]);

            return inviteInfo;
        }
        public void AddGroupNotice(GroupRequestID requestID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
        {
            string binBucket = OpenMetaverse.Utils.BytesToHexString(binaryBucket, "");

            Hashtable param = new Hashtable();
            param["GroupID"] = groupID.ToString();
            param["NoticeID"] = noticeID.ToString();
            param["FromName"] = fromName;
            param["Subject"] = subject;
            param["Message"] = message;
            param["BinaryBucket"] = binBucket;
            param["TimeStamp"] = ((uint)Util.UnixTimeSinceEpoch()).ToString();

            XmlRpcCall(requestID, "groups.addGroupNotice", param);
        }
        public void RemoveAgentToGroupInvite(GroupRequestID requestID, UUID inviteID)
        {
            Hashtable param = new Hashtable();
            param["InviteID"] = inviteID.ToString();

            XmlRpcCall(requestID, "groups.removeAgentToGroupInvite", param);
        }
Пример #28
0
        private Hashtable XmlRpcCall(GroupRequestID requestID, string function, Hashtable param)
        {
            if (requestID == null)
            {
                requestID = new GroupRequestID();
            }
            param.Add("RequestingAgentID", requestID.AgentID.ToString());
            param.Add("RequestingAgentUserService", requestID.UserServiceURL);
            param.Add("RequestingSessionID", requestID.SessionID.ToString());


            param.Add("ReadKey", m_groupReadKey);
            param.Add("WriteKey", m_groupWriteKey);


            IList parameters = new ArrayList();

            parameters.Add(param);

            XmlRpcRequest req;

            if (!m_disableKeepAlive)
            {
                req = new XmlRpcRequest(function, parameters);
            }
            else
            {
                // This seems to solve a major problem on some windows servers
                req = new NoKeepAliveXmlRpcRequest(function, parameters);
            }

            XmlRpcResponse resp = null;

            try
            {
                resp = req.Send(m_serviceURL, 10000);
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[XMLRPCGROUPDATA]: An error has occured while attempting to access the XmlRpcGroups server method: {0}", function);
                m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", e.ToString());


                foreach (string key in param.Keys)
                {
                    m_log.WarnFormat("[XMLRPCGROUPDATA]: {0} :: {1}", key, param[key].ToString());
                }

                Hashtable respData = new Hashtable();
                respData.Add("error", e.ToString());
                return(respData);
            }

            if (resp.Value is Hashtable)
            {
                Hashtable respData = (Hashtable)resp.Value;
                if (respData.Contains("error") && !respData.Contains("succeed"))
                {
                    LogRespDataToConsoleError(respData);
                }

                return(respData);
            }

            m_log.ErrorFormat("[XMLRPCGROUPDATA]: The XmlRpc server returned a {1} instead of a hashtable for {0}", function, resp.Value.GetType().ToString());

            if (resp.Value is ArrayList)
            {
                ArrayList al = (ArrayList)resp.Value;
                m_log.ErrorFormat("[XMLRPCGROUPDATA]: Contains {0} elements", al.Count);

                foreach (object o in al)
                {
                    m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} :: {1}", o.GetType().ToString(), o.ToString());
                }
            }
            else
            {
                m_log.ErrorFormat("[XMLRPCGROUPDATA]: Function returned: {0}", resp.Value.ToString());
            }

            Hashtable error = new Hashtable();

            error.Add("error", "invalid return value");
            return(error);
        }
        public List<GroupRoleMembersData> GetGroupRoleMembers(GroupRequestID requestID, UUID GroupID)
        {
            Hashtable param = new Hashtable();
            param["GroupID"] = GroupID.ToString();

            Hashtable respData = XmlRpcCall(requestID, "groups.getGroupRoleMembers", param);

            List<GroupRoleMembersData> members = new List<GroupRoleMembersData>();

            if (!respData.Contains("error"))
            {
                foreach (Hashtable membership in respData.Values)
                {
                    GroupRoleMembersData data = new GroupRoleMembersData();

                    data.MemberID = new UUID((string)membership["AgentID"]);
                    data.RoleID = new UUID((string)membership["RoleID"]);

                    members.Add(data);
                }
            }
            return members;
        }
        public GroupNoticeInfo GetGroupNotice(GroupRequestID requestID, UUID noticeID)
        {
            Hashtable param = new Hashtable();
            param["NoticeID"] = noticeID.ToString();

            Hashtable respData = XmlRpcCall(requestID, "groups.getGroupNotice", param);


            if (respData.Contains("error"))
            {
                return null;
            }

            GroupNoticeInfo data = new GroupNoticeInfo();
            data.GroupID = UUID.Parse((string)respData["GroupID"]);
            data.Message = (string)respData["Message"];
            data.BinaryBucket = Utils.HexStringToBytes((string)respData["BinaryBucket"], true);
            data.noticeData.NoticeID = UUID.Parse((string)respData["NoticeID"]);
            data.noticeData.Timestamp = uint.Parse((string)respData["Timestamp"]);
            data.noticeData.FromName = (string)respData["FromName"];
            data.noticeData.Subject = (string)respData["Subject"];
            data.noticeData.HasAttachment = false;
            data.noticeData.AssetType = 0;

            if (data.Message == null)
            {
                data.Message = string.Empty;
            }

            return data;
        }
        public void AddGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, 
                                 string title, ulong powers)
        {
            Hashtable param = new Hashtable();
            param["GroupID"] = groupID.ToString();
            param["RoleID"] = roleID.ToString();
            param["Name"] = name;
            param["Description"] = description;
            param["Title"] = title;
            param["Powers"] = powers.ToString();

            XmlRpcCall(requestID, "groups.addRoleToGroup", param);
        }
        public void AddAgentToGroupInvite(GroupRequestID requestID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID)
        {
            Hashtable param = new Hashtable();
            param["InviteID"] = inviteID.ToString();
            param["AgentID"] = agentID.ToString();
            param["RoleID"] = roleID.ToString();
            param["GroupID"] = groupID.ToString();

            XmlRpcCall(requestID, "groups.addAgentToGroupInvite", param);

        }
        public void SetAgentActiveGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID)
        {
            Hashtable param = new Hashtable();
            param["AgentID"] = AgentID.ToString();
            param["GroupID"] = GroupID.ToString();
            param["SelectedRoleID"] = RoleID.ToString();

            XmlRpcCall(requestID, "groups.setAgentGroupInfo", param);
        }
        public GroupMembershipData GetAgentActiveMembership(GroupRequestID requestID, UUID AgentID)
        {
            Hashtable param = new Hashtable();
            param["AgentID"] = AgentID.ToString();

            Hashtable respData = XmlRpcCall(requestID, "groups.getAgentActiveMembership", param);

            if (respData.Contains("error"))
            {
                return null;
            }

            return HashTableToGroupMembershipData(respData);
        }
        public List<GroupMembershipData> GetAgentGroupMemberships(GroupRequestID requestID, UUID AgentID)
        {
            Hashtable param = new Hashtable();
            param["AgentID"] = AgentID.ToString();

            Hashtable respData = XmlRpcCall(requestID, "groups.getAgentGroupMemberships", param);

            List<GroupMembershipData> memberships = new List<GroupMembershipData>();

            if (!respData.Contains("error"))
            {
                foreach (object membership in respData.Values)
                {
                    memberships.Add(HashTableToGroupMembershipData((Hashtable)membership));
                }
            }
            
            return memberships;
        }
        public List<GroupRolesData> GetGroupRoles(GroupRequestID requestID, UUID GroupID)
        {
            Hashtable param = new Hashtable();
            param["GroupID"] = GroupID.ToString();

            Hashtable respData = XmlRpcCall(requestID, "groups.getGroupRoles", param);

            List<GroupRolesData> Roles = new List<GroupRolesData>();

            if (respData.Contains("error"))
            {
                return Roles;
            }

            foreach (Hashtable role in respData.Values)
            {
                GroupRolesData data = new GroupRolesData();
                data.Description = (string)role["Description"];
                data.Members = int.Parse((string)role["Members"]);
                data.Name = (string)role["Name"];
                data.Powers = ulong.Parse((string)role["Powers"]);
                data.RoleID = new UUID((string)role["RoleID"]);
                data.Title = (string)role["Title"];

                Roles.Add(data);
            }

            return Roles;

        }
        /// <summary>
        /// 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.
        /// </summary>
        public UUID CreateGroup(GroupRequestID requestID, string name, string charter, bool showInList, UUID insigniaID, 
                                int membershipFee, bool openEnrollment, bool allowPublish, 
                                bool maturePublish, UUID founderID)
        {
            UUID GroupID = UUID.Random();
            UUID OwnerRoleID = UUID.Random();

            Hashtable param = new Hashtable();
            param["GroupID"] = GroupID.ToString();
            param["Name"] = name;
            param["Charter"] = charter;
            param["ShowInList"] = showInList == true ? 1 : 0;
            param["InsigniaID"] = insigniaID.ToString();
            param["MembershipFee"] = 0;
            param["OpenEnrollment"] = openEnrollment == true ? 1 : 0;
            param["AllowPublish"] = allowPublish == true ? 1 : 0;
            param["MaturePublish"] = maturePublish == true ? 1 : 0;
            param["FounderID"] = founderID.ToString();
            param["EveryonePowers"] = ((ulong)m_DefaultEveryonePowers).ToString();
            param["OwnerRoleID"] = OwnerRoleID.ToString();

            // Would this be cleaner as (GroupPowers)ulong.MaxValue;
            GroupPowers OwnerPowers = GroupPowers.Accountable
                                    | GroupPowers.AllowEditLand
                                    | GroupPowers.AllowFly
                                    | GroupPowers.AllowLandmark
                                    | GroupPowers.AllowRez
                                    | GroupPowers.AllowSetHome
                                    | GroupPowers.AllowVoiceChat
                                    | GroupPowers.AssignMember
                                    | GroupPowers.AssignMemberLimited
                                    | GroupPowers.ChangeActions
                                    | GroupPowers.ChangeIdentity
                                    | GroupPowers.ChangeMedia
                                    | GroupPowers.ChangeOptions
                                    | GroupPowers.CreateRole
                                    | GroupPowers.DeedObject
                                    | GroupPowers.DeleteRole
                                    | GroupPowers.Eject
                                    | GroupPowers.FindPlaces
                                    | GroupPowers.Invite
                                    | GroupPowers.JoinChat
                                    | GroupPowers.LandChangeIdentity
                                    | GroupPowers.LandDeed
                                    | GroupPowers.LandDivideJoin
                                    | GroupPowers.LandEdit
                                    | GroupPowers.LandEjectAndFreeze
                                    | GroupPowers.LandGardening
                                    | GroupPowers.LandManageAllowed
                                    | GroupPowers.LandManageBanned
                                    | GroupPowers.LandManagePasses
                                    | GroupPowers.LandOptions
                                    | GroupPowers.LandRelease
                                    | GroupPowers.LandSetSale
                                    | GroupPowers.ModerateChat
                                    | GroupPowers.ObjectManipulate
                                    | GroupPowers.ObjectSetForSale
                                    | GroupPowers.ReceiveNotices
                                    | GroupPowers.RemoveMember
                                    | GroupPowers.ReturnGroupOwned
                                    | GroupPowers.ReturnGroupSet
                                    | GroupPowers.ReturnNonGroup
                                    | GroupPowers.RoleProperties
                                    | GroupPowers.SendNotices
                                    | GroupPowers.SetLandingPoint
                                    | GroupPowers.StartProposal
                                    | GroupPowers.VoteOnProposal;
            param["OwnersPowers"] = ((ulong)OwnerPowers).ToString();




            Hashtable respData = XmlRpcCall(requestID, "groups.createGroup", param);

            if (respData.Contains("error"))
            {
                // UUID is not nullable

                return UUID.Zero;
            }

            return UUID.Parse((string)respData["GroupID"]);
        }
        /// <summary>
        /// Encapsulate the XmlRpc call to standardize security and error handling.
        /// </summary>
        private Hashtable XmlRpcCall(GroupRequestID requestID, string function, Hashtable param)
        {
            if (requestID == null)
            {
                requestID = new GroupRequestID();
            }
            param.Add("RequestingAgentID", requestID.AgentID.ToString());
            param.Add("RequestingAgentUserService", requestID.UserServiceURL);
            param.Add("RequestingSessionID", requestID.SessionID.ToString());
            

            param.Add("ReadKey", m_groupReadKey);
            param.Add("WriteKey", m_groupWriteKey);


            IList parameters = new ArrayList();
            parameters.Add(param);

            ConfigurableKeepAliveXmlRpcRequest req;
            req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive);

            XmlRpcResponse resp = null;

            try
            {
                resp = req.Send(m_serviceURL, 10000);
            }
            catch (Exception e)
            {
                

                m_log.ErrorFormat("[XMLRPCGROUPDATA]: An error has occured while attempting to access the XmlRpcGroups server method: {0}", function);
                m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", e.ToString());

                foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine },StringSplitOptions.None))
                {
                    m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", ResponseLine);
                }

                foreach (string key in param.Keys)
                {
                    m_log.WarnFormat("[XMLRPCGROUPDATA]: {0} :: {1}", key, param[key].ToString());
                }

                Hashtable respData = new Hashtable();
                respData.Add("error", e.ToString());
                return respData;
            }

            if (resp.Value is Hashtable)
            {
                Hashtable respData = (Hashtable)resp.Value;
                if (respData.Contains("error") && !respData.Contains("succeed"))
                {
                    LogRespDataToConsoleError(respData);
                }

                return respData;
            }

            m_log.ErrorFormat("[XMLRPCGROUPDATA]: The XmlRpc server returned a {1} instead of a hashtable for {0}", function, resp.Value.GetType().ToString());

            if (resp.Value is ArrayList)
            {
                ArrayList al = (ArrayList)resp.Value;
                m_log.ErrorFormat("[XMLRPCGROUPDATA]: Contains {0} elements", al.Count);

                foreach (object o in al)
                {
                    m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} :: {1}", o.GetType().ToString(), o.ToString());
                }
            }
            else
            {
                m_log.ErrorFormat("[XMLRPCGROUPDATA]: Function returned: {0}", resp.Value.ToString());
            }

            Hashtable error = new Hashtable();
            error.Add("error", "invalid return value");
            return error;
        }
        public void SetAgentGroupInfo(GroupRequestID requestID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile)
        {
            Hashtable param = new Hashtable();
            param["AgentID"] = AgentID.ToString();
            param["GroupID"] = GroupID.ToString();
            param["AcceptNotices"] = AcceptNotices ? "1" : "0";
            param["ListInProfile"] = ListInProfile ? "1" : "0";

            XmlRpcCall(requestID, "groups.setAgentGroupInfo", param);

        }
        public GroupRecord GetGroupRecord(GroupRequestID requestID, UUID GroupID, string GroupName)
        {
            Hashtable param = new Hashtable();
            if (GroupID != UUID.Zero)
            {
                param["GroupID"] = GroupID.ToString();
            }
            if ((GroupName != null) && (GroupName != string.Empty))
            {
                param["Name"] = GroupName.ToString();
            }

            Hashtable respData = XmlRpcCall(requestID, "groups.getGroup", param);

            if (respData.Contains("error"))
            {
                return null;
            }

            return GroupProfileHashtableToGroupRecord(respData);

        }
        public GroupProfileData GetMemberGroupProfile(GroupRequestID requestID, UUID GroupID, UUID AgentID)
        {
            Hashtable param = new Hashtable();
            param["GroupID"] = GroupID.ToString();

            Hashtable respData = XmlRpcCall(requestID, "groups.getGroup", param);

            if (respData.Contains("error"))
            {
                // GroupProfileData is not nullable
                return new GroupProfileData();
            }

            GroupMembershipData MemberInfo = GetAgentGroupMembership(requestID, AgentID, GroupID);
            GroupProfileData MemberGroupProfile = GroupProfileHashtableToGroupProfileData(respData);

            MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle;
            MemberGroupProfile.PowersMask = MemberInfo.GroupPowers;

            return MemberGroupProfile;
        }
        public List<GroupNoticeData> GetGroupNotices(GroupRequestID requestID, UUID GroupID)
        {
            Hashtable param = new Hashtable();
            param["GroupID"] = GroupID.ToString();

            Hashtable respData = XmlRpcCall(requestID, "groups.getGroupNotices", param);

            List<GroupNoticeData> values = new List<GroupNoticeData>();

            if (!respData.Contains("error"))
            {
                foreach (Hashtable value in respData.Values)
                {
                    GroupNoticeData data = new GroupNoticeData();
                    data.NoticeID = UUID.Parse((string)value["NoticeID"]);
                    data.Timestamp = uint.Parse((string)value["Timestamp"]);
                    data.FromName = (string)value["FromName"];
                    data.Subject = (string)value["Subject"];
                    data.HasAttachment = false;
                    data.AssetType = 0;

                    values.Add(data);
                }
            }
            return values;

        }
        public void UpdateGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, 
                                    string title, ulong powers)
        {
            Hashtable param = new Hashtable();
            param["GroupID"] = groupID.ToString();
            param["RoleID"] = roleID.ToString();
            if (name != null)
            {
                param["Name"] = name;
            }
            if (description != null)
            {
                param["Description"] = description;
            }
            if (title != null)
            {
                param["Title"] = title;
            }
            param["Powers"] = powers.ToString();

            XmlRpcCall(requestID, "groups.updateGroupRole", param);
        }
        public List<DirGroupsReplyData> FindGroups(GroupRequestID requestID, string search)
        {
            Hashtable param = new Hashtable();
            param["Search"] = search;

            Hashtable respData = XmlRpcCall(requestID, "groups.findGroups", param);

            List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>();

            if (!respData.Contains("error"))
            {
                Hashtable results = (Hashtable)respData["results"];
                foreach (Hashtable groupFind in results.Values)
                {
                    DirGroupsReplyData data = new DirGroupsReplyData();
                    data.groupID = new UUID((string)groupFind["GroupID"]); ;
                    data.groupName = (string)groupFind["Name"];
                    data.members = int.Parse((string)groupFind["Members"]);
                    // data.searchOrder = order;

                    findings.Add(data);
                }
            }

            return findings;
        }
        public void RemoveGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID)
        {
            Hashtable param = new Hashtable();
            param["GroupID"] = groupID.ToString();
            param["RoleID"] = roleID.ToString();

            XmlRpcCall(requestID, "groups.removeRoleFromGroup", param);
        }
        public void RemoveAgentFromGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID)
        {
            Hashtable param = new Hashtable();
            param["AgentID"] = AgentID.ToString();
            param["GroupID"] = GroupID.ToString();
            param["RoleID"] = RoleID.ToString();

            XmlRpcCall(requestID, "groups.removeAgentFromGroupRole", param);
        }
        public void UpdateGroup(GroupRequestID requestID, UUID groupID, string charter, bool showInList, 
                                UUID insigniaID, int membershipFee, bool openEnrollment, 
                                bool allowPublish, bool maturePublish)
        {
            Hashtable param = new Hashtable();
            param["GroupID"] = groupID.ToString();
            param["Charter"] = charter;
            param["ShowInList"] = showInList == true ? 1 : 0;
            param["InsigniaID"] = insigniaID.ToString();
            param["MembershipFee"] = membershipFee;
            param["OpenEnrollment"] = openEnrollment == true ? 1 : 0;
            param["AllowPublish"] = allowPublish == true ? 1 : 0;
            param["MaturePublish"] = maturePublish == true ? 1 : 0;

            XmlRpcCall(requestID, "groups.updateGroup", param);
        }
        public void AddAgentToGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID)
        {
            Hashtable param = new Hashtable();
            param["AgentID"] = AgentID.ToString();
            param["GroupID"] = GroupID.ToString();
            param["RoleID"] = RoleID.ToString();

            XmlRpcCall(requestID, "groups.addAgentToGroup", param);
        }
Пример #49
0
        /// <summary>
        /// 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.
        /// </summary>
        public UUID CreateGroup(GroupRequestID requestID, string name, string charter, bool showInList, UUID insigniaID,
                                int membershipFee, bool openEnrollment, bool allowPublish,
                                bool maturePublish, UUID founderID)
        {
            UUID GroupID     = UUID.Random();
            UUID OwnerRoleID = UUID.Random();

            Hashtable param = new Hashtable();

            param["GroupID"]        = GroupID.ToString();
            param["Name"]           = name;
            param["Charter"]        = charter;
            param["ShowInList"]     = showInList == true ? 1 : 0;
            param["InsigniaID"]     = insigniaID.ToString();
            param["MembershipFee"]  = 0;
            param["OpenEnrollment"] = openEnrollment == true ? 1 : 0;
            param["AllowPublish"]   = allowPublish == true ? 1 : 0;
            param["MaturePublish"]  = maturePublish == true ? 1 : 0;
            param["FounderID"]      = founderID.ToString();
            param["EveryonePowers"] = ((ulong)m_DefaultEveryonePowers).ToString();
            param["OwnerRoleID"]    = OwnerRoleID.ToString();

            // Would this be cleaner as (GroupPowers)ulong.MaxValue;
            GroupPowers OwnerPowers = GroupPowers.Accountable
                                      | GroupPowers.AllowEditLand
                                      | GroupPowers.AllowFly
                                      | GroupPowers.AllowLandmark
                                      | GroupPowers.AllowRez
                                      | GroupPowers.AllowSetHome
                                      | GroupPowers.AllowVoiceChat
                                      | GroupPowers.AssignMember
                                      | GroupPowers.AssignMemberLimited
                                      | GroupPowers.ChangeActions
                                      | GroupPowers.ChangeIdentity
                                      | GroupPowers.ChangeMedia
                                      | GroupPowers.ChangeOptions
                                      | GroupPowers.CreateRole
                                      | GroupPowers.DeedObject
                                      | GroupPowers.DeleteRole
                                      | GroupPowers.Eject
                                      | GroupPowers.FindPlaces
                                      | GroupPowers.Invite
                                      | GroupPowers.JoinChat
                                      | GroupPowers.LandChangeIdentity
                                      | GroupPowers.LandDeed
                                      | GroupPowers.LandDivideJoin
                                      | GroupPowers.LandEdit
                                      | GroupPowers.LandEjectAndFreeze
                                      | GroupPowers.LandGardening
                                      | GroupPowers.LandManageAllowed
                                      | GroupPowers.LandManageBanned
                                      | GroupPowers.LandManagePasses
                                      | GroupPowers.LandOptions
                                      | GroupPowers.LandRelease
                                      | GroupPowers.LandSetSale
                                      | GroupPowers.ModerateChat
                                      | GroupPowers.ObjectManipulate
                                      | GroupPowers.ObjectSetForSale
                                      | GroupPowers.ReceiveNotices
                                      | GroupPowers.RemoveMember
                                      | GroupPowers.ReturnGroupOwned
                                      | GroupPowers.ReturnGroupSet
                                      | GroupPowers.ReturnNonGroup
                                      | GroupPowers.RoleProperties
                                      | GroupPowers.SendNotices
                                      | GroupPowers.SetLandingPoint
                                      | GroupPowers.StartProposal
                                      | GroupPowers.VoteOnProposal;

            param["OwnersPowers"] = ((ulong)OwnerPowers).ToString();



            Hashtable respData = XmlRpcCall(requestID, "groups.createGroup", param);

            if (respData.Contains("error"))
            {
                // UUID is not nullable

                return(UUID.Zero);
            }

            return(UUID.Parse((string)respData["GroupID"]));
        }
        public List<GroupMembersData> GetGroupMembers(GroupRequestID requestID, UUID GroupID)
        {
            Hashtable param = new Hashtable();
            param["GroupID"] = GroupID.ToString();

            Hashtable respData = XmlRpcCall(requestID, "groups.getGroupMembers", param);

            List<GroupMembersData> members = new List<GroupMembersData>();

            if (respData.Contains("error"))
            {
                return members;
            }

            foreach (Hashtable membership in respData.Values)
            {
                GroupMembersData data = new GroupMembersData();

                data.AcceptNotices = ((string)membership["AcceptNotices"]) == "1";
                data.AgentID = new UUID((string)membership["AgentID"]);
                data.Contribution = int.Parse((string)membership["Contribution"]);
                data.IsOwner = ((string)membership["IsOwner"]) == "1";
                data.ListInProfile = ((string)membership["ListInProfile"]) == "1";
                data.AgentPowers = ulong.Parse((string)membership["AgentPowers"]);
                data.Title = (string)membership["Title"];

                members.Add(data);
            }

            return members;

        }