aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/UserAccountService/UserAccountService.cs
diff options
context:
space:
mode:
authorDiva Canto2009-12-30 21:00:52 -0800
committerDiva Canto2009-12-30 21:00:52 -0800
commitc664307126e7869f6e7038173561de57be058104 (patch)
tree848f6fad19abdc65cb7c76a4eff67c8de453038a /OpenSim/Services/UserAccountService/UserAccountService.cs
parentFirst pass at the new login service. Still incomplete, but doesn't disrupt th... (diff)
parentImplement avatar picker queries (diff)
downloadopensim-SC_OLD-c664307126e7869f6e7038173561de57be058104.zip
opensim-SC_OLD-c664307126e7869f6e7038173561de57be058104.tar.gz
opensim-SC_OLD-c664307126e7869f6e7038173561de57be058104.tar.bz2
opensim-SC_OLD-c664307126e7869f6e7038173561de57be058104.tar.xz
Merge branch 'presence-refactor' of ssh://diva@opensimulator.org/var/git/opensim into presence-refactor
Diffstat (limited to 'OpenSim/Services/UserAccountService/UserAccountService.cs')
-rw-r--r--OpenSim/Services/UserAccountService/UserAccountService.cs119
1 files changed, 101 insertions, 18 deletions
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}