aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/IUserAccountData.cs5
-rw-r--r--OpenSim/Data/MSSQL/MSSQLUserAccountData.cs7
-rw-r--r--OpenSim/Data/MySQL/MySQLUserAccountData.cs38
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs10
-rw-r--r--OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs25
-rw-r--r--OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs15
-rw-r--r--OpenSim/Services/Interfaces/IUserAccountService.cs (renamed from OpenSim/Services/Interfaces/IUserService.cs)8
-rw-r--r--OpenSim/Services/UserAccountService/UserAccountService.cs119
8 files changed, 155 insertions, 72 deletions
diff --git a/OpenSim/Data/IUserAccountData.cs b/OpenSim/Data/IUserAccountData.cs
index 5ebe7d3..6ee5995 100644
--- a/OpenSim/Data/IUserAccountData.cs
+++ b/OpenSim/Data/IUserAccountData.cs
@@ -38,7 +38,7 @@ namespace OpenSim.Data
38 public UUID ScopeID; 38 public UUID ScopeID;
39 public string FirstName; 39 public string FirstName;
40 public string LastName; 40 public string LastName;
41 public Dictionary<string, object> Data; 41 public Dictionary<string, string> Data;
42 } 42 }
43 43
44 /// <summary> 44 /// <summary>
@@ -47,6 +47,7 @@ namespace OpenSim.Data
47 public interface IUserAccountData 47 public interface IUserAccountData
48 { 48 {
49 UserAccountData[] Get(string[] fields, string[] values); 49 UserAccountData[] Get(string[] fields, string[] values);
50 bool Store(UserAccountData data, UUID principalID, string token); 50 bool Store(UserAccountData data);
51 UserAccountData[] GetUsers(UUID scopeID, string query);
51 } 52 }
52} 53}
diff --git a/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs b/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs
index 01750d8..01c64dc 100644
--- a/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs
@@ -65,7 +65,7 @@ namespace OpenSim.Data.MSSQL
65 public UserAccountData Get(UUID principalID, UUID scopeID) 65 public UserAccountData Get(UUID principalID, UUID scopeID)
66 { 66 {
67 UserAccountData ret = new UserAccountData(); 67 UserAccountData ret = new UserAccountData();
68 ret.Data = new Dictionary<string, object>(); 68 ret.Data = new Dictionary<string, string>();
69 69
70 string sql = string.Format("select * from {0} where UUID = @principalID", m_Realm); 70 string sql = string.Format("select * from {0} where UUID = @principalID", m_Realm);
71 if (scopeID != UUID.Zero) 71 if (scopeID != UUID.Zero)
@@ -194,5 +194,10 @@ namespace OpenSim.Data.MSSQL
194 { 194 {
195 return null; 195 return null;
196 } 196 }
197
198 public UserAccountData[] GetUsers(UUID scopeID, string query)
199 {
200 return null;
201 }
197 } 202 }
198} 203}
diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs
index e2ce6d1..aa69d68 100644
--- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs
@@ -42,9 +42,43 @@ namespace OpenSim.Data.MySQL
42 { 42 {
43 } 43 }
44 44
45 public bool Store(UserAccountData data, UUID principalID, string token) 45 public UserAccountData[] GetUsers(UUID scopeID, string query)
46 { 46 {
47 return Store(data); 47 string[] words = query.Split(new char[] {' '});
48
49 for (int i = 0 ; i < words.Length ; i++)
50 {
51 if (words[i].Length < 3)
52 {
53 if (i != words.Length - 1)
54 Array.Copy(words, i + 1, words, i, words.Length - i - 1);
55 Array.Resize(ref words, words.Length - 1);
56 }
57 }
58
59 if (words.Length == 0)
60 return new UserAccountData[0];
61
62 if (words.Length > 2)
63 return new UserAccountData[0];
64
65 MySqlCommand cmd = new MySqlCommand();
66
67 if (words.Length == 1)
68 {
69 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?search or LastName like ?search)", m_Realm);
70 cmd.Parameters.AddWithValue("?search", "%" + words[0] + "%");
71 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
72 }
73 else
74 {
75 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst or LastName like ?searchLast)", m_Realm);
76 cmd.Parameters.AddWithValue("?searchFirst", "%" + words[0] + "%");
77 cmd.Parameters.AddWithValue("?searchLast", "%" + words[1] + "%");
78 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
79 }
80
81 return DoQuery(cmd);
48 } 82 }
49 } 83 }
50} 84}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs
index ce8c3a5..f55de5a 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs
@@ -159,15 +159,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
159 159
160 // Update all updatable fields 160 // Update all updatable fields
161 // 161 //
162 public bool SetUserAccount(UserAccount data) 162 public bool StoreUserAccount(UserAccount data)
163 { 163 {
164 return m_UserService.SetUserAccount(data); 164 return m_UserService.StoreUserAccount(data);
165 }
166
167 // Creates a user data record
168 public bool CreateUserAccount(UserAccount data)
169 {
170 return m_UserService.CreateUserAccount(data);
171 } 165 }
172 166
173 #endregion 167 #endregion
diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
index a92148c..544ffea 100644
--- a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
@@ -85,10 +85,8 @@ namespace OpenSim.Server.Handlers.UserAccounts
85 return GetAccount(request); 85 return GetAccount(request);
86 case "getaccounts": 86 case "getaccounts":
87 return GetAccounts(request); 87 return GetAccounts(request);
88 case "createaccount":
89 return CreateAccount(request);
90 case "setaccount": 88 case "setaccount":
91 return SetAccount(request); 89 return StoreAccount(request);
92 } 90 }
93 m_log.DebugFormat("[PRESENCE HANDLER]: unknown method request: {0}", method); 91 m_log.DebugFormat("[PRESENCE HANDLER]: unknown method request: {0}", method);
94 } 92 }
@@ -174,24 +172,7 @@ namespace OpenSim.Server.Handlers.UserAccounts
174 return encoding.GetBytes(xmlString); 172 return encoding.GetBytes(xmlString);
175 } 173 }
176 174
177 byte[] CreateAccount(Dictionary<string, object> request) 175 byte[] StoreAccount(Dictionary<string, object> request)
178 {
179 if (!request.ContainsKey("account"))
180 return FailureResult();
181 if (request["account"] == null)
182 return FailureResult();
183 if (!(request["account"] is Dictionary<string, object>))
184 return FailureResult();
185
186 UserAccount account = new UserAccount((Dictionary<string, object>) request["account"]);
187
188 if (m_UserAccountService.CreateUserAccount(account))
189 return SuccessResult();
190
191 return FailureResult();
192 }
193
194 byte[] SetAccount(Dictionary<string, object> request)
195 { 176 {
196 if (!request.ContainsKey("account")) 177 if (!request.ContainsKey("account"))
197 return FailureResult(); 178 return FailureResult();
@@ -202,7 +183,7 @@ namespace OpenSim.Server.Handlers.UserAccounts
202 183
203 UserAccount account = new UserAccount((Dictionary<string, object>)request["account"]); 184 UserAccount account = new UserAccount((Dictionary<string, object>)request["account"]);
204 185
205 if (m_UserAccountService.SetUserAccount(account)) 186 if (m_UserAccountService.StoreUserAccount(account))
206 return SuccessResult(); 187 return SuccessResult();
207 188
208 return FailureResult(); 189 return FailureResult();
diff --git a/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs
index d4b906a..46313d9 100644
--- a/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs
+++ b/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs
@@ -186,7 +186,7 @@ namespace OpenSim.Services.Connectors
186 return accounts; 186 return accounts;
187 } 187 }
188 188
189 public bool SetUserAccount(UserAccount data) 189 public bool StoreUserAccount(UserAccount data)
190 { 190 {
191 Dictionary<string, object> sendData = new Dictionary<string, object>(); 191 Dictionary<string, object> sendData = new Dictionary<string, object>();
192 //sendData["SCOPEID"] = scopeID.ToString(); 192 //sendData["SCOPEID"] = scopeID.ToString();
@@ -199,19 +199,6 @@ namespace OpenSim.Services.Connectors
199 return SendAndGetBoolReply(sendData); 199 return SendAndGetBoolReply(sendData);
200 } 200 }
201 201
202 public bool CreateUserAccount(UserAccount data)
203 {
204 Dictionary<string, object> sendData = new Dictionary<string, object>();
205 //sendData["SCOPEID"] = scopeID.ToString();
206 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
207 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
208 sendData["METHOD"] = "createaccount";
209
210 sendData["account"] = data.ToKeyValuePairs();
211
212 return SendAndGetBoolReply(sendData);
213 }
214
215 private UserAccount SendAndGetReply(Dictionary<string, object> sendData) 202 private UserAccount SendAndGetReply(Dictionary<string, object> sendData)
216 { 203 {
217 string reply = string.Empty; 204 string reply = string.Empty;
diff --git a/OpenSim/Services/Interfaces/IUserService.cs b/OpenSim/Services/Interfaces/IUserAccountService.cs
index 1bdaaab..b2d5d48 100644
--- a/OpenSim/Services/Interfaces/IUserService.cs
+++ b/OpenSim/Services/Interfaces/IUserAccountService.cs
@@ -95,11 +95,9 @@ namespace OpenSim.Services.Interfaces
95 // 95 //
96 List<UserAccount> GetUserAccounts(UUID scopeID, string query); 96 List<UserAccount> GetUserAccounts(UUID scopeID, string query);
97 97
98 // Update all updatable fields 98 // Store the data given, wich replaces the sotred data, therefore
99 // must be complete.
99 // 100 //
100 bool SetUserAccount(UserAccount data); 101 bool StoreUserAccount(UserAccount data);
101
102 // Creates a user data record
103 bool CreateUserAccount(UserAccount data);
104 } 102 }
105} 103}
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs
index 0270f9d..c14651d 100644
--- a/OpenSim/Services/UserAccountService/UserAccountService.cs
+++ b/OpenSim/Services/UserAccountService/UserAccountService.cs
@@ -62,40 +62,123 @@ namespace OpenSim.Services.UserAccountService
62 if (d.Length < 1) 62 if (d.Length < 1)
63 return null; 63 return null;
64 64
65 return MakeUserAccount(d[0]);
66 }
67
68 private UserAccount MakeUserAccount(UserAccountData d)
69 {
65 UserAccount u = new UserAccount(); 70 UserAccount u = new UserAccount();
66 u.FirstName = d[0].FirstName; 71 u.FirstName = d.FirstName;
67 u.LastName = d[0].LastName; 72 u.LastName = d.LastName;
68 u.PrincipalID = d[0].PrincipalID; 73 u.PrincipalID = d.PrincipalID;
69 u.ScopeID = d[0].ScopeID; 74 u.ScopeID = d.ScopeID;
70 u.Email = d[0].Data["Email"].ToString(); 75 u.Email = d.Data["Email"].ToString();
71 u.Created = Convert.ToInt32(d[0].Data["Created"].ToString()); 76 u.Created = Convert.ToInt32(d.Data["Created"].ToString());
72 77
73 return null; 78 string[] URLs = d.Data["ServiceURLs"].ToString().Split(new char[] {' '});
79 u.ServiceURLs = new Dictionary<string, object>();
80
81 foreach(string url in URLs)
82 {
83 string[] parts = url.Split(new char[] {'='});
84
85 if (parts.Length != 2)
86 continue;
87
88 string name = System.Web.HttpUtility.UrlDecode(parts[0]);
89 string val = System.Web.HttpUtility.UrlDecode(parts[1]);
90
91 u.ServiceURLs[name] = val;
92 }
93
94 return u;
74 } 95 }
75 96
76 public UserAccount GetUserAccount(UUID scopeID, string email) 97 public UserAccount GetUserAccount(UUID scopeID, string email)
77 { 98 {
78 return null; 99 UserAccountData[] d;
100
101 if (scopeID != UUID.Zero)
102 {
103 d = m_Database.Get(
104 new string[] {"ScopeID", "Email"},
105 new string[] {scopeID.ToString(), email});
106 }
107 else
108 {
109 d = m_Database.Get(
110 new string[] {"Email"},
111 new string[] {email});
112 }
113
114 if (d.Length < 1)
115 return null;
116
117 return MakeUserAccount(d[0]);
79 } 118 }
80 119
81 public UserAccount GetUserAccount(UUID scopeID, UUID userID) 120 public UserAccount GetUserAccount(UUID scopeID, UUID principalID)
82 { 121 {
83 return null; 122 UserAccountData[] d;
84 }
85 123
86 public bool SetUserAccount(UserAccount data) 124 if (scopeID != UUID.Zero)
87 { 125 {
88 return false; 126 d = m_Database.Get(
127 new string[] {"ScopeID", "PrincipalID"},
128 new string[] {scopeID.ToString(), principalID.ToString()});
129 }
130 else
131 {
132 d = m_Database.Get(
133 new string[] {"PrincipalID"},
134 new string[] {principalID.ToString()});
135 }
136
137 if (d.Length < 1)
138 return null;
139
140 return MakeUserAccount(d[0]);
89 } 141 }
90 142
91 public bool CreateUserAccount(UserAccount data) 143 public bool StoreUserAccount(UserAccount data)
92 { 144 {
93 return false; 145 UserAccountData d = new UserAccountData();
146
147 d.FirstName = data.FirstName;
148 d.LastName = data.LastName;
149 d.PrincipalID = data.PrincipalID;
150 d.ScopeID = data.ScopeID;
151 d.Data = new Dictionary<string,string>();
152 d.Data["Email"] = data.Email;
153 d.Data["Created"] = data.Created.ToString();
154
155 List<string> parts = new List<string>();
156
157 foreach (KeyValuePair<string,object> kvp in data.ServiceURLs)
158 {
159 string key = System.Web.HttpUtility.UrlEncode(kvp.Key);
160 string val = System.Web.HttpUtility.UrlEncode(kvp.Value.ToString());
161 parts.Add(key + "=" + val);
162 }
163
164 d.Data["ServiceURLs"] = string.Join(" ", parts.ToArray());
165
166 return m_Database.Store(d);
94 } 167 }
95 168
96 public List<UserAccount> GetUserAccounts(UUID scopeID, string query) 169 public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
97 { 170 {
98 return null; 171 UserAccountData[] d = m_Database.GetUsers(scopeID, query);
172
173 if (d == null)
174 return new List<UserAccount>();
175
176 List<UserAccount> ret = new List<UserAccount>();
177
178 foreach (UserAccountData data in d)
179 ret.Add(MakeUserAccount(data));
180
181 return ret;
99 } 182 }
100 } 183 }
101} 184}