aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Avatar
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs132
1 files changed, 83 insertions, 49 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs
index 6a8141a..1346508 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs
@@ -382,67 +382,101 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
382 { 382 {
383 // Friend Requests go by Instant Message.. using the dialog param 383 // Friend Requests go by Instant Message.. using the dialog param
384 // https://wiki.secondlife.com/wiki/ImprovedInstantMessage 384 // https://wiki.secondlife.com/wiki/ImprovedInstantMessage
385 UUID fromAgentID = new UUID(im.fromAgentID);
386 UUID toAgentID = new UUID(im.toAgentID);
387 385
388 if (im.dialog == (byte)InstantMessageDialog.FriendshipOffered) // 38 386 if (im.dialog == (byte)InstantMessageDialog.FriendshipOffered) // 38
389 { 387 {
390 // this is triggered by the initiating agent: 388 FriendshipOffered(client, im);
391 // A local agent offers friendship to some possibly remote friend.
392 // A IM is triggered, processed here and sent to the friend (possibly in a remote region).
393
394 // some properties are misused here:
395 // fromAgentName is the *destination* name (the friend we offer friendship to)
396
397 m_log.InfoFormat("[FRIEND]: Offer(38) - From: {0}, FromName: {1} To: {2}, Session: {3}, Message: {4}, Offline {5}",
398 im.fromAgentID, im.fromAgentName, im.toAgentID, im.imSessionID, im.message, im.offline);
399
400 // 1.20 protocol sends an UUID in the message field, instead of the friendship offer text.
401 // For interoperability, we have to clear that
402 if (Util.isUUID(im.message)) im.message = "";
403
404 // be sneeky and use the initiator-UUID as transactionID. This means we can be stateless.
405 // we have to look up the agent name on friendship-approval, though.
406 im.imSessionID = im.fromAgentID;
407 im.fromAgentName = client.Name;
408
409 if (m_TransferModule != null)
410 {
411 // Send it to whoever is the destination.
412 // If new friend is local, it will send an IM to the viewer.
413 // If new friend is remote, it will cause a OnGridInstantMessage on the remote server
414 m_TransferModule.SendInstantMessage(im,
415 delegate(bool success) {
416 m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success);
417 }
418 );
419 }
420 } 389 }
421 else if (im.dialog == (byte)InstantMessageDialog.FriendshipAccepted) // 39 390 else if (im.dialog == (byte)InstantMessageDialog.FriendshipAccepted) // 39
422 { 391 {
423 m_log.DebugFormat("[FRIEND]: 39 - from client {0}, agent {2} {3}, imsession {4} to {5}: {6} (dialog {7})", 392 FriendshipAccepted(client, im);
424 client.AgentId, im.fromAgentID, im.fromAgentName, im.imSessionID, im.toAgentID, im.message, im.dialog);
425
426 } 393 }
427 else if (im.dialog == (byte)InstantMessageDialog.FriendshipDeclined) // 40 394 else if (im.dialog == (byte)InstantMessageDialog.FriendshipDeclined) // 40
428 { 395 {
429 // declining the friendship offer causes a type 40 IM being sent to the (possibly remote) initiator 396 FriendshipDeclined(client, im);
430 // toAgentID is initiator, fromAgentID declined friendship 397 }
431 m_log.DebugFormat("[FRIEND]: 40 - from client {0}, agent {1} {2}, imsession {3} to {4}: {5} (dialog {6})", 398 }
432 client != null ? client.AgentId.ToString() : "<null>", 399
433 fromAgentID, im.fromAgentName, im.imSessionID, im.toAgentID, im.message, im.dialog); 400 /// <summary>
401 /// Invoked when a user offers a friendship.
402 /// </summary>
403 /// May not currently be used - see OnApproveFriendRequest() instead
404 /// <param name="im"></param>
405 /// <param name="client"></param>
406 private void FriendshipOffered(IClientAPI client, GridInstantMessage im)
407 {
408 // this is triggered by the initiating agent:
409 // A local agent offers friendship to some possibly remote friend.
410 // A IM is triggered, processed here and sent to the friend (possibly in a remote region).
411
412 // some properties are misused here:
413 // fromAgentName is the *destination* name (the friend we offer friendship to)
414
415 m_log.DebugFormat("[FRIEND]: Offer(38) - From: {0}, FromName: {1} To: {2}, Session: {3}, Message: {4}, Offline {5}",
416 im.fromAgentID, im.fromAgentName, im.toAgentID, im.imSessionID, im.message, im.offline);
434 417
435 // Send the decline to whoever is the destination. 418 // 1.20 protocol sends an UUID in the message field, instead of the friendship offer text.
436 GridInstantMessage msg = new GridInstantMessage(client.Scene, fromAgentID, client.Name, toAgentID, 419 // For interoperability, we have to clear that
437 im.dialog, im.message, im.offline != 0, im.Position); 420 if (Util.isUUID(im.message)) im.message = "";
421
422 // be sneeky and use the initiator-UUID as transactionID. This means we can be stateless.
423 // we have to look up the agent name on friendship-approval, though.
424 im.imSessionID = im.fromAgentID;
425 im.fromAgentName = client.Name;
426
427 if (m_TransferModule != null)
428 {
429 // Send it to whoever is the destination.
438 // If new friend is local, it will send an IM to the viewer. 430 // If new friend is local, it will send an IM to the viewer.
439 // If new friend is remote, it will cause a OnGridInstantMessage on the remote server 431 // If new friend is remote, it will cause a OnGridInstantMessage on the remote server
440 m_TransferModule.SendInstantMessage(msg, 432 m_TransferModule.SendInstantMessage(im,
441 delegate(bool success) { 433 delegate(bool success)
434 {
442 m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success); 435 m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success);
443 } 436 }
444 ); 437 );
445 } 438 }
439 }
440
441 /// <summary>
442 /// Invoked when a user accepts a friendship offer.
443 /// </summary>
444 /// <param name="im"></param>
445 /// <param name="client"></param>
446 private void FriendshipAccepted(IClientAPI client, GridInstantMessage im)
447 {
448 m_log.DebugFormat("[FRIEND]: 39 - from client {0}, agent {2} {3}, imsession {4} to {5}: {6} (dialog {7})",
449 client.AgentId, im.fromAgentID, im.fromAgentName, im.imSessionID, im.toAgentID, im.message, im.dialog);
450 }
451
452 /// <summary>
453 /// Invoked when a user declines a friendship offer.
454 /// </summary>
455 /// May not currently be used - see OnDenyFriendRequest() instead
456 /// <param name="im"></param>
457 /// <param name="client"></param>
458 private void FriendshipDeclined(IClientAPI client, GridInstantMessage im)
459 {
460 UUID fromAgentID = new UUID(im.fromAgentID);
461 UUID toAgentID = new UUID(im.toAgentID);
462
463 // declining the friendship offer causes a type 40 IM being sent to the (possibly remote) initiator
464 // toAgentID is initiator, fromAgentID declined friendship
465 m_log.DebugFormat("[FRIEND]: 40 - from client {0}, agent {1} {2}, imsession {3} to {4}: {5} (dialog {6})",
466 client != null ? client.AgentId.ToString() : "<null>",
467 fromAgentID, im.fromAgentName, im.imSessionID, im.toAgentID, im.message, im.dialog);
468
469 // Send the decline to whoever is the destination.
470 GridInstantMessage msg = new GridInstantMessage(client.Scene, fromAgentID, client.Name, toAgentID,
471 im.dialog, im.message, im.offline != 0, im.Position);
472
473 // If new friend is local, it will send an IM to the viewer.
474 // If new friend is remote, it will cause a OnGridInstantMessage on the remote server
475 m_TransferModule.SendInstantMessage(msg,
476 delegate(bool success) {
477 m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success);
478 }
479 );
446 } 480 }
447 481
448 private void OnGridInstantMessage(GridInstantMessage msg) 482 private void OnGridInstantMessage(GridInstantMessage msg)
@@ -467,11 +501,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
467 if (msg.dialog == (byte)InstantMessageDialog.FriendshipAccepted) 501 if (msg.dialog == (byte)InstantMessageDialog.FriendshipAccepted)
468 { 502 {
469 // for accept friendship, we have to do a bit more 503 // for accept friendship, we have to do a bit more
470 approveFriendship(new UUID(msg.fromAgentID), new UUID(msg.toAgentID), msg.fromAgentName); 504 ApproveFriendship(new UUID(msg.fromAgentID), new UUID(msg.toAgentID), msg.fromAgentName);
471 } 505 }
472 } 506 }
473 507
474 private void approveFriendship(UUID fromAgentID, UUID toAgentID, string fromName) 508 private void ApproveFriendship(UUID fromAgentID, UUID toAgentID, string fromName)
475 { 509 {
476 m_log.DebugFormat("[FRIEND]: Approve friendship from {0} (ID: {1}) to {2}", 510 m_log.DebugFormat("[FRIEND]: Approve friendship from {0} (ID: {1}) to {2}",
477 fromAgentID, fromName, toAgentID); 511 fromAgentID, fromName, toAgentID);
@@ -537,7 +571,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
537 friendPresence.ControllingClient.SendInstantMessage(agentID, agentID.ToString(), friendID, client.Name, 571 friendPresence.ControllingClient.SendInstantMessage(agentID, agentID.ToString(), friendID, client.Name,
538 (byte)InstantMessageDialog.FriendshipAccepted, 572 (byte)InstantMessageDialog.FriendshipAccepted,
539 (uint)Util.UnixTimeSinceEpoch()); 573 (uint)Util.UnixTimeSinceEpoch());
540 approveFriendship(agentID, friendID, client.Name); 574 ApproveFriendship(agentID, friendID, client.Name);
541 } 575 }
542 else 576 else
543 { 577 {