aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llimview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llimview.cpp')
-rw-r--r--linden/indra/newview/llimview.cpp127
1 files changed, 50 insertions, 77 deletions
diff --git a/linden/indra/newview/llimview.cpp b/linden/indra/newview/llimview.cpp
index e6169d5..21d8e1f 100644
--- a/linden/indra/newview/llimview.cpp
+++ b/linden/indra/newview/llimview.cpp
@@ -78,14 +78,14 @@ LLIMMgr* gIMMgr = NULL;
78// Statics 78// Statics
79// 79//
80// *FIXME: make these all either UIStrings or Strings 80// *FIXME: make these all either UIStrings or Strings
81static LLString sOnlyUserMessage; 81static std::string sOnlyUserMessage;
82static LLUIString sOfflineMessage; 82static LLUIString sOfflineMessage;
83static LLString sMutedMessage; 83static std::string sMutedMessage;
84static LLUIString sInviteMessage; 84static LLUIString sInviteMessage;
85 85
86std::map<std::string,LLString> LLFloaterIM::sEventStringsMap; 86std::map<std::string,std::string> LLFloaterIM::sEventStringsMap;
87std::map<std::string,LLString> LLFloaterIM::sErrorStringsMap; 87std::map<std::string,std::string> LLFloaterIM::sErrorStringsMap;
88std::map<std::string,LLString> LLFloaterIM::sForceCloseSessionMap; 88std::map<std::string,std::string> LLFloaterIM::sForceCloseSessionMap;
89 89
90// 90//
91// Helper Functions 91// Helper Functions
@@ -94,7 +94,7 @@ std::map<std::string,LLString> LLFloaterIM::sForceCloseSessionMap;
94// returns true if a should appear before b 94// returns true if a should appear before b
95//static BOOL group_dictionary_sort( LLGroupData* a, LLGroupData* b ) 95//static BOOL group_dictionary_sort( LLGroupData* a, LLGroupData* b )
96//{ 96//{
97// return (LLString::compareDict( a->mName, b->mName ) < 0); 97// return (LLStringUtil::compareDict( a->mName, b->mName ) < 0);
98//} 98//}
99 99
100 100
@@ -157,10 +157,10 @@ BOOL LLFloaterIM::postBuild()
157{ 157{
158 // IM session initiation warnings 158 // IM session initiation warnings
159 sOnlyUserMessage = getString("only_user_message"); 159 sOnlyUserMessage = getString("only_user_message");
160 sOfflineMessage = getUIString("offline_message"); 160 sOfflineMessage = getString("offline_message");
161 sMutedMessage = getUIString("muted_message"); 161 sMutedMessage = getString("muted_message");
162 162
163 sInviteMessage = getUIString("invite_message"); 163 sInviteMessage = getString("invite_message");
164 164
165 if ( sErrorStringsMap.find("generic") == sErrorStringsMap.end() ) 165 if ( sErrorStringsMap.find("generic") == sErrorStringsMap.end() )
166 { 166 {
@@ -216,12 +216,6 @@ BOOL LLFloaterIM::postBuild()
216 } 216 }
217 217
218 218
219 if ( sEventStringsMap.end() == sEventStringsMap.find("mute") )
220 {
221 sEventStringsMap["mute"] =
222 getString("mute_agent_event");
223 }
224
225 if ( sForceCloseSessionMap.end() == 219 if ( sForceCloseSessionMap.end() ==
226 sForceCloseSessionMap.find("removed") ) 220 sForceCloseSessionMap.find("removed") )
227 { 221 {
@@ -267,13 +261,13 @@ class LLIMMgr::LLIMSessionInvite
267public: 261public:
268 LLIMSessionInvite( 262 LLIMSessionInvite(
269 const LLUUID& session_id, 263 const LLUUID& session_id,
270 const LLString& session_name, 264 const std::string& session_name,
271 const LLUUID& caller_id, 265 const LLUUID& caller_id,
272 const LLString& caller_name, 266 const std::string& caller_name,
273 EInstantMessage type, 267 EInstantMessage type,
274 EInvitationType inv_type, 268 EInvitationType inv_type,
275 const LLString& session_handle, 269 const std::string& session_handle,
276 const LLString& notify_box) : 270 const std::string& notify_box) :
277 mSessionID(session_id), 271 mSessionID(session_id),
278 mSessionName(session_name), 272 mSessionName(session_name),
279 mCallerID(caller_id), 273 mCallerID(caller_id),
@@ -285,13 +279,13 @@ public:
285 {}; 279 {};
286 280
287 LLUUID mSessionID; 281 LLUUID mSessionID;
288 LLString mSessionName; 282 std::string mSessionName;
289 LLUUID mCallerID; 283 LLUUID mCallerID;
290 LLString mCallerName; 284 std::string mCallerName;
291 EInstantMessage mType; 285 EInstantMessage mType;
292 EInvitationType mInvType; 286 EInvitationType mInvType;
293 LLString mSessionHandle; 287 std::string mSessionHandle;
294 LLString mNotifyBox; 288 std::string mNotifyBox;
295}; 289};
296 290
297 291
@@ -394,9 +388,9 @@ LLIMMgr::~LLIMMgr()
394void LLIMMgr::addMessage( 388void LLIMMgr::addMessage(
395 const LLUUID& session_id, 389 const LLUUID& session_id,
396 const LLUUID& target_id, 390 const LLUUID& target_id,
397 const char* from, 391 const std::string& from,
398 const char* msg, 392 const std::string& msg,
399 const char* session_name, 393 const std::string& session_name,
400 EInstantMessage dialog, 394 EInstantMessage dialog,
401 U32 parent_estate_id, 395 U32 parent_estate_id,
402 const LLUUID& region_id, 396 const LLUUID& region_id,
@@ -441,8 +435,8 @@ void LLIMMgr::addMessage(
441 // create IM window as necessary 435 // create IM window as necessary
442 if(!floater) 436 if(!floater)
443 { 437 {
444 const char* name = from; 438 std::string name = from;
445 if(session_name && (strlen(session_name)>1)) 439 if(!session_name.empty() && session_name.size()>1)
446 { 440 {
447 name = session_name; 441 name = session_name;
448 } 442 }
@@ -480,7 +474,7 @@ void LLIMMgr::addMessage(
480 } 474 }
481 475
482 // now add message to floater 476 // now add message to floater
483 bool is_from_system = target_id.isNull() || !strcmp(from, SYSTEM_FROM); 477 bool is_from_system = target_id.isNull() || (from == SYSTEM_FROM);
484 const LLColor4& color = ( is_from_system ? 478 const LLColor4& color = ( is_from_system ?
485 gSavedSettings.getColor4("SystemChatColor") : 479 gSavedSettings.getColor4("SystemChatColor") :
486 gSavedSettings.getColor("IMChatColor")); 480 gSavedSettings.getColor("IMChatColor"));
@@ -516,7 +510,7 @@ void LLIMMgr::addMessage(
516 } 510 }
517} 511}
518 512
519void LLIMMgr::addSystemMessage(const LLUUID& session_id, const LLString& message_name, const LLString::format_map_t& args) 513void LLIMMgr::addSystemMessage(const LLUUID& session_id, const std::string& message_name, const LLStringUtil::format_map_t& args)
520{ 514{
521 LLUIString message; 515 LLUIString message;
522 516
@@ -525,7 +519,7 @@ void LLIMMgr::addSystemMessage(const LLUUID& session_id, const LLString& message
525 { 519 {
526 LLFloaterChat* floaterp = LLFloaterChat::getInstance(); 520 LLFloaterChat* floaterp = LLFloaterChat::getInstance();
527 521
528 message = floaterp->getUIString(message_name); 522 message = floaterp->getString(message_name);
529 message.setArgList(args); 523 message.setArgList(args);
530 524
531 LLChat chat(message); 525 LLChat chat(message);
@@ -537,10 +531,10 @@ void LLIMMgr::addSystemMessage(const LLUUID& session_id, const LLString& message
537 LLFloaterIMPanel* floaterp = findFloaterBySession(session_id); 531 LLFloaterIMPanel* floaterp = findFloaterBySession(session_id);
538 if (floaterp) 532 if (floaterp)
539 { 533 {
540 message = floaterp->getUIString(message_name); 534 message = floaterp->getString(message_name);
541 message.setArgList(args); 535 message.setArgList(args);
542 536
543 gIMMgr->addMessage(session_id, LLUUID::null, SYSTEM_FROM, message.getString().c_str()); 537 gIMMgr->addMessage(session_id, LLUUID::null, SYSTEM_FROM, message.getString());
544 } 538 }
545 } 539 }
546} 540}
@@ -574,7 +568,7 @@ BOOL LLIMMgr::isIMSessionOpen(const LLUUID& uuid)
574 568
575LLUUID LLIMMgr::addP2PSession(const std::string& name, 569LLUUID LLIMMgr::addP2PSession(const std::string& name,
576 const LLUUID& other_participant_id, 570 const LLUUID& other_participant_id,
577 const LLString& voice_session_handle) 571 const std::string& voice_session_handle)
578{ 572{
579 LLUUID session_id = addSession(name, IM_NOTHING_SPECIAL, other_participant_id); 573 LLUUID session_id = addSession(name, IM_NOTHING_SPECIAL, other_participant_id);
580 574
@@ -700,12 +694,12 @@ void LLIMMgr::removeSession(const LLUUID& session_id)
700 694
701void LLIMMgr::inviteToSession( 695void LLIMMgr::inviteToSession(
702 const LLUUID& session_id, 696 const LLUUID& session_id,
703 const LLString& session_name, 697 const std::string& session_name,
704 const LLUUID& caller_id, 698 const LLUUID& caller_id,
705 const LLString& caller_name, 699 const std::string& caller_name,
706 EInstantMessage type, 700 EInstantMessage type,
707 EInvitationType inv_type, 701 EInvitationType inv_type,
708 const LLString& session_handle) 702 const std::string& session_handle)
709{ 703{
710 //ignore invites from muted residents 704 //ignore invites from muted residents
711 if (LLMuteList::getInstance()->isMuted(caller_id)) 705 if (LLMuteList::getInstance()->isMuted(caller_id))
@@ -713,7 +707,7 @@ void LLIMMgr::inviteToSession(
713 return; 707 return;
714 } 708 }
715 709
716 LLString notify_box_type; 710 std::string notify_box_type;
717 711
718 BOOL ad_hoc_invite = FALSE; 712 BOOL ad_hoc_invite = FALSE;
719 if(type == IM_SESSION_P2P_INVITE) 713 if(type == IM_SESSION_P2P_INVITE)
@@ -777,11 +771,11 @@ void LLIMMgr::inviteToSession(
777 { 771 {
778 if (caller_name.empty()) 772 if (caller_name.empty())
779 { 773 {
780 gCacheName->getName(caller_id, onInviteNameLookup, invite); 774 gCacheName->get(caller_id, FALSE, onInviteNameLookup, invite);
781 } 775 }
782 else 776 else
783 { 777 {
784 LLString::format_map_t args; 778 LLStringUtil::format_map_t args;
785 args["[NAME]"] = caller_name; 779 args["[NAME]"] = caller_name;
786 args["[GROUP]"] = session_name; 780 args["[GROUP]"] = session_name;
787 781
@@ -800,14 +794,14 @@ void LLIMMgr::inviteToSession(
800} 794}
801 795
802//static 796//static
803void LLIMMgr::onInviteNameLookup(const LLUUID& id, const char* first, const char* last, BOOL is_group, void* userdata) 797void LLIMMgr::onInviteNameLookup(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group, void* userdata)
804{ 798{
805 LLIMSessionInvite* invite = (LLIMSessionInvite*)userdata; 799 LLIMSessionInvite* invite = (LLIMSessionInvite*)userdata;
806 800
807 invite->mCallerName = llformat("%s %s", first, last); 801 invite->mCallerName = first + " " + last;
808 invite->mSessionName = invite->mCallerName; 802 invite->mSessionName = invite->mCallerName;
809 803
810 LLString::format_map_t args; 804 LLStringUtil::format_map_t args;
811 args["[NAME]"] = invite->mCallerName; 805 args["[NAME]"] = invite->mCallerName;
812 806
813 LLNotifyBox::showXml( 807 LLNotifyBox::showXml(
@@ -1421,7 +1415,7 @@ public:
1421 const LLSD& input) const 1415 const LLSD& input) const
1422 { 1416 {
1423 LLUUID session_id; 1417 LLUUID session_id;
1424 LLString reason; 1418 std::string reason;
1425 1419
1426 session_id = input["body"]["session_id"].asUUID(); 1420 session_id = input["body"]["session_id"].asUUID();
1427 reason = input["body"]["reason"].asString(); 1421 reason = input["body"]["reason"].asString();
@@ -1503,7 +1497,6 @@ public:
1503 { 1497 {
1504 return; 1498 return;
1505 } 1499 }
1506 char buffer[DB_IM_MSG_BUF_SIZE * 2]; /* Flawfinder: ignore */
1507 LLChat chat; 1500 LLChat chat;
1508 1501
1509 std::string message = message_params["message"].asString(); 1502 std::string message = message_params["message"].asString();
@@ -1519,19 +1512,18 @@ public:
1519 BOOL is_busy = gAgent.getBusy(); 1512 BOOL is_busy = gAgent.getBusy();
1520 BOOL is_muted = LLMuteList::getInstance()->isMuted( 1513 BOOL is_muted = LLMuteList::getInstance()->isMuted(
1521 from_id, 1514 from_id,
1522 name.c_str(), 1515 name,
1523 LLMute::flagTextChat); 1516 LLMute::flagTextChat);
1524 1517
1525 BOOL is_linden = LLMuteList::getInstance()->isLinden( 1518 BOOL is_linden = LLMuteList::getInstance()->isLinden(name);
1526 name.c_str()); 1519 std::string separator_string(": ");
1527 char separator_string[3]=": "; /* Flawfinder: ignore */
1528 int message_offset=0; 1520 int message_offset=0;
1529 1521
1530 //Handle IRC styled /me messages. 1522 //Handle IRC styled /me messages.
1531 if (!strncmp(message.c_str(), "/me ", 4) || 1523 std::string prefix = message.substr(0, 4);
1532 !strncmp(message.c_str(), "/me'", 4)) 1524 if (prefix == "/me " || prefix == "/me'")
1533 { 1525 {
1534 strcpy(separator_string,""); /* Flawfinder: ignore */ 1526 separator_string = "";
1535 message_offset = 3; 1527 message_offset = 3;
1536 } 1528 }
1537 1529
@@ -1545,23 +1537,12 @@ public:
1545 } 1537 }
1546 1538
1547 // standard message, not from system 1539 // standard message, not from system
1548 char saved[MAX_STRING]; /* Flawfinder: ignore */ 1540 std::string saved;
1549 saved[0] = '\0';
1550 if(offline == IM_OFFLINE) 1541 if(offline == IM_OFFLINE)
1551 { 1542 {
1552 char time_buf[TIME_STR_LENGTH]; /* Flawfinder: ignore */ 1543 saved = llformat("(Saved %s) ", formatted_time(timestamp).c_str());
1553 snprintf(saved, /* Flawfinder: ignore */
1554 MAX_STRING,
1555 "(Saved %s) ",
1556 formatted_time(timestamp, time_buf));
1557 } 1544 }
1558 snprintf( 1545 std::string buffer = separator_string + saved + message.substr(message_offset);
1559 buffer,
1560 sizeof(buffer),
1561 "%s%s%s",
1562 separator_string,
1563 saved,
1564 (message.c_str() + message_offset)); /*Flawfinder: ignore*/
1565 1546
1566 BOOL is_this_agent = FALSE; 1547 BOOL is_this_agent = FALSE;
1567 if(from_id == gAgentID) 1548 if(from_id == gAgentID)
@@ -1571,24 +1552,16 @@ public:
1571 gIMMgr->addMessage( 1552 gIMMgr->addMessage(
1572 session_id, 1553 session_id,
1573 from_id, 1554 from_id,
1574 name.c_str(), 1555 name,
1575 buffer, 1556 buffer,
1576 (char*)&bin_bucket[0], 1557 std::string((char*)&bin_bucket[0]),
1577 IM_SESSION_INVITE, 1558 IM_SESSION_INVITE,
1578 message_params["parent_estate_id"].asInteger(), 1559 message_params["parent_estate_id"].asInteger(),
1579 message_params["region_id"].asUUID(), 1560 message_params["region_id"].asUUID(),
1580 ll_vector3_from_sd(message_params["position"]), 1561 ll_vector3_from_sd(message_params["position"]),
1581 true); 1562 true);
1582 1563
1583 snprintf( 1564 chat.mText = std::string("IM: ") + name + separator_string + saved + message.substr(message_offset);
1584 buffer,
1585 sizeof(buffer),
1586 "IM: %s%s%s%s",
1587 name.c_str(),
1588 separator_string,
1589 saved,
1590 (message.c_str()+message_offset)); /* Flawfinder: ignore */
1591 chat.mText = buffer;
1592 LLFloaterChat::addChat(chat, TRUE, is_this_agent); 1565 LLFloaterChat::addChat(chat, TRUE, is_this_agent);
1593 1566
1594 //K now we want to accept the invitation 1567 //K now we want to accept the invitation