Option to show (group) IMs in nearby chat plus separate save option. Fixes FIRE-1086

master
Ansariel 2011-07-18 21:06:58 +02:00
parent f4c861b566
commit 8485bff29b
8 changed files with 157 additions and 25 deletions

View File

@ -50,7 +50,8 @@ typedef enum e_chat_type
CHAT_TYPE_STOP = 5,
CHAT_TYPE_DEBUG_MSG = 6,
CHAT_TYPE_REGION = 7,
CHAT_TYPE_OWNER = 8
CHAT_TYPE_OWNER = 8,
CHAT_TYPE_IM = 9 // Ansariel: Special type for IMs in nearby chat
} EChatType;
typedef enum e_chat_audible_level

View File

@ -2,6 +2,28 @@
<llsd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="llsd.xsd">
<map>
<key>FSShowIMInChatHistory</key>
<map>
<key>Comment</key>
<string>If true, IM will also be shown in the nearby chat history.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>FSLogIMInChatHistory</key>
<map>
<key>Comment</key>
<string>If true, IM will also be logged in the nearby chat history if logging nearby chat and showing IMs in nearby chat is enabled.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>FSPaymentInfoInChat</key>
<map>
<key>Comment</key>

View File

@ -307,12 +307,13 @@ public:
{
user_name->setValue( LLSD() );
LLAvatarNameCache::get(mAvatarID,
boost::bind(&LLChatHistoryHeader::onAvatarNameCache, this, _1, _2));
boost::bind(&LLChatHistoryHeader::onAvatarNameCache, this, _1, _2, chat.mChatType));
}
else
{
// If the agent's chat was subject to @shownames=n we should display their anonimized name
mFrom = chat.mFromName;
if (chat.mChatType == CHAT_TYPE_IM) mFrom = LLTrans::getString("IMPrefix") + " " + mFrom;
user_name->setValue(mFrom);
user_name->setToolTip(mFrom);
setToolTip(mFrom);
@ -331,12 +332,13 @@ public:
username_end == (chat.mFromName.length() - 1))
{
user_name->setValue( LLSD() );
LLAvatarNameCache::get(mAvatarID, boost::bind(&LLChatHistoryHeader::onAvatarNameCache, this, _1, _2));
LLAvatarNameCache::get(mAvatarID, boost::bind(&LLChatHistoryHeader::onAvatarNameCache, this, _1, _2, chat.mChatType));
}
else
{
// If the agent's chat was subject to @shownames=n we should display their anonimized name
mFrom = chat.mFromName;
if (chat.mChatType == CHAT_TYPE_IM) mFrom = LLTrans::getString("IMPrefix") + " " + mFrom;
user_name->setValue(mFrom);
user_name->setToolTip(mFrom);
setToolTip(mFrom);
@ -431,12 +433,13 @@ public:
}
}
void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name)
void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name, EChatType chat_type)
{
mFrom = av_name.mDisplayName;
if (chat_type == CHAT_TYPE_IM) mFrom = LLTrans::getString("IMPrefix") + " " + mFrom;
LLTextBox* user_name = getChild<LLTextBox>("user_name");
user_name->setValue( LLSD(av_name.mDisplayName ) );
user_name->setValue( LLSD(mFrom) );
user_name->setToolTip( av_name.mUsername );
if (gSavedSettings.getBOOL("NameTagShowUsernames") && LLAvatarNameCache::useDisplayNames())
@ -917,6 +920,12 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL
// reset the style parameter for the header only -AO
link_params.color(header_name_color);
link_params.readonly_color(header_name_color);
if (chat.mChatType == CHAT_TYPE_IM)
{
mEditor->appendText(LLTrans::getString("IMPrefix") + " ", false, link_params);
}
if ((gSavedSettings.getBOOL("NameTagShowUsernames")) && (gSavedSettings.getBOOL("UseDisplayNames")))
{
checkDisplayName();
@ -938,7 +947,14 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL
}
else
{
mEditor->appendText(chat.mFromName + delimiter, false, style_params);
if (chat.mChatType == CHAT_TYPE_IM)
{
mEditor->appendText(LLTrans::getString("IMPrefix") + " " + chat.mFromName + delimiter, false, style_params);
}
else
{
mEditor->appendText(chat.mFromName + delimiter, false, style_params);
}
}
}
}
@ -952,7 +968,10 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL
LLDate new_message_time = LLDate::now();
if (mLastFromName == chat.mFromName
std::string tmp_from_name(chat.mFromName);
if (chat.mChatType == CHAT_TYPE_IM) tmp_from_name = LLTrans::getString("IMPrefix") + " " + tmp_from_name;
if (mLastFromName == tmp_from_name
&& mLastFromID == chat.mFromID
&& mLastMessageTime.notNull()
&& (new_message_time.secondsSinceEpoch() - mLastMessageTime.secondsSinceEpoch()) < 60.0
@ -994,7 +1013,9 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL
widget_associated_text += chat.mFromName + delimiter;
mEditor->appendWidget(p, widget_associated_text, false);
mLastFromName = chat.mFromName;
if (chat.mChatType == CHAT_TYPE_IM) mLastFromName = LLTrans::getString("IMPrefix") + " " + mLastFromName;
mLastFromID = chat.mFromID;
mLastMessageTime = new_message_time;
mIsLastMessageFromLog = message_from_log;

View File

@ -810,7 +810,24 @@ bool LLIMModel::addToHistory(const LLUUID& session_id, const std::string& from,
return false;
}
session->addMessage(from, from_id, utf8_text, LLLogChat::timestamp(false)); //might want to add date separately
std::string timestr = LLLogChat::timestamp(false);
session->addMessage(from, from_id, utf8_text, timestr); //might want to add date separately
// Ansariel: Forward IM to nearby chat if wanted
static LLCachedControl<bool> show_im_in_chat(gSavedSettings, "FSShowIMInChatHistory");
if (show_im_in_chat)
{
LLChat chat;
chat.mChatStyle = CHAT_STYLE_NORMAL;
chat.mChatType = CHAT_TYPE_IM;
chat.mFromID = from_id;
chat.mFromName = from;
chat.mSourceType = CHAT_SOURCE_AGENT;
chat.mText = utf8_text;
chat.mTimeStr = timestr;
LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat", LLSD());
nearby_chat->addMessage(chat, true, LLSD());
}
return true;
}

View File

@ -573,6 +573,18 @@ bool LLChatLogParser::parse(std::string& raw, LLSD& im)
bool has_name = name_and_text[IDX_NAME].matched;
std::string name = name_and_text[IDX_NAME];
// Ansariel: Handle the case an IM was stored in nearby chat history
if (name == "IM:")
{
U32 divider_pos = stuff.find(NAME_TEXT_DIVIDER, 3);
if (divider_pos != std::string::npos && divider_pos < (stuff.length() - NAME_TEXT_DIVIDER.length()))
{
im[IM_FROM] = stuff.substr(0, divider_pos);
im[IM_TEXT] = stuff.substr(divider_pos + NAME_TEXT_DIVIDER.length());
return true;
}
}
//we don't need a name/text separator
if (has_name && name.length() && name[name.length()-1] == ':')
{

View File

@ -291,6 +291,16 @@ void LLNearbyChat::addMessage(const LLChat& chat,bool archive,const LLSD &args)
{
from_name = av_name.getCompleteName();
}
// Ansariel: Handle IMs in nearby chat
if (gSavedSettings.getBOOL("FSShowIMInChatHistory") && chat.mChatType == CHAT_TYPE_IM)
{
if (gSavedSettings.getBOOL("FSLogIMInChatHistory"))
{
from_name = "IM: " + from_name;
}
else return;
}
}
LLLogChat::saveHistory("chat", from_name, chat.mFromID, chat.mText);
@ -562,6 +572,7 @@ void LLNearbyChat::loadHistory()
std::list<LLSD>::const_iterator it = history.begin();
while (it != history.end())
{
bool im_type = false;
const LLSD& msg = *it;
std::string from = msg[IM_FROM];
@ -572,6 +583,17 @@ void LLNearbyChat::loadHistory()
}
else
{
// Ansariel: Strip IM prefix so we can properly
// retrieve the UUID in case we got a
// saved IM in nearby chat history.
std::string im_prefix = "IM: ";
size_t im_prefix_found = from.find(im_prefix);
if (im_prefix_found != std::string.npos)
{
from = from.substr(im_prefix.length());
im_type = true;
}
std::string legacy_name = gCacheName->buildLegacyName(from);
gCacheName->getUUID(legacy_name, from_id);
}
@ -583,6 +605,8 @@ void LLNearbyChat::loadHistory()
chat.mTimeStr = msg[IM_TIME].asString();
chat.mChatStyle = CHAT_STYLE_HISTORY;
if (im_type) chat.mChatType = CHAT_TYPE_IM;
chat.mSourceType = CHAT_SOURCE_AGENT;
if (from_id.isNull() && SYSTEM_FROM == from)
{

View File

@ -705,7 +705,7 @@
right="-1"
follows="all"
label="Chat"
name="tab1-2" >
name="firestorm_chat" >
<tab_container
label="Firestorm Prefs"
@ -721,7 +721,7 @@
<!--Chat: General-->
<panel
border="true"
top_pad="5"
top_pad="1"
bottom="-1"
left="1"
right="-1"
@ -733,7 +733,7 @@
name="chat_and_in_enhancements"
follows="left|top"
layout="topleft"
top_pad="15"
top_pad="5"
left="24"
height="10"
width="180">
@ -754,7 +754,7 @@
label="Emotes use italic font"
layout="topleft"
top_pad="0"
height="20"
height="18"
width="400" />
<check_box
control_name="AutoCloseOOC"
@ -762,7 +762,7 @@
label="Auto-close ((OOC)) parentheses"
layout="topleft"
top_pad="0"
height="20"
height="18"
width="400" />
<check_box
control_name="OnlineOfflinetoNearbyChat"
@ -770,7 +770,7 @@
label="Friend on/off-line notices to Nearby Chat"
layout="topleft"
top_pad="0"
height="20"
height="18"
width="400" />
<check_box
control_name="ShowStreamMetadata"
@ -778,7 +778,7 @@
label="Show stream title in local chat"
layout="topleft"
top_pad="0"
height="20"
height="18"
width="400" />
<check_box
control_name="StreamMetadataAnnounceToChat"
@ -786,7 +786,7 @@
label="Announce stream title to chat channel:"
layout="topleft"
top_pad="0"
height="20"
height="18"
width="240" />
<spinner
top_delta="-2"
@ -794,7 +794,7 @@
decimal_digits="0"
layout="topleft"
follows="left|top"
height="20"
height="18"
left_pad="5"
increment="1"
initial_val="362394"
@ -817,7 +817,7 @@
follows="left|top"
layout="topleft"
left_pad="0"
height="20"
height="18"
width="130"
text_color="White_25">
(requires restart)
@ -828,7 +828,39 @@
top_pad="0"
left="20"
width="400"
height="20"
height="18"
name="FSShowIMInChatHistory"
control_name="FSShowIMInChatHistory"
label="Show IMs in nearby chat window"/>
<check_box
layout="topleft"
follows="left|top"
top_pad="0"
left="30"
width="155"
height="18"
name="FSLogIMInChatHistory"
control_name="FSLogIMInChatHistory"
label="Save IMs in nearby chat"/>
<text
top_delta="2"
name="requires_save_chat_logs"
follows="left|top"
layout="topleft"
left_pad="0"
height="18"
width="200"
text_color="White_25">
(requires saving nearby chat logs)
</text>
<check_box
layout="topleft"
follows="left|top"
top_pad="0"
left="20"
width="400"
height="18"
name="PhoenixUseNearbyChatConsole"
control_name="PhoenixUseNearbyChatConsole"
label="Use console for chat popups instead of floating toasts (Viewer 1.x style)"/>
<check_box
@ -836,7 +868,8 @@
follows="left|top"
top_pad="0"
width="50"
height="20"
height="18"
name="PhoenixLogImToChatConsole"
control_name="PhoenixLogImToChatConsole"
label="Show IMs and group chat in chat console"/>
<check_box
@ -844,7 +877,8 @@
follows="left|top"
top_pad="0"
width="200"
height="20"
height="18"
name="ChatFullWidth"
control_name="ChatFullWidth"
label="Use full screen width for console"/>
<text
@ -918,7 +952,7 @@
top_pad="0"
left="20"
width="50"
height="20"
height="18"
control_name="FSPaymentInfoInChat"
name="FSPaymentInfoInChat"
label="Show L$ transactions in local chat instead of toasts"/>
@ -927,7 +961,7 @@
follows="left|top"
top_pad="0"
width="50"
height="20"
height="18"
control_name="PhoenixMuteAllGroups"
name="PhoenixMuteAllGroups"
label="Disable ALL group chats"/>
@ -936,14 +970,14 @@
follows="left|top"
top_pad="0"
width="50"
height="20"
height="18"
control_name="PhoenixMuteGroupWhenNoticesDisabled"
name="PhoenixMuteGroupWhenNoticesDisabled"
label="When 'Receive group notices' is disabled, disable group chat as well"/>
<button
layout="topleft"
follows="left|top"
top_pad="10"
top_pad="5"
width="250"
height="22"
mouse_opaque="true"

View File

@ -3500,4 +3500,5 @@ Abuse Report</string>
<string name="Z">Z</string>
<!-- Key names end -->
<string name="IMPrefix">IM:</string>
</strings>