diff options
Diffstat (limited to 'OpenSim/Services/Interfaces/IUserAccountService.cs')
-rw-r--r-- | OpenSim/Services/Interfaces/IUserAccountService.cs | 195 |
1 files changed, 195 insertions, 0 deletions
diff --git a/OpenSim/Services/Interfaces/IUserAccountService.cs b/OpenSim/Services/Interfaces/IUserAccountService.cs new file mode 100644 index 0000000..2f7702c --- /dev/null +++ b/OpenSim/Services/Interfaces/IUserAccountService.cs | |||
@@ -0,0 +1,195 @@ | |||
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 OpenMetaverse; | ||
31 | |||
32 | using OpenSim.Framework; | ||
33 | |||
34 | namespace OpenSim.Services.Interfaces | ||
35 | { | ||
36 | public class UserAccount | ||
37 | { | ||
38 | public UserAccount() | ||
39 | { | ||
40 | } | ||
41 | |||
42 | public UserAccount(UUID principalID) | ||
43 | { | ||
44 | PrincipalID = principalID; | ||
45 | } | ||
46 | |||
47 | /// <summary> | ||
48 | /// Initializes a new instance of the <see cref="OpenSim.Services.Interfaces.UserAccount"/> class. | ||
49 | /// This method is used by externasl/3rd party management applications that need us to create a | ||
50 | /// random UUID for the new user. | ||
51 | /// </summary> | ||
52 | /// <param name='scopeID'> | ||
53 | /// Scope I. | ||
54 | /// </param> | ||
55 | /// <param name='firstName'> | ||
56 | /// First name. | ||
57 | /// </param> | ||
58 | /// <param name='lastName'> | ||
59 | /// Last name. | ||
60 | /// </param> | ||
61 | /// <param name='email'> | ||
62 | /// Email. | ||
63 | /// </param> | ||
64 | public UserAccount(UUID scopeID, string firstName, string lastName, string email) | ||
65 | { | ||
66 | PrincipalID = UUID.Random(); | ||
67 | ScopeID = scopeID; | ||
68 | FirstName = firstName; | ||
69 | LastName = lastName; | ||
70 | Email = email; | ||
71 | ServiceURLs = new Dictionary<string, object>(); | ||
72 | Created = Util.UnixTimeSinceEpoch(); | ||
73 | } | ||
74 | |||
75 | public UserAccount(UUID scopeID, UUID principalID, string firstName, string lastName, string email) | ||
76 | { | ||
77 | PrincipalID = principalID; | ||
78 | ScopeID = scopeID; | ||
79 | FirstName = firstName; | ||
80 | LastName = lastName; | ||
81 | Email = email; | ||
82 | ServiceURLs = new Dictionary<string, object>(); | ||
83 | Created = Util.UnixTimeSinceEpoch(); | ||
84 | } | ||
85 | |||
86 | public string FirstName; | ||
87 | public string LastName; | ||
88 | public string Email; | ||
89 | public UUID PrincipalID; | ||
90 | public UUID ScopeID; | ||
91 | public int UserLevel; | ||
92 | public int UserFlags; | ||
93 | public string UserTitle; | ||
94 | public Boolean LocalToGrid = true; | ||
95 | |||
96 | public Dictionary<string, object> ServiceURLs; | ||
97 | |||
98 | public int Created; | ||
99 | |||
100 | public string Name | ||
101 | { | ||
102 | get { return FirstName + " " + LastName; } | ||
103 | } | ||
104 | |||
105 | public UserAccount(Dictionary<string, object> kvp) | ||
106 | { | ||
107 | if (kvp.ContainsKey("FirstName")) | ||
108 | FirstName = kvp["FirstName"].ToString(); | ||
109 | if (kvp.ContainsKey("LastName")) | ||
110 | LastName = kvp["LastName"].ToString(); | ||
111 | if (kvp.ContainsKey("Email")) | ||
112 | Email = kvp["Email"].ToString(); | ||
113 | if (kvp.ContainsKey("PrincipalID")) | ||
114 | UUID.TryParse(kvp["PrincipalID"].ToString(), out PrincipalID); | ||
115 | if (kvp.ContainsKey("ScopeID")) | ||
116 | UUID.TryParse(kvp["ScopeID"].ToString(), out ScopeID); | ||
117 | if (kvp.ContainsKey("UserLevel")) | ||
118 | UserLevel = Convert.ToInt32(kvp["UserLevel"].ToString()); | ||
119 | if (kvp.ContainsKey("UserFlags")) | ||
120 | UserFlags = Convert.ToInt32(kvp["UserFlags"].ToString()); | ||
121 | if (kvp.ContainsKey("UserTitle")) | ||
122 | UserTitle = kvp["UserTitle"].ToString(); | ||
123 | if (kvp.ContainsKey("LocalToGrid")) | ||
124 | Boolean.TryParse(kvp["LocalToGrid"].ToString(), out LocalToGrid); | ||
125 | |||
126 | if (kvp.ContainsKey("Created")) | ||
127 | Created = Convert.ToInt32(kvp["Created"].ToString()); | ||
128 | if (kvp.ContainsKey("ServiceURLs") && kvp["ServiceURLs"] != null) | ||
129 | { | ||
130 | ServiceURLs = new Dictionary<string, object>(); | ||
131 | string str = kvp["ServiceURLs"].ToString(); | ||
132 | if (str != string.Empty) | ||
133 | { | ||
134 | string[] parts = str.Split(new char[] { ';' }); | ||
135 | // Dictionary<string, object> dic = new Dictionary<string, object>(); | ||
136 | foreach (string s in parts) | ||
137 | { | ||
138 | string[] parts2 = s.Split(new char[] { '*' }); | ||
139 | if (parts2.Length == 2) | ||
140 | ServiceURLs[parts2[0]] = parts2[1]; | ||
141 | } | ||
142 | } | ||
143 | } | ||
144 | } | ||
145 | |||
146 | public Dictionary<string, object> ToKeyValuePairs() | ||
147 | { | ||
148 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
149 | result["FirstName"] = FirstName; | ||
150 | result["LastName"] = LastName; | ||
151 | result["Email"] = Email; | ||
152 | result["PrincipalID"] = PrincipalID.ToString(); | ||
153 | result["ScopeID"] = ScopeID.ToString(); | ||
154 | result["Created"] = Created.ToString(); | ||
155 | result["UserLevel"] = UserLevel.ToString(); | ||
156 | result["UserFlags"] = UserFlags.ToString(); | ||
157 | result["UserTitle"] = UserTitle; | ||
158 | result["LocalToGrid"] = LocalToGrid.ToString(); | ||
159 | |||
160 | string str = string.Empty; | ||
161 | foreach (KeyValuePair<string, object> kvp in ServiceURLs) | ||
162 | { | ||
163 | str += kvp.Key + "*" + (kvp.Value == null ? "" : kvp.Value) + ";"; | ||
164 | } | ||
165 | result["ServiceURLs"] = str; | ||
166 | |||
167 | return result; | ||
168 | } | ||
169 | |||
170 | }; | ||
171 | |||
172 | public interface IUserAccountService | ||
173 | { | ||
174 | UserAccount GetUserAccount(UUID scopeID, UUID userID); | ||
175 | UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName); | ||
176 | UserAccount GetUserAccount(UUID scopeID, string Email); | ||
177 | |||
178 | /// <summary> | ||
179 | /// Returns the list of avatars that matches both the search criterion and the scope ID passed | ||
180 | /// </summary> | ||
181 | /// <param name="scopeID"></param> | ||
182 | /// <param name="query"></param> | ||
183 | /// <returns></returns> | ||
184 | List<UserAccount> GetUserAccounts(UUID scopeID, string query); | ||
185 | |||
186 | /// <summary> | ||
187 | /// Store the data given, wich replaces the stored data, therefore must be complete. | ||
188 | /// </summary> | ||
189 | /// <param name="data"></param> | ||
190 | /// <returns></returns> | ||
191 | bool StoreUserAccount(UserAccount data); | ||
192 | |||
193 | void InvalidateCache(UUID userID); | ||
194 | } | ||
195 | } | ||