From 85c24a489dd0550db253f442fc5e22a6494b7cd7 Mon Sep 17 00:00:00 2001
From: Mnikolenko ProductEngine <mnikolenko@productengine.com>
Date: Mon, 6 Feb 2017 13:04:22 +0200
Subject: [PATCH] MAINT-7104 Add Grid status floater and toolbar button

---
 indra/newview/CMakeLists.txt                  |  2 +
 indra/newview/app_settings/commands.xml       | 10 +++
 indra/newview/app_settings/settings.xml       | 16 ++++
 indra/newview/llfloatergridstatus.cpp         | 84 +++++++++++++++++++
 indra/newview/llfloatergridstatus.h           | 56 +++++++++++++
 indra/newview/llviewerfloaterreg.cpp          |  2 +
 .../skins/default/textures/textures.xml       |  1 +
 .../default/xui/en/floater_grid_status.xml    | 18 ++++
 .../newview/skins/default/xui/en/strings.xml  |  2 +
 9 files changed, 191 insertions(+)
 create mode 100644 indra/newview/llfloatergridstatus.cpp
 create mode 100644 indra/newview/llfloatergridstatus.h
 create mode 100644 indra/newview/skins/default/xui/en/floater_grid_status.xml

diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 9ac1c3520d1..dbec4b5d651 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -236,6 +236,7 @@ set(viewer_SOURCE_FILES
     llfloatergesture.cpp
     llfloatergodtools.cpp
     llfloatergotoline.cpp
+    llfloatergridstatus.cpp
     llfloatergroupbulkban.cpp
     llfloatergroupinvite.cpp
     llfloatergroups.cpp
@@ -852,6 +853,7 @@ set(viewer_HEADER_FILES
     llfloatergesture.h
     llfloatergodtools.h
     llfloatergotoline.h
+    llfloatergridstatus.h
     llfloatergroupbulkban.h
     llfloatergroupinvite.h
     llfloatergroups.h
diff --git a/indra/newview/app_settings/commands.xml b/indra/newview/app_settings/commands.xml
index 9bc0a7c7014..64cd11a53a3 100644
--- a/indra/newview/app_settings/commands.xml
+++ b/indra/newview/app_settings/commands.xml
@@ -292,4 +292,14 @@
            is_running_function="Floater.IsOpen"
            is_running_parameters="reporter"
            />
+  <command name="gridstatus"
+           available_in_toybox="true"
+           icon="Command_Grid_Status_Icon"
+           label_ref="Command_Grid_Status_Label"
+           tooltip_ref="Command_Grid_Status_Tooltip"
+           execute_function="Floater.ToggleOrBringToFront"
+           execute_parameters="grid_status"
+           is_running_function="Floater.IsOpen"
+           is_running_parameters="grid_status"
+           />
 </commands>
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 717deba8c7c..e96401b5110 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -15125,6 +15125,22 @@
         <integer>0</integer>
         </array>
         </map>
+    <key>GridStatusFloaterRect</key>
+    <map>
+        <key>Comment</key>
+        <string>Web profile floater dimensions</string>
+        <key>Persist</key>
+        <integer>1</integer>
+        <key>Type</key>
+        <string>Rect</string>
+        <key>Value</key>
+        <array>
+            <integer>0</integer>
+            <integer>520</integer>
+            <integer>625</integer>
+            <integer>0</integer>
+        </array>
+    </map>
     <key>HelpFloaterOpen</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llfloatergridstatus.cpp b/indra/newview/llfloatergridstatus.cpp
new file mode 100644
index 00000000000..a12f717a255
--- /dev/null
+++ b/indra/newview/llfloatergridstatus.cpp
@@ -0,0 +1,84 @@
+/** 
+ * @file llfloatergridstatus.cpp
+ * @brief Grid status floater - uses an embedded web browser to show Grid status info
+ *
+ * $LicenseInfo:firstyear=2009&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, 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 "llfloatergridstatus.h"
+
+#include "llhttpconstants.h"
+#include "llmediactrl.h"
+#include "llviewercontrol.h"
+
+
+LLFloaterGridStatus::LLFloaterGridStatus(const Params& key) :
+	LLFloaterWebContent(key)
+{
+}
+
+BOOL LLFloaterGridStatus::postBuild()
+{
+	LLFloaterWebContent::postBuild();
+	mWebBrowser->addObserver(this);
+
+	return TRUE;
+}
+
+void LLFloaterGridStatus::onOpen(const LLSD& key)
+{
+	Params p(key);
+	p.trusted_content = true;
+	p.allow_address_entry = false;
+
+	LLFloaterWebContent::onOpen(p);
+	applyPreferredRect();
+	if (mWebBrowser)
+	{
+		std::string url = "http://secondlife-status.statuspage.io/";
+		mWebBrowser->navigateTo(url, HTTP_CONTENT_TEXT_HTML);
+	}
+}
+// virtual
+void LLFloaterGridStatus::handleReshape(const LLRect& new_rect, bool by_user)
+{
+	if (by_user && !isMinimized())
+	{
+		gSavedSettings.setRect("GridStatusFloaterRect", new_rect);
+	}
+
+	LLFloaterWebContent::handleReshape(new_rect, by_user);
+}
+
+void LLFloaterGridStatus::applyPreferredRect()
+{
+	const LLRect preferred_rect = gSavedSettings.getRect("GridStatusFloaterRect");
+
+	// Don't override position that may have been set by floater stacking code.
+	LLRect new_rect = getRect();
+	new_rect.setLeftTopAndSize(
+		new_rect.mLeft, new_rect.mTop,
+		preferred_rect.getWidth(), preferred_rect.getHeight());
+	setShape(new_rect);
+}
diff --git a/indra/newview/llfloatergridstatus.h b/indra/newview/llfloatergridstatus.h
new file mode 100644
index 00000000000..045c647f4ad
--- /dev/null
+++ b/indra/newview/llfloatergridstatus.h
@@ -0,0 +1,56 @@
+/** 
+ * @file llfloatergridstatus.h
+ * @brief Grid status floater - uses an embedded web browser to show Grid status info
+ *
+ * $LicenseInfo:firstyear=2009&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, 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_LLFLOATERGRIDSTATUS_H
+#define LL_LLFLOATERGRIDSTATUS_H
+
+#include "llfloaterwebcontent.h"
+#include "llviewermediaobserver.h"
+
+#include <string>
+
+class LLMediaCtrl;
+
+
+class LLFloaterGridStatus :
+	public LLFloaterWebContent
+{
+public:
+	typedef LLSDParamAdapter<_Params> Params;
+
+	LLFloaterGridStatus(const Params& key);
+
+	/*virtual*/ void onOpen(const LLSD& key);
+	/*virtual*/ void handleReshape(const LLRect& new_rect, bool by_user = false);
+
+private:
+	/*virtual*/ BOOL postBuild();
+
+	void applyPreferredRect();
+};
+
+#endif  // LL_LLFLOATERGRIDSTATUS_H
+
diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp
index ec7a81584aa..46525e84553 100644
--- a/indra/newview/llviewerfloaterreg.cpp
+++ b/indra/newview/llviewerfloaterreg.cpp
@@ -70,6 +70,7 @@
 #include "llfloaterfonttest.h"
 #include "llfloatergesture.h"
 #include "llfloatergodtools.h"
+#include "llfloatergridstatus.h"
 #include "llfloatergroups.h"
 #include "llfloaterhelpbrowser.h"
 #include "llfloaterhoverheight.h"
@@ -231,6 +232,7 @@ void LLViewerFloaterReg::registerFloaters()
 
 	LLFloaterReg::add("gestures", "floater_gesture.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGesture>);
 	LLFloaterReg::add("god_tools", "floater_god_tools.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGodTools>);
+	LLFloaterReg::add("grid_status", "floater_grid_status.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGridStatus>);
 	LLFloaterReg::add("group_picker", "floater_choose_group.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGroupPicker>);
 
 	LLFloaterReg::add("help_browser", "floater_help_browser.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterHelpBrowser>);
diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml
index 760c294f901..bd8c0d5a967 100644
--- a/indra/newview/skins/default/textures/textures.xml
+++ b/indra/newview/skins/default/textures/textures.xml
@@ -136,6 +136,7 @@ with the same filename but different name
   <texture name="Command_Facebook_Icon"     file_name="toolbar_icons/facebook.png"     preload="true" />
   <texture name="Command_Flickr_Icon"       file_name="toolbar_icons/flickr.png"       preload="true" />
   <texture name="Command_Gestures_Icon"     file_name="toolbar_icons/gestures.png"     preload="true" />
+  <texture name="Command_Grid_Status_Icon"  file_name="icons/Info.png" preload="true" />
   <texture name="Command_HowTo_Icon"        file_name="toolbar_icons/howto.png"        preload="true" />
   <texture name="Command_Inventory_Icon"    file_name="toolbar_icons/inventory.png"    preload="true" />
   <texture name="Command_Map_Icon"          file_name="toolbar_icons/map.png"          preload="true" />
diff --git a/indra/newview/skins/default/xui/en/floater_grid_status.xml b/indra/newview/skins/default/xui/en/floater_grid_status.xml
new file mode 100644
index 00000000000..b97bd8056dc
--- /dev/null
+++ b/indra/newview/skins/default/xui/en/floater_grid_status.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<floater
+  positioning="cascading"
+  legacy_header_height="18"
+  can_resize="true"
+  height="775"
+  layout="topleft"
+  min_height="485"
+  min_width="485"
+  name="floater_grid_status"
+  help_topic="floater_grid_status"
+  save_rect="true"
+  save_visibility="true"
+  title=""
+  initial_mime_type="text/html"
+  width="780"
+  tab_stop="true"
+  filename="floater_web_content.xml"/>
diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml
index b75f6317999..6f00f1731ed 100644
--- a/indra/newview/skins/default/xui/en/strings.xml
+++ b/indra/newview/skins/default/xui/en/strings.xml
@@ -4070,6 +4070,7 @@ Try enclosing path to the editor with double quotes.
   <string name="Command_Facebook_Label">Facebook</string>
   <string name="Command_Flickr_Label">Flickr</string>
   <string name="Command_Gestures_Label">Gestures</string>
+  <string name="Command_Grid_Status_Label">Grid status</string>
   <string name="Command_HowTo_Label">How to</string>
   <string name="Command_Inventory_Label">Inventory</string>
   <string name="Command_Map_Label">Map</string>
@@ -4102,6 +4103,7 @@ Try enclosing path to the editor with double quotes.
   <string name="Command_Facebook_Tooltip">Post to Facebook</string>
   <string name="Command_Flickr_Tooltip">Upload to Flickr</string>
   <string name="Command_Gestures_Tooltip">Gestures for your avatar</string>
+  <string name="Command_Grid_Status_Tooltip">Show current Grid status</string>
   <string name="Command_HowTo_Tooltip">How to do common tasks</string>
   <string name="Command_Inventory_Tooltip">View and use your belongings</string>
   <string name="Command_Map_Tooltip">Map of the world</string>
-- 
GitLab