corrade-vassal – Diff between revs 13 and 16

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 13 Rev 16
1 /////////////////////////////////////////////////////////////////////////// 1 ///////////////////////////////////////////////////////////////////////////
2 // Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 // 2 // Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 //
3 // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // 3 // Please see: http://www.gnu.org/licenses/gpl.html for legal details, //
4 // rights of fair usage, the disclaimer and warranty conditions. // 4 // rights of fair usage, the disclaimer and warranty conditions. //
5 /////////////////////////////////////////////////////////////////////////// 5 ///////////////////////////////////////////////////////////////////////////
6   6  
7 using System; 7 using System;
8 using System.Collections.Generic; 8 using System.Collections.Generic;
9 using System.ComponentModel; 9 using System.ComponentModel;
10 using System.IO; 10 using System.IO;
11 using System.Linq; 11 using System.Linq;
12 using System.Text; 12 using System.Text;
13 using System.Xml.Serialization; 13 using System.Xml.Serialization;
14   14  
15 namespace Vassal 15 namespace Vassal
16 { 16 {
17 /// <summary> 17 /// <summary>
18 /// Possible input and output filters. 18 /// Possible input and output filters.
19 /// </summary> 19 /// </summary>
20 public enum Filter : uint 20 public enum Filter : uint
21 { 21 {
22 [XmlEnum(Name = "none")] [Description("none")] NONE = 0, 22 [XmlEnum(Name = "none")] [Description("none")] NONE = 0,
23 [XmlEnum(Name = "RFC1738")] [Description("RFC1738")] RFC1738, 23 [XmlEnum(Name = "RFC1738")] [Description("RFC1738")] RFC1738,
24 [XmlEnum(Name = "RFC3986")] [Description("RFC3986")] RFC3986, 24 [XmlEnum(Name = "RFC3986")] [Description("RFC3986")] RFC3986,
25 [XmlEnum(Name = "ENIGMA")] [Description("ENIGMA")] ENIGMA, 25 [XmlEnum(Name = "ENIGMA")] [Description("ENIGMA")] ENIGMA,
26 [XmlEnum(Name = "VIGENERE")] [Description("VIGENERE")] VIGENERE, 26 [XmlEnum(Name = "VIGENERE")] [Description("VIGENERE")] VIGENERE,
27 [XmlEnum(Name = "ATBASH")] [Description("ATBASH")] ATBASH, 27 [XmlEnum(Name = "ATBASH")] [Description("ATBASH")] ATBASH,
28 [XmlEnum(Name = "BASE64")] [Description("BASE64")] BASE64 28 [XmlEnum(Name = "BASE64")] [Description("BASE64")] BASE64
29 } 29 }
30   30  
31 /// <summary> 31 /// <summary>
32 /// ENIGMA machine settings. 32 /// ENIGMA machine settings.
33 /// </summary> 33 /// </summary>
34 public struct ENIGMA 34 public struct ENIGMA
35 { 35 {
36 public char[] plugs; 36 public char[] plugs;
37 public char reflector; 37 public char reflector;
38 public char[] rotors; 38 public char[] rotors;
39 } 39 }
40   40  
41 [Serializable] 41 [Serializable]
42 public class VassalConfiguration 42 public class VassalConfiguration
43 { 43 {
44 private static readonly object VassalConfigurationLock = new object(); 44 private static readonly object VassalConfigurationLock = new object();
45 private uint _dataTimeout = 15000; 45 private uint _servicesTimeout = 60000;
46   46  
47 private ENIGMA _enigma = new ENIGMA 47 private ENIGMA _enigma = new ENIGMA
48 { 48 {
49 rotors = new[] {'3', 'g', '1'}, 49 rotors = new[] {'3', 'g', '1'},
50 plugs = new[] {'z', 'p', 'q'}, 50 plugs = new[] {'z', 'p', 'q'},
51 reflector = 'b' 51 reflector = 'b'
52 }; 52 };
53   53  
54 private string _group = string.Empty; 54 private string _group = string.Empty;
55 private string _HTTPServerURL = @"http://127.0.0.1:8080/"; 55 private string _HTTPServerURL = @"http://127.0.0.1:8080/";
56 private List<Filter> _inputFilters = new List<Filter>(); 56 private List<Filter> _inputFilters = new List<Filter>();
57 private List<Filter> _outputFilters = new List<Filter>(); 57 private List<Filter> _outputFilters = new List<Filter>();
58 private string _password = string.Empty; 58 private string _password = string.Empty;
59 private uint _regionRestartDelay = 120; 59 private uint _regionRestartDelay = 120;
60 private uint _teleportTimeout = 30000; 60 private uint _teleportTimeout = 30000;
61 private string _vigenereSecret = string.Empty; 61 private string _vigenereSecret = string.Empty;
62   62  
63 public string Group 63 public string Group
64 { 64 {
65 get 65 get
66 { 66 {
67 lock (VassalConfigurationLock) 67 lock (VassalConfigurationLock)
68 { 68 {
69 return _group; 69 return _group;
70 } 70 }
71 } 71 }
72 set 72 set
73 { 73 {
74 lock (VassalConfigurationLock) 74 lock (VassalConfigurationLock)
75 { 75 {
76 _group = value; 76 _group = value;
77 } 77 }
78 } 78 }
79 } 79 }
80   80  
81 public string Password 81 public string Password
82 { 82 {
83 get 83 get
84 { 84 {
85 lock (VassalConfigurationLock) 85 lock (VassalConfigurationLock)
86 { 86 {
87 return _password; 87 return _password;
88 } 88 }
89 } 89 }
90 set 90 set
91 { 91 {
92 lock (VassalConfigurationLock) 92 lock (VassalConfigurationLock)
93 { 93 {
94 _password = value; 94 _password = value;
95 } 95 }
96 } 96 }
97 } 97 }
98   98  
99 public ENIGMA ENIGMA 99 public ENIGMA ENIGMA
100 { 100 {
101 get 101 get
102 { 102 {
103 lock (VassalConfigurationLock) 103 lock (VassalConfigurationLock)
104 { 104 {
105 return _enigma; 105 return _enigma;
106 } 106 }
107 } 107 }
108 set 108 set
109 { 109 {
110 lock (VassalConfigurationLock) 110 lock (VassalConfigurationLock)
111 { 111 {
112 _enigma = value; 112 _enigma = value;
113 } 113 }
114 } 114 }
115 } 115 }
116   116  
117 public string VIGENERESecret 117 public string VIGENERESecret
118 { 118 {
119 get 119 get
120 { 120 {
121 lock (VassalConfigurationLock) 121 lock (VassalConfigurationLock)
122 { 122 {
123 return _vigenereSecret; 123 return _vigenereSecret;
124 } 124 }
125 } 125 }
126 set 126 set
127 { 127 {
128 lock (VassalConfigurationLock) 128 lock (VassalConfigurationLock)
129 { 129 {
130 _vigenereSecret = value; 130 _vigenereSecret = value;
131 } 131 }
132 } 132 }
133 } 133 }
134   134  
135 public List<Filter> InputFilters 135 public List<Filter> InputFilters
136 { 136 {
137 get 137 get
138 { 138 {
139 lock (VassalConfigurationLock) 139 lock (VassalConfigurationLock)
140 { 140 {
141 return !_inputFilters.Any() ? new List<Filter> {Filter.RFC1738} : _inputFilters; 141 return !_inputFilters.Any() ? new List<Filter> {Filter.RFC1738} : _inputFilters;
142 } 142 }
143 } 143 }
144 set 144 set
145 { 145 {
146 lock (VassalConfigurationLock) 146 lock (VassalConfigurationLock)
147 { 147 {
148 _inputFilters = value; 148 _inputFilters = value;
149 } 149 }
150 } 150 }
151 } 151 }
152   152  
153 public List<Filter> OutputFilters 153 public List<Filter> OutputFilters
154 { 154 {
155 get 155 get
156 { 156 {
157 lock (VassalConfigurationLock) 157 lock (VassalConfigurationLock)
158 { 158 {
159 return !_outputFilters.Any() ? new List<Filter> {Filter.RFC1738} : _outputFilters; 159 return !_outputFilters.Any() ? new List<Filter> {Filter.RFC1738} : _outputFilters;
160 } 160 }
161 } 161 }
162 set 162 set
163 { 163 {
164 lock (VassalConfigurationLock) 164 lock (VassalConfigurationLock)
165 { 165 {
166 _outputFilters = value; 166 _outputFilters = value;
167 } 167 }
168 } 168 }
169 } 169 }
170   170  
171 public string HTTPServerURL 171 public string HTTPServerURL
172 { 172 {
173 get 173 get
174 { 174 {
175 lock (VassalConfigurationLock) 175 lock (VassalConfigurationLock)
176 { 176 {
177 return _HTTPServerURL; 177 return _HTTPServerURL;
178 } 178 }
179 } 179 }
180 set 180 set
181 { 181 {
182 lock (VassalConfigurationLock) 182 lock (VassalConfigurationLock)
183 { 183 {
184 _HTTPServerURL = value; 184 _HTTPServerURL = value;
185 } 185 }
186 } 186 }
187 } 187 }
188   188  
189 public uint TeleportTimeout 189 public uint TeleportTimeout
190 { 190 {
191 get 191 get
192 { 192 {
193 lock (VassalConfigurationLock) 193 lock (VassalConfigurationLock)
194 { 194 {
195 return _teleportTimeout; 195 return _teleportTimeout;
196 } 196 }
197 } 197 }
198 set 198 set
199 { 199 {
200 lock (VassalConfigurationLock) 200 lock (VassalConfigurationLock)
201 { 201 {
202 _teleportTimeout = value; 202 _teleportTimeout = value;
203 } 203 }
204 } 204 }
205 } 205 }
206   206  
207 public uint DataTimeout 207 public uint ServicesTimeout
208 { 208 {
209 get 209 get
210 { 210 {
211 lock (VassalConfigurationLock) 211 lock (VassalConfigurationLock)
212 { 212 {
213 return _dataTimeout; 213 return _servicesTimeout;
214 } 214 }
215 } 215 }
216 set 216 set
217 { 217 {
218 lock (VassalConfigurationLock) 218 lock (VassalConfigurationLock)
219 { 219 {
220 _dataTimeout = value; 220 _servicesTimeout = value;
221 } 221 }
222 } 222 }
223 } 223 }
224   224  
225 public uint RegionRestartDelay 225 public uint RegionRestartDelay
226 { 226 {
227 get 227 get
228 { 228 {
229 lock (VassalConfigurationLock) 229 lock (VassalConfigurationLock)
230 { 230 {
231 return _regionRestartDelay; 231 return _regionRestartDelay;
232 } 232 }
233 } 233 }
234 set 234 set
235 { 235 {
236 lock (VassalConfigurationLock) 236 lock (VassalConfigurationLock)
237 { 237 {
238 _regionRestartDelay = value; 238 _regionRestartDelay = value;
239 } 239 }
240 } 240 }
241 } 241 }
242   242  
243 public static void Save(string file, ref VassalConfiguration configuration) 243 public static void Save(string file, ref VassalConfiguration configuration)
244 { 244 {
245 lock (VassalConfigurationLock) 245 lock (VassalConfigurationLock)
246 { 246 {
247 using (StreamWriter writer = new StreamWriter(file, false, Encoding.UTF8)) 247 using (StreamWriter writer = new StreamWriter(file, false, Encoding.UTF8))
248 { 248 {
249 XmlSerializer serializer = new XmlSerializer(typeof (VassalConfiguration)); 249 XmlSerializer serializer = new XmlSerializer(typeof (VassalConfiguration));
250 serializer.Serialize(writer, configuration); 250 serializer.Serialize(writer, configuration);
251 //writer.Flush(); 251 //writer.Flush();
252 } 252 }
253 } 253 }
254 } 254 }
255   255  
256 public static void Load(string file, ref VassalConfiguration configuration) 256 public static void Load(string file, ref VassalConfiguration configuration)
257 { 257 {
258 lock (VassalConfigurationLock) 258 lock (VassalConfigurationLock)
259 { 259 {
260 using (StreamReader stream = new StreamReader(file, Encoding.UTF8)) 260 using (StreamReader stream = new StreamReader(file, Encoding.UTF8))
261 { 261 {
262 XmlSerializer serializer = 262 XmlSerializer serializer =
263 new XmlSerializer(typeof (VassalConfiguration)); 263 new XmlSerializer(typeof (VassalConfiguration));
264 configuration = (VassalConfiguration) serializer.Deserialize(stream); 264 configuration = (VassalConfiguration) serializer.Deserialize(stream);
265 } 265 }
266 } 266 }
267 } 267 }
268 } 268 }
269 } 269 }
270   270  
271
Generated by GNU Enscript 1.6.5.90.
271
Generated by GNU Enscript 1.6.5.90.
272   272  
273   273  
274   274