diff options
-rw-r--r-- | indra/newview/app_settings/commands.xml | 1 | ||||
-rw-r--r-- | indra/newview/app_settings/settings.xml | 33 | ||||
-rw-r--r-- | indra/newview/llfloatergridstatus.cpp | 156 | ||||
-rw-r--r-- | indra/newview/llfloatergridstatus.h | 15 | ||||
-rw-r--r-- | indra/newview/llstartup.cpp | 3 | ||||
-rw-r--r-- | indra/newview/skins/default/textures/textures.xml | 2 | ||||
-rw-r--r-- | indra/newview/skins/default/textures/toolbar_icons/grid_status.png | bin | 0 -> 483 bytes |
7 files changed, 181 insertions, 29 deletions
diff --git a/indra/newview/app_settings/commands.xml b/indra/newview/app_settings/commands.xml index 64cd11a53a..412d3a53b3 100644 --- a/indra/newview/app_settings/commands.xml +++ b/indra/newview/app_settings/commands.xml @@ -294,6 +294,7 @@ /> <command name="gridstatus" available_in_toybox="true" + is_flashing_allowed="true" icon="Command_Grid_Status_Icon" label_ref="Command_Grid_Status_Label" tooltip_ref="Command_Grid_Status_Tooltip" diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index e96401b511..fb644d3d5a 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -5163,6 +5163,39 @@ <key>Value</key> <string>http://wiki.secondlife.com/wiki/[LSL_STRING]</string> </map> + <key>GridStatusRSS</key> + <map> + <key>Comment</key> + <string>URL that points to SL Grid Status RSS</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>String</string> + <key>Value</key> + <string>https://secondlife-status.statuspage.io/history.atom</string> + </map> + <key>GridStatusUpdateDelay</key> + <map> + <key>Comment</key> + <string>Timer delay for updating Grid Status RSS.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>F32</string> + <key>Value</key> + <real>60.0</real> + </map> + <key>TestGridStatusRSSFromFile</key> + <map> + <key>Comment</key> + <string>For testing only: Don't update rss xml file from server.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> <key>LagMeterShrunk</key> <map> <key>Comment</key> 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<std::string, std::string> 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<LLFloaterGridStatus>("grid_status"); } diff --git a/indra/newview/llfloatergridstatus.h b/indra/newview/llfloatergridstatus.h index 045c647f4a..1608515003 100644 --- a/indra/newview/llfloatergridstatus.h +++ b/indra/newview/llfloatergridstatus.h @@ -46,10 +46,25 @@ public: /*virtual*/ void onOpen(const LLSD& key); /*virtual*/ void handleReshape(const LLRect& new_rect, bool by_user = false); + static bool checkGridStatusRSS(); + static void getGridStatusRSSCoro(); + + void startGridStatusTimer(); + BOOL isFirstUpdate() { return mIsFirstUpdate; } + void setFirstUpdate(BOOL first_update) { mIsFirstUpdate = first_update; } + + static LLFloaterGridStatus* getInstance(); + + private: /*virtual*/ BOOL postBuild(); void applyPreferredRect(); + + static std::map<std::string, std::string> sItemsMap; + + LLFrameTimer mGridStatusTimer; + BOOL mIsFirstUpdate; }; #endif // LL_LLFLOATERGRIDSTATUS_H diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index b762b2ae1c..347409fcab 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -56,6 +56,7 @@ #include "llerrorcontrol.h" #include "llfloaterreg.h" #include "llfocusmgr.h" +#include "llfloatergridstatus.h" #include "llfloaterimsession.h" #include "lllocationhistory.h" #include "llimageworker.h" @@ -1875,6 +1876,8 @@ bool idle_startup() LLFloaterReg::showInitialVisibleInstances(); + LLFloaterGridStatus::getInstance()->startGridStatusTimer(); + display_startup(); display_startup(); diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index bd8c0d5a96..d757e39366 100644 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -136,7 +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_Grid_Status_Icon" file_name="toolbar_icons/grid_status.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/textures/toolbar_icons/grid_status.png b/indra/newview/skins/default/textures/toolbar_icons/grid_status.png Binary files differnew file mode 100644 index 0000000000..b92b93cfb4 --- /dev/null +++ b/indra/newview/skins/default/textures/toolbar_icons/grid_status.png |