From 089fc07d207c71ce1401e72f09c31ad8c45872e2 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Fri, 15 Aug 2008 23:44:58 -0500 Subject: Second Life viewer sources 1.17.0.12 --- linden/indra/newview/llviewermessage.cpp | 152 +++++++++++++------------------ 1 file changed, 61 insertions(+), 91 deletions(-) (limited to 'linden/indra/newview/llviewermessage.cpp') diff --git a/linden/indra/newview/llviewermessage.cpp b/linden/indra/newview/llviewermessage.cpp index 4973989..87ff5aa 100644 --- a/linden/indra/newview/llviewermessage.cpp +++ b/linden/indra/newview/llviewermessage.cpp @@ -787,15 +787,15 @@ void open_offer(const std::vector& items, const std::string& from_name) if (check_offer_throttle(from_name, false)) { // I'm not sure this is a good idea. JC - // bool show_keep_discard = item->getPermissions().getCreator() != gAgent.getID(); - bool show_keep_discard = true; + bool show_keep_discard = item->getPermissions().getCreator() != gAgent.getID(); + //bool show_keep_discard = true; switch(item->getType()) { case LLAssetType::AT_NOTECARD: - open_notecard(*it, LLString("Note: ") + item->getName(), show_keep_discard, LLUUID::null, FALSE); + open_notecard((LLViewerInventoryItem*)item, LLString("Note: ") + item->getName(), LLUUID::null, show_keep_discard, LLUUID::null, FALSE); break; case LLAssetType::AT_LANDMARK: - open_landmark(*it, LLString("Landmark: ") + item->getName(), show_keep_discard, LLUUID::null, FALSE); + open_landmark((LLViewerInventoryItem*)item, LLString("Landmark: ") + item->getName(), show_keep_discard, LLUUID::null, FALSE); break; case LLAssetType::AT_TEXTURE: open_texture(*it, LLString("Texture: ") + item->getName(), show_keep_discard, LLUUID::null, FALSE); @@ -850,7 +850,7 @@ void inventory_offer_mute_callback(const LLUUID& blocked_id, const char* first_name, const char* last_name, BOOL is_group, - void*) + void* user_data) { LLString from_name; LLMute::EType type; @@ -874,10 +874,35 @@ void inventory_offer_mute_callback(const LLUUID& blocked_id, gFloaterMute->show(); gFloaterMute->selectMute(blocked_id); } + + // purge the offer queue of any previously queued inventory offers from the same source. + LLView::child_list_t notification_queue(*(gNotifyBoxView->getChildList())); + for(LLView::child_list_iter_t iter = notification_queue.begin(); + iter != notification_queue.end(); + iter++) + { + LLNotifyBox* notification = (LLNotifyBox*)*iter; + // scan for other inventory offers (i.e. ignore other types of notifications). + // we can tell by looking for the associated callback they were created with. + if(notification->getNotifyCallback() == inventory_offer_callback) + { + // found one. + // safe to downcast user data because we know it's associated with offer callback. + LLOfferInfo* offer_data = (LLOfferInfo*)notification->getUserData(); + if(offer_data == user_data) + { + continue; // don't remove the msg triggering us. it will be dequeued normally. + } + if(offer_data->mFromID == blocked_id) + { + gNotifyBoxView->removeChild(notification); + } + } + } } -void inventory_offer_callback(S32 option, void* user_data) -{ +void inventory_offer_callback(S32 button, void* user_data) + { LLChat chat; LLString log_message; @@ -889,9 +914,9 @@ void inventory_offer_callback(S32 option, void* user_data) // * callback may be called immediately, // * adding the mute sends a message, // * we can't build two messages at once. JC - if (option == 2) + if (2 == button) { - gCacheName->get(info->mFromID, info->mFromGroup, inventory_offer_mute_callback, NULL); + gCacheName->get(info->mFromID, info->mFromGroup, inventory_offer_mute_callback, user_data); } LLMessageSystem* msg = gMessageSystem; @@ -922,7 +947,8 @@ void inventory_offer_callback(S32 option, void* user_data) } // XUI:translate - LLString from_string; + LLString from_string; // Used in the pop-up. + LLString chatHistory_string; // Used in chat history. if (info->mFromObject == TRUE) { if (info->mFromGroup) @@ -931,10 +957,12 @@ void inventory_offer_callback(S32 option, void* user_data) if (gCacheName->getGroupName(info->mFromID, group_name)) { from_string = LLString("An object named '") + info->mFromName + "' owned by the group '" + group_name + "'"; + chatHistory_string = info->mFromName + " owned by the group '" + group_name + "'"; } else { from_string = LLString("An object named '") + info->mFromName + "' owned by an unknown group"; + chatHistory_string = info->mFromName + " owned by an unknown group"; } } else @@ -944,21 +972,23 @@ void inventory_offer_callback(S32 option, void* user_data) if (gCacheName->getName(info->mFromID, first_name, last_name)) { from_string = LLString("An object named '") + info->mFromName + "' owned by " + first_name + " " + last_name; + chatHistory_string = info->mFromName + " owned by " + first_name + " " + last_name; } else { from_string = LLString("An object named '") + info->mFromName + "' owned by an unknown user"; + chatHistory_string = info->mFromName + " owned by an unknown user"; } } } else { - from_string = info->mFromName; + from_string = chatHistory_string = info->mFromName; } bool busy=FALSE; - switch(option) + switch(button) { case IOR_ACCEPT: // ACCEPT. The math for the dialog works, because the accept @@ -975,7 +1005,7 @@ void inventory_offer_callback(S32 option, void* user_data) //don't spam them if they are getting flooded if (check_offer_throttle(info->mFromName, true)) { - log_message = info->mFromName + " gave you " + info->mDesc + "."; + log_message = chatHistory_string + " gave you " + info->mDesc + "."; chat.mText = log_message; LLFloaterChat::addChatHistory(chat); } @@ -1017,7 +1047,7 @@ void inventory_offer_callback(S32 option, void* user_data) default: llwarns << "inventory_offer_callback: unknown offer type" << llendl; break; - } + } // end switch (info->mIM) break; case IOR_BUSY: @@ -1040,6 +1070,10 @@ void inventory_offer_callback(S32 option, void* user_data) log_message = "You decline " + info->mDesc + " from " + info->mFromName + "."; chat.mText = log_message; + if( gMuteListp->isMuted(info->mFromID ) && ! gMuteListp->isLinden(info->mFromName) ) // muting for SL-42269 + { + chat.mMuted = TRUE; + } LLFloaterChat::addChatHistory(chat); // If it's from an agent, we have to fetch the item to throw @@ -1086,7 +1120,6 @@ void inventory_offer_callback(S32 option, void* user_data) void inventory_offer_handler(LLOfferInfo* info, BOOL from_task) { - //Until throttling is implmented, busy mode should reject inventory instead of silently //accepting it. SEE SL-39554 if (gAgent.getBusy()) @@ -1101,15 +1134,15 @@ void inventory_offer_handler(LLOfferInfo* info, BOOL from_task) inventory_offer_callback(IOR_MUTE, info); return; } - - if (gSavedSettings.getBOOL("ShowNewInventory") + + // Avoid the Accept/Discard dialog if the user so desires. JC + if (gSavedSettings.getBOOL("AutoAcceptNewInventory") && (info->mType == LLAssetType::AT_NOTECARD || info->mType == LLAssetType::AT_LANDMARK || info->mType == LLAssetType::AT_TEXTURE)) { // For certain types, just accept the items into the inventory, - // and we'll automatically open them on receipt. - // 0 = accept button + // and possibly open them on receipt depending upon "ShowNewInventory". inventory_offer_callback(IOR_ACCEPT, info); return; } @@ -1678,86 +1711,23 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) } break; - case IM_SESSION_911_SEND: + case IM_SESSION_SEND: { - //this is just the same code as IM_SESSION_SEND for a bit - //I was too lazy to make this a function....sorry - jwolk if (!is_linden && is_busy) { return; } - - // standard message, not from system - char saved[MAX_STRING]; /* Flawfinder: ignore */ - saved[0] = '\0'; - if(offline == IM_OFFLINE) - { - char time_buf[TIME_STR_LENGTH]; /* Flawfinder: ignore */ - snprintf(saved, /* Flawfinder: ignore */ - MAX_STRING, - "(Saved %s) ", - formatted_time(timestamp, time_buf)); - } - - snprintf(buffer, /* Flawfinder: ignore */ - sizeof(buffer), - "%s%s%s%s", - name, - separator_string, - saved, - (message+message_offset)); - - BOOL is_this_agent = FALSE; - if(from_id == gAgentID) - { - from_id = LLUUID::null; - is_this_agent = TRUE; - } - - gIMView->addMessage( - session_id, - from_id, - name, - buffer, - (char*)binary_bucket, - IM_SESSION_ADD, - parent_estate_id, - region_id, - position); - snprintf(buffer, sizeof(buffer), "IM: %s%s%s%s", name, separator_string, saved, (message+message_offset)); /* Flawfinder: ignore */ - chat.mText = buffer; - LLFloaterChat::addChat(chat, TRUE, is_this_agent); - - //ok, now we want to add a teleport button if we are receving - //a message from not ourself - LLFloaterIMPanel* panel = - gIMView->findFloaterBySession(session_id); - - if (panel && !is_this_agent ) - { - //don't add a teleport button for yourself - panel->addTeleportButton(); - } - break; - } - case IM_SESSION_SEND: - { - if (!is_linden && is_busy) + // System messages, specifically "Foo Bar has left this session" + // are not shown unless you actually have that session open. + // Band-aid. JC + if (offline == IM_ONLINE + && chat.mFromName == SYSTEM_FROM + && !gIMView->hasSession(session_id)) { return; } - // System messages, specifically "Foo Bar has left this session" - // are not shown unless you actually have that session open. - // Band-aid. JC - if (offline == IM_ONLINE - && chat.mFromName == SYSTEM_FROM - && !gIMView->hasSession(session_id)) - { - return; - } - // standard message, not from system char saved[MAX_STRING]; /* Flawfinder: ignore */ saved[0] = '\0'; @@ -1782,7 +1752,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) name, buffer, (char*)binary_bucket, - IM_SESSION_ADD, + IM_SESSION_INVITE, parent_estate_id, region_id, position); @@ -2184,7 +2154,7 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) if (chat.mSourceType == CHAT_SOURCE_OBJECT && chat.mChatType != CHAT_TYPE_DEBUG_MSG) { - LLViewerPartSourceChat *psc = new LLViewerPartSourceChat(chatter->getPositionAgent()); + LLPointer psc = new LLViewerPartSourceChat(chatter->getPositionAgent()); psc->setSourceObject(chatter); psc->setColor(color); //We set the particles to be owned by the object's owner, -- cgit v1.1