28 using System.Collections.Generic;
30 using System.Reflection;
32 using OpenSim.Framework;
34 using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
35 using OpenSim.Region.Framework;
36 using OpenSim.Region.Framework.Interfaces;
37 using OpenSim.Region.Framework.Scenes;
38 using OpenSim.Services.Interfaces;
39 using OpenSim.Server.Base;
49 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"LibraryModule")]
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53 private static bool m_HasRunOnce =
false;
55 private bool m_Enabled =
false;
57 private Scene m_Scene;
61 #region ISharedRegionModule
65 m_Enabled = config.Configs[
"Modules"].GetBoolean(
"LibraryModule", m_Enabled);
68 IConfig libConfig = config.Configs[
"LibraryService"];
69 if (libConfig != null)
71 string dllName = libConfig.GetString(
"LocalServiceModule", string.Empty);
72 m_log.Debug(
"[LIBRARY MODULE]: Library service dll is " + dllName);
73 if (dllName !=
string.Empty)
80 if (m_Library == null)
82 m_log.Warn(
"[LIBRARY MODULE]: No local library service. Module will be disabled.");
87 public bool IsSharedModule
94 get {
return "Library Module"; }
97 public Type ReplaceableInterface
131 LoadLibrariesFromArchives();
146 #endregion ISharedRegionModule
148 #region LoadLibraries
149 private string pathToLibraries =
"Library";
156 m_log.Debug(
"[LIBRARY MODULE]: No library. Ignoring Library Module");
164 m_MockScene.RegisterModuleInterface<
IAssetService>(m_Scene.AssetService);
167 uinfo.FirstName =
"OpenSim";
168 uinfo.LastName =
"Library";
169 uinfo.ServiceURLs =
new Dictionary<string, object>();
171 foreach (
string iarFileName
in Directory.GetFiles(pathToLibraries,
"*.iar"))
173 string simpleName = Path.GetFileNameWithoutExtension(iarFileName);
175 m_log.InfoFormat(
"[LIBRARY MODULE]: Loading library archive {0} ({1})...", iarFileName, simpleName);
176 simpleName = GetInventoryPathFromName(simpleName);
181 HashSet<InventoryNodeBase> nodes = archread.Execute();
182 if (nodes != null && nodes.Count == 0)
185 m_log.InfoFormat(
"[LIBRARY MODULE]: Didn't find {0} in library. Placing archive on the top level", simpleName);
187 archread =
new InventoryArchiveReadRequest(m_MockScene.InventoryService, m_MockScene.AssetService, m_MockScene.UserAccountService, uinfo,
"/", iarFileName,
false);
196 m_log.DebugFormat(
"[LIBRARY MODULE]: Exception when processing archive {0}: {1}", iarFileName, e.StackTrace);
207 m_log.DebugFormat(
"[LIBRARY MODULE]: Fixing perms for {0} {1}", node.Name, node.ID);
211 InventoryItemBase item = (InventoryItemBase)node;
239 m_log.DebugFormat(
" --> item {0}", item.Name);
243 m_log.DebugFormat(
" - folder {0}", f.Name);
248 private string GetInventoryPathFromName(
string name)
250 string[] parts = name.Split(
new char[] {
' ' });
251 if (parts.Length == 3)
255 for (
int i = 0; i < parts.Length - 1; i++)
256 name = name +
' ' + parts[i];
262 #endregion LoadLibraries
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
void LoadLibrariesFromArchives()
List< InventoryFolderImpl > RequestListOfFolderImpls()
OpenSim.Framework.RegionInfo RegionInfo
void PostInitialise()
This is called exactly once after all the shared region-modules have been instanciated and IRegionMod...
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
Dictionary< UUID, InventoryItemBase > Items
Items that are contained in this folder
virtual UUID Owner
The agent who's inventory this is contained by
void Initialise(IConfigSource config)
This is called to initialize the region module. For shared modules, this is called exactly once...
Inventory Item - contains all the properties associated with an individual inventory piece...
OpenSim.Framework.PermissionMask PermissionMask
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
Interactive OpenSim region server
Common base class for inventory nodes of different types (files, folders, etc.)
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...