MAINT-938 FIXED (Make debit-permissions dialog give a stronger warning)

- Added new tag called "footer" to the notification. This tag allows to display messages under the buttons in toasts.
- Created new class LLToastScriptQuestion for the "ScriptQuestionCaution" notification. This notification supports tag <footer>.
master
Paul ProductEngine 2012-05-17 21:02:53 +03:00
parent d6569db352
commit f4edcdd409
12 changed files with 292 additions and 18 deletions

View File

@ -399,6 +399,7 @@ LLNotificationTemplate::LLNotificationTemplate(const LLNotificationTemplate::Par
: mName(p.name),
mType(p.type),
mMessage(p.value),
mFooter(p.footer.value),
mLabel(p.label),
mIcon(p.icon),
mURL(p.url.value),
@ -870,6 +871,15 @@ std::string LLNotification::getMessage() const
return message;
}
std::string LLNotification::getFooter() const
{
if (!mTemplatep)
return std::string();
std::string message = mTemplatep->mFooter;
return message;
}
std::string LLNotification::getLabel() const
{
std::string label = mTemplatep->mLabel;

View File

@ -509,6 +509,7 @@ public:
std::string getType() const;
std::string getMessage() const;
std::string getFooter() const;
std::string getLabel() const;
std::string getURL() const;
S32 getURLOption() const;

View File

@ -167,6 +167,17 @@ struct LLNotificationTemplate
{}
};
struct Footer : public LLInitParam::Block<Footer>
{
Mandatory<std::string> value;
Footer()
: value("value")
{
addSynonym(value, "");
}
};
struct Params : public LLInitParam::Block<Params>
{
Mandatory<std::string> name;
@ -184,7 +195,8 @@ struct LLNotificationTemplate
Optional<FormRef> form_ref;
Optional<ENotificationPriority,
NotificationPriorityValues> priority;
Multiple<Tag> tags;
Multiple<Tag> tags;
Optional<Footer> footer;
Params()
@ -202,7 +214,8 @@ struct LLNotificationTemplate
url("url"),
unique("unique"),
form_ref(""),
tags("tag")
tags("tag"),
footer("footer")
{}
};
@ -231,6 +244,8 @@ struct LLNotificationTemplate
// The text used to display the notification. Replaceable parameters
// are enclosed in square brackets like this [].
std::string mMessage;
// The text used to display the notification, but under the form.
std::string mFooter;
// The label for the notification; used for
// certain classes of notification (those with a window and a window title).
// Also used when a notification pops up underneath the current one.

View File

@ -489,6 +489,7 @@ set(viewer_SOURCE_FILES
lltoastnotifypanel.cpp
lltoastpanel.cpp
lltoastscripttextbox.cpp
lltoastscriptquestion.cpp
lltool.cpp
lltoolbarview.cpp
lltoolbrush.cpp
@ -1036,6 +1037,7 @@ set(viewer_HEADER_FILES
lltoastnotifypanel.h
lltoastpanel.h
lltoastscripttextbox.h
lltoastscriptquestion.h
lltool.h
lltoolbarview.h
lltoolbrush.h

View File

@ -101,7 +101,7 @@ bool LLScriptHandler::processNotification(const LLSD& notify)
}
else
{
LLToastNotifyPanel* notify_box = new LLToastNotifyPanel(notification);
LLToastPanel* notify_box = LLToastPanel::buidPanelFromNotification(notification);
LLToast::Params p;
p.notif_id = notification->getID();

View File

@ -52,7 +52,7 @@ const LLFontGL* LLToastNotifyPanel::sFontSmall = NULL;
LLToastNotifyPanel::button_click_signal_t LLToastNotifyPanel::sButtonClickSignal;
LLToastNotifyPanel::LLToastNotifyPanel(LLNotificationPtr& notification, const LLRect& rect, bool show_images) :
LLToastNotifyPanel::LLToastNotifyPanel(const LLNotificationPtr& notification, const LLRect& rect, bool show_images) :
LLToastPanel(notification),
mTextBox(NULL),
mInfoPanel(NULL),
@ -536,7 +536,7 @@ void LLToastNotifyPanel::onToastPanelButtonClicked(const LLUUID& notification_id
}
}
void LLToastNotifyPanel::disableRespondedOptions(LLNotificationPtr& notification)
void LLToastNotifyPanel::disableRespondedOptions(const LLNotificationPtr& notification)
{
LLSD response = notification->getResponse();
for (LLSD::map_const_iterator response_it = response.beginMap();

View File

@ -60,7 +60,7 @@ public:
* @deprecated if you intend to instantiate LLToastNotifyPanel - it's point to
* implement right class for desired toast panel. @see LLGenericTipPanel as example.
*/
LLToastNotifyPanel(LLNotificationPtr& pNotification, const LLRect& rect = LLRect::null, bool show_images = true);
LLToastNotifyPanel(const LLNotificationPtr& pNotification, const LLRect& rect = LLRect::null, bool show_images = true);
virtual ~LLToastNotifyPanel();
LLPanel * getControlPanel() { return mControlPanel; }
@ -118,7 +118,7 @@ protected:
/**
* Process response data. Will disable selected options
*/
void disableRespondedOptions(LLNotificationPtr& notification);
void disableRespondedOptions(const LLNotificationPtr& notification);
bool mIsTip;
bool mAddedDefaultBtn;

View File

@ -29,7 +29,9 @@
#include "llpanelgenerictip.h"
#include "llpanelonlinestatus.h"
#include "llnotifications.h"
#include "lltoastnotifypanel.h"
#include "lltoastpanel.h"
#include "lltoastscriptquestion.h"
//static
const S32 LLToastPanel::MIN_PANEL_HEIGHT = 40; // VPAD(4)*2 + ICON_HEIGHT(32)
@ -106,6 +108,17 @@ LLToastPanel* LLToastPanel::buidPanelFromNotification(
res = new LLPanelGenericTip(notification);
}
}
else if("notify" == notification->getType())
{
if (notification->getPriority() == NOTIFICATION_PRIORITY_CRITICAL)
{
res = new LLToastScriptQuestion(notification);
}
else
{
res = new LLToastNotifyPanel(notification);
}
}
/*
else if(...)
create all other specific non-public toast panel

View File

@ -0,0 +1,130 @@
/**
* @file lltoastscriptquestion.cpp
*
* $LicenseInfo:firstyear=2010&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2012, 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 "llbutton.h"
#include "llnotifications.h"
#include "lltoastscriptquestion.h"
const int LEFT_PAD = 10;
const int BUTTON_HEIGHT = 27;
const int MAX_LINES_COUNT = 50;
LLToastScriptQuestion::LLToastScriptQuestion(const LLNotificationPtr& notification)
:
LLToastPanel(notification)
{
buildFromFile("panel_script_question_toast.xml");
}
BOOL LLToastScriptQuestion::postBuild()
{
createButtons();
LLTextBox* mMessage = getChild<LLTextBox>("top_info_message");
LLTextBox* mFooter = getChild<LLTextBox>("bottom_info_message");
mMessage->setValue(mNotification->getMessage());
mFooter->setValue(mNotification->getFooter());
snapToMessageHeight();
return TRUE;
}
void LLToastScriptQuestion::snapToMessageHeight()
{
LLTextBox* mMessage = getChild<LLTextBox>("top_info_message");
LLTextBox* mFooter = getChild<LLTextBox>("bottom_info_message");
if (!mMessage || !mFooter)
{
return;
}
if (mMessage->getVisible() && mFooter->getVisible())
{
S32 heightDelta = 0;
S32 maxTextHeight = (mMessage->getDefaultFont()->getLineHeight() * MAX_LINES_COUNT)
+ (mFooter->getDefaultFont()->getLineHeight() * MAX_LINES_COUNT);
LLRect messageRect = mMessage->getRect();
LLRect footerRect = mFooter->getRect();
S32 oldTextHeight = messageRect.getHeight() + footerRect.getHeight();
S32 requiredTextHeight = mMessage->getTextBoundingRect().getHeight() + mFooter->getTextBoundingRect().getHeight();
S32 newTextHeight = llmin(requiredTextHeight, maxTextHeight);
heightDelta = newTextHeight - oldTextHeight - heightDelta;
reshape( getRect().getWidth(), llmax(getRect().getHeight() + heightDelta, MIN_PANEL_HEIGHT));
}
}
void LLToastScriptQuestion::createButtons()
{
LLNotificationFormPtr form = mNotification->getForm();
int num_elements = form->getNumElements();
int buttons_width = 0;
for (int i = 0; i < num_elements; ++i)
{
LLSD form_element = form->getElement(i);
if ("button" == form_element["type"].asString())
{
LLButton::Params p;
const LLFontGL* font = LLFontGL::getFontSansSerif();
p.name(form_element["name"].asString());
p.label(form_element["text"].asString());
p.layout("topleft");
p.font(font);
p.rect.height(BUTTON_HEIGHT);
p.click_callback.function(boost::bind(&LLToastScriptQuestion::onButtonClicked, this, form_element["name"].asString()));
p.rect.left = LEFT_PAD;
p.rect.width = font->getWidth(form_element["text"].asString());
p.auto_resize = true;
p.follows.flags(FOLLOWS_LEFT | FOLLOWS_BOTTOM);
p.image_color(LLUIColorTable::instance().getColor("ButtonCautionImageColor"));
p.image_color_disabled(LLUIColorTable::instance().getColor("ButtonCautionImageColor"));
LLButton* button = LLUICtrlFactory::create<LLButton>(p);
button->autoResize();
getChild<LLPanel>("buttons_panel")->addChild(button);
LLRect rect = button->getRect();
rect.setLeftTopAndSize(buttons_width, rect.mTop, rect.getWidth(), rect.getHeight());
button->setRect(rect);
buttons_width += rect.getWidth() + LEFT_PAD;
}
}
}
void LLToastScriptQuestion::onButtonClicked(std::string btn_name)
{
LLSD response = mNotification->getResponseTemplate();
response[btn_name] = true;
mNotification->respond(response);
}

View File

@ -0,0 +1,49 @@
/**
* @file lltoastscriptquestion.h
*
* $LicenseInfo:firstyear=2010&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2012, 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 "lltoastpanel.h"
#ifndef LLTOASTSCRIPTQUESTION_H_
#define LLTOASTSCRIPTQUESTION_H_
class LLToastScriptQuestion : public LLToastPanel
{
LOG_CLASS(LLToastScriptQuestion);
public:
LLToastScriptQuestion(const LLNotificationPtr& notification);
virtual BOOL postBuild();
virtual ~LLToastScriptQuestion(){};
private:
void snapToMessageHeight();
void createButtons();
void onButtonClicked(std::string btn_name);
};
#endif /* LLTOASTSCRIPTQUESTION_H_ */

View File

@ -6373,31 +6373,30 @@ Is this OK?
<notification
icon="notify.tga"
name="ScriptQuestionCaution"
priority="high"
priority="critical"
persist="true"
type="notify">
An object named &apos;&lt;nolink&gt;[OBJECTNAME]&lt;/nolink&gt;&apos;, owned by &apos;[NAME]&apos; would like to:
Warning: The object &apos;&lt;nolink&gt;[OBJECTNAME]&lt;/nolink&gt;&apos; wants total access to your Linden Dollars account. If you allow access, it can remove funds from your account at any time, or empty your account completely, on an ongoing basis with no additional warnings.
It is rare that such a request is legitimate. Do not allow access if you do not fully understand why it wants access to your account.
[QUESTIONS]
If you do not trust this object and its creator, you should deny the request.
Grant this request?
<tag>confirm</tag>
<form name="form">
<button
index="0"
name="Grant"
text="Grant"/>
text="Allow total access"/>
<button
default="true"
index="1"
name="Deny"
text="Deny"/>
<button
index="2"
name="Details"
text="Details..."/>
</form>
<footer>
If you allow access to your account, you will also be allowing the object to:
Animate your avatar
Act on your control inputs
</footer>
</notification>
<notification

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<panel
background_opaque="false"
border_visible="false"
background_visible="true"
bg_alpha_color="PanelNotificationBackground"
bg_opaque_color="PanelNotificationBackground"
chrome="true"
height="270"
label="script_question_panel"
layout="topleft"
left="0"
name="panel_script_question_toast"
top="0"
width="305">
<text
follows="left|right|top"
font="SansSerifBold"
height="150"
layout="topleft"
left="10"
mouse_opaque="false"
name="top_info_message"
parse_highlights="true"
parse_urls="true"
text_color="NotifyCautionBoxColor"
top="10"
value=""
width="285"
wrap="true"/>
<panel
background_visible="false"
follows="left|right|top"
height="30"
label="buttons_panel"
layout="topleft"
name="buttons_panel"
top_pad="10"
width="285">
</panel>
<text
follows="all"
font="SansSerifBold"
height="55"
layout="topleft"
mouse_opaque="false"
name="bottom_info_message"
parse_highlights="true"
parse_urls="true"
text_color="NotifyCautionBoxColor"
top_pad="5"
value=""
width="285"
wrap="true"/>
</panel>