aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorDiva Canto2014-06-01 10:06:26 -0700
committerDiva Canto2014-06-01 10:06:26 -0700
commit2ff9ea3f8038653135c284cc0c93d88690db9a22 (patch)
tree34448f055a3577311e147503536260337a8d4719 /OpenSim/Framework
parentFix a bug where estate not found would result in a dummy estate record with e... (diff)
downloadopensim-SC_OLD-2ff9ea3f8038653135c284cc0c93d88690db9a22.zip
opensim-SC_OLD-2ff9ea3f8038653135c284cc0c93d88690db9a22.tar.gz
opensim-SC_OLD-2ff9ea3f8038653135c284cc0c93d88690db9a22.tar.bz2
opensim-SC_OLD-2ff9ea3f8038653135c284cc0c93d88690db9a22.tar.xz
Fixed a few things pertaining to interfacing with the estate service. Specifically, StoreEstateSettings was not being used anywhere; instead EstatSetting.Save was being called, but that method is a trigger to the DB-layer code directly, which, besides being wrong, was making it impossible to replace the service with a remote connector.
Also added more packing/unpacking code.
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/EstateBan.cs49
-rw-r--r--OpenSim/Framework/EstateSettings.cs101
2 files changed, 144 insertions, 6 deletions
diff --git a/OpenSim/Framework/EstateBan.cs b/OpenSim/Framework/EstateBan.cs
index de9ebf6..ebed794 100644
--- a/OpenSim/Framework/EstateBan.cs
+++ b/OpenSim/Framework/EstateBan.cs
@@ -25,6 +25,10 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31
28using OpenMetaverse; 32using OpenMetaverse;
29 33
30namespace OpenSim.Framework 34namespace OpenSim.Framework
@@ -111,5 +115,50 @@ namespace OpenSim.Framework
111 } 115 }
112 } 116 }
113 117
118 public EstateBan() { }
119
120 public Dictionary<string, object> ToMap()
121 {
122 Dictionary<string, object> map = new Dictionary<string, object>();
123 PropertyInfo[] properties = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
124 foreach (PropertyInfo p in properties)
125 map[p.Name] = p.GetValue(this, null);
126
127 return map;
128 }
129
130 public EstateBan(Dictionary<string, object> map)
131 {
132 foreach (KeyValuePair<string, object> kvp in map)
133 {
134 PropertyInfo p = this.GetType().GetProperty(kvp.Key, BindingFlags.Public | BindingFlags.Instance);
135 if (p == null)
136 continue;
137 object value = p.GetValue(this, null);
138 if (value is String)
139 p.SetValue(this, map[p.Name], null);
140 else if (value is UInt32)
141 p.SetValue(this, UInt32.Parse((string)map[p.Name]), null);
142 else if (value is Boolean)
143 p.SetValue(this, Boolean.Parse((string)map[p.Name]), null);
144 else if (value is UUID)
145 p.SetValue(this, UUID.Parse((string)map[p.Name]), null);
146 }
147 }
148
149
150 /// <summary>
151 /// For debugging
152 /// </summary>
153 /// <returns></returns>
154 public override string ToString()
155 {
156 Dictionary<string, object> map = ToMap();
157 string result = string.Empty;
158 foreach (KeyValuePair<string, object> kvp in map)
159 result += string.Format("{0}: {1} {2}", kvp.Key, kvp.Value, Environment.NewLine);
160
161 return result;
162 }
114 } 163 }
115} 164}
diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs
index dd3e195..328fca4 100644
--- a/OpenSim/Framework/EstateSettings.cs
+++ b/OpenSim/Framework/EstateSettings.cs
@@ -418,17 +418,106 @@ namespace OpenSim.Framework
418 Dictionary<string, object> map = new Dictionary<string, object>(); 418 Dictionary<string, object> map = new Dictionary<string, object>();
419 PropertyInfo[] properties = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); 419 PropertyInfo[] properties = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
420 foreach (PropertyInfo p in properties) 420 foreach (PropertyInfo p in properties)
421 map[p.Name] = p.GetValue(this, null); 421 {
422 422 // EstateBans is a complex type, let's treat it as special
423 if (p.Name == "EstateBans")
424 continue;
425
426 object value = p.GetValue(this, null);
427 if (value != null)
428 {
429 if (p.PropertyType.IsArray) // of UUIDs
430 {
431 if (((Array)value).Length > 0)
432 {
433 string[] args = new string[((Array)value).Length];
434 int index = 0;
435 foreach (object o in (Array)value)
436 args[index++] = o.ToString();
437 map[p.Name] = String.Join(",", args);
438 }
439 }
440 else // simple types
441 map[p.Name] = value;
442 }
443 }
444
445 // EstateBans are special
446 Dictionary<string, object> bans = new Dictionary<string, object>();
447 int i = 0;
448 foreach (EstateBan ban in EstateBans)
449 bans["ban" + i++] = ban.ToMap();
450 map["EstateBans"] = bans;
423 return map; 451 return map;
424 } 452 }
425 453
426 public EstateSettings(Dictionary<string, object> map) 454 /// <summary>
455 /// For debugging
456 /// </summary>
457 /// <returns></returns>
458 public override string ToString()
427 { 459 {
428 PropertyInfo[] properties = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); 460 Dictionary<string, object> map = ToMap();
429 foreach (PropertyInfo p in properties) 461 String result = String.Empty;
430 p.SetValue(this, map[p.Name], null); 462
463 foreach (KeyValuePair<string, object> kvp in map)
464 {
465 if (kvp.Key == "EstateBans")
466 {
467 result += "EstateBans:" + Environment.NewLine;
468 foreach (KeyValuePair<string, object> ban in (Dictionary<string, object>)kvp.Value)
469 result += ban.Value.ToString();
470 }
471 else
472 result += string.Format("{0}: {1} {2}", kvp.Key, kvp.Value.ToString(), Environment.NewLine);
473 }
431 474
475 return result;
476 }
477
478 public EstateSettings(Dictionary<string, object> map)
479 {
480 foreach (KeyValuePair<string, object> kvp in map)
481 {
482 PropertyInfo p = this.GetType().GetProperty(kvp.Key, BindingFlags.Public | BindingFlags.Instance);
483 if (p == null)
484 continue;
485
486 // EstateBans is a complex type, let's treat it as special
487 if (p.Name == "EstateBans")
488 continue;
489
490 if (p.PropertyType.IsArray)
491 {
492 string[] elements = ((string)map[p.Name]).Split(new char[] { ',' });
493 UUID[] uuids = new UUID[elements.Length];
494 int i = 0;
495 foreach (string e in elements)
496 uuids[i++] = new UUID(e);
497 p.SetValue(this, uuids, null);
498 }
499 else
500 {
501 object value = p.GetValue(this, null);
502 if (value is String)
503 p.SetValue(this, map[p.Name], null);
504 else if (value is UInt32)
505 p.SetValue(this, UInt32.Parse((string)map[p.Name]), null);
506 else if (value is Boolean)
507 p.SetValue(this, Boolean.Parse((string)map[p.Name]), null);
508 else if (value is UUID)
509 p.SetValue(this, UUID.Parse((string)map[p.Name]), null);
510 }
511 }
512
513 // EstateBans are special
514 var banData = ((Dictionary<string, object>)map["EstateBans"]).Values;
515 EstateBan[] bans = new EstateBan[banData.Count];
516 int b = 0;
517 foreach (Dictionary<string, object> ban in banData)
518 bans[b++] = new EstateBan(ban);
519 PropertyInfo bansProperty = this.GetType().GetProperty("EstateBans", BindingFlags.Public | BindingFlags.Instance);
520 bansProperty.SetValue(this, bans, null);
432 } 521 }
433 } 522 }
434} 523}