aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Application/OpenSim.cs3
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs13
-rw-r--r--OpenSim/Region/Framework/Scenes/EntityManager.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Permissions.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs16
-rw-r--r--OpenSim/Region/OptionalModules/SvnSerialiser/Properties/AssemblyInfo.cs62
-rw-r--r--OpenSim/Region/OptionalModules/SvnSerialiser/SvnBackupModule.cs399
8 files changed, 25 insertions, 483 deletions
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 300d8a6..7a188fd 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -220,10 +220,11 @@ namespace OpenSim
220 m_console.Commands.AddCommand("region", false, "debug packet", 220 m_console.Commands.AddCommand("region", false, "debug packet",
221 "debug packet <level>", 221 "debug packet <level>",
222 "Turn on packet debugging", 222 "Turn on packet debugging",
223 "If level > 255 then all incoming and outgoing packets are logged.\n" 223 "If level > 255 then all incoming and outgoing packets are logged.\n"
224 + "If level <= 255 then incoming AgentUpdate and outgoing SimStats and SimulatorViewerTimeMessage packets are not logged.\n" 224 + "If level <= 255 then incoming AgentUpdate and outgoing SimStats and SimulatorViewerTimeMessage packets are not logged.\n"
225 + "If level <= 200 then incoming RequestImage and outgoing ImagePacket, ImageData, LayerData and CoarseLocationUpdate packets are not logged.\n" 225 + "If level <= 200 then incoming RequestImage and outgoing ImagePacket, ImageData, LayerData and CoarseLocationUpdate packets are not logged.\n"
226 + "If level <= 100 then incoming ViewerEffect and AgentAnimation and outgoing ViewerEffect and AvatarAnimation packets are not logged.\n" 226 + "If level <= 100 then incoming ViewerEffect and AgentAnimation and outgoing ViewerEffect and AvatarAnimation packets are not logged.\n"
227 + "If level <= 50 then outgoing ImprovedTerseObjectUpdate packets are not logged.\n"
227 + "If level <= 0 then no packets are logged.", 228 + "If level <= 0 then no packets are logged.",
228 Debug); 229 Debug);
229 230
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 04710f1..00a605e 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -11347,23 +11347,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11347 { 11347 {
11348 if (m_debugPacketLevel > 0) 11348 if (m_debugPacketLevel > 0)
11349 { 11349 {
11350 bool outputPacket = true; 11350 bool logPacket = true;
11351 11351
11352 if (m_debugPacketLevel <= 255 11352 if (m_debugPacketLevel <= 255
11353 && (packet.Type == PacketType.SimStats || packet.Type == PacketType.SimulatorViewerTimeMessage)) 11353 && (packet.Type == PacketType.SimStats || packet.Type == PacketType.SimulatorViewerTimeMessage))
11354 outputPacket = false; 11354 logPacket = false;
11355 11355
11356 if (m_debugPacketLevel <= 200 11356 if (m_debugPacketLevel <= 200
11357 && (packet.Type == PacketType.ImagePacket 11357 && (packet.Type == PacketType.ImagePacket
11358 || packet.Type == PacketType.ImageData 11358 || packet.Type == PacketType.ImageData
11359 || packet.Type == PacketType.LayerData 11359 || packet.Type == PacketType.LayerData
11360 || packet.Type == PacketType.CoarseLocationUpdate)) 11360 || packet.Type == PacketType.CoarseLocationUpdate))
11361 outputPacket = false; 11361 logPacket = false;
11362 11362
11363 if (m_debugPacketLevel <= 100 && (packet.Type == PacketType.AvatarAnimation || packet.Type == PacketType.ViewerEffect)) 11363 if (m_debugPacketLevel <= 100 && (packet.Type == PacketType.AvatarAnimation || packet.Type == PacketType.ViewerEffect))
11364 outputPacket = false; 11364 logPacket = false;
11365
11366 if (m_debugPacketLevel <= 50 && packet.Type == PacketType.ImprovedTerseObjectUpdate)
11367 logPacket = false;
11365 11368
11366 if (outputPacket) 11369 if (logPacket)
11367 m_log.DebugFormat("[CLIENT]: Packet OUT {0}", packet.Type); 11370 m_log.DebugFormat("[CLIENT]: Packet OUT {0}", packet.Type);
11368 } 11371 }
11369 11372
diff --git a/OpenSim/Region/Framework/Scenes/EntityManager.cs b/OpenSim/Region/Framework/Scenes/EntityManager.cs
index 0defa93..1812bd2 100644
--- a/OpenSim/Region/Framework/Scenes/EntityManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EntityManager.cs
@@ -36,7 +36,8 @@ namespace OpenSim.Region.Framework.Scenes
36{ 36{
37 public class EntityManager 37 public class EntityManager
38 { 38 {
39 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 39// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
40
40 private readonly DoubleDictionary<UUID, uint, EntityBase> m_entities = new DoubleDictionary<UUID, uint, EntityBase>(); 41 private readonly DoubleDictionary<UUID, uint, EntityBase> m_entities = new DoubleDictionary<UUID, uint, EntityBase>();
41 42
42 public int Count 43 public int Count
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
index 1295e58..66439ab 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
@@ -91,7 +91,7 @@ namespace OpenSim.Region.Framework.Scenes
91 91
92 public class ScenePermissions 92 public class ScenePermissions
93 { 93 {
94 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 94// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
95 95
96 private Scene m_scene; 96 private Scene m_scene;
97 97
@@ -131,7 +131,7 @@ namespace OpenSim.Region.Framework.Scenes
131 public event IssueEstateCommandHandler OnIssueEstateCommand; 131 public event IssueEstateCommandHandler OnIssueEstateCommand;
132 public event IsGodHandler OnIsGod; 132 public event IsGodHandler OnIsGod;
133 public event IsAdministratorHandler OnIsAdministrator; 133 public event IsAdministratorHandler OnIsAdministrator;
134 public event EditParcelHandler OnEditParcel; 134// public event EditParcelHandler OnEditParcel;
135 public event EditParcelPropertiesHandler OnEditParcelProperties; 135 public event EditParcelPropertiesHandler OnEditParcelProperties;
136 public event SellParcelHandler OnSellParcel; 136 public event SellParcelHandler OnSellParcel;
137 public event AbandonParcelHandler OnAbandonParcel; 137 public event AbandonParcelHandler OnAbandonParcel;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 45625d6..3776d47 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -136,9 +136,9 @@ namespace OpenSim.Region.Framework.Scenes
136 // TODO: Possibly stop other classes being able to manipulate this directly. 136 // TODO: Possibly stop other classes being able to manipulate this directly.
137 private SceneGraph m_sceneGraph; 137 private SceneGraph m_sceneGraph;
138 private volatile int m_bordersLocked; 138 private volatile int m_bordersLocked;
139 private int m_RestartTimerCounter; 139// private int m_RestartTimerCounter;
140 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing 140 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing
141 private int m_incrementsof15seconds; 141// private int m_incrementsof15seconds;
142 private volatile bool m_backingup; 142 private volatile bool m_backingup;
143 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); 143 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>();
144 private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>(); 144 private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>();
@@ -151,7 +151,7 @@ namespace OpenSim.Region.Framework.Scenes
151 private int m_update_events = 1; 151 private int m_update_events = 1;
152 private int m_update_backup = 200; 152 private int m_update_backup = 200;
153 private int m_update_terrain = 50; 153 private int m_update_terrain = 50;
154 private int m_update_land = 1; 154// private int m_update_land = 1;
155 private int m_update_coarse_locations = 80; 155 private int m_update_coarse_locations = 80;
156 156
157 private int frameMS; 157 private int frameMS;
@@ -192,7 +192,7 @@ namespace OpenSim.Region.Framework.Scenes
192 private Timer m_mapGenerationTimer = new Timer(); 192 private Timer m_mapGenerationTimer = new Timer();
193 private bool m_generateMaptiles; 193 private bool m_generateMaptiles;
194 194
195 private Dictionary<UUID, string[]> m_UserNamesCache = new Dictionary<UUID, string[]>(); 195// private Dictionary<UUID, string[]> m_UserNamesCache = new Dictionary<UUID, string[]>();
196 196
197 #endregion Fields 197 #endregion Fields
198 198
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index 6c13eb5..b2b3ad9 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -1114,15 +1114,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1114 WriteVector(writer, "AngularVelocity", sop.AngularVelocity); 1114 WriteVector(writer, "AngularVelocity", sop.AngularVelocity);
1115 WriteVector(writer, "Acceleration", sop.Acceleration); 1115 WriteVector(writer, "Acceleration", sop.Acceleration);
1116 writer.WriteElementString("Description", sop.Description); 1116 writer.WriteElementString("Description", sop.Description);
1117 if (sop.Color != null) 1117
1118 { 1118 writer.WriteStartElement("Color");
1119 writer.WriteStartElement("Color"); 1119 writer.WriteElementString("R", sop.Color.R.ToString(Utils.EnUsCulture));
1120 writer.WriteElementString("R", sop.Color.R.ToString(Utils.EnUsCulture)); 1120 writer.WriteElementString("G", sop.Color.G.ToString(Utils.EnUsCulture));
1121 writer.WriteElementString("G", sop.Color.G.ToString(Utils.EnUsCulture)); 1121 writer.WriteElementString("B", sop.Color.B.ToString(Utils.EnUsCulture));
1122 writer.WriteElementString("B", sop.Color.B.ToString(Utils.EnUsCulture)); 1122 writer.WriteElementString("A", sop.Color.G.ToString(Utils.EnUsCulture));
1123 writer.WriteElementString("A", sop.Color.G.ToString(Utils.EnUsCulture)); 1123 writer.WriteEndElement();
1124 writer.WriteEndElement();
1125 }
1126 1124
1127 writer.WriteElementString("Text", sop.Text); 1125 writer.WriteElementString("Text", sop.Text);
1128 writer.WriteElementString("SitName", sop.SitName); 1126 writer.WriteElementString("SitName", sop.SitName);
diff --git a/OpenSim/Region/OptionalModules/SvnSerialiser/Properties/AssemblyInfo.cs b/OpenSim/Region/OptionalModules/SvnSerialiser/Properties/AssemblyInfo.cs
deleted file mode 100644
index 54c90bf..0000000
--- a/OpenSim/Region/OptionalModules/SvnSerialiser/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,62 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Reflection;
29using System.Runtime.InteropServices;
30
31// General information about an assembly is controlled through the following
32// set of attributes. Change these attribute values to modify the information
33// associated with an assembly.
34[assembly: AssemblyTitle("SvnSerialiser")]
35[assembly: AssemblyDescription("")]
36[assembly: AssemblyConfiguration("")]
37[assembly: AssemblyCompany("http://opensimulator.org")]
38[assembly: AssemblyProduct("SvnSerialiser")]
39[assembly: AssemblyCopyright("Copyright (c) 2008")]
40[assembly: AssemblyTrademark("")]
41[assembly: AssemblyCulture("")]
42
43// Setting ComVisible to false makes the types in this assembly not visible
44// to COM components. If you need to access a type in this assembly from
45// COM, set the ComVisible attribute to true on that type.
46[assembly: ComVisible(false)]
47
48// The following GUID is for the ID of the typelib if this project is exposed to COM
49[assembly: Guid("c0893655-0c18-4dd7-8b5b-5f58ab1ec6c7")]
50
51// Version information for an assembly consists of the following four values:
52//
53// Major Version
54// Minor Version
55// Build Number
56// Revision
57//
58// You can specify all the values or you can default the Build and Revision Numbers
59// by using the '*' as shown below:
60// [assembly: AssemblyVersion("0.6.5.*")]
61[assembly: AssemblyVersion("0.6.5.*")]
62[assembly: AssemblyFileVersion("0.6.5.0")]
diff --git a/OpenSim/Region/OptionalModules/SvnSerialiser/SvnBackupModule.cs b/OpenSim/Region/OptionalModules/SvnSerialiser/SvnBackupModule.cs
deleted file mode 100644
index ccdea14..0000000
--- a/OpenSim/Region/OptionalModules/SvnSerialiser/SvnBackupModule.cs
+++ /dev/null
@@ -1,399 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using System.Timers;
33using log4net;
34using Nini.Config;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.CoreModules.World.Serialiser;
37using OpenSim.Region.CoreModules.World.Terrain;
38using OpenSim.Region.Framework.Scenes;
39using PumaCode.SvnDotNet.AprSharp;
40using PumaCode.SvnDotNet.SubversionSharp;
41using Slash = System.IO.Path;
42
43namespace OpenSim.Region.Modules.SvnSerialiser
44{
45 public class SvnBackupModule : IRegionModule
46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48
49 private List<Scene> m_scenes;
50 private Timer m_timer;
51 private bool m_enabled;
52 private bool m_installBackupOnLoad;
53 private IRegionSerialiserModule m_serialiser;
54 private bool m_svnAutoSave;
55 private SvnClient m_svnClient;
56 private string m_svndir = "SVNmodule" + Slash.DirectorySeparatorChar + "repo";
57 private string m_svnpass = "password";
58
59 private TimeSpan m_svnperiod = new TimeSpan(0, 0, 15, 0, 0);
60 private string m_svnurl = "svn://insert.Your.svn/here/";
61 private string m_svnuser = "username";
62
63 #region SvnModule Core
64
65 /// <summary>
66 /// Exports a specified scene to the SVN repo directory, then commits.
67 /// </summary>
68 /// <param name="scene">The scene to export</param>
69 public void SaveRegion(Scene scene)
70 {
71 List<string> svnfilenames = CreateAndAddExport(scene);
72
73 m_svnClient.Commit3(svnfilenames, true, false);
74 m_log.Info("[SVNBACKUP]: Region backup successful (" + scene.RegionInfo.RegionName + ").");
75 }
76
77 /// <summary>
78 /// Saves all registered scenes to the SVN repo, then commits.
79 /// </summary>
80 public void SaveAllRegions()
81 {
82 List<string> svnfilenames = new List<string>();
83 List<string> regions = new List<string>();
84
85 foreach (Scene scene in m_scenes)
86 {
87 svnfilenames.AddRange(CreateAndAddExport(scene));
88 regions.Add("'" + scene.RegionInfo.RegionName + "' ");
89 }
90
91 m_svnClient.Commit3(svnfilenames, true, false);
92 m_log.Info("[SVNBACKUP]: Server backup successful (" + String.Concat(regions.ToArray()) + ").");
93 }
94
95 private List<string> CreateAndAddExport(Scene scene)
96 {
97 m_log.Info("[SVNBACKUP]: Saving a region to SVN with name " + scene.RegionInfo.RegionName);
98
99 List<string> filenames = m_serialiser.SerialiseRegion(scene, m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID + Slash.DirectorySeparatorChar);
100
101 try
102 {
103 m_svnClient.Add3(m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID, true, false, false);
104 }
105 catch (SvnException)
106 {
107 }
108
109 List<string> svnfilenames = new List<string>();
110 foreach (string filename in filenames)
111 svnfilenames.Add(m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID + Slash.DirectorySeparatorChar + filename);
112 svnfilenames.Add(m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID);
113
114 return svnfilenames;
115 }
116
117 public void LoadRegion(Scene scene)
118 {
119 IRegionSerialiserModule serialiser = scene.RequestModuleInterface<IRegionSerialiserModule>();
120 if (serialiser != null)
121 {
122 serialiser.LoadPrimsFromXml2(
123 scene,
124 m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID
125 + Slash.DirectorySeparatorChar + "objects.xml");
126
127 scene.RequestModuleInterface<ITerrainModule>().LoadFromFile(
128 m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID
129 + Slash.DirectorySeparatorChar + "heightmap.r32");
130
131 m_log.Info("[SVNBACKUP]: Region load successful (" + scene.RegionInfo.RegionName + ").");
132 }
133 else
134 {
135 m_log.ErrorFormat(
136 "[SVNBACKUP]: Region load of {0} failed - no serialisation module available",
137 scene.RegionInfo.RegionName);
138 }
139 }
140
141 private void CheckoutSvn()
142 {
143 m_svnClient.Checkout2(m_svnurl, m_svndir, Svn.Revision.Head, Svn.Revision.Head, true, false);
144 }
145
146 private void CheckoutSvn(SvnRevision revision)
147 {
148 m_svnClient.Checkout2(m_svnurl, m_svndir, revision, revision, true, false);
149 }
150
151 // private void CheckoutSvnPartial(string subdir)
152 // {
153 // if (!Directory.Exists(m_svndir + Slash.DirectorySeparatorChar + subdir))
154 // Directory.CreateDirectory(m_svndir + Slash.DirectorySeparatorChar + subdir);
155
156 // m_svnClient.Checkout2(m_svnurl + "/" + subdir, m_svndir, Svn.Revision.Head, Svn.Revision.Head, true, false);
157 // }
158
159 // private void CheckoutSvnPartial(string subdir, SvnRevision revision)
160 // {
161 // if (!Directory.Exists(m_svndir + Slash.DirectorySeparatorChar + subdir))
162 // Directory.CreateDirectory(m_svndir + Slash.DirectorySeparatorChar + subdir);
163
164 // m_svnClient.Checkout2(m_svnurl + "/" + subdir, m_svndir, revision, revision, true, false);
165 // }
166
167 #endregion
168
169 #region SvnDotNet Callbacks
170
171 private SvnError SimpleAuth(out SvnAuthCredSimple svnCredentials, IntPtr baton,
172 AprString realm, AprString username, bool maySave, AprPool pool)
173 {
174 svnCredentials = SvnAuthCredSimple.Alloc(pool);
175 svnCredentials.Username = new AprString(m_svnuser, pool);
176 svnCredentials.Password = new AprString(m_svnpass, pool);
177 svnCredentials.MaySave = false;
178 return SvnError.NoError;
179 }
180
181 private SvnError GetCommitLogCallback(out AprString logMessage, out SvnPath tmpFile, AprArray commitItems, IntPtr baton, AprPool pool)
182 {
183 if (!commitItems.IsNull)
184 {
185 foreach (SvnClientCommitItem2 item in commitItems)
186 {
187 m_log.Debug("[SVNBACKUP]: ... " + Path.GetFileName(item.Path.ToString()) + " (" + item.Kind.ToString() + ") r" + item.Revision.ToString());
188 }
189 }
190
191 string msg = "Region Backup (" + System.Environment.MachineName + " at " + DateTime.UtcNow + " UTC)";
192
193 m_log.Debug("[SVNBACKUP]: Saved with message: " + msg);
194
195 logMessage = new AprString(msg, pool);
196 tmpFile = new SvnPath(pool);
197
198 return (SvnError.NoError);
199 }
200
201 #endregion
202
203 #region IRegionModule Members
204
205 public void Initialise(Scene scene, IConfigSource source)
206 {
207 m_scenes = new List<Scene>();
208 m_timer = new Timer();
209
210 try
211 {
212 if (!source.Configs["SVN"].GetBoolean("Enabled", false))
213 return;
214
215 m_enabled = true;
216
217 m_svndir = source.Configs["SVN"].GetString("Directory", m_svndir);
218 m_svnurl = source.Configs["SVN"].GetString("URL", m_svnurl);
219 m_svnuser = source.Configs["SVN"].GetString("Username", m_svnuser);
220 m_svnpass = source.Configs["SVN"].GetString("Password", m_svnpass);
221 m_installBackupOnLoad = source.Configs["SVN"].GetBoolean("ImportOnStartup", m_installBackupOnLoad);
222 m_svnAutoSave = source.Configs["SVN"].GetBoolean("Autosave", m_svnAutoSave);
223 m_svnperiod = new TimeSpan(0, source.Configs["SVN"].GetInt("AutosavePeriod", (int) m_svnperiod.TotalMinutes), 0);
224 }
225 catch (Exception)
226 {
227 }
228
229 lock (m_scenes)
230 {
231 m_scenes.Add(scene);
232 }
233 //Only register it once, to prevent command being executed x*region times
234 if (m_scenes.Count == 1)
235 {
236 scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
237 }
238 }
239
240 public void PostInitialise()
241 {
242 if (m_enabled == false)
243 return;
244
245 if (m_svnAutoSave)
246 {
247 m_timer.Interval = m_svnperiod.TotalMilliseconds;
248 m_timer.Elapsed += m_timer_Elapsed;
249 m_timer.AutoReset = true;
250 m_timer.Start();
251 }
252
253 m_log.Info("[SVNBACKUP]: Connecting to SVN server " + m_svnurl + " ...");
254 SetupSvnProvider();
255
256 m_log.Info("[SVNBACKUP]: Creating repository in " + m_svndir + ".");
257 CreateSvnDirectory();
258 CheckoutSvn();
259 SetupSerialiser();
260
261 if (m_installBackupOnLoad)
262 {
263 m_log.Info("[SVNBACKUP]: Importing latest SVN revision to scenes...");
264 foreach (Scene scene in m_scenes)
265 {
266 LoadRegion(scene);
267 }
268 }
269 }
270
271 public void Close()
272 {
273 }
274
275 public string Name
276 {
277 get { return "SvnBackupModule"; }
278 }
279
280 public bool IsSharedModule
281 {
282 get { return true; }
283 }
284
285 #endregion
286
287 private void EventManager_OnPluginConsole(string[] args)
288 {
289 if (args[0] == "svn" && args[1] == "save")
290 {
291 SaveAllRegions();
292 }
293 if (args.Length == 2)
294 {
295 if (args[0] == "svn" && args[1] == "load")
296 {
297 LoadAllScenes();
298 }
299 }
300 if (args.Length == 3)
301 {
302 if (args[0] == "svn" && args[1] == "load")
303 {
304 LoadAllScenes(Int32.Parse(args[2]));
305 }
306 }
307 if (args.Length == 3)
308 {
309 if (args[0] == "svn" && args[1] == "load-region")
310 {
311 LoadScene(args[2]);
312 }
313 }
314 if (args.Length == 4)
315 {
316 if (args[0] == "svn" && args[1] == "load-region")
317 {
318 LoadScene(args[2], Int32.Parse(args[3]));
319 }
320 }
321 }
322
323 public void LoadScene(string name)
324 {
325 CheckoutSvn();
326
327 foreach (Scene scene in m_scenes)
328 {
329 if (scene.RegionInfo.RegionName.ToLower().Equals(name.ToLower()))
330 {
331 LoadRegion(scene);
332 return;
333 }
334 }
335 m_log.Warn("[SVNBACKUP]: No region loaded - unable to find matching name.");
336 }
337
338 public void LoadScene(string name, int revision)
339 {
340 CheckoutSvn(new SvnRevision(revision));
341
342 foreach (Scene scene in m_scenes)
343 {
344 if (scene.RegionInfo.RegionName.ToLower().Equals(name.ToLower()))
345 {
346 LoadRegion(scene);
347 return;
348 }
349 }
350 m_log.Warn("[SVNBACKUP]: No region loaded - unable to find matching name.");
351 }
352
353 public void LoadAllScenes()
354 {
355 CheckoutSvn();
356
357 foreach (Scene scene in m_scenes)
358 {
359 LoadRegion(scene);
360 }
361 }
362
363 public void LoadAllScenes(int revision)
364 {
365 CheckoutSvn(new SvnRevision(revision));
366
367 foreach (Scene scene in m_scenes)
368 {
369 LoadRegion(scene);
370 }
371 }
372
373 private void m_timer_Elapsed(object sender, ElapsedEventArgs e)
374 {
375 SaveAllRegions();
376 }
377
378 private void SetupSerialiser()
379 {
380 if (m_scenes.Count > 0)
381 m_serialiser = m_scenes[0].RequestModuleInterface<IRegionSerialiserModule>();
382 }
383
384 private void SetupSvnProvider()
385 {
386 m_svnClient = new SvnClient();
387 m_svnClient.AddUsernameProvider();
388 m_svnClient.AddPromptProvider(new SvnAuthProviderObject.SimplePrompt(SimpleAuth), IntPtr.Zero, 2);
389 m_svnClient.OpenAuth();
390 m_svnClient.Context.LogMsgFunc2 = new SvnDelegate(new SvnClient.GetCommitLog2(GetCommitLogCallback));
391 }
392
393 private void CreateSvnDirectory()
394 {
395 if (!Directory.Exists(m_svndir))
396 Directory.CreateDirectory(m_svndir);
397 }
398 }
399}