aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLGridData.cs17
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLUserData.cs27
-rw-r--r--OpenSim/Grid/UserServer/Main.cs2
-rw-r--r--OpenSim/Grid/UserServer/UserManager.cs36
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1UserServices.cs48
5 files changed, 110 insertions, 20 deletions
diff --git a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs
index 930b3f4..4d65ee9 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs
@@ -176,20 +176,24 @@ namespace OpenSim.Framework.Data.MySQL
176 public List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) 176 public List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query)
177 { 177 {
178 List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>(); 178 List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>();
179
180 System.Text.RegularExpressions.Regex objAlphaNumericPattern = new System.Text.RegularExpressions.Regex("[^a-zA-Z0-9]");
181
179 string[] querysplit; 182 string[] querysplit;
180 querysplit = query.Split(' '); 183 querysplit = query.Split(' ');
181 if (querysplit.Length == 2) 184 if (querysplit.Length == 2)
182 { 185 {
186 Dictionary<string, string> param = new Dictionary<string, string>();
187 param["?first"] = objAlphaNumericPattern.Replace(querysplit[0],"") + "%";
188 param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], "") + "%";
183 try 189 try
184 { 190 {
185 lock (database) 191 lock (database)
186 { 192 {
187 Dictionary<string, string> param = new Dictionary<string, string>(); 193
188 param["?first"] = querysplit[0];
189 param["?second"] = querysplit[1];
190 194
191 IDbCommand result = 195 IDbCommand result =
192 database.Query("SELECT UUID,username,surname FROM users WHERE username = ?first AND lastname = ?second", param); 196 database.Query("SELECT UUID,username,surname FROM users WHERE username like ?first AND lastname like ?second LIMIT 100", param);
193 IDataReader reader = result.ExecuteReader(); 197 IDataReader reader = result.ExecuteReader();
194 198
195 199
@@ -224,11 +228,10 @@ namespace OpenSim.Framework.Data.MySQL
224 lock (database) 228 lock (database)
225 { 229 {
226 Dictionary<string, string> param = new Dictionary<string, string>(); 230 Dictionary<string, string> param = new Dictionary<string, string>();
227 param["?first"] = querysplit[0]; 231 param["?first"] = objAlphaNumericPattern.Replace(querysplit[0],"") + "%";
228 param["?second"] = querysplit[1];
229 232
230 IDbCommand result = 233 IDbCommand result =
231 database.Query("SELECT UUID,username,surname FROM users WHERE username = ?first OR lastname = ?second", param); 234 database.Query("SELECT UUID,username,surname FROM users WHERE username like ?first OR lastname like ?second", param);
232 IDataReader reader = result.ExecuteReader(); 235 IDataReader reader = result.ExecuteReader();
233 236
234 237
diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs
index 3ae1fba..3138911 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs
@@ -110,31 +110,35 @@ namespace OpenSim.Framework.Data.MySQL
110 public List<OpenSim.Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) 110 public List<OpenSim.Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query)
111 { 111 {
112 List<OpenSim.Framework.AvatarPickerAvatar> returnlist = new List<OpenSim.Framework.AvatarPickerAvatar>(); 112 List<OpenSim.Framework.AvatarPickerAvatar> returnlist = new List<OpenSim.Framework.AvatarPickerAvatar>();
113
114 System.Text.RegularExpressions.Regex objAlphaNumericPattern = new System.Text.RegularExpressions.Regex("[^a-zA-Z0-9]");
115
113 string[] querysplit; 116 string[] querysplit;
114 querysplit = query.Split(' '); 117 querysplit = query.Split(' ');
115 if (querysplit.Length == 2) 118 if (querysplit.Length == 2)
116 { 119 {
120 Dictionary<string, string> param = new Dictionary<string, string>();
121 param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], "") + "%";
122 param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], "") + "%";
117 try 123 try
118 { 124 {
119 lock (database) 125 lock (database)
120 { 126 {
121 Dictionary<string, string> param = new Dictionary<string, string>(); 127
122 param["?first"] = querysplit[0];
123 param["?second"] = querysplit[1];
124 128
125 IDbCommand result = 129 IDbCommand result =
126 database.Query("SELECT UUID,username,surname FROM users WHERE username = ?first AND lastname = ?second", param); 130 database.Query("SELECT UUID,username,lastname FROM users WHERE username like ?first AND lastname like ?second LIMIT 100", param);
127 IDataReader reader = result.ExecuteReader(); 131 IDataReader reader = result.ExecuteReader();
128 132
129 133
130 while (reader.Read()) 134 while (reader.Read())
131 { 135 {
132 OpenSim.Framework.AvatarPickerAvatar user = new OpenSim.Framework.AvatarPickerAvatar(); 136 OpenSim.Framework.AvatarPickerAvatar user = new OpenSim.Framework.AvatarPickerAvatar();
133 user.AvatarID = new LLUUID((string)reader["UUID"]); 137 user.AvatarID = new LLUUID((string)reader["UUID"]);
134 user.firstName = (string)reader["username"]; 138 user.firstName = (string)reader["username"];
135 user.lastName = (string)reader["surname"]; 139 user.lastName = (string)reader["lastname"];
136 returnlist.Add(user); 140 returnlist.Add(user);
137 141
138 } 142 }
139 reader.Close(); 143 reader.Close();
140 result.Dispose(); 144 result.Dispose();
@@ -148,7 +152,7 @@ namespace OpenSim.Framework.Data.MySQL
148 } 152 }
149 153
150 154
151 155
152 } 156 }
153 else if (querysplit.Length == 1) 157 else if (querysplit.Length == 1)
154 { 158 {
@@ -158,11 +162,10 @@ namespace OpenSim.Framework.Data.MySQL
158 lock (database) 162 lock (database)
159 { 163 {
160 Dictionary<string, string> param = new Dictionary<string, string>(); 164 Dictionary<string, string> param = new Dictionary<string, string>();
161 param["?first"] = querysplit[0]; 165 param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], "") + "%";
162 param["?second"] = querysplit[1];
163 166
164 IDbCommand result = 167 IDbCommand result =
165 database.Query("SELECT UUID,username,surname FROM users WHERE username = ?first OR lastname = ?second", param); 168 database.Query("SELECT UUID,username,lastname FROM users WHERE username like ?first OR lastname like ?first LIMIT 100", param);
166 IDataReader reader = result.ExecuteReader(); 169 IDataReader reader = result.ExecuteReader();
167 170
168 171
@@ -171,7 +174,7 @@ namespace OpenSim.Framework.Data.MySQL
171 OpenSim.Framework.AvatarPickerAvatar user = new OpenSim.Framework.AvatarPickerAvatar(); 174 OpenSim.Framework.AvatarPickerAvatar user = new OpenSim.Framework.AvatarPickerAvatar();
172 user.AvatarID = new LLUUID((string)reader["UUID"]); 175 user.AvatarID = new LLUUID((string)reader["UUID"]);
173 user.firstName = (string)reader["username"]; 176 user.firstName = (string)reader["username"];
174 user.lastName = (string)reader["surname"]; 177 user.lastName = (string)reader["lastname"];
175 returnlist.Add(user); 178 returnlist.Add(user);
176 179
177 } 180 }
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index c834690..634698e 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -98,6 +98,8 @@ namespace OpenSim.Grid.UserServer
98 98
99 httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName); 99 httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName);
100 httpServer.AddXmlRPCHandler("get_user_by_uuid", m_userManager.XmlRPCGetUserMethodUUID); 100 httpServer.AddXmlRPCHandler("get_user_by_uuid", m_userManager.XmlRPCGetUserMethodUUID);
101 httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", m_userManager.XmlRPCGetAvatarPickerAvatar);
102
101 103
102 httpServer.AddStreamHandler( 104 httpServer.AddStreamHandler(
103 new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod)); 105 new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod));
diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs
index 58e9677..16eedcd 100644
--- a/OpenSim/Grid/UserServer/UserManager.cs
+++ b/OpenSim/Grid/UserServer/UserManager.cs
@@ -27,6 +27,7 @@
27*/ 27*/
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic;
30using libsecondlife; 31using libsecondlife;
31using Nwc.XmlRpc; 32using Nwc.XmlRpc;
32using OpenSim.Framework; 33using OpenSim.Framework;
@@ -70,6 +71,24 @@ namespace OpenSim.Grid.UserServer
70 return response; 71 return response;
71 } 72 }
72 73
74 public XmlRpcResponse AvatarPickerListtoXmlRPCResponse(LLUUID queryID, List<AvatarPickerAvatar> returnUsers)
75 {
76 XmlRpcResponse response = new XmlRpcResponse();
77 Hashtable responseData = new Hashtable();
78 // Query Result Information
79 responseData["queryid"] = (string)queryID.ToStringHyphenated();
80 responseData["avcount"] = (string)returnUsers.Count.ToString();
81
82 for (int i = 0; i < returnUsers.Count; i++)
83 {
84 responseData["avatarid" + i.ToString()] = returnUsers[i].AvatarID.ToStringHyphenated();
85 responseData["firstname" + i.ToString()] = returnUsers[i].firstName;
86 responseData["lastname" + i.ToString()] = returnUsers[i].lastName;
87 }
88 response.Value = responseData;
89
90 return response;
91 }
73 /// <summary> 92 /// <summary>
74 /// Converts a user profile to an XML element which can be returned 93 /// Converts a user profile to an XML element which can be returned
75 /// </summary> 94 /// </summary>
@@ -113,6 +132,23 @@ namespace OpenSim.Grid.UserServer
113 132
114 #region XMLRPC User Methods 133 #region XMLRPC User Methods
115 134
135 public XmlRpcResponse XmlRPCGetAvatarPickerAvatar(XmlRpcRequest request)
136 {
137 XmlRpcResponse response = new XmlRpcResponse();
138 Hashtable requestData = (Hashtable)request.Params[0];
139 List<AvatarPickerAvatar> returnAvatar = new List<AvatarPickerAvatar>();
140 LLUUID queryID = new LLUUID(LLUUID.Zero.ToStringHyphenated());
141
142 if (requestData.Contains("avquery") && requestData.Contains("queryid"))
143 {
144 queryID = new LLUUID((string)requestData["queryid"]);
145 returnAvatar = GenerateAgentPickerRequestResponse(queryID,(string)requestData["avquery"]);
146 }
147
148 Console.WriteLine("[AVATARINFO]: Servicing Avatar Query: " + (string)requestData["avquery"]);
149 return AvatarPickerListtoXmlRPCResponse(queryID,returnAvatar);
150 }
151
116 public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request) 152 public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request)
117 { 153 {
118 XmlRpcResponse response = new XmlRpcResponse(); 154 XmlRpcResponse response = new XmlRpcResponse();
diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
index 475066e..ed77e20 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
@@ -80,6 +80,34 @@ namespace OpenSim.Region.Communications.OGS1
80 return userData; 80 return userData;
81 } 81 }
82 82
83 public List<AvatarPickerAvatar> ConvertXMLRPCDataToAvatarPickerList(LLUUID queryID,Hashtable data)
84 {
85 List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>();
86 int pickercount = Convert.ToInt32((string)data["avcount"]);
87 LLUUID respqueryID = new LLUUID((string)data["queryid"]);
88 if (queryID == respqueryID)
89 {
90 for (int i = 0; i < pickercount; i++)
91 {
92 AvatarPickerAvatar apicker = new AvatarPickerAvatar();
93 LLUUID avatarID = new LLUUID((string)data["avatarid" + i.ToString()]);
94 string firstname = (string)data["firstname" + i.ToString()];
95 string lastname = (string)data["lastname" + i.ToString()];
96 apicker.AvatarID = avatarID;
97 apicker.firstName = firstname;
98 apicker.lastName = lastname;
99 pickerlist.Add(apicker);
100 }
101 }
102 else
103 {
104 MainLog.Instance.Warn("INTERGRID", "Got invalid queryID from userServer");
105 }
106 return pickerlist;
107
108 }
109
110
83 public UserProfileData GetUserProfile(string firstName, string lastName) 111 public UserProfileData GetUserProfile(string firstName, string lastName)
84 { 112 {
85 return GetUserProfile(firstName + " " + lastName); 113 return GetUserProfile(firstName + " " + lastName);
@@ -89,7 +117,25 @@ namespace OpenSim.Region.Communications.OGS1
89 public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID queryID, string query) 117 public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID queryID, string query)
90 { 118 {
91 List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>(); 119 List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>();
92 120 System.Text.RegularExpressions.Regex objAlphaNumericPattern = new System.Text.RegularExpressions.Regex("[^a-zA-Z0-9 ]");
121 try
122 {
123 Hashtable param = new Hashtable();
124 param["queryid"] = (string)queryID.ToStringHyphenated();
125 param["avquery"] = objAlphaNumericPattern.Replace(query, "");
126 IList parameters = new ArrayList();
127 parameters.Add(param);
128 XmlRpcRequest req = new XmlRpcRequest("get_avatar_picker_avatar", parameters);
129 XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000);
130 Hashtable respData = (Hashtable)resp.Value;
131 pickerlist = ConvertXMLRPCDataToAvatarPickerList(queryID,respData);
132 }
133 catch (WebException e)
134 {
135 MainLog.Instance.Warn("Error when trying to fetch Avatar Picker Response: " +
136 e.Message);
137 // Return Empty picker list (no results)
138 }
93 return pickerlist; 139 return pickerlist;
94 } 140 }
95 public UserProfileData GetUserProfile(string name) 141 public UserProfileData GetUserProfile(string name)