Exemple #1
0
        byte[] HandleGetNotices(Dictionary <string, object> request)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            if (!request.ContainsKey("RequestingAgentID"))
            {
                NullResult(result, "Bad network data");
            }

            else if (request.ContainsKey("NoticeID")) // just one
            {
                GroupNoticeInfo notice = m_GroupsService.GetGroupNotice(request["RequestingAgentID"].ToString(), new UUID(request["NoticeID"].ToString()));

                if (notice == null)
                {
                    NullResult(result, "NO such notice");
                }
                else
                {
                    result["RESULT"] = GroupsDataUtils.GroupNoticeInfo(notice);
                }
            }
            else if (request.ContainsKey("GroupID")) // all notices for group
            {
                List <ExtendedGroupNoticeData> notices = m_GroupsService.GetGroupNotices(request["RequestingAgentID"].ToString(), new UUID(request["GroupID"].ToString()));

                if (notices == null || (notices != null && notices.Count == 0))
                {
                    NullResult(result, "No notices");
                }
                else
                {
                    Dictionary <string, object> dict = new Dictionary <string, object>();
                    int i = 0;
                    foreach (ExtendedGroupNoticeData n in notices)
                    {
                        dict["n-" + i++] = GroupsDataUtils.GroupNoticeData(n);
                    }

                    result["RESULT"] = dict;
                }
            }
            else
            {
                NullResult(result, "Bad OP in request");
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);

            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
Exemple #2
0
        byte[] GetMultiAccounts(Dictionary <string, object> request)
        {
            UUID scopeID = UUID.Zero;

            if (request.ContainsKey("ScopeID") && !UUID.TryParse(request["ScopeID"].ToString(), out scopeID))
            {
                return(FailureResult());
            }

            if (!request.ContainsKey("IDS"))
            {
                m_log.DebugFormat("[USER SERVICE HANDLER]: GetMultiAccounts called without required uuids argument");
                return(FailureResult());
            }

            if (!(request["IDS"] is List <string>))
            {
                m_log.DebugFormat("[USER SERVICE HANDLER]: GetMultiAccounts input argument was of unexpected type {0}", request["IDS"].GetType().ToString());
                return(FailureResult());
            }

            List <string> userIDs = (List <string>)request["IDS"];

            List <UserAccount> accounts = m_UserAccountService.GetUserAccounts(scopeID, userIDs);

            Dictionary <string, object> result = new Dictionary <string, object>();

            if ((accounts == null) || ((accounts != null) && (accounts.Count == 0)))
            {
                result["result"] = "null";
            }
            else
            {
                int i = 0;
                foreach (UserAccount acc in accounts)
                {
                    if (acc == null)
                    {
                        continue;
                    }
                    Dictionary <string, object> rinfoDict = acc.ToKeyValuePairs();
                    result["account" + i] = rinfoDict;
                    i++;
                }
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);

            //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
        byte[] GetRegionByPosition(Dictionary <string, object> request)
        {
            UUID scopeID = UUID.Zero;

            if (request.ContainsKey("SCOPEID"))
            {
                UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
            }
            else
            {
                m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by position");
            }

            int x = 0, y = 0;

            if (request.ContainsKey("X"))
            {
                Int32.TryParse(request["X"].ToString(), out x);
            }
            else
            {
                m_log.WarnFormat("[GRID HANDLER]: no X in request to get region by position");
            }
            if (request.ContainsKey("Y"))
            {
                Int32.TryParse(request["Y"].ToString(), out y);
            }
            else
            {
                m_log.WarnFormat("[GRID HANDLER]: no Y in request to get region by position");
            }

            // m_log.DebugFormat("{0} GetRegionByPosition: loc=<{1},{2}>", LogHeader, x, y);
            GridRegion rinfo = m_GridService.GetRegionByPosition(scopeID, x, y);

            Dictionary <string, object> result = new Dictionary <string, object>();

            if (rinfo == null)
            {
                result["result"] = "null";
            }
            else
            {
                result["result"] = rinfo.ToKeyValuePairs();
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);

            //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
        byte[] HandleInvite(Dictionary <string, object> request)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            if (!request.ContainsKey("RequestingAgentID") || !request.ContainsKey("InviteID"))
            {
                NullResult(result, "Bad network data");
                string xmlString = ServerUtils.BuildXmlResponse(result);
                return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
            }
            else
            {
                string op = request["OP"].ToString();

                if (op == "ADD" && request.ContainsKey("GroupID") && request.ContainsKey("RoleID") && request.ContainsKey("AgentID"))
                {
                    bool success = m_GroupsService.AddAgentToGroupInvite(request["RequestingAgentID"].ToString(),
                                                                         new UUID(request["InviteID"].ToString()), new UUID(request["GroupID"].ToString()),
                                                                         new UUID(request["RoleID"].ToString()), request["AgentID"].ToString());

                    result["RESULT"] = success.ToString();
                    return(Util.UTF8NoBomEncoding.GetBytes(ServerUtils.BuildXmlResponse(result)));
                }
                else if (op == "DELETE")
                {
                    m_GroupsService.RemoveAgentToGroupInvite(request["RequestingAgentID"].ToString(), new UUID(request["InviteID"].ToString()));
                    result["RESULT"] = "true";
                    return(Util.UTF8NoBomEncoding.GetBytes(ServerUtils.BuildXmlResponse(result)));
                }
                else if (op == "GET")
                {
                    GroupInviteInfo invite = m_GroupsService.GetAgentToGroupInvite(request["RequestingAgentID"].ToString(),
                                                                                   new UUID(request["InviteID"].ToString()));

                    if (invite != null)
                    {
                        result["RESULT"] = GroupsDataUtils.GroupInviteInfo(invite);
                    }
                    else
                    {
                        result["RESULT"] = "NULL";
                    }

                    return(Util.UTF8NoBomEncoding.GetBytes(ServerUtils.BuildXmlResponse(result)));
                }

                NullResult(result, "Bad OP in request");
                return(Util.UTF8NoBomEncoding.GetBytes(ServerUtils.BuildXmlResponse(result)));
            }
        }
        byte[] GetNeighbours(Dictionary <string, object> request)
        {
            UUID scopeID = UUID.Zero;

            if (request.ContainsKey("SCOPEID"))
            {
                UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
            }
            else
            {
                m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours");
            }

            UUID regionID = UUID.Zero;

            if (request.ContainsKey("REGIONID"))
            {
                UUID.TryParse(request["REGIONID"].ToString(), out regionID);
            }
            else
            {
                m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours");
            }

            List <GridRegion> rinfos = m_GridService.GetNeighbours(scopeID, regionID);
            //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);

            Dictionary <string, object> result = new Dictionary <string, object>();

            if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
            {
                result["result"] = "null";
            }
            else
            {
                int i = 0;
                foreach (GridRegion rinfo in rinfos)
                {
                    Dictionary <string, object> rinfoDict = rinfo.ToKeyValuePairs();
                    result["region" + i] = rinfoDict;
                    i++;
                }
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);
            //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
            UTF8Encoding encoding = new UTF8Encoding();

            return(encoding.GetBytes(xmlString));
        }
        byte[] HandleAddOrUpdateGroup(Dictionary <string, object> request)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            ExtendedGroupRecord grec = GroupsDataUtils.GroupRecord(request);

            if (!request.ContainsKey("RequestingAgentID") || !request.ContainsKey("OP"))
            {
                NullResult(result, "Bad network data");
            }

            else
            {
                string RequestingAgentID = request["RequestingAgentID"].ToString();
                string reason            = string.Empty;
                string op = request["OP"].ToString();
                if (op == "ADD")
                {
                    grec.GroupID = m_GroupsService.CreateGroup(RequestingAgentID, grec.GroupName, grec.Charter, grec.ShowInList, grec.GroupPicture, grec.MembershipFee,
                                                               grec.OpenEnrollment, grec.AllowPublish, grec.MaturePublish, grec.FounderID, out reason);
                }
                else if (op == "UPDATE")
                {
                    m_GroupsService.UpdateGroup(RequestingAgentID, grec.GroupID, grec.Charter, grec.ShowInList, grec.GroupPicture, grec.MembershipFee,
                                                grec.OpenEnrollment, grec.AllowPublish, grec.MaturePublish);
                }

                if (grec.GroupID != UUID.Zero)
                {
                    grec = m_GroupsService.GetGroupRecord(RequestingAgentID, grec.GroupID);
                    if (grec == null)
                    {
                        NullResult(result, "Internal Error");
                    }
                    else
                    {
                        result["RESULT"] = GroupsDataUtils.GroupRecord(grec);
                    }
                }
                else
                {
                    NullResult(result, reason);
                }
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);

            //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
Exemple #7
0
        protected override byte[] ProcessRequest(string path, Stream requestData,
                                                 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            string body;

            using (StreamReader sr = new StreamReader(requestData))
                body = sr.ReadToEnd();
            body = body.Trim();

            //m_log.DebugFormat("[get_display_names]: query String: {0}", body);

            Dictionary <string, object> request = ServerUtils.ParseQueryString(body);


            List <string> userIDs;

            if (!request.ContainsKey("AgentIDs"))
            {
                m_log.DebugFormat("[GRID USER HANDLER]: get_display_names called without required uuids argument");
                return(new byte[0]);
            }

            if (!(request["AgentIDs"] is List <string>))
            {
                m_log.DebugFormat("[GRID USER HANDLER]: get_display_names input argument was of unexpected type {0}", request["uuids"].GetType().ToString());
                return(new byte[0]);
            }

            userIDs = (List <string>)request["AgentIDs"];

            List <UserAccount> userAccounts = m_UserAccountService.GetUserAccounts(UUID.Zero, userIDs);

            Dictionary <string, object> result = new Dictionary <string, object>();

            int i = 0;

            foreach (UserAccount user in userAccounts)
            {
                result["uuid" + i] = user.PrincipalID;
                result["name" + i] = user.DisplayName;
                i++;
            }

            result["success"] = "true";

            string xmlString = ServerUtils.BuildXmlResponse(result);

            //m_log.InfoFormat("[get_display_name]: response string: {0}", xmlString);
            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
        byte[] GetGridExtraFeatures(Dictionary <string, object> request)
        {
            Dictionary <string, object> result        = new Dictionary <string, object> ();
            Dictionary <string, object> extraFeatures = m_GridService.GetExtraFeatures();

            foreach (string key in extraFeatures.Keys)
            {
                result [key] = extraFeatures [key];
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);

            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
        byte[] HandleAddNotice(Dictionary <string, object> request)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            if (!request.ContainsKey("RequestingAgentID") || !request.ContainsKey("GroupID") || !request.ContainsKey("NoticeID") ||
                !request.ContainsKey("FromName") || !request.ContainsKey("Subject") || !request.ContainsKey("Message") ||
                !request.ContainsKey("HasAttachment"))
            {
                NullResult(result, "Bad network data");
            }

            else
            {
                bool   hasAtt   = bool.Parse(request["HasAttachment"].ToString());
                byte   attType  = 0;
                string attName  = string.Empty;
                string attOwner = string.Empty;
                UUID   attItem  = UUID.Zero;
                if (request.ContainsKey("AttachmentType"))
                {
                    attType = byte.Parse(request["AttachmentType"].ToString());
                }
                if (request.ContainsKey("AttachmentName"))
                {
                    attName = request["AttachmentName"].ToString();
                }
                if (request.ContainsKey("AttachmentItemID"))
                {
                    attItem = new UUID(request["AttachmentItemID"].ToString());
                }
                if (request.ContainsKey("AttachmentOwnerID"))
                {
                    attOwner = request["AttachmentOwnerID"].ToString();
                }

                bool success = m_GroupsService.AddGroupNotice(request["RequestingAgentID"].ToString(), new UUID(request["GroupID"].ToString()),
                                                              new UUID(request["NoticeID"].ToString()), request["FromName"].ToString(), request["Subject"].ToString(),
                                                              request["Message"].ToString(), hasAtt, attType, attName, attItem, attOwner);

                result["RESULT"] = success.ToString();
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);

            //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
        byte[] HandleAddAgentToGroup(Dictionary <string, object> request)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            if (!request.ContainsKey("RequestingAgentID") || !request.ContainsKey("AgentID") ||
                !request.ContainsKey("GroupID") || !request.ContainsKey("RoleID"))
            {
                NullResult(result, "Bad network data");
            }
            else
            {
                UUID   groupID           = new UUID(request["GroupID"].ToString());
                UUID   roleID            = new UUID(request["RoleID"].ToString());
                string agentID           = request["AgentID"].ToString();
                string requestingAgentID = request["RequestingAgentID"].ToString();
                string token             = string.Empty;
                string reason            = string.Empty;

                if (request.ContainsKey("AccessToken"))
                {
                    token = request["AccessToken"].ToString();
                }

                if (!m_GroupsService.AddAgentToGroup(requestingAgentID, agentID, groupID, roleID, token, out reason))
                {
                    NullResult(result, reason);
                }
                else
                {
                    GroupMembershipData membership = m_GroupsService.GetAgentGroupMembership(requestingAgentID, agentID, groupID);
                    if (membership == null)
                    {
                        NullResult(result, "Internal error");
                    }
                    else
                    {
                        result["RESULT"] = GroupsDataUtils.GroupMembershipData((ExtendedGroupMembershipData)membership);
                    }
                }
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);

            //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
Exemple #11
0
        byte[] HandleGetFolderContent(Dictionary <string, object> request)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();
            UUID principal = UUID.Zero;

            UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
            UUID folderID = UUID.Zero;

            UUID.TryParse(request["FOLDER"].ToString(), out folderID);

            InventoryCollection icoll = m_InventoryService.GetFolderContent(principal, folderID);

            if (icoll != null)
            {
                result["FID"]     = icoll.FolderID.ToString();
                result["VERSION"] = icoll.Version.ToString();
                Dictionary <string, object> folders = new Dictionary <string, object>();
                int i = 0;
                if (icoll.Folders != null)
                {
                    foreach (InventoryFolderBase f in icoll.Folders)
                    {
                        folders["folder_" + i.ToString()] = EncodeFolder(f);
                        i++;
                    }
                    result["FOLDERS"] = folders;
                }
                if (icoll.Items != null)
                {
                    i = 0;
                    Dictionary <string, object> items = new Dictionary <string, object>();
                    foreach (InventoryItemBase it in icoll.Items)
                    {
                        items["item_" + i.ToString()] = EncodeItem(it);
                        i++;
                    }
                    result["ITEMS"] = items;
                }
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);

            //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
Exemple #12
0
        byte[] GetGridUserInfos(Dictionary <string, object> request)
        {
            string[] userIDs;

            if (!request.ContainsKey("AgentIDs"))
            {
                m_log.DebugFormat("[GRID USER HANDLER]: GetGridUserInfos called without required uuids argument");
                return(FailureResult());
            }

            if (!(request["AgentIDs"] is List <string>))
            {
                m_log.DebugFormat("[GRID USER HANDLER]: GetGridUserInfos input argument was of unexpected type {0}", request["uuids"].GetType().ToString());
                return(FailureResult());
            }

            userIDs = ((List <string>)request["AgentIDs"]).ToArray();

            GridUserInfo[] pinfos = m_GridUserService.GetGridUserInfo(userIDs);

            Dictionary <string, object> result = new Dictionary <string, object>();

            if ((pinfos == null) || ((pinfos != null) && (pinfos.Length == 0)))
            {
                result["result"] = "null";
            }
            else
            {
                int i = 0;
                foreach (GridUserInfo pinfo in pinfos)
                {
                    if (pinfo == null)
                    {
                        continue;
                    }
                    Dictionary <string, object> rinfoDict = pinfo.ToKeyValuePairs();
                    result["griduser" + i] = rinfoDict;
                    i++;
                }
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);

            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
        private byte[] HandleRemoveRole(Dictionary <string, object> request)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            if (!request.ContainsKey("RequestingAgentID") || !request.ContainsKey("GroupID") || !request.ContainsKey("RoleID"))
            {
                NullResult(result, "Bad network data");
            }
            else
            {
                m_GroupsService.RemoveGroupRole(request["RequestingAgentID"].ToString(), new UUID(request["GroupID"].ToString()),
                                                new UUID(request["RoleID"].ToString()));
                result["RESULT"] = "true";
            }

            //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
            return(Util.UTF8NoBomEncoding.GetBytes(ServerUtils.BuildXmlResponse(result)));
        }
Exemple #14
0
        byte[] HandleGetAssetPermissions(Dictionary <string, object> request)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();
            UUID principal = UUID.Zero;

            UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
            UUID assetID = UUID.Zero;

            UUID.TryParse(request["ASSET"].ToString(), out assetID);

            int perms = m_InventoryService.GetAssetPermissions(principal, assetID);

            result["RESULT"] = perms.ToString();
            string xmlString = ServerUtils.BuildXmlResponse(result);

            //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
        byte[] GetRegionByName(Dictionary <string, object> request)
        {
            UUID scopeID = UUID.Zero;

            if (request.ContainsKey("SCOPEID"))
            {
                UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
            }
            else
            {
                m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by name");
            }

            string regionName = string.Empty;

            if (request.ContainsKey("NAME"))
            {
                regionName = request["NAME"].ToString();
            }
            else
            {
                m_log.WarnFormat("[GRID HANDLER]: no name in request to get region by name");
            }

            GridRegion rinfo = m_GridService.GetRegionByName(scopeID, regionName);
            //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);

            Dictionary <string, object> result = new Dictionary <string, object>();

            if (rinfo == null)
            {
                result["result"] = "null";
            }
            else
            {
                result["result"] = rinfo.ToKeyValuePairs();
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);
            //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
            UTF8Encoding encoding = new UTF8Encoding();

            return(encoding.GetBytes(xmlString));
        }
        byte[] HandleSetActive(Dictionary <string, object> request)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            if (!request.ContainsKey("RequestingAgentID") || !request.ContainsKey("GroupID") ||
                !request.ContainsKey("AgentID") || !request.ContainsKey("OP"))
            {
                NullResult(result, "Bad network data");
                string xmlString = ServerUtils.BuildXmlResponse(result);
                return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
            }
            else
            {
                string op = request["OP"].ToString();

                if (op == "GROUP")
                {
                    ExtendedGroupMembershipData group = m_GroupsService.SetAgentActiveGroup(request["RequestingAgentID"].ToString(),
                                                                                            request["AgentID"].ToString(), new UUID(request["GroupID"].ToString()));

                    if (group == null)
                    {
                        NullResult(result, "Internal error");
                    }
                    else
                    {
                        result["RESULT"] = GroupsDataUtils.GroupMembershipData(group);
                    }

                    string xmlString = ServerUtils.BuildXmlResponse(result);

                    //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
                    return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
                }
                else if (op == "ROLE" && request.ContainsKey("RoleID"))
                {
                    m_GroupsService.SetAgentActiveGroupRole(request["RequestingAgentID"].ToString(), request["AgentID"].ToString(),
                                                            new UUID(request["GroupID"].ToString()), new UUID(request["RoleID"].ToString()));
                    result["RESULT"] = "true";
                }

                return(Util.UTF8NoBomEncoding.GetBytes(ServerUtils.BuildXmlResponse(result)));
            }
        }
        private byte[] GetRegionByUUID(Dictionary <string, object> request)
        {
            UUID scopeID = UUID.Zero;

            if (request.ContainsKey("SCOPEID"))
            {
                UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
            }
            else
            {
                m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours");
            }

            UUID regionID = UUID.Zero;

            if (request.ContainsKey("REGIONID"))
            {
                UUID.TryParse(request["REGIONID"].ToString(), out regionID);
            }
            else
            {
                m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours");
            }

            GridRegion rinfo = m_GridService.GetRegionByUUID(scopeID, regionID);
            //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);

            Dictionary <string, object> result = new Dictionary <string, object>();

            if (rinfo == null)
            {
                result["result"] = "null";
            }
            else
            {
                result["result"] = rinfo.ToKeyValuePairs();
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);

            //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
Exemple #18
0
        byte[] HandleGetRootFolder(Dictionary <string, object> request)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            UUID principal = UUID.Zero;

            UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
            InventoryFolderBase rfolder = m_InventoryService.GetRootFolder(principal);

            if (rfolder != null)
            {
                result["folder"] = EncodeFolder(rfolder);
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);

            //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
Exemple #19
0
        byte[] GetAgents(Dictionary <string, object> request)
        {
            string[] userIDs;

            if (!request.ContainsKey("uuids"))
            {
                m_log.DebugFormat("[PRESENCE HANDLER]: GetAgents called without required uuids argument");
                return(FailureResult());
            }

            if (!(request["uuids"] is List <string>))
            {
                m_log.DebugFormat("[PRESENCE HANDLER]: GetAgents input argument was of unexpected type {0}", request["uuids"].GetType().ToString());
                return(FailureResult());
            }

            userIDs = ((List <string>)request["uuids"]).ToArray();

            PresenceInfo[] pinfos = m_PresenceService.GetAgents(userIDs);

            Dictionary <string, object> result = new Dictionary <string, object>();

            if ((pinfos == null) || ((pinfos != null) && (pinfos.Length == 0)))
            {
                result["result"] = "null";
            }
            else
            {
                int i = 0;
                foreach (PresenceInfo pinfo in pinfos)
                {
                    Dictionary <string, object> rinfoDict = pinfo.ToKeyValuePairs();
                    result["presence" + i] = rinfoDict;
                    i++;
                }
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);
            //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
            UTF8Encoding encoding = new UTF8Encoding();

            return(encoding.GetBytes(xmlString));
        }
        private byte[] HandleUpdateMembership(Dictionary <string, object> request)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            if (!request.ContainsKey("RequestingAgentID") || !request.ContainsKey("AgentID") || !request.ContainsKey("GroupID") ||
                !request.ContainsKey("AcceptNotices") || !request.ContainsKey("ListInProfile"))
            {
                NullResult(result, "Bad network data");
            }
            else
            {
                m_GroupsService.UpdateMembership(request["RequestingAgentID"].ToString(), request["AgentID"].ToString(), new UUID(request["GroupID"].ToString()),
                                                 bool.Parse(request["AcceptNotices"].ToString()), bool.Parse(request["ListInProfile"].ToString()));

                result["RESULT"] = "true";
            }

            //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
            return(Util.UTF8NoBomEncoding.GetBytes(ServerUtils.BuildXmlResponse(result)));
        }
Exemple #21
0
        byte[] HandleGetItem(Dictionary <string, object> request)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();
            UUID id = UUID.Zero;

            UUID.TryParse(request["ID"].ToString(), out id);

            InventoryItemBase item = new InventoryItemBase(id);

            item = m_InventoryService.GetItem(item);
            if (item != null)
            {
                result["item"] = EncodeItem(item);
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);

            //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
Exemple #22
0
        protected override byte[] ProcessRequest(string path, Stream request,
                                                 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            byte[] result = new byte[0];
            Dictionary <string, object> data = null;

            string[] p = SplitParams(path);

            // /estates/  (all)
            // /estates/?name=string
            // /estates/?owner=uuid
            if (p.Length == 0)
            {
                data = GetEstates(httpRequest, httpResponse);
            }
            else
            {
                string resource = p[0];

                // /estates/estate/?region=uuid&create=[t|f]
                // /estates/estate/?eid=int
                if ("estate".Equals(resource))
                {
                    data = GetEstate(httpRequest, httpResponse);
                }
                // /estates/regions/?eid=int
                else if ("regions".Equals(resource))
                {
                    data = GetRegions(httpRequest, httpResponse);
                }
            }

            if (data == null)
            {
                data = new Dictionary <string, object>();
            }

            string xmlString = ServerUtils.BuildXmlResponse(data);

            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
Exemple #23
0
        byte[] GetAccounts(Dictionary <string, object> request)
        {
            if (!request.ContainsKey("query"))
            {
                return(FailureResult());
            }

            UUID scopeID = UUID.Zero;

            if (request.ContainsKey("ScopeID") && !UUID.TryParse(request["ScopeID"].ToString(), out scopeID))
            {
                return(FailureResult());
            }

            string query = request["query"].ToString();

            List <UserAccount> accounts = m_UserAccountService.GetUserAccounts(scopeID, query);

            Dictionary <string, object> result = new Dictionary <string, object>();

            if ((accounts == null) || ((accounts != null) && (accounts.Count == 0)))
            {
                result["result"] = "null";
            }
            else
            {
                int i = 0;
                foreach (UserAccount acc in accounts)
                {
                    Dictionary <string, object> rinfoDict = acc.ToKeyValuePairs();
                    result["account" + i] = rinfoDict;
                    i++;
                }
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);
            //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
            UTF8Encoding encoding = new UTF8Encoding();

            return(encoding.GetBytes(xmlString));
        }
        byte[] HandleGetGroup(Dictionary <string, object> request)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            if (!request.ContainsKey("RequestingAgentID") || !request.ContainsKey("AccessToken"))
            {
                NullResult(result, "Bad network data");
            }
            else
            {
                string RequestingAgentID = request["RequestingAgentID"].ToString();
                string token             = request["AccessToken"].ToString();

                UUID   groupID   = UUID.Zero;
                string groupName = string.Empty;

                if (request.ContainsKey("GroupID"))
                {
                    groupID = new UUID(request["GroupID"].ToString());
                }
                if (request.ContainsKey("Name"))
                {
                    groupName = request["Name"].ToString();
                }

                ExtendedGroupRecord grec = m_GroupsService.GetGroupRecord(RequestingAgentID, groupID, groupName, token);
                if (grec == null)
                {
                    NullResult(result, "Group not found");
                }
                else
                {
                    result["RESULT"] = GroupsDataUtils.GroupRecord(grec);
                }
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);

            //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
Exemple #25
0
        byte[] HandleStore(Dictionary <string, object> request)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            GridInstantMessage im = OfflineIMDataUtils.GridInstantMessage(request);

            string reason = string.Empty;

            bool success = m_OfflineIMService.StoreMessage(im, out reason);

            result["RESULT"] = success.ToString();
            if (!success)
            {
                result["REASON"] = reason;
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);

            //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
Exemple #26
0
        byte[] HandleGetFolder(Dictionary <string, object> request)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();
            UUID id = UUID.Zero;

            UUID.TryParse(request["ID"].ToString(), out id);

            InventoryFolderBase folder = new InventoryFolderBase(id);

            folder = m_InventoryService.GetFolder(folder);
            if (folder != null)
            {
                result["folder"] = EncodeFolder(folder);
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);
            //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
            UTF8Encoding encoding = new UTF8Encoding();

            return(encoding.GetBytes(xmlString));
        }
Exemple #27
0
        byte[] HandleGetMultipleItems(Dictionary <string, object> request)
        {
            Dictionary <string, object> resultSet = new Dictionary <string, object>();
            UUID principal = UUID.Zero;

            UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
            string itemIDstr = request["ITEMS"].ToString();
            int    count     = 0;

            Int32.TryParse(request["COUNT"].ToString(), out count);

            UUID[]   fids  = new UUID[count];
            string[] uuids = itemIDstr.Split(',');
            int      i     = 0;

            foreach (string id in uuids)
            {
                UUID fid = UUID.Zero;
                if (UUID.TryParse(id, out fid))
                {
                    fids[i] = fid;
                }
                i += 1;
            }

            InventoryItemBase[] itemsList = m_InventoryService.GetMultipleItems(principal, fids);
            if (itemsList != null && itemsList.Length > 0)
            {
                count = 0;
                foreach (InventoryItemBase item in itemsList)
                {
                    resultSet["item_" + count++] = (item == null) ? (object)"NULL" : EncodeItem(item);
                }
            }

            string xmlString = ServerUtils.BuildXmlResponse(resultSet);

            //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
Exemple #28
0
        byte[] HandleRemoveAgentFromGroup(Dictionary <string, object> request)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            if (!request.ContainsKey("AccessToken") || !request.ContainsKey("AgentID") ||
                !request.ContainsKey("GroupID"))
            {
                NullResult(result, "Bad network data");
            }
            else
            {
                UUID   groupID = new UUID(request["GroupID"].ToString());
                string agentID = request["AgentID"].ToString();
                string token   = request["AccessToken"].ToString();

                m_GroupsService.RemoveAgentFromGroup(agentID, agentID, groupID, token);
            }

            //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
            result["RESULT"] = "true";
            return(Util.UTF8NoBomEncoding.GetBytes(ServerUtils.BuildXmlResponse(result)));
        }
        byte[] HandlePutRole(Dictionary <string, object> request)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            if (!request.ContainsKey("RequestingAgentID") || !request.ContainsKey("GroupID") || !request.ContainsKey("RoleID") ||
                !request.ContainsKey("Name") || !request.ContainsKey("Description") || !request.ContainsKey("Title") ||
                !request.ContainsKey("Powers") || !request.ContainsKey("OP"))
            {
                NullResult(result, "Bad network data");
            }

            else
            {
                string op     = request["OP"].ToString();
                string reason = string.Empty;

                bool success = false;
                if (op == "ADD")
                {
                    success = m_GroupsService.AddGroupRole(request["RequestingAgentID"].ToString(), new UUID(request["GroupID"].ToString()),
                                                           new UUID(request["RoleID"].ToString()), request["Name"].ToString(), request["Description"].ToString(),
                                                           request["Title"].ToString(), UInt64.Parse(request["Powers"].ToString()), out reason);
                }

                else if (op == "UPDATE")
                {
                    success = m_GroupsService.UpdateGroupRole(request["RequestingAgentID"].ToString(), new UUID(request["GroupID"].ToString()),
                                                              new UUID(request["RoleID"].ToString()), request["Name"].ToString(), request["Description"].ToString(),
                                                              request["Title"].ToString(), UInt64.Parse(request["Powers"].ToString()));
                }

                result["RESULT"] = success.ToString();
            }

            string xmlString = ServerUtils.BuildXmlResponse(result);

            //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }
Exemple #30
0
        byte[] GetGridUserInfo(Dictionary <string, object> request)
        {
            string user = String.Empty;

            if (!request.ContainsKey("UserID"))
            {
                return(FailureResult());
            }

            user = request["UserID"].ToString();

            GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(user);

            Dictionary <string, object> result = new Dictionary <string, object>();

            result["result"] = guinfo.ToKeyValuePairs();

            string xmlString = ServerUtils.BuildXmlResponse(result);

            //m_log.DebugFormat("[GRID USER HANDLER]: resp string: {0}", xmlString);
            return(Util.UTF8NoBomEncoding.GetBytes(xmlString));
        }