diff options
author | Jacek Antonelli | 2008-09-06 18:24:57 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-09-06 18:25:07 -0500 |
commit | 798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch) | |
tree | 1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/newview/llmutelist.cpp | |
parent | Second Life viewer sources 1.20.15 (diff) | |
download | meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2 meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz |
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/newview/llmutelist.cpp')
-rw-r--r-- | linden/indra/newview/llmutelist.cpp | 78 |
1 files changed, 38 insertions, 40 deletions
diff --git a/linden/indra/newview/llmutelist.cpp b/linden/indra/newview/llmutelist.cpp index 408b70e..0cdfe83 100644 --- a/linden/indra/newview/llmutelist.cpp +++ b/linden/indra/newview/llmutelist.cpp | |||
@@ -97,9 +97,9 @@ const char AGENT_SUFFIX[] = " (resident)"; | |||
97 | const char OBJECT_SUFFIX[] = " (object)"; | 97 | const char OBJECT_SUFFIX[] = " (object)"; |
98 | const char GROUP_SUFFIX[] = " (group)"; | 98 | const char GROUP_SUFFIX[] = " (group)"; |
99 | 99 | ||
100 | LLString LLMute::getDisplayName() const | 100 | std::string LLMute::getDisplayName() const |
101 | { | 101 | { |
102 | LLString name_with_suffix = mName; | 102 | std::string name_with_suffix = mName; |
103 | switch (mType) | 103 | switch (mType) |
104 | { | 104 | { |
105 | case BY_NAME: | 105 | case BY_NAME: |
@@ -119,7 +119,7 @@ LLString LLMute::getDisplayName() const | |||
119 | return name_with_suffix; | 119 | return name_with_suffix; |
120 | } | 120 | } |
121 | 121 | ||
122 | void LLMute::setFromDisplayName(const LLString& display_name) | 122 | void LLMute::setFromDisplayName(const std::string& display_name) |
123 | { | 123 | { |
124 | size_t pos = 0; | 124 | size_t pos = 0; |
125 | mName = display_name; | 125 | mName = display_name; |
@@ -198,7 +198,7 @@ void LLMuteList::loadUserVolumes() | |||
198 | 198 | ||
199 | LLSD settings_llsd; | 199 | LLSD settings_llsd; |
200 | llifstream file; | 200 | llifstream file; |
201 | file.open(filename.c_str()); | 201 | file.open(filename); |
202 | if (file.is_open()) | 202 | if (file.is_open()) |
203 | { | 203 | { |
204 | LLSDSerialize::fromXML(settings_llsd, file); | 204 | LLSDSerialize::fromXML(settings_llsd, file); |
@@ -225,11 +225,11 @@ LLMuteList::~LLMuteList() | |||
225 | } | 225 | } |
226 | 226 | ||
227 | llofstream file; | 227 | llofstream file; |
228 | file.open(filename.c_str()); | 228 | file.open(filename); |
229 | LLSDSerialize::toPrettyXML(settings_llsd, file); | 229 | LLSDSerialize::toPrettyXML(settings_llsd, file); |
230 | } | 230 | } |
231 | 231 | ||
232 | BOOL LLMuteList::isLinden(const LLString& name) const | 232 | BOOL LLMuteList::isLinden(const std::string& name) const |
233 | { | 233 | { |
234 | typedef boost::tokenizer<boost::char_separator<char> > tokenizer; | 234 | typedef boost::tokenizer<boost::char_separator<char> > tokenizer; |
235 | boost::char_separator<char> sep(" "); | 235 | boost::char_separator<char> sep(" "); |
@@ -240,7 +240,7 @@ BOOL LLMuteList::isLinden(const LLString& name) const | |||
240 | token_iter++; | 240 | token_iter++; |
241 | if (token_iter == tokens.end()) return FALSE; | 241 | if (token_iter == tokens.end()) return FALSE; |
242 | 242 | ||
243 | LLString last_name = *token_iter; | 243 | std::string last_name = *token_iter; |
244 | return last_name == "Linden"; | 244 | return last_name == "Linden"; |
245 | } | 245 | } |
246 | 246 | ||
@@ -449,9 +449,9 @@ void LLMuteList::updateRemove(const LLMute& mute) | |||
449 | gAgent.sendReliableMessage(); | 449 | gAgent.sendReliableMessage(); |
450 | } | 450 | } |
451 | 451 | ||
452 | void notify_automute_callback(const LLUUID& agent_id, const char* first_name, const char* last_name, BOOL is_group, void* user_data) | 452 | void notify_automute_callback(const LLUUID& agent_id, const std::string& first_name, const std::string& last_name, BOOL is_group, void* user_data) |
453 | { | 453 | { |
454 | U32 temp_data = (U32)user_data; | 454 | U32 temp_data = (U32) (uintptr_t) user_data; |
455 | LLMuteList::EAutoReason reason = (LLMuteList::EAutoReason)temp_data; | 455 | LLMuteList::EAutoReason reason = (LLMuteList::EAutoReason)temp_data; |
456 | LLUIString auto_message; | 456 | LLUIString auto_message; |
457 | 457 | ||
@@ -486,20 +486,19 @@ void notify_automute_callback(const LLUUID& agent_id, const char* first_name, co | |||
486 | } | 486 | } |
487 | 487 | ||
488 | 488 | ||
489 | BOOL LLMuteList::autoRemove(const LLUUID& agent_id, const EAutoReason reason, const LLString& first_name, const LLString& last_name) | 489 | BOOL LLMuteList::autoRemove(const LLUUID& agent_id, const EAutoReason reason, const std::string& first_name, const std::string& last_name) |
490 | { | 490 | { |
491 | BOOL removed = FALSE; | 491 | BOOL removed = FALSE; |
492 | 492 | ||
493 | if (isMuted(agent_id)) | 493 | if (isMuted(agent_id)) |
494 | { | 494 | { |
495 | LLMute automute(agent_id, "", LLMute::AGENT); | 495 | LLMute automute(agent_id, LLStringUtil::null, LLMute::AGENT); |
496 | removed = TRUE; | 496 | removed = TRUE; |
497 | remove(automute); | 497 | remove(automute); |
498 | 498 | ||
499 | if (first_name.empty() && last_name.empty()) | 499 | if (first_name.empty() && last_name.empty()) |
500 | { | 500 | { |
501 | char cache_first[DB_FIRST_NAME_BUF_SIZE]; /* Flawfinder: ignore */ | 501 | std::string cache_first, cache_last; |
502 | char cache_last[DB_LAST_NAME_BUF_SIZE]; /* Flawfinder: ignore */ | ||
503 | if (gCacheName->getName(agent_id, cache_first, cache_last)) | 502 | if (gCacheName->getName(agent_id, cache_first, cache_last)) |
504 | { | 503 | { |
505 | // name in cache, call callback directly | 504 | // name in cache, call callback directly |
@@ -514,7 +513,7 @@ BOOL LLMuteList::autoRemove(const LLUUID& agent_id, const EAutoReason reason, co | |||
514 | else | 513 | else |
515 | { | 514 | { |
516 | // call callback directly | 515 | // call callback directly |
517 | notify_automute_callback(agent_id, first_name.c_str(), last_name.c_str(), FALSE, (void *)reason); | 516 | notify_automute_callback(agent_id, first_name, last_name, FALSE, (void *)reason); |
518 | } | 517 | } |
519 | } | 518 | } |
520 | 519 | ||
@@ -548,7 +547,7 @@ std::vector<LLMute> LLMuteList::getMutes() const | |||
548 | //----------------------------------------------------------------------------- | 547 | //----------------------------------------------------------------------------- |
549 | // loadFromFile() | 548 | // loadFromFile() |
550 | //----------------------------------------------------------------------------- | 549 | //----------------------------------------------------------------------------- |
551 | BOOL LLMuteList::loadFromFile(const LLString& filename) | 550 | BOOL LLMuteList::loadFromFile(const std::string& filename) |
552 | { | 551 | { |
553 | if(!filename.size()) | 552 | if(!filename.size()) |
554 | { | 553 | { |
@@ -556,7 +555,7 @@ BOOL LLMuteList::loadFromFile(const LLString& filename) | |||
556 | return FALSE; | 555 | return FALSE; |
557 | } | 556 | } |
558 | 557 | ||
559 | LLFILE* fp = LLFile::fopen(filename.c_str(), "rb"); /*Flawfinder: ignore*/ | 558 | LLFILE* fp = LLFile::fopen(filename, "rb"); /*Flawfinder: ignore*/ |
560 | if (!fp) | 559 | if (!fp) |
561 | { | 560 | { |
562 | llwarns << "Couldn't open mute list " << filename << llendl; | 561 | llwarns << "Couldn't open mute list " << filename << llendl; |
@@ -579,7 +578,7 @@ BOOL LLMuteList::loadFromFile(const LLString& filename) | |||
579 | buffer, " %d %254s %254[^|]| %u\n", &type, id_buffer, name_buffer, | 578 | buffer, " %d %254s %254[^|]| %u\n", &type, id_buffer, name_buffer, |
580 | &flags); | 579 | &flags); |
581 | LLUUID id = LLUUID(id_buffer); | 580 | LLUUID id = LLUUID(id_buffer); |
582 | LLMute mute(id, name_buffer, (LLMute::EType)type, flags); | 581 | LLMute mute(id, std::string(name_buffer), (LLMute::EType)type, flags); |
583 | if (mute.mID.isNull() | 582 | if (mute.mID.isNull() |
584 | || mute.mType == LLMute::BY_NAME) | 583 | || mute.mType == LLMute::BY_NAME) |
585 | { | 584 | { |
@@ -598,7 +597,7 @@ BOOL LLMuteList::loadFromFile(const LLString& filename) | |||
598 | //----------------------------------------------------------------------------- | 597 | //----------------------------------------------------------------------------- |
599 | // saveToFile() | 598 | // saveToFile() |
600 | //----------------------------------------------------------------------------- | 599 | //----------------------------------------------------------------------------- |
601 | BOOL LLMuteList::saveToFile(const LLString& filename) | 600 | BOOL LLMuteList::saveToFile(const std::string& filename) |
602 | { | 601 | { |
603 | if(!filename.size()) | 602 | if(!filename.size()) |
604 | { | 603 | { |
@@ -606,35 +605,35 @@ BOOL LLMuteList::saveToFile(const LLString& filename) | |||
606 | return FALSE; | 605 | return FALSE; |
607 | } | 606 | } |
608 | 607 | ||
609 | LLFILE* fp = LLFile::fopen(filename.c_str(), "wb"); /*Flawfinder: ignore*/ | 608 | LLFILE* fp = LLFile::fopen(filename, "wb"); /*Flawfinder: ignore*/ |
610 | if (!fp) | 609 | if (!fp) |
611 | { | 610 | { |
612 | llwarns << "Couldn't open mute list " << filename << llendl; | 611 | llwarns << "Couldn't open mute list " << filename << llendl; |
613 | return FALSE; | 612 | return FALSE; |
614 | } | 613 | } |
615 | // legacy mutes have null uuid | 614 | // legacy mutes have null uuid |
616 | char id_string[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ | 615 | std::string id_string; |
617 | LLUUID::null.toString(id_string); | 616 | LLUUID::null.toString(id_string); |
618 | for (string_set_t::iterator it = mLegacyMutes.begin(); | 617 | for (string_set_t::iterator it = mLegacyMutes.begin(); |
619 | it != mLegacyMutes.end(); | 618 | it != mLegacyMutes.end(); |
620 | ++it) | 619 | ++it) |
621 | { | 620 | { |
622 | fprintf(fp, "%d %s %s|\n", (S32)LLMute::BY_NAME, id_string, it->c_str()); | 621 | fprintf(fp, "%d %s %s|\n", (S32)LLMute::BY_NAME, id_string.c_str(), it->c_str()); |
623 | } | 622 | } |
624 | for (mute_set_t::iterator it = mMutes.begin(); | 623 | for (mute_set_t::iterator it = mMutes.begin(); |
625 | it != mMutes.end(); | 624 | it != mMutes.end(); |
626 | ++it) | 625 | ++it) |
627 | { | 626 | { |
628 | it->mID.toString(id_string); | 627 | it->mID.toString(id_string); |
629 | const LLString& name = it->mName; | 628 | const std::string& name = it->mName; |
630 | fprintf(fp, "%d %s %s|%u\n", (S32)it->mType, id_string, name.c_str(), it->mFlags); | 629 | fprintf(fp, "%d %s %s|%u\n", (S32)it->mType, id_string.c_str(), name.c_str(), it->mFlags); |
631 | } | 630 | } |
632 | fclose(fp); | 631 | fclose(fp); |
633 | return TRUE; | 632 | return TRUE; |
634 | } | 633 | } |
635 | 634 | ||
636 | 635 | ||
637 | BOOL LLMuteList::isMuted(const LLUUID& id, const LLString& name, U32 flags) const | 636 | BOOL LLMuteList::isMuted(const LLUUID& id, const std::string& name, U32 flags) const |
638 | { | 637 | { |
639 | LLUUID id_to_check = id; | 638 | LLUUID id_to_check = id; |
640 | 639 | ||
@@ -677,10 +676,10 @@ void LLMuteList::requestFromServer(const LLUUID& agent_id) | |||
677 | { | 676 | { |
678 | loadUserVolumes(); | 677 | loadUserVolumes(); |
679 | 678 | ||
680 | char agent_id_string[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ | 679 | std::string agent_id_string; |
681 | char filename[LL_MAX_PATH]; /*Flawfinder: ignore*/ | 680 | std::string filename; |
682 | agent_id.toString(agent_id_string); | 681 | agent_id.toString(agent_id_string); |
683 | snprintf(filename, sizeof(filename), "%s.cached_mute", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,agent_id_string).c_str()); /* Flawfinder: ignore */ | 682 | filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,agent_id_string) + ".cached_mute"; |
684 | LLCRC crc; | 683 | LLCRC crc; |
685 | crc.update(filename); | 684 | crc.update(filename); |
686 | 685 | ||
@@ -703,10 +702,10 @@ void LLMuteList::cache(const LLUUID& agent_id) | |||
703 | // Write to disk even if empty. | 702 | // Write to disk even if empty. |
704 | if(mIsLoaded) | 703 | if(mIsLoaded) |
705 | { | 704 | { |
706 | char agent_id_string[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ | 705 | std::string agent_id_string; |
707 | char filename[LL_MAX_PATH]; /*Flawfinder: ignore*/ | 706 | std::string filename; |
708 | agent_id.toString(agent_id_string); | 707 | agent_id.toString(agent_id_string); |
709 | snprintf(filename, sizeof(filename), "%s.cached_mute", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,agent_id_string).c_str()); /* Flawfinder: ignore */ | 708 | filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,agent_id_string) + ".cached_mute"; |
710 | saveToFile(filename); | 709 | saveToFile(filename); |
711 | } | 710 | } |
712 | } | 711 | } |
@@ -745,12 +744,11 @@ void LLMuteList::processMuteListUpdate(LLMessageSystem* msg, void**) | |||
745 | llwarns << "Got an mute list update for the wrong agent." << llendl; | 744 | llwarns << "Got an mute list update for the wrong agent." << llendl; |
746 | return; | 745 | return; |
747 | } | 746 | } |
748 | char filename[MAX_STRING]; /*Flawfinder: ignore*/ | 747 | std::string filename; |
749 | filename[0] = '\0'; | 748 | msg->getStringFast(_PREHASH_MuteData, _PREHASH_Filename, filename); |
750 | msg->getStringFast(_PREHASH_MuteData, _PREHASH_Filename, MAX_STRING, filename); | ||
751 | 749 | ||
752 | std::string *local_filename_and_path = new std::string(gDirUtilp->getExpandedFilename( LL_PATH_CACHE, filename )); | 750 | std::string *local_filename_and_path = new std::string(gDirUtilp->getExpandedFilename( LL_PATH_CACHE, filename )); |
753 | gXferManager->requestFile(local_filename_and_path->c_str(), | 751 | gXferManager->requestFile(*local_filename_and_path, |
754 | filename, | 752 | filename, |
755 | LL_PATH_CACHE, | 753 | LL_PATH_CACHE, |
756 | msg->getSender(), | 754 | msg->getSender(), |
@@ -764,10 +762,10 @@ void LLMuteList::processUseCachedMuteList(LLMessageSystem* msg, void**) | |||
764 | { | 762 | { |
765 | llinfos << "LLMuteList::processUseCachedMuteList()" << llendl; | 763 | llinfos << "LLMuteList::processUseCachedMuteList()" << llendl; |
766 | 764 | ||
767 | char agent_id_string[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ | 765 | std::string agent_id_string; |
768 | gAgent.getID().toString(agent_id_string); | 766 | gAgent.getID().toString(agent_id_string); |
769 | char filename[LL_MAX_PATH]; /*Flawfinder: ignore*/ | 767 | std::string filename; |
770 | snprintf(filename, sizeof(filename), "%s.cached_mute", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,agent_id_string).c_str()); /* Flawfinder: ignore */ | 768 | filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,agent_id_string) + ".cached_mute"; |
771 | LLMuteList::getInstance()->loadFromFile(filename); | 769 | LLMuteList::getInstance()->loadFromFile(filename); |
772 | } | 770 | } |
773 | 771 | ||
@@ -775,11 +773,11 @@ void LLMuteList::onFileMuteList(void** user_data, S32 error_code, LLExtStat ext_ | |||
775 | { | 773 | { |
776 | llinfos << "LLMuteList::processMuteListFile()" << llendl; | 774 | llinfos << "LLMuteList::processMuteListFile()" << llendl; |
777 | 775 | ||
778 | std::string *local_filename_and_path = (std::string*)user_data; | 776 | std::string* local_filename_and_path = (std::string*)user_data; |
779 | if(local_filename_and_path && !local_filename_and_path->empty() && (error_code == 0)) | 777 | if(local_filename_and_path && !local_filename_and_path->empty() && (error_code == 0)) |
780 | { | 778 | { |
781 | LLMuteList::getInstance()->loadFromFile(local_filename_and_path->c_str()); | 779 | LLMuteList::getInstance()->loadFromFile(*local_filename_and_path); |
782 | LLFile::remove(local_filename_and_path->c_str()); | 780 | LLFile::remove(*local_filename_and_path); |
783 | } | 781 | } |
784 | delete local_filename_and_path; | 782 | delete local_filename_and_path; |
785 | } | 783 | } |