From 2da8eb43d57ae6876f9955386f604f2c56849211 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 14 Aug 2009 14:40:43 -0400 Subject: Wrap a subset of the LLFloaterReg API with an event API --- indra/llui/CMakeLists.txt | 2 ++ indra/llui/llfloaterreg.cpp | 3 ++ indra/llui/llfloaterreg.h | 1 + indra/llui/llfloaterreglistener.cpp | 60 +++++++++++++++++++++++++++++++++++++ indra/llui/llfloaterreglistener.h | 34 +++++++++++++++++++++ 5 files changed, 100 insertions(+) create mode 100644 indra/llui/llfloaterreglistener.cpp create mode 100644 indra/llui/llfloaterreglistener.h (limited to 'indra/llui') diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index 269c02263d..49230833f8 100644 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -40,6 +40,7 @@ set(llui_SOURCE_FILES llfiltereditor.cpp llfloater.cpp llfloaterreg.cpp + llfloaterreglistener.cpp llflyoutbutton.cpp llfocusmgr.cpp llfunctorregistry.cpp @@ -115,6 +116,7 @@ set(llui_HEADER_FILES llfiltereditor.h llfloater.h llfloaterreg.h + llfloaterreglistener.h llflyoutbutton.h llfocusmgr.h llfunctorregistry.h diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index a63b1b085c..8617ba940e 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -36,6 +36,7 @@ #include "llfloater.h" #include "llmultifloater.h" +#include "llfloaterreglistener.h" //******************************************************* @@ -45,6 +46,8 @@ LLFloaterReg::instance_map_t LLFloaterReg::sInstanceMap; LLFloaterReg::build_map_t LLFloaterReg::sBuildMap; std::map LLFloaterReg::sGroupMap; +static LLFloaterRegListener sFloaterRegListener("LLFloaterReg"); + //******************************************************* //static diff --git a/indra/llui/llfloaterreg.h b/indra/llui/llfloaterreg.h index 7edac43c96..451bd1dbe3 100644 --- a/indra/llui/llfloaterreg.h +++ b/indra/llui/llfloaterreg.h @@ -70,6 +70,7 @@ public: typedef std::map build_map_t; private: + friend class LLFloaterRegListener; static instance_list_t sNullInstanceList; static instance_map_t sInstanceMap; static build_map_t sBuildMap; diff --git a/indra/llui/llfloaterreglistener.cpp b/indra/llui/llfloaterreglistener.cpp new file mode 100644 index 0000000000..37708a7cd9 --- /dev/null +++ b/indra/llui/llfloaterreglistener.cpp @@ -0,0 +1,60 @@ +/** + * @file llfloaterreglistener.cpp + * @author Nat Goodspeed + * @date 2009-08-12 + * @brief Implementation for llfloaterreglistener. + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +// Precompiled header +#include "linden_common.h" +// associated header +#include "llfloaterreglistener.h" +// STL headers +// std headers +// external library headers +// other Linden headers +#include "llfloaterreg.h" + +LLFloaterRegListener::LLFloaterRegListener(const std::string& pumpName): + LLDispatchListener(pumpName, "op") +{ + add("getBuildMap", &LLFloaterRegListener::getBuildMap, LLSD().insert("reply", LLSD())); + LLSD requiredName; + requiredName["name"] = LLSD(); + add("showInstance", &LLFloaterRegListener::showInstance, requiredName); + add("hideInstance", &LLFloaterRegListener::hideInstance, requiredName); +} + +void LLFloaterRegListener::getBuildMap(const LLSD& event) const +{ + // Honor the "reqid" convention by echoing event["reqid"] in our reply packet. + LLReqID reqID(event); + LLSD reply(reqID.makeResponse()); + // Build an LLSD map that mirrors sBuildMap. Since we have no good way to + // represent a C++ callable in LLSD, the only part of BuildData we can + // store is the filename. For each LLSD map entry, it would be more + // extensible to store a nested LLSD map containing a single key "file" -- + // but we don't bother, simply storing the string filename instead. + for (LLFloaterReg::build_map_t::const_iterator mi(LLFloaterReg::sBuildMap.begin()), + mend(LLFloaterReg::sBuildMap.end()); + mi != mend; ++mi) + { + reply[mi->first] = mi->second.mFile; + } + // Send the reply to the LLEventPump named in event["reply"]. + LLEventPumps::instance().obtain(event["reply"]).post(reply); +} + +void LLFloaterRegListener::showInstance(const LLSD& event) const +{ + LLFloaterReg::showInstance(event["name"], event["key"], event["focus"]); +} + +void LLFloaterRegListener::hideInstance(const LLSD& event) const +{ + LLFloaterReg::hideInstance(event["name"], event["key"]); +} diff --git a/indra/llui/llfloaterreglistener.h b/indra/llui/llfloaterreglistener.h new file mode 100644 index 0000000000..049389c094 --- /dev/null +++ b/indra/llui/llfloaterreglistener.h @@ -0,0 +1,34 @@ +/** + * @file llfloaterreglistener.h + * @author Nat Goodspeed + * @date 2009-08-12 + * @brief Wrap (subset of) LLFloaterReg API with an event API + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +#if ! defined(LL_LLFLOATERREGLISTENER_H) +#define LL_LLFLOATERREGLISTENER_H + +#include "lleventdispatcher.h" +#include + +class LLSD; + +/// Event API wrapper for LLFloaterReg +class LLFloaterRegListener: public LLDispatchListener +{ +public: + /// As all public LLFloaterReg methods are static, there's no point in + /// binding an LLFloaterReg instance. + LLFloaterRegListener(const std::string& pumpName); + +private: + void getBuildMap(const LLSD& event) const; + void showInstance(const LLSD& event) const; + void hideInstance(const LLSD& event) const; +}; + +#endif /* ! defined(LL_LLFLOATERREGLISTENER_H) */ -- cgit v1.2.3