Merge branch 'presence-refactor' of ssh://diva@opensimulator.org/var/git/opensim into presence-refactor
commit
c664307126
|
@ -38,7 +38,7 @@ namespace OpenSim.Data
|
|||
public UUID ScopeID;
|
||||
public string FirstName;
|
||||
public string LastName;
|
||||
public Dictionary<string, object> Data;
|
||||
public Dictionary<string, string> Data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -47,6 +47,7 @@ namespace OpenSim.Data
|
|||
public interface IUserAccountData
|
||||
{
|
||||
UserAccountData[] Get(string[] fields, string[] values);
|
||||
bool Store(UserAccountData data, UUID principalID, string token);
|
||||
bool Store(UserAccountData data);
|
||||
UserAccountData[] GetUsers(UUID scopeID, string query);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace OpenSim.Data.MSSQL
|
|||
public UserAccountData Get(UUID principalID, UUID scopeID)
|
||||
{
|
||||
UserAccountData ret = new UserAccountData();
|
||||
ret.Data = new Dictionary<string, object>();
|
||||
ret.Data = new Dictionary<string, string>();
|
||||
|
||||
string sql = string.Format("select * from {0} where UUID = @principalID", m_Realm);
|
||||
if (scopeID != UUID.Zero)
|
||||
|
@ -194,5 +194,10 @@ namespace OpenSim.Data.MSSQL
|
|||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public UserAccountData[] GetUsers(UUID scopeID, string query)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,9 +42,43 @@ namespace OpenSim.Data.MySQL
|
|||
{
|
||||
}
|
||||
|
||||
public bool Store(UserAccountData data, UUID principalID, string token)
|
||||
public UserAccountData[] GetUsers(UUID scopeID, string query)
|
||||
{
|
||||
return Store(data);
|
||||
string[] words = query.Split(new char[] {' '});
|
||||
|
||||
for (int i = 0 ; i < words.Length ; i++)
|
||||
{
|
||||
if (words[i].Length < 3)
|
||||
{
|
||||
if (i != words.Length - 1)
|
||||
Array.Copy(words, i + 1, words, i, words.Length - i - 1);
|
||||
Array.Resize(ref words, words.Length - 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (words.Length == 0)
|
||||
return new UserAccountData[0];
|
||||
|
||||
if (words.Length > 2)
|
||||
return new UserAccountData[0];
|
||||
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
|
||||
if (words.Length == 1)
|
||||
{
|
||||
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);
|
||||
cmd.Parameters.AddWithValue("?search", "%" + words[0] + "%");
|
||||
cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
cmd.Parameters.AddWithValue("?searchFirst", "%" + words[0] + "%");
|
||||
cmd.Parameters.AddWithValue("?searchLast", "%" + words[1] + "%");
|
||||
cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
|
||||
}
|
||||
|
||||
return DoQuery(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -159,15 +159,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
|
|||
|
||||
// Update all updatable fields
|
||||
//
|
||||
public bool SetUserAccount(UserAccount data)
|
||||
public bool StoreUserAccount(UserAccount data)
|
||||
{
|
||||
return m_UserService.SetUserAccount(data);
|
||||
}
|
||||
|
||||
// Creates a user data record
|
||||
public bool CreateUserAccount(UserAccount data)
|
||||
{
|
||||
return m_UserService.CreateUserAccount(data);
|
||||
return m_UserService.StoreUserAccount(data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -85,10 +85,8 @@ namespace OpenSim.Server.Handlers.UserAccounts
|
|||
return GetAccount(request);
|
||||
case "getaccounts":
|
||||
return GetAccounts(request);
|
||||
case "createaccount":
|
||||
return CreateAccount(request);
|
||||
case "setaccount":
|
||||
return SetAccount(request);
|
||||
return StoreAccount(request);
|
||||
}
|
||||
m_log.DebugFormat("[PRESENCE HANDLER]: unknown method request: {0}", method);
|
||||
}
|
||||
|
@ -174,24 +172,7 @@ namespace OpenSim.Server.Handlers.UserAccounts
|
|||
return encoding.GetBytes(xmlString);
|
||||
}
|
||||
|
||||
byte[] CreateAccount(Dictionary<string, object> request)
|
||||
{
|
||||
if (!request.ContainsKey("account"))
|
||||
return FailureResult();
|
||||
if (request["account"] == null)
|
||||
return FailureResult();
|
||||
if (!(request["account"] is Dictionary<string, object>))
|
||||
return FailureResult();
|
||||
|
||||
UserAccount account = new UserAccount((Dictionary<string, object>) request["account"]);
|
||||
|
||||
if (m_UserAccountService.CreateUserAccount(account))
|
||||
return SuccessResult();
|
||||
|
||||
return FailureResult();
|
||||
}
|
||||
|
||||
byte[] SetAccount(Dictionary<string, object> request)
|
||||
byte[] StoreAccount(Dictionary<string, object> request)
|
||||
{
|
||||
if (!request.ContainsKey("account"))
|
||||
return FailureResult();
|
||||
|
@ -202,7 +183,7 @@ namespace OpenSim.Server.Handlers.UserAccounts
|
|||
|
||||
UserAccount account = new UserAccount((Dictionary<string, object>)request["account"]);
|
||||
|
||||
if (m_UserAccountService.SetUserAccount(account))
|
||||
if (m_UserAccountService.StoreUserAccount(account))
|
||||
return SuccessResult();
|
||||
|
||||
return FailureResult();
|
||||
|
|
|
@ -186,7 +186,7 @@ namespace OpenSim.Services.Connectors
|
|||
return accounts;
|
||||
}
|
||||
|
||||
public bool SetUserAccount(UserAccount data)
|
||||
public bool StoreUserAccount(UserAccount data)
|
||||
{
|
||||
Dictionary<string, object> sendData = new Dictionary<string, object>();
|
||||
//sendData["SCOPEID"] = scopeID.ToString();
|
||||
|
@ -199,19 +199,6 @@ namespace OpenSim.Services.Connectors
|
|||
return SendAndGetBoolReply(sendData);
|
||||
}
|
||||
|
||||
public bool CreateUserAccount(UserAccount data)
|
||||
{
|
||||
Dictionary<string, object> sendData = new Dictionary<string, object>();
|
||||
//sendData["SCOPEID"] = scopeID.ToString();
|
||||
sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
|
||||
sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
|
||||
sendData["METHOD"] = "createaccount";
|
||||
|
||||
sendData["account"] = data.ToKeyValuePairs();
|
||||
|
||||
return SendAndGetBoolReply(sendData);
|
||||
}
|
||||
|
||||
private UserAccount SendAndGetReply(Dictionary<string, object> sendData)
|
||||
{
|
||||
string reply = string.Empty;
|
||||
|
|
|
@ -95,11 +95,9 @@ namespace OpenSim.Services.Interfaces
|
|||
//
|
||||
List<UserAccount> GetUserAccounts(UUID scopeID, string query);
|
||||
|
||||
// Update all updatable fields
|
||||
// Store the data given, wich replaces the sotred data, therefore
|
||||
// must be complete.
|
||||
//
|
||||
bool SetUserAccount(UserAccount data);
|
||||
|
||||
// Creates a user data record
|
||||
bool CreateUserAccount(UserAccount data);
|
||||
bool StoreUserAccount(UserAccount data);
|
||||
}
|
||||
}
|
|
@ -62,40 +62,123 @@ namespace OpenSim.Services.UserAccountService
|
|||
if (d.Length < 1)
|
||||
return null;
|
||||
|
||||
UserAccount u = new UserAccount();
|
||||
u.FirstName = d[0].FirstName;
|
||||
u.LastName = d[0].LastName;
|
||||
u.PrincipalID = d[0].PrincipalID;
|
||||
u.ScopeID = d[0].ScopeID;
|
||||
u.Email = d[0].Data["Email"].ToString();
|
||||
u.Created = Convert.ToInt32(d[0].Data["Created"].ToString());
|
||||
return MakeUserAccount(d[0]);
|
||||
}
|
||||
|
||||
return null;
|
||||
private UserAccount MakeUserAccount(UserAccountData d)
|
||||
{
|
||||
UserAccount u = new UserAccount();
|
||||
u.FirstName = d.FirstName;
|
||||
u.LastName = d.LastName;
|
||||
u.PrincipalID = d.PrincipalID;
|
||||
u.ScopeID = d.ScopeID;
|
||||
u.Email = d.Data["Email"].ToString();
|
||||
u.Created = Convert.ToInt32(d.Data["Created"].ToString());
|
||||
|
||||
string[] URLs = d.Data["ServiceURLs"].ToString().Split(new char[] {' '});
|
||||
u.ServiceURLs = new Dictionary<string, object>();
|
||||
|
||||
foreach(string url in URLs)
|
||||
{
|
||||
string[] parts = url.Split(new char[] {'='});
|
||||
|
||||
if (parts.Length != 2)
|
||||
continue;
|
||||
|
||||
string name = System.Web.HttpUtility.UrlDecode(parts[0]);
|
||||
string val = System.Web.HttpUtility.UrlDecode(parts[1]);
|
||||
|
||||
u.ServiceURLs[name] = val;
|
||||
}
|
||||
|
||||
return u;
|
||||
}
|
||||
|
||||
public UserAccount GetUserAccount(UUID scopeID, string email)
|
||||
{
|
||||
return null;
|
||||
UserAccountData[] d;
|
||||
|
||||
if (scopeID != UUID.Zero)
|
||||
{
|
||||
d = m_Database.Get(
|
||||
new string[] {"ScopeID", "Email"},
|
||||
new string[] {scopeID.ToString(), email});
|
||||
}
|
||||
else
|
||||
{
|
||||
d = m_Database.Get(
|
||||
new string[] {"Email"},
|
||||
new string[] {email});
|
||||
}
|
||||
|
||||
if (d.Length < 1)
|
||||
return null;
|
||||
|
||||
return MakeUserAccount(d[0]);
|
||||
}
|
||||
|
||||
public UserAccount GetUserAccount(UUID scopeID, UUID userID)
|
||||
public UserAccount GetUserAccount(UUID scopeID, UUID principalID)
|
||||
{
|
||||
return null;
|
||||
UserAccountData[] d;
|
||||
|
||||
if (scopeID != UUID.Zero)
|
||||
{
|
||||
d = m_Database.Get(
|
||||
new string[] {"ScopeID", "PrincipalID"},
|
||||
new string[] {scopeID.ToString(), principalID.ToString()});
|
||||
}
|
||||
else
|
||||
{
|
||||
d = m_Database.Get(
|
||||
new string[] {"PrincipalID"},
|
||||
new string[] {principalID.ToString()});
|
||||
}
|
||||
|
||||
if (d.Length < 1)
|
||||
return null;
|
||||
|
||||
return MakeUserAccount(d[0]);
|
||||
}
|
||||
|
||||
public bool SetUserAccount(UserAccount data)
|
||||
public bool StoreUserAccount(UserAccount data)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
UserAccountData d = new UserAccountData();
|
||||
|
||||
public bool CreateUserAccount(UserAccount data)
|
||||
{
|
||||
return false;
|
||||
d.FirstName = data.FirstName;
|
||||
d.LastName = data.LastName;
|
||||
d.PrincipalID = data.PrincipalID;
|
||||
d.ScopeID = data.ScopeID;
|
||||
d.Data = new Dictionary<string,string>();
|
||||
d.Data["Email"] = data.Email;
|
||||
d.Data["Created"] = data.Created.ToString();
|
||||
|
||||
List<string> parts = new List<string>();
|
||||
|
||||
foreach (KeyValuePair<string,object> kvp in data.ServiceURLs)
|
||||
{
|
||||
string key = System.Web.HttpUtility.UrlEncode(kvp.Key);
|
||||
string val = System.Web.HttpUtility.UrlEncode(kvp.Value.ToString());
|
||||
parts.Add(key + "=" + val);
|
||||
}
|
||||
|
||||
d.Data["ServiceURLs"] = string.Join(" ", parts.ToArray());
|
||||
|
||||
return m_Database.Store(d);
|
||||
}
|
||||
|
||||
public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
|
||||
{
|
||||
return null;
|
||||
UserAccountData[] d = m_Database.GetUsers(scopeID, query);
|
||||
|
||||
if (d == null)
|
||||
return new List<UserAccount>();
|
||||
|
||||
List<UserAccount> ret = new List<UserAccount>();
|
||||
|
||||
foreach (UserAccountData data in d)
|
||||
ret.Add(MakeUserAccount(data));
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1052,6 +1052,7 @@
|
|||
|
||||
<ReferencePath>../../../bin/</ReferencePath>
|
||||
<Reference name="System"/>
|
||||
<Reference name="System.Web"/>
|
||||
<Reference name="OpenMetaverseTypes.dll"/>
|
||||
<Reference name="OpenMetaverse.dll"/>
|
||||
<Reference name="OpenSim.Framework"/>
|
||||
|
|
Loading…
Reference in New Issue