Exemplo n.º 1
0
 public void Initialise(Scene scene, IConfigSource source, ISimulationBase openSimBase)
 {
     if (serviceConnectors == null)
     {
         serviceConnectors = AuroraModuleLoader.PickupModules<IService>();
         foreach (IService connector in serviceConnectors)
         {
             try
             {
                 connector.Initialize(source, openSimBase.ApplicationRegistry);
             }
             catch
             {
             }
         }
         foreach (IService connector in serviceConnectors)
         {
             try
             {
                 connector.PostInitialize(source, openSimBase.ApplicationRegistry);
             }
             catch
             {
             }
         }
     }
     scene.AddModuleInterfaces(openSimBase.ApplicationRegistry.GetInterfaces());
 }
Exemplo n.º 2
0
        /// <summary>
        /// Create a scene and its initial base structures.
        /// </summary>
        /// <param name="regionInfo"></param>
        /// <param name="proxyOffset"></param>
        /// <param name="configSource"></param>
        /// <param name="clientServer"> </param>
        /// <returns></returns>
        protected Scene SetupScene (RegionInfo regionInfo, IConfigSource configSource)
        {
            AgentCircuitManager circuitManager = new AgentCircuitManager ();
            List<IClientNetworkServer> clientServers = AuroraModuleLoader.PickupModules<IClientNetworkServer> ();
            List<IClientNetworkServer> allClientServers = new List<IClientNetworkServer> ();
            foreach (IClientNetworkServer clientServer in clientServers)
            {
                foreach (int port in regionInfo.UDPPorts)
                {
                    IClientNetworkServer copy = clientServer.Copy ();
                    copy.Initialise (port, m_configSource, circuitManager);
                    allClientServers.Add (copy);
                }
            }

            Scene scene = new Scene ();
            scene.AddModuleInterfaces (m_openSimBase.ApplicationRegistry.GetInterfaces ());
            scene.Initialize (regionInfo, circuitManager, allClientServers);

            return scene;
        }
Exemplo n.º 3
0
        /// <summary>
        ///   Create a scene and its initial base structures.
        /// </summary>
        /// <param name = "regionInfo"></param>
        /// <param name = "proxyOffset"></param>
        /// <param name = "configSource"></param>
        /// <param name = "clientServer"> </param>
        /// <returns></returns>
        protected IScene SetupScene(RegionInfo regionInfo, IConfigSource configSource)
        {
            AgentCircuitManager         circuitManager   = new AgentCircuitManager();
            List <IClientNetworkServer> clientServers    = AuroraModuleLoader.PickupModules <IClientNetworkServer>();
            List <IClientNetworkServer> allClientServers = new List <IClientNetworkServer>();

            foreach (IClientNetworkServer clientServer in clientServers)
            {
                foreach (int port in regionInfo.UDPPorts)
                {
                    IClientNetworkServer copy = clientServer.Copy();
                    copy.Initialise(port, m_configSource, circuitManager);
                    allClientServers.Add(copy);
                }
            }

            Scene scene = new Scene();

            scene.AddModuleInterfaces(m_openSimBase.ApplicationRegistry.GetInterfaces());
            scene.Initialize(regionInfo, circuitManager, allClientServers);

            return(scene);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create a scene and its initial base structures.
        /// </summary>
        /// <param name="regionInfo"></param>
        /// <param name="proxyOffset"></param>
        /// <param name="configSource"></param>
        /// <param name="clientServer"> </param>
        /// <returns></returns>
        protected Scene SetupScene(RegionInfo regionInfo, IConfigSource configSource)
        {
            AgentCircuitManager circuitManager = new AgentCircuitManager();
            IPAddress           listenIP       = regionInfo.InternalEndPoint.Address;

            if (!IPAddress.TryParse(regionInfo.InternalEndPoint.Address.ToString(), out listenIP))
            {
                listenIP = IPAddress.Parse("0.0.0.0");
            }

            uint port = (uint)regionInfo.InternalEndPoint.Port;

            string ClientstackDll = m_config.Configs["Startup"].GetString("ClientStackPlugin", "OpenSim.Region.ClientStack.LindenUDP.dll");

            IClientNetworkServer clientServer = AuroraModuleLoader.LoadPlugin <IClientNetworkServer> (Util.BasePathCombine(ClientstackDll));

            clientServer.Initialise(
                listenIP, ref port, 0, regionInfo.m_allow_alternate_ports,
                m_config, circuitManager);

            regionInfo.InternalEndPoint.Port = (int)port;

            Scene scene = new Scene();

            scene.AddModuleInterfaces(m_OpenSimBase.ApplicationRegistry.GetInterfaces());
            scene.Initialize(regionInfo, circuitManager, clientServer);

            StartModules(scene);

            m_clientServers.Add(clientServer);

            //Do this here so that we don't have issues later when startup complete messages start coming in
            m_localScenes.Add(scene);

            return(scene);
        }
Exemplo n.º 5
0
        ///<summary>
        ///</summary>
        ///<param name = "assetID"></param>
        ///<param name = "inventoryItem"></param>
        ///<param name = "data"></param>
        public UUID UploadCompleteHandler(string assetName, string assetDescription, UUID assetID,
                                          UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType,
                                          string assetType, uint everyone_mask, uint group_mask, uint next_owner_mask)
        {
            sbyte assType = 0;
            sbyte inType = 0;

            if (inventoryType == "sound")
            {
                inType = 1;
                assType = 1;
            }
            else if (inventoryType == "animation")
            {
                inType = 19;
                assType = 20;
            }
            else if (inventoryType == "snapshot")
            {
                inType = 15;
                assType = 0;
            }
            else if (inventoryType == "wearable")
            {
                inType = 18;
                switch (assetType)
                {
                    case "bodypart":
                        assType = 13;
                        break;
                    case "clothing":
                        assType = 5;
                        break;
                }
            }
            else if (inventoryType == "object")
            {
                inType = (sbyte) InventoryType.Object;
                assType = (sbyte) AssetType.Object;

                List<Vector3> positions = new List<Vector3>();
                List<Quaternion> rotations = new List<Quaternion>();
                OSDMap request = (OSDMap) OSDParser.DeserializeLLSDXml(data);
                OSDArray instance_list = (OSDArray) request["instance_list"];
                OSDArray mesh_list = (OSDArray) request["mesh_list"];
                OSDArray texture_list = (OSDArray) request["texture_list"];
                SceneObjectGroup grp = null;

                List<UUID> textures = new List<UUID>();
#if(!ISWIN)
                for (int i = 0; i < texture_list.Count; i++)
                {
                    AssetBase textureAsset = new AssetBase(UUID.Random(), assetName, AssetType.Texture, m_service.AgentID);
                    textureAsset.Data = texture_list[i].AsBinary();
                    textureAsset.ID = m_assetService.Store(textureAsset);
                    textures.Add(textureAsset.ID);
                }
#else
                foreach (AssetBase textureAsset in texture_list.Select(t => new AssetBase(UUID.Random(), assetName, AssetType.Texture,
                                                                                          m_service.AgentID) {Data = t.AsBinary()}))
                {
                    textureAsset.ID = m_assetService.Store(textureAsset);
                    textures.Add(textureAsset.ID);
                }
#endif
                InventoryFolderBase meshFolder = m_inventoryService.GetFolderForType(m_service.AgentID,
                                                                                     InventoryType.Mesh, AssetType.Mesh);
                for (int i = 0; i < mesh_list.Count; i++)
                {
                    PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox();

                    Primitive.TextureEntry textureEntry =
                        new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE);
                    OSDMap inner_instance_list = (OSDMap) instance_list[i];

                    OSDArray face_list = (OSDArray) inner_instance_list["face_list"];
                    for (uint face = 0; face < face_list.Count; face++)
                    {
                        OSDMap faceMap = (OSDMap) face_list[(int) face];
                        Primitive.TextureEntryFace f = pbs.Textures.CreateFace(face);
                        if (faceMap.ContainsKey("fullbright"))
                            f.Fullbright = faceMap["fullbright"].AsBoolean();
                        if (faceMap.ContainsKey("diffuse_color"))
                            f.RGBA = faceMap["diffuse_color"].AsColor4();

                        int textureNum = faceMap["image"].AsInteger();
                        float imagerot = faceMap["imagerot"].AsInteger();
                        float offsets = (float) faceMap["offsets"].AsReal();
                        float offsett = (float) faceMap["offsett"].AsReal();
                        float scales = (float) faceMap["scales"].AsReal();
                        float scalet = (float) faceMap["scalet"].AsReal();

                        if (imagerot != 0)
                            f.Rotation = imagerot;
                        if (offsets != 0)
                            f.OffsetU = offsets;
                        if (offsett != 0)
                            f.OffsetV = offsett;
                        if (scales != 0)
                            f.RepeatU = scales;
                        if (scalet != 0)
                            f.RepeatV = scalet;
                        f.TextureID = textures.Count > textureNum ? textures[textureNum] : Primitive.TextureEntry.WHITE_TEXTURE;
                        textureEntry.FaceTextures[face] = f;
                    }
                    pbs.TextureEntry = textureEntry.GetBytes();

                    AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, AssetType.Mesh, m_service.AgentID)
                                              {Data = mesh_list[i].AsBinary()};
                    meshAsset.ID = m_assetService.Store(meshAsset);

                    if (meshFolder == null)
                    {
                        m_inventoryService.CreateUserInventory(m_service.AgentID, false);
                        meshFolder = m_inventoryService.GetFolderForType(m_service.AgentID, InventoryType.Mesh,
                                                                         AssetType.Mesh);
                    }

                    InventoryItemBase itemBase = new InventoryItemBase(UUID.Random(), m_service.AgentID)
                                                     {
                                                         AssetType = (sbyte) AssetType.Mesh,
                                                         AssetID = meshAsset.ID,
                                                         CreatorId = m_service.AgentID.ToString(),
                                                         Folder = meshFolder.ID,
                                                         InvType = (int) InventoryType.Texture,
                                                         Name = "(Mesh) - " + assetName,
                                                         CurrentPermissions = (uint) PermissionMask.All,
                                                         BasePermissions = (uint) PermissionMask.All,
                                                         EveryOnePermissions = everyone_mask,
                                                         GroupPermissions = group_mask,
                                                         NextPermissions = next_owner_mask
                                                     };
                    //Bad... but whatever
                    m_inventoryService.AddItem(itemBase);

                    pbs.SculptEntry = true;
                    pbs.SculptTexture = meshAsset.ID;
                    pbs.SculptType = (byte) SculptType.Mesh;
                    pbs.SculptData = meshAsset.Data;

                    Vector3 position = inner_instance_list["position"].AsVector3();
                    Vector3 scale = inner_instance_list["scale"].AsVector3();
                    Quaternion rotation = inner_instance_list["rotation"].AsQuaternion();

                    int physicsShapeType = inner_instance_list["physics_shape_type"].AsInteger();
                    int material = inner_instance_list["material"].AsInteger();
                    int mesh = inner_instance_list["mesh"].AsInteger();

                    UUID owner_id = m_service.AgentID;

                    IScene fakeScene = new Scene();
                    fakeScene.AddModuleInterfaces(m_service.Registry.GetInterfaces());

                    SceneObjectPart prim = new SceneObjectPart(owner_id, pbs, position, Quaternion.Identity,
                                                               Vector3.Zero, assetName, fakeScene)
                                               {Scale = scale, AbsolutePosition = position};

                    rotations.Add(rotation);
                    positions.Add(position);
                    prim.UUID = UUID.Random();
                    prim.CreatorID = owner_id;
                    prim.OwnerID = owner_id;
                    prim.GroupID = UUID.Zero;
                    prim.LastOwnerID = prim.OwnerID;
                    prim.CreationDate = Util.UnixTimeSinceEpoch();
                    prim.Name = assetName;
                    prim.Description = "";
                    prim.PhysicsType = (byte) physicsShapeType;

                    prim.BaseMask = (uint) PermissionMask.All;
                    prim.EveryoneMask = everyone_mask;
                    prim.NextOwnerMask = next_owner_mask;
                    prim.GroupMask = group_mask;
                    prim.OwnerMask = (uint) PermissionMask.All;

                    if (grp == null)
                        grp = new SceneObjectGroup(prim, fakeScene);
                    else
                        grp.AddChild(prim, i + 1);
                    grp.RootPart.IsAttachment = false;
                }
                if (grp.ChildrenList.Count > 1) //Fix first link #
                    grp.RootPart.LinkNum++;

                Vector3 rootPos = positions[0];
                grp.SetAbsolutePosition(false, rootPos);
                for (int i = 0; i < positions.Count; i++)
                {
                    Vector3 offset = positions[i] - rootPos;
                    grp.ChildrenList[i].SetOffsetPosition(offset);
                    Vector3 abs = grp.ChildrenList[i].AbsolutePosition;
                    Vector3 currentPos = positions[i];
                }
                //grp.Rotation = rotations[0];
                for (int i = 0; i < rotations.Count; i++)
                {
                    if (i != 0)
                        grp.ChildrenList[i].SetRotationOffset(false, rotations[i], false);
                }
                grp.UpdateGroupRotationR(rotations[0]);
                data = Encoding.ASCII.GetBytes(grp.ToXml2());
            }
            AssetBase asset = new AssetBase(assetID, assetName, (AssetType) assType, m_service.AgentID) {Data = data};
            asset.ID = m_assetService.Store(asset);
            assetID = asset.ID;

            InventoryItemBase item = new InventoryItemBase
                                         {
                                             Owner = m_service.AgentID,
                                             CreatorId = m_service.AgentID.ToString(),
                                             ID = inventoryItem,
                                             AssetID = asset.ID,
                                             Description = assetDescription,
                                             Name = assetName,
                                             AssetType = assType,
                                             InvType = inType,
                                             Folder = parentFolder,
                                             CurrentPermissions = (uint) PermissionMask.All,
                                             BasePermissions = (uint) PermissionMask.All,
                                             EveryOnePermissions = everyone_mask,
                                             NextPermissions = next_owner_mask,
                                             GroupPermissions = group_mask,
                                             CreationDate = Util.UnixTimeSinceEpoch()
                                         };

            m_inventoryService.AddItem(item);

            return assetID;
        }
        /// <summary>
        ///   Use the asset set information at path to load assets
        /// </summary>
        /// <param name = "path"></param>
        /// <param name = "assets"></param>
        protected void LoadLibraries(string iarFileName)
        {
            RegionInfo regInfo = new RegionInfo();
            IScene m_MockScene = null;
            //Make the scene for the IAR loader
            if (m_registry is IScene)
                m_MockScene = (IScene) m_registry;
            else
            {
                m_MockScene = new Scene();
                m_MockScene.Initialize(regInfo);
                m_MockScene.AddModuleInterfaces(m_registry.GetInterfaces());
            }

            UserAccount uinfo = m_MockScene.UserAccountService.GetUserAccount(UUID.Zero, m_service.LibraryOwner);
            //Make the user account for the default IAR
            if (uinfo == null)
            {
                MainConsole.Instance.Warn("Creating user " + m_service.LibraryOwnerName);
                m_MockScene.UserAccountService.CreateUser(m_service.LibraryOwner, m_service.LibraryOwnerName, "", "");
                uinfo = m_MockScene.UserAccountService.GetUserAccount(UUID.Zero, m_service.LibraryOwner);
                m_MockScene.InventoryService.CreateUserInventory(uinfo.PrincipalID, false);
            }
            if (m_MockScene.InventoryService.GetRootFolder(m_service.LibraryOwner) == null)
                m_MockScene.InventoryService.CreateUserInventory(uinfo.PrincipalID, false);

            List<InventoryFolderBase> rootFolders = m_MockScene.InventoryService.GetFolderFolders(uinfo.PrincipalID,
                                                                                                  UUID.Zero);
#if (!ISWIN)
            bool alreadyExists = false;
            foreach (InventoryFolderBase folder in rootFolders)
            {
                if (folder.Name == iarFileName)
                {
                    alreadyExists = true;
                    break;
                }
            }
#else
            bool alreadyExists = rootFolders.Any(folder => folder.Name == iarFileName);
#endif
            if (alreadyExists)
            {
                MainConsole.Instance.InfoFormat("[LIBRARY INVENTORY]: Found previously loaded iar file {0}, ignoring.", iarFileName);
                return;
            }

            MainConsole.Instance.InfoFormat("[LIBRARY INVENTORY]: Loading iar file {0}", iarFileName);
            InventoryFolderBase rootFolder = m_MockScene.InventoryService.GetRootFolder(uinfo.PrincipalID);

            if (null == rootFolder)
            {
                //We need to create the root folder, otherwise the IAR freaks
                m_MockScene.InventoryService.CreateUserInventory(uinfo.PrincipalID, false);
            }

            InventoryArchiveReadRequest archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, "/", iarFileName,
                                                                                   false);

            try
            {
                List<InventoryNodeBase> nodes = new List<InventoryNodeBase>(archread.Execute(true));
                if (nodes.Count == 0)
                    return;
                InventoryFolderBase f = (InventoryFolderBase) nodes[0];

                TraverseFolders(nodes[0].ID, m_MockScene);
                //This is our loaded folder
                //Fix the name for later
                f.Name = iarFileName;
                f.ParentID = UUID.Zero;
                //f.Type = (int)AssetType.RootFolder;
                m_MockScene.InventoryService.UpdateFolder(f);
            }
            catch (Exception e)
            {
                MainConsole.Instance.DebugFormat("[LIBRARY MODULE]: Exception when processing archive {0}: {1}", iarFileName,
                                  e.StackTrace);
            }
            finally
            {
                archread.Close();
            }
        }
        /// <summary>
        /// Use the asset set information at path to load assets
        /// </summary>
        /// <param name="path"></param>
        /// <param name="assets"></param>
        protected void LoadLibraries(string iarFileName)
        {
            RegionInfo regInfo = new RegionInfo();
            Scene m_MockScene = null;
            //Make the scene for the IAR loader
            if (m_registry is Scene)
                m_MockScene = (Scene)m_registry;
            else
            {
                m_MockScene = new Scene(regInfo);
                m_MockScene.AddModuleInterfaces(m_registry.GetInterfaces());
            }

            UserAccount uinfo = m_MockScene.UserAccountService.GetUserAccount(UUID.Zero, m_service.LibraryOwner);
            //Make the user account for the default IAR
            if (uinfo == null)
            {
                m_log.Warn("Creating user " + m_service.LibraryOwnerName[0] + " " + m_service.LibraryOwnerName[1]);
                m_MockScene.UserAccountService.CreateUser(m_service.LibraryOwnerName[0],
                    m_service.LibraryOwnerName[1], "", "");
                uinfo = m_MockScene.UserAccountService.GetUserAccount(UUID.Zero, m_service.LibraryOwnerName[0],
                    m_service.LibraryOwnerName[1]);
                m_MockScene.InventoryService.CreateUserInventory(uinfo.PrincipalID);
            }

            InventoryCollection col = m_MockScene.InventoryService.GetFolderContent(uinfo.PrincipalID, UUID.Zero);
            bool alreadyExists = false;
            foreach (InventoryFolderBase folder in col.Folders)
            {
                if (folder.Name == iarFileName)
                {
                    alreadyExists = true;
                    break;
                }
            }
            if (alreadyExists)
            {
                m_log.InfoFormat("[LIBRARY INVENTORY]: Found previously loaded iar file {0}, ignoring.", iarFileName);
                return;
            }

            m_log.InfoFormat("[LIBRARY INVENTORY]: Loading iar file {0}", iarFileName);
            InventoryFolderBase rootFolder = m_MockScene.InventoryService.GetRootFolder(uinfo.PrincipalID);

            if (null == rootFolder)
            {
                //We need to create the root folder, otherwise the IAR freaks
                m_MockScene.InventoryService.CreateUserInventory(uinfo.PrincipalID);
            }

            InventoryArchiveReadRequest archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, "/", iarFileName, false);

            try
            {
                List<InventoryNodeBase> nodes = new List<InventoryNodeBase>(archread.Execute(true));
                if (nodes.Count == 0)
                    return;
                InventoryFolderImpl f = new InventoryFolderImpl((InventoryFolderBase)nodes[0]);

                TraverseFolders(f, nodes[0].ID, m_MockScene);
                //This is our loaded folder
                //Fix the name for later
                f.Name = iarFileName;
                f.ParentID = UUID.Zero;
                bool update = m_MockScene.InventoryService.UpdateFolder(f);
                m_service.AddToDefaultInventory(f);
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[LIBRARY MODULE]: Exception when processing archive {0}: {1}", iarFileName, e.StackTrace);
            }
            finally
            {
                archread.Close();
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Create a scene and its initial base structures.
        /// </summary>
        /// <param name="regionInfo"></param>
        /// <param name="proxyOffset"></param>
        /// <param name="configSource"></param>
        /// <param name="clientServer"> </param>
        /// <returns></returns>
        protected Scene SetupScene(RegionInfo regionInfo, IConfigSource configSource)
        {
            AgentCircuitManager circuitManager = new AgentCircuitManager();
            IPAddress listenIP = regionInfo.InternalEndPoint.Address;
            if (!IPAddress.TryParse(regionInfo.InternalEndPoint.Address.ToString(), out listenIP))
                listenIP = IPAddress.Parse("0.0.0.0");

            uint port = (uint)regionInfo.InternalEndPoint.Port;

            string ClientstackDll = m_config.Configs["Startup"].GetString("ClientStackPlugin", "OpenSim.Region.ClientStack.LindenUDP.dll");

            IClientNetworkServer clientServer = AuroraModuleLoader.LoadPlugin<IClientNetworkServer> (Util.BasePathCombine(ClientstackDll));
            clientServer.Initialise(
                    listenIP, ref port, 0, regionInfo.m_allow_alternate_ports,
                    m_config, circuitManager);

            regionInfo.InternalEndPoint.Port = (int)port;

            Scene scene = new Scene ();
            scene.AddModuleInterfaces (m_OpenSimBase.ApplicationRegistry.GetInterfaces ());
            scene.Initialize (regionInfo, circuitManager, clientServer);

            StartModules(scene);

            m_clientServers.Add(clientServer);

            //Do this here so that we don't have issues later when startup complete messages start coming in
            m_localScenes.Add(scene);

            return scene;
        }
        public void FinishedStartup()
        {
            m_log.InfoFormat("[DefaultInventoryToIARConverter]: start");

            string IARName = "DefaultInventory.iar";
            IniConfigSource iniSource = null;
            try
            {
                iniSource = new IniConfigSource("DefaultInventory/Inventory.ini", Nini.Ini.IniFileType.AuroraStyle);
            }
            catch
            {
            }
            IConfig libConfig = m_config.Configs["DefaultAssetsIARCreator"];
            if (libConfig == null)
                libConfig = iniSource.Configs["DefaultAssetsIARCreator"];
            if (libConfig != null)
            {
                if (!libConfig.GetBoolean("Enabled", false))
                    return;
                IARName = libConfig.GetString("NameOfIAR", IARName);
            }
            else
                return;
            m_service = m_registry.RequestModuleInterface<ILibraryService>();

            RegionInfo regInfo = new RegionInfo();
            IScene m_MockScene = null;
            //Make the scene for the IAR loader
            if (m_registry is IScene)
                m_MockScene = (IScene)m_registry;
            else
            {
                m_MockScene = new Scene();
                m_MockScene.Initialize(regInfo);
                m_MockScene.AddModuleInterfaces(m_registry.GetInterfaces());
            }

            m_log.InfoFormat("[DefaultInventoryToIARConverter]: 1");
            UserAccount uinfo = m_MockScene.UserAccountService.GetUserAccount(null, m_service.LibraryOwner);
            //Make the user account for the default IAR
            if (uinfo == null)
            {
                uinfo = new UserAccount(m_service.LibraryOwner);
                uinfo.Name = m_service.LibraryOwnerName;
                //m_MockScene.InventoryService.CreateUserInventory(m_service.LibraryOwner, false);
                m_log.InfoFormat("[DefaultInventoryToIARConverter]: 1,1");
                m_Database = DataManager.RequestPlugin<IInventoryData>();
                m_log.InfoFormat("[DefaultInventoryToIARConverter]: 1,2");
                if(m_Database == null) m_log.InfoFormat("[DefaultInventoryToIARConverter]: m_Database == null");
                InventoryFolderBase newFolder = new InventoryFolderBase
                                                    {
                                                    Name = "My Inventory",
                                                    Type = 9,
                                                    Version = 1,
                                                    ID = new UUID("00000112-000f-0000-0000-000100bba000"),
                                                    Owner = m_service.LibraryOwner,
                                                    ParentID = UUID.Zero
                                                    };
                m_log.InfoFormat("[DefaultInventoryToIARConverter]: 1,3");
            m_Database.StoreFolder(newFolder);
            m_log.InfoFormat("[DefaultInventoryToIARConverter]: 1,4");
            }
            m_log.InfoFormat("[DefaultInventoryToIARConverter]: 2");

            List<AssetBase> assets = new List<AssetBase> ();
            if (m_MockScene.InventoryService != null)
            {
                //Add the folders to the user's inventory
                InventoryCollection i = m_MockScene.InventoryService.GetFolderContent (m_service.LibraryOwner, UUID.Zero);
                if (i != null)
                {
                    foreach (InventoryItemBase item in i.Items)
                    {

                        AssetBase asset = m_MockScene.RequestModuleInterface<IAssetService> ().Get (item.AssetID.ToString ());
                        if (asset != null)
                        {
                            assets.Add (asset);
                            m_log.InfoFormat("[DefaultInventoryToIARConverter]: added asset");
                            }
                    }
                }
                else m_log.InfoFormat("[DefaultInventoryToIARConverter]: i == null");
            }

            m_log.InfoFormat("[DefaultInventoryToIARConverter]: 3");

            InventoryFolderBase rootFolder = null;
            List<InventoryFolderBase> rootFolders = m_MockScene.InventoryService.GetRootFolders (m_service.LibraryOwner);
            foreach (InventoryFolderBase folder in rootFolders)
            {
            m_log.InfoFormat("folder name {0}", folder.Name);
                //if (folder.Name == "My Inventory")
                //    continue;

                rootFolder = folder;
                break;
            }

            m_log.InfoFormat("[DefaultInventoryToIARConverter]: 4");

            if (rootFolder != null)
            {
                //Save the IAR of the default assets
                InventoryArchiveWriteRequest write = new InventoryArchiveWriteRequest (Guid.NewGuid (), null, m_MockScene,
                    uinfo, "/", new GZipStream (new FileStream (IARName, FileMode.Create), CompressionMode.Compress), true, rootFolder, assets);
                write.Execute ();
            }
            else {
            m_log.InfoFormat("[DefaultInventoryToIARConverter]: rootFolder == null");
            }

            m_log.InfoFormat("[DefaultInventoryToIARConverter]: end");
        }
Exemplo n.º 10
0
        public void LoadFromFile()
        {
            GZipStream m_loadStream = new GZipStream(ArchiveHelpers.GetStream(m_fileName), CompressionMode.Decompress);
            TarArchiveReader reader = new TarArchiveReader(m_loadStream);

            byte[] data;
            string filePath;
            TarArchiveReader.TarEntryType entryType;

            #region Our Region Info

            IParcelServiceConnector parcelService = Aurora.DataManager.DataManager.RequestPlugin<IParcelServiceConnector>();

            SceneManager sceneManager = m_simulationBase.ApplicationRegistry.RequestModuleInterface<SceneManager>();
            RegionInfo regionInfo = new RegionInfo();
            IScene fakeScene = new Scene();
            fakeScene.AddModuleInterfaces(m_simulationBase.ApplicationRegistry.GetInterfaces());

            #endregion

            while ((data = reader.ReadEntry(out filePath, out entryType)) != null)
            {
                if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType)
                    continue;

                if (filePath.StartsWith("estate/"))
                {
                    string estateData = Encoding.UTF8.GetString(data);
                    EstateSettings settings = new EstateSettings(WebUtils.ParseXmlResponse(estateData));
                    regionInfo.EstateSettings = settings;
                }
                else if (filePath.StartsWith("regioninfo/"))
                {
                    regionInfo.UnpackRegionInfoData((OSDMap)OSDParser.DeserializeLLSDBinary(data));
                }
            }

            if (!m_useExistingRegionInfo)
            {
                regionInfo.RegionID = UUID.Random();
                regionInfo.RegionName = MainConsole.Instance.Prompt("Region Name: ", regionInfo.RegionName);
                regionInfo.RegionLocX = int.Parse(MainConsole.Instance.Prompt("Region Position X: ", regionInfo.RegionLocX.ToString()));
                regionInfo.RegionLocY = int.Parse(MainConsole.Instance.Prompt("Region Position Y: ", regionInfo.RegionLocY.ToString()));
                regionInfo.InternalEndPoint.Port = int.Parse(MainConsole.Instance.Prompt("HTTP Port: ", regionInfo.InternalEndPoint.Port.ToString()));
            }

            //ISimulationDataStore simulationStore = sceneManager.SimulationDataService;
            //Hijack the old simulation service and replace it with ours
            sceneManager.SimulationDataService = new OverridenFileBasedSimulationData (m_fileName, m_saveNewArchiveAtClose);

            ///Now load the region!
            sceneManager.AllRegions++;
            sceneManager.StartNewRegion (regionInfo);
        }
        public void Start(IConfigSource config, IRegistryCore registry)
        {
            string IARName = "DefaultInventory.iar";
            IniConfigSource iniSource = null;
            try
            {
                iniSource = new IniConfigSource("DefaultInventory/Inventory.ini", Nini.Ini.IniFileType.AuroraStyle);
            }
            catch
            {
            }
            IConfig libConfig = config.Configs["DefaultAssetsIARCreator"];
            if (libConfig == null)
                libConfig = iniSource.Configs["DefaultAssetsIARCreator"];
            if (libConfig != null)
            {
                if (!libConfig.GetBoolean("Enabled", false))
                    return;
                IARName = libConfig.GetString("NameOfIAR", IARName);
            }
            else
                return;
            m_service = registry.RequestModuleInterface<ILibraryService>();

            RegionInfo regInfo = new RegionInfo();
            IScene m_MockScene = null;
            //Make the scene for the IAR loader
            if (registry is IScene)
                m_MockScene = (IScene)registry;
            else
            {
                m_MockScene = new Scene();
                m_MockScene.Initialize(regInfo);
                m_MockScene.AddModuleInterfaces(registry.GetInterfaces());
            }

            UserAccount uinfo = m_MockScene.UserAccountService.GetUserAccount(UUID.Zero, m_service.LibraryOwner);
            //Make the user account for the default IAR
            if (uinfo == null)
            {
                uinfo = new UserAccount(m_service.LibraryOwner);
                uinfo.Name = m_service.LibraryOwnerName;
                m_MockScene.InventoryService.CreateUserInventory(m_service.LibraryOwner, false);
            }

            List<AssetBase> assets = new List<AssetBase> ();
            if (m_MockScene.InventoryService != null)
            {
                //Add the folders to the user's inventory
                InventoryCollection i = m_MockScene.InventoryService.GetFolderContent (m_service.LibraryOwner, UUID.Zero);
                if (i != null)
                {
                    foreach (InventoryItemBase item in i.Items)
                    {
                        AssetBase asset = m_MockScene.RequestModuleInterface<IAssetService> ().Get (item.AssetID.ToString ());
                        if (asset != null)
                            assets.Add (asset);
                    }
                }
            }
            InventoryFolderBase rootFolder = null;
            List<InventoryFolderBase> rootFolders = m_MockScene.InventoryService.GetRootFolders (m_service.LibraryOwner);
            foreach (InventoryFolderBase folder in rootFolders)
            {
                if (folder.Name == "My Inventory")
                    continue;

                rootFolder = folder;
                break;
            }
            if (rootFolder != null)
            {
                //Save the IAR of the default assets
                InventoryArchiveWriteRequest write = new InventoryArchiveWriteRequest (Guid.NewGuid (), null, m_MockScene,
                    uinfo, "/", new GZipStream (new FileStream (IARName, FileMode.Create), CompressionMode.Compress), true, rootFolder, assets);
                write.Execute ();
            }
        }