Commit 7e3610ef authored by Cinder's avatar Cinder
Browse files

Looking for bugs, rewriting chat...

parent d172c06f
......@@ -38,7 +38,6 @@
#include "alchatcommand.h"
#include "llagent.h"
#include "llgesturemgr.h"
#include "llviewergesture.h" // for triggering gestures
#include "llviewermenu.h" // for deleting object with DEL key
#include "llmultigesture.h"
#include "llviewerchat.h"
......@@ -189,9 +188,8 @@ void LLChatBar::refreshGestures()
// collect list of unique gestures
std::map <std::string, BOOL> unique;
LLGestureMgr::item_map_t::const_iterator it;
const LLGestureMgr::item_map_t& active_gestures = LLGestureMgr::instance().getActiveGestures();
for (it = active_gestures.begin(); it != active_gestures.end(); ++it)
for (auto it = active_gestures.cbegin(); it != active_gestures.cend(); ++it)
{
LLMultiGesture* gesture = (*it).second;
if (gesture)
......@@ -203,9 +201,7 @@ void LLChatBar::refreshGestures()
}
}
// add unique gestures
std::map <std::string, BOOL>::iterator it2;
for (it2 = unique.begin(); it2 != unique.end(); ++it2)
for (auto it2 = unique.begin(); it2 != unique.end(); ++it2)
{
mGestureCombo->addSimpleElement((*it2).first);
}
......@@ -226,27 +222,6 @@ void LLChatBar::refreshGestures()
}
}
// Move the cursor to the correct input field.
void LLChatBar::setKeyboardFocus(BOOL focus)
{
if (focus)
{
if (mInputEditor)
{
mInputEditor->setFocus(TRUE);
mInputEditor->selectAll();
}
}
else if (gFocusMgr.childHasKeyboardFocus(this))
{
if (mInputEditor)
{
mInputEditor->deselect();
}
setFocus(FALSE);
}
}
// Ignore arrow keys in chat bar
void LLChatBar::setIgnoreArrowKeys(BOOL b)
......@@ -257,12 +232,12 @@ void LLChatBar::setIgnoreArrowKeys(BOOL b)
}
}
BOOL LLChatBar::inputEditorHasFocus()
BOOL LLChatBar::inputEditorHasFocus() const
{
return mInputEditor && mInputEditor->hasFocus();
}
std::string LLChatBar::getCurrentChat()
std::string LLChatBar::getCurrentChat() const
{
return mInputEditor ? mInputEditor->getText() : LLStringUtil::null;
}
......@@ -290,54 +265,7 @@ void LLChatBar::setGestureCombo(LLComboBox* combo)
void LLChatBar::sendChat( EChatType type )
{
if (mInputEditor)
{
LLWString text = mInputEditor->getWText();
LLWStringUtil::trim(text);
LLWStringUtil::replaceChar(text,182,'\n'); // Convert paragraph symbols back into newlines.
if (!text.empty())
{
// store sent line in history, duplicates will get filtered
if (mInputEditor) mInputEditor->updateHistory();
// Check if this is destined for another channel
S32 channel = 0;
stripChannelNumber(text, &channel);
std::string utf8text = wstring_to_utf8str(text);
// Try to trigger a gesture, if not chat to a script.
std::string utf8_revised_text;
if (0 == channel)
{
applyMUPose(utf8text);
// discard returned "found" boolean
if(!LLGestureMgr::instance().triggerAndReviseString(utf8text, &utf8_revised_text))
{
utf8_revised_text = utf8text;
}
}
else
{
utf8_revised_text = utf8text;
}
utf8_revised_text = utf8str_trim(utf8_revised_text);
type = processChatTypeTriggers(type, utf8_revised_text);
if (!utf8_revised_text.empty())
{
if(!ALChatCommand::parseCommand(utf8_revised_text))
{
// Chat with animation
sendChatFromViewer(utf8_revised_text, type, gSavedSettings.getBOOL("PlayChatAnim"));
}
}
}
mInputEditor->setText(LLStringUtil::null);
}
gAgent.stopTyping();
LLChatUtilities::processChat(mInputEditor, type);
// If the user wants to stop chatting on hitting return, lose focus
// and go out of chat mode.
......
......@@ -55,23 +55,16 @@ public:
void refresh() override;
void refreshGestures();
// Move cursor into chat input field.
void setKeyboardFocus(BOOL b);
// Ignore arrow keys for chat bar
void setIgnoreArrowKeys(BOOL b);
BOOL inputEditorHasFocus();
std::string getCurrentChat();
BOOL inputEditorHasFocus() const;
std::string getCurrentChat() const;
// since chat bar logic is reused for chat history
// gesture combo box might not be a direct child
void setGestureCombo(LLComboBox* combo);
// callbacks
void onClickSay(LLUICtrl* ctrl);
static void onTabClick( void* userdata );
static void onInputEditorKeystroke(LLLineEditor* caller, void* userdata);
static void onInputEditorFocusLost();
static void onInputEditorGainFocus();
......@@ -87,7 +80,6 @@ protected:
~LLChatBar();
void sendChat(EChatType type);
void updateChat();
LLLineEditor* mInputEditor;
......
......@@ -26,17 +26,17 @@
*/
#include "llviewerprecompiledheaders.h"
#include "llchatutilities.h"
#include "message.h"
#include "llagent.h"
#include "llanimationstates.h"
#include "llchatutilities.h"
#include "llcommandhandler.h"
#include "llmediactrl.h"
#include "llviewercontrol.h"
#include "llviewerstats.h"
// legacy callback glue
extern void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel);
......
......@@ -28,8 +28,17 @@
#include "llchat.h"
#include "llagent.h"
#include "llgesturemgr.h"
#include "alchatcommand.h"
#include <type_traits>
namespace LLChatUtilities
{
template <typename T>
void processChat(T* editor, EChatType type);
// Send a chat (after stripping /20foo channel chats).
// "Animate" means the nodding animation for regular text.
void sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL animate);
......@@ -40,6 +49,67 @@ namespace LLChatUtilities
LLWString stripChannelNumber(const LLWString &mesg, S32* channel);
EChatType processChatTypeTriggers(EChatType type, std::string &str);
void applyMUPose(std::string& text);
template <class T> void processChat(T* editor, EChatType type);
}
template<typename> struct Void { using type = void; };
template<typename, typename = void> struct has_getWText : std::false_type {};
template<typename T>
struct has_getWText<T, typename Void<decltype(std::declval<T*>()->getWText())>::type> : std::true_type {};
template <class T>
void LLChatUtilities::processChat(T* editor, EChatType type)
{
static_assert(has_getWText<T>::value, "Class must implement getWText()");
//static_assert(has_setText<T>::value, "Class must implement setText(const std::string&)");
if (editor)
{
LLWString text = editor->getWText();
LLWStringUtil::trim(text);
LLWStringUtil::replaceChar(text, 182, '\n'); // Convert paragraph symbols back into newlines.
if (!text.empty())
{
// Check if this is destined for another channel
S32 channel = 0;
stripChannelNumber(text, &channel);
std::string utf8text = wstring_to_utf8str(text);
// Try to trigger a gesture, if not chat to a script.
std::string utf8_revised_text;
if (0 == channel)
{
applyMUPose(utf8text);
// discard returned "found" boolean
if (!LLGestureMgr::instance().triggerAndReviseString(utf8text, &utf8_revised_text))
{
utf8_revised_text = utf8text;
}
}
else
{
utf8_revised_text = utf8text;
}
utf8_revised_text = utf8str_trim(utf8_revised_text);
type = processChatTypeTriggers(type, utf8_revised_text);
if (!utf8_revised_text.empty())
{
if (!ALChatCommand::parseCommand(utf8_revised_text))
{
// Chat with animation
sendChatFromViewer(utf8_revised_text, type, gSavedSettings.getBOOL("PlayChatAnim"));
}
}
}
editor->setText(LLStringUtil::null);
}
gAgent.stopTyping();
}
#endif // LL_CHATUTILITIES_H
......@@ -398,21 +398,21 @@ void LLConversationViewSession::setVisibleIfDetached(BOOL visible)
}
}
LLFloater* LLConversationViewSession::getSessionFloater()
LLFloater* LLConversationViewSession::getSessionFloater() const
{
LLFolderViewModelItem* item = mViewModelItem;
LLUUID session_uuid = dynamic_cast<LLConversationItem*>(item)->getUUID();
return LLFloaterIMSessionTab::getConversation(session_uuid);
}
LLConversationViewParticipant* LLConversationViewSession::findParticipant(const LLUUID& participant_id)
LLConversationViewParticipant* LLConversationViewSession::findParticipant(const LLUUID& participant_id) const
{
// This is *not* a general tree parsing algorithm. We search only in the mItems list
// assuming there is no mFolders which makes sense for sessions (sessions don't contain
// sessions).
LLConversationViewParticipant* participant = nullptr;
items_t::const_iterator iter;
for (iter = getItemsBegin(); iter != getItemsEnd(); iter++)
for (iter = getItemsBegin(); iter != getItemsEnd(); ++iter)
{
participant = dynamic_cast<LLConversationViewParticipant*>(*iter);
if (participant->hasSameValue(participant_id))
......@@ -456,8 +456,7 @@ void LLConversationViewSession::refresh()
mSpeakingIndicator->setVisible(false);
}
LLConversationViewParticipant* participant = nullptr;
items_t::const_iterator iter;
for (iter = getItemsBegin(); iter != getItemsEnd(); iter++)
for (items_t::const_iterator iter = getItemsBegin(); iter != getItemsEnd(); ++iter)
{
participant = dynamic_cast<LLConversationViewParticipant*>(*iter);
if (participant)
......@@ -730,7 +729,7 @@ void LLConversationViewParticipant::updateChildren()
}
}
LLView* LLConversationViewParticipant::getItemChildView(EAvatarListItemChildIndex child_view_index)
LLView* LLConversationViewParticipant::getItemChildView(EAvatarListItemChildIndex child_view_index) const
{
LLView* child_view = nullptr;
......
......@@ -81,7 +81,7 @@ public:
void toggleCollapsedMode(bool is_collapsed);
void setVisibleIfDetached(BOOL visible);
LLConversationViewParticipant* findParticipant(const LLUUID& participant_id);
LLConversationViewParticipant* findParticipant(const LLUUID& participant_id) const;
void showVoiceIndicator(bool visible);
void showTypingIndicator(bool visible);
......@@ -91,7 +91,7 @@ public:
/*virtual*/ void setFlashState(bool flash_state) override;
void setHighlightState(bool hihglight_state);
LLFloater* getSessionFloater();
LLFloater* getSessionFloater() const;
private:
......@@ -176,7 +176,7 @@ private:
static S32 sChildrenWidths[ALIC_COUNT];
static void initChildrenWidths(LLConversationViewParticipant* self);
void updateChildren();
LLView* getItemChildView(EAvatarListItemChildIndex child_view_index);
LLView* getItemChildView(EAvatarListItemChildIndex child_view_index) const;
boost::signals2::connection mActiveVoiceChannelConnection;
};
......
This diff is collapsed.
......@@ -34,7 +34,6 @@
// newview
#include "llimview.h"
#include "llevents.h"
#include "llavatarpropertiesprocessor.h"
#include "llgroupmgr.h"
#include "llconversationmodel.h"
#include "llconversationview.h"
......@@ -55,20 +54,20 @@ public:
LLFloaterIMContainer(const LLSD& seed, const Params& params = getDefaultParams());
virtual ~LLFloaterIMContainer();
/*virtual*/ BOOL postBuild() override;
/*virtual*/ void onOpen(const LLSD& key) override;
/*virtual*/ void draw() override;
/*virtual*/ void setMinimized(BOOL b) override;
/*virtual*/ void setVisible(BOOL visible) override;
/*virtual*/ void setVisibleAndFrontmost(BOOL take_focus=TRUE, const LLSD& key = LLSD()) override;
/*virtual*/ void updateResizeLimits() override;
/*virtual*/ void handleReshape(const LLRect& rect, bool by_user) override;
BOOL postBuild() override;
void onOpen(const LLSD& key) override;
void draw() override;
void setMinimized(BOOL b) override;
void setVisible(BOOL visible) override;
void setVisibleAndFrontmost(BOOL take_focus=TRUE, const LLSD& key = LLSD()) override;
void updateResizeLimits() override;
void handleReshape(const LLRect& rect, bool by_user) override;
void onCloseFloater(LLUUID& id);
/*virtual*/ void addFloater(LLFloater* floaterp,
BOOL select_added_floater,
LLTabContainer::eInsertionPoint insertion_point = LLTabContainer::END) override;
void addFloater(LLFloater* floaterp,
BOOL select_added_floater,
LLTabContainer::eInsertionPoint insertion_point = LLTabContainer::END) override;
void returnFloaterToHost();
void showConversation(const LLUUID& session_id);
void selectConversation(const LLUUID& session_id);
......@@ -79,33 +78,32 @@ public:
bool selectNextorPreviousConversation(bool select_next, bool focus_selected = true);
void expandConversation();
/*virtual*/ void tabClose() override;
void tabClose() override;
void showStub(bool visible);
static LLFloater* getCurrentVoiceFloater();
static LLFloaterIMContainer* findInstance();
static LLFloaterIMContainer* getInstance();
static void onCurrentChannelChanged(const LLUUID& session_id);
void collapseMessagesPane(bool collapse);
bool isMessagesPaneCollapsed();
bool isConversationsPaneCollapsed();
bool isMessagesPaneCollapsed() const;
bool isConversationsPaneCollapsed() const;
// Callbacks
static void idle(void* user_data);
// LLIMSessionObserver observe triggers
/*virtual*/ void sessionAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id, BOOL has_offline_msg) override;
/*virtual*/ void sessionActivated(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id) override;
/*virtual*/ void sessionVoiceOrIMStarted(const LLUUID& session_id) override;
/*virtual*/ void sessionRemoved(const LLUUID& session_id) override;
/*virtual*/ void sessionIDUpdated(const LLUUID& old_session_id, const LLUUID& new_session_id) override;
void sessionAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id, BOOL has_offline_msg) override;
void sessionActivated(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id) override;
void sessionVoiceOrIMStarted(const LLUUID& session_id) override;
void sessionRemoved(const LLUUID& session_id) override;
void sessionIDUpdated(const LLUUID& old_session_id, const LLUUID& new_session_id) override;
LLConversationViewModel& getRootViewModel() { return mConversationViewModel; }
LLUUID getSelectedSession() { return mSelectedSession; }
LLUUID getSelectedSession() const { return mSelectedSession; }
void setSelectedSession(LLUUID sessionID) { mSelectedSession = sessionID; }
LLConversationItem* getSessionModel(const LLUUID& session_id) { return get_ptr_in_map(mConversationsItems,session_id); }
LLConversationItem* getSessionModel(const LLUUID& session_id) const { return get_ptr_in_map(mConversationsItems,session_id); }
LLConversationSort& getSortOrder() { return mConversationViewModel.getSorter(); }
// Handling of lists of participants is public so to be common with llfloatersessiontab
......@@ -116,10 +114,10 @@ public:
void assignResizeLimits();
BOOL handleKeyHere(KEY key, MASK mask ) override;
/*virtual*/ void closeFloater(bool app_quitting = false) override;
void closeFloater(bool app_quitting = false) override;
void closeAllConversations();
void closeSelectedConversations(const uuid_vec_t& ids);
/*virtual*/ BOOL isFrontmost() override;
BOOL isFrontmost() override;
private:
......@@ -127,7 +125,7 @@ private:
avatarID_panel_map_t mSessions;
boost::signals2::connection mNewMessageConnection;
/*virtual*/ void computeResizeLimits(S32& new_min_width, S32& new_min_height) override {}
void computeResizeLimits(S32& new_min_width, S32& new_min_height) override {}
void onNewMessageReceived(const LLSD& data);
......@@ -136,8 +134,8 @@ private:
void processParticipantsStyleUpdate();
void onSpeakButtonPressed();
void onSpeakButtonReleased();
/*virtual*/ void onClickCloseBtn(bool app_quitting = false) override;
/*virtual*/ void closeHostedFloater() override;
void onClickCloseBtn(bool app_quitting = false) override;
void closeHostedFloater() override;
void collapseConversationsPane(bool collapse, bool save_is_allowed=true);
......@@ -152,7 +150,7 @@ private:
void setSortOrderParticipants(const LLConversationFilter::ESortOrderType order);
void setSortOrder(const LLConversationSort& order);
void getSelectedUUIDs(uuid_vec_t& selected_uuids, bool participant_uuids = true);
void getSelectedUUIDs(uuid_vec_t& selected_uuids, bool participant_uuids = true) const;
const LLConversationItem * getCurSelectedViewModelItem();
void getParticipantUUIDs(uuid_vec_t& selected_uuids);
void doToSelected(const LLSD& userdata);
......@@ -169,7 +167,6 @@ private:
bool isGroupModerator();
bool haveAbilityToBan();
bool canBanSelectedMember(const LLUUID& participant_uuid);
LLUUID getGroupUIIDForSelectedParticipant();
bool isMuted(const LLUUID& avatar_id);
void moderateVoice(const std::string& command, const LLUUID& userID);
void moderateVoiceAllParticipants(bool unmute);
......@@ -208,9 +205,9 @@ public:
static bool isConversationLoggingAllowed();
void flashConversationItemWidget(const LLUUID& session_id, bool is_flashes);
void highlightConversationItemWidget(const LLUUID& session_id, bool is_highlighted);
bool isScrolledOutOfSight(LLConversationViewSession* conversation_item_widget);
bool isScrolledOutOfSight(LLConversationViewSession* conversation_item_widget) const;
boost::signals2::connection mMicroChangedSignal;
S32 getConversationListItemSize() { return mConversationsWidgets.size(); }
S32 getConversationListItemSize() const { return mConversationsWidgets.size(); }
typedef std::list<LLFloater*> floater_list_t;
void getDetachedConversationFloaters(floater_list_t& floaters);
......
......@@ -28,39 +28,25 @@
#include "llviewerprecompiledheaders.h"
#include "lliconctrl.h"
#include "llappviewer.h"
#include "llchatentry.h"
#include "llfloaterreg.h"
#include "lltrans.h"
#include "llfloaterimcontainer.h"
#include "llfloatersidepanelcontainer.h"
#include "llfocusmgr.h"
#include "lllogchat.h"
#include "llresizebar.h"
#include "llresizehandle.h"
#include "lldraghandle.h"
#include "llmenugl.h"
#include "llviewermenu.h" // for gMenuHolder
#include "llfloaterimnearbychathandler.h"
#include "llchannelmanager.h"
#include "llchathistory.h"
#include "llstylemap.h"
#include "llavatarnamecache.h"
#include "llfloaterreg.h"
#include "lltrans.h"
#include "llfirstuse.h"
#include "llfloaterimnearbychat.h"
#include "llagent.h" // gAgent
#include "llchatentry.h"
#include "llchatutilities.h"
#include "llgesturemgr.h"
#include "llmultigesture.h"
#include "llkeyboard.h"
#include "llnavigationbar.h"
#include "llwindow.h"
#include "llviewerwindow.h"
#include "llrootview.h"
#include "llviewerchat.h"
#include "lltranslate.h"
#include "llautoreplace.h"
......@@ -359,7 +345,7 @@ bool LLFloaterIMNearbyChat::isChatVisible()
void LLFloaterIMNearbyChat::showHistory()
{
openFloater();
LLFloaterIMContainer::getInstance()->selectConversation(LLUUID(NULL));
LLFloaterIMContainer::getInstance()->selectConversation(LLUUID::null);
if(!isMessagePaneExpanded())
{
......@@ -373,7 +359,7 @@ void LLFloaterIMNearbyChat::showHistory()
setResizeLimits(getMinWidth(), EXPANDED_MIN_HEIGHT);
}
std::string LLFloaterIMNearbyChat::getCurrentChat()
std::string LLFloaterIMNearbyChat::getCurrentChat() const
{
return mInputEditor ? mInputEditor->getText() : LLStringUtil::null;
}
......@@ -503,11 +489,6 @@ void LLFloaterIMNearbyChat::onChatBoxKeystroke()
}
}
//LL_INFOS() << "GESTUREDEBUG " << trigger
// << " len " << length
// << " outlen " << out_str.getLength()
// << LL_ENDL;
}
}
......@@ -525,53 +506,7 @@ void LLFloaterIMNearbyChat::onChatBoxFocusReceived()
void LLFloaterIMNearbyChat::sendChat( EChatType type )
{
if (mInputEditor)
{
LLWString text = mInputEditor->getWText();
LLWStringUtil::trim(text);
LLWStringUtil::replaceChar(text,182,'\n'); // Convert paragraph symbols back into newlines.
if (!text.empty())
{
// Check if this is destined for another channel
S32 channel = 0;
stripChannelNumber(text, &channel);
std::string utf8text = wstring_to_utf8str(text);
// Try to trigger a gesture, if not chat to a script.
std::string utf8_revised_text;
if (0 == channel)
{
applyMUPose(utf8text);
// discard returned "found" boolean
if(!LLGestureMgr::instance().triggerAndReviseString(utf8text, &utf8_revised_text))
{
utf8_revised_text = utf8text;
}
}
else
{
utf8_revised_text = utf8text;
}
utf8_revised_text = utf8str_trim(utf8_revised_text);
type = processChatTypeTriggers(type, utf8_revised_text);
if (!utf8_revised_text.empty())
{
if(!ALChatCommand::parseCommand(utf8_revised_text))
{
// Chat with animation
sendChatFromViewer(utf8_revised_text, type, gSavedSettings.getBOOL("PlayChatAnim"));
}
}
}
mInputEditor->setText(LLStringUtil::null);
}
gAgent.stopTyping();
LLChatUtilities::processChat(mInputEditor, type);
// If the user wants to stop chatting on hitting return, lose focus
// and go out of chat mode.
......
......@@ -30,16 +30,11 @@
#include "llfloaterimsessiontab.h"
#include "llgesturemgr.h"