diff --git a/indra/newview/llimpanel.cpp b/indra/newview/llimpanel.cpp index 71e1ec865..9e37cacc8 100644 --- a/indra/newview/llimpanel.cpp +++ b/indra/newview/llimpanel.cpp @@ -278,87 +278,46 @@ bool send_start_session_messages( // LLFloaterIMPanel // LLFloaterIMPanel::LLFloaterIMPanel( - const std::string& session_label, + const std::string& log_label, const LLUUID& session_id, const LLUUID& other_participant_id, - EInstantMessage dialog) : - LLFloater(session_label, LLRect(), session_label), + const EInstantMessage& dialog, + const LLDynamicArray& ids) : + LLFloater(log_label, LLRect(), log_label), + mStartCallOnInitialize(false), mInputEditor(NULL), mHistoryEditor(NULL), - mSessionUUID(session_id), - mVoiceChannel(NULL), - mSessionInitialized(FALSE), + mSessionInitialized(false), mSessionStartMsgPos(0), + mSessionType(P2P_SESSION), + mSessionUUID(session_id), + mLogLabel(log_label), + mQueuedMsgsForInit(), mOtherParticipantUUID(other_participant_id), mDialog(dialog), - mTyping(FALSE), - mOtherTyping(FALSE), + mTyping(false), mTypingLineStartIndex(0), - mSentTypingState(TRUE), + mOtherTyping(false), + mOtherTypingName(), mNumUnreadMessages(0), - mShowSpeakersOnConnect(TRUE), - mStartCallOnInitialize(false), - mTextIMPossible(TRUE), - mProfileButtonEnabled(TRUE), - mCallBackEnabled(TRUE), + mSentTypingState(true), + mShowSpeakersOnConnect(true), + mDing(false), + mRPMode(false), + mTextIMPossible(true), + mCallBackEnabled(true), mSpeakers(NULL), mSpeakerPanel(NULL), - mFirstKeystrokeTimer(), - mLastKeystrokeTimer() -{ - if(mOtherParticipantUUID.isNull()) - { - llwarns << "Other participant is NULL" << llendl; - } - - init(session_label); -} - -LLFloaterIMPanel::LLFloaterIMPanel( - const std::string& session_label, - const LLUUID& session_id, - const LLUUID& other_participant_id, - const LLDynamicArray& ids, - EInstantMessage dialog) : - LLFloater(session_label, LLRect(), session_label), - mInputEditor(NULL), - mHistoryEditor(NULL), - mSessionUUID(session_id), mVoiceChannel(NULL), - mSessionInitialized(FALSE), - mSessionStartMsgPos(0), - mOtherParticipantUUID(other_participant_id), - mDialog(dialog), - mTyping(FALSE), - mOtherTyping(FALSE), - mTypingLineStartIndex(0), - mSentTypingState(TRUE), - mShowSpeakersOnConnect(TRUE), - mStartCallOnInitialize(false), - mTextIMPossible(TRUE), - mProfileButtonEnabled(TRUE), - mCallBackEnabled(TRUE), - mSpeakers(NULL), - mSpeakerPanel(NULL), mFirstKeystrokeTimer(), mLastKeystrokeTimer() { - if(mOtherParticipantUUID.isNull()) + if (mOtherParticipantUUID.isNull()) { llwarns << "Other participant is NULL" << llendl; } - mSessionInitialTargetIDs = ids; - init(session_label); -} - - -void LLFloaterIMPanel::init(const std::string& session_label) -{ // set P2P type by default - mSessionType = P2P_SESSION; - - mSessionLabel = session_label; // [Ansariel: Display name support] mProfileButtonEnabled = FALSE; @@ -429,7 +388,7 @@ void LLFloaterIMPanel::init(const std::string& session_label) &getFactoryMap(), FALSE); - setTitle(mSessionLabel); + setTitle(mLogLabel); // [Ansariel: Display name support] if (mProfileButtonEnabled) @@ -444,7 +403,7 @@ void LLFloaterIMPanel::init(const std::string& session_label) if ( gSavedPerAccountSettings.getBOOL("LogShowHistory") ) { - LLLogChat::loadHistory(mSessionLabel, + LLLogChat::loadHistory(mLogLabel, &chatFromLogFile, (void *)this); } @@ -454,13 +413,12 @@ void LLFloaterIMPanel::init(const std::string& session_label) if ( !send_start_session_messages( mSessionUUID, mOtherParticipantUUID, - mSessionInitialTargetIDs, + ids, mDialog) ) { //we don't need to need to wait for any responses //so we're already initialized - mSessionInitialized = TRUE; - mSessionStartMsgPos = 0; + mSessionInitialized = true; } else { @@ -468,8 +426,7 @@ void LLFloaterIMPanel::init(const std::string& session_label) LLUIString session_start = sSessionStartString; session_start.setArg("[NAME]", getTitle()); - mSessionStartMsgPos = - mHistoryEditor->getWText().length(); + mSessionStartMsgPos = mHistoryEditor->getWText().length(); addHistoryLine( session_start, @@ -489,6 +446,7 @@ void LLFloaterIMPanel::onAvatarNameLookup(const LLUUID&, const LLAvatarName& ava std::string title; LLAvatarNameCache::getPNSName(avatar_name, title); setTitle(title); + // Singu Note: We could set tab name here, too now. } LLFloaterIMPanel::~LLFloaterIMPanel() @@ -531,9 +489,6 @@ BOOL LLFloaterIMPanel::postBuild() if (checkRequirements()) { - mDing = false; - mRPMode = false; - mInputEditor = getChild("chat_editor"); mInputEditor->setFocusReceivedCallback( boost::bind(&LLFloaterIMPanel::onInputEditorFocusReceived, this) ); mFocusLostSignal = mInputEditor->setFocusLostCallback( boost::bind(&LLFloaterIMPanel::onInputEditorFocusLost, this) ); @@ -629,7 +584,7 @@ void LLFloaterIMPanel::draw() { LLViewerRegion* region = gAgent.getRegion(); - BOOL enable_connect = (region && region->getCapability("ChatSessionRequest") != "") + bool enable_connect = (region && !region->getCapability("ChatSessionRequest").empty()) && mSessionInitialized && LLVoiceClient::getInstance()->voiceEnabled() && mCallBackEnabled; @@ -661,7 +616,6 @@ void LLFloaterIMPanel::draw() if (mShowSpeakersOnConnect && mVoiceChannel->isActive()) { childSetVisible("active_speakers_panel", true); - mShowSpeakersOnConnect = FALSE; } if (LLUICtrl* ctrl = findChild("toggle_active_speakers_btn")) ctrl->setValue(getChildView("active_speakers_panel")->getVisible()); @@ -671,7 +625,7 @@ void LLFloaterIMPanel::draw() // Time out if user hasn't typed for a while. if (mLastKeystrokeTimer.getElapsedTimeF32() > LLAgent::TYPING_TIMEOUT_SECS) { - setTyping(FALSE); + setTyping(false); } // If we are typing, and it's been a little while, send the @@ -679,8 +633,8 @@ void LLFloaterIMPanel::draw() if (!mSentTypingState && mFirstKeystrokeTimer.getElapsedTimeF32() > 1.f) { - sendTypingState(TRUE); - mSentTypingState = TRUE; + sendTypingState(true); + mSentTypingState = true; } } @@ -864,9 +818,9 @@ void LLFloaterIMPanel::addHistoryLine(const std::string &utf8msg, LLColor4 incol // [Ansariel: Display name support] // Floater title contains display name -> bad idea to use that as filename - // mSessionLabel, however, should still be the old legacy name + // mLogLabel, however, is the old legacy name //LLLogChat::saveHistory(getTitle(),histstr); - LLLogChat::saveHistory(mSessionLabel, histstr); + LLLogChat::saveHistory(mLogLabel, histstr); // [/Ansariel: Display name support] } @@ -895,7 +849,7 @@ void LLFloaterIMPanel::setVisible(BOOL b) } -void LLFloaterIMPanel::setInputFocus( BOOL b ) +void LLFloaterIMPanel::setInputFocus(bool b) { mInputEditor->setFocus( b ); } @@ -1024,7 +978,7 @@ BOOL LLFloaterIMPanel::dropCategory(LLInventoryCategory* category, BOOL drop) return rv; } -BOOL LLFloaterIMPanel::isInviteAllowed() const +bool LLFloaterIMPanel::isInviteAllowed() const { return ( (IM_SESSION_CONFERENCE_START == mDialog) @@ -1093,7 +1047,7 @@ void LLFloaterIMPanel::onClickHistory() { // [Ansariel: Display name support] //show_log_browser(getTitle(), mOtherParticipantUUID.asString()); - show_log_browser(mSessionLabel, mOtherParticipantUUID.asString()); + show_log_browser(mLogLabel, mOtherParticipantUUID.asString()); // [/Ansariel: Display name support] } } @@ -1115,21 +1069,13 @@ void LLFloaterIMPanel::onInputEditorFocusLost() void LLFloaterIMPanel::onInputEditorKeystroke(LLLineEditor* caller) { - std::string text = caller->getText(); - if (!text.empty()) - { - setTyping(TRUE); - } - else - { - // Deleting all text counts as stopping typing. - setTyping(FALSE); - } + // Deleting all text counts as stopping typing. + setTyping(!caller->getText().empty()); } void LLFloaterIMPanel::onClose(bool app_quitting) { - setTyping(FALSE); + setTyping(false); if(mSessionUUID.notNull()) { @@ -1429,8 +1375,8 @@ LL_WARNS("Splitting") << "Pos: " << pos << " next_split: " << next_split << LL_E // Don't need to actually send the typing stop message, the other // client will infer it from receiving the message. - mTyping = FALSE; - mSentTypingState = TRUE; + mTyping = false; + mSentTypingState = true; } void LLFloaterIMPanel::processSessionUpdate(const LLSD& session_update) @@ -1439,15 +1385,15 @@ void LLFloaterIMPanel::processSessionUpdate(const LLSD& session_update) session_update.has("moderated_mode") && session_update["moderated_mode"].has("voice") ) { - BOOL voice_moderated = session_update["moderated_mode"]["voice"]; + bool voice_moderated = session_update["moderated_mode"]["voice"]; if (voice_moderated) { - setTitle(mSessionLabel + std::string(" ") + getString("moderated_chat_label")); + setTitle(mLogLabel + std::string(" ") + getString("moderated_chat_label")); } else { - setTitle(mSessionLabel); + setTitle(mLogLabel); } @@ -1460,18 +1406,16 @@ void LLFloaterIMPanel::sessionInitReplyReceived(const LLUUID& session_id) { mSessionUUID = session_id; mVoiceChannel->updateSessionID(session_id); - mSessionInitialized = TRUE; + mSessionInitialized = true; //we assume the history editor hasn't moved at all since //we added the starting session message //so, we count how many characters to remove - S32 chars_to_remove = mHistoryEditor->getWText().length() - - mSessionStartMsgPos; + S32 chars_to_remove = mHistoryEditor->getWText().length() - mSessionStartMsgPos; mHistoryEditor->removeTextFromEnd(chars_to_remove); //and now, send the queued msg - LLSD::array_iterator iter; - for ( iter = mQueuedMsgsForInit.beginArray(); + for (LLSD::array_iterator iter = mQueuedMsgsForInit.beginArray(); iter != mQueuedMsgsForInit.endArray(); ++iter) { @@ -1489,7 +1433,7 @@ void LLFloaterIMPanel::sessionInitReplyReceived(const LLUUID& session_id) } } -void LLFloaterIMPanel::setTyping(BOOL typing) +void LLFloaterIMPanel::setTyping(bool typing) { if (typing) { @@ -1502,7 +1446,7 @@ void LLFloaterIMPanel::setTyping(BOOL typing) mFirstKeystrokeTimer.reset(); // Will send typing state after a short delay. - mSentTypingState = FALSE; + mSentTypingState = false; } mSpeakers->setSpeakerTyping(gAgent.getID(), TRUE); @@ -1512,8 +1456,8 @@ void LLFloaterIMPanel::setTyping(BOOL typing) if (mTyping) { // you just stopped typing, send state immediately - sendTypingState(FALSE); - mSentTypingState = TRUE; + sendTypingState(false); + mSentTypingState = true; } mSpeakers->setSpeakerTyping(gAgent.getID(), FALSE); } @@ -1521,7 +1465,7 @@ void LLFloaterIMPanel::setTyping(BOOL typing) mTyping = typing; } -void LLFloaterIMPanel::sendTypingState(BOOL typing) +void LLFloaterIMPanel::sendTypingState(bool typing) { if(gSavedSettings.getBOOL("AscentHideTypingNotification")) return; @@ -1547,7 +1491,7 @@ void LLFloaterIMPanel::sendTypingState(BOOL typing) } -void LLFloaterIMPanel::processIMTyping(const LLIMInfo* im_info, BOOL typing) +void LLFloaterIMPanel::processIMTyping(const LLIMInfo* im_info, bool typing) { if (typing) { @@ -1574,7 +1518,7 @@ void LLFloaterIMPanel::addTypingIndicator(const std::string &name) typing_start.setArg("[NAME]", name); addHistoryLine(typing_start, gSavedSettings.getColor4("SystemChatColor"), false); mOtherTypingName = name; - mOtherTyping = TRUE; + mOtherTyping = true; } // MBW -- XXX -- merge from release broke this (argument to this function changed from an LLIMInfo to a name) // Richard will fix. @@ -1587,7 +1531,7 @@ void LLFloaterIMPanel::removeTypingIndicator(const LLIMInfo* im_info) if (mOtherTyping) { // Must do this first, otherwise addHistoryLine calls us again. - mOtherTyping = FALSE; + mOtherTyping = false; S32 chars_to_remove = mHistoryEditor->getWText().length() - mTypingLineStartIndex; mHistoryEditor->removeTextFromEnd(chars_to_remove); @@ -1710,7 +1654,7 @@ const bool LLFloaterIMPanel::isModerator(const LLUUID& speaker_id) LLPointer speakerp = mSpeakers->findSpeaker(speaker_id); return speakerp && speakerp->mIsModerator; } - return FALSE; + return false; } BOOL LLFloaterIMPanel::focusFirstItem(BOOL prefer_text_fields, BOOL focus_flash ) diff --git a/indra/newview/llimpanel.h b/indra/newview/llimpanel.h index 5ec7c692c..8e901d7d8 100644 --- a/indra/newview/llimpanel.h +++ b/indra/newview/llimpanel.h @@ -55,15 +55,11 @@ public: // the default. For example, if you open a session though a // calling card, a new session id will be generated, but the // target_id will be the agent referenced by the calling card. - LLFloaterIMPanel(const std::string& session_label, + LLFloaterIMPanel(const std::string& log_label, const LLUUID& session_id, const LLUUID& target_id, - EInstantMessage dialog); - LLFloaterIMPanel(const std::string& session_label, - const LLUUID& session_id, - const LLUUID& target_id, - const LLDynamicArray& ids, - EInstantMessage dialog); + const EInstantMessage& dialog, + const LLDynamicArray& ids = LLDynamicArray()); virtual ~LLFloaterIMPanel(); void lookupName(); @@ -86,7 +82,7 @@ public: const LLUUID& source = LLUUID::null, const std::string& name = LLStringUtil::null); - void setInputFocus( BOOL b ); + void setInputFocus(bool b); void setVisible(BOOL b); @@ -121,7 +117,7 @@ public: void sessionInitReplyReceived(const LLUUID& im_session_id); // Handle other participant in the session typing. - void processIMTyping(const LLIMInfo* im_info, BOOL typing); + void processIMTyping(const LLIMInfo* im_info, bool typing); static void chatFromLogFile(LLLogChat::ELogLineType type, std::string line, void* userdata); //show error statuses to the user @@ -133,22 +129,11 @@ public: static bool onConfirmForceCloseError(const LLSD& notification, const LLSD& response); - typedef enum e_session_type - { - P2P_SESSION, - GROUP_SESSION, - ADHOC_SESSION - } SType; - SType mSessionType; - // LLIMModel Functionality bool getSessionInitialized() const { return mSessionInitialized; } bool mStartCallOnInitialize; private: - // called by constructors - void init(const std::string& session_label); - // Called by UI methods. void onSendMsg(); @@ -157,11 +142,11 @@ private: BOOL dropCategory(LLInventoryCategory* category, BOOL drop); // test if local agent can add agents. - BOOL isInviteAllowed() const; + bool isInviteAllowed() const; // Called whenever the user starts or stops typing. // Sends the typing state to the other user if necessary. - void setTyping(BOOL typing); + void setTyping(bool typing); // Add the "User is typing..." indicator. void addTypingIndicator(const std::string &name); @@ -169,7 +154,7 @@ private: // Remove the "User is typing..." indicator. void removeTypingIndicator(const LLIMInfo* im_info); - void sendTypingState(BOOL typing); + void sendTypingState(bool typing); const bool isModerator(const LLUUID& speaker_id); @@ -177,6 +162,19 @@ private: LLLineEditor* mInputEditor; LLViewerTextEditor* mHistoryEditor; + bool mSessionInitialized; + + // Where does the "Starting session..." line start? + S32 mSessionStartMsgPos; + + enum SType + { + P2P_SESSION, + GROUP_SESSION, + ADHOC_SESSION + }; + SType mSessionType; + // The value of the mSessionUUID depends on how the IM session was started: // one-on-one ==> random id // group ==> group_id @@ -184,10 +182,9 @@ private: // 911 ==> Gaurdian_Angel_Group_ID ^ gAgent.getID() LLUUID mSessionUUID; - std::string mSessionLabel; - LLVoiceChannel* mVoiceChannel; + // mLogLabel is the name of the log file before directories and extensions + std::string mLogLabel; - BOOL mSessionInitialized; LLSD mQueuedMsgsForInit; // The value mOtherParticipantUUID depends on how the IM session was started: @@ -196,39 +193,38 @@ private: // inventory folder ==> first target id in list // 911 ==> sender LLUUID mOtherParticipantUUID; - LLDynamicArray mSessionInitialTargetIDs; EInstantMessage mDialog; // Are you currently typing? - BOOL mTyping; + bool mTyping; + + // Where does the "User is typing..." line start? + S32 mTypingLineStartIndex; // Is other user currently typing? - BOOL mOtherTyping; + bool mOtherTyping; // name of other user who is currently typing std::string mOtherTypingName; - // Where does the "User is typing..." line start? - S32 mTypingLineStartIndex; - // Where does the "Starting session..." line start? - S32 mSessionStartMsgPos; - S32 mNumUnreadMessages; - BOOL mSentTypingState; + bool mSentTypingState; - BOOL mShowSpeakersOnConnect; + bool mShowSpeakersOnConnect; - BOOL mTextIMPossible; BOOL mProfileButtonEnabled; - BOOL mCallBackEnabled; bool mDing; // Whether or not to play a ding on new messages bool mRPMode; + bool mTextIMPossible; + bool mCallBackEnabled; + LLIMSpeakerMgr* mSpeakers; LLParticipantList* mSpeakerPanel; + LLVoiceChannel* mVoiceChannel; // Optimization: Don't send "User is typing..." until the // user has actually been typing for a little while. Prevents diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 0538918c5..0fcf96747 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -480,13 +480,7 @@ void LLIMMgr::addMessage( name = session_name; } - - floater = createFloater( - new_session_id, - other_participant_id, - name, - dialog, - FALSE); + floater = createFloater(new_session_id, other_participant_id, name, dialog); // When we get a new IM, and if you are a god, display a bit // of information about the source. This is to help liaisons @@ -651,13 +645,7 @@ LLUUID LLIMMgr::addSession( LLDynamicArray ids; ids.put(other_participant_id); - floater = createFloater( - session_id, - other_participant_id, - name, - ids, - dialog, - TRUE); + floater = createFloater(session_id, other_participant_id, name, dialog, ids, true); noteOfflineUsers(floater, ids); LLFloaterChatterBox::showInstance(session_id); @@ -714,13 +702,7 @@ LLUUID LLIMMgr::addSession( { // On creation, use the first element of ids as the // "other_participant_id" - floater = createFloater( - session_id, - other_participant_id, - name, - ids, - dialog, - TRUE); + floater = createFloater(session_id, other_participant_id, name, dialog, ids, true); if ( !floater ) return LLUUID::null; @@ -1094,52 +1076,9 @@ LLFloaterIMPanel* LLIMMgr::createFloater( const LLUUID& session_id, const LLUUID& other_participant_id, const std::string& session_label, - EInstantMessage dialog, - BOOL user_initiated) -{ - if (session_id.isNull()) - { - llwarns << "Creating LLFloaterIMPanel with null session ID" << llendl; - } - - llinfos << "LLIMMgr::createFloater: from " << other_participant_id - << " in session " << session_id << llendl; - LLFloaterIMPanel* floater = new LLFloaterIMPanel(session_label, - session_id, - other_participant_id, - dialog); - LLTabContainer::eInsertionPoint i_pt = user_initiated ? LLTabContainer::RIGHT_OF_CURRENT : LLTabContainer::END; - LLFloaterChatterBox::getInstance(LLSD())->addFloater(floater, FALSE, i_pt); - static LLCachedControl tear_off("OtherChatsTornOff"); - if (tear_off) - { - LLFloaterChatterBox::getInstance(LLSD())->removeFloater(floater); // removal sets up relationship for re-attach - gFloaterView->addChild(floater); // reparent to floater view - LLFloater* focused_floater = gFloaterView->getFocusedFloater(); // obtain the focused floater - floater->open(); // make the new chat floater appear - static LLCachedControl minimize("OtherChatsTornOffAndMinimized"); - if (focused_floater != NULL) // there was a focused floater - { - floater->setMinimized(minimize); // so minimize this one, for now, if desired - focused_floater->setFocus(true); // and work around focus being removed by focusing on the last - } - else if (minimize) - { - floater->setFocus(false); // work around focus being granted to new floater - floater->setMinimized(true); - } - } - mFloaters.insert(floater->getHandle()); - return floater; -} - -LLFloaterIMPanel* LLIMMgr::createFloater( - const LLUUID& session_id, - const LLUUID& other_participant_id, - const std::string& session_label, + const EInstantMessage& dialog, const LLDynamicArray& ids, - EInstantMessage dialog, - BOOL user_initiated) + bool user_initiated) { if (session_id.isNull()) { @@ -1148,11 +1087,7 @@ LLFloaterIMPanel* LLIMMgr::createFloater( llinfos << "LLIMMgr::createFloater: from " << other_participant_id << " in session " << session_id << llendl; - LLFloaterIMPanel* floater = new LLFloaterIMPanel(session_label, - session_id, - other_participant_id, - ids, - dialog); + LLFloaterIMPanel* floater = new LLFloaterIMPanel(session_label, session_id, other_participant_id, dialog, ids); LLTabContainer::eInsertionPoint i_pt = user_initiated ? LLTabContainer::RIGHT_OF_CURRENT : LLTabContainer::END; LLFloaterChatterBox::getInstance(LLSD())->addFloater(floater, FALSE, i_pt); static LLCachedControl tear_off("OtherChatsTornOff"); diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h index b2786cab9..2a2ac9dc7 100644 --- a/indra/newview/llimview.h +++ b/indra/newview/llimview.h @@ -192,15 +192,9 @@ private: LLFloaterIMPanel* createFloater(const LLUUID& session_id, const LLUUID& target_id, const std::string& name, - EInstantMessage dialog, - BOOL user_initiated = FALSE); - - LLFloaterIMPanel* createFloater(const LLUUID& session_id, - const LLUUID& target_id, - const std::string& name, - const LLDynamicArray& ids, - EInstantMessage dialog, - BOOL user_initiated = FALSE); + const EInstantMessage& dialog, + const LLDynamicArray& ids = LLDynamicArray(), + bool user_initiated = false); // This simple method just iterates through all of the ids, and // prints a simple message if they are not online. Used to help