From 7c34cd8eb670ad559f4d1af58296ae57578c8e47 Mon Sep 17 00:00:00 2001 From: Lynx Linden Date: Fri, 11 Dec 2009 20:14:23 +0000 Subject: EXT-3408: Added support for secondlife:///app/classified SLurls I added a handler for this SLurl type that displays the classifieds details in the side tray. In order to do this, you have to open the profile of the classified's creator first. Which means that I have to ask the server for the classified's description in order to get the creator id. This is done with an LLAvatarPropertiesObserver observer. One complication here is that this observer takes the avatar id as a parameter, but we don't know that (that's what we're trying to find out) - so I made it possible to pass in a null avatar id - it's only used to filter out non-interested observers in the notifyObserver() call. --- indra/newview/llpanelpicks.cpp | 99 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) (limited to 'indra/newview/llpanelpicks.cpp') diff --git a/indra/newview/llpanelpicks.cpp b/indra/newview/llpanelpicks.cpp index 59a68bc12d..7d21867efc 100644 --- a/indra/newview/llpanelpicks.cpp +++ b/indra/newview/llpanelpicks.cpp @@ -37,6 +37,7 @@ #include "llagent.h" #include "llagentpicksinfo.h" #include "llavatarconstants.h" +#include "llcommandhandler.h" #include "llflatlistview.h" #include "llfloaterreg.h" #include "llfloaterworldmap.h" @@ -55,6 +56,8 @@ #include "llpanelprofile.h" #include "llpanelpick.h" #include "llpanelclassified.h" +#include "llpanelprofileview.h" +#include "llsidetray.h" static const std::string XML_BTN_NEW = "new_btn"; static const std::string XML_BTN_DELETE = "trash_btn"; @@ -72,6 +75,83 @@ static const std::string CLASSIFIED_NAME("classified_name"); static LLRegisterPanelClassWrapper t_panel_picks("panel_picks"); +class LLClassifiedHandler : + public LLCommandHandler, + public LLAvatarPropertiesObserver +{ +public: + // throttle calls from untrusted browsers + LLClassifiedHandler() : LLCommandHandler("classified", UNTRUSTED_THROTTLE) {} + + std::set mClassifiedIds; + + bool handle(const LLSD& params, const LLSD& query_map, LLMediaCtrl* web) + { + if (params.size() < 2) + { + return false; + } + + // get the ID for the classified + LLUUID classified_id; + if (!classified_id.set(params[0], FALSE)) + { + return false; + } + + // show the classified in the side tray. + // need to ask the server for more info first though... + const std::string verb = params[1].asString(); + if (verb == "about") + { + mClassifiedIds.insert(classified_id); + LLAvatarPropertiesProcessor::getInstance()->addObserver(LLUUID(), this); + LLAvatarPropertiesProcessor::getInstance()->sendClassifiedInfoRequest(classified_id); + return true; + } + + return false; + } + + /*virtual*/ void processProperties(void* data, EAvatarProcessorType type) + { + if (APT_CLASSIFIED_INFO != type) + { + return; + } + + // is this the classified that we asked for? + LLAvatarClassifiedInfo* c_info = static_cast(data); + if (!c_info || mClassifiedIds.find(c_info->classified_id) == mClassifiedIds.end()) + { + return; + } + + // open the people profile page for the classified's owner + LLSD params; + params["id"] = c_info->creator_id; + params["classified"] = c_info->classified_id; + params["open_tab_name"] = "panel_profile"; + LLPanelProfileView *profile = dynamic_cast(LLSideTray::getInstance()->showPanel("panel_profile_view", params)); + + // then open the classified panel on this user's profile panel + if (profile) + { + LLPanelPicks* panel_picks = profile->getChild("panel_picks"); + if (panel_picks) + { + panel_picks->openClassifiedInfo(c_info); + } + } + + // remove our observer now that we're done + mClassifiedIds.erase(c_info->classified_id); + LLAvatarPropertiesProcessor::getInstance()->removeObserver(LLUUID(), this); + } + +}; +LLClassifiedHandler gClassifiedHandler; + ////////////////////////////////////////////////////////////////////////// /** @@ -624,6 +704,25 @@ void LLPanelPicks::openClassifiedInfo() getProfilePanel()->openPanel(mPanelClassifiedInfo, params); } +void LLPanelPicks::openClassifiedInfo(LLAvatarClassifiedInfo *c_info) +{ + if (! c_info) + { + return; + } + + createClassifiedInfoPanel(); + + LLSD params; + params["classified_id"] = c_info->classified_id; + params["avatar_id"] = c_info->creator_id; + params["snapshot_id"] = c_info->snapshot_id; + params["name"] = c_info->name; + params["desc"] = c_info->description; + + getProfilePanel()->openPanel(mPanelClassifiedInfo, params); +} + void LLPanelPicks::showAccordion(const std::string& name, bool show) { LLAccordionCtrlTab* tab = getChild(name); -- cgit v1.2.3