Exemplo n.º 1
0
        /// <summary>
        ///     Tell the user about an update
        /// </summary>
        /// <param name="newDisplayName"></param>
        /// <param name="oldDisplayName"></param>
        /// <param name="iD"></param>
        /// <param name="isDefault"></param>
        /// <param name="first"></param>
        /// <param name="last"></param>
        /// <param name="account"></param>
        /// <returns></returns>

        public OSD DisplayNameUpdate(string newDisplayName, string oldDisplayName, UUID iD, bool isDefault, string first,
                                     string last, string account, DateTime nextUpdate)
        {
            OSDMap nameReply = new OSDMap {
                { "message", OSD.FromString("DisplayNameUpdate") }
            };

            OSDMap body = new OSDMap();

            OSDMap agentData = new OSDMap();

            agentData ["display_name"]             = OSD.FromString(newDisplayName);
            agentData ["id"]                       = OSD.FromUUID(iD);
            agentData ["is_display_name_default"]  = OSD.FromBoolean(isDefault);
            agentData ["legacy_first_name"]        = OSD.FromString(first);
            agentData ["legacy_last_name"]         = OSD.FromString(last);
            agentData ["username"]                 = OSD.FromString(account);
            agentData ["display_name_next_update"] = OSD.FromDate(nextUpdate);

            body.Add("agent", agentData);
            body.Add("agent_id", OSD.FromUUID(iD));
            body.Add("old_display_name", OSD.FromString(oldDisplayName));

            nameReply.Add("body", body);

            return(nameReply);
        }
Exemplo n.º 2
0
        public void SerializeDate()
        {
            DateTime dtOne     = new DateTime(2005, 8, 10, 11, 23, 4, DateTimeKind.Utc);
            OSD      llsdOne   = OSD.FromDate(dtOne);
            string   sDtOne    = OSDParser.SerializeLLSDNotation(llsdOne);
            OSD      llsdOneDS = OSDParser.DeserializeLLSDNotation(sDtOne);

            Assert.AreEqual(OSDType.Date, llsdOneDS.Type);
            DateTime dtOneDS = llsdOneDS.AsDate();

            Assert.AreEqual(dtOne, dtOneDS.ToUniversalTime());

            DateTime dtTwo     = new DateTime(2010, 10, 11, 23, 00, 10, 100, DateTimeKind.Utc);
            OSD      llsdTwo   = OSD.FromDate(dtTwo);
            string   sDtTwo    = OSDParser.SerializeLLSDNotation(llsdTwo);
            OSD      llsdTwoDS = OSDParser.DeserializeLLSDNotation(sDtTwo);

            Assert.AreEqual(OSDType.Date, llsdTwoDS.Type);
            DateTime dtTwoDS = llsdTwoDS.AsDate();

            Assert.AreEqual(dtTwo, dtTwoDS.ToUniversalTime());

            // check if a *local* time can be serialized and deserialized
            DateTime dtThree              = new DateTime(2009, 12, 30, 8, 25, 10, DateTimeKind.Local);
            OSD      llsdDateThree        = OSD.FromDate(dtThree);
            string   sDateThreeSerialized = OSDParser.SerializeLLSDNotation(llsdDateThree);
            OSD      llsdDateThreeDS      = OSDParser.DeserializeLLSDNotation(sDateThreeSerialized);

            Assert.AreEqual(OSDType.Date, llsdDateThreeDS.Type);
            Assert.AreEqual(dtThree, llsdDateThreeDS.AsDate());
        }
Exemplo n.º 3
0
        void PackUserInfo(IUserProfileInfo info, UserAccount account, ref OSDArray agents)
        {
            OSDMap agentMap = new OSDMap();

            agentMap ["username"]          = account.Name;
            agentMap ["display_name"]      = (info == null || info.DisplayName == "") ? account.Name : info.DisplayName;
            agentMap ["legacy_first_name"] = account.FirstName;
            agentMap ["legacy_last_name"]  = account.LastName;
            agentMap ["id"] = account.PrincipalID;
            agentMap ["is_display_name_default"] = isDefaultDisplayName(account.FirstName, account.LastName, account.Name,
                                                                        info == null ? account.Name : info.DisplayName);
            if (info != null)
            {
                if (m_update_days > 0)
                {
                    agentMap ["display_name_next_update"] = OSD.FromDate(info.DisplayNameUpdated.AddDays(m_update_days));
                }
                else
                {
                    agentMap ["display_name_next_update"] = OSD.FromDate(info.DisplayNameUpdated);
                }
            }

            agents.Add(agentMap);
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Tell the user about an update
        /// </summary>
        /// <param name="newDisplayName"></param>
        /// <param name="oldDisplayName"></param>
        /// <param name="ID"></param>
        /// <param name="isDefault"></param>
        /// <param name="First"></param>
        /// <param name="Last"></param>
        /// <param name="Account"></param>
        /// <returns></returns>
        public OSD DisplayNameUpdate(string newDisplayName, string oldDisplayName, UUID ID, bool isDefault, string First,
                                     string Last, string Account)
        {
            OSDMap nameReply = new OSDMap {
                { "message", OSD.FromString("DisplayNameUpdate") }
            };

            OSDMap body      = new OSDMap();
            OSDMap agentData = new OSDMap
            {
                { "display_name", OSD.FromString(newDisplayName) },
                {
                    "display_name_next_update", OSD.FromDate(
                        DateTime.ParseExact("1970-01-01 00:00:00 +0", "yyyy-MM-dd hh:mm:ss z",
                                            DateTimeFormatInfo.InvariantInfo).ToUniversalTime())
                },
                { "id", OSD.FromUUID(ID) },
                { "is_display_name_default", OSD.FromBoolean(isDefault) },
                { "legacy_first_name", OSD.FromString(First) },
                { "legacy_last_name", OSD.FromString(Last) },
                { "username", OSD.FromString(Account) }
            };

            body.Add("agent", agentData);
            body.Add("agent_id", OSD.FromUUID(ID));
            body.Add("old_display_name", OSD.FromString(oldDisplayName));

            nameReply.Add("body", body);

            return(nameReply);
        }
Exemplo n.º 5
0
        private byte[] CreateMetadata(UUID creatorID, string contentType, bool local, bool temporary, byte[] data, Dictionary <string, string> extraHeaders)
        {
            using (MemoryStream stream = new MemoryStream())
            {
                OSDMap metadata = new OSDMap();
                metadata["local"]         = OSD.FromBoolean(local);
                metadata["temporary"]     = OSD.FromBoolean(temporary);
                metadata["content_type"]  = OSD.FromString(contentType);
                metadata["creator_id"]    = OSD.FromUUID(creatorID);
                metadata["creation_date"] = OSD.FromDate(DateTime.UtcNow);
                metadata["sha256"]        = OSD.FromBinary(Utils.SHA256(data));

                if (extraHeaders != null && extraHeaders.Count > 0)
                {
                    OSDMap headerMap = new OSDMap(extraHeaders.Count);
                    foreach (KeyValuePair <string, string> kvp in extraHeaders)
                    {
                        headerMap.Add(kvp.Key, OSD.FromString(kvp.Value));
                    }
                    metadata["extra_headers"] = headerMap;
                }

                return(Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(metadata)));
            }
        }
Exemplo n.º 6
0
        /// <summary>
        ///     Send back a user's display name
        /// </summary>
        /// <param name="newDisplayName"></param>
        /// <param name="oldDisplayName"></param>
        /// <param name="ID"></param>
        /// <param name="isDefault"></param>
        /// <param name="First"></param>
        /// <param name="Last"></param>
        /// <param name="Account"></param>
        /// <returns></returns>
        public OSD DisplayNameReply(string newDisplayName, string oldDisplayName, UUID ID, bool isDefault, string First,
                                    string Last, string Account)
        {
            OSDMap nameReply = new OSDMap();

            OSDMap body      = new OSDMap();
            OSDMap content   = new OSDMap();
            OSDMap agentData = new OSDMap();

            content.Add("display_name", OSD.FromString(newDisplayName));
            content.Add("display_name_next_update",
                        OSD.FromDate(
                            DateTime.ParseExact("1970-01-01 00:00:00 +0", "yyyy-MM-dd hh:mm:ss z",
                                                DateTimeFormatInfo.InvariantInfo).ToUniversalTime()));
            content.Add("id", OSD.FromUUID(ID));
            content.Add("is_display_name_default", OSD.FromBoolean(isDefault));
            content.Add("legacy_first_name", OSD.FromString(First));
            content.Add("legacy_last_name", OSD.FromString(Last));
            content.Add("username", OSD.FromString(Account));
            body.Add("content", content);
            body.Add("agent", agentData);
            body.Add("reason", OSD.FromString("OK"));
            body.Add("status", OSD.FromInteger(200));

            nameReply.Add("body", body);
            nameReply.Add("message", OSD.FromString("SetDisplayNameReply"));

            return(nameReply);
        }
        /// <summary>
        ///     This method creates a smaller OSD that
        ///     does not contain sensitive information
        ///     if the trusted boolean is false
        /// </summary>
        /// <param name="trusted"></param>
        /// <returns></returns>
        public OSDMap ToOSD(bool trusted)
        {
            OSDMap map = new OSDMap {
                { "PrincipalID", OSD.FromUUID(PrincipalID) },
                { "AllowPublish", OSD.FromBoolean(AllowPublish) },
                { "MaturePublish", OSD.FromBoolean(MaturePublish) },
                { "WantToMask", OSD.FromUInteger(Interests.WantToMask) },
                { "WantToText", OSD.FromString(Interests.WantToText) },
                { "CanDoMask", OSD.FromUInteger(Interests.CanDoMask) },
                { "CanDoText", OSD.FromString(Interests.CanDoText) },
                { "Languages", OSD.FromString(Interests.Languages) },
                { "AboutText", OSD.FromString(AboutText) },
                { "FirstLifeImage", OSD.FromUUID(FirstLifeImage) },
                { "FirstLifeAboutText", OSD.FromString(FirstLifeAboutText) },
                { "Image", OSD.FromUUID(Image) },
                { "WebURL", OSD.FromString(WebURL) },
                { "Created", OSD.FromInteger(Created) },
                { "DisplayName", OSD.FromString(DisplayName) },
                { "DisplayNameUpdated", OSD.FromDate(DisplayNameUpdated) },
                { "Partner", OSD.FromUUID(Partner) },
                { "Visible", OSD.FromBoolean(Visible) },
                { "CustomType", OSD.FromString(CustomType) }
            };

            if (trusted)
            {
                map.Add("AArchiveName", OSD.FromString(AArchiveName));
                map.Add("IMViaEmail", OSD.FromBoolean(IMViaEmail));
                map.Add("IsNewUser", OSD.FromBoolean(IsNewUser));
                map.Add("MembershipGroup", OSD.FromString(MembershipGroup));
            }

            map.Add("Notes", OSD.FromString(OSDParser.SerializeJsonString(Notes)));
            return(map);
        }
Exemplo n.º 8
0
        public void SerializeDateTime()
        {
            DateTime dt       = new DateTime(2008, 1, 1, 20, 10, 31, 0, DateTimeKind.Utc);
            OSD      llsdDate = OSD.FromDate(dt);

            byte[] binaryDateSerialized = OSDParser.SerializeLLSDBinary(llsdDate);
            Assert.AreEqual(binaryDateTime, binaryDateSerialized);

            // check if a *local* time can be serialized and deserialized
            DateTime dtOne       = new DateTime(2009, 12, 30, 8, 25, 10, DateTimeKind.Local);
            OSD      llsdDateOne = OSD.FromDate(dtOne);

            byte[] binaryDateOneSerialized = OSDParser.SerializeLLSDBinary(llsdDateOne);
            OSD    llsdDateOneDS           = OSDParser.DeserializeLLSDBinary(binaryDateOneSerialized);

            Assert.AreEqual(OSDType.Date, llsdDateOneDS.Type);
            Assert.AreEqual(dtOne, llsdDateOneDS.AsDate());

            DateTime dtTwo       = new DateTime(2010, 11, 11, 10, 8, 20, DateTimeKind.Utc);
            OSD      llsdDateTwo = OSD.FromDate(dtTwo);

            byte[] binaryDateTwoSerialized = OSDParser.SerializeLLSDBinary(llsdDateTwo);
            OSD    llsdDateTwoDS           = OSDParser.DeserializeLLSDBinary(binaryDateTwoSerialized);

            Assert.AreEqual(OSDType.Date, llsdDateOneDS.Type);
            Assert.AreEqual(dtTwo.ToLocalTime(), llsdDateTwoDS.AsDate());
        }
Exemplo n.º 9
0
        /// <summary>
        ///     Send back a user's display name
        /// </summary>
        /// <param name="newDisplayName"></param>
        /// <param name="oldDisplayName"></param>
        /// <param name="iD"></param>
        /// <param name="isDefault"></param>
        /// <param name="first"></param>
        /// <param name="last"></param>
        /// <param name="account"></param>
        /// <returns></returns>
        OSD DisplayNameReply(string newDisplayName, string oldDisplayName, UUID iD, bool isDefault, string first,
                             string last, string account, DateTime nextUpdate)
        {
            OSDMap nameReply = new OSDMap();

            OSDMap body      = new OSDMap();
            OSDMap content   = new OSDMap();
            OSDMap agentData = new OSDMap();

            content.Add("display_name", OSD.FromString(newDisplayName));
            content.Add("display_name_next_update", OSD.FromDate(nextUpdate));
            content.Add("id", OSD.FromUUID(iD));
            content.Add("is_display_name_default", OSD.FromBoolean(isDefault));
            content.Add("legacy_first_name", OSD.FromString(first));
            content.Add("legacy_last_name", OSD.FromString(last));
            content.Add("username", OSD.FromString(account));

            body.Add("content", content);
            body.Add("agent", agentData);
            //body.Add ("old_display_name", OSD.FromString (oldDisplayName));
            body.Add("reason", OSD.FromString("OK"));
            body.Add("status", OSD.FromInteger(200));

            nameReply.Add("body", body);
            nameReply.Add("message", OSD.FromString("SetDisplayNameReply"));

            return(nameReply);
        }
Exemplo n.º 10
0
 public OSDMap GetOSD()
 {
     return(new OSDMap
     {
         { "agent_id", OSD.FromUUID(AgentID) },
         { "created", OSD.FromDate(Created) }
     });
 }
Exemplo n.º 11
0
        protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
//            m_log.DebugFormat("[GET_DISPLAY_NAMES]: called {0}", httpRequest.Url.Query);

            NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);

            string[] ids = query.GetValues("ids");


            if (m_UserManagement == null)
            {
                m_log.Error("[GET_DISPLAY_NAMES]: Cannot fetch display names without a user management component");
                httpResponse.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
                return(new byte[0]);
            }

            OSDMap   osdReply = new OSDMap();
            OSDArray agents   = new OSDArray();

            osdReply["agents"] = agents;
            foreach (string id in ids)
            {
                UUID uuid = UUID.Zero;
                if (UUID.TryParse(id, out uuid))
                {
                    string name = m_UserManagement.GetUserName(uuid);
                    if (!string.IsNullOrEmpty(name))
                    {
                        string[] parts   = name.Split(new char[] { ' ' });
                        OSDMap   osdname = new OSDMap();
                        // a date that is valid
//                        osdname["display_name_next_update"] = OSD.FromDate(new DateTime(1970,1,1));
                        // but send one that blocks edition, since we actually don't suport this
                        osdname["display_name_next_update"] = OSD.FromDate(DateTime.UtcNow.AddDays(8));
                        osdname["display_name_expires"]     = OSD.FromDate(DateTime.UtcNow.AddMonths(1));
                        osdname["display_name"]             = OSD.FromString(name);
                        osdname["legacy_first_name"]        = parts[0];
                        osdname["legacy_last_name"]         = parts[1];
                        osdname["username"] = OSD.FromString(name);
                        osdname["id"]       = OSD.FromUUID(uuid);
                        osdname["is_display_name_default"] = OSD.FromBoolean(true);

                        agents.Add(osdname);
                    }
                }
            }

            // Full content request
            httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK;
            //httpResponse.ContentLength = ??;
            httpResponse.ContentType = "application/llsd+xml";

            string reply = OSDParser.SerializeLLSDXmlString(osdReply);

            return(System.Text.Encoding.UTF8.GetBytes(reply));
        }
Exemplo n.º 12
0
 private void CreateMetaDataMap(AssetMetadata data, OSDMap map)
 {
     map["ContentType"]  = OSD.FromString(data.ContentType);
     map["CreationDate"] = OSD.FromDate(data.CreationDate);
     map["CreatorID"]    = OSD.FromString(data.CreatorID);
     map["Description"]  = OSD.FromString(data.Description);
     map["ID"]           = OSD.FromString(data.ID);
     map["Name"]         = OSD.FromString(data.Name);
     map["Type"]         = OSD.FromInteger(data.Type);
 }
Exemplo n.º 13
0
        /// <summary>
        ///     Set the display name for the given user
        /// </summary>
        /// <param name="path"></param>
        /// <param name="request"></param>
        /// <param name="httpRequest"></param>
        /// <param name="httpResponse"></param>
        /// <returns></returns>
        byte[] ProcessSetDisplayName(string path, Stream request,
                                     OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            try
            {
                OSDMap   rm             = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request));
                OSDArray display_name   = (OSDArray)rm["display_name"];
                string   oldDisplayName = display_name[0].AsString();
                string   newDisplayName = display_name[1].AsString();

                //Check to see if their name contains a banned character
                if (
                    bannedNames.Select(bannedUserName => bannedUserName.Replace(" ", ""))
                    .Any(BannedUserName => newDisplayName.ToLower().Contains(BannedUserName.ToLower())))
                {
                    newDisplayName = m_service.ClientCaps.AccountInfo.Name;
                }

                IUserProfileInfo info = m_profileConnector.GetUserProfile(m_service.AgentID);
                if (info == null)
                {
                    //m_avatar.ControllingClient.SendAlertMessage ("You cannot update your display name currently as your profile cannot be found.");
                }
                else
                {
                    //Set the name
                    info.DisplayName = newDisplayName;
                    m_profileConnector.UpdateUserProfile(info);
                    OSDMap osdname = new OSDMap();

                    //One for us
                    DisplayNameUpdate(newDisplayName, oldDisplayName, m_service.ClientCaps.AccountInfo, m_service.AgentID);
                    osdname["display_name_next_update"] = OSD.FromDate(DateTime.UtcNow.AddDays(8));


                    foreach (
                        IRegionClientCapsService avatar in
                        m_service.RegionCaps.GetClients().Where(avatar => avatar.AgentID != m_service.AgentID))
                    {
                        //Update all others
                        DisplayNameUpdate(newDisplayName, oldDisplayName, m_service.ClientCaps.AccountInfo, avatar.AgentID);
                    }
                    //The reply
                    SetDisplayNameReply(newDisplayName, oldDisplayName, m_service.ClientCaps.AccountInfo);
                }
            }
            catch
            {
            }

            return(MainServer.BlankResponse);
        }
Exemplo n.º 14
0
        private void PackUserInfo(IUserProfileInfo info, UserAccount account, ref OSDArray agents)
        {
            OSDMap agentMap = new OSDMap();

            agentMap["username"]                 = account.Name;
            agentMap["display_name"]             = info.DisplayName;
            agentMap["display_name_next_update"] = OSD.FromDate(DateTime.ParseExact("1970-01-01 00:00:00 +0", "yyyy-MM-dd hh:mm:ss z", System.Globalization.DateTimeFormatInfo.InvariantInfo).ToUniversalTime());
            agentMap["legacy_first_name"]        = account.FirstName;
            agentMap["legacy_last_name"]         = account.LastName;
            agentMap["id"] = info.PrincipalID;
            agentMap["is_display_name_default"] = isDefaultDisplayName(account.FirstName, account.LastName, account.Name, info.DisplayName);

            agents.Add(agentMap);
        }
Exemplo n.º 15
0
        /// <summary>
        ///     Pack this asset into an OSDMap
        /// </summary>
        /// <returns></returns>
        public override OSDMap ToOSD()
        {
            OSDMap assetMap = new OSDMap
            {
                { "AssetFlags", OSD.FromInteger((int)Flags) },
                { "AssetID", ID },
                { "CreationDate", OSD.FromDate(CreationDate) },
                { "CreatorID", OSD.FromUUID(CreatorID) },
                { "Data", OSD.FromBinary(Data) },
                { "HostUri", OSD.FromString(HostUri) },
                { "LastAccessed", OSD.FromDate(LastAccessed) },
                { "Name", OSD.FromString(Name) },
                { "ParentID", CreationDate },
                { "TypeAsset", OSD.FromInteger((int)TypeAsset) },
                { "Description", OSD.FromString(Description) },
                { "DatabaseTable", OSD.FromString(DatabaseTable) }
            };

            return(assetMap);
        }
Exemplo n.º 16
0
        private OSDMap SerializeInventoryNode(InventoryBase node)
        {
            OSDMap map = new OSDMap();

            if (node is InventoryItem)
            {
                InventoryItem item = (InventoryItem)node;
                map["asset_id"]      = OSD.FromUUID(item.AssetID);
                map["content_type"]  = OSD.FromString(item.ContentType);
                map["creation_date"] = OSD.FromDate(item.CreationDate);
                map["creator_id"]    = OSD.FromUUID(item.CreatorID);
                map["description"]   = OSD.FromString(item.Description);
                map["extra_data"]    = item.ExtraData;
                map["id"]            = OSD.FromUUID(item.ID);
                map["name"]          = OSD.FromString(item.Name);
                map["owner_id"]      = OSD.FromUUID(item.OwnerID);
                map["parent_id"]     = OSD.FromUUID(item.ParentID);
            }
            else if (node is InventoryFolder)
            {
                InventoryFolder folder = (InventoryFolder)node;
                map["extra_data"]   = folder.ExtraData;
                map["id"]           = OSD.FromUUID(folder.ID);
                map["name"]         = OSD.FromString(folder.Name);
                map["owner_id"]     = OSD.FromUUID(folder.OwnerID);
                map["parent_id"]    = OSD.FromUUID(folder.ParentID);
                map["content_type"] = OSD.FromString(folder.PreferredContentType);
                map["version"]      = OSD.FromInteger(folder.Version);
            }
            else
            {
                m_log.Warn("Unrecognized inventory node " + node);
            }

            return(map);
        }
Exemplo n.º 17
0
        void PackUserInfo(IUserProfileInfo info, UserAccount account, ref OSDArray agents)
        {
            if (display_update_enabled == "false")
            {
                MainConsole.Instance.InfoFormat("[DisplayNames] DisplayNames Update Time Disabled by Configuration");
                OSDMap agentMap = new OSDMap();
                agentMap["username"]                 = account.Name;
                agentMap["display_name"]             = (info == null || info.DisplayName == "") ? account.Name : info.DisplayName;
                agentMap["display_name_next_update"] =
                    OSD.FromDate(
                        DateTime.ParseExact("1970-01-01 00:00:00 +0", "yyyy-MM-dd hh:mm:ss z",
                                            DateTimeFormatInfo.InvariantInfo).ToUniversalTime());
                agentMap["legacy_first_name"] = account.FirstName;
                agentMap["legacy_last_name"]  = account.LastName;
                agentMap["id"] = account.PrincipalID;
                agentMap["is_display_name_default"] = isDefaultDisplayName(account.FirstName, account.LastName, account.Name,
                                                                           info == null ? account.Name : info.DisplayName);

                agents.Add(agentMap);
            }
            else if (display_update_enabled == "true")
            {
                MainConsole.Instance.InfoFormat("[DisplayNames] DisplayNames Update Time Enabled by Configuration");
                OSDMap agentMap = new OSDMap();
                agentMap["username"]                 = account.Name;
                agentMap["display_name"]             = (info == null || info.DisplayName == "") ? account.Name : info.DisplayName;
                agentMap["display_name_next_update"] = OSD.FromDate(DateTime.UtcNow.AddDays(display_update_days));
                agentMap["legacy_first_name"]        = account.FirstName;
                agentMap["legacy_last_name"]         = account.LastName;
                agentMap["id"] = account.PrincipalID;
                agentMap["is_display_name_default"] = isDefaultDisplayName(account.FirstName, account.LastName, account.Name,
                                                                           info == null ? account.Name : info.DisplayName);

                agents.Add(agentMap);
            }
        }
Exemplo n.º 18
0
        /// <summary>
        ///     Tell the user about an update
        /// </summary>
        /// <param name="newDisplayName"></param>
        /// <param name="oldDisplayName"></param>
        /// <param name="iD"></param>
        /// <param name="isDefault"></param>
        /// <param name="first"></param>
        /// <param name="last"></param>
        /// <param name="account"></param>
        /// <returns></returns>

        public OSD DisplayNameUpdate(string newDisplayName, string oldDisplayName, UUID iD, bool isDefault, string first,
                                     string last, string account)
        {
            OSDMap nameReply = new OSDMap {
                { "message", OSD.FromString("DisplayNameUpdate") }
            };

            OSDMap body = new OSDMap();

            ///Display Name time working ... fix date in viewer? but how
            if (display_update_enabled == "true")
            {
                MainConsole.Instance.InfoFormat("[DisplayNames] Display Names Time Enabled");
                OSDMap agentData = new OSDMap
                {
                    { "display_name", OSD.FromString(newDisplayName) },
                    {
                        "display_name_next_update", OSD.FromDate(
                            DateTime.UtcNow.AddDays(display_update_days))
                    },
                    { "id", OSD.FromUUID(iD) },
                    { "is_display_name_default", OSD.FromBoolean(isDefault) },
                    { "legacy_first_name", OSD.FromString(first) },
                    { "legacy_last_name", OSD.FromString(last) },
                    { "username", OSD.FromString(account) }
                };

                body.Add("agent", agentData);
                body.Add("agent_id", OSD.FromUUID(iD));
                body.Add("old_display_name", OSD.FromString(oldDisplayName));

                nameReply.Add("body", body);

                return(nameReply);
            }
            else
            {
                MainConsole.Instance.InfoFormat("[DisplayNames] Display Names Time Disabled");
                OSDMap agentData = new OSDMap
                {
                    { "display_name", OSD.FromString(newDisplayName) },
                    {
                        "display_name_next_update", OSD.FromDate(
                            DateTime.ParseExact("1970-01-01 00:00:00 +0", "yyyy-MM-dd hh:mm:ss z",
                                                DateTimeFormatInfo.InvariantInfo).ToUniversalTime())
                    },
                    { "id", OSD.FromUUID(iD) },
                    { "is_display_name_default", OSD.FromBoolean(isDefault) },
                    { "legacy_first_name", OSD.FromString(first) },
                    { "legacy_last_name", OSD.FromString(last) },
                    { "username", OSD.FromString(account) }
                };

                body.Add("agent", agentData);
                body.Add("agent_id", OSD.FromUUID(iD));
                body.Add("old_display_name", OSD.FromString(oldDisplayName));

                nameReply.Add("body", body);

                return(nameReply);
            }
        }
Exemplo n.º 19
0
        public OSDMap GetOSD()
        {
            OSDMap map = new OSDMap();

            map["id"]       = OSD.FromUUID(ID);
            map["local_id"] = OSD.FromInteger(LocalID);

            OSDArray blacklist = new OSDArray();

            if (AccessBlackList != null)
            {
                for (int i = 0; i < AccessBlackList.Count; i++)
                {
                    blacklist.Add(AccessBlackList[i].GetOSD());
                }
            }
            map["access_black_list"] = blacklist;

            OSDArray whitelist = new OSDArray();

            if (AccessWhiteList != null)
            {
                for (int i = 0; i < AccessWhiteList.Count; i++)
                {
                    whitelist.Add(AccessWhiteList[i].GetOSD());
                }
            }
            map["access_white_list"] = whitelist;

            map["auth_buyer_id"]    = OSD.FromUUID(AuthBuyerID);
            map["auto_return_time"] = OSD.FromInteger(AutoReturnTime);
            map["bitmap"]           = OSD.FromBinary(Bitmap);
            map["category"]         = OSD.FromInteger((int)Category);
            map["claim_date"]       = OSD.FromDate(ClaimDate);
            map["desc"]             = OSD.FromString(Desc);
            map["dwell"]            = OSD.FromReal(Dwell);
            map["flags"]            = OSD.FromInteger((uint)Flags);
            map["group_id"]         = OSD.FromUUID(GroupID);
            map["is_group_owned"]   = OSD.FromBoolean(IsGroupOwned);
            map["landing"]          = OSD.FromInteger((int)Landing);
            map["max_prims"]        = OSD.FromInteger(MaxPrims);

            OSDMap media = new OSDMap
            {
                { "auto_scale", OSD.FromBoolean(Media.MediaAutoScale) },
                { "desc", OSD.FromString(Media.MediaDesc) },
                { "height", OSD.FromInteger(Media.MediaHeight) },
                { "id", OSD.FromUUID(Media.MediaID) },
                { "loop", OSD.FromBoolean(Media.MediaLoop) },
                { "type", OSD.FromString(Media.MediaType) },
                { "url", OSD.FromString(Media.MediaURL) },
                { "width", OSD.FromInteger(Media.MediaWidth) }
            };

            map["parcel_media"] = media;

            map["music_url"]           = OSD.FromString(MusicURL);
            map["name"]                = OSD.FromString(Name);
            map["obscure_media"]       = OSD.FromBoolean(ObscureMedia);
            map["obscure_music"]       = OSD.FromBoolean(ObscureMusic);
            map["owner_id"]            = OSD.FromUUID(OwnerID);
            map["pass_hours"]          = OSD.FromReal(PassHours);
            map["pass_price"]          = OSD.FromInteger(PassPrice);
            map["deny_age_unverified"] = OSD.FromBoolean(DenyAgeUnverified);
            map["deny_anonymous"]      = OSD.FromBoolean(DenyAnonymous);
            map["push_override"]       = OSD.FromBoolean(PushOverride);
            map["sale_price"]          = OSD.FromInteger(SalePrice);
            map["snapshot_id"]         = OSD.FromUUID(SnapshotID);
            map["status"]              = OSD.FromInteger((int)Status);
            map["landing_location"]    = OSD.FromVector3(LandingLocation);
            map["landing_look_at"]     = OSD.FromVector3(LandingLookAt);

            return(map);
        }
Exemplo n.º 20
0
        protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            //            m_log.DebugFormat("[GET_DISPLAY_NAMES]: called {0}", httpRequest.Url.Query);

            NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);

            string[] ids = query.GetValues("ids");

            if (m_UserManagement == null)
            {
                m_log.Error("[GET_DISPLAY_NAMES]: Cannot fetch display names without a user management component");
                httpResponse.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
                return(new byte[0]);
            }

            Dictionary <UUID, string> names = m_UserManagement.GetUsersNames(ids, UUID.Zero);

            OSDMap   osdReply = new OSDMap();
            OSDArray agents   = new OSDArray();

            osdReply["agents"] = agents;
            foreach (KeyValuePair <UUID, string> kvp in names)
            {
                if (string.IsNullOrEmpty(kvp.Value))
                {
                    continue;
                }
                if (kvp.Key == UUID.Zero)
                {
                    continue;
                }

                string[] parts   = kvp.Value.Split(new char[] { ' ' });
                OSDMap   osdname = new OSDMap();
                if (parts[0] == "Unknown")
                {
                    osdname["display_name_next_update"] = OSD.FromDate(DateTime.UtcNow.AddHours(1));
                    osdname["display_name_expires"]     = OSD.FromDate(DateTime.UtcNow.AddHours(2));
                }
                else
                {
                    osdname["display_name_next_update"] = OSD.FromDate(DateTime.UtcNow.AddDays(8));
                    osdname["display_name_expires"]     = OSD.FromDate(DateTime.UtcNow.AddMonths(1));
                }
                osdname["display_name"]      = OSD.FromString(kvp.Value);
                osdname["legacy_first_name"] = parts[0];
                osdname["legacy_last_name"]  = parts[1];
                osdname["username"]          = OSD.FromString(kvp.Value);
                osdname["id"] = OSD.FromUUID(kvp.Key);
                osdname["is_display_name_default"] = OSD.FromBoolean(true);

                agents.Add(osdname);
            }

            // Full content request
            httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK;
            //httpResponse.ContentLength = ??;
            httpResponse.ContentType = "application/llsd+xml";

            string reply = OSDParser.SerializeLLSDXmlString(osdReply);

            return(System.Text.Encoding.UTF8.GetBytes(reply));
        }
Exemplo n.º 21
0
        public OSDMap GetOSD()
        {
            Primitive.ConstructionData primData = Prim.PrimData;
            Primitive.ObjectProperties properties = Prim.Properties;

            OSDMap pathMap = new OSDMap();
            pathMap["begin"] = OSD.FromReal(primData.PathBegin);
            pathMap["curve"] = OSD.FromInteger((int)primData.PathCurve);
            pathMap["end"] = OSD.FromReal(primData.PathEnd);
            pathMap["radius_offset"] = OSD.FromReal(primData.PathRadiusOffset);
            pathMap["revolutions"] = OSD.FromReal(primData.PathRevolutions);
            pathMap["scale_x"] = OSD.FromReal(primData.PathScaleX);
            pathMap["scale_y"] = OSD.FromReal(primData.PathScaleY);
            pathMap["shear_x"] = OSD.FromReal(primData.PathShearX);
            pathMap["shear_y"] = OSD.FromReal(primData.PathShearY);
            pathMap["skew"] = OSD.FromReal(primData.PathSkew);
            pathMap["taper_x"] = OSD.FromReal(primData.PathTaperX);
            pathMap["taper_y"] = OSD.FromReal(primData.PathTaperY);
            pathMap["twist"] = OSD.FromReal(primData.PathTwist);
            pathMap["twist_begin"] = OSD.FromReal(primData.PathTwistBegin);

            OSDMap profileMap = new OSDMap();
            profileMap["begin"] = OSD.FromReal(primData.ProfileBegin);
            profileMap["curve"] = OSD.FromInteger((int)primData.ProfileCurve);
            profileMap["hole"] = OSD.FromInteger((int)primData.ProfileHole);
            profileMap["end"] = OSD.FromReal(primData.ProfileEnd);
            profileMap["hollow"] = OSD.FromReal(primData.ProfileHollow);

            OSDMap propertiesMap = new OSDMap();

            if (properties != null)
            {
                propertiesMap["aggregate_perms"] = OSD.FromInteger(properties.AggregatePerms);
                propertiesMap["aggregate_perms_textures"] = OSD.FromInteger(properties.AggregatePermTextures);
                propertiesMap["aggregate_perms_textures_owner"] = OSD.FromInteger(properties.AggregatePermTexturesOwner);
                propertiesMap["category"] = OSD.FromInteger((int)properties.Category);
                propertiesMap["creation_date"] = OSD.FromDate(properties.CreationDate);
                propertiesMap["creator_id"] = OSD.FromUUID(properties.CreatorID);
                propertiesMap["description"] = OSD.FromString(properties.Description);
                propertiesMap["folder_id"] = OSD.FromUUID(properties.FolderID);
                propertiesMap["from_task_id"] = OSD.FromUUID(properties.FromTaskID);
                // properties.GroupID is redundant
                propertiesMap["inventory_serial"] = OSD.FromInteger(properties.InventorySerial);
                propertiesMap["item_id"] = OSD.FromUUID(properties.ItemID);
                propertiesMap["last_owner_id"] = OSD.FromUUID(properties.LastOwnerID);
                propertiesMap["name"] = OSD.FromString(properties.Name);
                // properties.ObjectID is redundant
                // properties.OwnerID is redundant
                propertiesMap["ownership_cost"] = OSD.FromInteger(properties.OwnershipCost);
                propertiesMap["permissions"] = properties.Permissions.GetOSD();
                propertiesMap["sale_price"] = OSD.FromInteger(properties.SalePrice);
                propertiesMap["sale_type"] = OSD.FromInteger((int)properties.SaleType);
                propertiesMap["sit_name"] = OSD.FromString(properties.SitName);
                propertiesMap["touch_name"] = OSD.FromString(properties.TouchName);
            }

            OSDMap primMap = new OSDMap();
            primMap["path"] = pathMap;
            primMap["profile"] = profileMap;
            primMap["properties"] = propertiesMap;

            primMap["acceleration"] = OSD.FromVector3(Prim.Acceleration);
            primMap["ang_velocity"] = OSD.FromVector3(Prim.AngularVelocity);
            primMap["click_action"] = OSD.FromInteger((int)Prim.ClickAction);
            primMap["flags"] = OSD.FromInteger((uint)Prim.Flags);
            primMap["group_id"] = OSD.FromUUID(Prim.GroupID);
            primMap["id"] = OSD.FromUUID(Prim.ID);
            primMap["local_id"] = OSD.FromInteger(Prim.LocalID);
            primMap["media_url"] = OSD.FromString(Prim.MediaURL);
            primMap["owner_id"] = OSD.FromUUID(Prim.OwnerID);
            primMap["parent_id"] = OSD.FromInteger(Prim.ParentID);
            primMap["particles"] = Prim.ParticleSys.GetOSD();
            primMap["position"] = OSD.FromVector3(Prim.Position);
            primMap["rotation"] = OSD.FromQuaternion(Prim.Rotation);
            primMap["scale"] = OSD.FromVector3(Prim.Scale);
            primMap["scratch_pad"] = OSD.FromBinary(Prim.ScratchPad);
            primMap["sound"] = OSD.FromUUID(Prim.Sound);
            primMap["sound_flags"] = OSD.FromInteger((int)Prim.SoundFlags);
            primMap["sound_gain"] = OSD.FromReal(Prim.SoundGain);
            primMap["sound_radius"] = OSD.FromReal(Prim.SoundRadius);
            primMap["text"] = OSD.FromString(Prim.Text);
            primMap["text_color"] = OSD.FromColor4(Prim.TextColor);
            primMap["texture_anim"] = Prim.TextureAnim.GetOSD();
            primMap["tree_species"] = OSD.FromInteger((int)Prim.TreeSpecies);
            primMap["velocity"] = OSD.FromVector3(Prim.Velocity);

            primMap["material"] = OSD.FromInteger((int)primData.Material);
            primMap["state"] = OSD.FromInteger(primData.State);
            primMap["pcode"] = OSD.FromInteger((int)primData.PCode);

            if (Prim.NameValues != null)
                primMap["name_values"] = OSD.FromString(NameValue.NameValuesToString(Prim.NameValues));
            if (Prim.Textures != null)
                primMap["textures"] = Prim.Textures.GetOSD();
            if (Prim.Light != null)
                primMap["light"] = Prim.Light.GetOSD();
            if (Prim.Flexible != null)
                primMap["flex"] = Prim.Flexible.GetOSD();
            if (Prim.Sculpt != null)
                primMap["sculpt"] = Prim.Sculpt.GetOSD();

            OSDMap map = new OSDMap();
            map["prim"] = primMap;
            map["sit_position"] = OSD.FromVector3(SitPosition);
            map["sit_rotation"] = OSD.FromQuaternion(SitRotation);
            map["attachment_position"] = OSD.FromVector3(AttachmentPosition);
            map["attachment_rotation"] = OSD.FromQuaternion(AttachmentRotation);
            map["last_attachment_point"] = OSD.FromInteger((int)LastAttachmentPoint);
            map["before_attachment_rotation"] = OSD.FromQuaternion(BeforeAttachmentRotation);
            map["rotation_axis"] = OSD.FromVector3(m_rotationAxis);
            map["link_number"] = OSD.FromInteger(m_linkNumber);
            map["remote_script_access_pin"] = OSD.FromInteger(RemoteScriptAccessPIN);
            map["inventory"] = OSD.FromString(Inventory.GetTaskInventoryAsset());

            OSDArray buttons = new OSDArray { 
                OSD.FromInteger(PayPriceButtons[0]),
                OSD.FromInteger(PayPriceButtons[1]),
                OSD.FromInteger(PayPriceButtons[2]),
                OSD.FromInteger(PayPriceButtons[3])
            };

            map["pay_price_buttons"] = buttons;
            map["pay_price"] = OSD.FromInteger(PayPrice);

            if (Prim.FaceMedia != null)
            {
                OSDArray faceMedia = new OSDArray(Prim.FaceMedia.Length);
                for (int i = 0; i < Prim.FaceMedia.Length; i++)
                {
                    MediaEntry entry = Prim.FaceMedia[i];
                    if (entry != null)
                        faceMedia.Add(entry.GetOSD());
                    else
                        faceMedia.Add(new OSD());
                }
                map["face_media"] = faceMedia;
            }
            map["media_version"] = OSD.FromString(Prim.MediaVersion);

            map["last_updated"] = OSD.FromDate(m_lastUpdated);

            return map;
        }