summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterabout.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloaterabout.cpp')
-rwxr-xr-xindra/newview/llfloaterabout.cpp93
1 files changed, 92 insertions, 1 deletions
diff --git a/indra/newview/llfloaterabout.cpp b/indra/newview/llfloaterabout.cpp
index 7bd01f6beb..bababca652 100755
--- a/indra/newview/llfloaterabout.cpp
+++ b/indra/newview/llfloaterabout.cpp
@@ -34,10 +34,12 @@
// Viewer includes
#include "llagent.h"
#include "llagentui.h"
-#include "llappviewer.h"
+#include "llappviewer.h"
+#include "llnotificationsutil.h"
#include "llslurl.h"
#include "llvoiceclient.h"
#include "lluictrlfactory.h"
+#include "llupdaterservice.h"
#include "llviewertexteditor.h"
#include "llviewercontrol.h"
#include "llviewerstats.h"
@@ -87,10 +89,24 @@ public:
/// separated so that we can programmatically access the same info.
static LLSD getInfo();
void onClickCopyToClipboard();
+ void onClickUpdateCheck();
+
+ // checks state of updater service and starts a check outside of schedule.
+ // subscribes callback for closest state update
+ static void setUpdateListener();
private:
void setSupportText(const std::string& server_release_notes_url);
+ // notifications for user requested checks
+ static void showCheckUpdateNotification(S32 state);
+
+ // callback method for manual checks
+ static bool callbackCheckUpdate(LLSD const & event);
+
+ // listener name for update checks
+ static const std::string sCheckUpdateListenerName;
+
static void startFetchServerReleaseNotes();
static void handleServerReleaseNotes(LLSD results);
};
@@ -123,6 +139,9 @@ BOOL LLFloaterAbout::postBuild()
getChild<LLUICtrl>("copy_btn")->setCommitCallback(
boost::bind(&LLFloaterAbout::onClickCopyToClipboard, this));
+ getChild<LLUICtrl>("update_btn")->setCommitCallback(
+ boost::bind(&LLFloaterAbout::onClickUpdateCheck, this));
+
static const LLUIColor about_color = LLUIColorTable::instance().getColor("TextFgReadOnlyColor");
if (gAgent.getRegion())
@@ -270,6 +289,11 @@ void LLFloaterAbout::onClickCopyToClipboard()
support_widget->deselect();
}
+void LLFloaterAbout::onClickUpdateCheck()
+{
+ setUpdateListener();
+}
+
void LLFloaterAbout::setSupportText(const std::string& server_release_notes_url)
{
#if LL_WINDOWS
@@ -291,6 +315,68 @@ void LLFloaterAbout::setSupportText(const std::string& server_release_notes_url)
}
///----------------------------------------------------------------------------
+/// Floater About Update-check related functions
+///----------------------------------------------------------------------------
+
+const std::string LLFloaterAbout::sCheckUpdateListenerName = "LLUpdateNotificationListener";
+
+void LLFloaterAbout::showCheckUpdateNotification(S32 state)
+{
+ switch (state)
+ {
+ case LLUpdaterService::UP_TO_DATE:
+ LLNotificationsUtil::add("UpdateViewerUpToDate");
+ break;
+ case LLUpdaterService::DOWNLOADING:
+ case LLUpdaterService::INSTALLING:
+ LLNotificationsUtil::add("UpdateDownloadInProgress");
+ break;
+ case LLUpdaterService::TERMINAL:
+ // download complete, user triggered check after download pop-up appeared
+ LLNotificationsUtil::add("UpdateDownloadComplete");
+ break;
+ default:
+ LLNotificationsUtil::add("UpdateCheckError");
+ break;
+ }
+}
+
+bool LLFloaterAbout::callbackCheckUpdate(LLSD const & event)
+{
+ if (!event.has("payload"))
+ {
+ return false;
+ }
+
+ LLSD payload = event["payload"];
+ if (payload.has("type") && payload["type"].asInteger() == LLUpdaterService::STATE_CHANGE)
+ {
+ LLEventPumps::instance().obtain("mainlooprepeater").stopListening(sCheckUpdateListenerName);
+ showCheckUpdateNotification(payload["state"].asInteger());
+ }
+ return false;
+}
+
+void LLFloaterAbout::setUpdateListener()
+{
+ LLUpdaterService update_service;
+ S32 service_state = update_service.getState();
+ // Note: Do not set state listener before forceCheck() since it set's new state
+ if (update_service.forceCheck() || service_state == LLUpdaterService::CHECKING_FOR_UPDATE)
+ {
+ LLEventPump& mainloop(LLEventPumps::instance().obtain("mainlooprepeater"));
+ if (mainloop.getListener(sCheckUpdateListenerName) == LLBoundListener()) // dummy listener
+ {
+ mainloop.listen(sCheckUpdateListenerName, boost::bind(&callbackCheckUpdate, _1));
+ }
+ }
+ else
+ {
+ showCheckUpdateNotification(service_state);
+ }
+}
+
+///----------------------------------------------------------------------------
/// LLFloaterAboutUtil
///----------------------------------------------------------------------------
void LLFloaterAboutUtil::registerFloater()
@@ -300,3 +386,8 @@ void LLFloaterAboutUtil::registerFloater()
}
+void LLFloaterAboutUtil::checkUpdatesAndNotify()
+{
+ LLFloaterAbout::setUpdateListener();
+}
+