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.cpp111
1 files changed, 45 insertions, 66 deletions
diff --git a/linden/indra/newview/llimview.cpp b/linden/indra/newview/llimview.cpp
index e6169d5..309e479 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
@@ -267,13 +267,13 @@ class LLIMMgr::LLIMSessionInvite
267public: 267public:
268 LLIMSessionInvite( 268 LLIMSessionInvite(
269 const LLUUID& session_id, 269 const LLUUID& session_id,
270 const LLString& session_name, 270 const std::string& session_name,
271 const LLUUID& caller_id, 271 const LLUUID& caller_id,
272 const LLString& caller_name, 272 const std::string& caller_name,
273 EInstantMessage type, 273 EInstantMessage type,
274 EInvitationType inv_type, 274 EInvitationType inv_type,
275 const LLString& session_handle, 275 const std::string& session_handle,
276 const LLString& notify_box) : 276 const std::string& notify_box) :
277 mSessionID(session_id), 277 mSessionID(session_id),
278 mSessionName(session_name), 278 mSessionName(session_name),
279 mCallerID(caller_id), 279 mCallerID(caller_id),
@@ -285,13 +285,13 @@ public:
285 {}; 285 {};
286 286
287 LLUUID mSessionID; 287 LLUUID mSessionID;
288 LLString mSessionName; 288 std::string mSessionName;
289 LLUUID mCallerID; 289 LLUUID mCallerID;
290 LLString mCallerName; 290 std::string mCallerName;
291 EInstantMessage mType; 291 EInstantMessage mType;
292 EInvitationType mInvType; 292 EInvitationType mInvType;
293 LLString mSessionHandle; 293 std::string mSessionHandle;
294 LLString mNotifyBox; 294 std::string mNotifyBox;
295}; 295};
296 296
297 297
@@ -394,9 +394,9 @@ LLIMMgr::~LLIMMgr()
394void LLIMMgr::addMessage( 394void LLIMMgr::addMessage(
395 const LLUUID& session_id, 395 const LLUUID& session_id,
396 const LLUUID& target_id, 396 const LLUUID& target_id,
397 const char* from, 397 const std::string& from,
398 const char* msg, 398 const std::string& msg,
399 const char* session_name, 399 const std::string& session_name,
400 EInstantMessage dialog, 400 EInstantMessage dialog,
401 U32 parent_estate_id, 401 U32 parent_estate_id,
402 const LLUUID& region_id, 402 const LLUUID& region_id,
@@ -441,8 +441,8 @@ void LLIMMgr::addMessage(
441 // create IM window as necessary 441 // create IM window as necessary
442 if(!floater) 442 if(!floater)
443 { 443 {
444 const char* name = from; 444 std::string name = from;
445 if(session_name && (strlen(session_name)>1)) 445 if(!session_name.empty() && session_name.size()>1)
446 { 446 {
447 name = session_name; 447 name = session_name;
448 } 448 }
@@ -480,7 +480,7 @@ void LLIMMgr::addMessage(
480 } 480 }
481 481
482 // now add message to floater 482 // now add message to floater
483 bool is_from_system = target_id.isNull() || !strcmp(from, SYSTEM_FROM); 483 bool is_from_system = target_id.isNull() || (from == SYSTEM_FROM);
484 const LLColor4& color = ( is_from_system ? 484 const LLColor4& color = ( is_from_system ?
485 gSavedSettings.getColor4("SystemChatColor") : 485 gSavedSettings.getColor4("SystemChatColor") :
486 gSavedSettings.getColor("IMChatColor")); 486 gSavedSettings.getColor("IMChatColor"));
@@ -516,7 +516,7 @@ void LLIMMgr::addMessage(
516 } 516 }
517} 517}
518 518
519void LLIMMgr::addSystemMessage(const LLUUID& session_id, const LLString& message_name, const LLString::format_map_t& args) 519void LLIMMgr::addSystemMessage(const LLUUID& session_id, const std::string& message_name, const LLStringUtil::format_map_t& args)
520{ 520{
521 LLUIString message; 521 LLUIString message;
522 522
@@ -540,7 +540,7 @@ void LLIMMgr::addSystemMessage(const LLUUID& session_id, const LLString& message
540 message = floaterp->getUIString(message_name); 540 message = floaterp->getUIString(message_name);
541 message.setArgList(args); 541 message.setArgList(args);
542 542
543 gIMMgr->addMessage(session_id, LLUUID::null, SYSTEM_FROM, message.getString().c_str()); 543 gIMMgr->addMessage(session_id, LLUUID::null, SYSTEM_FROM, message.getString());
544 } 544 }
545 } 545 }
546} 546}
@@ -574,7 +574,7 @@ BOOL LLIMMgr::isIMSessionOpen(const LLUUID& uuid)
574 574
575LLUUID LLIMMgr::addP2PSession(const std::string& name, 575LLUUID LLIMMgr::addP2PSession(const std::string& name,
576 const LLUUID& other_participant_id, 576 const LLUUID& other_participant_id,
577 const LLString& voice_session_handle) 577 const std::string& voice_session_handle)
578{ 578{
579 LLUUID session_id = addSession(name, IM_NOTHING_SPECIAL, other_participant_id); 579 LLUUID session_id = addSession(name, IM_NOTHING_SPECIAL, other_participant_id);
580 580
@@ -700,12 +700,12 @@ void LLIMMgr::removeSession(const LLUUID& session_id)
700 700
701void LLIMMgr::inviteToSession( 701void LLIMMgr::inviteToSession(
702 const LLUUID& session_id, 702 const LLUUID& session_id,
703 const LLString& session_name, 703 const std::string& session_name,
704 const LLUUID& caller_id, 704 const LLUUID& caller_id,
705 const LLString& caller_name, 705 const std::string& caller_name,
706 EInstantMessage type, 706 EInstantMessage type,
707 EInvitationType inv_type, 707 EInvitationType inv_type,
708 const LLString& session_handle) 708 const std::string& session_handle)
709{ 709{
710 //ignore invites from muted residents 710 //ignore invites from muted residents
711 if (LLMuteList::getInstance()->isMuted(caller_id)) 711 if (LLMuteList::getInstance()->isMuted(caller_id))
@@ -713,7 +713,7 @@ void LLIMMgr::inviteToSession(
713 return; 713 return;
714 } 714 }
715 715
716 LLString notify_box_type; 716 std::string notify_box_type;
717 717
718 BOOL ad_hoc_invite = FALSE; 718 BOOL ad_hoc_invite = FALSE;
719 if(type == IM_SESSION_P2P_INVITE) 719 if(type == IM_SESSION_P2P_INVITE)
@@ -777,11 +777,11 @@ void LLIMMgr::inviteToSession(
777 { 777 {
778 if (caller_name.empty()) 778 if (caller_name.empty())
779 { 779 {
780 gCacheName->getName(caller_id, onInviteNameLookup, invite); 780 gCacheName->get(caller_id, FALSE, onInviteNameLookup, invite);
781 } 781 }
782 else 782 else
783 { 783 {
784 LLString::format_map_t args; 784 LLStringUtil::format_map_t args;
785 args["[NAME]"] = caller_name; 785 args["[NAME]"] = caller_name;
786 args["[GROUP]"] = session_name; 786 args["[GROUP]"] = session_name;
787 787
@@ -800,14 +800,14 @@ void LLIMMgr::inviteToSession(
800} 800}
801 801
802//static 802//static
803void LLIMMgr::onInviteNameLookup(const LLUUID& id, const char* first, const char* last, BOOL is_group, void* userdata) 803void LLIMMgr::onInviteNameLookup(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group, void* userdata)
804{ 804{
805 LLIMSessionInvite* invite = (LLIMSessionInvite*)userdata; 805 LLIMSessionInvite* invite = (LLIMSessionInvite*)userdata;
806 806
807 invite->mCallerName = llformat("%s %s", first, last); 807 invite->mCallerName = first + " " + last;
808 invite->mSessionName = invite->mCallerName; 808 invite->mSessionName = invite->mCallerName;
809 809
810 LLString::format_map_t args; 810 LLStringUtil::format_map_t args;
811 args["[NAME]"] = invite->mCallerName; 811 args["[NAME]"] = invite->mCallerName;
812 812
813 LLNotifyBox::showXml( 813 LLNotifyBox::showXml(
@@ -1421,7 +1421,7 @@ public:
1421 const LLSD& input) const 1421 const LLSD& input) const
1422 { 1422 {
1423 LLUUID session_id; 1423 LLUUID session_id;
1424 LLString reason; 1424 std::string reason;
1425 1425
1426 session_id = input["body"]["session_id"].asUUID(); 1426 session_id = input["body"]["session_id"].asUUID();
1427 reason = input["body"]["reason"].asString(); 1427 reason = input["body"]["reason"].asString();
@@ -1503,7 +1503,6 @@ public:
1503 { 1503 {
1504 return; 1504 return;
1505 } 1505 }
1506 char buffer[DB_IM_MSG_BUF_SIZE * 2]; /* Flawfinder: ignore */
1507 LLChat chat; 1506 LLChat chat;
1508 1507
1509 std::string message = message_params["message"].asString(); 1508 std::string message = message_params["message"].asString();
@@ -1519,19 +1518,18 @@ public:
1519 BOOL is_busy = gAgent.getBusy(); 1518 BOOL is_busy = gAgent.getBusy();
1520 BOOL is_muted = LLMuteList::getInstance()->isMuted( 1519 BOOL is_muted = LLMuteList::getInstance()->isMuted(
1521 from_id, 1520 from_id,
1522 name.c_str(), 1521 name,
1523 LLMute::flagTextChat); 1522 LLMute::flagTextChat);
1524 1523
1525 BOOL is_linden = LLMuteList::getInstance()->isLinden( 1524 BOOL is_linden = LLMuteList::getInstance()->isLinden(name);
1526 name.c_str()); 1525 std::string separator_string(": ");
1527 char separator_string[3]=": "; /* Flawfinder: ignore */
1528 int message_offset=0; 1526 int message_offset=0;
1529 1527
1530 //Handle IRC styled /me messages. 1528 //Handle IRC styled /me messages.
1531 if (!strncmp(message.c_str(), "/me ", 4) || 1529 std::string prefix = message.substr(0, 4);
1532 !strncmp(message.c_str(), "/me'", 4)) 1530 if (prefix == "/me " || prefix == "/me'")
1533 { 1531 {
1534 strcpy(separator_string,""); /* Flawfinder: ignore */ 1532 separator_string = "";
1535 message_offset = 3; 1533 message_offset = 3;
1536 } 1534 }
1537 1535
@@ -1545,23 +1543,12 @@ public:
1545 } 1543 }
1546 1544
1547 // standard message, not from system 1545 // standard message, not from system
1548 char saved[MAX_STRING]; /* Flawfinder: ignore */ 1546 std::string saved;
1549 saved[0] = '\0';
1550 if(offline == IM_OFFLINE) 1547 if(offline == IM_OFFLINE)
1551 { 1548 {
1552 char time_buf[TIME_STR_LENGTH]; /* Flawfinder: ignore */ 1549 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 } 1550 }
1558 snprintf( 1551 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 1552
1566 BOOL is_this_agent = FALSE; 1553 BOOL is_this_agent = FALSE;
1567 if(from_id == gAgentID) 1554 if(from_id == gAgentID)
@@ -1571,24 +1558,16 @@ public:
1571 gIMMgr->addMessage( 1558 gIMMgr->addMessage(
1572 session_id, 1559 session_id,
1573 from_id, 1560 from_id,
1574 name.c_str(), 1561 name,
1575 buffer, 1562 buffer,
1576 (char*)&bin_bucket[0], 1563 std::string((char*)&bin_bucket[0]),
1577 IM_SESSION_INVITE, 1564 IM_SESSION_INVITE,
1578 message_params["parent_estate_id"].asInteger(), 1565 message_params["parent_estate_id"].asInteger(),
1579 message_params["region_id"].asUUID(), 1566 message_params["region_id"].asUUID(),
1580 ll_vector3_from_sd(message_params["position"]), 1567 ll_vector3_from_sd(message_params["position"]),
1581 true); 1568 true);
1582 1569
1583 snprintf( 1570 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); 1571 LLFloaterChat::addChat(chat, TRUE, is_this_agent);
1593 1572
1594 //K now we want to accept the invitation 1573 //K now we want to accept the invitation