diff options
Diffstat (limited to 'indra/newview/llviewermessage.cpp')
-rw-r--r-- | indra/newview/llviewermessage.cpp | 280 |
1 files changed, 112 insertions, 168 deletions
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 2a6b272741..5836aff4e7 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -2,25 +2,31 @@ * @file llviewermessage.cpp * @brief Dumping ground for viewer-side message system callbacks. * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * $LicenseInfo:firstyear=2002&license=viewergpl$ + * + * Copyright (c) 2002-2009, Linden Research, Inc. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. * $/LicenseInfo$ */ @@ -103,6 +109,10 @@ #include <boost/algorithm/string/split.hpp> // #include <boost/regex.hpp> +#if LL_WINDOWS // For Windows specific error handler +#include "llwindebug.h" // For the invalid message handler +#endif + #include "llnotificationmanager.h" // #if LL_MSVC @@ -696,7 +706,7 @@ static void highlight_inventory_items_in_panel(const std::vector<LLUUID>& items, ++item_iter) { const LLUUID& item_id = (*item_iter); - if(!highlight_offered_object(item_id)) + if(!highlight_offered_item(item_id)) { continue; } @@ -747,18 +757,6 @@ public: const std::string& from_name) : LLInventoryFetchItemsObserver(object_id), mFromName(from_name) {} - /*virtual*/ void startFetch() - { - for (uuid_vec_t::const_iterator it = mIDs.begin(); it < mIDs.end(); ++it) - { - LLViewerInventoryCategory* cat = gInventory.getCategory(*it); - if (cat) - { - mComplete.push_back((*it)); - } - } - LLInventoryFetchItemsObserver::startFetch(); - } /*virtual*/ void done() { open_inventory_offer(mComplete, mFromName); @@ -1071,135 +1069,111 @@ bool check_offer_throttle(const std::string& from_name, bool check_only) } } -void open_inventory_offer(const uuid_vec_t& objects, const std::string& from_name) +void open_inventory_offer(const uuid_vec_t& items, const std::string& from_name) { - for (uuid_vec_t::const_iterator obj_iter = objects.begin(); - obj_iter != objects.end(); - ++obj_iter) + for (uuid_vec_t::const_iterator item_iter = items.begin(); + item_iter != items.end(); + ++item_iter) { - const LLUUID& obj_id = (*obj_iter); - if(!highlight_offered_object(obj_id)) + const LLUUID& item_id = (*item_iter); + if(!highlight_offered_item(item_id)) { continue; } - const LLInventoryObject *obj = gInventory.getObject(obj_id); - if (!obj) - { - llwarns << "Cannot find object [ itemID:" << obj_id << " ] to open." << llendl; + LLInventoryItem* item = gInventory.getItem(item_id); + llassert(item); + if (!item) { continue; } - const LLAssetType::EType asset_type = obj->getActualType(); - - // Either an inventory item or a category. - const LLInventoryItem* item = dynamic_cast<const LLInventoryItem*>(obj); - if (item) - { - //////////////////////////////////////////////////////////////////////////////// - // Special handling for various types. - if (check_offer_throttle(from_name, false)) // If we are throttled, don't display + //////////////////////////////////////////////////////////////////////////////// + // Special handling for various types. + const LLAssetType::EType asset_type = item->getActualType(); + if (check_offer_throttle(from_name, false)) // If we are throttled, don't display + { + LL_DEBUGS("Messaging") << "Highlighting inventory item: " << item->getUUID() << LL_ENDL; + // If we opened this ourselves, focus it + const BOOL take_focus = from_name.empty() ? TAKE_FOCUS_YES : TAKE_FOCUS_NO; + switch(asset_type) { - LL_DEBUGS("Messaging") << "Highlighting inventory item: " << item->getUUID() << LL_ENDL; - // If we opened this ourselves, focus it - const BOOL take_focus = from_name.empty() ? TAKE_FOCUS_YES : TAKE_FOCUS_NO; - switch(asset_type) - { - case LLAssetType::AT_NOTECARD: + case LLAssetType::AT_NOTECARD: + { + LLFloaterReg::showInstance("preview_notecard", LLSD(item_id), take_focus); + break; + } + case LLAssetType::AT_LANDMARK: + { + LLInventoryCategory* parent_folder = gInventory.getCategory(item->getParentUUID()); + if ("inventory_handler" == from_name) { - LLFloaterReg::showInstance("preview_notecard", LLSD(obj_id), take_focus); - break; + //we have to filter inventory_handler messages to avoid notification displaying + LLSideTray::getInstance()->showPanel("panel_places", + LLSD().with("type", "landmark").with("id", item->getUUID())); } - case LLAssetType::AT_LANDMARK: + else if("group_offer" == from_name) { - LLInventoryCategory* parent_folder = gInventory.getCategory(item->getParentUUID()); - if ("inventory_handler" == from_name) - { - //we have to filter inventory_handler messages to avoid notification displaying - LLSideTray::getInstance()->showPanel("panel_places", - LLSD().with("type", "landmark").with("id", item->getUUID())); - } - else if("group_offer" == from_name) - { - // "group_offer" is passed by LLOpenTaskGroupOffer - // Notification about added landmark will be generated under the "from_name.empty()" called from LLOpenTaskOffer::done(). - LLSD args; - args["type"] = "landmark"; - args["id"] = obj_id; - LLSideTray::getInstance()->showPanel("panel_places", args); - - continue; - } - else if(from_name.empty()) - { - std::string folder_name; - if (parent_folder) - { - // Localize folder name. - // *TODO: share this code? - folder_name = parent_folder->getName(); - if (LLFolderType::lookupIsProtectedType(parent_folder->getPreferredType())) - { - LLTrans::findString(folder_name, "InvFolder " + folder_name); - } - } - else - { - folder_name = LLTrans::getString("Unknown"); - } - - // we receive a message from LLOpenTaskOffer, it mean that new landmark has been added. - LLSD args; - args["LANDMARK_NAME"] = item->getName(); - args["FOLDER_NAME"] = folder_name; - LLNotificationsUtil::add("LandmarkCreated", args); - } + // "group_offer" is passed by LLOpenTaskGroupOffer + // Notification about added landmark will be generated under the "from_name.empty()" called from LLOpenTaskOffer::done(). + LLSD args; + args["type"] = "landmark"; + args["id"] = item_id; + LLSideTray::getInstance()->showPanel("panel_places", args); + + continue; } - break; - case LLAssetType::AT_TEXTURE: + else if(from_name.empty()) { - LLFloaterReg::showInstance("preview_texture", LLSD(obj_id), take_focus); - break; + // we receive a message from LLOpenTaskOffer, it mean that new landmark has been added. + LLSD args; + args["LANDMARK_NAME"] = item->getName(); + args["FOLDER_NAME"] = std::string(parent_folder ? parent_folder->getName() : "unknown"); + LLNotificationsUtil::add("LandmarkCreated", args); } - case LLAssetType::AT_ANIMATION: - LLFloaterReg::showInstance("preview_anim", LLSD(obj_id), take_focus); - break; - case LLAssetType::AT_SCRIPT: - LLFloaterReg::showInstance("preview_script", LLSD(obj_id), take_focus); - break; - case LLAssetType::AT_SOUND: - LLFloaterReg::showInstance("preview_sound", LLSD(obj_id), take_focus); - break; - default: - break; } + break; + case LLAssetType::AT_TEXTURE: + { + LLFloaterReg::showInstance("preview_texture", LLSD(item_id), take_focus); + break; + } + case LLAssetType::AT_ANIMATION: + LLFloaterReg::showInstance("preview_anim", LLSD(item_id), take_focus); + break; + case LLAssetType::AT_SCRIPT: + LLFloaterReg::showInstance("preview_script", LLSD(item_id), take_focus); + break; + case LLAssetType::AT_SOUND: + LLFloaterReg::showInstance("preview_sound", LLSD(item_id), take_focus); + break; + default: + break; } } - + //////////////////////////////////////////////////////////////////////////////// - // Highlight item - const BOOL auto_open = - gSavedSettings.getBOOL("ShowInInventory") && // don't open if showininventory is false - !(asset_type == LLAssetType::AT_CALLINGCARD) && // don't open if it's a calling card - !(item && (item->getInventoryType() == LLInventoryType::IT_ATTACHMENT)) && // don't open if it's an item that's an attachment - !from_name.empty(); // don't open if it's not from anyone. + // Highlight item if it's not in the trash, lost+found, or COF + const BOOL auto_open = gSavedSettings.getBOOL("ShowInInventory") && + (asset_type != LLAssetType::AT_CALLINGCARD) && + (item->getInventoryType() != LLInventoryType::IT_ATTACHMENT) && + !from_name.empty(); LLInventoryPanel *active_panel = LLInventoryPanel::getActiveInventoryPanel(auto_open); if(active_panel) { - LL_DEBUGS("Messaging") << "Highlighting" << obj_id << LL_ENDL; + LL_DEBUGS("Messaging") << "Highlighting" << item_id << LL_ENDL; LLFocusableElement* focus_ctrl = gFocusMgr.getKeyboardFocus(); - active_panel->setSelection(obj_id, TAKE_FOCUS_NO); + active_panel->setSelection(item_id, TAKE_FOCUS_NO); gFocusMgr.setKeyboardFocus(focus_ctrl); } } } -bool highlight_offered_object(const LLUUID& obj_id) +bool highlight_offered_item(const LLUUID& item_id) { - const LLInventoryObject* obj = gInventory.getObject(obj_id); - if(!obj) + LLInventoryItem* item = gInventory.getItem(item_id); + if(!item) { - LL_WARNS("Messaging") << "Unable to show inventory item: " << obj_id << LL_ENDL; + LL_WARNS("Messaging") << "Unable to show inventory item: " << item_id << LL_ENDL; return false; } @@ -1208,7 +1182,7 @@ bool highlight_offered_object(const LLUUID& obj_id) // notification (e.g. trash, cof, lost-and-found). if(!gAgent.getAFK()) { - const LLViewerInventoryCategory *parent = gInventory.getFirstNondefaultParent(obj_id); + const LLViewerInventoryCategory *parent = gInventory.getFirstNondefaultParent(item_id); if (parent) { const LLFolderType::EType parent_type = parent->getPreferredType(); @@ -1225,9 +1199,8 @@ bool highlight_offered_object(const LLUUID& obj_id) void inventory_offer_mute_callback(const LLUUID& blocked_id, const std::string& first_name, const std::string& last_name, - BOOL is_group, boost::shared_ptr<LLNotificationResponderInterface> offer_ptr) + BOOL is_group, LLOfferInfo* offer = NULL) { - LLOfferInfo* offer = dynamic_cast<LLOfferInfo*>(offer_ptr.get()); std::string from_name; LLMute::EType type; if (is_group) @@ -1417,13 +1390,7 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD& // * we can't build two messages at once. if (2 == button) // Block { - LLNotificationPtr notification_ptr = LLNotifications::instance().find(notification["id"].asUUID()); - - llassert(notification_ptr != NULL); - if (notification_ptr != NULL) - { - gCacheName->get(mFromID, mFromGroup, boost::bind(&inventory_offer_mute_callback,_1,_2,_3,_4, notification_ptr->getResponderPtr())); - } + gCacheName->get(mFromID, mFromGroup, boost::bind(&inventory_offer_mute_callback,_1,_2,_3,_4,this)); } std::string from_string; // Used in the pop-up. @@ -1557,13 +1524,7 @@ bool LLOfferInfo::inventory_task_offer_callback(const LLSD& notification, const // * we can't build two messages at once. if (2 == button) { - LLNotificationPtr notification_ptr = LLNotifications::instance().find(notification["id"].asUUID()); - - llassert(notification_ptr != NULL); - if (notification_ptr != NULL) - { - gCacheName->get(mFromID, mFromGroup, boost::bind(&inventory_offer_mute_callback,_1,_2,_3,_4, notification_ptr->getResponderPtr())); - } + gCacheName->get(mFromID, mFromGroup, boost::bind(&inventory_offer_mute_callback,_1,_2,_3,_4,this)); } LLMessageSystem* msg = gMessageSystem; @@ -2003,18 +1964,6 @@ static bool parse_lure_bucket(const std::string& bucket, return true; } -class LLPostponedIMSystemTipNotification: public LLPostponedNotification -{ -protected: - /* virtual */ - void modifyNotificationParams() - { - LLSD payload = mParams.payload; - payload["SESSION_NAME"] = mName; - mParams.payload = payload; - } -}; - void process_improved_im(LLMessageSystem *msg, void **user_data) { if (gNoRender) @@ -2085,19 +2034,14 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) LLSD args; LLSD payload; - LLNotification::Params params; - switch(dialog) { case IM_CONSOLE_AND_CHAT_HISTORY: + // *TODO: Translate args["MESSAGE"] = message; - args["NAME"] = name; + payload["SESSION_NAME"] = name; payload["from_id"] = from_id; - - params.name = "IMSystemMessageTip"; - params.substitutions = args; - params.payload = payload; - LLPostponedNotification::add<LLPostponedIMSystemTipNotification>(params, from_id, false); + LLNotificationsUtil::add("IMSystemMessageTip",args, payload); break; case IM_NOTHING_SPECIAL: @@ -2119,7 +2063,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) // initiated by the other party) then... std::string my_name; LLAgentUI::buildFullname(my_name); - std::string response = gSavedPerAccountSettings.getString("BusyModeResponse"); + std::string response = gSavedPerAccountSettings.getString("BusyModeResponse2"); pack_instant_message( gMessageSystem, gAgent.getID(), @@ -2608,7 +2552,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) params.substitutions = substitutions; params.payload = payload; - LLPostponedNotification::add<LLPostponedServerObjectNotification>(params, from_id, from_group); + LLPostponedNotification::add<LLPostponedServerObjectNotification>(params, from_id, false); } break; case IM_FROM_TASK_AS_ALERT: @@ -2651,7 +2595,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) { LLVector3 pos, look_at; U64 region_handle; - U8 region_access = SIM_ACCESS_MIN; + U8 region_access; std::string region_info = ll_safe_string((char*)binary_bucket, binary_bucket_size); std::string region_access_str = LLStringUtil::null; std::string region_access_icn = LLStringUtil::null; @@ -2792,7 +2736,7 @@ void busy_message (LLMessageSystem* msg, LLUUID from_id) { std::string my_name; LLAgentUI::buildFullname(my_name); - std::string response = gSavedPerAccountSettings.getString("BusyModeResponse"); + std::string response = gSavedPerAccountSettings.getString("BusyModeResponse2"); pack_instant_message( gMessageSystem, gAgent.getID(), @@ -5116,7 +5060,7 @@ void process_alert_message(LLMessageSystem *msgsystem, void **user_data) void process_alert_core(const std::string& message, BOOL modal) { - // HACK -- handle callbacks for specific alerts. It also is localized in notifications.xml + // HACK -- handle callbacks for specific alerts if ( message == "You died and have been teleported to your home location") { LLViewerStats::getInstance()->incStat(LLViewerStats::ST_KILLED_COUNT); |