aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Data.SQLite/SQLiteUserData.cs')
-rw-r--r--OpenSim/Framework/Data.SQLite/SQLiteUserData.cs44
1 files changed, 36 insertions, 8 deletions
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
index c97dc52..e9a8eca 100644
--- a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
+++ b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
@@ -47,16 +47,20 @@ namespace OpenSim.Framework.Data.SQLite
47 /// </summary> 47 /// </summary>
48 private const string userSelect = "select * from users"; 48 private const string userSelect = "select * from users";
49 private const string userFriendsSelect = "select a.ownerID as ownerID,a.friendID as friendID,a.friendPerms as friendPerms,b.friendPerms as ownerperms, b.ownerID as fownerID, b.friendID as ffriendID from userfriends as a, userfriends as b"; 49 private const string userFriendsSelect = "select a.ownerID as ownerID,a.friendID as friendID,a.friendPerms as friendPerms,b.friendPerms as ownerperms, b.ownerID as fownerID, b.friendID as ffriendID from userfriends as a, userfriends as b";
50 50
51 private DataSet ds; 51 private DataSet ds;
52 private SqliteDataAdapter da; 52 private SqliteDataAdapter da;
53 private SqliteDataAdapter daf; 53 private SqliteDataAdapter daf;
54 SqliteConnection g_conn;
54 55
55 public void Initialise() 56 public void Initialise()
56 { 57 {
57 SqliteConnection conn = new SqliteConnection("URI=file:userprofiles.db,version=3"); 58 SqliteConnection conn = new SqliteConnection("URI=file:userprofiles.db,version=3");
58 TestTables(conn); 59 TestTables(conn);
59 60
61 // This sucks, but It doesn't seem to work with the dataset Syncing :P
62 g_conn = conn;
63
60 ds = new DataSet(); 64 ds = new DataSet();
61 da = new SqliteDataAdapter(new SqliteCommand(userSelect, conn)); 65 da = new SqliteDataAdapter(new SqliteCommand(userSelect, conn));
62 daf = new SqliteDataAdapter(new SqliteCommand(userFriendsSelect, conn)); 66 daf = new SqliteDataAdapter(new SqliteCommand(userFriendsSelect, conn));
@@ -147,11 +151,11 @@ namespace OpenSim.Framework.Data.SQLite
147 151
148 152
149 DataRow row = friends.NewRow(); 153 DataRow row = friends.NewRow();
150 fillFriendRow(row, friendlistowner,friend,perms); 154 fillFriendRow(row, friendlistowner.UUID.ToString(),friend.UUID.ToString(),perms);
151 friends.Rows.Add(row); 155 friends.Rows.Add(row);
152 156
153 row = friends.NewRow(); 157 row = friends.NewRow();
154 fillFriendRow(row, friend, friendlistowner, perms); 158 fillFriendRow(row, friend.UUID.ToString(), friendlistowner.UUID.ToString(), perms);
155 friends.Rows.Add(row); 159 friends.Rows.Add(row);
156 160
157 MainLog.Instance.Verbose("SQLITE", 161 MainLog.Instance.Verbose("SQLITE",
@@ -164,7 +168,7 @@ namespace OpenSim.Framework.Data.SQLite
164 public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend) 168 public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend)
165 { 169 {
166 DataTable ua = ds.Tables["userfriends"]; 170 DataTable ua = ds.Tables["userfriends"];
167 string select = "a.ownernID '" + friendlistowner.UUID.ToString() + "' and b.friendID ='" + friend.UUID.ToString() + "';"; 171 string select = "`ownerID` ='" + friendlistowner.UUID.ToString() + "' and `friendID` ='" + friend.UUID.ToString() + "'";
168 lock (ds) 172 lock (ds)
169 { 173 {
170 DataRow[] rows = ds.Tables["userfriends"].Select(select); 174 DataRow[] rows = ds.Tables["userfriends"].Select(select);
@@ -175,20 +179,44 @@ namespace OpenSim.Framework.Data.SQLite
175 { 179 {
176 for (int i = 0; i < rows.Length; i++) 180 for (int i = 0; i < rows.Length; i++)
177 { 181 {
178 FriendListItem user = new FriendListItem();
179 DataRow row = rows[i]; 182 DataRow row = rows[i];
180 row.Delete(); 183 row.Delete();
181 } 184 }
182 daf.Update(ds, "userfriends"); 185
186 }
187 }
188 }
189 select = "`ownerID` ='" + friend.UUID.ToString() + "' and `friendID` ='" + friendlistowner.UUID.ToString() + "'";
190 lock (ds)
191 {
192 DataRow[] rows = ds.Tables["userfriends"].Select(select);
193
194 if (rows != null)
195 {
196 if (rows.Length > 0)
197 {
198 for (int i = 0; i < rows.Length; i++)
199 {
200 DataRow row = rows[i];
201 row.Delete();
202 }
203
183 } 204 }
184 } 205 }
185 } 206 }
207 SqliteCommand deletecommand = new SqliteCommand("delete from userfriends where `ownerID`='" + friendlistowner.UUID.ToString() + "' and `friendID` ='" + friend.UUID.ToString() + "'", g_conn);
208 g_conn.Open();
209 deletecommand.ExecuteNonQuery();
210 deletecommand = new SqliteCommand("delete from userfriends where `ownerID`='" + friend.UUID.ToString() + "' and `friendID` ='" + friendlistowner.UUID.ToString() + "'", g_conn);
211 deletecommand.ExecuteNonQuery();
212 g_conn.Close();
213
186 MainLog.Instance.Verbose("FRIEND", "Stub RemoveUserFriend called"); 214 MainLog.Instance.Verbose("FRIEND", "Stub RemoveUserFriend called");
187 } 215 }
188 public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms) 216 public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms)
189 { 217 {
190 DataTable ua = ds.Tables["userfriends"]; 218 DataTable ua = ds.Tables["userfriends"];
191 string select = "a.ownernID '" + friendlistowner.UUID.ToString() + "' and b.friendID ='" + friend.UUID.ToString() + "';"; 219 string select = "a.ownerID ='" + friendlistowner.UUID.ToString() + "' and b.friendID ='" + friend.UUID.ToString() + "'";
192 lock (ds) 220 lock (ds)
193 { 221 {
194 DataRow[] rows = ds.Tables["userfriends"].Select(select); 222 DataRow[] rows = ds.Tables["userfriends"].Select(select);
@@ -737,7 +765,7 @@ namespace OpenSim.Framework.Data.SQLite
737 daf.UpdateCommand = createUpdateCommand("userfriends", "ownerID=:ownerID and friendID=:friendID", ds.Tables["userfriends"]); 765 daf.UpdateCommand = createUpdateCommand("userfriends", "ownerID=:ownerID and friendID=:friendID", ds.Tables["userfriends"]);
738 daf.UpdateCommand.Connection = conn; 766 daf.UpdateCommand.Connection = conn;
739 767
740 SqliteCommand delete = new SqliteCommand("delete from users where ownerID=:ownerID and friendID=:friendID"); 768 SqliteCommand delete = new SqliteCommand("delete from userfriends where ownerID=:ownerID and friendID=:friendID");
741 delete.Parameters.Add(createSqliteParameter("ownerID", typeof(String))); 769 delete.Parameters.Add(createSqliteParameter("ownerID", typeof(String)));
742 delete.Parameters.Add(createSqliteParameter("friendID", typeof(String))); 770 delete.Parameters.Add(createSqliteParameter("friendID", typeof(String)));
743 delete.Connection = conn; 771 delete.Connection = conn;