diff options
Diffstat (limited to 'indra/newview/llavataractions.cpp')
-rw-r--r-- | indra/newview/llavataractions.cpp | 132 |
1 files changed, 96 insertions, 36 deletions
diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp index 1e59e5b805..79b0c63b38 100644 --- a/indra/newview/llavataractions.cpp +++ b/indra/newview/llavataractions.cpp @@ -2,31 +2,25 @@ * @file llavataractions.cpp * @brief Friend-related actions (add, remove, offer teleport, etc) * - * $LicenseInfo:firstyear=2009&license=viewergpl$ - * - * Copyright (c) 2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2009&license=viewerlgpl$ * 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 + * Copyright (C) 2010, Linden Research, Inc. * - * 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 + * 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. * - * 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. + * 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. * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * 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 + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -55,6 +49,7 @@ #include "llfloaterpay.h" #include "llfloaterworldmap.h" #include "llgiveinventory.h" +#include "llinventorybridge.h" #include "llinventorymodel.h" // for gInventory.findCategoryUUIDForType #include "llinventorypanel.h" #include "llimview.h" // for gIMMgr @@ -449,17 +444,27 @@ namespace action_give_inventory } /** - * Checks My Inventory visibility. + * @return active inventory panel, or NULL if there's no such panel */ - static bool is_give_inventory_acceptable() + static LLInventoryPanel* get_active_inventory_panel() { LLInventoryPanel* active_panel = LLInventoryPanel::getActiveInventoryPanel(FALSE); if (!active_panel) { active_panel = get_outfit_editor_inventory_panel(); - if (!active_panel) return false; } + return active_panel; + } + + /** + * Checks My Inventory visibility. + */ + static bool is_give_inventory_acceptable() + { + LLInventoryPanel* active_panel = get_active_inventory_panel(); + if (!active_panel) return false; + // check selection in the panel const uuid_set_t inventory_selected_uuids = active_panel->getRootFolder()->getSelectionList(); if (inventory_selected_uuids.empty()) return false; // nothing selected @@ -549,12 +554,8 @@ namespace action_give_inventory return; } - LLInventoryPanel* active_panel = LLInventoryPanel::getActiveInventoryPanel(FALSE); - if (!active_panel) - { - active_panel = get_outfit_editor_inventory_panel(); - if (!active_panel) return; - } + LLInventoryPanel* active_panel = get_active_inventory_panel(); + if (!active_panel) return; const uuid_set_t inventory_selected_uuids = active_panel->getRootFolder()->getSelectionList(); if (inventory_selected_uuids.empty()) @@ -638,12 +639,8 @@ namespace action_give_inventory llassert(avatar_names.size() == avatar_uuids.size()); - LLInventoryPanel* active_panel = LLInventoryPanel::getActiveInventoryPanel(FALSE); - if (!active_panel) - { - active_panel = get_outfit_editor_inventory_panel(); - if (!active_panel) return; - } + LLInventoryPanel* active_panel = get_active_inventory_panel(); + if (!active_panel) return; const uuid_set_t inventory_selected_uuids = active_panel->getRootFolder()->getSelectionList(); if (inventory_selected_uuids.empty()) @@ -678,6 +675,53 @@ void LLAvatarActions::shareWithAvatars() LLNotificationsUtil::add("ShareNotification"); } + +// static +bool LLAvatarActions::canShareSelectedItems(LLInventoryPanel* inv_panel /* = NULL*/) +{ + using namespace action_give_inventory; + + if (!inv_panel) + { + LLInventoryPanel* active_panel = get_active_inventory_panel(); + if (!active_panel) return false; + inv_panel = active_panel; + } + + // check selection in the panel + LLFolderView* root_folder = inv_panel->getRootFolder(); + const uuid_set_t inventory_selected_uuids = root_folder->getSelectionList(); + if (inventory_selected_uuids.empty()) return false; // nothing selected + + bool can_share = true; + uuid_set_t::const_iterator it = inventory_selected_uuids.begin(); + const uuid_set_t::const_iterator it_end = inventory_selected_uuids.end(); + for (; it != it_end; ++it) + { + LLViewerInventoryCategory* inv_cat = gInventory.getCategory(*it); + // any category can be offered. + if (inv_cat) + { + continue; + } + + // check if inventory item can be given + LLFolderViewItem* item = root_folder->getItemByID(*it); + if (!item) return false; + LLInvFVBridge* bridge = dynamic_cast<LLInvFVBridge*>(item->getListener()); + if (bridge && bridge->canShare()) + { + continue; + } + + // there are neither item nor category in inventory + can_share = false; + break; + } + + return can_share; +} + // static void LLAvatarActions::toggleBlock(const LLUUID& id) { @@ -695,6 +739,7 @@ void LLAvatarActions::toggleBlock(const LLUUID& id) LLMuteList::getInstance()->add(mute); } } + // static bool LLAvatarActions::canOfferTeleport(const LLUUID& id) { @@ -710,6 +755,21 @@ bool LLAvatarActions::canOfferTeleport(const LLUUID& id) return true; } +// static +bool LLAvatarActions::canOfferTeleport(const uuid_vec_t& ids) +{ + bool result = true; + for (uuid_vec_t::const_iterator it = ids.begin(); it != ids.end(); ++it) + { + if(!canOfferTeleport(*it)) + { + result = false; + break; + } + } + return result; +} + void LLAvatarActions::inviteToGroup(const LLUUID& id) { LLFloaterGroupPicker* widget = LLFloaterReg::showTypedInstance<LLFloaterGroupPicker>("group_picker", LLSD(id)); |