From 85c24a489dd0550db253f442fc5e22a6494b7cd7 Mon Sep 17 00:00:00 2001 From: Mnikolenko ProductEngine Date: Mon, 6 Feb 2017 13:04:22 +0200 Subject: MAINT-7104 Add Grid status floater and toolbar button --- indra/newview/llfloatergridstatus.cpp | 84 +++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 indra/newview/llfloatergridstatus.cpp (limited to 'indra/newview/llfloatergridstatus.cpp') diff --git a/indra/newview/llfloatergridstatus.cpp b/indra/newview/llfloatergridstatus.cpp new file mode 100644 index 0000000000..a12f717a25 --- /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); +} -- cgit v1.2.3 From 67edb011b5b803c21652c9735e03a387f26a77d5 Mon Sep 17 00:00:00 2001 From: Mnikolenko ProductEngine Date: Tue, 14 Feb 2017 13:37:45 +0200 Subject: MAINT-7104 Flash toolbar when grid status page is updated --- indra/newview/llfloatergridstatus.cpp | 156 ++++++++++++++++++++++++++++------ 1 file changed, 128 insertions(+), 28 deletions(-) (limited to 'indra/newview/llfloatergridstatus.cpp') diff --git a/indra/newview/llfloatergridstatus.cpp b/indra/newview/llfloatergridstatus.cpp index a12f717a25..3429203afe 100644 --- a/indra/newview/llfloatergridstatus.cpp +++ b/indra/newview/llfloatergridstatus.cpp @@ -28,57 +28,157 @@ #include "llfloatergridstatus.h" +#include "llcallbacklist.h" +#include "llcorehttputil.h" +#include "llfloaterreg.h" #include "llhttpconstants.h" #include "llmediactrl.h" +#include "llsdserialize.h" +#include "lltoolbarview.h" #include "llviewercontrol.h" +#include "llxmltree.h" +std::map LLFloaterGridStatus::sItemsMap; +const std::string DEFAULT_GRID_STATUS_URL = "http://secondlife-status.statuspage.io/"; LLFloaterGridStatus::LLFloaterGridStatus(const Params& key) : - LLFloaterWebContent(key) + LLFloaterWebContent(key), + mIsFirstUpdate(TRUE) { } BOOL LLFloaterGridStatus::postBuild() { - LLFloaterWebContent::postBuild(); - mWebBrowser->addObserver(this); + LLFloaterWebContent::postBuild(); + mWebBrowser->addObserver(this); - return TRUE; + 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); - } + Params p(key); + p.trusted_content = true; + p.allow_address_entry = false; + + LLFloaterWebContent::onOpen(p); + applyPreferredRect(); + if (mWebBrowser) + { + mWebBrowser->navigateTo(DEFAULT_GRID_STATUS_URL, HTTP_CONTENT_TEXT_HTML); + } +} + +void LLFloaterGridStatus::startGridStatusTimer() +{ + checkGridStatusRSS(); + doPeriodically(boost::bind(&LLFloaterGridStatus::checkGridStatusRSS), gSavedSettings.getF32("GridStatusUpdateDelay")); +} + +bool LLFloaterGridStatus::checkGridStatusRSS() +{ + if(gToolBarView->hasCommand(LLCommandId("gridstatus"))) + { + LLCoros::instance().launch("LLFloaterGridStatus::getGridStatusRSSCoro", + boost::bind(&LLFloaterGridStatus::getGridStatusRSSCoro)); + } + return false; +} + +void LLFloaterGridStatus::getGridStatusRSSCoro() +{ + + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getGridStatusRSSCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders); + + httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_TEXT_XML); + std::string url = gSavedSettings.getString("GridStatusRSS"); + + LLSD result = httpAdapter->getRawAndSuspend(httpRequest, url, httpOpts, httpHeaders); + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + if (!status) + { + return; + } + + const LLSD::Binary &rawBody = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_RAW].asBinary(); + std::string body(rawBody.begin(), rawBody.end()); + + std::string fullpath = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"grid_status_rss.xml"); + if(!gSavedSettings.getBOOL("TestGridStatusRSSFromFile")) + { + llofstream custom_file_out(fullpath.c_str(), std::ios::trunc); + if (custom_file_out.is_open()) + { + custom_file_out << body; + custom_file_out.close(); + } + } + LLXmlTree grid_status_xml; + if (!grid_status_xml.parseFile(fullpath)) + { + return ; + } + bool new_entries = false; + LLXmlTreeNode* rootp = grid_status_xml.getRoot(); + for (LLXmlTreeNode* item = rootp->getChildByName( "entry" ); item; item = rootp->getNextNamedChild()) + { + LLXmlTreeNode* id_node = item->getChildByName("id"); + LLXmlTreeNode* updated_node = item->getChildByName("updated"); + if (!id_node || !updated_node) + { + continue; + } + std::string guid = id_node->getContents(); + std::string date = updated_node->getContents(); + if(sItemsMap.find( guid ) == sItemsMap.end()) + { + new_entries = true; + } + else + { + if(sItemsMap[guid] != date) + { + new_entries = true; + } + } + sItemsMap[guid] = date; + } + if(new_entries && !getInstance()->isFirstUpdate()) + { + gToolBarView->flashCommand(LLCommandId("gridstatus"), true); + } + getInstance()->setFirstUpdate(FALSE); } + // virtual void LLFloaterGridStatus::handleReshape(const LLRect& new_rect, bool by_user) { - if (by_user && !isMinimized()) - { - gSavedSettings.setRect("GridStatusFloaterRect", new_rect); - } + if (by_user && !isMinimized()) + { + gSavedSettings.setRect("GridStatusFloaterRect", new_rect); + } - LLFloaterWebContent::handleReshape(new_rect, by_user); + 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); + const LLRect preferred_rect = gSavedSettings.getRect("GridStatusFloaterRect"); + + LLRect new_rect = getRect(); + new_rect.setLeftTopAndSize( + new_rect.mLeft, new_rect.mTop, + preferred_rect.getWidth(), preferred_rect.getHeight()); + setShape(new_rect); +} + +LLFloaterGridStatus* LLFloaterGridStatus::getInstance() +{ + return LLFloaterReg::getTypedInstance("grid_status"); } -- cgit v1.2.3 From 6e06281477840e2403d52510b54bf2cd99dd8216 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Tue, 14 Feb 2017 15:46:27 +0200 Subject: MAINT-7104 whitespace clean-up --- indra/newview/llfloatergridstatus.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llfloatergridstatus.cpp') diff --git a/indra/newview/llfloatergridstatus.cpp b/indra/newview/llfloatergridstatus.cpp index 3429203afe..c47ff1c1d9 100644 --- a/indra/newview/llfloatergridstatus.cpp +++ b/indra/newview/llfloatergridstatus.cpp @@ -4,7 +4,7 @@ * * $LicenseInfo:firstyear=2009&license=viewerlgpl$ * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * Copyright (C) 2017, 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 -- cgit v1.2.3