diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/newview/llappviewer.cpp | 3 | ||||
-rw-r--r-- | indra/newview/llappviewerlistener.cpp | 33 | ||||
-rw-r--r-- | indra/newview/llappviewerlistener.h | 34 |
4 files changed, 72 insertions, 0 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 5d79dfbc3e..29031418b8 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -73,6 +73,7 @@ set(viewer_SOURCE_FILES llagentpilot.cpp llanimstatelabels.cpp llappviewer.cpp + llappviewerlistener.cpp llassetuploadresponders.cpp llassetuploadqueue.cpp llaudiosourcevo.cpp @@ -468,6 +469,7 @@ set(viewer_HEADER_FILES llanimstatelabels.h llappearance.h llappviewer.h + llappviewerlistener.h llassetuploadresponders.h llassetuploadqueue.h llaudiosourcevo.h diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 455e987da0..a3b41b4ace 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -177,7 +177,10 @@ //---------------------------------------------------------------------------- // llviewernetwork.h #include "llviewernetwork.h" +// define a self-registering event API object +#include "llappviewerlistener.h" +static LLAppViewerListener sAppViewerListener("LLAppViewer", LLAppViewer::instance()); ////// Windows-specific includes to the bottom - nasty defines in these pollute the preprocessor // diff --git a/indra/newview/llappviewerlistener.cpp b/indra/newview/llappviewerlistener.cpp new file mode 100644 index 0000000000..a8c98b17a7 --- /dev/null +++ b/indra/newview/llappviewerlistener.cpp @@ -0,0 +1,33 @@ +/** + * @file llappviewerlistener.cpp + * @author Nat Goodspeed + * @date 2009-06-23 + * @brief Implementation for llappviewerlistener. + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +// Precompiled header +#include "llviewerprecompiledheaders.h" +// associated header +#include "llappviewerlistener.h" +// STL headers +// std headers +// external library headers +// other Linden headers +#include "llappviewer.h" + +LLAppViewerListener::LLAppViewerListener(const std::string& pumpname, LLAppViewer* llappviewer): + LLDispatchListener(pumpname, "op"), + mAppViewer(llappviewer) +{ + // add() every method we want to be able to invoke via this event API. + add("requestQuit", &LLAppViewerListener::requestQuit); +} + +void LLAppViewerListener::requestQuit(const LLSD& event) const +{ + mAppViewer->requestQuit(); +} diff --git a/indra/newview/llappviewerlistener.h b/indra/newview/llappviewerlistener.h new file mode 100644 index 0000000000..ab17dd1d90 --- /dev/null +++ b/indra/newview/llappviewerlistener.h @@ -0,0 +1,34 @@ +/** + * @file llappviewerlistener.h + * @author Nat Goodspeed + * @date 2009-06-18 + * @brief Wrap subset of LLAppViewer API in event API + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +#if ! defined(LL_LLAPPVIEWERLISTENER_H) +#define LL_LLAPPVIEWERLISTENER_H + +#include "lleventdispatcher.h" + +class LLAppViewer; +class LLSD; + +/// Listen on an LLEventPump with specified name for LLAppViewer request events. +class LLAppViewerListener: public LLDispatchListener +{ +public: + /// Specify the pump name on which to listen, and bind the LLAppViewer + /// instance to use (e.g. LLAppViewer::instance()). + LLAppViewerListener(const std::string& pumpname, LLAppViewer* llappviewer); + +private: + void requestQuit(const LLSD& event) const; + + LLAppViewer* mAppViewer; +}; + +#endif /* ! defined(LL_LLAPPVIEWERLISTENER_H) */ |