aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorSean Dague2007-08-28 02:25:44 +0000
committerSean Dague2007-08-28 02:25:44 +0000
commitd5c5aff919773a06fbbdab8f2e49c0a729011bab (patch)
treeea2c150e9a5f37916f3093a42032522730254e60 /OpenSim
parentreverting to old case sensitive username behavior. As sdague pointed out,we a... (diff)
downloadopensim-SC_OLD-d5c5aff919773a06fbbdab8f2e49c0a729011bab.zip
opensim-SC_OLD-d5c5aff919773a06fbbdab8f2e49c0a729011bab.tar.gz
opensim-SC_OLD-d5c5aff919773a06fbbdab8f2e49c0a729011bab.tar.bz2
opensim-SC_OLD-d5c5aff919773a06fbbdab8f2e49c0a729011bab.tar.xz
sqlite user datastore "should" be functionally complete
with this checkin, though it's not tested. Will do that tommorrow.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Data.SQLite/SQLiteUserData.cs189
1 files changed, 74 insertions, 115 deletions
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
index 84e58fa..ea26592 100644
--- a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
+++ b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
@@ -78,7 +78,12 @@ namespace OpenSim.Framework.Data.SQLite
78 { 78 {
79 DataRow row = ds.Tables["users"].Rows.Find(uuid); 79 DataRow row = ds.Tables["users"].Rows.Find(uuid);
80 if(row != null) { 80 if(row != null) {
81 return buildUserProfile(row); 81 UserProfileData user = buildUserProfile(row);
82 row = ds.Tables["useragents"].Rows.Find(uuid);
83 if(row != null) {
84 user.currentAgent = buildUserAgent(row);
85 }
86 return user;
82 } else { 87 } else {
83 return null; 88 return null;
84 } 89 }
@@ -105,7 +110,12 @@ namespace OpenSim.Framework.Data.SQLite
105 string select = "surname = '" + lname + "' and username = '" + fname + "'"; 110 string select = "surname = '" + lname + "' and username = '" + fname + "'";
106 DataRow[] rows = ds.Tables["users"].Select(select); 111 DataRow[] rows = ds.Tables["users"].Select(select);
107 if(rows.Length > 0) { 112 if(rows.Length > 0) {
108 return buildUserProfile(rows[0]); 113 UserProfileData user = buildUserProfile(rows[0]);
114 DataRow row = ds.Tables["useragents"].Rows.Find(user.UUID);
115 if(row != null) {
116 user.currentAgent = buildUserAgent(row);
117 }
118 return user;
109 } else { 119 } else {
110 return null; 120 return null;
111 } 121 }
@@ -174,6 +184,23 @@ namespace OpenSim.Framework.Data.SQLite
174 { 184 {
175 fillUserRow(row, user); 185 fillUserRow(row, user);
176 } 186 }
187
188 if(user.currentAgent != null) {
189 DataTable ua = ds.Tables["useragents"];
190 row = ua.Rows.Find(user.UUID);
191 if (row == null)
192 {
193 row = ua.NewRow();
194 fillUserAgentRow(row, user.currentAgent);
195 ua.Rows.Add(row);
196 }
197 else
198 {
199 fillUserAgentRow(row, user.currentAgent);
200 }
201 }
202 // save changes off to disk
203 da.Update(ds, "users");
177 } 204 }
178 205
179 /// <summary> 206 /// <summary>
@@ -183,23 +210,14 @@ namespace OpenSim.Framework.Data.SQLite
183 /// <returns>True on success, false on error</returns> 210 /// <returns>True on success, false on error</returns>
184 public bool updateUserProfile(UserProfileData user) 211 public bool updateUserProfile(UserProfileData user)
185 { 212 {
186 DataTable users = ds.Tables["users"]; 213 try {
187 DataRow row = users.Rows.Find(user.UUID); 214 addNewUserProfile(user);
188 if (row == null) 215 return true;
189 { 216 } catch (Exception) {
190 row = users.NewRow(); 217 return false;
191 fillUserRow(row, user);
192 users.Rows.Add(row);
193 }
194 else
195 {
196 fillUserRow(row, user);
197 } 218 }
198 return true;
199 } 219 }
200 220
201
202
203 /// <summary> 221 /// <summary>
204 /// Creates a new user agent 222 /// Creates a new user agent
205 /// </summary> 223 /// </summary>
@@ -404,106 +422,47 @@ namespace OpenSim.Framework.Data.SQLite
404 row["profileFirstImage"] = user.profileFirstImage; 422 row["profileFirstImage"] = user.profileFirstImage;
405 } 423 }
406 424
407// private PrimitiveBaseShape buildShape(DataRow row) 425 private UserAgentData buildUserAgent(DataRow row)
408// { 426 {
409// PrimitiveBaseShape s = new PrimitiveBaseShape(); 427 UserAgentData ua = new UserAgentData();
410// s.Scale = new LLVector3(
411// Convert.ToSingle(row["ScaleX"]),
412// Convert.ToSingle(row["ScaleY"]),
413// Convert.ToSingle(row["ScaleZ"])
414// );
415// // paths
416// s.PCode = Convert.ToByte(row["PCode"]);
417// s.PathBegin = Convert.ToUInt16(row["PathBegin"]);
418// s.PathEnd = Convert.ToUInt16(row["PathEnd"]);
419// s.PathScaleX = Convert.ToByte(row["PathScaleX"]);
420// s.PathScaleY = Convert.ToByte(row["PathScaleY"]);
421// s.PathShearX = Convert.ToByte(row["PathShearX"]);
422// s.PathShearY = Convert.ToByte(row["PathShearY"]);
423// s.PathSkew = Convert.ToSByte(row["PathSkew"]);
424// s.PathCurve = Convert.ToByte(row["PathCurve"]);
425// s.PathRadiusOffset = Convert.ToSByte(row["PathRadiusOffset"]);
426// s.PathRevolutions = Convert.ToByte(row["PathRevolutions"]);
427// s.PathTaperX = Convert.ToSByte(row["PathTaperX"]);
428// s.PathTaperY = Convert.ToSByte(row["PathTaperY"]);
429// s.PathTwist = Convert.ToSByte(row["PathTwist"]);
430// s.PathTwistBegin = Convert.ToSByte(row["PathTwistBegin"]);
431// // profile
432// s.ProfileBegin = Convert.ToUInt16(row["ProfileBegin"]);
433// s.ProfileEnd = Convert.ToUInt16(row["ProfileEnd"]);
434// s.ProfileCurve = Convert.ToByte(row["ProfileCurve"]);
435// s.ProfileHollow = Convert.ToByte(row["ProfileHollow"]);
436// // text TODO: this isn't right] = but I'm not sure the right
437// // way to specify this as a blob atm
438// s.TextureEntry = (byte[])row["Texture"];
439// s.ExtraParams = (byte[])row["ExtraParams"];
440// // System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
441// // string texture = encoding.GetString((Byte[])row["Texture"]);
442// // if (!texture.StartsWith("<"))
443// // {
444// // //here so that we can still work with old format database files (ie from before I added xml serialization)
445// // LLObject.TextureEntry textureEntry = null;
446// // textureEntry = new LLObject.TextureEntry(new LLUUID(texture));
447// // s.TextureEntry = textureEntry.ToBytes();
448// // }
449// // else
450// // {
451// // TextureBlock textureEntry = TextureBlock.FromXmlString(texture);
452// // s.TextureEntry = textureEntry.TextureData;
453// // s.ExtraParams = textureEntry.ExtraParams;
454// // }
455 428
456// return s; 429 ua.UUID = new LLUUID((string)row["UUID"]);
457// } 430 ua.agentIP = (string)row["agentIP"];
458 431 ua.agentPort = Convert.ToUInt32(row["agentPort"]);
459// private void fillShapeRow(DataRow row, SceneObjectPart prim) 432 ua.agentOnline = Convert.ToBoolean(row["agentOnline"]);
460// { 433 ua.sessionID = new LLUUID((string)row["sessionID"]);
461// PrimitiveBaseShape s = prim.Shape; 434 ua.secureSessionID = new LLUUID((string)row["secureSessionID"]);
462// row["UUID"] = prim.UUID; 435 ua.regionID = new LLUUID((string)row["regionID"]);
463// // shape is an enum 436 ua.loginTime = Convert.ToInt32(row["loginTime"]);
464// row["Shape"] = 0; 437 ua.logoutTime = Convert.ToInt32(row["logoutTime"]);
465// // vectors 438 ua.currentRegion = new LLUUID((string)row["currentRegion"]);
466// row["ScaleX"] = s.Scale.X; 439 ua.currentHandle = Convert.ToUInt32(row["currentHandle"]);
467// row["ScaleY"] = s.Scale.Y; 440 ua.currentPos = new LLVector3(
468// row["ScaleZ"] = s.Scale.Z; 441 Convert.ToSingle(row["currentPosX"]),
469// // paths 442 Convert.ToSingle(row["currentPosY"]),
470// row["PCode"] = s.PCode; 443 Convert.ToSingle(row["currentPosZ"])
471// row["PathBegin"] = s.PathBegin; 444 );
472// row["PathEnd"] = s.PathEnd; 445 return ua;
473// row["PathScaleX"] = s.PathScaleX; 446 }
474// row["PathScaleY"] = s.PathScaleY; 447
475// row["PathShearX"] = s.PathShearX; 448 private void fillUserAgentRow(DataRow row, UserAgentData ua)
476// row["PathShearY"] = s.PathShearY; 449 {
477// row["PathSkew"] = s.PathSkew; 450 row["UUID"] = ua.UUID;
478// row["PathCurve"] = s.PathCurve; 451 row["agentIP"] = ua.agentIP;
479// row["PathRadiusOffset"] = s.PathRadiusOffset; 452 row["agentPort"] = ua.agentPort;
480// row["PathRevolutions"] = s.PathRevolutions; 453 row["agentOnline"] = ua.agentOnline;
481// row["PathTaperX"] = s.PathTaperX; 454 row["sessionID"] = ua.sessionID;
482// row["PathTaperY"] = s.PathTaperY; 455 row["secureSessionID"] = ua.secureSessionID;
483// row["PathTwist"] = s.PathTwist; 456 row["regionID"] = ua.regionID;
484// row["PathTwistBegin"] = s.PathTwistBegin; 457 row["loginTime"] = ua.loginTime;
485// // profile 458 row["logoutTime"] = ua.logoutTime;
486// row["ProfileBegin"] = s.ProfileBegin; 459 row["currentRegion"] = ua.currentRegion;
487// row["ProfileEnd"] = s.ProfileEnd; 460 row["currentHandle"] = ua.currentHandle;
488// row["ProfileCurve"] = s.ProfileCurve; 461 // vectors
489// row["ProfileHollow"] = s.ProfileHollow; 462 row["currentPosX"] = ua.currentPos.X;
490// // text TODO: this isn't right] = but I'm not sure the right 463 row["currentPosY"] = ua.currentPos.Y;
491// // way to specify this as a blob atm 464 row["currentPosZ"] = ua.currentPos.Z;
492 465 }
493// // And I couldn't work out how to save binary data either
494// // seems that the texture colum is being treated as a string in the Datarow
495// // if you do a .getType() on it, it returns string, while the other columns return correct type
496// // MW[10-08-07]
497// // Added following xml hack but not really ideal , also ExtraParams isn't currently part of the database
498// // am a bit worried about adding it now as some people will have old format databases, so for now including that data in this xml data
499// // MW[17-08-07]
500// row["Texture"] = s.TextureEntry;
501// row["ExtraParams"] = s.ExtraParams;
502// // TextureBlock textureBlock = new TextureBlock(s.TextureEntry);
503// // textureBlock.ExtraParams = s.ExtraParams;
504// // System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
505// // row["Texture"] = encoding.GetBytes(textureBlock.ToXMLString());
506// }
507 466
508 /*********************************************************************** 467 /***********************************************************************
509 * 468 *