Merge branch 'keyword'

This commit is contained in:
TighMacFanatic
2011-05-04 18:06:02 -04:00
10 changed files with 388 additions and 16 deletions

View File

@@ -77,6 +77,7 @@ set(viewer_SOURCE_FILES
cofmgr.cpp
ascentdaycyclemanager.cpp
ascentfloatercontactgroups.cpp
ascentkeyword.cpp
ascentprefssys.cpp
ascentprefsvan.cpp
dhparam.cpp
@@ -549,6 +550,7 @@ set(viewer_HEADER_FILES
cofmgr.h
ascentdaycyclemanager.h
ascentfloatercontactgroups.h
ascentkeyword.h
ascentprefssys.h
ascentprefsvan.h
emerald.h

View File

@@ -673,5 +673,100 @@
<key>Value</key>
<integer>0</integer>
</map>
<key>KeywordsChangeColor</key>
<map>
<key>Comment</key>
<string>change message color if keyword found</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>1</integer>
</map>
<key>KeywordsColor</key>
<map>
<key>Comment</key>
<string>Color of keyword detects messages</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Color4</string>
<key>Value</key>
<array>
<real>1.0</real>
<real>0.600000023842</real>
<real>0.0</real>
<real>1.0</real>
</array>
</map>
<key>KeywordsInChat</key>
<map>
<key>Comment</key>
<string>Look for keywords in local chat</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>1</integer>
</map>
<key>KeywordsInIM</key>
<map>
<key>Comment</key>
<string>Look for keywords in group instant messages</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>1</integer>
</map>
<key>KeywordsList</key>
<map>
<key>Comment</key>
<string>Comma seperated key words to search for</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>String</string>
<key>Value</key>
<string></string>
</map>
<key>KeywordsOn</key>
<map>
<key>Comment</key>
<string>Look for keywords</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>KeywordsPlaySound</key>
<map>
<key>Comment</key>
<string>Play a sound if keyword found</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>KeywordsSound</key>
<map>
<key>Comment</key>
<string>The sound to play if a keyword is found</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>String</string>
<key>Value</key>
<string></string>
</map>
</map>
</llsd>

View File

@@ -0,0 +1,88 @@
/**
* @file ascentprefssys.cpp
* @Ascent Viewer preferences panel
*
* $LicenseInfo:firstyear=2011&license=viewergpl$
*
* Copyright (c) 2011, Tigh MacFanatic.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "ascentkeyword.h"
#include "llviewercontrol.h"
#include <boost/regex.hpp>
BOOL AscentKeyword::hasKeyword(std::string msg,int source)
{
static const LLCachedControl<bool> mKeywordsOn("KeywordsOn", false, gSavedPerAccountSettings);
static const LLCachedControl<bool> mKeywordsInChat("KeywordsInChat", false, gSavedPerAccountSettings);
static const LLCachedControl<bool> mKeywordsInIM("KeywordsInIM", false, gSavedPerAccountSettings);
if (mKeywordsOn)
{
if ((source == 1) && (mKeywordsInChat))
{
return containsKeyWord(msg);
}
if ((source == 2) && (mKeywordsInIM))
{
return containsKeyWord(msg);
}
}
return FALSE;
}
bool AscentKeyword::containsKeyWord(std::string source)
{
static const LLCachedControl<std::string> mKeywordsList("KeywordsList", "", gSavedPerAccountSettings);
static const LLCachedControl<bool> mKeywordsPlaySound("KeywordsPlaySound", false, gSavedPerAccountSettings);
static const LLCachedControl<std::string> mKeywordsSound("KeywordsSound", "", gSavedPerAccountSettings);
std::string s = mKeywordsList;
LLStringUtil::toLower(s);
LLStringUtil::toLower(source);
boost::regex re(",");
boost::sregex_token_iterator i(s.begin(), s.end(), re, -1);
boost::sregex_token_iterator j;
while(i != j)
{
if(source.find( *i++) != std::string::npos)
{
if (mKeywordsPlaySound)
{
LLUI::sAudioCallback(LLUUID(mKeywordsSound));
}
return true;
}
}
return false;
}

View File

@@ -0,0 +1,53 @@
/**
* @file ascentprefssys.cpp
* @Ascent Viewer preferences panel
*
* $LicenseInfo:firstyear=2011&license=viewergpl$
*
* Copyright (c) 2011, Tigh MacFanatic.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#ifndef ASCENTKEYWORD_H
#define ASCENTKEYWORD_H
class AscentKeyword
{
public:
enum MessageSource
{
LocalChat=1,
PrivateMessage=2,
GroupChat=3
};
static BOOL hasKeyword(std::string msg, int source);
private:
static bool containsKeyWord(std::string source);
};
#endif

View File

@@ -51,7 +51,6 @@
#include "lgghunspell_wrapper.h"
LLPrefsAscentSys::LLPrefsAscentSys()
{
LLUICtrlFactory::getInstance()->buildPanel(this, "panel_preferences_ascent_system.xml");
@@ -67,6 +66,9 @@ LLPrefsAscentSys::LLPrefsAscentSys()
childSetAction("EmSpell_Add", onSpellAdd, this);
childSetAction("EmSpell_Remove", onSpellRemove, this);
childSetCommitCallback("Keywords_Alert", onCommitCheckBox, this);
refreshValues();
refresh();
}
@@ -110,6 +112,17 @@ void LLPrefsAscentSys::onCommitCheckBox(LLUICtrl* ctrl, void* user_data)
bool enabled = self->childGetValue("enable_clouds").asBoolean();
self->childSetEnabled("enable_classic_clouds", enabled);
}
else if (ctrl->getName() == "Keywords_Alert")
{
bool enabled = self->childGetValue("Keywords_Alert").asBoolean();
self->childSetEnabled("Keywords_Entries", enabled);
self->childSetEnabled("Keywords_LocalChat", enabled);
self->childSetEnabled("Keywords_IM", enabled);
self->childSetEnabled("Keywords_Highlight", enabled);
self->childSetEnabled("Keywords_Color", enabled);
self->childSetEnabled("Keywords_PlaySound", enabled);
self->childSetEnabled("Keywords_SoundUUID", enabled);
}
}
void LLPrefsAscentSys::onSpellAdd(void* data)
@@ -204,6 +217,15 @@ void LLPrefsAscentSys::refreshValues()
mDisableClickSit = gSavedSettings.getBOOL("DisableClickSit");
//Text Options ------------------------------------------------------------------------
mSpellDisplay = gSavedSettings.getBOOL("SpellDisplay");
mKeywordsOn = gSavedPerAccountSettings.getBOOL("KeywordsOn");
mKeywordsList = gSavedPerAccountSettings.getString("KeywordsList");
mKeywordsInChat = gSavedPerAccountSettings.getBOOL("KeywordsInChat");
mKeywordsInIM = gSavedPerAccountSettings.getBOOL("KeywordsInIM");
mKeywordsChangeColor = gSavedPerAccountSettings.getBOOL("KeywordsChangeColor");
mKeywordsColor = gSavedPerAccountSettings.getColor4("KeywordsColor");
mKeywordsPlaySound = gSavedPerAccountSettings.getBOOL("KeywordsPlaySound");
mKeywordsSound = static_cast<LLUUID>(gSavedPerAccountSettings.getString("KeywordsSound"));
}
void LLPrefsAscentSys::refresh()
@@ -359,10 +381,21 @@ void LLPrefsAscentSys::refresh()
combo->setSimple(std::string(""));
}
childSetValue("Keywords_Alert", mKeywordsOn);
childSetValue("Keywords_Entries", mKeywordsList);
childSetValue("Keywords_LocalChat", mKeywordsInChat);
childSetValue("Keywords_IM", mKeywordsInIM);
childSetValue("Keywords_Highlight", mKeywordsChangeColor);
childSetValue("Keywords_PlaySound", mKeywordsPlaySound);
childSetValue("Keywords_SoundUUID", mKeywordsSound);
LLColorSwatchCtrl* colorctrl = getChild<LLColorSwatchCtrl>("Keywords_Color");
colorctrl->set(LLColor4(mKeywordsColor),TRUE);
}
void LLPrefsAscentSys::cancel()
{
{/*
//General -----------------------------------------------------------------------------
childSetValue("double_click_teleport_check", mDoubleClickTeleport);
childSetValue("center_after_teleport_check", mResetCameraAfterTP);
@@ -412,7 +445,18 @@ void LLPrefsAscentSys::cancel()
//Text Options ------------------------------------------------------------------------
childSetValue("SpellDisplay", mSpellDisplay);
}
childSetValue("Keywords_Alert", mKeywordsOn);
childSetValue("Keywords_Entries", mKeywordsList);
childSetValue("Keywords_LocalChat", mKeywordsInChat);
childSetValue("Keywords_IM", mKeywordsInIM);
childSetValue("Keywords_Highlight", mKeywordsChangeColor);
childSetValue("Keywords_PlaySound", mKeywordsPlaySound);
childSetValue("Keywords_SoundUUID", mKeywordsSound);
LLColorSwatchCtrl* colorctrl = getChild<LLColorSwatchCtrl>("Keywords_Color");
colorctrl->set(LLColor4(mKeywordsColor),TRUE);
*/}
void LLPrefsAscentSys::apply()
{
@@ -549,7 +593,18 @@ void LLPrefsAscentSys::apply()
LLHUDEffectLookAt::sDebugLookAt = childGetValue("show_look_at_check");
gSavedSettings.setBOOL("RevokePermsOnStandUp", childGetValue("revoke_perms_on_stand_up_check"));
gSavedSettings.setBOOL("DisableClickSit", childGetValue("disable_click_sit_check"));
//Text Options ---------------------------------------------------------------------------
gSavedPerAccountSettings.setBOOL("KeywordsOn", childGetValue("Keywords_Alert"));
gSavedPerAccountSettings.setString("KeywordsList", childGetValue("Keywords_Entries"));
gSavedPerAccountSettings.setBOOL("KeywordsInChat", childGetValue("Keywords_LocalChat"));
gSavedPerAccountSettings.setBOOL("KeywordsInIM", childGetValue("Keywords_IM"));
gSavedPerAccountSettings.setBOOL("KeywordsChangeColor", childGetValue("Keywords_Highlight"));
gSavedPerAccountSettings.setColor4("KeywordsColor", childGetValue("Keywords_Color"));
gSavedPerAccountSettings.setBOOL("KeywordsPlaySound", childGetValue("Keywords_PlaySound"));
gSavedPerAccountSettings.setString("KeywordsSound", childGetValue("Keywords_SoundUUID"));
refreshValues();
refresh();
}

View File

@@ -98,6 +98,14 @@ protected:
BOOL mDisableClickSit;
//Text Options ------------------------------------------------------------------------
BOOL mSpellDisplay;
BOOL mKeywordsOn;
std::string mKeywordsList;
BOOL mKeywordsInIM;
BOOL mKeywordsInChat;
BOOL mKeywordsChangeColor;
BOOL mKeywordsPlaySound;
LLUUID mKeywordsSound;
LLColor4 mKeywordsColor;
};
#endif

View File

@@ -75,6 +75,7 @@
#include "llfloaterhtml.h"
#include "llweb.h"
#include "llstylemap.h"
#include "ascentkeyword.h"
// linden library includes
#include "llaudioengine.h"
@@ -595,6 +596,20 @@ LLColor4 get_text_color(const LLChat& chat)
}
}
static const LLCachedControl<bool> mKeywordsChangeColor("KeywordsChangeColor", false, gSavedPerAccountSettings);
static const LLCachedControl<LLColor4> mKeywordsColor("KeywordsColor", LLColor4(1.f, 1.f, 1.f, 1.f), gSavedPerAccountSettings);
if (gAgent.getID() != chat.mFromID)
{
if (mKeywordsChangeColor)
{
if (AscentKeyword::hasKeyword(chat.mText, 1))
{
text_color = mKeywordsColor;
}
}
}
return text_color;
}

View File

@@ -74,6 +74,7 @@
#include "llhttpclient.h"
#include "llmutelist.h"
#include "llstylemap.h"
#include "ascentkeyword.h"
#include "boost/algorithm/string.hpp"
@@ -1592,8 +1593,23 @@ BOOL LLFloaterIMPanel::inviteToSession(const LLDynamicArray<LLUUID>& ids)
return TRUE;
}
void LLFloaterIMPanel::addHistoryLine(const std::string &utf8msg, const LLColor4& color, bool log_to_file, const LLUUID& source, const std::string& name)
void LLFloaterIMPanel::addHistoryLine(const std::string &utf8msg, LLColor4 incolor, bool log_to_file, const LLUUID& source, const std::string& name)
{
static const LLCachedControl<bool> mKeywordsChangeColor("KeywordsChangeColor", false, gSavedPerAccountSettings);
static const LLCachedControl<LLColor4> mKeywordsColor("KeywordsColor", LLColor4(1.f, 1.f, 1.f, 1.f), gSavedPerAccountSettings);
if (gAgent.getID() != source)
{
if (mKeywordsChangeColor)
{
if (AscentKeyword::hasKeyword(utf8msg, 2))
{
incolor = mKeywordsColor;
}
}
}
const LLColor4& color = incolor;
// start tab flashing when receiving im for background session from user
if (source != LLUUID::null)
{

View File

@@ -211,7 +211,7 @@ public:
BOOL inviteToSession(const LLDynamicArray<LLUUID>& agent_ids);
void addHistoryLine(const std::string &utf8msg,
const LLColor4& color = LLColor4::white,
LLColor4 incolor = LLColor4::white,
bool log_to_file = true,
const LLUUID& source = LLUUID::null,
const std::string& name = LLStringUtil::null);

View File

@@ -530,40 +530,80 @@ Use #f for user's first name, #l for last name,
<check_box bottom="-25" enabled="true" follows="left|top" font="SansSerifSmall" height="16"
label="Show misspelled words in red" left="12" mouse_opaque="true" name="SpellDisplay"
control_name="SpellDisplay" width="126"/>
<text bottom_delta="-30" follows="left|top" font="SansSerifSmall" height="16" left="12"
<text bottom_delta="-24" follows="left|top" font="SansSerifSmall" height="16" left="12"
name="EmSpell_txt1" width="512">
Current language (dictionary):
</text>
<combo_box allow_text_entry="false" bottom_delta="-20" left_delta="0" follows="left|top" height="18"
<combo_box allow_text_entry="false" bottom_delta="-20" left_delta="0" follows="left|top" height="20"
max_chars="200" mouse_opaque="true" name="SpellBase" width="250"
control_name="SpellBase" tool_tip=""/>
<text bottom_delta="-30" follows="left|top" font="SansSerifSmall" height="16" left="12"
<text bottom_delta="-24" follows="left|top" font="SansSerifSmall" height="20" left="12"
name="EmSpell_txt3" width="512">
Downloaded languages (dictionaries):
</text>
<combo_box allow_text_entry="false" bottom_delta="-20" left_delta="0" follows="left|top" height="18"
<combo_box allow_text_entry="false" bottom_delta="-20" left_delta="0" follows="left|top" height="20"
max_chars="200" mouse_opaque="true" name="EmSpell_Avail" width="250"
control_name="EmSpell_Avail" tool_tip=""/>
<button bottom_delta="0" follows="left|top" font="SansSerifSmall" height="20" label="Install"
name="EmSpell_Add" tool_tip="" left_delta="255" width="80"/>
<button bottom_delta="-22" follows="left|top" font="SansSerifSmall" height="20" label="Download More..."
name="EmSpell_GetMore" tool_tip="Get more dictionaries availabe online" left="12" width="250"/>
<text bottom_delta="-30" follows="left|top" font="SansSerifSmall" height="16" left="12"
<text bottom_delta="-24" follows="left|top" font="SansSerifSmall" height="20" left="12"
name="EmSpell_txt2" width="512">
Additional custom languages (dictionaries):
</text>
<combo_box allow_text_entry="false" bottom_delta="-20" left_delta="0" follows="left|top" height="18"
<combo_box allow_text_entry="false" bottom_delta="-20" left_delta="0" follows="left|top" height="20"
max_chars="200" mouse_opaque="true" name="EmSpell_Installed" width="250"
control_name="EmSpell_Installed" tool_tip=""/>
<button bottom_delta="0" follows="left|top" font="SansSerifSmall" height="20" label="Remove"
name="EmSpell_Remove" tool_tip="" left_delta="255" width="80"/>
<button bottom_delta="-20" follows="left|top" font="SansSerifSmall" height="18" label="Edit Custom dictionary"
<button bottom_delta="-20" follows="left|top" font="SansSerifSmall" height="20" label="Edit Custom dictionary"
name="EmSpell_EditCustom" tool_tip="" left="12" width="250"/>
<text bottom_delta="-30" follows="left|top" font="SansSerifSmall" height="16" left="12"
<text bottom_delta="-24" follows="left|top" font="SansSerifSmall" height="20" left="12"
name="EmSpell_txt4" width="512">
To use spellcheck, right-click a misspelled word
(red or otherwise) and select its replacement
To use spellcheck, right-click a misspelled word
(red or otherwise) and select its replacement
</text>
<view_border bevel_style="none" border_thickness="1" bottom_delta="-16" follows="top|left" height="0"
left="5" name="CmdDivisor" width="356"/>
<check_box bottom_delta="-24" enabled="true" follows="left|top" font="SansSerifSmall" height="16"
label="Highlight messages if any of they contain the terms" left="5" mouse_opaque="true"
name="Keywords_Alert" radio_style="false" width="270"/>
<text bottom_delta="-20" follows="left|top" font="SansSerifSmall" height="20" left="12"
name="keyword_txt1" width="512">
(separated by commas)
</text>
<line_editor bevel_style="in" border_style="line" border_thickness="1" bottom_delta="-20" follows="left|top"
font="SansSerifSmall" height="20" left_delta="5" max_length="500" mouse_opaque="true" name="Keywords_Entries" width="300" />
<text bottom_delta="-24" follows="left|top" font="SansSerifSmall" height="20" left_delta="15" name="EmKeyw"
width="100">Is found within:</text>
<check_box bottom_delta="3" enabled="true" follows="left|top" font="SansSerifSmall" height="16"
label="Local Chat Floater" left_delta="100" mouse_opaque="true" name="Keywords_LocalChat" radio_style="false" width="270"/>
<check_box bottom_delta="-15" enabled="true" follows="left|top" font="SansSerifSmall" height="16"
label="Instant Message Floater" left_delta="0" mouse_opaque="true" name="Keywords_IM" radio_style="false" width="270"/>
<check_box bottom_delta="-24" enabled="true" follows="left|top" font="SansSerifSmall" height="16"
label="Highlight the message in this color:" left_delta="-110" mouse_opaque="true" name="Keywords_Highlight"
radio_style="false" width="270"/>
<color_swatch border_color="0.45098, 0.517647, 0.607843, 1" bottom_delta="-16" can_apply_immediately="true"
color="1, 1, 1, 1" follows="left|top" height="35" label="" left_delta="210"
mouse_opaque="true" name="Keywords_Color" tool_tip="Click to open Color Picker" width="50"/>
<check_box bottom_delta="-10" enabled="true" follows="left|top" font="SansSerifSmall" height="16"
label="Play this sound alert: (UUID)" left_delta="-210" mouse_opaque="true" name="Keywords_PlaySound"
radio_style="false" width="270"/>
<line_editor bevel_style="in" border_style="line" border_thickness="1" bottom_delta="-20" follows="left|top"
font="SansSerifSmall" height="20" left_delta="-5" max_length="36" mouse_opaque="true" name="Keywords_SoundUUID" width="300" />
</panel>
</tab_container>