From b2591ca63c498ab606bf595e0b2e729e76caea24 Mon Sep 17 00:00:00 2001
From: dolphin <dolphin@lindenlab.com>
Date: Tue, 18 Mar 2014 14:12:22 -0700
Subject: [PATCH] Added a default message handler for experience logs.
 Currently just forwards the   notification.

---
 indra/newview/CMakeLists.txt                  |   4 +
 indra/newview/llexperiencelog.cpp             |  28 +++++
 indra/newview/llexperiencelog.h               |  33 +++++
 indra/newview/llpanelexperiencelog.cpp        | 118 ++++++++++++++++++
 indra/newview/llpanelexperiencelog.h          |  48 +++++++
 indra/newview/llstartup.cpp                   |   6 +-
 indra/newview/llstartup.h                     |   2 +-
 .../skins/default/xui/en/notifications.xml    |  20 +++
 .../newview/skins/default/xui/en/strings.xml  |  10 +-
 9 files changed, 265 insertions(+), 4 deletions(-)
 create mode 100644 indra/newview/llexperiencelog.cpp
 create mode 100644 indra/newview/llexperiencelog.h
 create mode 100644 indra/newview/llpanelexperiencelog.cpp
 create mode 100644 indra/newview/llpanelexperiencelog.h

diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 868a26f47d1..3a181331934 100755
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -190,6 +190,7 @@ set(viewer_SOURCE_FILES
     lleventpoll.cpp
     llexpandabletextbox.cpp
     llexperienceassociationresponder.cpp
+    llexperiencelog.cpp
     llexternaleditor.cpp
     llface.cpp
     llfacebookconnect.cpp
@@ -405,6 +406,7 @@ set(viewer_SOURCE_FILES
     llpanelcontents.cpp
     llpaneleditwearable.cpp
     llpanelexperiencelisteditor.cpp
+    llpanelexperiencelog.cpp
     llpanelexperiences.cpp
     llpanelface.cpp
     llpanelgenerictip.cpp
@@ -785,6 +787,7 @@ set(viewer_HEADER_FILES
     lleventpoll.h
     llexpandabletextbox.h
     llexperienceassociationresponder.h
+    llexperiencelog.h
     llexternaleditor.h
     llface.h
     llfacebookconnect.h
@@ -993,6 +996,7 @@ set(viewer_HEADER_FILES
     llpanelcontents.h
     llpaneleditwearable.h
     llpanelexperiencelisteditor.h
+    llpanelexperiencelog.h
     llpanelexperiences.h
     llpanelface.h
     llpanelgenerictip.h
diff --git a/indra/newview/llexperiencelog.cpp b/indra/newview/llexperiencelog.cpp
new file mode 100644
index 00000000000..9842bdc31c3
--- /dev/null
+++ b/indra/newview/llexperiencelog.cpp
@@ -0,0 +1,28 @@
+/** 
+ * @file llexperiencelog.cpp
+ * @brief llexperiencelog implementation
+ *
+ * $LicenseInfo:firstyear=2014&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2014, Linden Research, Inc.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * 
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * $/LicenseInfo$
+ */
+
+#include "llviewerprecompiledheaders.h"
+#include "llexperiencelog.h"
diff --git a/indra/newview/llexperiencelog.h b/indra/newview/llexperiencelog.h
new file mode 100644
index 00000000000..73d82f4fad2
--- /dev/null
+++ b/indra/newview/llexperiencelog.h
@@ -0,0 +1,33 @@
+/** 
+ * @file llexperiencelog.h
+ * @brief llexperiencelog and related class definitions
+ *
+ * $LicenseInfo:firstyear=2014&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2014, Linden Research, Inc.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * 
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * $/LicenseInfo$
+ */
+
+
+
+#ifndef LL_LLEXPERIENCELOG_H
+#define LL_LLEXPERIENCELOG_H
+
+
+#endif // LL_LLEXPERIENCELOG_H
diff --git a/indra/newview/llpanelexperiencelog.cpp b/indra/newview/llpanelexperiencelog.cpp
new file mode 100644
index 00000000000..009889a59fd
--- /dev/null
+++ b/indra/newview/llpanelexperiencelog.cpp
@@ -0,0 +1,118 @@
+/** 
+ * @file llpanelexperiencelog.cpp
+ * @brief llpanelexperiencelog
+ *
+ * $LicenseInfo:firstyear=2014&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2014, Linden Research, Inc.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * 
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * $/LicenseInfo$
+ */
+
+
+#include "llviewerprecompiledheaders.h"
+#include "llpanelexperiencelog.h"
+#include "lldispatcher.h"
+#include "llsdserialize.h"
+#include "llviewergenericmessage.h"
+#include "llnotificationsutil.h"
+#include "lltrans.h"
+
+
+class LLExperienceLogDispatchHandler : public LLDispatchHandler
+{
+public:
+	virtual bool operator()(
+		const LLDispatcher* dispatcher,
+		const std::string& key,
+		const LLUUID& invoice,
+		const sparam_t& strings)
+	{
+		LLSD message;
+
+		sparam_t::const_iterator it = strings.begin();
+		if(it != strings.end()){
+			const std::string& llsdRaw = *it++;
+			std::istringstream llsdData(llsdRaw);
+			if (!LLSDSerialize::deserialize(message, llsdData, llsdRaw.length()))
+			{
+				llwarns << "LLExperienceLogDispatchHandler: Attempted to read parameter data into LLSD but failed:" << llsdRaw << llendl;
+			}
+		}
+		message["public_id"] = invoice;
+
+		// Object Name
+		if(it != strings.end())
+		{
+			message["ObjectName"] = *it++;
+		}
+
+		// parcel Name
+		if(it != strings.end())
+		{
+			message["ParcelName"] = *it++;
+		}
+
+		LLExperienceLog::instance().handleExperienceMessage(message);
+		return true;
+	}
+};
+
+static LLExperienceLogDispatchHandler experience_log_dispatch_handler;
+
+void LLExperienceLog::handleExperienceMessage(LLSD& message)
+{
+	std::ostringstream str;
+	if(message.has("Permission"))
+	{
+		str << "ExperiencePermission" << message["Permission"].asInteger();
+		std::string entry;
+		if(LLTrans::findString(entry, str.str()))
+		{
+			str.str(entry);
+		}
+		else
+		{
+			str.str();
+		}
+	}
+
+	if(str.str().empty())
+	{
+		str.str(LLTrans::getString("ExperiencePermissionUnknown", message));
+	}
+
+	message["EventType"] = str.str();
+	if(message.has("IsAttachment") && message["IsAttachment"].asBoolean())
+	{
+		LLNotificationsUtil::add("ExperienceEventAttachment", message);
+	}
+	else
+	{
+		LLNotificationsUtil::add("ExperienceEvent", message);
+	}
+}
+
+LLExperienceLog::LLExperienceLog()
+{
+}
+
+void LLExperienceLog::initialize()
+{
+	gGenericDispatcher.addHandler("ExperienceEvent", &experience_log_dispatch_handler);
+}
diff --git a/indra/newview/llpanelexperiencelog.h b/indra/newview/llpanelexperiencelog.h
new file mode 100644
index 00000000000..7d2a24872a3
--- /dev/null
+++ b/indra/newview/llpanelexperiencelog.h
@@ -0,0 +1,48 @@
+/** 
+ * @file llpanelexperiencelog.h
+ * @brief llpanelexperiencelog and related class definitions
+ *
+ * $LicenseInfo:firstyear=2014&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2014, Linden Research, Inc.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * 
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * $/LicenseInfo$
+ */
+
+
+
+#ifndef LL_LLPANELEXPERIENCELOG_H
+#define LL_LLPANELEXPERIENCELOG_H
+
+#include "llsingleton.h"
+
+
+
+class LLExperienceLog : public LLSingleton<LLExperienceLog>
+{
+	friend class LLSingleton<LLExperienceLog>;
+protected:
+	LLExperienceLog();
+	
+public:
+	void initialize();
+	void handleExperienceMessage(LLSD& message);
+};
+
+
+#endif // LL_LLPANELEXPERIENCELOG_H
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index a9ac8d6ea74..b5f976080ac 100755
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -198,6 +198,7 @@
 #include "llevents.h"
 #include "llstartuplistener.h"
 #include "lltoolbarview.h"
+#include "llpanelexperiencelog.h"
 
 #if LL_WINDOWS
 #include "lldxhardware.h"
@@ -1412,7 +1413,7 @@ bool idle_startup()
 		LLStartUp::initNameCache();
 		display_startup();
 
-		LLStartUp::initExperienceCache();
+		LLStartUp::initExperiences();
 		display_startup();
 
 		// update the voice settings *after* gCacheName initialization
@@ -2829,10 +2830,11 @@ void LLStartUp::initNameCache()
 }
 
 
-void LLStartUp::initExperienceCache()
+void LLStartUp::initExperiences()
 {
 	LLAppViewer::instance()->loadExperienceCache();
 	LLExperienceCache::initClass();
+	LLExperienceLog::instance().initialize();
 }
 
 void LLStartUp::cleanupNameCache()
diff --git a/indra/newview/llstartup.h b/indra/newview/llstartup.h
index 00e03bcda60..94ecbcd3333 100755
--- a/indra/newview/llstartup.h
+++ b/indra/newview/llstartup.h
@@ -91,7 +91,7 @@ class LLStartUp
 	static void fontInit();
 
 	static void initNameCache();
-	static void initExperienceCache();
+	static void initExperiences();
 	
 	static void cleanupNameCache();
 
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index e0cc2229d53..b230e36cc77 100755
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -7069,6 +7069,26 @@ Unable to acquire a new experience:
               text="Allowed into a region by an experience"/>
     </form>
   </notification>
+
+  <notification
+    icon="notify.tga"
+    name="ExperienceEvent"
+    persist="false"
+    type="notify">
+    An object was allowed to [EventType] by the secondlife:///app/experience/[public_id]/profile experience.
+    Owner: secondlife:///app/agent/[OwnerID]/inspect
+    Object Name: [ObjectName]
+    Parcel Name: [ParcelName]
+  </notification>
+
+  <notification
+    icon="notify.tga"
+    name="ExperienceEventAttachment"
+    persist="false"
+    type="notify">
+    An attachment was allowed to [EventType] by the secondlife:///app/experience/[public_id]/profile experience.
+    Owner: secondlife:///app/agent/[OwnerID]/inspect
+  </notification>
   
   <notification
    icon="notify.tga"
diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml
index 5badeff38b9..dc9e96e2f28 100755
--- a/indra/newview/skins/default/xui/en/strings.xml
+++ b/indra/newview/skins/default/xui/en/strings.xml
@@ -3985,7 +3985,15 @@ Try enclosing path to the editor with double quotes.
   <string name="Admin_Experiences_Tab">ADMIN</string>
   <string name="Recent_Experiences_Tab">RECENT</string>
   <string name="Owned_Experiences_Tab">OWNED</string>
-
+  <string name="ExperiencePermission1">take over your controls</string>
+  <string name="ExperiencePermission3">override animations on your avatar</string>
+  <string name="ExperiencePermission4">attach to your avatar</string>
+  <string name="ExperiencePermission9">track your camera</string>
+  <string name="ExperiencePermission10">control your camera</string>
+  <string name="ExperiencePermission11">teleport you</string>
+  <string name="ExperiencePermission12">automatically accept experience permissions</string>
+  <string name="ExperiencePermissionUnknown">perform an unknown operation: [Permission]</string>
+  
   <!-- Conversation log messages -->
   <string name="logging_calls_disabled_log_empty">
     Conversations are not being logged. To begin keeping a log, choose "Save: Log only" or "Save: Log and transcripts" under Preferences > Chat.
-- 
GitLab