clockwerk-opensim – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 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 | |||
28 | using System; |
||
29 | using System.Collections.Generic; |
||
30 | using System.Reflection; |
||
31 | |||
32 | using OpenMetaverse; |
||
33 | |||
34 | namespace OpenSim.Framework |
||
35 | { |
||
36 | public class EstateBan |
||
37 | { |
||
38 | private uint m_estateID = 1; |
||
39 | /// <summary> |
||
40 | /// ID of the estate this ban limits access to. |
||
41 | /// </summary> |
||
42 | public uint EstateID |
||
43 | { |
||
44 | get |
||
45 | { |
||
46 | return m_estateID; |
||
47 | } |
||
48 | set |
||
49 | { |
||
50 | m_estateID = value; |
||
51 | } |
||
52 | } |
||
53 | |||
54 | private UUID m_bannedUserID = UUID.Zero; |
||
55 | /// <summary> |
||
56 | /// ID of the banned user. |
||
57 | /// </summary> |
||
58 | public UUID BannedUserID |
||
59 | { |
||
60 | get |
||
61 | { |
||
62 | return m_bannedUserID; |
||
63 | } |
||
64 | set |
||
65 | { |
||
66 | m_bannedUserID = value; |
||
67 | } |
||
68 | } |
||
69 | |||
70 | private string m_bannedHostAddress = string.Empty; |
||
71 | /// <summary> |
||
72 | /// IP address or domain name of the banned client. |
||
73 | /// </summary> |
||
74 | public string BannedHostAddress |
||
75 | { |
||
76 | get |
||
77 | { |
||
78 | return m_bannedHostAddress; |
||
79 | } |
||
80 | set |
||
81 | { |
||
82 | m_bannedHostAddress = value; |
||
83 | } |
||
84 | } |
||
85 | |||
86 | private string m_bannedHostIPMask = string.Empty; |
||
87 | /// <summary> |
||
88 | /// IP address mask for banning group of client hosts. |
||
89 | /// </summary> |
||
90 | public string BannedHostIPMask |
||
91 | { |
||
92 | get |
||
93 | { |
||
94 | return m_bannedHostIPMask; |
||
95 | } |
||
96 | set |
||
97 | { |
||
98 | m_bannedHostIPMask = value; |
||
99 | } |
||
100 | } |
||
101 | |||
102 | private string m_bannedHostNameMask = string.Empty; |
||
103 | /// <summary> |
||
104 | /// Domain name mask for banning group of client hosts. |
||
105 | /// </summary> |
||
106 | public string BannedHostNameMask |
||
107 | { |
||
108 | get |
||
109 | { |
||
110 | return m_bannedHostNameMask; |
||
111 | } |
||
112 | set |
||
113 | { |
||
114 | m_bannedHostNameMask = value; |
||
115 | } |
||
116 | } |
||
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 | } |
||
163 | } |
||
164 | } |