diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index b399760f99..59fc003ace 100755 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -33,6 +33,8 @@ include_directories(SYSTEM ) set(llui_SOURCE_FILES + fsregistrarutils.cpp + llaccordionctrl.cpp llaccordionctrltab.cpp llbadge.cpp @@ -137,6 +139,8 @@ set(llui_SOURCE_FILES set(llui_HEADER_FILES CMakeLists.txt + fsregistrarutils.h + llaccordionctrl.h llaccordionctrltab.h llbadge.h diff --git a/indra/llui/fsregistrarutils.cpp b/indra/llui/fsregistrarutils.cpp new file mode 100644 index 0000000000..e158781e39 --- /dev/null +++ b/indra/llui/fsregistrarutils.cpp @@ -0,0 +1,45 @@ +/** + * @file fsregistrarutils.cpp + * @brief Utility class to allow registrars access information from dependent projects + * + * $LicenseInfo:firstyear=2013&license=viewerlgpl$ + * Phoenix Firestorm Viewer Source Code + * Copyright (c) 2013 Ansariel Hiller @ Second Life + * + * 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. + * + * 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. + * + * 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 + * + * The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA + * http://www.firestormviewer.org + * $/LicenseInfo$ + */ + +#include "linden_common.h" +#include "fsregistrarutils.h" + +FSRegistrarUtils::FSRegistrarUtils() : + mEnableCheckFunction(NULL) +{ +} + +bool FSRegistrarUtils::checkIsEnabled(const LLUUID& av_id, EFSRegistrarFunctionActionType action) +{ + if (mEnableCheckFunction) + { + return mEnableCheckFunction(av_id, action); + } + return false; +} + +FSRegistrarUtils gFSRegistrarUtils; diff --git a/indra/llui/fsregistrarutils.h b/indra/llui/fsregistrarutils.h new file mode 100644 index 0000000000..b7fa9ed2f8 --- /dev/null +++ b/indra/llui/fsregistrarutils.h @@ -0,0 +1,62 @@ +/** + * @file fsregistrarutils.h + * @brief Utility class to allow registrars access information from dependent projects + * + * $LicenseInfo:firstyear=2013&license=viewerlgpl$ + * Phoenix Firestorm Viewer Source Code + * Copyright (c) 2013 Ansariel Hiller @ Second Life + * + * 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. + * + * 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. + * + * 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 + * + * The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA + * http://www.firestormviewer.org + * $/LicenseInfo$ + */ + +#ifndef FS_REGISTRARUTILS_H +#define FS_REGISTRARUTILS_H + +enum EFSRegistrarFunctionActionType +{ + FS_RGSTR_ACT_ADD_FRIEND, + FS_RGSTR_ACT_SEND_IM, + FS_RGSTR_ACT_ZOOM_IN, + FS_RGSTR_ACT_OFFER_TELEPORT, + FS_RGSTR_ACT_SHOW_PROFILE, + FS_RGSTR_ACT_TRACK_AVATAR, + FS_RGSTR_ACT_TELEPORT_TO +}; + +class FSRegistrarUtils +{ +public: + FSRegistrarUtils::FSRegistrarUtils(); + FSRegistrarUtils::~FSRegistrarUtils() { }; + + typedef boost::function enable_check_function_t; + void setEnableCheckFunction(const enable_check_function_t& func) + { + mEnableCheckFunction = func; + } + + bool checkIsEnabled(const LLUUID& av_id, EFSRegistrarFunctionActionType action); + +private: + enable_check_function_t mEnableCheckFunction; +}; + +extern FSRegistrarUtils gFSRegistrarUtils; + +#endif // FS_REGISTRARUTILS_H diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index a3351e7b50..68ebea44e5 100755 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -61,6 +61,8 @@ #include +#include "fsregistrarutils.h" + static LLDefaultChildRegistry::Register r("scroll_list"); // local structures & classes. @@ -1914,6 +1916,17 @@ BOOL LLScrollListCtrl::handleRightMouseDown(S32 x, S32 y, MASK mask) registrar.add("FS.TrackAvatar", boost::bind(&LLUrlAction::executeSLURL, "secondlife:///app/firestorm/" + id + "/track")); // Additional convenience options + // Add enable checks for menu items + LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; + enable_registrar.add("Url.EnableShowProfile", boost::bind(&FSRegistrarUtils::checkIsEnabled, gFSRegistrarUtils, uuid, FS_RGSTR_ACT_SHOW_PROFILE)); + enable_registrar.add("Url.EnableAddFriend", boost::bind(&FSRegistrarUtils::checkIsEnabled, gFSRegistrarUtils, uuid, FS_RGSTR_ACT_ADD_FRIEND)); + enable_registrar.add("Url.EnableSendIM", boost::bind(&FSRegistrarUtils::checkIsEnabled, gFSRegistrarUtils, uuid, FS_RGSTR_ACT_SEND_IM)); + enable_registrar.add("FS.EnableZoomIn", boost::bind(&FSRegistrarUtils::checkIsEnabled, gFSRegistrarUtils, uuid, FS_RGSTR_ACT_ZOOM_IN)); + enable_registrar.add("FS.EnableOfferTeleport", boost::bind(&FSRegistrarUtils::checkIsEnabled, gFSRegistrarUtils, uuid, FS_RGSTR_ACT_OFFER_TELEPORT)); + enable_registrar.add("FS.EnableTrackAvatar", boost::bind(&FSRegistrarUtils::checkIsEnabled, gFSRegistrarUtils, uuid, FS_RGSTR_ACT_TRACK_AVATAR)); + enable_registrar.add("FS.EnableTeleportToTarget", boost::bind(&FSRegistrarUtils::checkIsEnabled, gFSRegistrarUtils, uuid, FS_RGSTR_ACT_TELEPORT_TO)); + // + // create the context menu from the XUI file and display it std::string menu_name = is_group ? "menu_url_group.xml" : "menu_url_agent.xml"; delete mPopupMenu; diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index b06e98d8c6..ac71fce835 100755 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -44,6 +44,8 @@ #include "llwindow.h" #include +#include "fsregistrarutils.h" + const F32 CURSOR_FLASH_DELAY = 1.0f; // in seconds const S32 CURSOR_THICKNESS = 2; const F32 TRIPLE_CLICK_INTERVAL = 0.3f; // delay between double and triple click. @@ -2010,11 +2012,23 @@ void LLTextBase::createUrlContextMenu(S32 x, S32 y, const std::string &in_url) registrar.add("Url.SendIM", boost::bind(&LLUrlAction::sendIM, url)); // // Additional convenience options - std::string target_id = LLUrlAction::extractUuidFromSlurl(url).asString(); - registrar.add("FS.ZoomIn", boost::bind(&LLUrlAction::executeSLURL, "secondlife:///app/firestorm/" + target_id + "/zoom")); - registrar.add("FS.TeleportToTarget", boost::bind(&LLUrlAction::executeSLURL, "secondlife:///app/firestorm/" + target_id + "/teleportto")); - registrar.add("FS.OfferTeleport", boost::bind(&LLUrlAction::executeSLURL, "secondlife:///app/firestorm/" + target_id + "/offerteleport")); - registrar.add("FS.TrackAvatar", boost::bind(&LLUrlAction::executeSLURL, "secondlife:///app/firestorm/" + target_id + "/track")); + std::string target_id_str = LLUrlAction::extractUuidFromSlurl(url).asString(); + registrar.add("FS.ZoomIn", boost::bind(&LLUrlAction::executeSLURL, "secondlife:///app/firestorm/" + target_id_str + "/zoom")); + registrar.add("FS.TeleportToTarget", boost::bind(&LLUrlAction::executeSLURL, "secondlife:///app/firestorm/" + target_id_str + "/teleportto")); + registrar.add("FS.OfferTeleport", boost::bind(&LLUrlAction::executeSLURL, "secondlife:///app/firestorm/" + target_id_str + "/offerteleport")); + registrar.add("FS.TrackAvatar", boost::bind(&LLUrlAction::executeSLURL, "secondlife:///app/firestorm/" + target_id_str + "/track")); + // + + // Add enable checks for menu items + LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; + LLUUID target_id(target_id_str); + enable_registrar.add("Url.EnableShowProfile", boost::bind(&FSRegistrarUtils::checkIsEnabled, gFSRegistrarUtils, target_id, FS_RGSTR_ACT_SHOW_PROFILE)); + enable_registrar.add("Url.EnableAddFriend", boost::bind(&FSRegistrarUtils::checkIsEnabled, gFSRegistrarUtils, target_id, FS_RGSTR_ACT_ADD_FRIEND)); + enable_registrar.add("Url.EnableSendIM", boost::bind(&FSRegistrarUtils::checkIsEnabled, gFSRegistrarUtils, target_id, FS_RGSTR_ACT_SEND_IM)); + enable_registrar.add("FS.EnableZoomIn", boost::bind(&FSRegistrarUtils::checkIsEnabled, gFSRegistrarUtils, target_id, FS_RGSTR_ACT_ZOOM_IN)); + enable_registrar.add("FS.EnableOfferTeleport", boost::bind(&FSRegistrarUtils::checkIsEnabled, gFSRegistrarUtils, target_id, FS_RGSTR_ACT_OFFER_TELEPORT)); + enable_registrar.add("FS.EnableTrackAvatar", boost::bind(&FSRegistrarUtils::checkIsEnabled, gFSRegistrarUtils, target_id, FS_RGSTR_ACT_TRACK_AVATAR)); + enable_registrar.add("FS.EnableTeleportToTarget", boost::bind(&FSRegistrarUtils::checkIsEnabled, gFSRegistrarUtils, target_id, FS_RGSTR_ACT_TELEPORT_TO)); // // create and return the context menu from the XUI file diff --git a/indra/newview/fscommon.cpp b/indra/newview/fscommon.cpp index f5e295ac58..98c506f35a 100644 --- a/indra/newview/fscommon.cpp +++ b/indra/newview/fscommon.cpp @@ -28,17 +28,21 @@ #include "llviewerprecompiledheaders.h" #include "fscommon.h" +#include "fsradar.h" #include "llagent.h" +#include "llavataractions.h" #include "llavatarnamecache.h" #include "llfloatersidepanelcontainer.h" -#include "llnotificationmanager.h" #include "llinventorymodel.h" +#include "llnotificationmanager.h" +#include "llnotificationsutil.h" // reportToNearbyChat #include "llpanel.h" #include "lltooldraganddrop.h" #include "llviewerinventory.h" #include "llviewernetwork.h" #include "llviewerregion.h" -#include "llnotificationsutil.h" // reportToNearbyChat +#include "rlvactions.h" +#include "rlvhandler.h" #include #include @@ -51,6 +55,7 @@ static const std::string LL_PRODUCTENGINE = "ProductEngine"; static const std::string LL_SCOUT = "Scout"; static const std::string LL_TESTER = "Tester"; + S32 FSCommon::sObjectAddMsg = 0; void reportToNearbyChat(const std::string& message) @@ -283,3 +288,41 @@ bool FSCommon::isLinden(const LLUUID& av_id) last_name == LL_SCOUT || last_name == LL_TESTER); } + + +bool FSCommon::checkIsActionEnabled(const LLUUID& av_id, EFSRegistrarFunctionActionType action) +{ + bool isSelf = (av_id == gAgentID); + + if (action == FS_RGSTR_ACT_ADD_FRIEND) + { + return (!isSelf && !LLAvatarActions::isFriend(av_id)); + } + else if (action == FS_RGSTR_ACT_SEND_IM) + { + return (!isSelf && RlvActions::canStartIM(av_id)); + } + else if (action == FS_RGSTR_ACT_ZOOM_IN) + { + return (!isSelf && LLAvatarActions::canZoomIn(av_id)); + } + else if (action == FS_RGSTR_ACT_OFFER_TELEPORT) + { + return (!isSelf && LLAvatarActions::canOfferTeleport(av_id)); + } + else if (action == FS_RGSTR_ACT_SHOW_PROFILE) + { + return (isSelf || !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)); + } + else if (action == FS_RGSTR_ACT_TRACK_AVATAR) + { + return (!isSelf && FSRadar::getInstance()->getEntry(av_id) != NULL); + } + else if (action == FS_RGSTR_ACT_TELEPORT_TO) + { + return (!isSelf && FSRadar::getInstance()->getEntry(av_id) != NULL); + } + + return false; +} + diff --git a/indra/newview/fscommon.h b/indra/newview/fscommon.h index 93e2e65943..9f3adf20f1 100644 --- a/indra/newview/fscommon.h +++ b/indra/newview/fscommon.h @@ -28,6 +28,7 @@ #ifndef FS_COMMON_H #define FS_COMMON_H +#include "fsregistrarutils.h" #include "llchat.h" #include "llpanelpeople.h" #include "llviewerobject.h" @@ -73,6 +74,8 @@ namespace FSCommon * keep track of ObjectAdd messages sent to the similular. */ extern S32 sObjectAddMsg; + + bool checkIsActionEnabled(const LLUUID& av_id, EFSRegistrarFunctionActionType); }; #endif // FS_COMMON_H diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 121326954d..1a0b6fcffe 100755 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -225,6 +225,7 @@ #include "streamtitledisplay.h" #include "fscommon.h" #include "tea.h" +#include "fsregistrarutils.h" // // exported globals @@ -1740,6 +1741,9 @@ LLWorld::getInstance()->addRegion(gFirstSimHandle, gFirstSim, first_sim_size_x, llinfos << "Radar initialized" << llendl; // + // Register check function for registrar enable checks + gFSRegistrarUtils.setEnableCheckFunction(boost::bind(&FSCommon::checkIsActionEnabled, _1, _2)); + // fsdata support FSData::instance().addAgents(); // diff --git a/indra/newview/skins/default/xui/en/menu_url_agent.xml b/indra/newview/skins/default/xui/en/menu_url_agent.xml index fe2ca00742..7d890c5d8a 100755 --- a/indra/newview/skins/default/xui/en/menu_url_agent.xml +++ b/indra/newview/skins/default/xui/en/menu_url_agent.xml @@ -11,6 +11,8 @@ function="Url.Execute" /> --> + + + + + + +