diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/Autooar')
-rw-r--r-- | OpenSim/Region/OptionalModules/Autooar/AutooarModule.cs | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/Autooar/AutooarModule.cs b/OpenSim/Region/OptionalModules/Autooar/AutooarModule.cs new file mode 100644 index 0000000..6c10928 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Autooar/AutooarModule.cs | |||
@@ -0,0 +1,72 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.IO; | ||
4 | using System.Text; | ||
5 | using System.Timers; | ||
6 | using Nini.Config; | ||
7 | using OpenSim.Region.Framework.Interfaces; | ||
8 | using OpenSim.Region.Framework.Scenes; | ||
9 | |||
10 | namespace OpenSim.Region.OptionalModules.Autooar | ||
11 | { | ||
12 | public class AutooarModule : IRegionModule | ||
13 | { | ||
14 | private readonly Timer m_timer = new Timer(60000*20); | ||
15 | private readonly List<Scene> m_scenes = new List<Scene>(); | ||
16 | private IConfigSource config; | ||
17 | private bool m_enabled = false; | ||
18 | |||
19 | |||
20 | public void Initialise(Scene scene, IConfigSource source) | ||
21 | { | ||
22 | m_scenes.Add(scene); | ||
23 | config = source; | ||
24 | } | ||
25 | |||
26 | public void PostInitialise() | ||
27 | { | ||
28 | if(config.Configs["autooar"] != null) | ||
29 | { | ||
30 | m_enabled = config.Configs["autooar"].GetBoolean("Enabled", m_enabled); | ||
31 | } | ||
32 | |||
33 | if(m_enabled) | ||
34 | { | ||
35 | m_timer.Elapsed += m_timer_Elapsed; | ||
36 | m_timer.AutoReset = true; | ||
37 | m_timer.Start(); | ||
38 | } | ||
39 | } | ||
40 | |||
41 | void m_timer_Elapsed(object sender, ElapsedEventArgs e) | ||
42 | { | ||
43 | if (!Directory.Exists("autooars")) | ||
44 | Directory.CreateDirectory("autooars"); | ||
45 | |||
46 | foreach (Scene scene in m_scenes) | ||
47 | { | ||
48 | IRegionArchiverModule archiver = scene.RequestModuleInterface<IRegionArchiverModule>(); | ||
49 | |||
50 | archiver.ArchiveRegion(Path.Combine("autooars", | ||
51 | scene.RegionInfo.RegionName + "_" + scene.RegionInfo.RegionLocX + | ||
52 | "x" + scene.RegionInfo.RegionLocY + ".oar.tar.gz")); | ||
53 | } | ||
54 | } | ||
55 | |||
56 | public void Close() | ||
57 | { | ||
58 | if (m_timer.Enabled) | ||
59 | m_timer.Stop(); | ||
60 | } | ||
61 | |||
62 | public string Name | ||
63 | { | ||
64 | get { return "Automatic OAR Module"; } | ||
65 | } | ||
66 | |||
67 | public bool IsSharedModule | ||
68 | { | ||
69 | get { return true; } | ||
70 | } | ||
71 | } | ||
72 | } | ||