aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs158
1 files changed, 82 insertions, 76 deletions
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();