aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
authorMelanie2009-12-28 23:42:08 +0000
committerMelanie2009-12-28 23:42:08 +0000
commite0fc854f05b137c353196356e5b26d11b6ee6867 (patch)
tree9a1c0a29178a9f3e10b10f5e184f46bce1c61078 /OpenSim/Data
parentAdd the second step of the friends migration to pull data from the old table ... (diff)
downloadopensim-SC_OLD-e0fc854f05b137c353196356e5b26d11b6ee6867.zip
opensim-SC_OLD-e0fc854f05b137c353196356e5b26d11b6ee6867.tar.gz
opensim-SC_OLD-e0fc854f05b137c353196356e5b26d11b6ee6867.tar.bz2
opensim-SC_OLD-e0fc854f05b137c353196356e5b26d11b6ee6867.tar.xz
Adding new fields and home location methid to presence. Adding cleanup
(deleting all but one presence record) on logout so that they don't pile up.
Diffstat (limited to 'OpenSim/Data')
-rw-r--r--OpenSim/Data/IPresenceData.cs3
-rw-r--r--OpenSim/Data/MySQL/MySQLGenericTableHandler.cs2
-rw-r--r--OpenSim/Data/MySQL/MySQLPresenceData.cs52
3 files changed, 57 insertions, 0 deletions
diff --git a/OpenSim/Data/IPresenceData.cs b/OpenSim/Data/IPresenceData.cs
index 98353ed..20eb7f6 100644
--- a/OpenSim/Data/IPresenceData.cs
+++ b/OpenSim/Data/IPresenceData.cs
@@ -51,6 +51,9 @@ namespace OpenSim.Data
51 PresenceData Get(UUID sessionID); 51 PresenceData Get(UUID sessionID);
52 void LogoutRegionAgents(UUID regionID); 52 void LogoutRegionAgents(UUID regionID);
53 bool ReportAgent(UUID sessionID, UUID regionID, string position, string lookAt); 53 bool ReportAgent(UUID sessionID, UUID regionID, string position, string lookAt);
54 bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt);
54 PresenceData[] Get(string field, string data); 55 PresenceData[] Get(string field, string data);
56 void Prune(string userID);
57 bool Delete(string field, string val);
55 } 58 }
56} 59}
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
index b2bd5f6..873d6d4 100644
--- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
+++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
@@ -177,6 +177,8 @@ namespace OpenSim.Data.MySQL
177 result.Add(row); 177 result.Add(row);
178 } 178 }
179 179
180 reader.Close();
181
180 CloseReaderCommand(cmd); 182 CloseReaderCommand(cmd);
181 183
182 return result.ToArray(); 184 return result.ToArray();
diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs
index 8ccad90..72b8a0c 100644
--- a/OpenSim/Data/MySQL/MySQLPresenceData.cs
+++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs
@@ -93,5 +93,57 @@ namespace OpenSim.Data.MySQL
93 93
94 return true; 94 return true;
95 } 95 }
96
97 public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
98 {
99 PresenceData[] pd = Get("UserID", userID);
100 if (pd.Length == 0)
101 return false;
102
103 MySqlCommand cmd = new MySqlCommand();
104
105 cmd.CommandText = String.Format("update {0} set HomeRegionID=?HomeRegionID, HomePosition=?HomePosition, HomeLookAt=?HomeLookAt where UserID=?UserID", m_Realm);
106
107 cmd.Parameters.AddWithValue("?UserID", userID);
108 cmd.Parameters.AddWithValue("?HomeRegionID", regionID.ToString());
109 cmd.Parameters.AddWithValue("?HomePosition", position);
110 cmd.Parameters.AddWithValue("?HomeLookAt", lookAt);
111
112 if (ExecuteNonQuery(cmd) == 0)
113 return false;
114
115 return true;
116 }
117
118 public void Prune(string userID)
119 {
120 MySqlCommand cmd = new MySqlCommand();
121
122 cmd.CommandText = String.Format("select * from {0} where UserID=?UserID", m_Realm);
123
124 cmd.Parameters.AddWithValue("?UserID", userID);
125
126 IDataReader reader = ExecuteReader(cmd);
127
128 List<UUID> deleteSessions = new List<UUID>();
129 int online = 0;
130
131 while(reader.Read())
132 {
133 if (bool.Parse(reader["Online"].ToString()))
134 online++;
135 else
136 deleteSessions.Add(new UUID(reader["SessionID"].ToString()));
137 }
138
139 if (online == 0 && deleteSessions.Count > 0)
140 deleteSessions.RemoveAt(0);
141
142 reader.Close();
143 CloseReaderCommand(cmd);
144
145 foreach (UUID s in deleteSessions)
146 Delete("SessionID", s.ToString());
147 }
96 } 148 }
97} 149}