Skip to content
Snippets Groups Projects
Commit ff81c6c5 authored by Richard Linden's avatar Richard Linden
Browse files

changed format of notification_visibility rules to be cleaner

parent 3081f897
No related branches found
No related tags found
No related merge requests found
...@@ -431,13 +431,30 @@ LLNotificationTemplate::LLNotificationTemplate(const LLNotificationTemplate::Par ...@@ -431,13 +431,30 @@ LLNotificationTemplate::LLNotificationTemplate(const LLNotificationTemplate::Par
mForm = LLNotificationFormPtr(new LLNotificationForm(p.name, p.form_ref.form)); mForm = LLNotificationFormPtr(new LLNotificationForm(p.name, p.form_ref.form));
} }
LLNotificationVisibilityRule::LLNotificationVisibilityRule(const LLNotificationVisibilityRule::Params &p) LLNotificationVisibilityRule::LLNotificationVisibilityRule(const LLNotificationVisibilityRule::Rule &p)
: mVisible(p.visible),
mResponse(p.response),
mType(p.type),
mTag(p.tag),
mName(p.name)
{ {
if (p.show.isChosen())
{
mType = p.show.type;
mTag = p.show.tag;
mName = p.show.name;
mVisible = true;
}
else if (p.hide.isChosen())
{
mType = p.hide.type;
mTag = p.hide.tag;
mName = p.hide.name;
mVisible = false;
}
else if (p.respond.isChosen())
{
mType = p.respond.type;
mTag = p.respond.tag;
mName = p.respond.name;
mVisible = false;
mResponse = p.respond.response;
}
} }
LLNotification::LLNotification(const LLNotification::Params& p) : LLNotification::LLNotification(const LLNotification::Params& p) :
...@@ -1465,18 +1482,9 @@ bool LLNotifications::loadVisibilityRules() ...@@ -1465,18 +1482,9 @@ bool LLNotifications::loadVisibilityRules()
const std::string xml_filename = "notification_visibility.xml"; const std::string xml_filename = "notification_visibility.xml";
std::string full_filename = gDirUtilp->findSkinnedFilename(LLUI::getXUIPaths().front(), xml_filename); std::string full_filename = gDirUtilp->findSkinnedFilename(LLUI::getXUIPaths().front(), xml_filename);
LLXMLNodePtr root;
BOOL success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root);
if (!success || root.isNull() || !root->hasName( "notification_visibility" ))
{
llerrs << "Problem reading UI Notification Visibility Rules file: " << full_filename << llendl;
return false;
}
LLNotificationVisibilityRule::Rules params; LLNotificationVisibilityRule::Rules params;
LLXUIParser parser; LLSimpleXUIParser parser;
parser.readXUI(root, params, full_filename); parser.readXUI(full_filename, params);
if(!params.validateBlock()) if(!params.validateBlock())
{ {
...@@ -1486,7 +1494,8 @@ bool LLNotifications::loadVisibilityRules() ...@@ -1486,7 +1494,8 @@ bool LLNotifications::loadVisibilityRules()
mVisibilityRules.clear(); mVisibilityRules.clear();
for(LLInitParam::ParamIterator<LLNotificationVisibilityRule::Params>::iterator it = params.rules.begin(), end_it = params.rules.end(); for(LLInitParam::ParamIterator<LLNotificationVisibilityRule::Rule>::iterator it = params.rules.begin(),
end_it = params.rules.end();
it != end_it; it != end_it;
++it) ++it)
{ {
......
...@@ -37,34 +37,51 @@ ...@@ -37,34 +37,51 @@
// from the appropriate local language directory). // from the appropriate local language directory).
struct LLNotificationVisibilityRule struct LLNotificationVisibilityRule
{ {
struct Params : public LLInitParam::Block<Params> struct Filter : public LLInitParam::Block<Filter>
{ {
Mandatory<bool> visible; Optional<std::string> type,
Optional<std::string> response; tag,
Optional<std::string> type; name;
Optional<std::string> tag;
Optional<std::string> name; Filter()
: type("type"),
Params()
: visible("visible"),
response("response"),
type("type"),
tag("tag"), tag("tag"),
name("name") name("name")
{} {}
}; };
struct Respond : public LLInitParam::Block<Respond, Filter>
{
Mandatory<std::string> response;
Respond()
: response("response")
{}
};
struct Rule : public LLInitParam::Choice<Rule>
{
Alternative<Filter> show;
Alternative<Filter> hide;
Alternative<Respond> respond;
Rule()
: show("show"),
hide("hide"),
respond("respond")
{}
};
struct Rules : public LLInitParam::Block<Rules> struct Rules : public LLInitParam::Block<Rules>
{ {
Multiple<Params> rules; Multiple<Rule> rules;
Rules() Rules()
: rules("rule") : rules("")
{} {}
}; };
LLNotificationVisibilityRule(const Params& p); LLNotificationVisibilityRule(const Rule& p);
// If true, this rule makes matching notifications visible. Otherwise, it makes them invisible. // If true, this rule makes matching notifications visible. Otherwise, it makes them invisible.
bool mVisible; bool mVisible;
......
<?xml version="1.0" ?> <?xml version="1.0" ?>
<notification_visibility> <notification_visibility>
<rule visible="true"/> <show/>
</notification_visibility> </notification_visibility>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment