aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAdam Frisby2007-05-05 23:04:47 +0000
committerAdam Frisby2007-05-05 23:04:47 +0000
commit6d6117e0196e8aabccee2a8879b0b6ad950ab3ab (patch)
tree61d8e736ebd1a407010900d2839fbfdf83ea37d7
parentGrid Framework for DB4o - supports all framework.data interfaces. (diff)
downloadopensim-SC-6d6117e0196e8aabccee2a8879b0b6ad950ab3ab.zip
opensim-SC-6d6117e0196e8aabccee2a8879b0b6ad950ab3ab.tar.gz
opensim-SC-6d6117e0196e8aabccee2a8879b0b6ad950ab3ab.tar.bz2
opensim-SC-6d6117e0196e8aabccee2a8879b0b6ad950ab3ab.tar.xz
You can now save profiles to a database. (Zomg!)
Diffstat (limited to '')
-rw-r--r--OpenGrid.Framework.Data.DB4o/DB4oGridData.cs5
-rw-r--r--OpenGrid.Framework.Data.DB4o/DB4oManager.cs29
-rw-r--r--OpenGrid.Framework.Data.MySQL/MySQLGridData.cs12
-rw-r--r--OpenGrid.Framework.Data.MySQL/MySQLManager.cs53
-rw-r--r--OpenGrid.Framework.Data/GridData.cs15
-rw-r--r--OpenGridServices.GridServer/GridManager.cs12
6 files changed, 123 insertions, 3 deletions
diff --git a/OpenGrid.Framework.Data.DB4o/DB4oGridData.cs b/OpenGrid.Framework.Data.DB4o/DB4oGridData.cs
index d15e343..c8152f4 100644
--- a/OpenGrid.Framework.Data.DB4o/DB4oGridData.cs
+++ b/OpenGrid.Framework.Data.DB4o/DB4oGridData.cs
@@ -39,6 +39,11 @@ namespace OpenGrid.Framework.Data.DB4o
39 throw new Exception("Unable to find profile with UUID (" + uuid.ToStringHyphenated() + ")"); 39 throw new Exception("Unable to find profile with UUID (" + uuid.ToStringHyphenated() + ")");
40 } 40 }
41 41
42 public DataResponse AddProfile(SimProfileData profile)
43 {
44 return DataResponse.RESPONSE_OK;
45 }
46
42 public bool AuthenticateSim(LLUUID uuid, ulong handle, string key) { 47 public bool AuthenticateSim(LLUUID uuid, ulong handle, string key) {
43 if (manager.profiles[uuid].regionRecvKey == key) 48 if (manager.profiles[uuid].regionRecvKey == key)
44 return true; 49 return true;
diff --git a/OpenGrid.Framework.Data.DB4o/DB4oManager.cs b/OpenGrid.Framework.Data.DB4o/DB4oManager.cs
index f889636..3ebcee2 100644
--- a/OpenGrid.Framework.Data.DB4o/DB4oManager.cs
+++ b/OpenGrid.Framework.Data.DB4o/DB4oManager.cs
@@ -10,11 +10,13 @@ namespace OpenGrid.Framework.Data.DB4o
10 class DB4oManager 10 class DB4oManager
11 { 11 {
12 public Dictionary<LLUUID, SimProfileData> profiles = new Dictionary<LLUUID, SimProfileData>(); 12 public Dictionary<LLUUID, SimProfileData> profiles = new Dictionary<LLUUID, SimProfileData>();
13 13 string dbfl;
14
14 public DB4oManager(string db4odb) 15 public DB4oManager(string db4odb)
15 { 16 {
17 dbfl = db4odb;
16 IObjectContainer database; 18 IObjectContainer database;
17 database = Db4oFactory.OpenFile(db4odb); 19 database = Db4oFactory.OpenFile(dbfl);
18 IObjectSet result = database.Get(typeof(SimProfileData)); 20 IObjectSet result = database.Get(typeof(SimProfileData));
19 foreach(SimProfileData row in result) { 21 foreach(SimProfileData row in result) {
20 profiles.Add(row.UUID, row); 22 profiles.Add(row.UUID, row);
@@ -22,6 +24,29 @@ namespace OpenGrid.Framework.Data.DB4o
22 database.Close(); 24 database.Close();
23 } 25 }
24 26
27 /// <summary>
28 /// Adds a new profile to the database (Warning: Probably slow.)
29 /// </summary>
30 /// <param name="row">The profile to add</param>
31 /// <returns>Successful?</returns>
32 public bool AddRow(SimProfileData row)
33 {
34 profiles.Add(row.UUID, row);
35
36 try
37 {
38 IObjectContainer database;
39 database = Db4oFactory.OpenFile(dbfl);
40 database.Set(row);
41 database.Close();
42 return true;
43 }
44 catch (Exception e)
45 {
46 return false;
47 }
48 }
49
25 50
26 } 51 }
27} 52}
diff --git a/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs b/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs
index 0a84cdb..4404a16 100644
--- a/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs
+++ b/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs
@@ -75,6 +75,18 @@ namespace OpenGrid.Framework.Data.MySQL
75 return row; 75 return row;
76 } 76 }
77 77
78 public DataResponse AddProfile(SimProfileData profile)
79 {
80 if (database.insertRow(profile))
81 {
82 return DataResponse.RESPONSE_OK;
83 }
84 else
85 {
86 return DataResponse.RESPONSE_ERROR;
87 }
88 }
89
78 /// <summary> 90 /// <summary>
79 /// DEPRECIATED. Attempts to authenticate a region by comparing a shared secret. 91 /// DEPRECIATED. Attempts to authenticate a region by comparing a shared secret.
80 /// </summary> 92 /// </summary>
diff --git a/OpenGrid.Framework.Data.MySQL/MySQLManager.cs b/OpenGrid.Framework.Data.MySQL/MySQLManager.cs
index 057cd42..d3bfa18 100644
--- a/OpenGrid.Framework.Data.MySQL/MySQLManager.cs
+++ b/OpenGrid.Framework.Data.MySQL/MySQLManager.cs
@@ -117,5 +117,58 @@ namespace OpenGrid.Framework.Data.MySQL
117 } 117 }
118 return retval; 118 return retval;
119 } 119 }
120
121 public bool insertRow(SimProfileData profile) {
122 string sql = "REPLACE INTO regions VALUES (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, ";
123 sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, ";
124 sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey) VALUES ";
125
126 sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, ";
127 sql += "@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, ";
128 sql += "@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey);";
129
130 Dictionary<string, string> parameters = new Dictionary<string,string>();
131
132 parameters["regionHandle"] = profile.regionHandle.ToString();
133 parameters["regionName"] = profile.regionName;
134 parameters["uuid"] = profile.UUID.ToString();
135 parameters["regionRecvKey"] = profile.regionRecvKey;
136 parameters["regionSendKey"] = profile.regionSendKey;
137 parameters["regionDataURI"] = profile.regionDataURI;
138 parameters["serverIP"] = profile.serverIP;
139 parameters["serverPort"] = profile.serverPort.ToString();
140 parameters["serverURI"] = profile.serverURI;
141 parameters["locX"] = profile.regionLocX.ToString();
142 parameters["locY"] = profile.regionLocY.ToString();
143 parameters["locZ"] = profile.regionLocZ.ToString();
144 parameters["eastOverrideHandle"] = profile.regionEastOverrideHandle.ToString();
145 parameters["westOverrideHandle"] = profile.regionWestOverrideHandle.ToString();
146 parameters["northOverrideHandle"] = profile.regionNorthOverrideHandle.ToString();
147 parameters["southOverrideHandle"] = profile.regionSouthOverrideHandle.ToString();
148 parameters["regionAssetURI"] = profile.regionAssetURI;
149 parameters["regionAssetRecvKey"] = profile.regionAssetRecvKey;
150 parameters["regionAssetSendKey"] = profile.regionAssetSendKey;
151 parameters["regionUserURI"] = profile.regionUserURI;
152 parameters["regionUserRecvKey"] = profile.regionUserRecvKey;
153 parameters["regionUserSendKey"] = profile.regionUserSendKey;
154
155 bool returnval = false;
156
157 try
158 {
159 IDbCommand result = Query(sql, parameters);
160
161 if (result.ExecuteNonQuery() == 1)
162 returnval = true;
163
164 result.Dispose();
165 }
166 catch (Exception e)
167 {
168 return false;
169 }
170
171 return returnval;
172 }
120 } 173 }
121} 174}
diff --git a/OpenGrid.Framework.Data/GridData.cs b/OpenGrid.Framework.Data/GridData.cs
index 3b052fb..d5516b2 100644
--- a/OpenGrid.Framework.Data/GridData.cs
+++ b/OpenGrid.Framework.Data/GridData.cs
@@ -4,6 +4,14 @@ using System.Text;
4 4
5namespace OpenGrid.Framework.Data 5namespace OpenGrid.Framework.Data
6{ 6{
7 public enum DataResponse
8 {
9 RESPONSE_OK,
10 RESPONSE_AUTHREQUIRED,
11 RESPONSE_INVALIDCREDENTIALS,
12 RESPONSE_ERROR
13 }
14
7 /// <summary> 15 /// <summary>
8 /// A standard grid interface 16 /// A standard grid interface
9 /// </summary> 17 /// </summary>
@@ -54,5 +62,12 @@ namespace OpenGrid.Framework.Data
54 /// </summary> 62 /// </summary>
55 /// <returns>A string containing the plugin version</returns> 63 /// <returns>A string containing the plugin version</returns>
56 string getVersion(); 64 string getVersion();
65
66 /// <summary>
67 /// Adds a new profile to the database
68 /// </summary>
69 /// <param name="profile">The profile to add</param>
70 /// <returns>RESPONSE_OK if successful, error if not.</returns>
71 DataResponse AddProfile(SimProfileData profile);
57 } 72 }
58} 73}
diff --git a/OpenGridServices.GridServer/GridManager.cs b/OpenGridServices.GridServer/GridManager.cs
index b3b97a1..8cff0d3 100644
--- a/OpenGridServices.GridServer/GridManager.cs
+++ b/OpenGridServices.GridServer/GridManager.cs
@@ -320,7 +320,17 @@ namespace OpenGridServices.GridServer
320 320
321 try 321 try
322 { 322 {
323 // NEEDS IMPLEMENTATION. 323 foreach (KeyValuePair<string, IGridData> kvp in _plugins)
324 {
325 try
326 {
327 kvp.Value.AddProfile(TheSim);
328 }
329 catch (Exception e)
330 {
331 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("getRegionPlugin Handle " + kvp.Key + " unable to add new sim: " + e.ToString());
332 }
333 }
324 return "OK"; 334 return "OK";
325 } 335 }
326 catch (Exception e) 336 catch (Exception e)