aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/UserAccountService
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/UserAccountService')
-rw-r--r--OpenSim/Services/UserAccountService/UserAccountService.cs107
1 files changed, 88 insertions, 19 deletions
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs
index c14651d..dacfa51 100644
--- a/OpenSim/Services/UserAccountService/UserAccountService.cs
+++ b/OpenSim/Services/UserAccountService/UserAccountService.cs
@@ -29,6 +29,7 @@ using System;
29using System.Reflection; 29using System.Reflection;
30using Nini.Config; 30using Nini.Config;
31using OpenSim.Data; 31using OpenSim.Data;
32using OpenSim.Framework.Console;
32using OpenSim.Services.Interfaces; 33using OpenSim.Services.Interfaces;
33using System.Collections.Generic; 34using System.Collections.Generic;
34using OpenMetaverse; 35using OpenMetaverse;
@@ -37,10 +38,17 @@ namespace OpenSim.Services.UserAccountService
37{ 38{
38 public class UserAccountService : UserAccountServiceBase, IUserAccountService 39 public class UserAccountService : UserAccountServiceBase, IUserAccountService
39 { 40 {
40 public UserAccountService(IConfigSource config) : base(config) 41 public UserAccountService(IConfigSource config)
42 : base(config)
41 { 43 {
44 MainConsole.Instance.Commands.AddCommand("UserService", false,
45 "create user",
46 "create user [<first> [<last> [<pass> [<x> <y> [<email>]]]]]",
47 "Create a new user", HandleCreateUser);
42 } 48 }
43 49
50 #region IUserAccountService
51
44 public UserAccount GetUserAccount(UUID scopeID, string firstName, 52 public UserAccount GetUserAccount(UUID scopeID, string firstName,
45 string lastName) 53 string lastName)
46 { 54 {
@@ -49,14 +57,14 @@ namespace OpenSim.Services.UserAccountService
49 if (scopeID != UUID.Zero) 57 if (scopeID != UUID.Zero)
50 { 58 {
51 d = m_Database.Get( 59 d = m_Database.Get(
52 new string[] {"ScopeID", "FirstName", "LastName"}, 60 new string[] { "ScopeID", "FirstName", "LastName" },
53 new string[] {scopeID.ToString(), firstName, lastName}); 61 new string[] { scopeID.ToString(), firstName, lastName });
54 } 62 }
55 else 63 else
56 { 64 {
57 d = m_Database.Get( 65 d = m_Database.Get(
58 new string[] {"FirstName", "LastName"}, 66 new string[] { "FirstName", "LastName" },
59 new string[] {firstName, lastName}); 67 new string[] { firstName, lastName });
60 } 68 }
61 69
62 if (d.Length < 1) 70 if (d.Length < 1)
@@ -75,12 +83,12 @@ namespace OpenSim.Services.UserAccountService
75 u.Email = d.Data["Email"].ToString(); 83 u.Email = d.Data["Email"].ToString();
76 u.Created = Convert.ToInt32(d.Data["Created"].ToString()); 84 u.Created = Convert.ToInt32(d.Data["Created"].ToString());
77 85
78 string[] URLs = d.Data["ServiceURLs"].ToString().Split(new char[] {' '}); 86 string[] URLs = d.Data["ServiceURLs"].ToString().Split(new char[] { ' ' });
79 u.ServiceURLs = new Dictionary<string, object>(); 87 u.ServiceURLs = new Dictionary<string, object>();
80 88
81 foreach(string url in URLs) 89 foreach (string url in URLs)
82 { 90 {
83 string[] parts = url.Split(new char[] {'='}); 91 string[] parts = url.Split(new char[] { '=' });
84 92
85 if (parts.Length != 2) 93 if (parts.Length != 2)
86 continue; 94 continue;
@@ -101,14 +109,14 @@ namespace OpenSim.Services.UserAccountService
101 if (scopeID != UUID.Zero) 109 if (scopeID != UUID.Zero)
102 { 110 {
103 d = m_Database.Get( 111 d = m_Database.Get(
104 new string[] {"ScopeID", "Email"}, 112 new string[] { "ScopeID", "Email" },
105 new string[] {scopeID.ToString(), email}); 113 new string[] { scopeID.ToString(), email });
106 } 114 }
107 else 115 else
108 { 116 {
109 d = m_Database.Get( 117 d = m_Database.Get(
110 new string[] {"Email"}, 118 new string[] { "Email" },
111 new string[] {email}); 119 new string[] { email });
112 } 120 }
113 121
114 if (d.Length < 1) 122 if (d.Length < 1)
@@ -116,7 +124,7 @@ namespace OpenSim.Services.UserAccountService
116 124
117 return MakeUserAccount(d[0]); 125 return MakeUserAccount(d[0]);
118 } 126 }
119 127
120 public UserAccount GetUserAccount(UUID scopeID, UUID principalID) 128 public UserAccount GetUserAccount(UUID scopeID, UUID principalID)
121 { 129 {
122 UserAccountData[] d; 130 UserAccountData[] d;
@@ -124,14 +132,14 @@ namespace OpenSim.Services.UserAccountService
124 if (scopeID != UUID.Zero) 132 if (scopeID != UUID.Zero)
125 { 133 {
126 d = m_Database.Get( 134 d = m_Database.Get(
127 new string[] {"ScopeID", "PrincipalID"}, 135 new string[] { "ScopeID", "PrincipalID" },
128 new string[] {scopeID.ToString(), principalID.ToString()}); 136 new string[] { scopeID.ToString(), principalID.ToString() });
129 } 137 }
130 else 138 else
131 { 139 {
132 d = m_Database.Get( 140 d = m_Database.Get(
133 new string[] {"PrincipalID"}, 141 new string[] { "PrincipalID" },
134 new string[] {principalID.ToString()}); 142 new string[] { principalID.ToString() });
135 } 143 }
136 144
137 if (d.Length < 1) 145 if (d.Length < 1)
@@ -148,13 +156,13 @@ namespace OpenSim.Services.UserAccountService
148 d.LastName = data.LastName; 156 d.LastName = data.LastName;
149 d.PrincipalID = data.PrincipalID; 157 d.PrincipalID = data.PrincipalID;
150 d.ScopeID = data.ScopeID; 158 d.ScopeID = data.ScopeID;
151 d.Data = new Dictionary<string,string>(); 159 d.Data = new Dictionary<string, string>();
152 d.Data["Email"] = data.Email; 160 d.Data["Email"] = data.Email;
153 d.Data["Created"] = data.Created.ToString(); 161 d.Data["Created"] = data.Created.ToString();
154 162
155 List<string> parts = new List<string>(); 163 List<string> parts = new List<string>();
156 164
157 foreach (KeyValuePair<string,object> kvp in data.ServiceURLs) 165 foreach (KeyValuePair<string, object> kvp in data.ServiceURLs)
158 { 166 {
159 string key = System.Web.HttpUtility.UrlEncode(kvp.Key); 167 string key = System.Web.HttpUtility.UrlEncode(kvp.Key);
160 string val = System.Web.HttpUtility.UrlEncode(kvp.Value.ToString()); 168 string val = System.Web.HttpUtility.UrlEncode(kvp.Value.ToString());
@@ -180,5 +188,66 @@ namespace OpenSim.Services.UserAccountService
180 188
181 return ret; 189 return ret;
182 } 190 }
191
192 #endregion
193
194 #region Console commands
195 /// <summary>
196 /// Create a new user
197 /// </summary>
198 /// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email</param>
199 protected void HandleCreateUser(string module, string[] cmdparams)
200 {
201 string firstName;
202 string lastName;
203 string password;
204 string email;
205 uint regX = 1000;
206 uint regY = 1000;
207
208 // IConfig standalone;
209 // if ((standalone = m_config.Source.Configs["StandAlone"]) != null)
210 // {
211 // regX = (uint)standalone.GetInt("default_location_x", (int)regX);
212 // regY = (uint)standalone.GetInt("default_location_y", (int)regY);
213 // }
214
215
216 // if (cmdparams.Length < 3)
217 // firstName = MainConsole.Instance.CmdPrompt("First name", "Default");
218 // else firstName = cmdparams[2];
219
220 // if (cmdparams.Length < 4)
221 // lastName = MainConsole.Instance.CmdPrompt("Last name", "User");
222 // else lastName = cmdparams[3];
223
224 // if (cmdparams.Length < 5)
225 // password = MainConsole.Instance.PasswdPrompt("Password");
226 // else password = cmdparams[4];
227
228 // if (cmdparams.Length < 6)
229 // regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString()));
230 // else regX = Convert.ToUInt32(cmdparams[5]);
231
232 // if (cmdparams.Length < 7)
233 // regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString()));
234 // else regY = Convert.ToUInt32(cmdparams[6]);
235
236 // if (cmdparams.Length < 8)
237 // email = MainConsole.Instance.CmdPrompt("Email", "");
238 // else email = cmdparams[7];
239
240 // if (null == m_commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName))
241 // {
242 // m_commsManager.UserAdminService.AddUser(firstName, lastName, password, email, regX, regY);
243 // }
244 // else
245 // {
246 // m_log.ErrorFormat("[CONSOLE]: A user with the name {0} {1} already exists!", firstName, lastName);
247 // }
248 //}
249
250 }
251 #endregion
183 } 252 }
184} 253}