Simple update check mechanism, and tons of notification tweaking to make the notifications look less crap.
This commit is contained in:
@@ -962,3 +962,4 @@ P(wholeModelFeeResponder);
|
||||
P(wholeModelUploadResponder);
|
||||
P2(XMLRPCResponder, connect_40s);
|
||||
P2(crashLoggerResponder, transfer_300s);
|
||||
P(getUpdateInfoResponder);
|
||||
@@ -48,6 +48,7 @@
|
||||
#include "lluictrlfactory.h"
|
||||
#include "llnotifications.h"
|
||||
#include "llfunctorregistry.h"
|
||||
#include "lldraghandle.h"
|
||||
|
||||
const S32 MAX_ALLOWED_MSG_WIDTH = 400;
|
||||
const F32 DEFAULT_BUTTON_DELAY = 0.5f;
|
||||
@@ -233,6 +234,12 @@ LLAlertDialog::LLAlertDialog( LLNotificationPtr notification, bool modal)
|
||||
msg_box->setColor( LLUI::sColorsGroup->getColor( "AlertTextColor" ) );
|
||||
}
|
||||
|
||||
LLDragHandle* handle = getDragHandle();
|
||||
if (handle)
|
||||
{
|
||||
getDragHandle()->setTextColor(LLUI::sColorsGroup->getColor(mCaution ? "AlertCautionTextColor" : "AlertTextColor"));
|
||||
}
|
||||
|
||||
LLRect rect;
|
||||
rect.setLeftTopAndSize( msg_x, msg_y, text_rect.getWidth(), text_rect.getHeight() );
|
||||
msg_box->setRect( rect );
|
||||
@@ -257,6 +264,10 @@ LLAlertDialog::LLAlertDialog( LLNotificationPtr notification, bool modal)
|
||||
button_data.mText);
|
||||
|
||||
btn->setClickedCallback(boost::bind(&LLAlertDialog::onButtonPressed, this, _1, button_data.mUrl));
|
||||
if (mCaution)
|
||||
{
|
||||
btn->setColor(LLUI::sColorsGroup->getColor("ButtonCautionImageColor"));
|
||||
}
|
||||
|
||||
addChild(btn);
|
||||
|
||||
@@ -370,6 +381,11 @@ bool LLAlertDialog::setCheckBox( const std::string& check_title, const std::stri
|
||||
max_msg_width, LINE_HEIGHT);
|
||||
|
||||
mCheck = new LLCheckboxCtrl(std::string("check"), check_rect, check_title, font, boost::bind(&LLAlertDialog::onClickIgnore, this, _1));
|
||||
mCheck->setEnabledColor(LLUI::sColorsGroup->getColor( mCaution ? "AlertCautionTextColor" : "AlertTextColor"));
|
||||
if (mCaution)
|
||||
{
|
||||
mCheck->setButtonColor(LLUI::sColorsGroup->getColor("ButtonCautionImageColor"));
|
||||
}
|
||||
addChild(mCheck);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -100,8 +100,10 @@ public:
|
||||
// LLCheckBoxCtrl interface
|
||||
virtual BOOL toggle() { return mButton->toggleState(); } // returns new state
|
||||
|
||||
void setEnabledColor( const LLColor4 &color ) { mTextEnabledColor = color; }
|
||||
void setDisabledColor( const LLColor4 &color ) { mTextDisabledColor = color; }
|
||||
void setEnabledColor(const LLColor4 &color) { mTextEnabledColor = color; setEnabled(getEnabled()); }
|
||||
void setDisabledColor( const LLColor4 &color ) { mTextDisabledColor = color; setEnabled(getEnabled()); }
|
||||
|
||||
void setButtonColor(const LLColor4 &color) { if (mButton) mButton->setColor(color); }
|
||||
|
||||
void setLabel( const LLStringExplicit& label );
|
||||
std::string getLabel() const;
|
||||
|
||||
@@ -301,6 +301,13 @@ BOOL LLDragHandle::handleMouseUp(S32 x, S32 y, MASK mask)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void LLDragHandle::setTextColor(const LLColor4& color)
|
||||
{
|
||||
if (mTitleBox)
|
||||
{
|
||||
mTitleBox->setColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL LLDragHandle::handleHover(S32 x, S32 y, MASK mask)
|
||||
{
|
||||
|
||||
@@ -63,6 +63,8 @@ public:
|
||||
virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
|
||||
virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
|
||||
|
||||
virtual void setTextColor(const LLColor4& color);
|
||||
|
||||
protected:
|
||||
LLTextBox* getTitleBox() const { return mTitleBox; }
|
||||
void setTitleBox(LLTextBox*);
|
||||
|
||||
@@ -891,7 +891,7 @@ bool LLNotificationChannelBase::updateItem(const LLSD& payload, LLNotificationPt
|
||||
assert(!wasFound);
|
||||
if (passesFilter)
|
||||
{
|
||||
LL_INFOS() << "Inserting " << pNotification->getName() << LL_ENDL;
|
||||
//LL_INFOS() << "Inserting " << pNotification->getName() << LL_ENDL;
|
||||
// not in our list, add it and say so
|
||||
mItems.insert(pNotification);
|
||||
abortProcessing = mChanged(payload);
|
||||
|
||||
@@ -594,6 +594,7 @@ set(viewer_SOURCE_FILES
|
||||
scriptcounter.cpp
|
||||
sgmemstat.cpp
|
||||
shcommandhandler.cpp
|
||||
shupdatechecker.cpp
|
||||
shfloatermediaticker.cpp
|
||||
wlfPanel_AdvSettings.cpp
|
||||
)
|
||||
@@ -1136,6 +1137,7 @@ set(viewer_HEADER_FILES
|
||||
sgmemstat.h
|
||||
shcommandhandler.h
|
||||
shfloatermediaticker.h
|
||||
shupdatechecker.h
|
||||
wlfPanel_AdvSettings.h
|
||||
)
|
||||
|
||||
|
||||
@@ -873,6 +873,61 @@
|
||||
<key>Value</key>
|
||||
<boolean>1</boolean>
|
||||
</map>
|
||||
<key>SinguLastKnownReleaseBuild</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Latest known available verson.</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>S32</string>
|
||||
<key>Value</key>
|
||||
<boolean>0</boolean>
|
||||
</map>
|
||||
<key>SinguLastKnownAlphaBuild</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Latest known available verson.</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>S32</string>
|
||||
<key>Value</key>
|
||||
<boolean>0</boolean>
|
||||
</map>
|
||||
<key>WarnRecommendedUpdate</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Enables recommended update notification dialog</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Boolean</string>
|
||||
<key>Value</key>
|
||||
<integer>1</integer>
|
||||
</map>
|
||||
<key>WarnUrgentUpdate</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Enables critical update notification dialog</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Boolean</string>
|
||||
<key>Value</key>
|
||||
<integer>1</integer>
|
||||
</map>
|
||||
<key>WarnUrgentUpdateModal</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Enables critical update modal dialog</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Boolean</string>
|
||||
<key>Value</key>
|
||||
<integer>1</integer>
|
||||
</map>
|
||||
<key>UseWebProfiles</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#include "llfloaterchat.h" // for add_chat_history()
|
||||
#include "lloverlaybar.h" // for gOverlayBar
|
||||
#include "lluictrlfactory.h"
|
||||
#include "llcheckboxctrl.h"
|
||||
|
||||
#include "hippogridmanager.h"
|
||||
|
||||
@@ -183,6 +184,8 @@ LLNotifyBox::LLNotifyBox(LLNotificationPtr notification)
|
||||
bool layout_script_dialog(notification->getName() == "ScriptDialog" || notification->getName() == "ScriptDialogGroup");
|
||||
LLRect rect = mIsTip ? getNotifyTipRect(message)
|
||||
: getNotifyRect(is_textbox ? 10 : mNumOptions, layout_script_dialog, mIsCaution);
|
||||
if ((form->getIgnoreType() == LLNotificationForm::IGNORE_WITH_DEFAULT_RESPONSE || form->getIgnoreType() == LLNotificationForm::IGNORE_WITH_LAST_RESPONSE))
|
||||
rect.mBottom -= BTN_HEIGHT;
|
||||
setRect(rect);
|
||||
setFollows(mIsTip ? (FOLLOWS_BOTTOM|FOLLOWS_RIGHT) : (FOLLOWS_TOP|FOLLOWS_RIGHT));
|
||||
setBackgroundVisible(FALSE);
|
||||
@@ -359,6 +362,45 @@ LLNotifyBox::LLNotifyBox(LLNotificationPtr notification)
|
||||
addButton("OK", "OK", false, true, layout_script_dialog);
|
||||
mAddedDefaultBtn = true;
|
||||
}
|
||||
|
||||
std::string check_title;
|
||||
if (form->getIgnoreType() == LLNotificationForm::IGNORE_WITH_DEFAULT_RESPONSE)
|
||||
{
|
||||
check_title = LLNotificationTemplates::instance().getGlobalString("skipnexttime");
|
||||
}
|
||||
else if (form->getIgnoreType() == LLNotificationForm::IGNORE_WITH_LAST_RESPONSE)
|
||||
{
|
||||
check_title = LLNotificationTemplates::instance().getGlobalString("alwayschoose");
|
||||
}
|
||||
if (!check_title.empty())
|
||||
{
|
||||
const LLFontGL* font = LLResMgr::getInstance()->getRes(LLFONT_SANSSERIF);
|
||||
S32 line_height = llfloor(font->getLineHeight() + 0.99f);
|
||||
|
||||
// Extend dialog for "check next time"
|
||||
S32 max_msg_width = getRect().getWidth() - HPAD * 9;
|
||||
S32 check_width = S32(font->getWidth(check_title) + 0.99f) + 16;
|
||||
max_msg_width = llmax(max_msg_width, check_width);
|
||||
|
||||
S32 msg_x = (getRect().getWidth() - max_msg_width) / 2;
|
||||
|
||||
LLRect check_rect;
|
||||
check_rect.setOriginAndSize(msg_x, BOTTOM_PAD + BTN_HEIGHT + VPAD*2 + (BTN_HEIGHT + VPAD) * (mNumButtons / 3),
|
||||
max_msg_width, line_height);
|
||||
|
||||
LLCheckboxCtrl* check = new LLCheckboxCtrl(std::string("check"), check_rect, check_title, font,
|
||||
// Lambda abuse.
|
||||
[this](LLUICtrl* ctrl, const LLSD& param)
|
||||
{
|
||||
this->mNotification->setIgnored(ctrl->getValue());
|
||||
});
|
||||
check->setEnabledColor(LLUI::sColorsGroup->getColor(mIsCaution ? "AlertCautionTextColor" : "AlertTextColor"));
|
||||
if (mIsCaution)
|
||||
{
|
||||
check->setButtonColor(LLUI::sColorsGroup->getColor("ButtonCautionImageColor"));
|
||||
}
|
||||
addChild(check);
|
||||
}
|
||||
|
||||
if (++sNotifyBoxCount <= 0)
|
||||
LL_WARNS() << "A notification was mishandled. sNotifyBoxCount = " << sNotifyBoxCount << LL_ENDL;
|
||||
|
||||
@@ -225,6 +225,7 @@
|
||||
#include "llfloaterblacklist.h"
|
||||
#include "scriptcounter.h"
|
||||
#include "shfloatermediaticker.h"
|
||||
#include "shupdatechecker.h"
|
||||
#include "llpacketring.h"
|
||||
// </edit>
|
||||
|
||||
@@ -849,6 +850,7 @@ bool idle_startup()
|
||||
|
||||
// Go to the next startup state
|
||||
LLStartUp::setStartupState( STATE_BROWSER_INIT );
|
||||
check_for_updates();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
171
indra/newview/shupdatechecker.cpp
Normal file
171
indra/newview/shupdatechecker.cpp
Normal file
@@ -0,0 +1,171 @@
|
||||
#include "llviewerprecompiledheaders.h"
|
||||
|
||||
#include "llviewerwindow.h"
|
||||
#include "llwindow.h"
|
||||
#include "llpanelgeneral.h"
|
||||
#include "llappviewer.h"
|
||||
#include "llbutton.h"
|
||||
#include "llviewercontrol.h"
|
||||
#include "llnotificationsutil.h"
|
||||
#include "llstartup.h"
|
||||
#include "llviewerwindow.h" // to link into child list
|
||||
#include "llnotify.h"
|
||||
#include "lluictrlfactory.h"
|
||||
#include "llhttpclient.h"
|
||||
#include "llversioninfo.h"
|
||||
#include "llbufferstream.h"
|
||||
#include "llweb.h"
|
||||
|
||||
|
||||
#include <jsoncpp/reader.h>
|
||||
|
||||
extern AIHTTPTimeoutPolicy getUpdateInfoResponder_timeout;
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// GetUpdateInfoResponder
|
||||
class GetUpdateInfoResponder : public LLHTTPClient::ResponderWithCompleted
|
||||
{
|
||||
LOG_CLASS(GetUpdateInfoResponder);
|
||||
|
||||
public:
|
||||
GetUpdateInfoResponder(std::string type)
|
||||
: mType(type)
|
||||
{}
|
||||
void onNotifyButtonPress(const LLSD& notification, const LLSD& response, std::string name, std::string url)
|
||||
{
|
||||
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
|
||||
if (option == 0) // URL
|
||||
{
|
||||
std::string escaped_url = LLWeb::escapeURL(url);
|
||||
if (gViewerWindow)
|
||||
{
|
||||
gViewerWindow->getWindow()->spawnWebBrowser(escaped_url, true);
|
||||
}
|
||||
}
|
||||
if (option == 1) // Later
|
||||
{}
|
||||
else if (option == 2) // Ignore
|
||||
{
|
||||
LLNotificationPtr notifyptr = LLNotificationsUtil::find(notification["id"]);
|
||||
if (notifyptr)
|
||||
{
|
||||
notifyptr->setIgnored(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*virtual*/ void completedRaw(LLChannelDescriptors const& channels, buffer_ptr_t const& buffer)
|
||||
{
|
||||
LLBufferStream istr(channels, buffer.get());
|
||||
std::stringstream strstrm;
|
||||
strstrm << istr.rdbuf();
|
||||
const std::string body = strstrm.str();
|
||||
|
||||
if (mStatus != HTTP_OK)
|
||||
{
|
||||
LL_WARNS() << "Failed to get update info (" << mStatus << ")" << LL_ENDL;
|
||||
return;
|
||||
}
|
||||
|
||||
Json::Value root;
|
||||
Json::Reader reader;
|
||||
if (!reader.parse(body, root))
|
||||
{
|
||||
LL_WARNS() << "Failed to parse update info: " << reader.getFormattedErrorMessages() << LL_ENDL;
|
||||
return;
|
||||
}
|
||||
|
||||
std::string viewer_version = llformat("%s (%i)", LLVersionInfo::getShortVersion(), LLVersionInfo::getBuild());
|
||||
|
||||
const Json::Value data = root[mType];
|
||||
#if LL_WINDOWS
|
||||
std::string recommended_version = data["recommended"]["windows"].asString();
|
||||
std::string minimum_version = data["minimum"]["windows"].asString();
|
||||
#elif LL_LINUX
|
||||
std::string recommended_version = data["recommended"]["linux"].asString();
|
||||
std::string minimum_version = data["minimum"]["linux"].asString();
|
||||
#elif LL_DARWIN
|
||||
std::string recommended_version = data["recommended"]["apple"].asString();
|
||||
std::string minimum_version = data["minimum"]["apple"].asString();
|
||||
#endif
|
||||
|
||||
S32 minimum_build, recommended_build;
|
||||
sscanf(recommended_version.c_str(), "%*i.%*i.%*i (%i)", &recommended_build);
|
||||
sscanf(minimum_version.c_str(), "%*i.%*i.%*i (%i)", &minimum_build);
|
||||
|
||||
LL_INFOS() << LLVersionInfo::getBuild() << LL_ENDL;
|
||||
LLSD args;
|
||||
args["CURRENT_VER"] = viewer_version;
|
||||
args["RECOMMENDED_VER"] = recommended_version;
|
||||
args["MINIMUM_VER"] = minimum_version;
|
||||
args["URL"] = data["url"].asString();
|
||||
args["TYPE"] = mType == "release" ? "Viewer" : "Alpha";
|
||||
|
||||
static LLCachedControl<S32> sLastKnownReleaseBuild("SinguLastKnownReleaseBuild", 0);
|
||||
static LLCachedControl<S32> sLastKnownAlphaBuild("SinguLastKnownAlphaBuild", 0);
|
||||
|
||||
LLCachedControl<S32>& lastver = mType == "release" ? sLastKnownReleaseBuild : sLastKnownAlphaBuild;
|
||||
|
||||
if (LLVersionInfo::getBuild() < minimum_build || LLVersionInfo::getBuild() < recommended_build)
|
||||
{
|
||||
if (lastver.get() < recommended_build)
|
||||
{
|
||||
lastver = recommended_build;
|
||||
LLUI::sIgnoresGroup->setWarning("UrgentUpdateModal", true);
|
||||
LLUI::sIgnoresGroup->setWarning("UrgentUpdate", true);
|
||||
LLUI::sIgnoresGroup->setWarning("RecommendedUpdate", true);
|
||||
}
|
||||
std::string notificaiton;
|
||||
if (LLVersionInfo::getBuild() < minimum_build)
|
||||
{
|
||||
if (LLUI::sIgnoresGroup->getWarning("UrgentUpdateModal"))
|
||||
{
|
||||
notificaiton = "UrgentUpdateModal";
|
||||
}
|
||||
else
|
||||
{
|
||||
notificaiton = "UrgentUpdate";
|
||||
}
|
||||
}
|
||||
else if (LLVersionInfo::getBuild() < recommended_build)
|
||||
{
|
||||
notificaiton = "RecommendedUpdate";
|
||||
}
|
||||
if (!notificaiton.empty())
|
||||
{
|
||||
LLNotificationsUtil::add(notificaiton, args, LLSD(), boost::bind(&GetUpdateInfoResponder::onNotifyButtonPress, this, _1, _2, notificaiton, data["url"].asString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
/*virtual*/ AIHTTPTimeoutPolicy const& getHTTPTimeoutPolicy(void) const { return getUpdateInfoResponder_timeout; }
|
||||
/*virtual*/ char const* getName(void) const { return "GetUpdateInfoResponder"; }
|
||||
|
||||
private:
|
||||
std::string mType;
|
||||
};
|
||||
|
||||
void check_for_updates()
|
||||
{
|
||||
#if LL_WINDOWS | LL_LINUX | LL_DARWIN
|
||||
// Hard-code the update url for now.
|
||||
std::string url = "http://singularity-viewer.github.io/pages/api/get_update_info.json";//gSavedSettings.getString("SHUpdateCheckURL");
|
||||
if (!url.empty())
|
||||
{
|
||||
std::string type;
|
||||
auto& channel = LLVersionInfo::getChannel();
|
||||
if (channel == std::string("Singularity"))
|
||||
{
|
||||
type = "release";
|
||||
}
|
||||
else if (channel == std::string("Singularity Test") || channel == std::string("Singularity Alpha"))
|
||||
{
|
||||
type = "alpha";
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
LLHTTPClient::get(url, new GetUpdateInfoResponder(type));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -57,20 +57,6 @@
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<template name="okcancelbuttonscanceldefault">
|
||||
<form>
|
||||
<button
|
||||
index="0"
|
||||
name="OK"
|
||||
text="$yestext"/>
|
||||
<button
|
||||
default="true"
|
||||
index="1"
|
||||
name="Cancel"
|
||||
text="$notext"/>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<template name="okcancelignore">
|
||||
<form>
|
||||
<button
|
||||
@@ -86,6 +72,20 @@
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<template name="okcancelignorecanceldefault">
|
||||
<form>
|
||||
<button
|
||||
index="0"
|
||||
name="OK"
|
||||
text="$yestext"/>
|
||||
<button
|
||||
default="true"
|
||||
index="1"
|
||||
name="Cancel"
|
||||
text="$notext"/>
|
||||
<ignore text="$ignoretext"/>
|
||||
</form>
|
||||
</template>
|
||||
<template name="okhelpbuttons">
|
||||
<form>
|
||||
<button
|
||||
@@ -10595,4 +10595,62 @@ Do you wish to export anyway?
|
||||
Object successfully exported to: [FILENAME]
|
||||
</notification>
|
||||
|
||||
<notification
|
||||
icon="notifytip.tga"
|
||||
label="Update Available"
|
||||
name="RecommendedUpdate"
|
||||
type="notify">
|
||||
A newer version, [RECOMMENDED_VER], is available for Singularity[TYPE].
|
||||
|
||||
Click [Visit Page] to open
|
||||
[URL]
|
||||
for information and download links for this new version.
|
||||
<tag>confirm</tag>
|
||||
<usetemplate
|
||||
name="okcancelignorecanceldefault"
|
||||
notext="Later"
|
||||
yestext="Visit Page"
|
||||
ignoretext="Ignore recommended update notification"/>
|
||||
</notification>
|
||||
<notification
|
||||
icon="alert.tga"
|
||||
label="Critical Update!"
|
||||
name="UrgentUpdate"
|
||||
priority="high"
|
||||
type="notify">
|
||||
Your version of Singularity[TYPE] is critically out of date!
|
||||
|
||||
It is STRONGLY recommended to download a newer version of this viewer due to grid compatability and/or security concerns.
|
||||
|
||||
Click [Visit Page] to open
|
||||
[URL]
|
||||
for information and download links for newer versions.
|
||||
|
||||
<tag>confirm</tag>
|
||||
<usetemplate
|
||||
name="okcancelignorecanceldefault"
|
||||
notext="Later"
|
||||
yestext="Visit Page"
|
||||
ignoretext="Ignore critical update notification"/>
|
||||
</notification>
|
||||
<notification
|
||||
icon="alert.tga"
|
||||
label="Critical Update"
|
||||
name="UrgentUpdateModal"
|
||||
priority="high"
|
||||
type="alertmodal">
|
||||
Your version of Singularity[TYPE] is critically out of date!
|
||||
|
||||
It is STRONGLY recommended to download a newer version of this viewer due to grid compatability and/or security concerns.
|
||||
|
||||
Click [Visit Page] to open
|
||||
[URL]
|
||||
for information and download links for newer versions.
|
||||
<tag>confirm</tag>
|
||||
<usetemplate
|
||||
name="okcancelignorecanceldefault"
|
||||
notext="Later"
|
||||
yestext="Visit Page"
|
||||
ignoretext="Ignore critical update alert"/>
|
||||
</notification>
|
||||
</notifications>
|
||||
|
||||
Reference in New Issue
Block a user