summaryrefslogtreecommitdiff
path: root/indra/newview/llviewermessage.cpp
diff options
context:
space:
mode:
authorLoren Shih <seraph@lindenlab.com>2010-04-13 16:39:12 -0400
committerLoren Shih <seraph@lindenlab.com>2010-04-13 16:39:12 -0400
commit85f54aca0f9c93b60e89e79b70bdb1d88b3bc5d6 (patch)
treee605c21a938a5ba794df6e43607de8c4a0d81008 /indra/newview/llviewermessage.cpp
parent88782e75462ac3a959a59be97ff50b5fc34aabb9 (diff)
parentd05353fc3997f29bcf55a2fa49936e690b0725de (diff)
automated merge
Diffstat (limited to 'indra/newview/llviewermessage.cpp')
-rw-r--r--indra/newview/llviewermessage.cpp227
1 files changed, 198 insertions, 29 deletions
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 7981de0c20..9542bebde5 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -71,7 +71,6 @@
#include "llnotifications.h"
#include "llnotificationsutil.h"
#include "llpanelgrouplandmoney.h"
-#include "llpanelplaces.h"
#include "llrecentpeople.h"
#include "llscriptfloater.h"
#include "llselectmgr.h"
@@ -692,6 +691,52 @@ bool join_group_response(const LLSD& notification, const LLSD& response)
return false;
}
+
+static void highlight_inventory_items_in_panel(const std::vector<LLUUID>& items, LLInventoryPanel *inventory_panel)
+{
+ if (NULL == inventory_panel) return;
+
+ for (std::vector<LLUUID>::const_iterator item_iter = items.begin();
+ item_iter != items.end();
+ ++item_iter)
+ {
+ const LLUUID& item_id = (*item_iter);
+ if(!highlight_offered_item(item_id))
+ {
+ continue;
+ }
+
+ LLInventoryItem* item = gInventory.getItem(item_id);
+ llassert(item);
+ if (!item) {
+ continue;
+ }
+
+ LL_DEBUGS("Inventory_Move") << "Highlighting inventory item: " << item->getName() << ", " << item_id << LL_ENDL;
+ LLFolderView* fv = inventory_panel->getRootFolder();
+ if (fv)
+ {
+ LLFolderViewItem* fv_item = fv->getItemByID(item_id);
+ if (fv_item)
+ {
+ LLFolderViewItem* fv_folder = fv_item->getParentFolder();
+ if (fv_folder)
+ {
+ // Parent folders can be different in case of 2 consecutive drag and drop
+ // operations when the second one is started before the first one completes.
+ LL_DEBUGS("Inventory_Move") << "Open folder: " << fv_folder->getName() << LL_ENDL;
+ fv_folder->setOpen(TRUE);
+ if (fv_folder->isSelected())
+ {
+ fv->changeSelection(fv_folder, FALSE);
+ }
+ }
+ fv->changeSelection(fv_item, TRUE);
+ }
+ }
+ }
+}
+
static LLNotificationFunctorRegistration jgr_1("JoinGroup", join_group_response);
static LLNotificationFunctorRegistration jgr_2("JoinedTooManyGroupsMember", join_group_response);
static LLNotificationFunctorRegistration jgr_3("JoinGroupCanAfford", join_group_response);
@@ -717,6 +762,108 @@ private:
std::string mFromName;
};
+/**
+ * Class to observe adding of new items moved from the world to user's inventory to select them in inventory.
+ *
+ * We can't create it each time items are moved because "drop" event is sent separately for each
+ * element even while multi-dragging. We have to have the only instance of the observer. See EXT-4347.
+ */
+class LLViewerInventoryMoveFromWorldObserver : public LLInventoryMoveFromWorldObserver
+{
+public:
+ LLViewerInventoryMoveFromWorldObserver()
+ : LLInventoryMoveFromWorldObserver()
+ , mActivePanel(NULL)
+ {
+
+ }
+
+ void setMoveIntoFolderID(const LLUUID& into_folder_uuid) {mMoveIntoFolderID = into_folder_uuid; }
+
+private:
+ /*virtual */void onAssetAdded(const LLUUID& asset_id)
+ {
+ // Store active Inventory panel.
+ mActivePanel = LLInventoryPanel::getActiveInventoryPanel();
+
+ // Store selected items (without destination folder)
+ mSelectedItems.clear();
+ mActivePanel->getRootFolder()->getSelectionList(mSelectedItems);
+ mSelectedItems.erase(mMoveIntoFolderID);
+ }
+
+ /**
+ * Selects added inventory items watched by their Asset UUIDs if selection was not changed since
+ * all items were started to watch (dropped into a folder).
+ */
+ void done()
+ {
+ // if selection is not changed since watch started lets hightlight new items.
+ if (mActivePanel && !isSelectionChanged())
+ {
+ LL_DEBUGS("Inventory_Move") << "Selecting new items..." << LL_ENDL;
+ mActivePanel->clearSelection();
+ highlight_inventory_items_in_panel(mAddedItems, mActivePanel);
+ }
+ }
+
+ /**
+ * Returns true if selected inventory items were changed since moved inventory items were started to watch.
+ */
+ bool isSelectionChanged()
+ {
+ const LLInventoryPanel * const current_active_panel = LLInventoryPanel::getActiveInventoryPanel();
+
+ if (NULL == mActivePanel || current_active_panel != mActivePanel)
+ {
+ return true;
+ }
+
+ // get selected items (without destination folder)
+ selected_items_t selected_items;
+ mActivePanel->getRootFolder()->getSelectionList(selected_items);
+ selected_items.erase(mMoveIntoFolderID);
+
+ // compare stored & current sets of selected items
+ selected_items_t different_items;
+ std::set_symmetric_difference(mSelectedItems.begin(), mSelectedItems.end(),
+ selected_items.begin(), selected_items.end(), std::inserter(different_items, different_items.begin()));
+
+ LL_DEBUGS("Inventory_Move") << "Selected firstly: " << mSelectedItems.size()
+ << ", now: " << selected_items.size() << ", difference: " << different_items.size() << LL_ENDL;
+
+ return different_items.size() > 0;
+ }
+
+ LLInventoryPanel *mActivePanel;
+ typedef std::set<LLUUID> selected_items_t;
+ selected_items_t mSelectedItems;
+
+ /**
+ * UUID of FolderViewFolder into which watched items are moved.
+ *
+ * Destination FolderViewFolder becomes selected while mouse hovering (when dragged items are dropped).
+ *
+ * If mouse is moved out it set unselected and number of selected items is changed
+ * even if selected items in Inventory stay the same.
+ * So, it is used to update stored selection list.
+ *
+ * @see onAssetAdded()
+ * @see isSelectionChanged()
+ */
+ LLUUID mMoveIntoFolderID;
+};
+
+LLViewerInventoryMoveFromWorldObserver* gInventoryMoveObserver = NULL;
+
+void set_dad_inventory_item(LLInventoryItem* inv_item, const LLUUID& into_folder_uuid)
+{
+ start_new_inventory_observer();
+
+ gInventoryMoveObserver->setMoveIntoFolderID(into_folder_uuid);
+ gInventoryMoveObserver->watchAsset(inv_item->getAssetUUID());
+}
+
//unlike the FetchObserver for AgentOffer, we only make one
//instance of the AddedObserver for TaskOffers
//and it never dies. We do this because we don't know the UUID of
@@ -727,6 +874,33 @@ class LLOpenTaskOffer : public LLInventoryAddedObserver
protected:
/*virtual*/ void done()
{
+ for (uuid_vec_t::iterator it = mAdded.begin(); it != mAdded.end();)
+ {
+ const LLUUID& item_uuid = *it;
+ bool was_moved = false;
+ LLInventoryObject* added_object = gInventory.getObject(item_uuid);
+ if (added_object)
+ {
+ // cast to item to get Asset UUID
+ LLInventoryItem* added_item = dynamic_cast<LLInventoryItem*>(added_object);
+ if (added_item)
+ {
+ const LLUUID& asset_uuid = added_item->getAssetUUID();
+ if (gInventoryMoveObserver->isAssetWatched(asset_uuid))
+ {
+ LL_DEBUGS("Inventory_Move") << "Found asset UUID: " << asset_uuid << LL_ENDL;
+ was_moved = true;
+ }
+ }
+ }
+
+ if (was_moved)
+ {
+ it = mAdded.erase(it);
+ }
+ else ++it;
+ }
+
open_inventory_offer(mAdded, "");
mAdded.clear();
}
@@ -755,6 +929,13 @@ void start_new_inventory_observer()
gNewInventoryObserver = new LLOpenTaskOffer;
gInventory.addObserver(gNewInventoryObserver);
}
+
+ if (!gInventoryMoveObserver) //inventory move from the world observer
+ {
+ // Observer is deleted by gInventory
+ gInventoryMoveObserver = new LLViewerInventoryMoveFromWorldObserver;
+ gInventory.addObserver(gInventoryMoveObserver);
+ }
}
class LLDiscardAgentOffer : public LLInventoryFetchItemsObserver
@@ -920,9 +1101,12 @@ void open_inventory_offer(const uuid_vec_t& items, const std::string& from_name)
}
else if("group_offer" == from_name)
{
- // do not open inventory when we open group notice attachment because
- // we already opened landmark info panel
// "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;
}
@@ -933,28 +1117,6 @@ void open_inventory_offer(const uuid_vec_t& items, const std::string& from_name)
args["LANDMARK_NAME"] = item->getName();
args["FOLDER_NAME"] = std::string(parent_folder ? parent_folder->getName() : "unknown");
LLNotificationsUtil::add("LandmarkCreated", args);
- // Created landmark is passed to Places panel to allow its editing. In fact panel should be already displayed.
- // If the panel is closed we don't reopen it until created landmark is loaded.
- //TODO*:: dserduk(7/12/09) remove LLPanelPlaces dependency from here
- LLPanelPlaces *places_panel = dynamic_cast<LLPanelPlaces*>(LLSideTray::getInstance()->getPanel("panel_places"));
- if (places_panel)
- {
- // Landmark creation handling is moved to LLPanelPlaces::showAddedLandmarkInfo()
- // TODO* LLPanelPlaces dependency is going to be removed. See EXT-4347.
- //if("create_landmark" == places_panel->getPlaceInfoType() && !places_panel->getItem())
- //{
- // places_panel->setItem(item);
- //}
- //else
- // we are opening a group notice attachment
- if("create_landmark" != places_panel->getPlaceInfoType())
- {
- LLSD args;
- args["type"] = "landmark";
- args["id"] = item_id;
- LLSideTray::getInstance()->showPanel("panel_places", args);
- }
- }
}
}
break;
@@ -2224,10 +2386,13 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
chat.mFromID = from_id ^ gAgent.getSessionID();
}
+ chat.mSourceType = CHAT_SOURCE_OBJECT;
+
if(SYSTEM_FROM == name)
{
// System's UUID is NULL (fixes EXT-4766)
chat.mFromID = LLUUID::null;
+ chat.mSourceType = CHAT_SOURCE_SYSTEM;
}
LLSD query_string;
@@ -2244,7 +2409,6 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
chat.mURL = link.str();
chat.mText = message;
- chat.mSourceType = CHAT_SOURCE_OBJECT;
// Note: lie to Nearby Chat, pretending that this is NOT an IM, because
// IMs from obejcts don't open IM sessions.
@@ -4548,11 +4712,12 @@ void process_money_balance_reply( LLMessageSystem* msg, void** )
if(boost::regex_match(desc, matches, expr))
{
// Name of full localizable notification string
- // there are three types of this string- with name of receiver and reason of payment,
- // without name and without reason (but not simultaneously)
+ // there are four types of this string- with name of receiver and reason of payment,
+ // without name and without reason (both may also be absent simultaneously).
// example of string without name - You paid L$100 to create a group.
// example of string without reason - You paid Smdby Linden L$100.
// example of string with reason and name - You paid Smbdy Linden L$100 for a land access pass.
+ // example of string with no info - You paid L$50.
std::string line = "you_paid_ldollars_no_name";
// arguments of string which will be in notification
@@ -4573,7 +4738,7 @@ void process_money_balance_reply( LLMessageSystem* msg, void** )
std::string reason = std::string(matches[3]);
if (reason.empty())
{
- line = "you_paid_ldollars_no_reason";
+ line = name.empty() ? "you_paid_ldollars_no_info" : "you_paid_ldollars_no_reason";
}
else
{
@@ -4617,6 +4782,10 @@ bool handle_special_notification_callback(const LLSD& notification, const LLSD&
gSavedSettings.setU32("PreferredMaturity", preferredMaturity);
gAgent.sendMaturityPreferenceToServer(preferredMaturity);
+ // notify user that the maturity preference has been changed
+ LLSD args;
+ args["RATING"] = LLViewerRegion::accessToString(preferredMaturity);
+ LLNotificationsUtil::add("PreferredMaturityChanged", args);
}
return false;