diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index a53a38124cb41d2dae783d0be4e8d2ee76f71258..e2a39d89e4b8e166383439a999f1781f2300ee8b 100755 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -180,6 +180,7 @@ LLTextBase::Params::Params() LLTextBase::LLTextBase(const LLTextBase::Params &p) : LLUICtrl(p, LLTextViewModelPtr(new LLTextViewModel)), mURLClickSignal(NULL), + mIsFriendSignal(NULL), mMaxTextByteLength( p.max_text_length ), mFont(p.font), mFontShadow(p.font_shadow), @@ -1943,6 +1944,7 @@ void LLTextBase::createUrlContextMenu(S32 x, S32 y, const std::string &in_url) registrar.add("Url.Teleport", boost::bind(&LLUrlAction::teleportToLocation, url)); registrar.add("Url.ShowProfile", boost::bind(&LLUrlAction::showProfile, url)); registrar.add("Url.AddFriend", boost::bind(&LLUrlAction::addFriend, url)); + registrar.add("Url.RemoveFriend", boost::bind(&LLUrlAction::removeFriend, url)); registrar.add("Url.SendIM", boost::bind(&LLUrlAction::sendIM, url)); registrar.add("Url.ShowOnMap", boost::bind(&LLUrlAction::showLocationOnMap, url)); registrar.add("Url.CopyLabel", boost::bind(&LLUrlAction::copyLabelToClipboard, url)); @@ -1952,6 +1954,19 @@ void LLTextBase::createUrlContextMenu(S32 x, S32 y, const std::string &in_url) delete mPopupMenu; mPopupMenu = LLUICtrlFactory::getInstance()->createFromFile<LLContextMenu>(xui_file, LLMenuGL::sMenuContainer, LLMenuHolderGL::child_registry_t::instance()); + if (mIsFriendSignal) + { + bool isFriend = (*mIsFriendSignal)(LLUUID(LLUrlAction::getUserID(url))); + LLView* addFriendButton = mPopupMenu->getChild<LLView>("add_friend"); + LLView* removeFriendButton = mPopupMenu->getChild<LLView>("remove_friend"); + + if (addFriendButton && removeFriendButton) + { + addFriendButton->setEnabled(!isFriend); + removeFriendButton->setEnabled(isFriend); + } + } + if (mPopupMenu) { mPopupMenu->show(x, y); @@ -2932,6 +2947,15 @@ boost::signals2::connection LLTextBase::setURLClickedCallback(const commit_signa return mURLClickSignal->connect(cb); } +boost::signals2::connection LLTextBase::setIsFriendCallback(const is_friend_signal_t::slot_type& cb) +{ + if (!mIsFriendSignal) + { + mIsFriendSignal = new is_friend_signal_t(); + } + return mIsFriendSignal->connect(cb); +} + // // LLTextSegment // diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index 2fb58d468aa10e8a64b0b1ffa59af0306acb2061..a74e97cac836787d086301241233eecadc224f66 100755 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -258,6 +258,8 @@ class LLTextBase friend class LLNormalTextSegment; friend class LLUICtrlFactory; + typedef boost::signals2::signal<bool (const LLUUID& user_id)> is_friend_signal_t; + struct LineSpacingParams : public LLInitParam::ChoiceBlock<LineSpacingParams> { Alternative<F32> multiple; @@ -434,6 +436,7 @@ class LLTextBase virtual void appendImageSegment(const LLStyle::Params& style_params); virtual void appendWidget(const LLInlineViewSegment::Params& params, const std::string& text, bool allow_undo); boost::signals2::connection setURLClickedCallback(const commit_signal_t::slot_type& cb); + boost::signals2::connection setIsFriendCallback(const is_friend_signal_t::slot_type& cb); void setWordWrap(bool wrap); LLScrollContainer* getScrollContainer() const { return mScroller; } @@ -648,6 +651,9 @@ class LLTextBase // Fired when a URL link is clicked commit_signal_t* mURLClickSignal; + // Used to check if user with given ID is avatar's friend + is_friend_signal_t* mIsFriendSignal; + LLUIString mLabel; // text label that is visible when no user text provided }; diff --git a/indra/llui/llurlaction.cpp b/indra/llui/llurlaction.cpp index f51aeaec1315b56e1fa4c560cd4fc4a6305ce201..cf707d87dc30cc839e2a4e9b2314fa1cb159bc03 100755 --- a/indra/llui/llurlaction.cpp +++ b/indra/llui/llurlaction.cpp @@ -188,3 +188,11 @@ void LLUrlAction::addFriend(std::string url) } } +void LLUrlAction::removeFriend(std::string url) +{ + std::string id_str = getUserID(url); + if (LLUUID::validate(id_str)) + { + executeSLURL("secondlife:///app/agent/" + id_str + "/removefriend"); + } +} diff --git a/indra/llui/llurlaction.h b/indra/llui/llurlaction.h index e31cd71a20769acd176ab616a3ce37160a93c6d9..65283394a0ae11b500831cff72b8d6e169297e02 100755 --- a/indra/llui/llurlaction.h +++ b/indra/llui/llurlaction.h @@ -79,6 +79,7 @@ class LLUrlAction static std::string getUserID(std::string url); static void sendIM(std::string url); static void addFriend(std::string url); + static void LLUrlAction::removeFriend(std::string url); /// specify the callbacks to enable this class's functionality typedef boost::function<void (const std::string&)> url_callback_t; diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp index 99ee6888889be5b03cfb9558a2012f9bf704d8ad..b1cc502c4bbf881222d58aed55080d55c0b1ff5f 100755 --- a/indra/llui/llurlentry.cpp +++ b/indra/llui/llurlentry.cpp @@ -504,6 +504,10 @@ std::string localize_slapp_label(const std::string& url, const std::string& full { return LLTrans::getString("SLappAgentRequestFriend") + " " + full_name; } + if (LLStringUtil::endsWith(url, "/removefriend")) + { + return LLTrans::getString("SLappAgentRemoveFriend") + " " + full_name; + } return full_name; } diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp index 0f138873ac8cec543dbc16078ef48098af611934..af3c6eff1169323a9dfe93d24aee41849024d6e4 100755 --- a/indra/newview/llchathistory.cpp +++ b/indra/newview/llchathistory.cpp @@ -628,6 +628,7 @@ LLChatHistory::LLChatHistory(const LLChatHistory::Params& p) editor_params.enabled = false; // read only editor_params.show_context_menu = "true"; mEditor = LLUICtrlFactory::create<LLTextEditor>(editor_params, this); + mEditor->setIsFriendCallback(LLAvatarActions::isFriend); } LLSD LLChatHistory::getValue() const diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index e2e70067737035f532ae343562829e84a3361e7d..3b95b4647679ad0e2ff00914d9d04e6adce2f208 100755 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -137,6 +137,12 @@ class LLAgentHandler : public LLCommandHandler return true; } + if (verb == "removefriend") + { + LLAvatarActions::removeFriendDialog(avatar_id); + return true; + } + if (verb == "mute") { if (! LLAvatarActions::isBlocked(avatar_id)) 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 7cd56f257a82808d1a31f4c978c618c6bd78a218..e8b6116026a90669a877477e5486ef19503f0963 100755 --- a/indra/newview/skins/default/xui/en/menu_url_agent.xml +++ b/indra/newview/skins/default/xui/en/menu_url_agent.xml @@ -21,8 +21,15 @@ layout="topleft" name="add_friend"> <menu_item_call.on_click - function="Url.AddFriend" /> + function="Url.AddFriend" /> </menu_item_call> + <menu_item_call + label="Remove Friend..." + layout="topleft" + name="remove_friend"> + <menu_item_call.on_click + function="Url.RemoveFriend" /> + </menu_item_call> <menu_item_separator layout="topleft" /> <menu_item_call diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index 3b57ff5fd67e8da54edbdfa61b4b62c4a49aa2cb..521aed698a960dba7fa8aa47d99a83fea8f7bbc0 100755 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -209,7 +209,8 @@ Please try logging in again in a minute.</string> <string name="SLappAgentIM">IM</string> <string name="SLappAgentPay">Pay</string> <string name="SLappAgentOfferTeleport">Offer Teleport to </string> - <string name="SLappAgentRequestFriend">Friend Request </string> + <string name="SLappAgentRequestFriend">Friend Request</string> + <string name="SLappAgentRemoveFriend">Friend Removal</string> <!-- ButtonToolTips, llfloater.cpp --> <string name="BUTTON_CLOSE_DARWIN">Close (⌘W)</string>