diff options
Diffstat (limited to 'linden/indra/newview/llimpanel.cpp')
-rw-r--r-- | linden/indra/newview/llimpanel.cpp | 231 |
1 files changed, 86 insertions, 145 deletions
diff --git a/linden/indra/newview/llimpanel.cpp b/linden/indra/newview/llimpanel.cpp index d95abf3..3c89131 100644 --- a/linden/indra/newview/llimpanel.cpp +++ b/linden/indra/newview/llimpanel.cpp | |||
@@ -33,6 +33,7 @@ | |||
33 | #include "indra_constants.h" | 33 | #include "indra_constants.h" |
34 | #include "llfocusmgr.h" | 34 | #include "llfocusmgr.h" |
35 | #include "llfontgl.h" | 35 | #include "llfontgl.h" |
36 | #include "llhttpclient.h" | ||
36 | #include "llrect.h" | 37 | #include "llrect.h" |
37 | #include "llerror.h" | 38 | #include "llerror.h" |
38 | #include "llstring.h" | 39 | #include "llstring.h" |
@@ -60,6 +61,7 @@ | |||
60 | #include "llvieweruictrlfactory.h" | 61 | #include "llvieweruictrlfactory.h" |
61 | #include "lllogchat.h" | 62 | #include "lllogchat.h" |
62 | #include "llfloaterhtml.h" | 63 | #include "llfloaterhtml.h" |
64 | #include "llviewerregion.h" | ||
63 | #include "llweb.h" | 65 | #include "llweb.h" |
64 | 66 | ||
65 | // | 67 | // |
@@ -113,8 +115,7 @@ bool send_start_session_messages(const LLUUID& temp_session_id, | |||
113 | const LLDynamicArray<LLUUID>& ids, | 115 | const LLDynamicArray<LLUUID>& ids, |
114 | EInstantMessage dialog) | 116 | EInstantMessage dialog) |
115 | { | 117 | { |
116 | if ( (dialog == IM_SESSION_911_START) || | 118 | if ( (dialog == IM_SESSION_GROUP_START) || |
117 | (dialog == IM_SESSION_GROUP_START) || | ||
118 | (dialog == IM_SESSION_CONFERENCE_START) ) | 119 | (dialog == IM_SESSION_CONFERENCE_START) ) |
119 | { | 120 | { |
120 | S32 count = ids.size(); | 121 | S32 count = ids.size(); |
@@ -129,7 +130,6 @@ bool send_start_session_messages(const LLUUID& temp_session_id, | |||
129 | switch(dialog) | 130 | switch(dialog) |
130 | { | 131 | { |
131 | case IM_SESSION_GROUP_START: | 132 | case IM_SESSION_GROUP_START: |
132 | case IM_SESSION_911_START: | ||
133 | gMessageSystem->addBinaryDataFast(_PREHASH_BinaryBucket, | 133 | gMessageSystem->addBinaryDataFast(_PREHASH_BinaryBucket, |
134 | EMPTY_BINARY_BUCKET, | 134 | EMPTY_BINARY_BUCKET, |
135 | EMPTY_BINARY_BUCKET_SIZE); | 135 | EMPTY_BINARY_BUCKET_SIZE); |
@@ -210,35 +210,58 @@ LLFloaterIMPanel::LLFloaterIMPanel(const std::string& name, | |||
210 | mSessionInitialized(FALSE), | 210 | mSessionInitialized(FALSE), |
211 | mSessionInitRequested(FALSE) | 211 | mSessionInitRequested(FALSE) |
212 | { | 212 | { |
213 | init(session_label); | ||
214 | |||
215 | mSessionInitialTargetIDs = ids; | 213 | mSessionInitialTargetIDs = ids; |
214 | init(session_label); | ||
216 | } | 215 | } |
217 | 216 | ||
218 | 217 | ||
219 | void LLFloaterIMPanel::init(const LLString& session_label) | 218 | void LLFloaterIMPanel::init(const LLString& session_label) |
220 | { | 219 | { |
221 | gUICtrlFactory->buildFloater(this, | 220 | gUICtrlFactory->buildFloater(this, |
222 | "floater_instant_message.xml", | 221 | "floater_instant_message.xml", |
223 | NULL, | 222 | NULL, |
224 | FALSE); | 223 | FALSE); |
225 | 224 | ||
226 | setLabel(session_label); | 225 | setLabel(session_label); |
227 | setTitle(session_label); | 226 | setTitle(session_label); |
228 | mInputEditor->setMaxTextLength(1023); | 227 | mInputEditor->setMaxTextLength(1023); |
228 | // enable line history support for instant message bar | ||
229 | mInputEditor->setEnableLineHistory(TRUE); | ||
229 | 230 | ||
230 | if ( gSavedPerAccountSettings.getBOOL("LogShowHistory") ) | 231 | if ( gSavedPerAccountSettings.getBOOL("LogShowHistory") ) |
231 | { | 232 | { |
232 | LLLogChat::loadHistory(session_label, | 233 | LLLogChat::loadHistory(session_label, |
233 | &chatFromLogFile, | 234 | &chatFromLogFile, |
234 | (void *)this); | 235 | (void *)this); |
235 | } | 236 | } |
236 | 237 | ||
237 | if(IM_SESSION_911_START == mDialog) | 238 | if ( !mSessionInitialized ) |
238 | { | 239 | { |
239 | LLTextBox* live_help_text = | 240 | if ( !send_start_session_messages( |
240 | LLUICtrlFactory::getTextBoxByName(this, "live_help_dialog"); | 241 | mSessionUUID, |
241 | addHistoryLine(live_help_text->getText()); | 242 | mOtherParticipantUUID, |
243 | mSessionInitialTargetIDs, | ||
244 | mDialog) ) | ||
245 | { | ||
246 | //we don't need to need to wait for any responses | ||
247 | //so we're already initialized | ||
248 | mSessionInitialized = TRUE; | ||
249 | } | ||
250 | else | ||
251 | { | ||
252 | //locally echo a little "starting session" message | ||
253 | LLUIString session_start = sSessionStartString; | ||
254 | |||
255 | session_start.setArg("[NAME]", getTitle()); | ||
256 | mSessionStartMsgPos = | ||
257 | mHistoryEditor->getText().length(); | ||
258 | |||
259 | bool log_to_file = false; | ||
260 | addHistoryLine( | ||
261 | session_start, | ||
262 | LLColor4::grey, | ||
263 | log_to_file); | ||
264 | } | ||
242 | } | 265 | } |
243 | } | 266 | } |
244 | 267 | ||
@@ -253,7 +276,6 @@ BOOL LLFloaterIMPanel::postBuild() | |||
253 | requires("title_string", WIDGET_TYPE_TEXT_BOX); | 276 | requires("title_string", WIDGET_TYPE_TEXT_BOX); |
254 | requires("typing_start_string", WIDGET_TYPE_TEXT_BOX); | 277 | requires("typing_start_string", WIDGET_TYPE_TEXT_BOX); |
255 | requires("session_start_string", WIDGET_TYPE_TEXT_BOX); | 278 | requires("session_start_string", WIDGET_TYPE_TEXT_BOX); |
256 | requires("teleport_btn", WIDGET_TYPE_BUTTON); | ||
257 | 279 | ||
258 | if (checkRequirements()) | 280 | if (checkRequirements()) |
259 | { | 281 | { |
@@ -271,16 +293,10 @@ BOOL LLFloaterIMPanel::postBuild() | |||
271 | LLButton* close_btn = LLUICtrlFactory::getButtonByName(this, "close_btn"); | 293 | LLButton* close_btn = LLUICtrlFactory::getButtonByName(this, "close_btn"); |
272 | close_btn->setClickedCallback(&LLFloaterIMPanel::onClickClose, this); | 294 | close_btn->setClickedCallback(&LLFloaterIMPanel::onClickClose, this); |
273 | 295 | ||
274 | LLButton* tp_btn = LLUICtrlFactory::getButtonByName(this, "teleport_btn"); | ||
275 | tp_btn->setClickedCallback(&LLFloaterIMPanel::onTeleport, this); | ||
276 | tp_btn->setVisible(FALSE); | ||
277 | tp_btn->setEnabled(FALSE); | ||
278 | |||
279 | mHistoryEditor = LLViewerUICtrlFactory::getViewerTextEditorByName(this, "im_history"); | 296 | mHistoryEditor = LLViewerUICtrlFactory::getViewerTextEditorByName(this, "im_history"); |
280 | mHistoryEditor->setParseHTML(TRUE); | 297 | mHistoryEditor->setParseHTML(TRUE); |
281 | 298 | ||
282 | if (IM_SESSION_GROUP_START == mDialog | 299 | if (IM_SESSION_GROUP_START == mDialog) |
283 | || IM_SESSION_911_START == mDialog) | ||
284 | { | 300 | { |
285 | profile_btn->setEnabled(FALSE); | 301 | profile_btn->setEnabled(FALSE); |
286 | } | 302 | } |
@@ -326,55 +342,55 @@ void LLFloaterIMPanel::draw() | |||
326 | LLFloater::draw(); | 342 | LLFloater::draw(); |
327 | } | 343 | } |
328 | 344 | ||
345 | class LLSessionInviteResponder : public LLHTTPClient::Responder | ||
346 | { | ||
347 | public: | ||
348 | LLSessionInviteResponder(const LLUUID& session_id) | ||
349 | { | ||
350 | mSessionID = session_id; | ||
351 | } | ||
352 | |||
353 | void error(U32 statusNum, const std::string& reason) | ||
354 | { | ||
355 | llinfos << "Error inviting all agents to session" << llendl; | ||
329 | 356 | ||
330 | BOOL LLFloaterIMPanel::addParticipants(const LLDynamicArray<LLUUID>& ids) | 357 | //throw something back to the viewer here? |
358 | } | ||
359 | |||
360 | private: | ||
361 | LLUUID mSessionID; | ||
362 | }; | ||
363 | |||
364 | BOOL LLFloaterIMPanel::inviteToSession(const LLDynamicArray<LLUUID>& ids) | ||
331 | { | 365 | { |
332 | S32 count = ids.count(); | 366 | S32 count = ids.count(); |
333 | 367 | ||
334 | if( isAddAllowed() && (count > 0) ) | 368 | if( isAddAllowed() && (count > 0) ) |
335 | { | 369 | { |
336 | llinfos << "LLFloaterIMPanel::addParticipants() - adding participants" << llendl; | 370 | llinfos << "LLFloaterIMPanel::inviteToSession() - adding participants" << llendl; |
337 | const S32 MAX_AGENTS = 50; | ||
338 | if(count > MAX_AGENTS) return FALSE; | ||
339 | |||
340 | LLMessageSystem *msg = gMessageSystem; | ||
341 | msg->newMessageFast(_PREHASH_ImprovedInstantMessage); | ||
342 | msg->nextBlockFast(_PREHASH_AgentData); | ||
343 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | ||
344 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | ||
345 | msg->nextBlockFast(_PREHASH_MessageBlock); | ||
346 | msg->addBOOLFast(_PREHASH_FromGroup, FALSE); | ||
347 | msg->addUUIDFast(_PREHASH_ToAgentID, mOtherParticipantUUID); | ||
348 | msg->addU8Fast(_PREHASH_Offline, IM_ONLINE); | ||
349 | msg->addU8Fast(_PREHASH_Dialog, IM_SESSION_ADD); | ||
350 | msg->addUUIDFast(_PREHASH_ID, mSessionUUID); | ||
351 | msg->addU32Fast(_PREHASH_Timestamp, NO_TIMESTAMP); // no timestamp necessary | ||
352 | std::string name; | ||
353 | gAgent.buildFullname(name); | ||
354 | msg->addStringFast(_PREHASH_FromAgentName, name); | ||
355 | msg->addStringFast(_PREHASH_Message, LLString::null); | ||
356 | msg->addU32Fast(_PREHASH_ParentEstateID, 0); | ||
357 | msg->addUUIDFast(_PREHASH_RegionID, LLUUID::null); | ||
358 | msg->addVector3Fast(_PREHASH_Position, gAgent.getPositionAgent()); | ||
359 | 371 | ||
360 | // *FIX: this could suffer from endian issues | 372 | std::string url = |
361 | S32 bucket_size = UUID_BYTES * count; | 373 | gAgent.getRegion()->getCapability("ChatSessionRequest"); |
362 | U8* bucket = new U8[bucket_size]; | 374 | |
363 | U8* pos = bucket; | 375 | LLSD data; |
364 | for(S32 i = 0; i < count; ++i) | 376 | data["params"] = LLSD::emptyArray(); |
377 | for (int i = 0; i < count; i++) | ||
365 | { | 378 | { |
366 | memcpy(pos, &(ids.get(i)), UUID_BYTES); | 379 | data["params"].append(ids.get(i)); |
367 | pos += UUID_BYTES; | ||
368 | } | 380 | } |
369 | msg->addBinaryDataFast(_PREHASH_BinaryBucket, | 381 | |
370 | bucket, | 382 | data["method"] = "invite"; |
371 | bucket_size); | 383 | data["session-id"] = mSessionUUID; |
372 | delete[] bucket; | 384 | LLHTTPClient::post( |
373 | gAgent.sendReliableMessage(); | 385 | url, |
386 | data, | ||
387 | new LLSessionInviteResponder(mSessionUUID)); | ||
388 | |||
374 | } | 389 | } |
375 | else | 390 | else |
376 | { | 391 | { |
377 | llinfos << "LLFloaterIMPanel::addParticipants() - no need to add agents for " | 392 | llinfos << "LLFloaterIMPanel::inviteToSession -" |
393 | << " no need to invite agents for " | ||
378 | << mDialog << llendl; | 394 | << mDialog << llendl; |
379 | // successful add, because everyone that needed to get added | 395 | // successful add, because everyone that needed to get added |
380 | // was added. | 396 | // was added. |
@@ -530,7 +546,7 @@ BOOL LLFloaterIMPanel::dropCallingCard(LLInventoryItem* item, BOOL drop) | |||
530 | { | 546 | { |
531 | LLDynamicArray<LLUUID> ids; | 547 | LLDynamicArray<LLUUID> ids; |
532 | ids.put(item->getCreatorUUID()); | 548 | ids.put(item->getCreatorUUID()); |
533 | addParticipants(ids); | 549 | inviteToSession(ids); |
534 | } | 550 | } |
535 | } | 551 | } |
536 | else | 552 | else |
@@ -566,7 +582,7 @@ BOOL LLFloaterIMPanel::dropCategory(LLInventoryCategory* category, BOOL drop) | |||
566 | { | 582 | { |
567 | ids.put(items.get(i)->getCreatorUUID()); | 583 | ids.put(items.get(i)->getCreatorUUID()); |
568 | } | 584 | } |
569 | addParticipants(ids); | 585 | inviteToSession(ids); |
570 | } | 586 | } |
571 | } | 587 | } |
572 | return rv; | 588 | return rv; |
@@ -576,7 +592,7 @@ BOOL LLFloaterIMPanel::isAddAllowed() const | |||
576 | { | 592 | { |
577 | 593 | ||
578 | return ((IM_SESSION_CONFERENCE_START == mDialog) | 594 | return ((IM_SESSION_CONFERENCE_START == mDialog) |
579 | || (IM_SESSION_ADD) ); | 595 | || (IM_SESSION_INVITE) ); |
580 | } | 596 | } |
581 | 597 | ||
582 | 598 | ||
@@ -610,39 +626,6 @@ void LLFloaterIMPanel::onClickClose( void* userdata ) | |||
610 | } | 626 | } |
611 | } | 627 | } |
612 | 628 | ||
613 | void LLFloaterIMPanel::addTeleportButton() | ||
614 | { | ||
615 | LLButton* btn = | ||
616 | LLViewerUICtrlFactory::getButtonByName(this, "teleport_btn"); | ||
617 | |||
618 | if ( !btn->getEnabled() ) | ||
619 | { | ||
620 | //it's required, don't need to check for null here | ||
621 | // adjust the size of the editor to make room for the button | ||
622 | LLRect rect = mInputEditor->getRect(); | ||
623 | S32 editor_right = rect.mRight - btn->getRect().getWidth(); | ||
624 | rect.mRight = editor_right; | ||
625 | mInputEditor->reshape(rect.getWidth(), rect.getHeight(), FALSE); | ||
626 | mInputEditor->setRect(rect); | ||
627 | |||
628 | btn->setVisible(TRUE); | ||
629 | btn->setEnabled(TRUE); | ||
630 | } | ||
631 | } | ||
632 | |||
633 | // static | ||
634 | void LLFloaterIMPanel::onTeleport(void* userdata) | ||
635 | { | ||
636 | LLFloaterIMPanel* self = (LLFloaterIMPanel*) userdata; | ||
637 | if(self) | ||
638 | { | ||
639 | send_simple_im(self->mSessionUUID, //to | ||
640 | "", | ||
641 | IM_TELEPORT_911, | ||
642 | self->mSessionUUID);//session | ||
643 | } | ||
644 | } | ||
645 | |||
646 | // static | 629 | // static |
647 | void LLFloaterIMPanel::onInputEditorFocusReceived( LLUICtrl* caller, void* userdata ) | 630 | void LLFloaterIMPanel::onInputEditorFocusReceived( LLUICtrl* caller, void* userdata ) |
648 | { | 631 | { |
@@ -690,7 +673,7 @@ void LLFloaterIMPanel::onClose(bool app_quitting) | |||
690 | name.c_str(), | 673 | name.c_str(), |
691 | "", | 674 | "", |
692 | IM_ONLINE, | 675 | IM_ONLINE, |
693 | IM_SESSION_DROP, | 676 | IM_SESSION_LEAVE, |
694 | mSessionUUID); | 677 | mSessionUUID); |
695 | gAgent.sendReliableMessage(); | 678 | gAgent.sendReliableMessage(); |
696 | } | 679 | } |
@@ -715,11 +698,7 @@ void deliver_message(const std::string& utf8_text, | |||
715 | // which case it's probably an IM to everyone. | 698 | // which case it's probably an IM to everyone. |
716 | U8 new_dialog = dialog; | 699 | U8 new_dialog = dialog; |
717 | 700 | ||
718 | if ( dialog == IM_SESSION_911_START ) | 701 | if ( dialog != IM_NOTHING_SPECIAL ) |
719 | { | ||
720 | new_dialog = IM_SESSION_911_SEND; | ||
721 | } | ||
722 | else if ( dialog != IM_NOTHING_SPECIAL ) | ||
723 | { | 702 | { |
724 | new_dialog = IM_SESSION_SEND; | 703 | new_dialog = IM_SESSION_SEND; |
725 | } | 704 | } |
@@ -755,49 +734,6 @@ void LLFloaterIMPanel::sendMsg() | |||
755 | std::string utf8_text = wstring_to_utf8str(text); | 734 | std::string utf8_text = wstring_to_utf8str(text); |
756 | utf8_text = utf8str_truncate(utf8_text, MAX_MSG_BUF_SIZE - 1); | 735 | utf8_text = utf8str_truncate(utf8_text, MAX_MSG_BUF_SIZE - 1); |
757 | 736 | ||
758 | if ( !mSessionInitialized ) | ||
759 | { | ||
760 | //we send requests (if we need to) to initialize our session | ||
761 | if ( !mSessionInitRequested ) | ||
762 | { | ||
763 | mSessionInitRequested = TRUE; | ||
764 | if ( !send_start_session_messages(mSessionUUID, | ||
765 | mOtherParticipantUUID, | ||
766 | mSessionInitialTargetIDs, | ||
767 | mDialog) ) | ||
768 | { | ||
769 | //we don't need to need to wait for any responses | ||
770 | //so we don't need to disable | ||
771 | mSessionInitialized = TRUE; | ||
772 | } | ||
773 | else | ||
774 | { | ||
775 | //queue up the message to send once the session is | ||
776 | //initialized | ||
777 | mQueuedMsgsForInit.append(utf8_text); | ||
778 | |||
779 | //locally echo a little "starting session" message | ||
780 | LLUIString session_start = sSessionStartString; | ||
781 | |||
782 | session_start.setArg("[NAME]", getTitle()); | ||
783 | mSessionStartMsgPos = | ||
784 | mHistoryEditor->getText().length(); | ||
785 | |||
786 | bool log_to_file = false; | ||
787 | addHistoryLine(session_start, | ||
788 | LLColor4::grey, | ||
789 | log_to_file); | ||
790 | |||
791 | } | ||
792 | } | ||
793 | else | ||
794 | { | ||
795 | //queue up the message to send once the session is | ||
796 | //initialized | ||
797 | mQueuedMsgsForInit.append(utf8_text); | ||
798 | } | ||
799 | } | ||
800 | |||
801 | if ( mSessionInitialized ) | 737 | if ( mSessionInitialized ) |
802 | { | 738 | { |
803 | deliver_message(utf8_text, | 739 | deliver_message(utf8_text, |
@@ -831,6 +767,10 @@ void LLFloaterIMPanel::sendMsg() | |||
831 | addHistoryLine(history_echo); | 767 | addHistoryLine(history_echo); |
832 | } | 768 | } |
833 | } | 769 | } |
770 | else | ||
771 | { | ||
772 | mQueuedMsgsForInit.append(utf8_text); | ||
773 | } | ||
834 | 774 | ||
835 | gViewerStats->incStat(LLViewerStats::ST_IM_COUNT); | 775 | gViewerStats->incStat(LLViewerStats::ST_IM_COUNT); |
836 | } | 776 | } |
@@ -969,3 +909,4 @@ void LLFloaterIMPanel::chatFromLogFile(LLString line, void* userdata) | |||
969 | self->mHistoryEditor->appendColoredText(line, false, true, LLColor4::grey); | 909 | self->mHistoryEditor->appendColoredText(line, false, true, LLColor4::grey); |
970 | 910 | ||
971 | } | 911 | } |
912 | |||