aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie Thielker2010-07-03 20:27:00 +0200
committerMelanie Thielker2010-07-03 20:27:00 +0200
commitedcfaf60c99b7cde324621c2ffcfbb16e4eb4c5e (patch)
treed48676190d41a69cb6aebff794c6291cd93198c4 /OpenSim
parentMerge branch 'careminster-presence-refactor' of ssh://3dhosting.de/var/git/ca... (diff)
downloadopensim-SC_OLD-edcfaf60c99b7cde324621c2ffcfbb16e4eb4c5e.zip
opensim-SC_OLD-edcfaf60c99b7cde324621c2ffcfbb16e4eb4c5e.tar.gz
opensim-SC_OLD-edcfaf60c99b7cde324621c2ffcfbb16e4eb4c5e.tar.bz2
opensim-SC_OLD-edcfaf60c99b7cde324621c2ffcfbb16e4eb4c5e.tar.xz
Fix IMs the right way. This sets it up so that timestamps are actually
in PST (to match viewer time), does correct storage and retrieval of IMs, corrects the session ID and makes sure IMs don't get marked "saved" if they're live. Removes the group IM save option, which our group IM module never had in the first place, as saving group chatter makes no sense at all.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs27
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs65
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs22
4 files changed, 86 insertions, 35 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
index a7aa4ea..ffdac58 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
@@ -156,16 +156,31 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
156 return; 156 return;
157 } 157 }
158 158
159 // Force timestamp to server time to avoid "Saved on" headers 159 DateTime dt = DateTime.UtcNow;
160 // being generated for online users
161 im.timestamp = (uint)Util.UnixTimeSinceEpoch();
162 160
163 if (dialog == (byte)InstantMessageDialog.MessageFromAgent || 161 // Ticks from UtcNow, but make it look like local. Evil, huh?
164 dialog == (byte)InstantMessageDialog.MessageFromObject) 162 dt = DateTime.SpecifyKind(dt, DateTimeKind.Local);
163
164 try
165 {
166 // Convert that to the PST timezone
167 TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles");
168 dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo);
169 }
170 catch
165 { 171 {
166 im.offline = 1; 172 m_log.Info("[OFFLINE MESSAGING]: No PST timezone found on this machine. Saving with local timestamp.");
167 } 173 }
168 174
175 // And make it look local again to fool the unix time util
176 dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc);
177
178 im.timestamp = (uint)Util.ToUnixTime(dt);
179
180 // If client is null, this message comes from storage and IS offline
181 if (client != null)
182 im.offline = 0;
183
169 if (m_TransferModule != null) 184 if (m_TransferModule != null)
170 { 185 {
171 m_TransferModule.SendInstantMessage(im, 186 m_TransferModule.SendInstantMessage(im,
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
index a2dc91f..feeb9e6 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
@@ -192,6 +192,17 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
192 // Needed for proper state management for stored group 192 // Needed for proper state management for stored group
193 // invitations 193 // invitations
194 // 194 //
195
196 im.offline = 1;
197
198 // Reconstruct imSessionID
199 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
200 {
201 UUID fromAgentID = new UUID(im.fromAgentID);
202 UUID sessionID = fromAgentID ^ client.AgentId;
203 im.imSessionID = new Guid(sessionID.ToString());
204 }
205
195 Scene s = FindScene(client.AgentId); 206 Scene s = FindScene(client.AgentId);
196 if (s != null) 207 if (s != null)
197 s.EventManager.TriggerIncomingInstantMessage(im); 208 s.EventManager.TriggerIncomingInstantMessage(im);
@@ -201,35 +212,37 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
201 212
202 private void UndeliveredMessage(GridInstantMessage im) 213 private void UndeliveredMessage(GridInstantMessage im)
203 { 214 {
204 if (im.dialog == 19) 215 if (im.dialog != (byte)InstantMessageDialog.MessageFromObject &&
205 im.offline = 1; // We want them pushed out to the server 216 im.dialog != (byte)InstantMessageDialog.MessageFromAgent &&
206 if ((im.offline != 0) 217 im.dialog != (byte)InstantMessageDialog.GroupNotice &&
207 && (!im.fromGroup || (im.fromGroup && m_ForwardOfflineGroupMessages))) 218 im.dialog != (byte)InstantMessageDialog.InventoryOffered)
208 { 219 {
209 // It's not delivered. Make sure the scope id is saved 220 return;
210 // We don't need the imSessionID here anymore, overwrite it 221 }
211 Scene scene = FindScene(new UUID(im.fromAgentID));
212 if (scene == null)
213 scene = m_SceneList[0];
214 im.imSessionID = new Guid(scene.RegionInfo.ScopeID.ToString());
215 222
216 bool success = SynchronousRestObjectPoster.BeginPostObject<GridInstantMessage, bool>( 223 // It's not delivered. Make sure the scope id is saved
217 "POST", m_RestURL+"/SaveMessage/", im); 224 // We don't need the imSessionID here anymore, overwrite it
225 Scene scene = FindScene(new UUID(im.fromAgentID));
226 if (scene == null)
227 scene = m_SceneList[0];
228 im.imSessionID = new Guid(scene.RegionInfo.ScopeID.ToString());
218 229
219 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) 230 bool success = SynchronousRestObjectPoster.BeginPostObject<GridInstantMessage, bool>(
220 { 231 "POST", m_RestURL+"/SaveMessage/", im);
221 IClientAPI client = FindClient(new UUID(im.fromAgentID)); 232
222 if (client == null) 233 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
223 return; 234 {
224 235 IClientAPI client = FindClient(new UUID(im.fromAgentID));
225 client.SendInstantMessage(new GridInstantMessage( 236 if (client == null)
226 null, new UUID(im.toAgentID), 237 return;
227 "System", new UUID(im.fromAgentID), 238
228 (byte)InstantMessageDialog.MessageFromAgent, 239 client.SendInstantMessage(new GridInstantMessage(
229 "User is not logged in. "+ 240 null, new UUID(im.toAgentID),
230 (success ? "Message saved." : "Message not saved"), 241 "System", new UUID(im.fromAgentID),
231 false, new Vector3())); 242 (byte)InstantMessageDialog.MessageFromAgent,
232 } 243 "User is not logged in. "+
244 (success ? "Message saved." : "Message not saved"),
245 false, new Vector3()));
233 } 246 }
234 } 247 }
235 } 248 }
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 4a4cac9..e51d9ee 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -3730,8 +3730,11 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos);
3730 { 3730 {
3731 CollidingMessage.Colliders = colliding; 3731 CollidingMessage.Colliders = colliding;
3732 3732
3733 foreach (SceneObjectGroup att in Attachments) 3733 lock (m_attachments)
3734 Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); 3734 {
3735 foreach (SceneObjectGroup att in m_attachments)
3736 Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage);
3737 }
3735 } 3738 }
3736 } 3739 }
3737 3740
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 11d7c2b..f153504 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -3252,7 +3252,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3252 msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here 3252 msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here
3253// m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); 3253// m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message);
3254// m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); 3254// m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString());
3255 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp; 3255 DateTime dt = DateTime.UtcNow;
3256
3257 // Ticks from UtcNow, but make it look like local. Evil, huh?
3258 dt = DateTime.SpecifyKind(dt, DateTimeKind.Local);
3259
3260 try
3261 {
3262 // Convert that to the PST timezone
3263 TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles");
3264 dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo);
3265 }
3266 catch
3267 {
3268 // No logging here, as it could be VERY spammy
3269 }
3270
3271 // And make it look local again to fool the unix time util
3272 dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc);
3273
3274 msg.timestamp = (uint)Util.ToUnixTime(dt);
3275
3256 //if (client != null) 3276 //if (client != null)
3257 //{ 3277 //{
3258 msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; 3278 msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName;