aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs97
-rw-r--r--OpenSim/Region/Environment/Modules/ExportSerialiser/IFileSerialiser.cs4
-rw-r--r--OpenSim/Region/Environment/Modules/ExportSerialiser/IRegionSerialiser.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseObjects.cs41
-rw-r--r--OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseTerrain.cs4
-rw-r--r--OpenSim/Region/Environment/Modules/ModuleFramework/Commander.cs58
-rw-r--r--OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs141
7 files changed, 184 insertions, 163 deletions
diff --git a/OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs b/OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs
index f811f22..91770af 100644
--- a/OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs
+++ b/OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs
@@ -37,10 +37,54 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
37{ 37{
38 public class ExportSerialisationModule : IRegionModule, IRegionSerialiser 38 public class ExportSerialisationModule : IRegionModule, IRegionSerialiser
39 { 39 {
40 private List<Scene> m_regions = new List<Scene>();
41 private List<IFileSerialiser> m_serialisers = new List<IFileSerialiser>();
42 private Commander m_commander = new Commander("Export"); 40 private Commander m_commander = new Commander("Export");
41 private List<Scene> m_regions = new List<Scene>();
43 private string m_savedir = "exports" + "/"; 42 private string m_savedir = "exports" + "/";
43 private List<IFileSerialiser> m_serialisers = new List<IFileSerialiser>();
44
45 #region IRegionModule Members
46
47 public void Initialise(Scene scene, IConfigSource source)
48 {
49 scene.RegisterModuleCommander("Export", m_commander);
50 scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
51 scene.RegisterModuleInterface<IRegionSerialiser>(this);
52
53 lock (m_regions)
54 {
55 m_regions.Add(scene);
56 }
57 }
58
59 public void PostInitialise()
60 {
61 lock (m_serialisers)
62 {
63 m_serialisers.Add(new SerialiseTerrain());
64 m_serialisers.Add(new SerialiseObjects());
65 }
66
67 LoadCommanderCommands();
68 }
69
70 public void Close()
71 {
72 m_regions.Clear();
73 }
74
75 public string Name
76 {
77 get { return "ExportSerialisationModule"; }
78 }
79
80 public bool IsSharedModule
81 {
82 get { return true; }
83 }
84
85 #endregion
86
87 #region IRegionSerialiser Members
44 88
45 public List<string> SerialiseRegion(Scene scene, string saveDir) 89 public List<string> SerialiseRegion(Scene scene, string saveDir)
46 { 90 {
@@ -76,22 +120,9 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
76 return results; 120 return results;
77 } 121 }
78 122
123 #endregion
79 124
80 #region IRegionModule Members 125 private void EventManager_OnPluginConsole(string[] args)
81
82 public void Initialise(Scene scene, IConfigSource source)
83 {
84 scene.RegisterModuleCommander("Export", m_commander);
85 scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
86 scene.RegisterModuleInterface<IRegionSerialiser>(this);
87
88 lock (m_regions)
89 {
90 m_regions.Add(scene);
91 }
92 }
93
94 void EventManager_OnPluginConsole(string[] args)
95 { 126 {
96 if (args[0] == "export") 127 if (args[0] == "export")
97 { 128 {
@@ -108,7 +139,7 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
108 { 139 {
109 foreach (Scene region in m_regions) 140 foreach (Scene region in m_regions)
110 { 141 {
111 if (region.RegionInfo.RegionName == (string)args[0]) 142 if (region.RegionInfo.RegionName == (string) args[0])
112 { 143 {
113 List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/"); 144 List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/");
114 } 145 }
@@ -133,33 +164,5 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
133 m_commander.RegisterCommand("save", serialiseSceneCommand); 164 m_commander.RegisterCommand("save", serialiseSceneCommand);
134 m_commander.RegisterCommand("save-all", serialiseAllScenesCommand); 165 m_commander.RegisterCommand("save-all", serialiseAllScenesCommand);
135 } 166 }
136
137 public void PostInitialise()
138 {
139 lock (m_serialisers)
140 {
141 m_serialisers.Add(new SerialiseTerrain());
142 m_serialisers.Add(new SerialiseObjects());
143 }
144
145 LoadCommanderCommands();
146 }
147
148 public void Close()
149 {
150 m_regions.Clear();
151 }
152
153 public string Name
154 {
155 get { return "ExportSerialisationModule"; }
156 }
157
158 public bool IsSharedModule
159 {
160 get { return true; }
161 }
162
163 #endregion
164 } 167 }
165} 168} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/ExportSerialiser/IFileSerialiser.cs b/OpenSim/Region/Environment/Modules/ExportSerialiser/IFileSerialiser.cs
index 8cd97a8..77a418f 100644
--- a/OpenSim/Region/Environment/Modules/ExportSerialiser/IFileSerialiser.cs
+++ b/OpenSim/Region/Environment/Modules/ExportSerialiser/IFileSerialiser.cs
@@ -29,8 +29,8 @@ using OpenSim.Region.Environment.Scenes;
29 29
30namespace OpenSim.Region.Environment.Modules.ExportSerialiser 30namespace OpenSim.Region.Environment.Modules.ExportSerialiser
31{ 31{
32 interface IFileSerialiser 32 internal interface IFileSerialiser
33 { 33 {
34 string WriteToFile(Scene scene, string dir); 34 string WriteToFile(Scene scene, string dir);
35 } 35 }
36} 36} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/ExportSerialiser/IRegionSerialiser.cs b/OpenSim/Region/Environment/Modules/ExportSerialiser/IRegionSerialiser.cs
index 5b10957..e1721ff 100644
--- a/OpenSim/Region/Environment/Modules/ExportSerialiser/IRegionSerialiser.cs
+++ b/OpenSim/Region/Environment/Modules/ExportSerialiser/IRegionSerialiser.cs
@@ -34,4 +34,4 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
34 { 34 {
35 List<string> SerialiseRegion(Scene scene, string saveDir); 35 List<string> SerialiseRegion(Scene scene, string saveDir);
36 } 36 }
37} 37} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseObjects.cs b/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseObjects.cs
index ac80f40..7e5cf47 100644
--- a/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseObjects.cs
+++ b/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseObjects.cs
@@ -27,20 +27,30 @@
27 27
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.IO; 29using System.IO;
30using System.IO.Compression;
30using System.Text; 31using System.Text;
31using System.Xml; 32using System.Xml;
32using OpenSim.Region.Environment.Scenes; 33using OpenSim.Region.Environment.Scenes;
33 34
34namespace OpenSim.Region.Environment.Modules.ExportSerialiser 35namespace OpenSim.Region.Environment.Modules.ExportSerialiser
35{ 36{
36 class SerialiseObjects : IFileSerialiser 37 internal class SerialiseObjects : IFileSerialiser
37 { 38 {
38 #region IFileSerialiser Members 39 #region IFileSerialiser Members
39 40
41 public string WriteToFile(Scene scene, string dir)
42 {
43 string targetFileName = dir + "objects.xml";
44
45 SaveSerialisedToFile(targetFileName, scene);
46
47 return "objects.xml";
48 }
49
50 #endregion
40 51
41 public void SaveSerialisedToFile(string fileName, Scene scene) 52 public void SaveSerialisedToFile(string fileName, Scene scene)
42 { 53 {
43 int primCount = 0;
44 string xmlstream = "<scene>"; 54 string xmlstream = "<scene>";
45 55
46 List<EntityBase> EntityList = scene.GetEntities(); 56 List<EntityBase> EntityList = scene.GetEntities();
@@ -50,8 +60,7 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
50 { 60 {
51 if (ent is SceneObjectGroup) 61 if (ent is SceneObjectGroup)
52 { 62 {
53 EntityXml.Add(((SceneObjectGroup)ent).ToXmlString2()); 63 EntityXml.Add(((SceneObjectGroup) ent).ToXmlString2());
54 primCount++;
55 } 64 }
56 } 65 }
57 EntityXml.Sort(); 66 EntityXml.Sort();
@@ -69,26 +78,24 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
69 formatter.Formatting = Formatting.Indented; 78 formatter.Formatting = Formatting.Indented;
70 doc.WriteContentTo(formatter); 79 doc.WriteContentTo(formatter);
71 formatter.Flush(); 80 formatter.Flush();
72 StreamReader reader = new StreamReader(stream);
73 81
74 stream.Seek(0, SeekOrigin.Begin); 82 stream.Seek(0, SeekOrigin.Begin);
75 83
76 FileStream objectsFile = new FileStream(fileName, FileMode.Create); 84 FileStream objectsFile = new FileStream(fileName, FileMode.Create);
85
77 stream.WriteTo(objectsFile); 86 stream.WriteTo(objectsFile);
78 objectsFile.Flush(); 87 objectsFile.Flush();
79 objectsFile.Close(); 88 objectsFile.Close();
80 89
90 #region GZip Compressed Version
91 FileStream objectsFileCompressed = new FileStream(fileName + ".gzs", FileMode.Create);
92 MemoryStream gzipMSStream = new MemoryStream();
93 GZipStream gzipStream = new GZipStream(gzipMSStream, CompressionMode.Compress);
94 stream.WriteTo(gzipStream);
95 gzipMSStream.WriteTo(objectsFileCompressed);
96 objectsFileCompressed.Flush();
97 objectsFileCompressed.Close();
98 #endregion
81 } 99 }
82
83 public string WriteToFile(Scene scene, string dir)
84 {
85 string targetFileName = dir + "objects.xml";
86
87 SaveSerialisedToFile(targetFileName, scene);
88
89 return "objects.xml";
90 }
91
92 #endregion
93 } 100 }
94} 101} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseTerrain.cs b/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseTerrain.cs
index 8555089..c4790c2 100644
--- a/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseTerrain.cs
+++ b/OpenSim/Region/Environment/Modules/ExportSerialiser/SerialiseTerrain.cs
@@ -31,7 +31,7 @@ using OpenSim.Region.Environment.Scenes;
31 31
32namespace OpenSim.Region.Environment.Modules.ExportSerialiser 32namespace OpenSim.Region.Environment.Modules.ExportSerialiser
33{ 33{
34 class SerialiseTerrain : IFileSerialiser 34 internal class SerialiseTerrain : IFileSerialiser
35 { 35 {
36 #region IFileSerialiser Members 36 #region IFileSerialiser Members
37 37
@@ -50,4 +50,4 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
50 50
51 #endregion 51 #endregion
52 } 52 }
53} 53} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/ModuleFramework/Commander.cs b/OpenSim/Region/Environment/Modules/ModuleFramework/Commander.cs
index 27d73b5..7ef087d 100644
--- a/OpenSim/Region/Environment/Modules/ModuleFramework/Commander.cs
+++ b/OpenSim/Region/Environment/Modules/ModuleFramework/Commander.cs
@@ -42,11 +42,11 @@ namespace OpenSim.Region.Environment.Modules.ModuleFramework
42 public class Command : ICommand 42 public class Command : ICommand
43 { 43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 private List<CommandArgument> m_args = new List<CommandArgument>();
45 46
46 private Action<object[]> m_command; 47 private Action<object[]> m_command;
47 private string m_name;
48 private string m_help; 48 private string m_help;
49 private List<CommandArgument> m_args = new List<CommandArgument>(); 49 private string m_name;
50 50
51 public Command(string name, Action<Object[]> command, string help) 51 public Command(string name, Action<Object[]> command, string help)
52 { 52 {
@@ -55,6 +55,8 @@ namespace OpenSim.Region.Environment.Modules.ModuleFramework
55 m_help = help; 55 m_help = help;
56 } 56 }
57 57
58 #region ICommand Members
59
58 public void AddArgument(string name, string helptext, string type) 60 public void AddArgument(string name, string helptext, string type)
59 { 61 {
60 m_args.Add(new CommandArgument(name, helptext, type)); 62 m_args.Add(new CommandArgument(name, helptext, type));
@@ -143,8 +145,8 @@ namespace OpenSim.Region.Environment.Modules.ModuleFramework
143 catch (FormatException) 145 catch (FormatException)
144 { 146 {
145 m_log.Error("Argument number " + (i + 1) + 147 m_log.Error("Argument number " + (i + 1) +
146 " (" + m_args[i].Name + ") must be a valid " + 148 " (" + m_args[i].Name + ") must be a valid " +
147 m_args[i].ArgumentType.ToLower() + "."); 149 m_args[i].ArgumentType.ToLower() + ".");
148 } 150 }
149 cleanArgs[i] = m_args[i].ArgumentValue; 151 cleanArgs[i] = m_args[i].ArgumentValue;
150 152
@@ -153,6 +155,8 @@ namespace OpenSim.Region.Environment.Modules.ModuleFramework
153 155
154 m_command.Invoke(cleanArgs); 156 m_command.Invoke(cleanArgs);
155 } 157 }
158
159 #endregion
156 } 160 }
157 161
158 /// <summary> 162 /// <summary>
@@ -160,8 +164,8 @@ namespace OpenSim.Region.Environment.Modules.ModuleFramework
160 /// </summary> 164 /// </summary>
161 public class CommandArgument 165 public class CommandArgument
162 { 166 {
163 private string m_name;
164 private string m_help; 167 private string m_help;
168 private string m_name;
165 private string m_type; 169 private string m_type;
166 private Object m_val; 170 private Object m_val;
167 171
@@ -208,29 +212,13 @@ namespace OpenSim.Region.Environment.Modules.ModuleFramework
208 m_name = name; 212 m_name = name;
209 } 213 }
210 214
215 #region ICommander Members
216
211 public void RegisterCommand(string commandName, ICommand command) 217 public void RegisterCommand(string commandName, ICommand command)
212 { 218 {
213 m_commands[commandName] = command; 219 m_commands[commandName] = command;
214 } 220 }
215 221
216 void ShowConsoleHelp()
217 {
218 m_log.Info("===" + m_name + "===");
219 foreach (ICommand com in m_commands.Values)
220 {
221 m_log.Info("* " + com.Name + " - " + com.Help);
222 }
223 }
224
225 string EscapeRuntimeAPICommand(string command)
226 {
227 command = command.Replace('-', '_');
228 StringBuilder tmp = new StringBuilder(command);
229 tmp[0] = tmp[0].ToString().ToUpper().ToCharArray()[0];
230
231 return tmp.ToString();
232 }
233
234 /// <summary> 222 /// <summary>
235 /// Generates a runtime C# class which can be compiled and inserted via reflection to enable modules to register new script commands 223 /// Generates a runtime C# class which can be compiled and inserted via reflection to enable modules to register new script commands
236 /// </summary> 224 /// </summary>
@@ -253,7 +241,7 @@ namespace OpenSim.Region.Environment.Modules.ModuleFramework
253 { 241 {
254 classSrc += "\t\targs[" + i.ToString() + "] = " + Util.Md5Hash(arg.Key) + " " + ";\n"; 242 classSrc += "\t\targs[" + i.ToString() + "] = " + Util.Md5Hash(arg.Key) + " " + ";\n";
255 i++; 243 i++;
256 } 244 }
257 classSrc += "\t\tGetCommander(\"" + m_name + "\").Run(\"" + com.Name + "\", args);\n"; 245 classSrc += "\t\tGetCommander(\"" + m_name + "\").Run(\"" + com.Name + "\", args);\n";
258 classSrc += "\t}\n"; 246 classSrc += "\t}\n";
259 } 247 }
@@ -296,5 +284,25 @@ namespace OpenSim.Region.Environment.Modules.ModuleFramework
296 ShowConsoleHelp(); 284 ShowConsoleHelp();
297 } 285 }
298 } 286 }
287
288 #endregion
289
290 private void ShowConsoleHelp()
291 {
292 m_log.Info("===" + m_name + "===");
293 foreach (ICommand com in m_commands.Values)
294 {
295 m_log.Info("* " + com.Name + " - " + com.Help);
296 }
297 }
298
299 private string EscapeRuntimeAPICommand(string command)
300 {
301 command = command.Replace('-', '_');
302 StringBuilder tmp = new StringBuilder(command);
303 tmp[0] = tmp[0].ToString().ToUpper().ToCharArray()[0];
304
305 return tmp.ToString();
306 }
299 } 307 }
300} 308} \ No newline at end of file
diff --git a/OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs b/OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs
index 4046a7c..d932c55 100644
--- a/OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs
+++ b/OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs
@@ -18,22 +18,21 @@ namespace OpenSim.Region.Modules.SvnSerialiser
18 public class SvnBackupModule : IRegionModule 18 public class SvnBackupModule : IRegionModule
19 { 19 {
20 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 20 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
21 21
22 private SvnClient m_svnClient;
23 private bool m_enabled = false; 22 private bool m_enabled = false;
24 private bool m_installBackupOnLoad = false; 23 private bool m_installBackupOnLoad = false;
25 private string m_svnurl = "svn://insert.your.svn/here/"; 24 private List<Scene> m_scenes = new List<Scene>();
26 private string m_svnuser = "username"; 25 private IRegionSerialiser m_serialiser;
27 private string m_svnpass = "password"; 26 private bool m_svnAutoSave = false;
27 private SvnClient m_svnClient;
28 private string m_svndir = "SVNmodule\\repo"; 28 private string m_svndir = "SVNmodule\\repo";
29 private string m_svnpass = "password";
29 30
30 private TimeSpan m_svnperiod = new TimeSpan(0, 0, 15, 0, 0); 31 private TimeSpan m_svnperiod = new TimeSpan(0, 0, 15, 0, 0);
31 private bool m_svnAutoSave = false; 32 private string m_svnurl = "svn://insert.your.svn/here/";
33 private string m_svnuser = "username";
32 private Timer m_timer = new Timer(); 34 private Timer m_timer = new Timer();
33 35
34 private IRegionSerialiser m_serialiser;
35 private List<Scene> m_scenes = new List<Scene>();
36
37 #region SvnModule Core 36 #region SvnModule Core
38 37
39 /// <summary> 38 /// <summary>
@@ -76,7 +75,9 @@ namespace OpenSim.Region.Modules.SvnSerialiser
76 { 75 {
77 m_svnClient.Add3(m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID.ToString(), true, false, false); 76 m_svnClient.Add3(m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID.ToString(), true, false, false);
78 } 77 }
79 catch (SvnException) { } 78 catch (SvnException)
79 {
80 }
80 81
81 List<string> svnfilenames = new List<string>(); 82 List<string> svnfilenames = new List<string>();
82 foreach (string filename in filenames) 83 foreach (string filename in filenames)
@@ -88,10 +89,10 @@ namespace OpenSim.Region.Modules.SvnSerialiser
88 89
89 public void LoadRegion(Scene scene) 90 public void LoadRegion(Scene scene)
90 { 91 {
91 scene.LoadPrimsFromXml2(m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID.ToString() + 92 scene.LoadPrimsFromXml2(m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID.ToString() +
92 Slash.DirectorySeparatorChar + "objects.xml"); 93 Slash.DirectorySeparatorChar + "objects.xml");
93 scene.RequestModuleInterface<ITerrainModule>().LoadFromFile(m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID.ToString() + 94 scene.RequestModuleInterface<ITerrainModule>().LoadFromFile(m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID.ToString() +
94 Slash.DirectorySeparatorChar + "heightmap.r32"); 95 Slash.DirectorySeparatorChar + "heightmap.r32");
95 m_log.Info("[SVNBACKUP]: Region load successful (" + scene.RegionInfo.RegionName + ")."); 96 m_log.Info("[SVNBACKUP]: Region load successful (" + scene.RegionInfo.RegionName + ").");
96 } 97 }
97 98
@@ -126,7 +127,7 @@ namespace OpenSim.Region.Modules.SvnSerialiser
126 #region SvnDotNet Callbacks 127 #region SvnDotNet Callbacks
127 128
128 private SvnError SimpleAuth(out SvnAuthCredSimple svnCredentials, IntPtr baton, 129 private SvnError SimpleAuth(out SvnAuthCredSimple svnCredentials, IntPtr baton,
129 AprString realm, AprString username, bool maySave, AprPool pool) 130 AprString realm, AprString username, bool maySave, AprPool pool)
130 { 131 {
131 svnCredentials = SvnAuthCredSimple.Alloc(pool); 132 svnCredentials = SvnAuthCredSimple.Alloc(pool);
132 svnCredentials.Username = new AprString(m_svnuser, pool); 133 svnCredentials.Username = new AprString(m_svnuser, pool);
@@ -140,7 +141,7 @@ namespace OpenSim.Region.Modules.SvnSerialiser
140 if (!commitItems.IsNull) 141 if (!commitItems.IsNull)
141 { 142 {
142 foreach (SvnClientCommitItem2 item in commitItems) 143 foreach (SvnClientCommitItem2 item in commitItems)
143 { 144 {
144 m_log.Debug("[SVNBACKUP]: ... " + Path.GetFileName(item.Path.ToString()) + " (" + item.Kind.ToString() + ") r" + item.Revision.ToString()); 145 m_log.Debug("[SVNBACKUP]: ... " + Path.GetFileName(item.Path.ToString()) + " (" + item.Kind.ToString() + ") r" + item.Revision.ToString());
145 } 146 }
146 } 147 }
@@ -174,8 +175,11 @@ namespace OpenSim.Region.Modules.SvnSerialiser
174 m_svnpass = source.Configs["SVN"].GetString("Password", m_svnpass); 175 m_svnpass = source.Configs["SVN"].GetString("Password", m_svnpass);
175 m_installBackupOnLoad = source.Configs["SVN"].GetBoolean("ImportOnStartup", m_installBackupOnLoad); 176 m_installBackupOnLoad = source.Configs["SVN"].GetBoolean("ImportOnStartup", m_installBackupOnLoad);
176 m_svnAutoSave = source.Configs["SVN"].GetBoolean("Autosave", m_svnAutoSave); 177 m_svnAutoSave = source.Configs["SVN"].GetBoolean("Autosave", m_svnAutoSave);
177 m_svnperiod = new TimeSpan(0, source.Configs["SVN"].GetInt("AutosavePeriod", (int)m_svnperiod.TotalMinutes), 0); 178 m_svnperiod = new TimeSpan(0, source.Configs["SVN"].GetInt("AutosavePeriod", (int) m_svnperiod.TotalMinutes), 0);
178 } catch(Exception) { } 179 }
180 catch (Exception)
181 {
182 }
179 183
180 lock (m_scenes) 184 lock (m_scenes)
181 { 185 {
@@ -185,7 +189,54 @@ namespace OpenSim.Region.Modules.SvnSerialiser
185 scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; 189 scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
186 } 190 }
187 191
188 void EventManager_OnPluginConsole(string[] args) 192 public void PostInitialise()
193 {
194 if (m_enabled == false)
195 return;
196
197 if (m_svnAutoSave == true)
198 {
199 m_timer.Interval = m_svnperiod.TotalMilliseconds;
200 m_timer.Elapsed += new ElapsedEventHandler(m_timer_Elapsed);
201 m_timer.AutoReset = true;
202 m_timer.Start();
203 }
204
205 m_log.Info("[SVNBACKUP]: Connecting to SVN server " + m_svnurl + " ...");
206 SetupSvnProvider();
207
208 m_log.Info("[SVNBACKUP]: Creating repository in " + m_svndir + ".");
209 CreateSvnDirectory();
210 CheckoutSvn();
211 SetupSerialiser();
212
213 if (m_installBackupOnLoad)
214 {
215 m_log.Info("[SVNBACKUP]: Importing latest SVN revision to scenes...");
216 foreach (Scene scene in m_scenes)
217 {
218 LoadRegion(scene);
219 }
220 }
221 }
222
223 public void Close()
224 {
225 }
226
227 public string Name
228 {
229 get { return "SvnBackupModule"; }
230 }
231
232 public bool IsSharedModule
233 {
234 get { return true; }
235 }
236
237 #endregion
238
239 private void EventManager_OnPluginConsole(string[] args)
189 { 240 {
190 if (args[0] == "svn" && args[1] == "save") 241 if (args[0] == "svn" && args[1] == "save")
191 { 242 {
@@ -272,38 +323,7 @@ namespace OpenSim.Region.Modules.SvnSerialiser
272 } 323 }
273 } 324 }
274 325
275 public void PostInitialise() 326 private void m_timer_Elapsed(object sender, ElapsedEventArgs e)
276 {
277 if (m_enabled == false)
278 return;
279
280 if (m_svnAutoSave == true)
281 {
282 m_timer.Interval = m_svnperiod.TotalMilliseconds;
283 m_timer.Elapsed += new ElapsedEventHandler(m_timer_Elapsed);
284 m_timer.AutoReset = true;
285 m_timer.Start();
286 }
287
288 m_log.Info("[SVNBACKUP]: Connecting to SVN server " + m_svnurl + " ...");
289 SetupSvnProvider();
290
291 m_log.Info("[SVNBACKUP]: Creating repository in " + m_svndir + ".");
292 CreateSvnDirectory();
293 CheckoutSvn();
294 SetupSerialiser();
295
296 if (m_installBackupOnLoad)
297 {
298 m_log.Info("[SVNBACKUP]: Importing latest SVN revision to scenes...");
299 foreach (Scene scene in m_scenes)
300 {
301 LoadRegion(scene);
302 }
303 }
304 }
305
306 void m_timer_Elapsed(object sender, ElapsedEventArgs e)
307 { 327 {
308 SaveAllRegions(); 328 SaveAllRegions();
309 } 329 }
@@ -320,7 +340,7 @@ namespace OpenSim.Region.Modules.SvnSerialiser
320 m_svnClient.AddUsernameProvider(); 340 m_svnClient.AddUsernameProvider();
321 m_svnClient.AddPromptProvider(new SvnAuthProviderObject.SimplePrompt(SimpleAuth), IntPtr.Zero, 2); 341 m_svnClient.AddPromptProvider(new SvnAuthProviderObject.SimplePrompt(SimpleAuth), IntPtr.Zero, 2);
322 m_svnClient.OpenAuth(); 342 m_svnClient.OpenAuth();
323 m_svnClient.Context.LogMsgFunc2 = new SvnDelegate(new SvnClient.GetCommitLog2(GetCommitLogCallback)); 343 m_svnClient.Context.LogMsgFunc2 = new SvnDelegate(new SvnClient.GetCommitLog2(GetCommitLogCallback));
324 } 344 }
325 345
326 private void CreateSvnDirectory() 346 private void CreateSvnDirectory()
@@ -328,22 +348,5 @@ namespace OpenSim.Region.Modules.SvnSerialiser
328 if (!Directory.Exists(m_svndir)) 348 if (!Directory.Exists(m_svndir))
329 Directory.CreateDirectory(m_svndir); 349 Directory.CreateDirectory(m_svndir);
330 } 350 }
331
332 public void Close()
333 {
334
335 }
336
337 public string Name
338 {
339 get { return "SvnBackupModule"; }
340 }
341
342 public bool IsSharedModule
343 {
344 get { return true; }
345 }
346
347 #endregion
348 } 351 }
349} 352} \ No newline at end of file