aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs
diff options
context:
space:
mode:
authorAdam Frisby2008-04-30 21:16:36 +0000
committerAdam Frisby2008-04-30 21:16:36 +0000
commitf5c312bc3c2567449c7268a54a08a54119f58d53 (patch)
tree424668a4bbec6873ebc5b8256f3671db102f5e9c /OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs
parent* Adds the AuthbuyerID field to sqlite and makes use of it. (diff)
downloadopensim-SC_OLD-f5c312bc3c2567449c7268a54a08a54119f58d53.zip
opensim-SC_OLD-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.gz
opensim-SC_OLD-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.bz2
opensim-SC_OLD-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.xz
* Refactored Environment/Modules directory - modules now reside in their own directory with any associated module-specific classes.
* Each module directory is currently inside one of the following category folders: Agent (Anything relating to do with Client<->Server communications.), Avatar (Anything to do with the avatar or presence inworld), Framework (Classes modules can use), Grid (Grid traffic, new OGS2 grid comms), Scripting (Scripting functions, etc), World (The enrivonment/scene, IE Sun/Tree modules.) * This should be moved into a seperate project file.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs168
1 files changed, 0 insertions, 168 deletions
diff --git a/OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs b/OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs
deleted file mode 100644
index 91770af..0000000
--- a/OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs
+++ /dev/null
@@ -1,168 +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 OpenSim 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 Nini.Config;
32using OpenSim.Region.Environment.Interfaces;
33using OpenSim.Region.Environment.Modules.ModuleFramework;
34using OpenSim.Region.Environment.Scenes;
35
36namespace OpenSim.Region.Environment.Modules.ExportSerialiser
37{
38 public class ExportSerialisationModule : IRegionModule, IRegionSerialiser
39 {
40 private Commander m_commander = new Commander("Export");
41 private List<Scene> m_regions = new List<Scene>();
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
88
89 public List<string> SerialiseRegion(Scene scene, string saveDir)
90 {
91 List<string> results = new List<string>();
92
93 if (!Directory.Exists(saveDir))
94 {
95 Directory.CreateDirectory(saveDir);
96 }
97
98 lock (m_serialisers)
99 {
100 foreach (IFileSerialiser serialiser in m_serialisers)
101 {
102 results.Add(serialiser.WriteToFile(scene, saveDir));
103 }
104 }
105
106 TextWriter regionInfoWriter = new StreamWriter(saveDir + "README.TXT");
107 regionInfoWriter.WriteLine("Region Name: " + scene.RegionInfo.RegionName);
108 regionInfoWriter.WriteLine("Region ID: " + scene.RegionInfo.RegionID.ToString());
109 regionInfoWriter.WriteLine("Backup Time: UTC " + DateTime.UtcNow.ToString());
110 regionInfoWriter.WriteLine("Serialise Version: 0.1");
111 regionInfoWriter.Close();
112
113 TextWriter manifestWriter = new StreamWriter(saveDir + "region.manifest");
114 foreach (string line in results)
115 {
116 manifestWriter.WriteLine(line);
117 }
118 manifestWriter.Close();
119
120 return results;
121 }
122
123 #endregion
124
125 private void EventManager_OnPluginConsole(string[] args)
126 {
127 if (args[0] == "export")
128 {
129 string[] tmpArgs = new string[args.Length - 2];
130 int i = 0;
131 for (i = 2; i < args.Length; i++)
132 tmpArgs[i - 2] = args[i];
133
134 m_commander.ProcessConsoleCommand(args[1], tmpArgs);
135 }
136 }
137
138 private void InterfaceSaveRegion(Object[] args)
139 {
140 foreach (Scene region in m_regions)
141 {
142 if (region.RegionInfo.RegionName == (string) args[0])
143 {
144 List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/");
145 }
146 }
147 }
148
149 private void InterfaceSaveAllRegions(Object[] args)
150 {
151 foreach (Scene region in m_regions)
152 {
153 List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/");
154 }
155 }
156
157 private void LoadCommanderCommands()
158 {
159 Command serialiseSceneCommand = new Command("save", InterfaceSaveRegion, "Saves the named region into the exports directory.");
160 serialiseSceneCommand.AddArgument("region-name", "The name of the region you wish to export", "String");
161
162 Command serialiseAllScenesCommand = new Command("save-all", InterfaceSaveAllRegions, "Saves all regions into the exports directory.");
163
164 m_commander.RegisterCommand("save", serialiseSceneCommand);
165 m_commander.RegisterCommand("save-all", serialiseAllScenesCommand);
166 }
167 }
168} \ No newline at end of file