From c07901e29ed545bbb02e3bddf148fe1104b94e9f Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Fri, 15 Aug 2008 23:44:56 -0500 Subject: Second Life viewer sources 1.15.1.3 --- linden/indra/newview/llinventorymodel.cpp | 134 +++++++++++------------------- 1 file changed, 47 insertions(+), 87 deletions(-) (limited to 'linden/indra/newview/llinventorymodel.cpp') diff --git a/linden/indra/newview/llinventorymodel.cpp b/linden/indra/newview/llinventorymodel.cpp index ddd229b..8e95156 100644 --- a/linden/indra/newview/llinventorymodel.cpp +++ b/linden/indra/newview/llinventorymodel.cpp @@ -27,6 +27,7 @@ */ #include "llviewerprecompiledheaders.h" + #include "llinventorymodel.h" #include "llassetstorage.h" @@ -41,6 +42,7 @@ #include "llfocusmgr.h" #include "llinventoryview.h" #include "llviewerinventory.h" +#include "llviewermessage.h" #include "llviewerwindow.h" #include "viewer.h" #include "lldbstrings.h" @@ -2282,7 +2284,7 @@ void LLInventoryModel::processUseCachedInventory(LLMessageSystem* msg, void**) void LLInventoryModel::processUpdateCreateInventoryItem(LLMessageSystem* msg, void**) { // do accounting and highlight new items if they arrive - if (gInventory.messageUpdateCore(msg, true, true)) + if (gInventory.messageUpdateCore(msg, true)) { U32 callback_id; LLUUID item_id; @@ -2298,12 +2300,15 @@ void LLInventoryModel::processUpdateCreateInventoryItem(LLMessageSystem* msg, vo void LLInventoryModel::processFetchInventoryReply(LLMessageSystem* msg, void**) { // no accounting - gInventory.messageUpdateCore(msg, false, false); + gInventory.messageUpdateCore(msg, false); } -bool LLInventoryModel::messageUpdateCore(LLMessageSystem* msg, bool account, bool highlight_new) +bool LLInventoryModel::messageUpdateCore(LLMessageSystem* msg, bool account) { + //make sure our added inventory observer is active -Gigs + start_new_inventory_observer(); + LLUUID agent_id; msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id); if(agent_id != gAgent.getID()) @@ -2312,16 +2317,15 @@ bool LLInventoryModel::messageUpdateCore(LLMessageSystem* msg, bool account, boo << llendl; return false; } - LLPointer lastitem; // hack item_array_t items; update_map_t update; S32 count = msg->getNumberOfBlocksFast(_PREHASH_InventoryData); bool all_one_folder = true; LLUUID folder_id; + // Does this loop ever execute more than once? -Gigs for(S32 i = 0; i < count; ++i) { LLPointer titem = new LLViewerInventoryItem; - lastitem = titem; titem->unpackMessage(msg, _PREHASH_InventoryData, i); lldebugs << "LLInventoryModel::messageUpdateCore() item id:" << titem->getUUID() << llendl; @@ -2359,6 +2363,7 @@ bool LLInventoryModel::messageUpdateCore(LLMessageSystem* msg, bool account, boo } U32 changes = 0x0; + //as above, this loop never seems to loop more than once per call for (item_array_t::iterator it = items.begin(); it != items.end(); ++it) { changes |= gInventory.updateItem(*it); @@ -2366,88 +2371,6 @@ bool LLInventoryModel::messageUpdateCore(LLMessageSystem* msg, bool account, boo gInventory.notifyObservers(); gViewerWindow->getWindow()->decBusyCount(); - // *HACK: Do the 'show' logic for a new item in the inventory if - // it is a newly created item. - if (highlight_new - && (changes & LLInventoryObserver::ADD) == LLInventoryObserver::ADD) - { - LLUUID trash_id; - trash_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_TRASH); - if(!gInventory.isObjectDescendentOf(lastitem->getUUID(), trash_id)) - { - LLMultiPreview* multi_previewp = LLMultiPreview::getAutoOpenInstance(folder_id); - if (!multi_previewp && all_one_folder && count > 1) - { - S32 left, top; - gFloaterView->getNewFloaterPosition(&left, &top); - - multi_previewp = new LLMultiPreview(LLRect(left, top, left + 300, top - 100)); - LLMultiPreview::setAutoOpenInstance(multi_previewp, folder_id); - } - - LLFloater::setFloaterHost(multi_previewp); - - bool show_keep_discard = lastitem->getPermissions().getCreator() != gAgent.getID(); - switch(lastitem->getType()) - { - case LLAssetType::AT_NOTECARD: - open_notecard( - lastitem->getUUID(), - LLString("Note: ") + lastitem->getName(), - show_keep_discard, - LLUUID::null, - FALSE); - break; - case LLAssetType::AT_LANDMARK: - open_landmark( - lastitem->getUUID(), - LLString(" ") + lastitem->getName(), - show_keep_discard, - LLUUID::null, - FALSE); - break; - case LLAssetType::AT_TEXTURE: - open_texture( - lastitem->getUUID(), - LLString("Texture: ") + lastitem->getName(), - show_keep_discard, - LLUUID::null, - FALSE); - break; - default: - break; - } - - LLFloater::setFloaterHost(NULL); - if (multi_previewp) - { - multi_previewp->open(); - } - - LLInventoryView* view = LLInventoryView::getActiveInventory(); - if(view) - { - LLUUID lost_and_found_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_LOST_AND_FOUND); - BOOL inventory_has_focus = gFocusMgr.childHasKeyboardFocus(view); - BOOL user_is_away = gAwayTimer.getStarted(); - - // don't select lost and found items if an active user is working in the inventory - if (!gInventory.isObjectDescendentOf(lastitem->getUUID(), lost_and_found_id) || - !inventory_has_focus || - user_is_away) - { - LLUICtrl* focus_ctrl = gFocusMgr.getKeyboardFocus(); - LLFocusMgr::FocusLostCallback callback = gFocusMgr.getFocusCallback(); - view->getPanel()->setSelection(lastitem->getUUID(), TAKE_FOCUS_NO); - // HACK to open inventory offers that are - // accepted. This information really needs to - // flow through the instant messages and - // inventory restore keyboard focus - gFocusMgr.setKeyboardFocus(focus_ctrl, callback); - } - } - } - } return true; } @@ -3452,6 +3375,43 @@ void LLInventoryExistenceObserver::changed(U32 mask) } } +void LLInventoryAddedObserver::changed(U32 mask) +{ + if(!(mask & LLInventoryObserver::ADD)) + { + return; + } + + // *HACK: If this was in response to a packet off + // the network, figure out which item was updated. + // Code from Gigs Taggert, sin allowed by JC. + LLMessageSystem* msg = gMessageSystem; + const char* msg_name = msg->getMessageName(); + if (!msg_name) return; + + // We only want newly created inventory items. JC + if ( strcmp(msg_name, "UpdateCreateInventoryItem") ) + { + return; + } + + LLPointer titem = new LLViewerInventoryItem; + S32 num_blocks = msg->getNumberOfBlocksFast(_PREHASH_InventoryData); + for(S32 i = 0; i < num_blocks; ++i) + { + titem->unpackMessage(msg, _PREHASH_InventoryData, i); + if (!(titem->getUUID().isNull())) + { + //we don't do anything with null keys + mAdded.push_back(titem->getUUID()); + } + } + if (!mAdded.empty()) + { + done(); + } +} + LLInventoryTransactionObserver::LLInventoryTransactionObserver( const LLTransactionID& transaction_id) : mTransactionID(transaction_id) -- cgit v1.1