summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2009-06-24 01:54:57 +0000
committerNat Goodspeed <nat@lindenlab.com>2009-06-24 01:54:57 +0000
commitda46eb9e7e0f6e069e7fc06176849d213876bfe3 (patch)
tree040ccf936d9dfa2ea8af4d6eee2013cf4858b198 /indra/newview
parentad1ecb126bfc19dc7c32fb87e82a1fe45782413f (diff)
DEV-31980: Extend LLEventDispatcher to handle const as well as non-const
methods. Introduce LLAppViewerListener based on LLDispatchListener, instantiate a static one in llappviewer.cpp. Initial implementation only supports ["op"] == "requestQuit".
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/CMakeLists.txt2
-rw-r--r--indra/newview/llappviewer.cpp3
-rw-r--r--indra/newview/llappviewerlistener.cpp33
-rw-r--r--indra/newview/llappviewerlistener.h34
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) */