public bool StoreAgentPreferences(AgentPrefs data)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            sendData["METHOD"] = "setagentprefs";

            sendData["PrincipalID"]      = data.PrincipalID.ToString();
            sendData["AccessPrefs"]      = data.AccessPrefs;
            sendData["HoverHeight"]      = data.HoverHeight.ToString();
            sendData["Language"]         = data.Language;
            sendData["LanguageIsPublic"] = data.LanguageIsPublic.ToString();
            sendData["PermEveryone"]     = data.PermEveryone.ToString();
            sendData["PermGroup"]        = data.PermGroup.ToString();
            sendData["PermNextOwner"]    = data.PermNextOwner.ToString();

            string uri       = string.Concat(m_ServerURI, "/agentprefs");
            string reqString = ServerUtils.BuildQueryString(sendData);

            // m_log.DebugFormat("[AGENT PREFS CONNECTOR]: queryString = {0}", reqString);

            try
            {
                string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
                if (reply != string.Empty)
                {
                    int indx = reply.IndexOf("success", StringComparison.InvariantCultureIgnoreCase);
                    if (indx > 0)
                    {
                        return(true);
                    }
                    return(false);
                }
                else
                {
                    m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: StoreAgentPreferences received empty reply");
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: Exception when contacting agent preferences server at {0}: {1}", uri, e.Message);
            }

            return(false);
        }
Exemple #2
0
        private bool Set(Dictionary <string, object> sendData)
        {
            string reqString = ServerUtils.BuildQueryString(sendData);
            string uri       = m_ServerURI + "/griduser";

            // m_log.DebugFormat("[GRID USER CONNECTOR]: queryString = {0}", reqString);
            try
            {
                string reply = SynchronousRestFormsRequester.MakeRequest("POST",
                                                                         uri,
                                                                         reqString,
                                                                         m_Auth);
                if (reply != string.Empty)
                {
                    Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);

                    if (replyData.ContainsKey("result"))
                    {
                        if (replyData["result"].ToString().ToLower() == "success")
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        m_log.DebugFormat("[GRID USER CONNECTOR]: SetPosition reply data does not contain result field");
                    }
                }
                else
                {
                    m_log.DebugFormat("[GRID USER CONNECTOR]: SetPosition received empty reply");
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[GRID USER CONNECTOR]: Exception when contacting grid user server at {0}: {1}", uri, e.Message);
            }

            return(false);
        }
        public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            //sendData["SCOPEID"] = scopeID.ToString();
            sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"]     = "login";

            sendData["UserID"]          = userID;
            sendData["SessionID"]       = sessionID.ToString();
            sendData["SecureSessionID"] = secureSessionID.ToString();

            string reqString = ServerUtils.BuildQueryString(sendData);
            string uri       = m_ServerURI + "/presence";

            // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString);
            try
            {
                string reply = SynchronousRestFormsRequester.MakeRequest("POST",
                                                                         uri,
                                                                         reqString,
                                                                         m_Auth);
                if (reply != string.Empty)
                {
                    int indx = reply.IndexOf("success", StringComparison.InvariantCultureIgnoreCase);
                    if (indx > 0)
                    {
                        return(true);
                    }
                    return(false);
                }
                else
                {
                    m_log.DebugFormat("[PRESENCE CONNECTOR]: LoginAgent received empty reply");
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message);
            }

            return(false);
        }
Exemple #4
0
        public PresenceInfo GetAgent(UUID sessionID)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            //sendData["SCOPEID"] = scopeID.ToString();
            sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"]     = "getagent";

            sendData["SessionID"] = sessionID.ToString();

            string reply     = string.Empty;
            string reqString = ServerUtils.BuildQueryString(sendData);

            // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString);
            try
            {
                reply = SynchronousRestFormsRequester.MakeRequest("POST",
                                                                  m_ServerURI + "/presence",
                                                                  reqString);
                if (reply == null || (reply != null && reply == string.Empty))
                {
                    m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgent received null or empty reply");
                    return(null);
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server: {0}", e.Message);
            }

            Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);
            PresenceInfo pinfo = null;

            if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null))
            {
                if (replyData["result"] is Dictionary <string, object> )
                {
                    pinfo = new PresenceInfo((Dictionary <string, object>)replyData["result"]);
                }
            }

            return(pinfo);
        }
        // Helpers
        //
        private Dictionary <string, object> MakeRequest(Dictionary <string, object> sendData)
        {
            RequestsMade++;

            string reply = String.Empty;

            reply = SynchronousRestFormsRequester.MakePostRequest(
                m_ServerURI + "/xinventory",
                ServerUtils.BuildQueryString(sendData), m_Auth, m_requestTimeoutSecs);

            if (string.IsNullOrWhiteSpace(reply))
            {
                return(new Dictionary <string, object>());
            }

            Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);

            return(replyData);
        }
        public bool StoreFriend(string PrincipalID, string Friend, int flags)
        {
            Dictionary <string, object> sendData = ToKeyValuePairs(PrincipalID, Friend, flags);

            sendData["METHOD"] = "storefriend";

            string reply = string.Empty;

            try
            {
                reply = SynchronousRestFormsRequester.MakeRequest("POST",
                                                                  m_ServerURI + "/friends",
                                                                  ServerUtils.BuildQueryString(sendData));
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: Exception when contacting friends server: {0}", e.Message);
                return(false);
            }

            if (reply != string.Empty)
            {
                Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);

                if ((replyData != null) && replyData.ContainsKey("Result") && (replyData["Result"] != null))
                {
                    bool success = false;
                    Boolean.TryParse(replyData["Result"].ToString(), out success);
                    return(success);
                }
                else
                {
                    m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: StoreFriend {0} {1} received null response",
                                      PrincipalID, Friend);
                }
            }
            else
            {
                m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: StoreFriend received null reply");
            }

            return(false);
        }
        public AvatarData GetAvatar(UUID userID)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            //sendData["SCOPEID"] = scopeID.ToString();
            sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"]     = "getavatar";

            sendData["UserID"] = userID;

            string reply     = string.Empty;
            string reqString = ServerUtils.BuildQueryString(sendData);
            string uri       = m_ServerURI + "/avatar";

            // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString);
            try
            {
                reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
                if (reply == null || (reply != null && reply == string.Empty))
                {
                    m_log.DebugFormat("[AVATAR CONNECTOR]: GetAgent received null or empty reply");
                    return(null);
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[AVATAR CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message);
            }

            Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);
            AvatarData avatar = null;

            if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null))
            {
                if (replyData["result"] is Dictionary <string, object> )
                {
                    avatar = new AvatarData((Dictionary <string, object>)replyData["result"]);
                }
            }

            return(avatar);
        }
        private Dictionary <string, object> MakeRequest(string method, Dictionary <string, object> sendData)
        {
            sendData["METHOD"] = method;

            string reply = SynchronousRestFormsRequester.MakeRequest("POST",
                                                                     m_ServerURI + "groups",
                                                                     ServerUtils.BuildQueryString(sendData),
                                                                     m_Auth);

            if (reply == string.Empty)
            {
                return(null);
            }

            Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(
                reply);

            return(replyData);
        }
Exemple #9
0
        private bool Call(GridRegion region, Dictionary <string, object> sendData)
        {
            string reqString = ServerUtils.BuildQueryString(sendData);

            // m_log.DebugFormat("[XESTATE CONNECTOR]: queryString = {0}", reqString);
            try
            {
                string url   = "http://" + region.ExternalHostName + ":" + region.HttpPort;
                string reply = SynchronousRestFormsRequester.MakeRequest("POST",
                                                                         url + "/estate",
                                                                         reqString);
                if (reply != string.Empty)
                {
                    Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);

                    if (replyData.ContainsKey("RESULT"))
                    {
                        if (replyData["RESULT"].ToString().ToLower() == "true")
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        m_log.DebugFormat("[XESTATE CONNECTOR]: reply data does not contain result field");
                    }
                }
                else
                {
                    m_log.DebugFormat("[XESTATE CONNECTOR]: received empty reply");
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[XESTATE CONNECTOR]: Exception when contacting remote sim: {0}", e.Message);
            }

            return(false);
        }
        public uint GetFriendPerms(UUID PrincipalID, UUID friendID)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            sendData["PRINCIPALID"] = PrincipalID.ToString();
            sendData["FRIENDID"]    = friendID.ToString();
            sendData["METHOD"]      = "getfriendperms";
            sendData["KEY"]         = m_ServiceKey;
            sendData["SESSIONID"]   = m_SessionID.ToString();

            string reqString = ServerUtils.BuildQueryString(sendData);
            string uri       = m_ServerURI + "/hgfriends";

            try
            {
                string reply = SynchronousRestFormsRequester.MakeRequest("POST",
                                                                         uri,
                                                                         reqString);
                if (reply != string.Empty)
                {
                    Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);

                    if ((replyData != null) && replyData.ContainsKey("Value") && (replyData["Value"] != null))
                    {
                        uint perms = 0;
                        uint.TryParse(replyData["Value"].ToString(), out perms);
                        return(perms);
                    }
                    else
                    {
                        m_log.DebugFormat("[HGFRIENDS CONNECTOR]: GetFriendPerms {0} received null response",
                                          PrincipalID);
                    }
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Exception when contacting friends server at {0}: {1}", uri, e.Message);
            }

            return(0);
        }
        public Byte[] MuteListRequest(UUID agentID, uint crc)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            sendData["METHOD"]  = "get";
            sendData["agentid"] = agentID.ToString();
            sendData["mutecrc"] = crc.ToString();

            try
            {
                string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI,
                                                                         ServerUtils.BuildQueryString(sendData), m_Auth);
                if (reply != string.Empty)
                {
                    Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);

                    if (replyData.ContainsKey("result"))
                    {
                        string datastr = replyData["result"].ToString();
                        if (String.IsNullOrWhiteSpace(datastr))
                        {
                            return(null);
                        }
                        return(Convert.FromBase64String(datastr));
                    }
                    else
                    {
                        m_log.DebugFormat("[MUTELIST CONNECTOR]: get reply data does not contain result field");
                    }
                }
                else
                {
                    m_log.DebugFormat("[MUTELIST CONNECTOR]: get received empty reply");
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[MUTELIST CONNECTOR]: Exception when contacting server at {0}: {1}", m_ServerURI, e.Message);
            }

            return(null);
        }
Exemple #12
0
        private bool SendAndGetBoolReply(Dictionary <string, object> sendData)
        {
            string reqString = ServerUtils.BuildQueryString(sendData);

            // m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString);
            try
            {
                string reply = SynchronousRestFormsRequester.MakeRequest("POST",
                                                                         m_ServerURI + "/accounts",
                                                                         reqString);
                if (reply != string.Empty)
                {
                    Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);

                    if (replyData.ContainsKey("result"))
                    {
                        if (replyData["result"].ToString().ToLower() == "success")
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        m_log.DebugFormat("[ACCOUNTS CONNECTOR]: Set or Create UserAccount reply data does not contain result field");
                    }
                }
                else
                {
                    m_log.DebugFormat("[ACCOUNTS CONNECTOR]: Set or Create UserAccount received empty reply");
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[ACCOUNTS CONNECTOR]: Exception when contacting user account server: {0}", e.Message);
            }

            return(false);
        }
        public Dictionary <string, object> GetExtraFeatures()
        {
            Dictionary <string, object> sendData      = new Dictionary <string, object>();
            Dictionary <string, object> extraFeatures = new Dictionary <string, object>();

            sendData["METHOD"] = "get_grid_extra_features";

            string reply = string.Empty;
            string uri   = m_ServerURI + "/grid";

            try
            {
                reply = SynchronousRestFormsRequester.MakeRequest("POST",
                                                                  uri,
                                                                  ServerUtils.BuildQueryString(sendData), m_Auth);
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[GRID CONNECTOR]: GetExtraFeatures - Exception when contacting grid server at {0}: {1}", uri, e.Message);
                return(extraFeatures);
            }

            if (reply != string.Empty)
            {
                Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);

                if ((replyData != null) && replyData.Count > 0)
                {
                    foreach (string key in replyData.Keys)
                    {
                        extraFeatures[key] = replyData[key].ToString();
                    }
                }
            }
            else
            {
                m_log.DebugFormat("[GRID CONNECTOR]: GetExtraServiceURLs received null reply");
            }

            return(extraFeatures);
        }
        public bool Release(UUID principalID, string token)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            sendData["PRINCIPAL"] = principalID.ToString();
            sendData["TOKEN"]     = token;

            sendData["METHOD"] = "release";

            string reply = SynchronousRestFormsRequester.MakeRequest("POST",
                                                                     m_ServerURI + "/auth/plain",
                                                                     ServerUtils.BuildQueryString(sendData), m_Auth);

            Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);

            if (replyData["Result"].ToString() != "Success")
            {
                return(false);
            }

            return(true);
        }
        // Helpers
        //
        private Dictionary <string, object> MakeRequest(string method,
                                                        Dictionary <string, object> sendData)
        {
            // Add "METHOD" as the first key in the dictionary. This ensures that it will be
            // visible even when using partial logging ("debug http all 5").
            Dictionary <string, object> temp = sendData;

            sendData = new Dictionary <string, object> {
                { "METHOD", method }
            };
            foreach (KeyValuePair <string, object> kvp in temp)
            {
                sendData.Add(kvp.Key, kvp.Value);
            }

            RequestsMade++;

            string reply   = String.Empty;
            int    retries = 0;

            do
            {
                reply = SynchronousRestFormsRequester.MakeRequest(
                    "POST", m_ServerURI + "/xinventory",
                    ServerUtils.BuildQueryString(sendData), m_requestTimeoutSecs, m_Auth);

                if (reply != String.Empty)
                {
                    break;
                }

                retries++;
            } while (retries <= m_maxRetries);

            Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(
                reply);

            return(replyData);
        }
Exemple #16
0
        protected GridUserInfo Get(Dictionary <string, object> sendData)
        {
            string reqString = ServerUtils.BuildQueryString(sendData);
            string uri       = m_ServerURI + "/griduser";

            // m_log.DebugFormat("[GRID USER CONNECTOR]: queryString = {0}", reqString);
            try
            {
                string reply = SynchronousRestFormsRequester.MakeRequest("POST",
                                                                         uri,
                                                                         reqString,
                                                                         m_Auth);
                if (reply != string.Empty)
                {
                    Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);
                    GridUserInfo guinfo = null;

                    if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null))
                    {
                        if (replyData["result"] is Dictionary <string, object> )
                        {
                            guinfo = Create((Dictionary <string, object>)replyData["result"]);
                        }
                    }

                    return(guinfo);
                }
                else
                {
                    m_log.DebugFormat("[GRID USER CONNECTOR]: Get received empty reply");
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[GRID USER CONNECTOR]: Exception when contacting grid user server at {0}: {1}", uri, e.Message);
            }

            return(null);
        }
Exemple #17
0
        protected bool Set(Dictionary<string, object> sendData, string userID, UUID regionID, Vector3 position, Vector3 lookAt)
        {
            sendData["UserID"] = userID;
            sendData["RegionID"] = regionID.ToString();
            sendData["Position"] = position.ToString();
            sendData["LookAt"] = lookAt.ToString();

            string reqString = ServerUtils.BuildQueryString(sendData);
            // m_log.DebugFormat("[GRID USER CONNECTOR]: queryString = {0}", reqString);
            try
            {
                string reply = SynchronousRestFormsRequester.MakeRequest("POST",
                        m_ServerURI + "/griduser",
                        reqString);
                if (reply != string.Empty)
                {
                    Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);

                    if (replyData.ContainsKey("result"))
                    {
                        if (replyData["result"].ToString().ToLower() == "success")
                            return true;
                        else
                            return false;
                    }
                    else
                        m_log.DebugFormat("[GRID USER CONNECTOR]: SetPosition reply data does not contain result field");

                }
                else
                    m_log.DebugFormat("[GRID USER CONNECTOR]: SetPosition received empty reply");
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[GRID USER CONNECTOR]: Exception when contacting grid user server: {0}", e.Message);
            }

            return false;
        }
        //
        //
        //
        //
        //

        #region Make Request

        private Dictionary <string, object> MakeRequest(string method, Dictionary <string, object> sendData)
        {
            sendData["METHOD"] = method;

            string reply = string.Empty;

            reply = SynchronousRestFormsRequester.MakeRequest("POST",
                                                              m_ServerURI + "hg-groups",
                                                              ServerUtils.BuildQueryString(sendData));

            //m_log.DebugFormat("[XXX]: reply was {0}", reply);

            if (string.IsNullOrEmpty(reply))
            {
                return(null);
            }

            Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(
                reply);

            return(replyData);
        }
Exemple #19
0
        public ExperienceInfo[] GetExperienceInfos(UUID[] experiences)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            sendData["METHOD"] = "getexperienceinfos";
            int i = 0;

            foreach (UUID id in experiences)
            {
                sendData[string.Format("id_{0}", i)] = id.ToString();
                i++;
            }

            string request_str = ServerUtils.BuildQueryString(sendData);

            List <ExperienceInfo> infos = new List <ExperienceInfo>();

            string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI, request_str, m_Auth);

            //m_log.InfoFormat("[EXPERIENCE SERVICE CONNECTOR]: Reply: {0}", reply);

            if (reply != string.Empty)
            {
                Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);

                Dictionary <string, object> .ValueCollection experienceList = replyData.Values;

                foreach (object ex in experienceList)
                {
                    if (ex is Dictionary <string, object> )
                    {
                        Dictionary <string, object> experience = (Dictionary <string, object>)ex;
                        infos.Add(new ExperienceInfo(experience));
                    }
                }
            }

            return(infos.ToArray());
        }
        public bool Delete(Dictionary <string, object> sendData, string PrincipalID, string Friend)
        {
            string reply = string.Empty;
            string uri   = m_ServerURI + "/friends";

            try
            {
                reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData), m_Auth);
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: Exception when contacting friends server at {0}: {1}", uri, e.Message);
                return(false);
            }

            if (reply != string.Empty)
            {
                Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);

                if ((replyData != null) && replyData.ContainsKey("Result") && (replyData["Result"] != null))
                {
                    bool success = false;
                    Boolean.TryParse(replyData["Result"].ToString(), out success);
                    return(success);
                }
                else
                {
                    m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: DeleteFriend {0} {1} received null response",
                                      PrincipalID, Friend);
                }
            }
            else
            {
                m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: DeleteFriend received null reply");
            }

            return(false);
        }
        public bool ReportAbuse(AbuseReportData report)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            sendData["METHOD"]        = "report";
            sendData["reporter"]      = report.SenderID.ToString();
            sendData["reporter-name"] = report.SenderName;
            sendData["abuser"]        = report.AbuserID.ToString();
            sendData["abuser-name"]   = report.AbuserName;
            sendData["summary"]       = report.Summary;
            sendData["check-flags"]   = report.CheckFlags.ToString();
            sendData["region-id"]     = report.AbuseRegionID.ToString();
            sendData["region-name"]   = report.AbuseRegionName;
            sendData["category"]      = report.Category;
            sendData["version"]       = report.Version;
            sendData["details"]       = report.Details;
            sendData["object-id"]     = report.ObjectID.ToString();
            sendData["position"]      = report.Position.ToString();
            sendData["report-type"]   = report.ReportType.ToString();
            sendData["image-data"]    = Convert.ToBase64String(report.ImageData);

            return(doSimplePost(ServerUtils.BuildQueryString(sendData), "report"));
        }
        public bool UpdateMute(MuteData mute)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            sendData["METHOD"]  = "update";
            sendData["agentid"] = mute.AgentID.ToString();
            sendData["muteid"]  = mute.MuteID.ToString();
            if (mute.MuteType != 0)
            {
                sendData["mutetype"] = mute.MuteType.ToString();
            }
            if (mute.MuteFlags != 0)
            {
                sendData["muteflags"] = mute.MuteFlags.ToString();
            }
            sendData["mutestamp"] = mute.Stamp.ToString();
            if (!String.IsNullOrEmpty(mute.MuteName))
            {
                sendData["mutename"] = mute.MuteName;
            }

            return(doSimplePost(ServerUtils.BuildQueryString(sendData), "update"));
        }
Exemple #23
0
        public ExperienceInfo UpdateExpereienceInfo(ExperienceInfo info)
        {
            // let's just pray they never add a parameter named "method"
            Dictionary <string, object> sendData = info.ToDictionary();

            sendData["METHOD"] = "updateexperienceinfo";

            string request_str = ServerUtils.BuildQueryString(sendData);

            string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI, request_str, m_Auth);

            //m_log.InfoFormat("[EXPERIENCE SERVICE CONNECTOR]: UpdateExpereienceInfo Reply: {0}", reply);

            if (reply != string.Empty)
            {
                Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);

                ExperienceInfo responseInfo = new ExperienceInfo(replyData);
                return(responseInfo);
            }

            return(null);
        }
Exemple #24
0
        private UserAccount SendAndGetReply(Dictionary <string, object> sendData)
        {
            string reply     = string.Empty;
            string reqString = ServerUtils.BuildQueryString(sendData);
            string uri       = m_ServerURI + "/accounts";

            // m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString);
            try
            {
                reply = SynchronousRestFormsRequester.MakeRequest("POST",
                                                                  uri,
                                                                  reqString,
                                                                  m_Auth);
                if (reply == null || (reply != null && reply == string.Empty))
                {
                    m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccount received null or empty reply");
                    return(null);
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[ACCOUNT CONNECTOR]: Exception when contacting user accounts server at {0}: {1}", uri, e.Message);
            }

            Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);
            UserAccount account = null;

            if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null))
            {
                if (replyData["result"] is Dictionary <string, object> )
                {
                    account = new UserAccount((Dictionary <string, object>)replyData["result"]);
                }
            }

            return(account);
        }
        public bool DeregisterRegion(UUID regionID)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            sendData["REGIONID"] = regionID.ToString();

            sendData["METHOD"] = "deregister";

            string uri = m_ServerURI + "/grid";

            try
            {
                string reply
                    = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData), m_Auth);

                if (reply != string.Empty)
                {
                    Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);

                    if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success"))
                    {
                        return(true);
                    }
                }
                else
                {
                    m_log.DebugFormat("[GRID CONNECTOR]: DeregisterRegion received null reply");
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
            }

            return(false);
        }
        public string Authenticate(UUID principalID, string password, int lifetime)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            sendData["LIFETIME"]  = lifetime.ToString();
            sendData["PRINCIPAL"] = principalID.ToString();
            sendData["PASSWORD"]  = password;

            sendData["METHOD"] = "authenticate";

            string reply = SynchronousRestFormsRequester.MakeRequest("POST",
                                                                     m_ServerURI + "/auth/plain",
                                                                     ServerUtils.BuildQueryString(sendData));

            Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(
                reply);

            if (replyData["Result"].ToString() != "Success")
            {
                return(String.Empty);
            }

            return(replyData["Token"].ToString());
        }
        public string RegisterRegion(UUID scopeID, GridRegion regionInfo)
        {
            Dictionary <string, object> rinfo    = regionInfo.ToKeyValuePairs();
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            foreach (KeyValuePair <string, object> kvp in rinfo)
            {
                sendData[kvp.Key] = (string)kvp.Value;
            }

            sendData["SCOPEID"]    = scopeID.ToString();
            sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"]     = "register";

            string reqString = ServerUtils.BuildQueryString(sendData);
            string uri       = m_ServerURI + "/grid";

            // m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
            try
            {
                string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
                if (reply != string.Empty)
                {
                    Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);

                    if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "success"))
                    {
                        return(String.Empty);
                    }
                    else if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "failure"))
                    {
                        m_log.ErrorFormat(
                            "[GRID CONNECTOR]: Registration failed: {0} when contacting {1}", replyData["Message"], uri);

                        return(replyData["Message"].ToString());
                    }
                    else if (!replyData.ContainsKey("Result"))
                    {
                        m_log.ErrorFormat(
                            "[GRID CONNECTOR]: reply data does not contain result field when contacting {0}", uri);
                    }
                    else
                    {
                        m_log.ErrorFormat(
                            "[GRID CONNECTOR]: unexpected result {0} when contacting {1}", replyData["Result"], uri);

                        return("Unexpected result " + replyData["Result"].ToString());
                    }
                }
                else
                {
                    m_log.ErrorFormat(
                        "[GRID CONNECTOR]: RegisterRegion received null reply when contacting grid server at {0}", uri);
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
            }

            return(string.Format("Error communicating with the grid service at {0}", uri));
        }
Exemple #28
0
        public List <UserAccount> GetUserAccounts(UUID scopeID, string query)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            //sendData["SCOPEID"] = scopeID.ToString();
            sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"]     = "getaccounts";

            sendData["ScopeID"] = scopeID.ToString();
            sendData["query"]   = query;

            string reply     = string.Empty;
            string reqString = ServerUtils.BuildQueryString(sendData);
            string uri       = m_ServerURI + "/accounts";

            // m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString);
            try
            {
                reply = SynchronousRestFormsRequester.MakeRequest("POST",
                                                                  uri,
                                                                  reqString);
                if (reply == null || (reply != null && reply == string.Empty))
                {
                    m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccounts received null or empty reply");
                    return(null);
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[ACCOUNT CONNECTOR]: Exception when contacting user accounts server at {0}: {1}", uri, e.Message);
            }

            List <UserAccount> accounts = new List <UserAccount>();

            Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);

            if (replyData != null)
            {
                if (replyData.ContainsKey("result") && replyData["result"].ToString() == "null")
                {
                    return(accounts);
                }

                Dictionary <string, object> .ValueCollection accountList = replyData.Values;
                //m_log.DebugFormat("[ACCOUNTS CONNECTOR]: GetAgents returned {0} elements", pinfosList.Count);
                foreach (object acc in accountList)
                {
                    if (acc is Dictionary <string, object> )
                    {
                        UserAccount pinfo = new UserAccount((Dictionary <string, object>)acc);
                        accounts.Add(pinfo);
                    }
                    else
                    {
                        m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccounts received invalid response type {0}",
                                          acc.GetType());
                    }
                }
            }
            else
            {
                m_log.DebugFormat("[ACCOUNTS CONNECTOR]: GetUserAccounts received null response");
            }

            return(accounts);
        }
Exemple #29
0
        public PresenceInfo[] GetAgents(string[] userIDs)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            //sendData["SCOPEID"] = scopeID.ToString();
            sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"]     = "getagents";

            sendData["uuids"] = new List <string>(userIDs);

            string reply     = string.Empty;
            string reqString = ServerUtils.BuildQueryString(sendData);
            string uri       = m_ServerURI + "/presence";

            //m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString);
            try
            {
                reply = SynchronousRestFormsRequester.MakeRequest("POST",
                                                                  uri,
                                                                  reqString,
                                                                  m_Auth);
            }
            catch (Exception e)
            {
                m_log.Error("[PRESENCE CONNECTOR]: GetAgents exception when contacting presence server at " + uri, e);
                return(new PresenceInfo[0]);
            }

            if ((reply == null) || (reply == string.Empty))
            {
                m_log.Error("[PRESENCE CONNECTOR]: GetAgents received null or empty reply");
                return(new PresenceInfo[0]);
            }

            List <PresenceInfo> rinfos = new List <PresenceInfo>();

            Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);

            if (replyData != null)
            {
                if (replyData.ContainsKey("result") &&
                    (replyData["result"].ToString() == "null" || replyData["result"].ToString() == "Failure"))
                {
                    return(new PresenceInfo[0]);
                }

                Dictionary <string, object> .ValueCollection pinfosList = replyData.Values;
                //m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgents returned {0} elements", pinfosList.Count);
                foreach (object presence in pinfosList)
                {
                    if (presence is Dictionary <string, object> )
                    {
                        PresenceInfo pinfo = new PresenceInfo((Dictionary <string, object>)presence);
                        rinfos.Add(pinfo);
                    }
                    else
                    {
                        m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgents received invalid response type {0}",
                                          presence.GetType());
                    }
                }
            }
            else
            {
                m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgents received null response");
            }

            return(rinfos.ToArray());
        }
Exemple #30
0
        public GridUserInfo[] GetGridUserInfo(string[] userIDs, bool update_name)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            //sendData["SCOPEID"] = scopeID.ToString();
            sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"]     = update_name ? "updateandgetgriduserinfos" : "getgriduserinfos";

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

            string reply     = string.Empty;
            string reqString = ServerUtils.BuildQueryString(sendData);
            string uri       = m_ServerURI + "/griduser";

            //m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString);
            try
            {
                reply = SynchronousRestFormsRequester.MakeRequest("POST",
                                                                  uri,
                                                                  reqString,
                                                                  m_Auth);
                if (reply == null || (reply != null && reply == string.Empty))
                {
                    m_log.DebugFormat("[GRID USER CONNECTOR]: GetGridUserInfo received null or empty reply");
                    return(null);
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[GRID USER CONNECTOR]: Exception when contacting grid user server at {0}: {1}", uri, e.Message);
            }

            List <GridUserInfo> rinfos = new List <GridUserInfo>();

            Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);

            if (replyData != null)
            {
                if (replyData.ContainsKey("result") &&
                    (replyData["result"].ToString() == "null" || replyData["result"].ToString() == "Failure"))
                {
                    return(new GridUserInfo[0]);
                }

                Dictionary <string, object> .ValueCollection pinfosList = replyData.Values;
                //m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgents returned {0} elements", pinfosList.Count);
                foreach (object griduser in pinfosList)
                {
                    if (griduser is Dictionary <string, object> )
                    {
                        GridUserInfo pinfo = Create((Dictionary <string, object>)griduser);
                        rinfos.Add(pinfo);
                    }
                    else
                    {
                        m_log.DebugFormat("[GRID USER CONNECTOR]: GetGridUserInfo received invalid response type {0}",
                                          griduser.GetType());
                    }
                }
            }
            else
            {
                m_log.DebugFormat("[GRID USER CONNECTOR]: GetGridUserInfo received null response");
            }

            return(rinfos.ToArray());
        }