diff options
Diffstat (limited to 'indra/newview/llviewermessage.cpp')
-rw-r--r-- | indra/newview/llviewermessage.cpp | 184 |
1 files changed, 99 insertions, 85 deletions
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 520de0e403..d02e667d19 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -48,6 +48,7 @@ #include "lldbstrings.h" #include "lleconomy.h" #include "llfilepicker.h" +#include "llfloaterreg.h" #include "llfocusmgr.h" #include "llfollowcamparams.h" #include "llinstantmessage.h" @@ -160,7 +161,7 @@ void open_offer(const std::vector<LLUUID>& items, const std::string& from_name); bool check_offer_throttle(const std::string& from_name, bool check_only); void callbackCacheEstateOwnerName(const LLUUID& id, const std::string& first, const std::string& last, - BOOL is_group, void*); + BOOL is_group); //inventory offer throttle globals LLFrameTimer gThrottleTimer; @@ -867,13 +868,14 @@ void open_offer(const std::vector<LLUUID>& items, const std::string& from_name) LLInventoryItem* item; for(; it != end; ++it) { - item = gInventory.getItem(*it); + const LLUUID& id = *it; + item = gInventory.getItem(id); if(!item) { - LL_WARNS("Messaging") << "Unable to show inventory item: " << *it << LL_ENDL; + LL_WARNS("Messaging") << "Unable to show inventory item: " << id << LL_ENDL; continue; } - if(gInventory.isObjectDescendentOf(*it, trash_id)) + if(gInventory.isObjectDescendentOf(id, trash_id)) { continue; } @@ -882,40 +884,43 @@ void open_offer(const std::vector<LLUUID>& items, const std::string& from_name) //if we are throttled, don't display them if (check_offer_throttle(from_name, false)) { - // I'm not sure this is a good idea. - bool show_keep_discard = item->getPermissions().getCreator() != gAgent.getID(); - //bool show_keep_discard = true; + // If we opened this ourselves, focus it + BOOL take_focus = from_name.empty() ? TAKE_FOCUS_YES : TAKE_FOCUS_NO; switch(asset_type) { - case LLAssetType::AT_NOTECARD: - open_notecard((LLViewerInventoryItem*)item, std::string("Note: ") + item->getName(), LLUUID::null, show_keep_discard, LLUUID::null, FALSE); + case LLAssetType::AT_NOTECARD: + LLFloaterReg::showInstance("preview_notecard", LLSD(id), take_focus); break; - case LLAssetType::AT_LANDMARK: - open_landmark((LLViewerInventoryItem*)item, std::string("Landmark: ") + item->getName(), show_keep_discard, LLUUID::null, FALSE); + case LLAssetType::AT_LANDMARK: + LLFloaterReg::showInstance("preview_landmark", LLSD(id), take_focus); break; - case LLAssetType::AT_TEXTURE: - open_texture(*it, std::string("Texture: ") + item->getName(), show_keep_discard, LLUUID::null, FALSE); + case LLAssetType::AT_TEXTURE: + LLFloaterReg::showInstance("preview_texture", LLSD(id), take_focus); break; - default: + default: break; } } //highlight item, if it's not in the trash or lost+found // Don't auto-open the inventory floater - LLInventoryView* view = LLInventoryView::getActiveInventory(); - if(!view) - { - return; - } - + LLInventoryView* view = NULL; if(gSavedSettings.getBOOL("ShowInInventory") && asset_type != LLAssetType::AT_CALLINGCARD && item->getInventoryType() != LLInventoryType::IT_ATTACHMENT && !from_name.empty()) { - LLInventoryView::showAgentInventory(TRUE); + view = LLInventoryView::showAgentInventory(); + } + else + { + view = LLInventoryView::getActiveInventory(); } + if(!view) + { + return; + } + //Trash Check LLUUID trash_id; trash_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_TRASH); @@ -941,17 +946,19 @@ void open_offer(const std::vector<LLUUID>& items, const std::string& from_name) LL_DEBUGS("Messaging") << "Highlighting" << item->getUUID() << LL_ENDL; //highlight item - LLUICtrl* focus_ctrl = gFocusMgr.getKeyboardFocus(); - view->getPanel()->setSelection(item->getUUID(), TAKE_FOCUS_NO); - gFocusMgr.setKeyboardFocus(focus_ctrl); + if (view->getPanel()) + { + LLUICtrl* focus_ctrl = gFocusMgr.getKeyboardFocus(); + view->getPanel()->setSelection(item->getUUID(), TAKE_FOCUS_NO); + gFocusMgr.setKeyboardFocus(focus_ctrl); + } } } void inventory_offer_mute_callback(const LLUUID& blocked_id, const std::string& first_name, const std::string& last_name, - BOOL is_group, - void* user_data) + BOOL is_group) { std::string from_name; LLMute::EType type; @@ -1040,7 +1047,7 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD& // * we can't build two messages at once. if (2 == button) { - gCacheName->get(mFromID, mFromGroup, inventory_offer_mute_callback, this); + gCacheName->get(mFromID, mFromGroup, &inventory_offer_mute_callback); } LLMessageSystem* msg = gMessageSystem; @@ -1070,7 +1077,6 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD& itemp = (LLViewerInventoryItem*)gInventory.getItem(mObjectID); } - // *TODO:translate std::string from_string; // Used in the pop-up. std::string chatHistory_string; // Used in chat history. if (mFromObject == TRUE) @@ -1080,13 +1086,18 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD& std::string group_name; if (gCacheName->getGroupName(mFromID, group_name)) { - from_string = std::string("An object named '") + mFromName + "' owned by the group '" + group_name + "'"; - chatHistory_string = mFromName + " owned by the group '" + group_name + "'"; + from_string = LLTrans::getString("InvOfferAnObjectNamed") + " "+"'" + + mFromName + LLTrans::getString("'") +" " + LLTrans::getString("InvOfferOwnedByGroup") + + " "+ "'" + group_name + "'"; + + chatHistory_string = mFromName + " " + LLTrans::getString("InvOfferOwnedByGroup") + + " " + group_name + "'"; } else { - from_string = std::string("An object named '") + mFromName + "' owned by an unknown group"; - chatHistory_string = mFromName + " owned by an unknown group"; + from_string = LLTrans::getString("InvOfferAnObjectNamed") + " "+"'" + + mFromName +"'"+ " " + LLTrans::getString("InvOfferOwnedByUnknownGroup"); + chatHistory_string = mFromName + " " + LLTrans::getString("InvOfferOwnedByUnknownGroup"); } } else @@ -1094,13 +1105,15 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD& std::string first_name, last_name; if (gCacheName->getName(mFromID, first_name, last_name)) { - from_string = std::string("An object named '") + mFromName + "' owned by " + first_name + " " + last_name; - chatHistory_string = mFromName + " owned by " + first_name + " " + last_name; + from_string = LLTrans::getString("InvOfferAnObjectNamed") + " "+ LLTrans::getString("'") + mFromName + + LLTrans::getString("'")+" " + LLTrans::getString("InvOfferOwnedBy") + first_name + " " + last_name; + chatHistory_string = mFromName + " " + LLTrans::getString("InvOfferOwnedBy") + " " + first_name + " " + last_name; } else { - from_string = std::string("An object named '") + mFromName + "' owned by an unknown user"; - chatHistory_string = mFromName + " owned by an unknown user"; + from_string = LLTrans::getString("InvOfferAnObjectNamed") + " "+LLTrans::getString("'") + + mFromName + LLTrans::getString("'")+" " + LLTrans::getString("InvOfferOwnedByUnknownUser"); + chatHistory_string = mFromName + " " + LLTrans::getString("InvOfferOwnedByUnknownUser"); } } } @@ -1128,7 +1141,7 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD& //don't spam them if they are getting flooded if (check_offer_throttle(mFromName, true)) { - log_message = chatHistory_string + " gave you " + mDesc + "."; + log_message = chatHistory_string + " " + LLTrans::getString("InvOfferGaveYou") + " " + mDesc + LLTrans::getString("."); chat.mText = log_message; LLFloaterChat::addChatHistory(chat); } @@ -1191,7 +1204,7 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD& // send the message msg->sendReliable(mHost); - log_message = "You decline " + mDesc + " from " + mFromName + "."; + log_message = LLTrans::getString("InvOfferYouDecline") + " " + mDesc + " " + LLTrans::getString("InvOfferFrom") + " " + mFromName +"."; chat.mText = log_message; if( LLMuteList::getInstance()->isMuted(mFromID ) && ! LLMuteList::getInstance()->isLinden(mFromName) ) // muting for SL-42269 { @@ -1232,10 +1245,6 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD& gInventory.addObserver(opener); } - // Allow these to stack up, but once you deal with one, reset the - // position. - gFloaterView->resetStartingFloaterPosition(); - delete this; return false; } @@ -1329,7 +1338,7 @@ void inventory_offer_handler(LLOfferInfo* info, BOOL from_task) args["NAME"] = info->mFromName; LLNotification::Params p("ObjectGiveItem"); - p.substitutions(args).payload(payload).functor(boost::bind(&LLOfferInfo::inventory_offer_callback, info, _1, _2)); + p.substitutions(args).payload(payload).functor.function(boost::bind(&LLOfferInfo::inventory_offer_callback, info, _1, _2)); if (from_task) { @@ -1415,7 +1424,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) LLChat chat; std::string buffer; - // *TODO:translate - need to fix the full name to first/last (maybe) + // *TODO: Translate - need to fix the full name to first/last (maybe) msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, from_id); msg->getBOOLFast(_PREHASH_MessageBlock, _PREHASH_FromGroup, from_group); msg->getUUIDFast(_PREHASH_MessageBlock, _PREHASH_ToAgentID, to_id); @@ -1466,7 +1475,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) case IM_CONSOLE_AND_CHAT_HISTORY: // These are used for system messages, hence don't need the name, // as it is always "Second Life". - // *TODO:translate + // *TODO: Translate args["MESSAGE"] = message; // Note: don't put the message in the IM history, even though was sent @@ -1611,7 +1620,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) case IM_MESSAGEBOX: { // This is a block, modeless dialog. - //*TODO:translate + //*TODO: Translate args["MESSAGE"] = message; LLNotifications::instance().add("SystemMessage", args); } @@ -1969,7 +1978,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) else { LLSD args; - // *TODO:translate -> [FIRST] [LAST] (maybe) + // *TODO: Translate -> [FIRST] [LAST] (maybe) args["NAME"] = name; args["MESSAGE"] = message; LLSD payload; @@ -2430,7 +2439,7 @@ void process_teleport_start(LLMessageSystem *msg, void**) } else { - gViewerWindow->setProgressCancelButtonVisible(TRUE, std::string("Cancel")); // *TODO: Translate + gViewerWindow->setProgressCancelButtonVisible(TRUE, LLTrans::getString("Cancel")); } // Freeze the UI and show progress bar @@ -2465,7 +2474,7 @@ void process_teleport_progress(LLMessageSystem* msg, void**) } else { - gViewerWindow->setProgressCancelButtonVisible(TRUE, std::string("Cancel")); //TODO: Translate + gViewerWindow->setProgressCancelButtonVisible(TRUE, LLTrans::getString("Cancel")); } std::string buffer; msg->getString("Info", "Message", buffer); @@ -4094,7 +4103,7 @@ void process_money_balance_reply( LLMessageSystem* msg, void** ) { // Make the user confirm the transaction, since they might // have missed something during an event. - // *TODO:translate + // *TODO: Translate LLSD args; args["MESSAGE"] = desc; LLNotifications::instance().add("SystemMessage", args); @@ -4170,7 +4179,7 @@ bool handle_special_notification(std::string notificationID, LLSD& llsdBlock) bool attempt_standard_notification(LLMessageSystem* msgsystem) { // if we have additional alert data - if (msgsystem->getNumberOfBlocksFast(_PREHASH_AlertInfo) > 0) + if (msgsystem->has(_PREHASH_AlertInfo) && msgsystem->getNumberOfBlocksFast(_PREHASH_AlertInfo) > 0) { // notification was specified using the new mechanism, so we can just handle it here std::string notificationID; @@ -4316,21 +4325,21 @@ void process_alert_core(const std::string& message, BOOL modal) } else { - // *TODO:translate + // *TODO: Translate args["MESSAGE"] = text; LLNotifications::instance().add("SystemMessage", args); } } else if (modal) { - // *TODO:translate + // *TODO: Translate LLSD args; args["ERROR_MESSAGE"] = message; LLNotifications::instance().add("ErrorMessage", args); } else { - // *TODO:translate + // *TODO: Translate LLSD args; args["MESSAGE"] = message; LLNotifications::instance().add("SystemMessageTip", args); @@ -4347,10 +4356,10 @@ void handle_show_mean_events(void *) return; } - LLFloaterBump::show(NULL); + LLFloaterBump::showInstance(); } -void mean_name_callback(const LLUUID &id, const std::string& first, const std::string& last, BOOL always_false, void* data) +void mean_name_callback(const LLUUID &id, const std::string& first, const std::string& last, BOOL always_false) { if (gNoRender) { @@ -4428,7 +4437,7 @@ void process_mean_collision_alert_message(LLMessageSystem *msgsystem, void **use LLMeanCollisionData *mcd = new LLMeanCollisionData(gAgentID, perp, time, type, mag); gMeanCollisionList.push_front(mcd); const BOOL is_group = FALSE; - gCacheName->get(perp, is_group, mean_name_callback); + gCacheName->get(perp, is_group, &mean_name_callback); } } } @@ -4480,7 +4489,7 @@ void notify_cautioned_script_question(const LLSD& notification, const LLSD& resp // located in [REGIONNAME] at [REGIONPOS], // has been <granted|denied> permission to: [PERMISSIONS]." - LLUIString notice(LLFloaterChat::getInstance()->getString(granted ? "ScriptQuestionCautionChatGranted" : "ScriptQuestionCautionChatDenied")); + LLUIString notice(LLTrans::getString(granted ? "ScriptQuestionCautionChatGranted" : "ScriptQuestionCautionChatDenied")); // always include the object name and owner name notice.setArg("[OBJECTNAME]", notification["payload"]["object_name"].asString()); @@ -4534,7 +4543,7 @@ void notify_cautioned_script_question(const LLSD& notification, const LLSD& resp perms.append(", "); } - perms.append(LLFloaterChat::getInstance()->getString(SCRIPT_QUESTIONS[i])); + perms.append(LLTrans::getString(SCRIPT_QUESTIONS[i])); } } @@ -4628,7 +4637,7 @@ static LLNotificationFunctorRegistration script_question_cb_reg_2("ScriptQuestio void process_script_question(LLMessageSystem *msg, void **user_data) { - // *TODO:translate owner name -> [FIRST] [LAST] + // *TODO: Translate owner name -> [FIRST] [LAST] LLHost sender = msg->getSender(); @@ -4696,7 +4705,7 @@ void process_script_question(LLMessageSystem *msg, void **user_data) if (questions & LSCRIPTRunTimePermissionBits[i]) { count++; - script_question += " " + LLFloaterChat::getInstance()->getString(SCRIPT_QUESTIONS[i]) + "\n"; + script_question += " " + LLTrans::getString(SCRIPT_QUESTIONS[i]) + "\n"; // check whether permission question should cause special caution dialog caution |= (SCRIPT_QUESTION_IS_CAUTION[i]); @@ -4752,7 +4761,7 @@ void container_inventory_arrived(LLViewerObject* object, LLUUID cat_id; cat_id = gInventory.createNewCategory(gAgent.getInventoryRootID(), LLAssetType::AT_NONE, - std::string("Acquired Items")); //TODO: Translate + LLTrans::getString("AcquiredItems")); InventoryObjectList::const_iterator it = inventory->begin(); InventoryObjectList::const_iterator end = inventory->end(); @@ -4846,10 +4855,11 @@ void container_inventory_arrived(LLViewerObject* object, // method to format the time. std::string formatted_time(const time_t& the_time) { - char buffer[30]; /* Flawfinder: ignore */ - LLStringUtil::copy(buffer, ctime(&the_time), 30); - buffer[24] = '\0'; - return std::string(buffer); + std::string dateStr = LLTrans::getString("ViewerMsgGenericTime"); + LLSD substitution; + substitution["datetime"] = (S32) the_time; + LLStringUtil::format (dateStr, substitution); + return dateStr; } @@ -4860,7 +4870,7 @@ void process_teleport_failed(LLMessageSystem *msg, void**) LLSD args; // if we have additional alert data - if (msg->getNumberOfBlocksFast(_PREHASH_AlertInfo) > 0) + if (msg->has(_PREHASH_AlertInfo) && msg->getSizeFast(_PREHASH_AlertInfo, _PREHASH_Message) > 0) { // Get the message ID msg->getStringFast(_PREHASH_AlertInfo, _PREHASH_Message, reason); @@ -5073,7 +5083,7 @@ void handle_lure(const LLUUID& invitee) } // Prompt for a message to the invited user. -void handle_lure(LLDynamicArray<LLUUID>& ids) +void handle_lure(std::vector<LLUUID>& ids) { LLSD edit_args; edit_args["REGION"] = gAgent.getRegion()->getName(); @@ -5297,7 +5307,7 @@ static LLNotificationFunctorRegistration callback_load_url_reg("LoadWebPage", ca // We've got the name of the person who owns the object hurling the url. // Display confirmation dialog. -void callback_load_url_name(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group, void* data) +void callback_load_url_name(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group) { std::vector<LLSD>::iterator it; for (it = gLoadUrlList.begin(); it != gLoadUrlList.end(); ) @@ -5310,7 +5320,7 @@ void callback_load_url_name(const LLUUID& id, const std::string& first, const st std::string owner_name; if (is_group) { - owner_name = first + " (group)"; + owner_name = first + LLTrans::getString("Group"); } else { @@ -5374,7 +5384,7 @@ void process_load_url(LLMessageSystem* msg, void**) // Add to list of pending name lookups gLoadUrlList.push_back(payload); - gCacheName->get(owner_id, owner_is_group, callback_load_url_name); + gCacheName->get(owner_id, owner_is_group, &callback_load_url_name); } @@ -5430,12 +5440,13 @@ void process_script_teleport_request(LLMessageSystem* msg, void**) msg->getVector3("Data", "SimPosition", pos); msg->getVector3("Data", "LookAt", look_at); - gFloaterWorldMap->trackURL(sim_name, (S32)pos.mV[VX], (S32)pos.mV[VY], (S32)pos.mV[VZ]); - LLFloaterWorldMap::show(NULL, TRUE); + LLFloaterWorldMap::getInstance()->trackURL( + sim_name, (S32)pos.mV[VX], (S32)pos.mV[VY], (S32)pos.mV[VZ]); + LLFloaterReg::showInstance("world_map", "center"); // remove above two lines and replace with below line // to re-enable parcel browser for llMapDestination() - // LLURLDispatcher::dispatch(LLURLDispatcher::buildSLURL(sim_name, (S32)pos.mV[VX], (S32)pos.mV[VY], (S32)pos.mV[VZ]), FALSE); + // LLURLDispatcher::dispatch(LLSLURL::buildSLURL(sim_name, (S32)pos.mV[VX], (S32)pos.mV[VY], (S32)pos.mV[VZ]), FALSE); } @@ -5454,13 +5465,16 @@ void process_covenant_reply(LLMessageSystem* msg, void**) LLFloaterBuyLand::updateEstateName(estate_name); // standard message, not from system - std::string last_modified = std::string("Last Modified ") + formatted_time((time_t)covenant_timestamp); + std::string last_modified = LLTrans::getString("last_modified"); + LLSD substitution; + substitution["datetime"] = (S32) covenant_timestamp; + LLStringUtil::format (last_modified, substitution); LLPanelEstateCovenant::updateLastModified(last_modified); LLPanelLandCovenant::updateLastModified(last_modified); LLFloaterBuyLand::updateLastModified(last_modified); - gCacheName->getName(estate_owner_id, callbackCacheEstateOwnerName); + gCacheName->get(estate_owner_id, false, &callbackCacheEstateOwnerName); // load the actual covenant asset data const BOOL high_priority = TRUE; @@ -5482,11 +5496,11 @@ void process_covenant_reply(LLMessageSystem* msg, void**) if (estate_owner_id.isNull()) { // mainland - covenant_text = "There is no Covenant provided for this Estate."; + covenant_text = LLTrans::getString("RegionNoCovenant"); } else { - covenant_text = "There is no Covenant provided for this Estate. The land on this estate is being sold by the Estate owner, not Linden Lab. Please contact the Estate Owner for sales details."; + covenant_text = LLTrans::getString("RegionNoCovenantOtherOwner"); } LLPanelEstateCovenant::updateCovenantText(covenant_text, covenant_id); LLPanelLandCovenant::updateCovenantText(covenant_text); @@ -5496,13 +5510,13 @@ void process_covenant_reply(LLMessageSystem* msg, void**) void callbackCacheEstateOwnerName(const LLUUID& id, const std::string& first, const std::string& last, - BOOL is_group, void*) + BOOL is_group) { std::string name; if (id.isNull()) { - name = "(none)"; + name = LLTrans::getString("none_text"); } else { @@ -5533,10 +5547,10 @@ void onCovenantLoadComplete(LLVFS *vfs, if( (file_length > 19) && !strncmp( &buffer[0], "Linden text version", 19 ) ) { - LLViewerTextEditor* editor = - new LLViewerTextEditor(std::string("temp"), - LLRect(0,0,0,0), - file_length+1); + LLViewerTextEditor::Params params; + params.name("temp"); + params.max_text_length(file_length+1); + LLViewerTextEditor * editor = LLUICtrlFactory::create<LLViewerTextEditor> (params); if( !editor->importBuffer( &buffer[0], file_length+1 ) ) { LL_WARNS("Messaging") << "Problem importing estate covenant." << LL_ENDL; @@ -5611,6 +5625,6 @@ void invalid_message_callback(LLMessageSystem* msg, void LLOfferInfo::forceResponse(InventoryOfferResponse response) { LLNotification::Params params("UserGiveItem"); - params.functor(boost::bind(&LLOfferInfo::inventory_offer_callback, this, _1, _2)); + params.functor.function(boost::bind(&LLOfferInfo::inventory_offer_callback, this, _1, _2)); LLNotifications::instance().forceResponse(params, response); } |