aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2010-03-23 02:05:56 +0000
committerMelanie2010-03-23 02:05:56 +0000
commitdcf18689b9ab29d4ceb2348bb56fc1f77a7a8912 (patch)
treeef72d57634075b044c65428f31c8f04c4c53a7bb /OpenSim
parentSomehow the starting estate number in MySQL was lost. This adds a migration (diff)
downloadopensim-SC_OLD-dcf18689b9ab29d4ceb2348bb56fc1f77a7a8912.zip
opensim-SC_OLD-dcf18689b9ab29d4ceb2348bb56fc1f77a7a8912.tar.gz
opensim-SC_OLD-dcf18689b9ab29d4ceb2348bb56fc1f77a7a8912.tar.bz2
opensim-SC_OLD-dcf18689b9ab29d4ceb2348bb56fc1f77a7a8912.tar.xz
First stage of the new interactive region creation. This will allow creation
of a region and joining it to an existing estate or creating a new estate, as well as creating an estate owner if in standalone, and assigning estate owners. In Grid mode, existing users must be used. MySQL ONLY!!!! so far, as I can't develop or test for either SQLite or MSSQL.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLEstateData.cs25
-rw-r--r--OpenSim/Data/MySQL/MySQLEstateData.cs175
-rw-r--r--OpenSim/Data/SQLite/SQLiteEstateData.cs25
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs115
-rw-r--r--OpenSim/Services/Interfaces/IUserAccountService.cs4
6 files changed, 302 insertions, 48 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLEstateData.cs b/OpenSim/Data/MSSQL/MSSQLEstateData.cs
index 1624f56..474f706 100644
--- a/OpenSim/Data/MSSQL/MSSQLEstateData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLEstateData.cs
@@ -346,6 +346,31 @@ namespace OpenSim.Data.MSSQL
346 } 346 }
347 } 347 }
348 } 348 }
349
350 public EstateSettings LoadEstateSettings(int estateID)
351 {
352 return new EstateSettings();
353 }
354
355 public List<int> GetEstates(string search)
356 {
357 return new List<int>();
358 }
359
360 public bool LinkRegion(UUID regionID, int estateID)
361 {
362 return false;
363 }
364
365 public List<UUID> GetRegions(int estateID)
366 {
367 return new List<UUID>();
368 }
369
370 public bool DeleteEstate(int estateID)
371 {
372 return false;
373 }
349 #endregion 374 #endregion
350 } 375 }
351} 376}
diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs
index e94dcda..7fe1fcc 100644
--- a/OpenSim/Data/MySQL/MySQLEstateData.cs
+++ b/OpenSim/Data/MySQL/MySQLEstateData.cs
@@ -123,50 +123,57 @@ namespace OpenSim.Data.MySQL
123 123
124 public EstateSettings LoadEstateSettings(UUID regionID, bool create) 124 public EstateSettings LoadEstateSettings(UUID regionID, bool create)
125 { 125 {
126 EstateSettings es = new EstateSettings();
127 es.OnSave += StoreEstateSettings;
128
129 string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + 126 string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) +
130 " from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = ?RegionID"; 127 " from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = ?RegionID";
131 128
129 using (MySqlCommand cmd = new MySqlCommand())
130 {
131 cmd.CommandText = sql;
132 cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
133
134 return DoLoad(cmd, regionID, create);
135 }
136 }
137
138 private EstateSettings DoLoad(MySqlCommand cmd, UUID regionID, bool create)
139 {
140 EstateSettings es = new EstateSettings();
141 es.OnSave += StoreEstateSettings;
142
132 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 143 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
133 { 144 {
134 dbcon.Open(); 145 dbcon.Open();
135 146
147 cmd.Connection = dbcon;
148
136 bool found = false; 149 bool found = false;
137 150
138 using (MySqlCommand cmd = dbcon.CreateCommand()) 151 using (IDataReader r = cmd.ExecuteReader())
139 { 152 {
140 cmd.CommandText = sql; 153 if (r.Read())
141 cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
142
143 using (IDataReader r = cmd.ExecuteReader())
144 { 154 {
145 if (r.Read()) 155 found = true;
146 {
147 found = true;
148 156
149 foreach (string name in FieldList) 157 foreach (string name in FieldList)
158 {
159 if (m_FieldMap[name].GetValue(es) is bool)
150 { 160 {
151 if (m_FieldMap[name].GetValue(es) is bool) 161 int v = Convert.ToInt32(r[name]);
152 { 162 if (v != 0)
153 int v = Convert.ToInt32(r[name]); 163 m_FieldMap[name].SetValue(es, true);
154 if (v != 0)
155 m_FieldMap[name].SetValue(es, true);
156 else
157 m_FieldMap[name].SetValue(es, false);
158 }
159 else if (m_FieldMap[name].GetValue(es) is UUID)
160 {
161 UUID uuid = UUID.Zero;
162
163 UUID.TryParse(r[name].ToString(), out uuid);
164 m_FieldMap[name].SetValue(es, uuid);
165 }
166 else 164 else
167 { 165 m_FieldMap[name].SetValue(es, false);
168 m_FieldMap[name].SetValue(es, r[name]); 166 }
169 } 167 else if (m_FieldMap[name].GetValue(es) is UUID)
168 {
169 UUID uuid = UUID.Zero;
170
171 UUID.TryParse(r[name].ToString(), out uuid);
172 m_FieldMap[name].SetValue(es, uuid);
173 }
174 else
175 {
176 m_FieldMap[name].SetValue(es, r[name]);
170 } 177 }
171 } 178 }
172 } 179 }
@@ -179,45 +186,45 @@ namespace OpenSim.Data.MySQL
179 186
180 names.Remove("EstateID"); 187 names.Remove("EstateID");
181 188
182 sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")"; 189 string sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")";
183 190
184 using (MySqlCommand cmd = dbcon.CreateCommand()) 191 using (MySqlCommand cmd2 = dbcon.CreateCommand())
185 { 192 {
186 cmd.CommandText = sql; 193 cmd2.CommandText = sql;
187 cmd.Parameters.Clear(); 194 cmd2.Parameters.Clear();
188 195
189 foreach (string name in FieldList) 196 foreach (string name in FieldList)
190 { 197 {
191 if (m_FieldMap[name].GetValue(es) is bool) 198 if (m_FieldMap[name].GetValue(es) is bool)
192 { 199 {
193 if ((bool)m_FieldMap[name].GetValue(es)) 200 if ((bool)m_FieldMap[name].GetValue(es))
194 cmd.Parameters.AddWithValue("?" + name, "1"); 201 cmd2.Parameters.AddWithValue("?" + name, "1");
195 else 202 else
196 cmd.Parameters.AddWithValue("?" + name, "0"); 203 cmd2.Parameters.AddWithValue("?" + name, "0");
197 } 204 }
198 else 205 else
199 { 206 {
200 cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); 207 cmd2.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString());
201 } 208 }
202 } 209 }
203 210
204 cmd.ExecuteNonQuery(); 211 cmd2.ExecuteNonQuery();
205 212
206 cmd.CommandText = "select LAST_INSERT_ID() as id"; 213 cmd2.CommandText = "select LAST_INSERT_ID() as id";
207 cmd.Parameters.Clear(); 214 cmd2.Parameters.Clear();
208 215
209 using (IDataReader r = cmd.ExecuteReader()) 216 using (IDataReader r = cmd2.ExecuteReader())
210 { 217 {
211 r.Read(); 218 r.Read();
212 es.EstateID = Convert.ToUInt32(r["id"]); 219 es.EstateID = Convert.ToUInt32(r["id"]);
213 } 220 }
214 221
215 cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; 222 cmd2.CommandText = "insert into estate_map values (?RegionID, ?EstateID)";
216 cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); 223 cmd2.Parameters.AddWithValue("?RegionID", regionID.ToString());
217 cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); 224 cmd2.Parameters.AddWithValue("?EstateID", es.EstateID.ToString());
218 225
219 // This will throw on dupe key 226 // This will throw on dupe key
220 try { cmd.ExecuteNonQuery(); } 227 try { cmd2.ExecuteNonQuery(); }
221 catch (Exception) { } 228 catch (Exception) { }
222 229
223 es.Save(); 230 es.Save();
@@ -390,5 +397,83 @@ namespace OpenSim.Data.MySQL
390 397
391 return uuids.ToArray(); 398 return uuids.ToArray();
392 } 399 }
400
401 public EstateSettings LoadEstateSettings(int estateID)
402 {
403 using (MySqlCommand cmd = new MySqlCommand())
404 {
405 string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + " from estate_settings where EstateID = ?EstateID";
406
407 cmd.CommandText = sql;
408 cmd.Parameters.AddWithValue("?EstateID", estateID);
409
410 return DoLoad(cmd, UUID.Zero, false);
411 }
412 }
413
414 public List<int> GetEstates(string search)
415 {
416 List<int> result = new List<int>();
417
418 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
419 {
420 dbcon.Open();
421
422 using (MySqlCommand cmd = dbcon.CreateCommand())
423 {
424 cmd.CommandText = "select estateID from estate_settings where EstateName = ?EstateName";
425 cmd.Parameters.AddWithValue("?EstateName", search);
426
427 using (IDataReader reader = cmd.ExecuteReader())
428 {
429 while (reader.Read())
430 {
431 result.Add(Convert.ToInt32(reader["EstateID"]));
432 }
433 reader.Close();
434 }
435 }
436
437
438 dbcon.Close();
439 }
440
441 return result;
442 }
443
444 public bool LinkRegion(UUID regionID, int estateID)
445 {
446 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
447 {
448 dbcon.Open();
449
450 using (MySqlCommand cmd = dbcon.CreateCommand())
451 {
452 cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)";
453 cmd.Parameters.AddWithValue("?RegionID", regionID);
454 cmd.Parameters.AddWithValue("?EstateID", estateID);
455
456 if (cmd.ExecuteNonQuery() == 0)
457 {
458 dbcon.Close();
459 return false;
460 }
461 }
462
463 dbcon.Close();
464 }
465
466 return true;
467 }
468
469 public List<UUID> GetRegions(int estateID)
470 {
471 return new List<UUID>();
472 }
473
474 public bool DeleteEstate(int estateID)
475 {
476 return false;
477 }
393 } 478 }
394} 479}
diff --git a/OpenSim/Data/SQLite/SQLiteEstateData.cs b/OpenSim/Data/SQLite/SQLiteEstateData.cs
index 4a447d2..5b6135e 100644
--- a/OpenSim/Data/SQLite/SQLiteEstateData.cs
+++ b/OpenSim/Data/SQLite/SQLiteEstateData.cs
@@ -320,5 +320,30 @@ namespace OpenSim.Data.SQLite
320 320
321 return uuids.ToArray(); 321 return uuids.ToArray();
322 } 322 }
323
324 public EstateSettings LoadEstateSettings(int estateID)
325 {
326 return new EstateSettings();
327 }
328
329 public List<int> GetEstates(string search)
330 {
331 return new List<int>();
332 }
333
334 public bool LinkRegion(UUID regionID, int estateID)
335 {
336 return false;
337 }
338
339 public List<UUID> GetRegions(int estateID)
340 {
341 return new List<UUID>();
342 }
343
344 public bool DeleteEstate(int estateID)
345 {
346 return false;
347 }
323 } 348 }
324} 349}
diff --git a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs b/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs
index 6861544..87c7a05 100644
--- a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs
@@ -25,6 +25,7 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System.Collections.Generic;
28using OpenMetaverse; 29using OpenMetaverse;
29using OpenSim.Framework; 30using OpenSim.Framework;
30 31
@@ -35,6 +36,11 @@ namespace OpenSim.Region.Framework.Interfaces
35 void Initialise(string connectstring); 36 void Initialise(string connectstring);
36 37
37 EstateSettings LoadEstateSettings(UUID regionID, bool create); 38 EstateSettings LoadEstateSettings(UUID regionID, bool create);
39 EstateSettings LoadEstateSettings(int estateID);
38 void StoreEstateSettings(EstateSettings es); 40 void StoreEstateSettings(EstateSettings es);
41 List<int> GetEstates(string search);
42 bool LinkRegion(UUID regionID, int estateID);
43 List<UUID> GetRegions(int estateID);
44 bool DeleteEstate(int estateID);
39 } 45 }
40} 46}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 078cf03..da81c03 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -604,7 +604,44 @@ namespace OpenSim.Region.Framework.Scenes
604 m_regInfo.RegionSettings = m_storageManager.DataStore.LoadRegionSettings(m_regInfo.RegionID); 604 m_regInfo.RegionSettings = m_storageManager.DataStore.LoadRegionSettings(m_regInfo.RegionID);
605 if (m_storageManager.EstateDataStore != null) 605 if (m_storageManager.EstateDataStore != null)
606 { 606 {
607 m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, true); 607 m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, false);
608 if (m_regInfo.EstateSettings.EstateID == 0) // No record at all
609 {
610 MainConsole.Instance.Output("Your region is not part of an estate.");
611 while (true)
612 {
613 string response = MainConsole.Instance.CmdPrompt("Do you wish to join an existing estate?", "no", new List<string>() {"yes", "no"});
614 if (response == "no")
615 {
616 // Create a new estate
617 m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, true);
618
619 m_regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", m_regInfo.EstateSettings.EstateName);
620 m_regInfo.EstateSettings.Save();
621 break;
622 }
623 else
624 {
625 response = MainConsole.Instance.CmdPrompt("Estate name to join", "None");
626 if (response == "None")
627 continue;
628
629 List<int> estateIDs = m_storageManager.EstateDataStore.GetEstates(response);
630 if (estateIDs.Count < 1)
631 {
632 MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again");
633 continue;
634 }
635
636 int estateID = estateIDs[0];
637
638 if (m_storageManager.EstateDataStore.LinkRegion(m_regInfo.RegionID, estateID))
639 break;
640
641 MainConsole.Instance.Output("Joining the estate failed. Please try again.");
642 }
643 }
644 }
608 } 645 }
609 646
610 //Bind Storage Manager functions to some land manager functions for this scene 647 //Bind Storage Manager functions to some land manager functions for this scene
@@ -1215,6 +1252,82 @@ namespace OpenSim.Region.Framework.Scenes
1215 m_dialogModule = RequestModuleInterface<IDialogModule>(); 1252 m_dialogModule = RequestModuleInterface<IDialogModule>();
1216 m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); 1253 m_capsModule = RequestModuleInterface<ICapabilitiesModule>();
1217 m_teleportModule = RequestModuleInterface<IEntityTransferModule>(); 1254 m_teleportModule = RequestModuleInterface<IEntityTransferModule>();
1255
1256 // Shoving this in here for now, because we have the needed
1257 // interfaces at this point
1258 //
1259 // TODO: Find a better place for this
1260 //
1261 while (m_regInfo.EstateSettings.EstateOwner == UUID.Zero)
1262 {
1263 MainConsole.Instance.Output("The current estate has no owner set.");
1264 string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test");
1265 string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User");
1266
1267 UserAccount account = UserAccountService.GetUserAccount(m_regInfo.ScopeID, first, last);
1268
1269 if (account == null)
1270 {
1271 account = new UserAccount(m_regInfo.ScopeID, first, last, String.Empty);
1272 if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0))
1273 {
1274 account.ServiceURLs = new Dictionary<string, object>();
1275 account.ServiceURLs["HomeURI"] = string.Empty;
1276 account.ServiceURLs["GatekeeperURI"] = string.Empty;
1277 account.ServiceURLs["InventoryServerURI"] = string.Empty;
1278 account.ServiceURLs["AssetServerURI"] = string.Empty;
1279 }
1280
1281 if (UserAccountService.StoreUserAccount(account))
1282 {
1283 string password = MainConsole.Instance.PasswdPrompt("Password");
1284 string email = MainConsole.Instance.CmdPrompt("Email", "");
1285
1286 account.Email = email;
1287 UserAccountService.StoreUserAccount(account);
1288
1289 bool success = false;
1290 success = AuthenticationService.SetPassword(account.PrincipalID, password);
1291 if (!success)
1292 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.",
1293 first, last);
1294
1295 GridRegion home = null;
1296 if (GridService != null)
1297 {
1298 List<GridRegion> defaultRegions = GridService.GetDefaultRegions(UUID.Zero);
1299 if (defaultRegions != null && defaultRegions.Count >= 1)
1300 home = defaultRegions[0];
1301
1302 if (PresenceService != null && home != null)
1303 PresenceService.SetHomeLocation(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0));
1304 else
1305 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.",
1306 first, last);
1307
1308 }
1309 else
1310 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.",
1311 first, last);
1312
1313 if (InventoryService != null)
1314 success = InventoryService.CreateUserInventory(account.PrincipalID);
1315 if (!success)
1316 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.",
1317 first, last);
1318
1319
1320 m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", first, last);
1321
1322 m_regInfo.EstateSettings.EstateOwner = account.PrincipalID;
1323 m_regInfo.EstateSettings.Save();
1324 }
1325 }
1326 else
1327 {
1328 MainConsole.Instance.Output("You appear to be connected to a grid and can't create users from here. Please enter the name of an existing user");
1329 }
1330 }
1218 } 1331 }
1219 1332
1220 #endregion 1333 #endregion
diff --git a/OpenSim/Services/Interfaces/IUserAccountService.cs b/OpenSim/Services/Interfaces/IUserAccountService.cs
index a45bf8c..befd14e 100644
--- a/OpenSim/Services/Interfaces/IUserAccountService.cs
+++ b/OpenSim/Services/Interfaces/IUserAccountService.cs
@@ -150,10 +150,10 @@ namespace OpenSim.Services.Interfaces
150 List<UserAccount> GetUserAccounts(UUID scopeID, string query); 150 List<UserAccount> GetUserAccounts(UUID scopeID, string query);
151 151
152 /// <summary> 152 /// <summary>
153 /// Store the data given, wich replaces the sotred data, therefore must be complete. 153 /// Store the data given, wich replaces the stored data, therefore must be complete.
154 /// </summary> 154 /// </summary>
155 /// <param name="data"></param> 155 /// <param name="data"></param>
156 /// <returns></returns> 156 /// <returns></returns>
157 bool StoreUserAccount(UserAccount data); 157 bool StoreUserAccount(UserAccount data);
158 } 158 }
159} \ No newline at end of file 159}