aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Data.MSSQL
diff options
context:
space:
mode:
authorlbsa712008-02-13 13:55:03 +0000
committerlbsa712008-02-13 13:55:03 +0000
commitc202a7d0aa1976d813489446643a5bcf969734d5 (patch)
tree1132cf04fd7d94f1f56688f03a7523f5e15d40ee /OpenSim/Framework/Data.MSSQL
parent* Split out MSSQLManager Test/Init into each provider. (diff)
downloadopensim-SC-c202a7d0aa1976d813489446643a5bcf969734d5.zip
opensim-SC-c202a7d0aa1976d813489446643a5bcf969734d5.tar.gz
opensim-SC-c202a7d0aa1976d813489446643a5bcf969734d5.tar.bz2
opensim-SC-c202a7d0aa1976d813489446643a5bcf969734d5.tar.xz
* Copied 'Friends' functionality from the MySQLUserData to MSSQLUserData
[Provided by openlifegrid.com]
Diffstat (limited to 'OpenSim/Framework/Data.MSSQL')
-rw-r--r--OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs141
1 files changed, 136 insertions, 5 deletions
diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs
index aacbb2d..95a0c08 100644
--- a/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs
+++ b/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs
@@ -161,23 +161,154 @@ namespace OpenSim.Framework.Data.MSSQL
161 161
162 public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms) 162 public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms)
163 { 163 {
164 m_log.Info("[FRIEND]: Stub AddNewUserFriend called"); 164 int dtvalue = Util.UnixTimeSinceEpoch();
165
166 Dictionary<string, string> param = new Dictionary<string, string>();
167 param["@ownerID"] = friendlistowner.UUID.ToString();
168 param["@friendID"] = friend.UUID.ToString();
169 param["@friendPerms"] = perms.ToString();
170 param["@datetimestamp"] = dtvalue.ToString();
171
172 try
173 {
174 lock (database)
175 {
176 IDbCommand adder =
177 database.Query(
178 "INSERT INTO `" + m_userFriendsTableName + "` " +
179 "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " +
180 "VALUES " +
181 "(@ownerID,@friendID,@friendPerms,@datetimestamp)",
182 param);
183 adder.ExecuteNonQuery();
184
185 adder =
186 database.Query(
187 "INSERT INTO `" + m_userFriendsTableName + "` " +
188 "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " +
189 "VALUES " +
190 "(@friendID,@ownerID,@friendPerms,@datetimestamp)",
191 param);
192 adder.ExecuteNonQuery();
193
194 }
195 }
196 catch (Exception e)
197 {
198 database.Reconnect();
199 m_log.Error(e.ToString());
200 return;
201 }
165 } 202 }
166 203
167 public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend) 204 public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend)
168 { 205 {
169 m_log.Info("[FRIEND]: Stub RemoveUserFriend called"); 206 Dictionary<string, string> param = new Dictionary<string, string>();
207 param["@ownerID"] = friendlistowner.UUID.ToString();
208 param["@friendID"] = friend.UUID.ToString();
209
210
211 try
212 {
213 lock (database)
214 {
215 IDbCommand updater =
216 database.Query(
217 "delete from " + m_userFriendsTableName + " where ownerID = @ownerID and friendID = @friendID",
218 param);
219 updater.ExecuteNonQuery();
220
221 updater =
222 database.Query(
223 "delete from " + m_userFriendsTableName + " where ownerID = @friendID and friendID = @ownerID",
224 param);
225 updater.ExecuteNonQuery();
226
227 }
228 }
229 catch (Exception e)
230 {
231 database.Reconnect();
232 m_log.Error(e.ToString());
233 return;
234 }
170 } 235 }
236
171 public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms) 237 public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms)
172 { 238 {
173 m_log.Info("[FRIEND]: Stub UpdateUserFriendPerms called"); 239 Dictionary<string, string> param = new Dictionary<string, string>();
240 param["@ownerID"] = friendlistowner.UUID.ToString();
241 param["@friendID"] = friend.UUID.ToString();
242 param["@friendPerms"] = perms.ToString();
243
244
245 try
246 {
247 lock (database)
248 {
249 IDbCommand updater =
250 database.Query(
251 "update " + m_userFriendsTableName +
252 " SET friendPerms = @friendPerms " +
253 "where ownerID = @ownerID and friendID = @friendID",
254 param);
255
256 updater.ExecuteNonQuery();
257 }
258 }
259 catch (Exception e)
260 {
261 database.Reconnect();
262 m_log.Error(e.ToString());
263 return;
264 }
174 } 265 }
175 266
176 267
177 public List<FriendListItem> GetUserFriendList(LLUUID friendlistowner) 268 public List<FriendListItem> GetUserFriendList(LLUUID friendlistowner)
178 { 269 {
179 m_log.Info("[FRIEND]: Stub GetUserFriendList called"); 270 List<FriendListItem> Lfli = new List<FriendListItem>();
180 return new List<FriendListItem>(); 271
272 Dictionary<string, string> param = new Dictionary<string, string>();
273 param["@ownerID"] = friendlistowner.UUID.ToString();
274
275 try
276 {
277 lock (database)
278 {
279 //Left Join userfriends to itself
280 IDbCommand result =
281 database.Query(
282 "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" +
283 " where a.ownerID = @ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID",
284 param);
285 IDataReader reader = result.ExecuteReader();
286
287
288 while (reader.Read())
289 {
290 FriendListItem fli = new FriendListItem();
291 fli.FriendListOwner = new LLUUID((string)reader["ownerID"]);
292 fli.Friend = new LLUUID((string)reader["friendID"]);
293 fli.FriendPerms = (uint)Convert.ToInt32(reader["friendPerms"]);
294
295 // This is not a real column in the database table, it's a joined column from the opposite record
296 fli.FriendListOwnerPerms = (uint)Convert.ToInt32(reader["ownerperms"]);
297
298 Lfli.Add(fli);
299 }
300 reader.Close();
301 result.Dispose();
302 }
303 }
304 catch (Exception e)
305 {
306 database.Reconnect();
307 m_log.Error(e.ToString());
308 return Lfli;
309 }
310
311 return Lfli;
181 } 312 }
182 313
183 #endregion 314 #endregion