diff options
author | Jacek Antonelli | 2008-08-15 23:44:54 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:54 -0500 |
commit | b2afb8800bb033a04bb3ecdf0363068d56648ef1 (patch) | |
tree | 3568129b5bbddb47cd39d622b4137a8fbff4abaf /linden/indra/newview/llviewermessage.cpp | |
parent | Second Life viewer sources 1.14.0.1 (diff) | |
download | meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.zip meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.gz meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.bz2 meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.xz |
Second Life viewer sources 1.15.0.2
Diffstat (limited to 'linden/indra/newview/llviewermessage.cpp')
-rw-r--r-- | linden/indra/newview/llviewermessage.cpp | 284 |
1 files changed, 148 insertions, 136 deletions
diff --git a/linden/indra/newview/llviewermessage.cpp b/linden/indra/newview/llviewermessage.cpp index 41d24fd..5dab363 100644 --- a/linden/indra/newview/llviewermessage.cpp +++ b/linden/indra/newview/llviewermessage.cpp | |||
@@ -4,6 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (c) 2002-2007, Linden Research, Inc. | 5 | * Copyright (c) 2002-2007, Linden Research, Inc. |
6 | * | 6 | * |
7 | * Second Life Viewer Source Code | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | 8 | * The source code in this file ("Source Code") is provided by Linden Lab |
8 | * to you under the terms of the GNU General Public License, version 2.0 | 9 | * to you under the terms of the GNU General Public License, version 2.0 |
9 | * ("GPL"), unless you have obtained a separate licensing agreement | 10 | * ("GPL"), unless you have obtained a separate licensing agreement |
@@ -106,6 +107,7 @@ | |||
106 | #include "llui.h" // for make_ui_sound | 107 | #include "llui.h" // for make_ui_sound |
107 | #include "lluploaddialog.h" | 108 | #include "lluploaddialog.h" |
108 | #include "llviewercamera.h" | 109 | #include "llviewercamera.h" |
110 | #include "llviewergenericmessage.h" | ||
109 | #include "llviewerinventory.h" | 111 | #include "llviewerinventory.h" |
110 | #include "llviewermenu.h" | 112 | #include "llviewermenu.h" |
111 | #include "llviewerobject.h" | 113 | #include "llviewerobject.h" |
@@ -142,8 +144,6 @@ extern BOOL gDebugClicks; | |||
142 | 144 | ||
143 | extern void bad_network_handler(); | 145 | extern void bad_network_handler(); |
144 | 146 | ||
145 | LLDispatcher gGenericDispatcher; | ||
146 | |||
147 | // function prototypes | 147 | // function prototypes |
148 | void open_offer(const std::vector<LLUUID>& items); | 148 | void open_offer(const std::vector<LLUUID>& items); |
149 | void friendship_offer_callback(S32 option, void* user_data); | 149 | void friendship_offer_callback(S32 option, void* user_data); |
@@ -1559,61 +1559,135 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) | |||
1559 | break; | 1559 | break; |
1560 | } | 1560 | } |
1561 | case IM_GROUP_VOTE: | 1561 | case IM_GROUP_VOTE: |
1562 | { | ||
1563 | LLUUID *userdata = new LLUUID(session_id); | ||
1564 | args["[NAME]"] = name; | ||
1565 | args["[MESSAGE]"] = message; | ||
1566 | LLNotifyBox::showXml("GroupVote", args, | ||
1567 | &group_vote_callback, userdata); | ||
1568 | } | ||
1569 | break; | ||
1570 | |||
1571 | case IM_GROUP_ELECTION_DEPRECATED: | ||
1572 | { | ||
1573 | llwarns << "Received IM: IM_GROUP_ELECTION_DEPRECATED" << llendl; | ||
1574 | } | ||
1575 | break; | ||
1576 | |||
1577 | case IM_SESSION_911_SEND: | ||
1578 | { | ||
1579 | //this is just the same code as IM_SESSION_SEND for a bit | ||
1580 | //I was too lazy to make this a function....sorry - jwolk | ||
1581 | if (!is_linden && is_busy) | ||
1562 | { | 1582 | { |
1563 | LLUUID *userdata = new LLUUID(session_id); | 1583 | return; |
1564 | args["[NAME]"] = name; | 1584 | } |
1565 | args["[MESSAGE]"] = message; | 1585 | |
1566 | LLNotifyBox::showXml("GroupVote", args, | 1586 | // standard message, not from system |
1567 | &group_vote_callback, userdata); | 1587 | char saved[MAX_STRING]; /* Flawfinder: ignore */ |
1588 | saved[0] = '\0'; | ||
1589 | if(offline == IM_OFFLINE) | ||
1590 | { | ||
1591 | char time_buf[TIME_STR_LENGTH]; /* Flawfinder: ignore */ | ||
1592 | snprintf(saved, /* Flawfinder: ignore */ | ||
1593 | MAX_STRING, | ||
1594 | "(Saved %s) ", | ||
1595 | formatted_time(timestamp, time_buf)); | ||
1596 | } | ||
1597 | |||
1598 | snprintf(buffer, /* Flawfinder: ignore */ | ||
1599 | sizeof(buffer), | ||
1600 | "%s%s%s%s", | ||
1601 | name, | ||
1602 | separator_string, | ||
1603 | saved, | ||
1604 | (message+message_offset)); | ||
1605 | |||
1606 | BOOL is_this_agent = FALSE; | ||
1607 | if(from_id == gAgentID) | ||
1608 | { | ||
1609 | from_id = LLUUID::null; | ||
1610 | is_this_agent = TRUE; | ||
1568 | } | 1611 | } |
1569 | break; | ||
1570 | 1612 | ||
1571 | case IM_GROUP_ELECTION_DEPRECATED: | 1613 | gIMView->addMessage( |
1614 | session_id, | ||
1615 | from_id, | ||
1616 | name, | ||
1617 | buffer, | ||
1618 | (char*)binary_bucket, | ||
1619 | IM_SESSION_ADD, | ||
1620 | parent_estate_id, | ||
1621 | region_id, | ||
1622 | position); | ||
1623 | |||
1624 | snprintf(buffer, sizeof(buffer), "IM: %s%s%s%s", name, separator_string, saved, (message+message_offset)); /* Flawfinder: ignore */ | ||
1625 | chat.mText = buffer; | ||
1626 | LLFloaterChat::addChat(chat, TRUE, is_this_agent); | ||
1627 | |||
1628 | //ok, now we want to add a teleport button if we are receving | ||
1629 | //a message from not ourself | ||
1630 | LLFloaterIMPanel* panel = | ||
1631 | gIMView->findFloaterBySession(session_id); | ||
1632 | |||
1633 | if (panel && !is_this_agent ) | ||
1572 | { | 1634 | { |
1573 | llwarns << "Received IM: IM_GROUP_ELECTION_DEPRECATED" << llendl; | 1635 | //don't add a teleport button for yourself |
1636 | panel->addTeleportButton(); | ||
1574 | } | 1637 | } |
1575 | break; | 1638 | break; |
1639 | } | ||
1576 | case IM_SESSION_SEND: | 1640 | case IM_SESSION_SEND: |
1641 | { | ||
1642 | if (!is_linden && is_busy) | ||
1577 | { | 1643 | { |
1578 | if (!is_linden && is_busy) | 1644 | return; |
1645 | } | ||
1646 | |||
1647 | // System messages, specifically "Foo Bar has left this session" | ||
1648 | // are not shown unless you actually have that session open. | ||
1649 | // Band-aid. JC | ||
1650 | if (offline == IM_ONLINE | ||
1651 | && chat.mFromName == SYSTEM_FROM | ||
1652 | && !gIMView->hasSession(session_id)) | ||
1579 | { | 1653 | { |
1580 | return; | 1654 | return; |
1581 | } | 1655 | } |
1582 | 1656 | ||
1583 | // standard message, not from system | 1657 | // standard message, not from system |
1584 | char saved[MAX_STRING]; /* Flawfinder: ignore */ | 1658 | char saved[MAX_STRING]; /* Flawfinder: ignore */ |
1585 | saved[0] = '\0'; | 1659 | saved[0] = '\0'; |
1586 | if(offline == IM_OFFLINE) | 1660 | if(offline == IM_OFFLINE) |
1587 | { | 1661 | { |
1588 | char time_buf[TIME_STR_LENGTH]; /* Flawfinder: ignore */ | 1662 | char time_buf[TIME_STR_LENGTH]; /* Flawfinder: ignore */ |
1589 | snprintf(saved, /* Flawfinder: ignore */ | 1663 | snprintf(saved, /* Flawfinder: ignore */ |
1590 | MAX_STRING, | 1664 | MAX_STRING, |
1591 | "(Saved %s) ", | 1665 | "(Saved %s) ", |
1592 | formatted_time(timestamp, time_buf)); | 1666 | formatted_time(timestamp, time_buf)); |
1593 | } | ||
1594 | snprintf(buffer, sizeof(buffer), "%s%s%s%s", name, separator_string, saved, (message+message_offset)); /* Flawfinder: ignore */ | ||
1595 | BOOL is_this_agent = FALSE; | ||
1596 | if(from_id == gAgentID) | ||
1597 | { | ||
1598 | from_id = LLUUID::null; | ||
1599 | is_this_agent = TRUE; | ||
1600 | } | ||
1601 | gIMView->addMessage( | ||
1602 | session_id, | ||
1603 | from_id, | ||
1604 | name, | ||
1605 | buffer, | ||
1606 | (char*)binary_bucket, | ||
1607 | IM_SESSION_ADD, | ||
1608 | parent_estate_id, | ||
1609 | region_id, | ||
1610 | position); | ||
1611 | |||
1612 | snprintf(buffer, sizeof(buffer), "IM: %s%s%s%s", name, separator_string, saved, (message+message_offset)); /* Flawfinder: ignore */ | ||
1613 | chat.mText = buffer; | ||
1614 | LLFloaterChat::addChat(chat, TRUE, is_this_agent); | ||
1615 | } | 1667 | } |
1616 | break; | 1668 | snprintf(buffer, sizeof(buffer), "%s%s%s%s", name, separator_string, saved, (message+message_offset)); /* Flawfinder: ignore */ |
1669 | BOOL is_this_agent = FALSE; | ||
1670 | if(from_id == gAgentID) | ||
1671 | { | ||
1672 | from_id = LLUUID::null; | ||
1673 | is_this_agent = TRUE; | ||
1674 | } | ||
1675 | gIMView->addMessage( | ||
1676 | session_id, | ||
1677 | from_id, | ||
1678 | name, | ||
1679 | buffer, | ||
1680 | (char*)binary_bucket, | ||
1681 | IM_SESSION_ADD, | ||
1682 | parent_estate_id, | ||
1683 | region_id, | ||
1684 | position); | ||
1685 | |||
1686 | snprintf(buffer, sizeof(buffer), "IM: %s%s%s%s", name, separator_string, saved, (message+message_offset)); /* Flawfinder: ignore */ | ||
1687 | chat.mText = buffer; | ||
1688 | LLFloaterChat::addChat(chat, TRUE, is_this_agent); | ||
1689 | } | ||
1690 | break; | ||
1617 | 1691 | ||
1618 | case IM_FROM_TASK: | 1692 | case IM_FROM_TASK: |
1619 | if (is_busy && !is_owned_by_me) | 1693 | if (is_busy && !is_owned_by_me) |
@@ -1684,21 +1758,6 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) | |||
1684 | } | 1758 | } |
1685 | break; | 1759 | break; |
1686 | 1760 | ||
1687 | case IM_LURE_911: | ||
1688 | { | ||
1689 | // HACK -- the from_id is the im_session_id | ||
1690 | LLFloaterIMPanel* panel = gIMView->findFloaterBySession(session_id); | ||
1691 | if (panel) | ||
1692 | { | ||
1693 | panel->addTeleportButton(from_id); | ||
1694 | } | ||
1695 | else | ||
1696 | { | ||
1697 | llinfos << "LLFloaterIMPanel not found for " << session_id << " from " << from_id << llendl; | ||
1698 | } | ||
1699 | } | ||
1700 | break; | ||
1701 | |||
1702 | case IM_GOTO_URL: | 1761 | case IM_GOTO_URL: |
1703 | { | 1762 | { |
1704 | char* url = new char[binary_bucket_size]; | 1763 | char* url = new char[binary_bucket_size]; |
@@ -2308,7 +2367,18 @@ void process_teleport_progress(LLMessageSystem* msg, void**) | |||
2308 | char buffer[MAX_STRING]; /* Flawfinder: ignore */ | 2367 | char buffer[MAX_STRING]; /* Flawfinder: ignore */ |
2309 | msg->getString("Info", "Message", MAX_STRING, buffer); | 2368 | msg->getString("Info", "Message", MAX_STRING, buffer); |
2310 | lldebugs << "teleport progress: " << buffer << llendl; | 2369 | lldebugs << "teleport progress: " << buffer << llendl; |
2311 | gAgent.setTeleportMessage(buffer); | 2370 | |
2371 | //Sorta hacky...default to using simulator raw messages | ||
2372 | //if we don't find the coresponding mapping in our progress mappings | ||
2373 | LLString message = buffer; | ||
2374 | |||
2375 | if (LLAgent::sTeleportProgressMessages.find(buffer) != | ||
2376 | LLAgent::sTeleportProgressMessages.end() ) | ||
2377 | { | ||
2378 | message = LLAgent::sTeleportProgressMessages[buffer]; | ||
2379 | } | ||
2380 | |||
2381 | gAgent.setTeleportMessage(LLAgent::sTeleportProgressMessages[message]); | ||
2312 | } | 2382 | } |
2313 | 2383 | ||
2314 | class LLFetchInWelcomeArea : public LLInventoryFetchDescendentsObserver | 2384 | class LLFetchInWelcomeArea : public LLInventoryFetchDescendentsObserver |
@@ -2465,7 +2535,7 @@ void process_teleport_finish(LLMessageSystem* msg, void**) | |||
2465 | 2535 | ||
2466 | send_complete_agent_movement(sim_host); | 2536 | send_complete_agent_movement(sim_host); |
2467 | gAgent.setTeleportState( LLAgent::TELEPORT_MOVING ); | 2537 | gAgent.setTeleportState( LLAgent::TELEPORT_MOVING ); |
2468 | gAgent.setTeleportMessage("Contacting New Region..."); | 2538 | gAgent.setTeleportMessage(LLAgent::sTeleportProgressMessages["contacting"]); |
2469 | 2539 | ||
2470 | regionp->setSeedCapability(std::string(seedCap)); | 2540 | regionp->setSeedCapability(std::string(seedCap)); |
2471 | 2541 | ||
@@ -2501,6 +2571,8 @@ void process_avatar_init_complete(LLMessageSystem* msg, void**) | |||
2501 | 2571 | ||
2502 | void process_agent_movement_complete(LLMessageSystem* msg, void**) | 2572 | void process_agent_movement_complete(LLMessageSystem* msg, void**) |
2503 | { | 2573 | { |
2574 | gAgentMovementCompleted = TRUE; | ||
2575 | |||
2504 | LLUUID agent_id; | 2576 | LLUUID agent_id; |
2505 | msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id); | 2577 | msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id); |
2506 | LLUUID session_id; | 2578 | LLUUID session_id; |
@@ -3903,7 +3975,16 @@ void process_alert_core(const char* buffer, BOOL modal) | |||
3903 | } | 3975 | } |
3904 | 3976 | ||
3905 | // Translate system messages here. | 3977 | // Translate system messages here. |
3906 | if (buffer[0] == '/') | 3978 | const char ALERT_PREFIX[] = "ALERT: "; |
3979 | const size_t ALERT_PREFIX_LEN = sizeof(ALERT_PREFIX) - 1; | ||
3980 | if (!strncmp(buffer, ALERT_PREFIX, ALERT_PREFIX_LEN)) | ||
3981 | { | ||
3982 | // Allow the server to spawn a named alert so that server alerts can be | ||
3983 | // translated out of English. JC | ||
3984 | std::string alert_name(buffer + ALERT_PREFIX_LEN); | ||
3985 | LLAlertDialog::showXml(alert_name); | ||
3986 | } | ||
3987 | else if (buffer[0] == '/') | ||
3907 | { | 3988 | { |
3908 | // System message is important, show in upper-right box not tip | 3989 | // System message is important, show in upper-right box not tip |
3909 | LLString text(buffer+1); | 3990 | LLString text(buffer+1); |
@@ -4295,7 +4376,7 @@ void process_teleport_failed(LLMessageSystem *msg, void**) | |||
4295 | msg->getStringFast(_PREHASH_Info, _PREHASH_Reason, STD_STRING_BUF_SIZE, reason); | 4376 | msg->getStringFast(_PREHASH_Info, _PREHASH_Reason, STD_STRING_BUF_SIZE, reason); |
4296 | 4377 | ||
4297 | LLStringBase<char>::format_map_t args; | 4378 | LLStringBase<char>::format_map_t args; |
4298 | args["[REASON]"] = reason; | 4379 | args["[REASON]"] = LLAgent::sTeleportErrorMessages[reason]; |
4299 | gViewerWindow->alertXml("CouldNotTeleportReason", args); | 4380 | gViewerWindow->alertXml("CouldNotTeleportReason", args); |
4300 | 4381 | ||
4301 | if( gAgent.getTeleportState() != LLAgent::TELEPORT_NONE ) | 4382 | if( gAgent.getTeleportState() != LLAgent::TELEPORT_NONE ) |
@@ -4449,25 +4530,6 @@ void handle_lure_callback_godlike(S32 option, void* userdata) | |||
4449 | handle_lure_callback(option, LLString::null, userdata); | 4530 | handle_lure_callback(option, LLString::null, userdata); |
4450 | } | 4531 | } |
4451 | 4532 | ||
4452 | void send_lure_911(void** user_data, S32 result) | ||
4453 | { | ||
4454 | LLUUID im_session_id(*((LLUUID*)user_data)); | ||
4455 | LLString name; | ||
4456 | gAgent.getName(name); | ||
4457 | LLString text = name + " needs help"; // this text is ignored for 911 lures | ||
4458 | LLMessageSystem* msg = gMessageSystem; | ||
4459 | msg->newMessageFast(_PREHASH_StartLure); | ||
4460 | msg->nextBlockFast(_PREHASH_AgentData); | ||
4461 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | ||
4462 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | ||
4463 | msg->nextBlockFast(_PREHASH_Info); | ||
4464 | msg->addU8Fast(_PREHASH_LureType, (U8)IM_LURE_911); | ||
4465 | msg->addStringFast(_PREHASH_Message, text.c_str()); | ||
4466 | msg->nextBlockFast(_PREHASH_TargetData); | ||
4467 | msg->addUUIDFast(_PREHASH_TargetID, im_session_id); | ||
4468 | gAgent.sendReliableMessage(); | ||
4469 | } | ||
4470 | |||
4471 | void handle_lure(const LLUUID& invitee) | 4533 | void handle_lure(const LLUUID& invitee) |
4472 | { | 4534 | { |
4473 | LLDynamicArray<LLUUID> ids; | 4535 | LLDynamicArray<LLUUID> ids; |
@@ -4985,59 +5047,6 @@ void onCovenantLoadComplete(LLVFS *vfs, | |||
4985 | LLFloaterBuyLand::updateCovenantText(covenant_text, asset_uuid); | 5047 | LLFloaterBuyLand::updateCovenantText(covenant_text, asset_uuid); |
4986 | } | 5048 | } |
4987 | 5049 | ||
4988 | void send_generic_message(const char* method, | ||
4989 | const std::vector<std::string>& strings, | ||
4990 | const LLUUID& invoice) | ||
4991 | { | ||
4992 | LLMessageSystem* msg = gMessageSystem; | ||
4993 | msg->newMessage("GenericMessage"); | ||
4994 | msg->nextBlockFast(_PREHASH_AgentData); | ||
4995 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | ||
4996 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | ||
4997 | msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used | ||
4998 | msg->nextBlock("MethodData"); | ||
4999 | msg->addString("Method", method); | ||
5000 | msg->addUUID("Invoice", invoice); | ||
5001 | if(strings.empty()) | ||
5002 | { | ||
5003 | msg->nextBlock("ParamList"); | ||
5004 | msg->addString("Parameter", NULL); | ||
5005 | } | ||
5006 | else | ||
5007 | { | ||
5008 | std::vector<std::string>::const_iterator it = strings.begin(); | ||
5009 | std::vector<std::string>::const_iterator end = strings.end(); | ||
5010 | for(; it != end; ++it) | ||
5011 | { | ||
5012 | msg->nextBlock("ParamList"); | ||
5013 | msg->addString("Parameter", (*it).c_str()); | ||
5014 | } | ||
5015 | } | ||
5016 | gAgent.sendReliableMessage(); | ||
5017 | } | ||
5018 | |||
5019 | |||
5020 | void process_generic_message(LLMessageSystem* msg, void**) | ||
5021 | { | ||
5022 | LLUUID agent_id; | ||
5023 | msg->getUUID("AgentData", "AgentID", agent_id); | ||
5024 | if (agent_id != gAgent.getID()) | ||
5025 | { | ||
5026 | llwarns << "GenericMessage for wrong agent" << llendl; | ||
5027 | return; | ||
5028 | } | ||
5029 | |||
5030 | std::string request; | ||
5031 | LLUUID invoice; | ||
5032 | LLDispatcher::sparam_t strings; | ||
5033 | LLDispatcher::unpackMessage(msg, request, invoice, strings); | ||
5034 | |||
5035 | if(!gGenericDispatcher.dispatch(request, invoice, strings)) | ||
5036 | { | ||
5037 | llwarns << "GenericMessage " << request << " failed to dispatch" | ||
5038 | << llendl; | ||
5039 | } | ||
5040 | } | ||
5041 | 5050 | ||
5042 | void process_feature_disabled_message(LLMessageSystem* msg, void**) | 5051 | void process_feature_disabled_message(LLMessageSystem* msg, void**) |
5043 | { | 5052 | { |
@@ -5062,3 +5071,6 @@ void invalid_message_callback(LLMessageSystem* msg, | |||
5062 | { | 5071 | { |
5063 | bad_network_handler(); | 5072 | bad_network_handler(); |
5064 | } | 5073 | } |
5074 | |||
5075 | // Please do not add more message handlers here. This file is huge. | ||
5076 | // Put them in a file related to the functionality you are implementing. JC | ||