// <dogmode> void LLChatBar::sendChat( EChatType type ) { if (mInputEditor) { LLWString text = mInputEditor->getConvertedText(); if (!text.empty()) { // store sent line in history, duplicates will get filtered if (mInputEditor) mInputEditor->updateHistory(); S32 channel = 0; stripChannelNumber(text, &channel); std::string utf8text = wstring_to_utf8str(text);//+" and read is "+llformat("%f",readChan)+" and undone is "+llformat("%d",undoneChan)+" but actualy channel is "+llformat("%d",channel); // Try to trigger a gesture, if not chat to a script. std::string utf8_revised_text; if (0 == channel) { convert_roleplay_text(utf8text); // discard returned "found" boolean LLGestureMgr::instance().triggerAndReviseString(utf8text, &utf8_revised_text); } else { utf8_revised_text = utf8text; } utf8_revised_text = utf8str_trim(utf8_revised_text); EChatType nType(type == CHAT_TYPE_OOC ? CHAT_TYPE_NORMAL : type); if (!utf8_revised_text.empty() && cmd_line_chat(utf8_revised_text, nType)) { // Chat with animation #if SHY_MOD //Command handler if(!SHCommandHandler::handleCommand(true, utf8_revised_text, gAgentID, (LLViewerObject*)gAgentAvatarp))//returns true if handled #endif //shy_mod sendChatFromViewer(utf8_revised_text, nType, TRUE); } } } childSetValue("Chat Editor", LLStringUtil::null); gAgent.stopTyping(); // If the user wants to stop chatting on hitting return, lose focus // and go out of chat mode. if (gChatBar == this && gSavedSettings.getBOOL("CloseChatOnReturn")) { stopChat(); } }
// Singu Note: LLFloaterIMSession::sendMsg void LLFloaterIMPanel::onSendMsg() { if (!gAgent.isGodlike() && (mSessionType == P2P_SESSION) && mOtherParticipantUUID.isNull()) { llinfos << "Cannot send IM to everyone unless you're a god." << llendl; return; } if (mInputEditor) { LLWString text = mInputEditor->getConvertedText(); if(!text.empty()) { // store sent line in history, duplicates will get filtered if (mInputEditor) mInputEditor->updateHistory(); // Truncate and convert to UTF8 for transport std::string utf8_text = wstring_to_utf8str(text); bool action = convert_roleplay_text(utf8_text); if (!action && mRPMode) utf8_text = "((" + utf8_text + "))"; // [RLVa:KB] - Checked: 2010-11-30 (RLVa-1.3.0) if ( (RlvActions::hasBehaviour(RLV_BHVR_SENDIM)) || (RlvActions::hasBehaviour(RLV_BHVR_SENDIMTO)) ) { bool fRlvFilter = false; switch (mSessionType) { case P2P_SESSION: // One-on-one IM fRlvFilter = !RlvActions::canSendIM(mOtherParticipantUUID); break; case GROUP_SESSION: // Group chat fRlvFilter = !RlvActions::canSendIM(mSessionUUID); break; case ADHOC_SESSION: // Conference chat: allow if all participants can be sent an IM { if (!mSpeakers) { fRlvFilter = true; break; } LLSpeakerMgr::speaker_list_t speakers; mSpeakers->getSpeakerList(&speakers, TRUE); for (LLSpeakerMgr::speaker_list_t::const_iterator itSpeaker = speakers.begin(); itSpeaker != speakers.end(); ++itSpeaker) { const LLSpeaker* pSpeaker = *itSpeaker; if ( (gAgentID != pSpeaker->mID) && (!RlvActions::canSendIM(pSpeaker->mID)) ) { fRlvFilter = true; break; } } } break; default: fRlvFilter = true; break; } if (fRlvFilter) { utf8_text = RlvStrings::getString(RLV_STRING_BLOCKED_SENDIM); } } // [/RLVa:KB] if ( mSessionInitialized ) { // Split messages that are too long, same code like in llimpanel.cpp U32 split = MAX_MSG_BUF_SIZE - 1; U32 pos = 0; U32 total = utf8_text.length(); while (pos < total) { U32 next_split = split; if (pos + next_split > total) { next_split = total - pos; } else { // don't split utf-8 bytes while (U8(utf8_text[pos + next_split]) != 0x20 // space && U8(utf8_text[pos + next_split]) != 0x21 // ! && U8(utf8_text[pos + next_split]) != 0x2C // , && U8(utf8_text[pos + next_split]) != 0x2E // . && U8(utf8_text[pos + next_split]) != 0x3F // ? && next_split > 0) { --next_split; } if (next_split == 0) { next_split = split; LL_WARNS("Splitting") << "utf-8 couldn't be split correctly" << LL_ENDL; } else { ++next_split; } } std::string send = utf8_text.substr(pos, next_split); pos += next_split; LL_DEBUGS("Splitting") << "Pos: " << pos << " next_split: " << next_split << LL_ENDL; deliver_message(send, mSessionUUID, mOtherParticipantUUID, mDialog); } // local echo if((mSessionType == P2P_SESSION) && (mOtherParticipantUUID.notNull())) { std::string name; gAgent.buildFullname(name); // Look for actions here. if (action) { utf8_text.replace(0,3,""); } else { utf8_text.insert(0, ": "); } bool other_was_typing = mOtherTyping; addHistoryLine(utf8_text, gSavedSettings.getColor("UserChatColor"), true, gAgentID, name); if (other_was_typing) addTypingIndicator(mOtherTypingName); } } else { //queue up the message to send once the session is //initialized mQueuedMsgsForInit.append(utf8_text); } } LLViewerStats::getInstance()->incStat(LLViewerStats::ST_IM_COUNT); mInputEditor->setText(LLStringUtil::null); } // Don't need to actually send the typing stop message, the other // client will infer it from receiving the message. mTyping = false; mSentTypingState = true; }