public MappedIdentity MapUser(OpenMetaverse.UUID SlId, string SlName = null)
        {
            var identity = new MappedIdentity(IdentityCategory.Agent);

            identity.AvatarID = SlId;

            if (SlName != null && !UsernameToKeyCache.ContainsKey(SlName))
            {
                identity.SlName            = SlName;
                UsernameToKeyCache[SlName] = SlId;
                KeyToUsernameCache[SlId]   = SlName;
            }

            if (KeyToUsernameCache.ContainsKey(SlId))
            {
                identity.SlName = KeyToUsernameCache[SlId];
            }
            else
            {
                identity.SlName = ResolveNameFromId(SlId);
            }

            identity.IrcNick   = MakeIrcName(identity.SlName, ".");
            identity.IrcIdent  = SlId.ToString();
            identity.IrcDomain = AGENTHOST;

            return(identity);
        }
        /// <summary>
        /// On our own thread, make  the synchronous texture request from the asset server
        /// </summary>
        /// <param name="qInstance"></param>
        /// <param name="obinID"></param>
        /// <returns></returns>
        private bool ThrottleTextureMakeRequest(DoLaterBase qInstance, Object obinID)
        {
            OMV.UUID binID = (OMV.UUID)obinID;

            Uri            assetPath = new Uri(m_basePath + "/assets/" + binID.ToString() + (m_dataFetch ? "/data" : ""));
            HttpWebRequest request   = (HttpWebRequest)WebRequest.Create(assetPath);

            request.MaximumAutomaticRedirections = 4;
            request.MaximumResponseHeadersLength = 4;
            request.Timeout = 30000; // 30 second timeout
            if (m_proxyPath != null)
            {
                // configure proxy if necessary
                WebProxy myProxy = new WebProxy();
                myProxy.Address = new Uri(m_proxyPath);
                request.Proxy   = myProxy;
            }
            try {
                m_log.Log(LogLevel.DCOMMDETAIL, "ThrottleTextureMakeRequest: requesting '{0}'", assetPath);
                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) {
                    m_log.Log(LogLevel.DCOMMDETAIL, "ThrottleTextureMakeRequest: request returned. resp={0}, l={1}",
                              response.StatusCode, response.ContentLength);
                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        using (Stream receiveStream = response.GetResponseStream()) {
                            OMV.Assets.AssetTexture at;
                            if (m_dataFetch)
                            {
                                // we're getting raw binary data
                                byte[] textureBuff = new byte[response.ContentLength];
                                receiveStream.Read(textureBuff, 0, (int)response.ContentLength);
                                at = new OMV.Assets.AssetTexture(binID, textureBuff);
                            }
                            else
                            {
                                // receiving a serialized package
                                XmlSerializer xserial             = new XmlSerializer(typeof(OpenSim.Framework.AssetBase));
                                OpenSim.Framework.AssetBase abase = (OpenSim.Framework.AssetBase)xserial.Deserialize(receiveStream);
                                at = new OMV.Assets.AssetTexture(binID, abase.Data);
                            }
                            ProcessDownloadFinished(OMV.TextureRequestState.Finished, at);
                        }
                    }
                    else
                    {
                        OMV.Assets.AssetTexture at = new OMV.Assets.AssetTexture(binID, new byte[0]);
                        ProcessDownloadFinished(OMV.TextureRequestState.NotFound, at);
                    }
                }
            }
            catch (Exception e) {
                m_log.Log(LogLevel.DBADERROR, "Error fetching asset: {0}", e);
                OMV.Assets.AssetTexture at = new OMV.Assets.AssetTexture(binID, new byte[0]);
                ProcessDownloadFinished(OMV.TextureRequestState.NotFound, at);
            }
            return(true);
        }
 public static EntityNameLL ConvertTextureWorldIDToEntityName(AssetContextBase context, OMV.UUID textureWorldID)
 {
     return(ConvertTextureWorldIDToEntityName(context, textureWorldID.ToString()));
 }
Esempio n. 4
0
        public override void StoreTextureImage(EntityHandle handle, string name, OMV.UUID creatorID, Image pImage)
        {
            // This application overloads AssetType.TExtureTGA to be our serialized image
            AssetBase newAsset = new AssetBase(((EntityHandleUUID)handle).GetUUID(), name, (sbyte)OMV.AssetType.TextureTGA, creatorID.ToString());

            using (MemoryStream byteStream = new MemoryStream()) {
                pImage.Save(byteStream, System.Drawing.Imaging.ImageFormat.Png);
                newAsset.Data = byteStream.ToArray();
            }
            _assetService.Store(newAsset);
        }
Esempio n. 5
0
        public override void StoreRawAsset(EntityHandle handle, string name, OMV.AssetType assetType, OMV.UUID creatorID, byte[] data)
        {
            AssetBase newAsset = new AssetBase(((EntityHandleUUID)handle).GetUUID(), name, (sbyte)assetType, creatorID.ToString());

            _assetService.Store(newAsset);
        }
Esempio n. 6
0
 // ToString() returns a 'name' for this entity that can be used to look it up
 public override string ToString()
 {
     return(_uuid.ToString());
 }
Esempio n. 7
0
        private void OnTextureDownloadFinished(string textureEntityName, bool hasTransparancy)
        {
            m_log.Log(LogLevel.DRENDERDETAIL, "OnTextureDownloadFinished {0}", textureEntityName);
            EntityName entName = new EntityName(textureEntityName);

            OMV.UUID id = new OMV.UUID(entName.ExtractEntityFromEntityName());

            TextureInfo info;

            lock (Textures) {
                if (!Textures.TryGetValue(id, out info))
                {
                    // The id of zero will say that the mipmaps need to be generated before the texture is used
                    m_log.Log(LogLevel.DRENDERDETAIL, "Adding TextureInfo for {0}:{1}", entName.Name, id.ToString());
                    info.Alpha = hasTransparancy;
                }
            }
        }
 public static EntityName AvatarEntityNameFromID(AssetContextBase acontext, OMV.UUID ID)
 {
     return(new EntityNameLL(acontext, "Avatar/" + ID.ToString()));
 }
        private void OnTextureDownloadFinished(string textureEntityName, bool hasTransparancy)
        {
            m_log.Log(LogLevel.DRENDERDETAIL, "OnTextureDownloadFinished {0}", textureEntityName);
            EntityName entName = new EntityName(textureEntityName);
            OMV.UUID id = new OMV.UUID(entName.ExtractEntityFromEntityName());

            TextureInfo info;
            lock (Textures) {
            if (!Textures.TryGetValue(id, out info)) {
                // The id of zero will say that the mipmaps need to be generated before the texture is used
                m_log.Log(LogLevel.DRENDERDETAIL, "Adding TextureInfo for {0}:{1}", entName.Name, id.ToString());
                info.Alpha = hasTransparancy;
            }
            }
        }
Esempio n. 10
0
        public void ToXmlRpc(XmlWriter writer)
        {
            writer.WriteStartElement("methodResponse");
            {
                writer.WriteStartElement("params");
                writer.WriteStartElement("param");
                writer.WriteStartElement("value");
                writer.WriteStartElement("struct");
                {
                    if (Success)
                    {
                        // session_id
                        WriteXmlRpcStringMember(writer, false, "session_id", SessionID.ToString());

                        // ui-config
                        WriteXmlRpcArrayStart(writer, "ui-config");
                        WriteXmlRpcStringMember(writer, true, "allow_first_life", "Y");
                        WriteXmlRpcArrayEnd(writer);

                        // inventory-lib-owner
                        WriteXmlRpcArrayStart(writer, "inventory-lib-owner");
                        WriteXmlRpcStringMember(writer, true, "agent_id", LibraryOwner.ToString());
                        WriteXmlRpcArrayEnd(writer);

                        // start_location
                        WriteXmlRpcStringMember(writer, false, "start_location", StartLocation);

                        // seconds_since_epoch
                        WriteXmlRpcIntMember(writer, false, "seconds_since_epoch", Utils.DateTimeToUnixTime(SecondsSinceEpoch));

                        // event_categories (TODO)
                        WriteXmlRpcArrayStart(writer, "event_categories");
                        WriteXmlRpcCategory(writer, "Default Event Category", 20);
                        WriteXmlRpcArrayEnd(writer);

                        // tutorial_setting (TODO)
                        WriteXmlRpcArrayStart(writer, "tutorial_setting");
                        WriteXmlRpcTutorialSetting(writer, "http://127.0.0.1/tutorial/");
                        WriteXmlRpcArrayEnd(writer);

                        // classified_categories (TODO)
                        WriteXmlRpcArrayStart(writer, "classified_categories");
                        WriteXmlRpcCategory(writer, "Default Classified Category", 1);
                        WriteXmlRpcArrayEnd(writer);

                        // inventory-root
                        WriteXmlRpcArrayStart(writer, "inventory-root");
                        WriteXmlRpcStringMember(writer, true, "folder_id", InventoryRoot.ToString());
                        WriteXmlRpcArrayEnd(writer);

                        // sim_port
                        WriteXmlRpcIntMember(writer, false, "sim_port", SimPort);

                        // agent_id
                        WriteXmlRpcStringMember(writer, false, "agent_id", AgentID.ToString());

                        // agent_access
                        WriteXmlRpcStringMember(writer, false, "agent_access", AgentAccess);

                        // inventory-skeleton
                        WriteXmlRpcArrayStart(writer, "inventory-skeleton");
                        if (InventorySkeleton != null)
                        {
                            foreach (InventoryFolder folder in InventorySkeleton)
                            {
                                WriteXmlRpcInventoryItem(writer, folder.Name, folder.ParentUUID, (uint)folder.Version, (uint)folder.PreferredType, folder.UUID);
                            }
                        }
                        else
                        {
                            WriteXmlRpcInventoryItem(writer, "Inventory", UUID.Zero, 1, (uint)InventoryType.Category, InventoryRoot);
                        }
                        WriteXmlRpcArrayEnd(writer);

                        // buddy-list
                        WriteXmlRpcArrayStart(writer, "buddy-list");
                        if (BuddyList != null)
                        {
                            foreach (FriendInfo friend in BuddyList)
                            {
                                WriteXmlRpcBuddy(writer, (uint)friend.MyFriendRights, (uint)friend.TheirFriendRights, friend.UUID);
                            }
                        }
                        else
                        {
                            //WriteXmlRpcBuddy(writer, 0, 0, UUID.Random());
                        }
                        WriteXmlRpcArrayEnd(writer);

                        // first_name
                        WriteXmlRpcStringMember(writer, false, "first_name", FirstName);

                        // global-textures
                        WriteXmlRpcArrayStart(writer, "global-textures");
                        writer.WriteStartElement("value");
                        writer.WriteStartElement("struct");
                        {
                            WriteXmlRpcStringMember(writer, false, "sun_texture_id", "cce0f112-878f-4586-a2e2-a8f104bba271");
                            WriteXmlRpcStringMember(writer, false, "cloud_texture_id", "fc4b9f0b-d008-45c6-96a4-01dd947ac621");
                            WriteXmlRpcStringMember(writer, false, "moon_texture_id", "d07f6eed-b96a-47cd-b51d-400ad4a1c428");
                        }
                        writer.WriteEndElement();
                        writer.WriteEndElement();
                        WriteXmlRpcArrayEnd(writer);

                        // inventory-skel-lib
                        WriteXmlRpcArrayStart(writer, "inventory-skel-lib");
                        if (LibrarySkeleton != null)
                        {
                            foreach (InventoryFolder folder in LibrarySkeleton)
                            {
                                WriteXmlRpcInventoryItem(writer, folder.Name, folder.ParentUUID, (uint)folder.Version, (uint)folder.PreferredType, folder.UUID);
                            }
                        }
                        else
                        {
                            WriteXmlRpcInventoryItem(writer, "Library", UUID.Zero, 1, (uint)InventoryType.Category, LibraryRoot);
                        }
                        WriteXmlRpcArrayEnd(writer);

                        // seed_capability
                        WriteXmlRpcStringMember(writer, false, "seed_capability", SeedCapability);

                        // gestures
                        WriteXmlRpcArrayStart(writer, "gestures");
                        WriteXmlRpcGesture(writer, UUID.Random(), UUID.Random());
                        WriteXmlRpcArrayEnd(writer);

                        // sim_ip
                        WriteXmlRpcStringMember(writer, false, "sim_ip", SimIP.ToString());

                        // inventory-lib-root
                        WriteXmlRpcArrayStart(writer, "inventory-lib-root");
                        WriteXmlRpcStringMember(writer, true, "folder_id", LibraryRoot.ToString());
                        WriteXmlRpcArrayEnd(writer);

                        // login-flags
                        WriteXmlRpcArrayStart(writer, "login-flags");
                        writer.WriteStartElement("value");
                        writer.WriteStartElement("struct");
                        {
                            WriteXmlRpcStringMember(writer, false, "gendered", "Y");
                            WriteXmlRpcStringMember(writer, false, "stipend_since_login", "N");
                            WriteXmlRpcStringMember(writer, false, "ever_logged_in", "Y");
                            if (DateTime.Now.IsDaylightSavingTime())
                            {
                                WriteXmlRpcStringMember(writer, false, "daylight_savings", "Y");
                            }
                            else
                            {
                                WriteXmlRpcStringMember(writer, false, "daylight_savings", "N");
                            }
                        }
                        writer.WriteEndElement();
                        writer.WriteEndElement();
                        WriteXmlRpcArrayEnd(writer);

                        // inventory_host
                        WriteXmlRpcStringMember(writer, false, "inventory_host", IPAddress.Loopback.ToString());

                        // home
                        LLSDArray homeRegionHandle = new LLSDArray(2);
                        uint      homeRegionX, homeRegionY;
                        Utils.LongToUInts(HomeRegion, out homeRegionX, out homeRegionY);
                        homeRegionHandle.Add(LLSD.FromReal((double)homeRegionX));
                        homeRegionHandle.Add(LLSD.FromReal((double)homeRegionY));

                        LLSDMap home = new LLSDMap(3);
                        home["region_handle"] = homeRegionHandle;
                        home["position"]      = LLSD.FromVector3(HomePosition);
                        home["look_at"]       = LLSD.FromVector3(HomeLookAt);

                        WriteXmlRpcStringMember(writer, false, "home", LLSDParser.SerializeNotation(home));

                        // message
                        WriteXmlRpcStringMember(writer, false, "message", Message);

                        // look_at
                        WriteXmlRpcStringMember(writer, false, "look_at", LLSDParser.SerializeNotation(LLSD.FromVector3(LookAt)));

                        // login
                        WriteXmlRpcStringMember(writer, false, "login", "true");

                        // event_notifications
                        WriteXmlRpcArrayStart(writer, "event_notifications");
                        WriteXmlRpcArrayEnd(writer);

                        // secure_session_id
                        WriteXmlRpcStringMember(writer, false, "secure_session_id", SecureSessionID.ToString());

                        // region_x
                        WriteXmlRpcIntMember(writer, false, "region_x", RegionX);

                        // last_name
                        WriteXmlRpcStringMember(writer, false, "last_name", LastName);

                        // region_y
                        WriteXmlRpcIntMember(writer, false, "region_y", RegionY);

                        // circuit_code
                        WriteXmlRpcIntMember(writer, false, "circuit_code", CircuitCode);

                        // initial-outfit
                        WriteXmlRpcArrayStart(writer, "initial-outfit");
                        WriteXmlRpcArrayEnd(writer);
                    }
                    else
                    {
                        // Login failure
                    }
                }
                writer.WriteEndElement();
                writer.WriteEndElement();
                writer.WriteEndElement();
                writer.WriteEndElement();
            }
            writer.WriteEndElement();
            writer.Close();
        }