diff options
Diffstat (limited to 'linden/indra/newview/llviewermessage.cpp')
-rwxr-xr-x | linden/indra/newview/llviewermessage.cpp | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/linden/indra/newview/llviewermessage.cpp b/linden/indra/newview/llviewermessage.cpp index 504c193..84e2b7e 100755 --- a/linden/indra/newview/llviewermessage.cpp +++ b/linden/indra/newview/llviewermessage.cpp | |||
@@ -158,6 +158,10 @@ | |||
158 | #include "llwindebug.h" // For the invalid message handler | 158 | #include "llwindebug.h" // For the invalid message handler |
159 | #endif | 159 | #endif |
160 | 160 | ||
161 | #if USE_OTR // [$PLOTR$] | ||
162 | #include "otr_wrapper.h" | ||
163 | #endif // USE_OTR // [/$PLOTR$] | ||
164 | |||
161 | //silly spam define D: | 165 | //silly spam define D: |
162 | bool dialogSpamOn; | 166 | bool dialogSpamOn; |
163 | static LLFrameTimer d_spam; | 167 | static LLFrameTimer d_spam; |
@@ -1582,14 +1586,135 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) | |||
1582 | is_owned_by_me = source->permYouOwner(); | 1586 | is_owned_by_me = source->permYouOwner(); |
1583 | } | 1587 | } |
1584 | 1588 | ||
1589 | #if USE_OTR // [$PLOTR$] | ||
1590 | std::string decrypted_msg; | ||
1591 | bool encrypted = false; | ||
1592 | // if ((CHAT_SOURCE_SYSTEM == chat.mSourceType) && | ||
1593 | // ((std::string::npos != message.find("not online")) || | ||
1594 | // (std::string::npos != message.find("stored and delivered later")))) | ||
1595 | // { | ||
1596 | // llinfos << "$PLOTR$ Looks like " << from_id << " went offline." << llendl; | ||
1597 | // } | ||
1598 | U32 otrpref = gSavedSettings.getU32("EmeraldUseOTR"); | ||
1599 | // otrpref: 0 == Require use of OTR in IMs, 1 == Request OTR if available, 2 == Accept OTR requests, 3 == Decline use of OTR | ||
1600 | if ((otrpref != 3) && !is_muted && (chat.mSourceType == CHAT_SOURCE_AGENT)) | ||
1601 | { | ||
1602 | int ignore_message = 0; | ||
1603 | char *newmessage = NULL; | ||
1604 | OtrlTLV *tlvs = NULL; | ||
1605 | char my_uuid[UUID_STR_SIZE]; | ||
1606 | char their_uuid[UUID_STR_SIZE]; | ||
1607 | |||
1608 | if (gOTR && | ||
1609 | ((IM_NOTHING_SPECIAL == dialog) || | ||
1610 | ((IM_TYPING_STOP == dialog) && | ||
1611 | (! ((message == "typing") || (message == "cryo::ping")))))) | ||
1612 | { | ||
1613 | // only try OTR for 1 on 1 IM's or special tagged typing_stop packets | ||
1614 | gAgent.getID().toString(&(my_uuid[0])); | ||
1615 | from_id.toString(&(their_uuid[0])); | ||
1616 | ignore_message = otrl_message_receiving( | ||
1617 | gOTR->get_userstate(), | ||
1618 | gOTR->get_uistate(), | ||
1619 | &session_id, | ||
1620 | my_uuid, | ||
1621 | gOTR->get_protocolid(), | ||
1622 | their_uuid, | ||
1623 | &(message[0]), &newmessage, | ||
1624 | &tlvs, | ||
1625 | NULL, NULL); | ||
1626 | } | ||
1627 | if (tlvs) | ||
1628 | { | ||
1629 | llinfos << "$PLOTR$ recieved TLVs" << llendl; | ||
1630 | LLUUID session = LLIMMgr::computeSessionID(dialog,from_id); | ||
1631 | |||
1632 | if(!otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED)) | ||
1633 | { | ||
1634 | // currently the only TLVs we deal with are SMP, and they require an IM panel | ||
1635 | if(!gIMMgr->hasSession(session)) | ||
1636 | { | ||
1637 | gIMMgr->addSession(name,IM_NOTHING_SPECIAL,from_id); | ||
1638 | } | ||
1639 | |||
1640 | } | ||
1641 | LLFloaterIMPanel* pan = gIMMgr->findFloaterBySession(session); | ||
1642 | if (pan) pan->handleOtrTlvs(tlvs); | ||
1643 | otrl_tlv_free(tlvs); | ||
1644 | } | ||
1645 | if (1 == ignore_message) | ||
1646 | { | ||
1647 | OtrlMessageType msgtype = otrl_proto_message_type(&(message[0])); | ||
1648 | if (OTRL_MSGTYPE_NOTOTR == msgtype) | ||
1649 | { | ||
1650 | llinfos << "$PLOTR$ [not otr, but to be ignored (" << message << ")]" << llendl; | ||
1651 | if ((0 == otrpref) && (IM_NOTHING_SPECIAL == dialog) && !is_muted) | ||
1652 | { | ||
1653 | LLUUID session = LLIMMgr::computeSessionID(dialog,from_id); | ||
1654 | if(!gIMMgr->hasSession(session)) | ||
1655 | { | ||
1656 | gIMMgr->addSession(name,IM_NOTHING_SPECIAL,from_id); | ||
1657 | } | ||
1658 | // NOT deliver_otr_message since those might go via typing_stop | ||
1659 | deliver_message( // $TODO$ move the following message to some .xml file | ||
1660 | "/me's settings require OTR encrypted instant messages. Your message was not displayed.", | ||
1661 | session, from_id, IM_NOTHING_SPECIAL); | ||
1662 | LLFloaterIMPanel* pan = gIMMgr->findFloaterBySession(session); | ||
1663 | if(pan)pan->doOtrStart(); | ||
1664 | } | ||
1665 | } | ||
1666 | else | ||
1667 | { | ||
1668 | // an internal OTR protocol message was recieved, don't show anything to the user | ||
1669 | llinfos << "$PLOTR$ [OTR PROTOCOL MESSAGE (" << message << ")]" << llendl; | ||
1670 | } | ||
1671 | otr_show_status(session_id); | ||
1672 | return; | ||
1673 | } | ||
1674 | if (newmessage) | ||
1675 | { | ||
1676 | // message was processed by OTR. Maybe decrypted, maybe just stripping off the | ||
1677 | // white-space "I have OTR" tag | ||
1678 | decrypted_msg = newmessage; // use processed message | ||
1679 | message = newmessage; // use processed message | ||
1680 | otrl_message_free(newmessage); | ||
1681 | ConnContext *context = otrl_context_find( | ||
1682 | gOTR->get_userstate(), | ||
1683 | their_uuid, | ||
1684 | my_uuid, | ||
1685 | gOTR->get_protocolid(), | ||
1686 | 0, NULL, NULL, NULL); | ||
1687 | encrypted = (context && (OTRL_MSGSTATE_ENCRYPTED == context->msgstate)); | ||
1688 | if (IM_TYPING_STOP == dialog) | ||
1689 | { | ||
1690 | if ("typing" == message) return; // don't display whitespace tagged "typing" stop messages | ||
1691 | dialog = IM_NOTHING_SPECIAL; // display messages received in typing_stop packets | ||
1692 | } | ||
1693 | } | ||
1694 | } | ||
1695 | |||
1696 | #endif // USE_OTR // [/$PLOTR$] | ||
1697 | |||
1585 | std::string separator_string(": "); | 1698 | std::string separator_string(": "); |
1586 | int message_offset = 0; | 1699 | int message_offset = 0; |
1587 | 1700 | ||
1701 | #if USE_OTR // [$PLOTR$] | ||
1702 | if(encrypted) | ||
1703 | { | ||
1704 | separator_string = "\xe2\x80\xa7: "; | ||
1705 | message = decrypted_msg; | ||
1706 | } | ||
1707 | #endif // USE_OTR // [/$PLOTR$] | ||
1708 | |||
1588 | //Handle IRC styled /me messages. | 1709 | //Handle IRC styled /me messages. |
1589 | std::string prefix = message.substr(0, 4); | 1710 | std::string prefix = message.substr(0, 4); |
1590 | if (prefix == "/me " || prefix == "/me'") | 1711 | if (prefix == "/me " || prefix == "/me'") |
1591 | { | 1712 | { |
1713 | #if USE_OTR // [$PLOTR$] | ||
1714 | separator_string = encrypted ? "\xe2\x80\xa7" : ""; | ||
1715 | #else | ||
1592 | separator_string = ""; | 1716 | separator_string = ""; |
1717 | #endif // USE_OTR // [/$PLOTR$] | ||
1593 | message_offset = 3; | 1718 | message_offset = 3; |
1594 | } | 1719 | } |
1595 | 1720 | ||