aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Framework/GridInstantMessage.cs6
-rw-r--r--OpenSim/Framework/IClientAPI.cs7
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs20
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs158
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs17
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs30
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/InstantMessage/MessageTransferModule.cs8
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Inventory/Transfer/InventoryTransferModule.cs49
-rw-r--r--OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs7
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs1
11 files changed, 134 insertions, 170 deletions
diff --git a/OpenSim/Framework/GridInstantMessage.cs b/OpenSim/Framework/GridInstantMessage.cs
index 9cecf42..64eec22 100644
--- a/OpenSim/Framework/GridInstantMessage.cs
+++ b/OpenSim/Framework/GridInstantMessage.cs
@@ -35,7 +35,6 @@ namespace OpenSim.Framework
35 { 35 {
36 public Guid fromAgentID; 36 public Guid fromAgentID;
37 public string fromAgentName; 37 public string fromAgentName;
38 public Guid fromAgentSession;
39 public Guid toAgentID; 38 public Guid toAgentID;
40 public byte dialog; 39 public byte dialog;
41 public bool fromGroup; 40 public bool fromGroup;
@@ -56,14 +55,13 @@ namespace OpenSim.Framework
56 } 55 }
57 56
58 public GridInstantMessage(IScene scene, UUID _fromAgentID, 57 public GridInstantMessage(IScene scene, UUID _fromAgentID,
59 string _fromAgentName, UUID _fromAgentSession, UUID _toAgentID, 58 string _fromAgentName, UUID _toAgentID,
60 byte _dialog, bool _fromGroup, string _message, 59 byte _dialog, bool _fromGroup, string _message,
61 UUID _imSessionID, bool _offline, Vector3 _position, 60 UUID _imSessionID, bool _offline, Vector3 _position,
62 byte[] _binaryBucket) 61 byte[] _binaryBucket)
63 { 62 {
64 fromAgentID = _fromAgentID.Guid; 63 fromAgentID = _fromAgentID.Guid;
65 fromAgentName = _fromAgentName; 64 fromAgentName = _fromAgentName;
66 fromAgentSession = _fromAgentSession.Guid;
67 toAgentID = _toAgentID.Guid; 65 toAgentID = _toAgentID.Guid;
68 dialog = _dialog; 66 dialog = _dialog;
69 fromGroup = _fromGroup; 67 fromGroup = _fromGroup;
@@ -88,7 +86,7 @@ namespace OpenSim.Framework
88 string _fromAgentName, UUID _toAgentID, byte _dialog, 86 string _fromAgentName, UUID _toAgentID, byte _dialog,
89 string _message, bool _offline, 87 string _message, bool _offline,
90 Vector3 _position) : this(scene, _fromAgentID, _fromAgentName, 88 Vector3 _position) : this(scene, _fromAgentID, _fromAgentName,
91 UUID.Zero, _toAgentID, _dialog, false, _message, 89 _toAgentID, _dialog, false, _message,
92 _fromAgentID ^ _toAgentID, _offline, _position, new byte[0]) 90 _fromAgentID ^ _toAgentID, _offline, _position, new byte[0])
93 { 91 {
94 } 92 }
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index ff2ca25..add177d 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -46,12 +46,7 @@ namespace OpenSim.Framework
46 46
47 public delegate void AvatarNowWearing(Object sender, AvatarWearingArgs e); 47 public delegate void AvatarNowWearing(Object sender, AvatarWearingArgs e);
48 48
49 public delegate void ImprovedInstantMessage(IClientAPI remoteclient, 49 public delegate void ImprovedInstantMessage(IClientAPI remoteclient, GridInstantMessage im);
50 UUID fromAgentID, UUID fromAgentSession, UUID toAgentID,
51 UUID imSessionID, uint timestamp,
52 string fromAgentName, string message, byte dialog, bool fromGroup,
53 byte offline, uint ParentEstateID,
54 Vector3 Position, UUID RegionID, byte[] binaryBucket);
55 50
56 // This shouldn't be cut down... 51 // This shouldn't be cut down...
57 // especially if we're ever going to implement groups, presence, estate message dialogs... 52 // especially if we're ever going to implement groups, presence, estate message dialogs...
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 3aa3fea..3933cf7 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -4030,13 +4030,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4030 4030
4031 if (handlerInstantMessage != null) 4031 if (handlerInstantMessage != null)
4032 { 4032 {
4033 handlerInstantMessage(this, msgpack.AgentData.AgentID, msgpack.AgentData.SessionID, 4033 GridInstantMessage im = new GridInstantMessage(Scene,
4034 msgpack.MessageBlock.ToAgentID, msgpack.MessageBlock.ID, 4034 msgpack.AgentData.AgentID,
4035 msgpack.MessageBlock.Timestamp, IMfromName, IMmessage, 4035 IMfromName,
4036 msgpack.MessageBlock.Dialog, msgpack.MessageBlock.FromGroup, 4036 msgpack.MessageBlock.ToAgentID,
4037 msgpack.MessageBlock.Offline, msgpack.MessageBlock.ParentEstateID, 4037 msgpack.MessageBlock.Dialog,
4038 msgpack.MessageBlock.Position, msgpack.MessageBlock.RegionID, 4038 msgpack.MessageBlock.FromGroup,
4039 msgpack.MessageBlock.BinaryBucket); 4039 IMmessage,
4040 msgpack.MessageBlock.ID,
4041 msgpack.MessageBlock.Offline != 0 ? true : false,
4042 msgpack.MessageBlock.Position,
4043 msgpack.MessageBlock.BinaryBucket);
4044
4045 handlerInstantMessage(this, im);
4040 } 4046 }
4041 break; 4047 break;
4042 4048
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs
index 72c64ad..f07cd4c 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs
@@ -263,7 +263,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
263 // to a user to 'add a friend' without causing dialog box spam 263 // to a user to 'add a friend' without causing dialog box spam
264 264
265 // Subscribe to instant messages 265 // Subscribe to instant messages
266 client.OnInstantMessage += OnInstantMessage; 266// client.OnInstantMessage += OnInstantMessage;
267 267
268 // Friend list management 268 // Friend list management
269 client.OnApproveFriendRequest += OnApproveFriendRequest; 269 client.OnApproveFriendRequest += OnApproveFriendRequest;
@@ -370,7 +370,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
370 #region FriendRequestHandling 370 #region FriendRequestHandling
371 371
372 private void OnInstantMessage(IClientAPI client, UUID fromAgentID, 372 private void OnInstantMessage(IClientAPI client, UUID fromAgentID,
373 UUID fromAgentSession, UUID toAgentID, 373 UUID toAgentID,
374 UUID imSessionID, uint timestamp, string fromAgentName, 374 UUID imSessionID, uint timestamp, string fromAgentName,
375 string message, byte dialog, bool fromGroup, byte offline, 375 string message, byte dialog, bool fromGroup, byte offline,
376 uint ParentEstateID, Vector3 Position, UUID RegionID, 376 uint ParentEstateID, Vector3 Position, UUID RegionID,
@@ -393,86 +393,65 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
393 // some properties are misused here: 393 // some properties are misused here:
394 // fromAgentName is the *destination* name (the friend we offer friendship to) 394 // fromAgentName is the *destination* name (the friend we offer friendship to)
395 395
396 if (fromAgentSession != UUID.Zero) 396 // (1)
397 { 397 // send the friendship-offer to the target
398 // (1) 398 m_log.InfoFormat("[FRIEND]: Offer(38) - From: {0}, FromName: {1} To: {2}, Session: {3}, Message: {4}, Offline {5}",
399 // send the friendship-offer to the target 399 fromAgentID, fromAgentName, toAgentID, imSessionID, message, offline);
400 m_log.InfoFormat("[FRIEND]: Offer(38) - From: {0}, FromName: {1} To: {2}, Session: {3}, Message: {4}, Offline {5}",
401 fromAgentID, fromAgentName, toAgentID, imSessionID, message, offline);
402
403 UUID transactionID = UUID.Random();
404
405 // 1.20 protocol sends an UUID in the message field, instead of the friendship offer text.
406 // For interoperability, we have to clear that
407 if (Util.isUUID(message)) message = "";
408
409 GridInstantMessage msg = new GridInstantMessage();
410 msg.fromAgentID = fromAgentID.Guid;
411 msg.fromAgentSession = UUID.Zero.Guid; // server IMs don't have a session
412 msg.toAgentID = toAgentID.Guid;
413 msg.imSessionID = transactionID.Guid; // Start new transaction
414 m_log.DebugFormat("[FRIEND]: new transactionID: {0}", msg.imSessionID);
415 msg.timestamp = timestamp;
416 if (client != null)
417 {
418 msg.fromAgentName = client.Name; // fromAgentName;
419 }
420 else
421 {
422 msg.fromAgentName = "(hippos)"; // Added for posterity. This means that we can't figure out who sent it
423 }
424 msg.message = message;
425 msg.dialog = dialog;
426 msg.fromGroup = fromGroup;
427 msg.offline = offline;
428 msg.ParentEstateID = ParentEstateID;
429 msg.Position = Position;
430 msg.RegionID = RegionID.Guid;
431 msg.binaryBucket = binaryBucket;
432
433 m_log.DebugFormat("[FRIEND]: storing transactionID {0} on sender side", transactionID);
434 lock (m_pendingFriendRequests)
435 {
436 m_pendingFriendRequests.Add(transactionID, new Transaction(fromAgentID, fromAgentName));
437 outPending();
438 }
439 400
440 // we don't want to get that new IM into here if we aren't local, as only on the destination 401 UUID transactionID = UUID.Random();
441 // should receive it. If we *are* local, *we* are the destination, so we have to receive it.
442 // As grid-IMs are routed to all modules (in contrast to local IMs), we have to decide here.
443 402
444 // We don't really care which local scene we pipe it through. 403 // 1.20 protocol sends an UUID in the message field, instead of the friendship offer text.
445 if (m_TransferModule != null) 404 // For interoperability, we have to clear that
446 { 405 if (Util.isUUID(message)) message = "";
447 m_TransferModule.SendInstantMessage(msg, 406
448 delegate(bool success) {} 407 GridInstantMessage msg = new GridInstantMessage();
449 ); 408 msg.fromAgentID = fromAgentID.Guid;
450 } 409 msg.toAgentID = toAgentID.Guid;
410 msg.imSessionID = transactionID.Guid; // Start new transaction
411 m_log.DebugFormat("[FRIEND]: new transactionID: {0}", msg.imSessionID);
412 msg.timestamp = timestamp;
413 if (client != null)
414 {
415 msg.fromAgentName = client.Name; // fromAgentName;
451 } 416 }
452 else 417 else
453 { 418 {
454 // (2) 419 msg.fromAgentName = "(hippos)"; // Added for posterity. This means that we can't figure out who sent it
455 // we are on the receiving end here; just add the transactionID to the stored transactions for later lookup 420 }
456 m_log.DebugFormat("[FRIEND]: storing transactionID {0} on receiver side", imSessionID); 421 msg.message = message;
457 lock (m_pendingFriendRequests) 422 msg.dialog = dialog;
458 { 423 msg.fromGroup = fromGroup;
459 // if both are on the same region-server, the transaction is stored already, but we have to update the name 424 msg.offline = offline;
460 if (m_pendingFriendRequests.ContainsKey(imSessionID)) 425 msg.ParentEstateID = ParentEstateID;
461 { 426 msg.Position = Position;
462 m_pendingFriendRequests[imSessionID].agentName = fromAgentName; 427 msg.RegionID = RegionID.Guid;
463 m_pendingFriendRequests[imSessionID].count++; 428 msg.binaryBucket = binaryBucket;
464 } 429
465 else m_pendingFriendRequests.Add(imSessionID, new Transaction(fromAgentID, fromAgentName)); 430 m_log.DebugFormat("[FRIEND]: storing transactionID {0} on sender side", transactionID);
466 outPending(); 431 lock (m_pendingFriendRequests)
467 } 432 {
433 m_pendingFriendRequests.Add(transactionID, new Transaction(fromAgentID, fromAgentName));
434 outPending();
435 }
436
437 // we don't want to get that new IM into here if we aren't local, as only on the destination
438 // should receive it. If we *are* local, *we* are the destination, so we have to receive it.
439 // As grid-IMs are routed to all modules (in contrast to local IMs), we have to decide here.
440
441 // We don't really care which local scene we pipe it through.
442 if (m_TransferModule != null)
443 {
444 m_TransferModule.SendInstantMessage(msg,
445 delegate(bool success) {}
446 );
468 } 447 }
469 } 448 }
470 else if (dialog == (byte)InstantMessageDialog.FriendshipAccepted) // 39 449 else if (dialog == (byte)InstantMessageDialog.FriendshipAccepted) // 39
471 { 450 {
472 // accepting the friendship offer causes a type 39 IM being sent to the (possibly remote) initiator 451 // accepting the friendship offer causes a type 39 IM being sent to the (possibly remote) initiator
473 // toAgentID is initiator, fromAgentID is new friend (which just approved) 452 // toAgentID is initiator, fromAgentID is new friend (which just approved)
474 m_log.DebugFormat("[FRIEND]: 39 - from client {0}, agentSession {1}, agent {2} {3}, imsession {4} to {5}: {6} (dialog {7})", 453 m_log.DebugFormat("[FRIEND]: 39 - from client {0}, agent {1} {2}, imsession {3} to {4}: {5} (dialog {6})",
475 client != null ? client.AgentId.ToString() : "<null>", fromAgentSession, 454 client != null ? client.AgentId.ToString() : "<null>",
476 fromAgentID, fromAgentName, imSessionID, toAgentID, message, dialog); 455 fromAgentID, fromAgentName, imSessionID, toAgentID, message, dialog);
477 lock (m_pendingFriendRequests) 456 lock (m_pendingFriendRequests)
478 { 457 {
@@ -520,8 +499,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
520 { 499 {
521 // declining the friendship offer causes a type 40 IM being sent to the (possibly remote) initiator 500 // declining the friendship offer causes a type 40 IM being sent to the (possibly remote) initiator
522 // toAgentID is initiator, fromAgentID declined friendship 501 // toAgentID is initiator, fromAgentID declined friendship
523 m_log.DebugFormat("[FRIEND]: 40 - from client {0}, agentSession {1}, agent {2} {3}, imsession {4} to {5}: {6} (dialog {7})", 502 m_log.DebugFormat("[FRIEND]: 40 - from client {0}, agent {1} {2}, imsession {3} to {4}: {5} (dialog {6})",
524 client != null ? client.AgentId.ToString() : "<null>", fromAgentSession, 503 client != null ? client.AgentId.ToString() : "<null>",
525 fromAgentID, fromAgentName, imSessionID, toAgentID, message, dialog); 504 fromAgentID, fromAgentName, imSessionID, toAgentID, message, dialog);
526 505
527 // not much to do, just clean up the transaction... 506 // not much to do, just clean up the transaction...
@@ -542,13 +521,42 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
542 521
543 private void OnGridInstantMessage(GridInstantMessage msg) 522 private void OnGridInstantMessage(GridInstantMessage msg)
544 { 523 {
524 if (msg.dialog == (byte)InstantMessageDialog.FriendshipOffered)
525 {
526 // we are on the receiving end here; just add the transactionID
527 // to the stored transactions for later lookup
528 //
529 m_log.DebugFormat("[FRIEND]: storing transactionID {0} on "+
530 "receiver side", msg.imSessionID);
531
532 lock (m_pendingFriendRequests)
533 {
534 // if both are on the same region-server, the transaction
535 // is stored already, but we have to update the name
536 //
537 if (m_pendingFriendRequests.ContainsKey(
538 new UUID(msg.imSessionID)))
539 {
540 m_pendingFriendRequests[new UUID(msg.imSessionID)].agentName =
541 msg.fromAgentName;
542 m_pendingFriendRequests[new UUID(msg.imSessionID)].count++;
543 }
544 else m_pendingFriendRequests.Add(new UUID(msg.imSessionID),
545 new Transaction(new UUID(msg.fromAgentID),
546 msg.fromAgentName));
547
548 outPending();
549 }
550
551 return;
552 }
553
545 // Just call the IM handler above 554 // Just call the IM handler above
546 // This event won't be raised unless we have that agent, 555 // This event won't be raised unless we have that agent,
547 // so we can depend on the above not trying to send 556 // so we can depend on the above not trying to send
548 // via grid again 557 // via grid again
549 // 558 //
550 OnInstantMessage(null, new UUID(msg.fromAgentID), 559 OnInstantMessage(null, new UUID(msg.fromAgentID),
551 new UUID(msg.fromAgentSession),
552 new UUID(msg.toAgentID), new UUID(msg.imSessionID), 560 new UUID(msg.toAgentID), new UUID(msg.imSessionID),
553 msg.timestamp, msg.fromAgentName, msg.message, 561 msg.timestamp, msg.fromAgentName, msg.message,
554 msg.dialog, msg.fromGroup, msg.offline, 562 msg.dialog, msg.fromGroup, msg.offline,
@@ -604,7 +612,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
604 msg.toAgentID = friendID.Guid; 612 msg.toAgentID = friendID.Guid;
605 msg.fromAgentID = agentID.Guid; 613 msg.fromAgentID = agentID.Guid;
606 msg.fromAgentName = client.Name; 614 msg.fromAgentName = client.Name;
607 msg.fromAgentSession = UUID.Zero.Guid; // server IMs don't have a session
608 msg.fromGroup = false; 615 msg.fromGroup = false;
609 msg.imSessionID = transactionID.Guid; 616 msg.imSessionID = transactionID.Guid;
610 msg.message = agentID.Guid.ToString(); 617 msg.message = agentID.Guid.ToString();
@@ -664,7 +671,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
664 msg.toAgentID = friendID.Guid; 671 msg.toAgentID = friendID.Guid;
665 msg.fromAgentID = agentID.Guid; 672 msg.fromAgentID = agentID.Guid;
666 msg.fromAgentName = client.Name; 673 msg.fromAgentName = client.Name;
667 msg.fromAgentSession = UUID.Zero.Guid; // server IMs don't have a session
668 msg.fromGroup = false; 674 msg.fromGroup = false;
669 msg.imSessionID = transactionID.Guid; 675 msg.imSessionID = transactionID.Guid;
670 msg.message = agentID.Guid.ToString(); 676 msg.message = agentID.Guid.ToString();
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs
index c291c16..eea8e40 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs
@@ -178,27 +178,14 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups
178 ActiveGroupTitle); 178 ActiveGroupTitle);
179 } 179 }
180 180
181 private void OnInstantMessage(IClientAPI client, UUID fromAgentID, 181 private void OnInstantMessage(IClientAPI client, GridInstantMessage im)
182 UUID fromAgentSession, UUID toAgentID,
183 UUID imSessionID, uint timestamp, string fromAgentName,
184 string message, byte dialog, bool fromGroup, byte offline,
185 uint ParentEstateID, Vector3 Position, UUID RegionID,
186 byte[] binaryBucket)
187 { 182 {
188 } 183 }
189 184
190 private void OnGridInstantMessage(GridInstantMessage msg) 185 private void OnGridInstantMessage(GridInstantMessage msg)
191 { 186 {
192 // Trigger the above event handler 187 // Trigger the above event handler
193 OnInstantMessage(null, new UUID(msg.fromAgentID), 188 OnInstantMessage(null, msg);
194 new UUID(msg.fromAgentSession),
195 new UUID(msg.toAgentID), new UUID(msg.imSessionID),
196 msg.timestamp, msg.fromAgentName,
197 msg.message, msg.dialog, msg.fromGroup, msg.offline,
198 msg.ParentEstateID,
199 new Vector3(msg.Position.X, msg.Position.Y, msg.Position.Z),
200 new UUID(msg.RegionID),
201 msg.binaryBucket);
202 } 189 }
203 190
204 private void HandleUUIDGroupNameRequest(UUID id,IClientAPI remote_client) 191 private void HandleUUIDGroupNameRequest(UUID id,IClientAPI remote_client)
diff --git a/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs
index cd8c82c..b106435 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs
@@ -110,33 +110,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
110 110
111 #endregion 111 #endregion
112 112
113 private void OnInstantMessage(IClientAPI client, UUID fromAgentID, 113 public void OnInstantMessage(IClientAPI client, GridInstantMessage im)
114 UUID fromAgentSession, UUID toAgentID,
115 UUID imSessionID, uint timestamp, string fromAgentName,
116 string message, byte dialog, bool fromGroup, byte offline,
117 uint ParentEstateID, Vector3 Position, UUID RegionID,
118 byte[] binaryBucket)
119 {
120 // This module handles exclusively private text IM from user
121 // to user. All others will be caught in other modules
122 //
123 if ( dialog != (byte)InstantMessageDialog.MessageFromAgent
124 && dialog != (byte)InstantMessageDialog.StartTyping
125 && dialog != (byte)InstantMessageDialog.StopTyping)
126 {
127 return;
128 }
129
130 GridInstantMessage im = new GridInstantMessage(client.Scene,
131 fromAgentID, fromAgentName, fromAgentSession, toAgentID,
132 dialog, fromGroup, message, imSessionID,
133 offline != 0 ? true : false, Position,
134 binaryBucket);
135
136 ProcessInstantMessage(client, im);
137 }
138
139 private void ProcessInstantMessage(IClientAPI client, GridInstantMessage im)
140 { 114 {
141 byte dialog = im.dialog; 115 byte dialog = im.dialog;
142 116
@@ -183,7 +157,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
183 // so we can depend on the above not trying to send 157 // so we can depend on the above not trying to send
184 // via grid again 158 // via grid again
185 // 159 //
186 ProcessInstantMessage(null, msg); 160 OnInstantMessage(null, msg);
187 } 161 }
188 } 162 }
189} 163}
diff --git a/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/MessageTransferModule.cs
index 0dc29a1..67346ae 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/MessageTransferModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/MessageTransferModule.cs
@@ -185,7 +185,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
185 bool successful = false; 185 bool successful = false;
186 // various rational defaults 186 // various rational defaults
187 UUID fromAgentID = UUID.Zero; 187 UUID fromAgentID = UUID.Zero;
188 UUID fromAgentSession = UUID.Zero;
189 UUID toAgentID = UUID.Zero; 188 UUID toAgentID = UUID.Zero;
190 UUID imSessionID = UUID.Zero; 189 UUID imSessionID = UUID.Zero;
191 uint timestamp = 0; 190 uint timestamp = 0;
@@ -207,7 +206,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
207 206
208 Hashtable requestData = (Hashtable)request.Params[0]; 207 Hashtable requestData = (Hashtable)request.Params[0];
209 // Check if it's got all the data 208 // Check if it's got all the data
210 if (requestData.ContainsKey("from_agent_id") && requestData.ContainsKey("from_agent_session") 209 if (requestData.ContainsKey("from_agent_id")
211 && requestData.ContainsKey("to_agent_id") && requestData.ContainsKey("im_session_id") 210 && requestData.ContainsKey("to_agent_id") && requestData.ContainsKey("im_session_id")
212 && requestData.ContainsKey("timestamp") && requestData.ContainsKey("from_agent_name") 211 && requestData.ContainsKey("timestamp") && requestData.ContainsKey("from_agent_name")
213 && requestData.ContainsKey("message") && requestData.ContainsKey("dialog") 212 && requestData.ContainsKey("message") && requestData.ContainsKey("dialog")
@@ -219,7 +218,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
219 { 218 {
220 // Do the easy way of validating the UUIDs 219 // Do the easy way of validating the UUIDs
221 UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID); 220 UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID);
222 UUID.TryParse((string)requestData["from_agent_session"], out fromAgentSession);
223 UUID.TryParse((string)requestData["to_agent_id"], out toAgentID); 221 UUID.TryParse((string)requestData["to_agent_id"], out toAgentID);
224 UUID.TryParse((string)requestData["im_session_id"], out imSessionID); 222 UUID.TryParse((string)requestData["im_session_id"], out imSessionID);
225 UUID.TryParse((string)requestData["region_id"], out RegionID); 223 UUID.TryParse((string)requestData["region_id"], out RegionID);
@@ -337,7 +335,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
337 GridInstantMessage gim = new GridInstantMessage(); 335 GridInstantMessage gim = new GridInstantMessage();
338 gim.fromAgentID = fromAgentID.Guid; 336 gim.fromAgentID = fromAgentID.Guid;
339 gim.fromAgentName = fromAgentName; 337 gim.fromAgentName = fromAgentName;
340 gim.fromAgentSession = fromAgentSession.Guid;
341 gim.fromGroup = fromGroup; 338 gim.fromGroup = fromGroup;
342 gim.imSessionID = imSessionID.Guid; 339 gim.imSessionID = imSessionID.Guid;
343 gim.RegionID = RegionID.Guid; 340 gim.RegionID = RegionID.Guid;
@@ -598,7 +595,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
598 { 595 {
599 Hashtable gim = new Hashtable(); 596 Hashtable gim = new Hashtable();
600 gim["from_agent_id"] = msg.fromAgentID.ToString(); 597 gim["from_agent_id"] = msg.fromAgentID.ToString();
601 gim["from_agent_session"] = msg.fromAgentSession.ToString(); 598 // Kept for compatibility
599 gim["from_agent_session"] = UUID.Zero.ToString();
602 gim["to_agent_id"] = msg.toAgentID.ToString(); 600 gim["to_agent_id"] = msg.toAgentID.ToString();
603 gim["im_session_id"] = msg.imSessionID.ToString(); 601 gim["im_session_id"] = msg.imSessionID.ToString();
604 gim["timestamp"] = msg.timestamp.ToString(); 602 gim["timestamp"] = msg.timestamp.ToString();
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
index 71cc726..f4707de 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
@@ -117,38 +117,34 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Transfer
117 return null; 117 return null;
118 } 118 }
119 119
120 private void OnInstantMessage(IClientAPI client, UUID fromAgentID, 120 private void OnInstantMessage(IClientAPI client, GridInstantMessage im)
121 UUID fromAgentSession, UUID toAgentID,
122 UUID imSessionID, uint timestamp, string fromAgentName,
123 string message, byte dialog, bool fromGroup, byte offline,
124 uint ParentEstateID, Vector3 Position, UUID RegionID,
125 byte[] binaryBucket)
126 { 121 {
127 Scene scene = FindClientScene(client.AgentId); 122 Scene scene = FindClientScene(client.AgentId);
128 123
129 if (scene == null) // Something seriously wrong here. 124 if (scene == null) // Something seriously wrong here.
130 return; 125 return;
131 126
132 if (dialog == (byte) InstantMessageDialog.InventoryOffered) 127 if (im.dialog == (byte) InstantMessageDialog.InventoryOffered)
133 { 128 {
134 ScenePresence user = 129 ScenePresence user =
135 scene.GetScenePresence(toAgentID); 130 scene.GetScenePresence(new UUID(im.toAgentID));
136 131
137 // First byte of the array is probably the item type 132 // First byte of the array is probably the item type
138 // Next 16 bytes are the UUID 133 // Next 16 bytes are the UUID
139 134
140 UUID itemID = new UUID(binaryBucket, 1); 135 UUID itemID = new UUID(im.binaryBucket, 1);
141 136
142 m_log.DebugFormat("[AGENT INVENTORY]: Inserting item {0} "+ 137 m_log.DebugFormat("[AGENT INVENTORY]: Inserting item {0} "+
143 "into agent {1}'s inventory", 138 "into agent {1}'s inventory",
144 itemID, toAgentID); 139 itemID, new UUID(im.toAgentID));
145 140
146 InventoryItemBase itemCopy = scene.GiveInventoryItem(toAgentID, 141 InventoryItemBase itemCopy = scene.GiveInventoryItem(
142 new UUID(im.toAgentID),
147 client.AgentId, itemID); 143 client.AgentId, itemID);
148 144
149 byte[] itemCopyID = itemCopy.ID.GetBytes(); 145 byte[] itemCopyID = itemCopy.ID.GetBytes();
150 146
151 Array.Copy(itemCopyID, 0, binaryBucket, 1, 16); 147 Array.Copy(itemCopyID, 0, im.binaryBucket, 1, 16);
152 148
153 // Send the IM to the recipient. The item is already 149 // Send the IM to the recipient. The item is already
154 // in their inventory, so it will not be lost if 150 // in their inventory, so it will not be lost if
@@ -164,9 +160,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Transfer
164 // same ID back on the reply so we know what to act on 160 // same ID back on the reply so we know what to act on
165 // 161 //
166 user.ControllingClient.SendInstantMessage( 162 user.ControllingClient.SendInstantMessage(
167 fromAgentID, message, toAgentID, fromAgentName, 163 new UUID(im.fromAgentID), im.message,
168 dialog, timestamp, itemCopy.ID, false, 164 new UUID(im.toAgentID),
169 binaryBucket); 165 im.fromAgentName, im.dialog, im.timestamp,
166 itemCopy.ID, false, im.binaryBucket);
170 167
171 return; 168 return;
172 } 169 }
@@ -177,15 +174,17 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Transfer
177 // TODO: Implement grid sending 174 // TODO: Implement grid sending
178 } 175 }
179 } 176 }
180 else if (dialog == (byte) InstantMessageDialog.InventoryAccepted) 177 else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted)
181 { 178 {
182 ScenePresence user = scene.GetScenePresence(toAgentID); 179 ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));
183 180
184 if (user != null) // Local 181 if (user != null) // Local
185 { 182 {
186 user.ControllingClient.SendInstantMessage( 183 user.ControllingClient.SendInstantMessage(
187 fromAgentID, message, toAgentID, fromAgentName, 184 new UUID(im.fromAgentID), im.message,
188 dialog, timestamp, UUID.Zero, false, binaryBucket); 185 new UUID(im.toAgentID),
186 im.fromAgentName, im.dialog, im.timestamp,
187 UUID.Zero, false, im.binaryBucket);
189 } 188 }
190 else 189 else
191 { 190 {
@@ -194,9 +193,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Transfer
194 // TODO: Implement sending via grid 193 // TODO: Implement sending via grid
195 } 194 }
196 } 195 }
197 else if (dialog == (byte) InstantMessageDialog.InventoryDeclined) 196 else if (im.dialog == (byte) InstantMessageDialog.InventoryDeclined)
198 { 197 {
199 UUID itemID = imSessionID; // The item, back from it's trip 198 UUID itemID = new UUID(im.imSessionID); // The item, back from it's trip
200 199
201 // Here, the recipient is local and we can assume that the 200 // Here, the recipient is local and we can assume that the
202 // inventory is loaded. Courtesy of the above bulk update, 201 // inventory is loaded. Courtesy of the above bulk update,
@@ -235,13 +234,15 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Transfer
235 } 234 }
236 } 235 }
237 236
238 ScenePresence user = scene.GetScenePresence(toAgentID); 237 ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));
239 238
240 if (user != null) // Local 239 if (user != null) // Local
241 { 240 {
242 user.ControllingClient.SendInstantMessage( 241 user.ControllingClient.SendInstantMessage(
243 fromAgentID, message, toAgentID, fromAgentName, 242 new UUID(im.fromAgentID), im.message,
244 dialog, timestamp, UUID.Zero, false, binaryBucket); 243 new UUID(im.toAgentID),
244 im.fromAgentName, im.dialog, im.timestamp,
245 UUID.Zero, false, im.binaryBucket);
245 } 246 }
246 else 247 else
247 { 248 {
diff --git a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs
index de0a41a..735a521 100644
--- a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs
@@ -84,9 +84,10 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
84 84
85 public void InstantMessage(UUID target, string message) 85 public void InstantMessage(UUID target, string message)
86 { 86 {
87 OnInstantMessage(this, m_uuid, SessionId, target, UUID.Combine(m_uuid, target), 87 OnInstantMessage(this, new GridInstantMessage(m_scene,
88 (uint) Util.UnixTimeSinceEpoch(), Name, message, 0, false, 0, 0, 88 m_uuid, m_firstname + " " + m_lastname,
89 Position, m_scene.RegionInfo.RegionID, new byte[0]); 89 target, 0, false, message,
90 UUID.Zero, false, Position, new byte[0]));
90 } 91 }
91 92
92 public void SendAgentOffline(UUID[] agentIDs) 93 public void SendAgentOffline(UUID[] agentIDs)
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index e19857c..0416e3a 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -977,7 +977,6 @@ namespace OpenSim.Region.Environment.Scenes
977 977
978 GridInstantMessage msg = new GridInstantMessage(); 978 GridInstantMessage msg = new GridInstantMessage();
979 msg.fromAgentID = new Guid(UUID.Zero.ToString()); // From server 979 msg.fromAgentID = new Guid(UUID.Zero.ToString()); // From server
980 msg.fromAgentSession = new Guid(transaction.ToString());
981 msg.toAgentID = new Guid(ret.Key.ToString()); 980 msg.toAgentID = new Guid(ret.Key.ToString());
982 msg.imSessionID = new Guid(transaction.ToString()); 981 msg.imSessionID = new Guid(transaction.ToString());
983 msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 982 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 8eff58e..2408a5e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2623,7 +2623,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2623 2623
2624 GridInstantMessage msg = new GridInstantMessage(); 2624 GridInstantMessage msg = new GridInstantMessage();
2625 msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; 2625 msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid;
2626 msg.fromAgentSession = new Guid(friendTransactionID.ToString());// fromAgentSession.UUID;
2627 msg.toAgentID = new Guid(user); // toAgentID.Guid; 2626 msg.toAgentID = new Guid(user); // toAgentID.Guid;
2628 msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here 2627 msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here
2629// Console.WriteLine("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); 2628// Console.WriteLine("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message);