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/llmessage/llcachename.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 '')
-rw-r--r-- | linden/indra/llmessage/llcachename.cpp | 80 |
1 files changed, 24 insertions, 56 deletions
diff --git a/linden/indra/llmessage/llcachename.cpp b/linden/indra/llmessage/llcachename.cpp index 9adf10d..70e1ccf 100644 --- a/linden/indra/llmessage/llcachename.cpp +++ b/linden/indra/llmessage/llcachename.cpp | |||
@@ -43,10 +43,9 @@ | |||
43 | #include "message.h" | 43 | #include "message.h" |
44 | 44 | ||
45 | // Constants | 45 | // Constants |
46 | // probably need a setUIString() call in the interface | 46 | static const std::string CN_WAITING("(Loading...)"); // *TODO: translate |
47 | const char* const CN_WAITING = "(Loading...)"; // *TODO: translate | 47 | static const std::string CN_NOBODY("(nobody)"); // *TODO: translate |
48 | const char* const CN_NOBODY = "(nobody)"; // *TODO: translate | 48 | static const std::string CN_NONE("(none)"); // *TODO: translate |
49 | const char* const CN_NONE = "(none)"; // *TODO: translate | ||
50 | 49 | ||
51 | // llsd serialization constants | 50 | // llsd serialization constants |
52 | static const std::string AGENTS("agents"); | 51 | static const std::string AGENTS("agents"); |
@@ -78,16 +77,13 @@ public: | |||
78 | public: | 77 | public: |
79 | bool mIsGroup; | 78 | bool mIsGroup; |
80 | U32 mCreateTime; // unix time_t | 79 | U32 mCreateTime; // unix time_t |
81 | char mFirstName[DB_FIRST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ | 80 | std::string mFirstName; |
82 | char mLastName[DB_LAST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ | 81 | std::string mLastName; |
83 | char mGroupName[DB_GROUP_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ | 82 | std::string mGroupName; |
84 | }; | 83 | }; |
85 | 84 | ||
86 | LLCacheNameEntry::LLCacheNameEntry() | 85 | LLCacheNameEntry::LLCacheNameEntry() |
87 | { | 86 | { |
88 | mFirstName[0] = '\0'; | ||
89 | mLastName[0] = '\0'; | ||
90 | mGroupName[0] = '\0'; | ||
91 | } | 87 | } |
92 | 88 | ||
93 | 89 | ||
@@ -235,7 +231,7 @@ public: | |||
235 | static void handleUUIDGroupNameRequest(LLMessageSystem* msg, void** userdata); | 231 | static void handleUUIDGroupNameRequest(LLMessageSystem* msg, void** userdata); |
236 | static void handleUUIDGroupNameReply(LLMessageSystem* msg, void** userdata); | 232 | static void handleUUIDGroupNameReply(LLMessageSystem* msg, void** userdata); |
237 | 233 | ||
238 | void notifyObservers(const LLUUID& id, const char* first, const char* last, BOOL group); | 234 | void notifyObservers(const LLUUID& id, const std::string& first, const std::string& last, BOOL group); |
239 | }; | 235 | }; |
240 | 236 | ||
241 | 237 | ||
@@ -390,8 +386,8 @@ void LLCacheName::importFile(LLFILE* fp) | |||
390 | LLCacheNameEntry* entry = new LLCacheNameEntry(); | 386 | LLCacheNameEntry* entry = new LLCacheNameEntry(); |
391 | entry->mIsGroup = false; | 387 | entry->mIsGroup = false; |
392 | entry->mCreateTime = create_time; | 388 | entry->mCreateTime = create_time; |
393 | LLString::copy(entry->mFirstName, firstname, DB_FIRST_NAME_BUF_SIZE); | 389 | entry->mFirstName = firstname; |
394 | LLString::copy(entry->mLastName, lastname, DB_LAST_NAME_BUF_SIZE); | 390 | entry->mLastName = lastname; |
395 | impl.mCache[id] = entry; | 391 | impl.mCache[id] = entry; |
396 | 392 | ||
397 | count++; | 393 | count++; |
@@ -426,12 +422,8 @@ bool LLCacheName::importFile(std::istream& istr) | |||
426 | LLCacheNameEntry* entry = new LLCacheNameEntry(); | 422 | LLCacheNameEntry* entry = new LLCacheNameEntry(); |
427 | entry->mIsGroup = false; | 423 | entry->mIsGroup = false; |
428 | entry->mCreateTime = ctime; | 424 | entry->mCreateTime = ctime; |
429 | std::string first = agent[FIRST].asString(); | 425 | entry->mFirstName = agent[FIRST].asString(); |
430 | first.copy(entry->mFirstName, DB_FIRST_NAME_BUF_SIZE, 0); | 426 | entry->mLastName = agent[LAST].asString(); |
431 | entry->mFirstName[llmin(first.size(),(std::string::size_type)DB_FIRST_NAME_BUF_SIZE-1)] = '\0'; | ||
432 | std::string last = agent[LAST].asString(); | ||
433 | last.copy(entry->mLastName, DB_LAST_NAME_BUF_SIZE, 0); | ||
434 | entry->mLastName[llmin(last.size(),(std::string::size_type)DB_LAST_NAME_BUF_SIZE-1)] = '\0'; | ||
435 | impl.mCache[id] = entry; | 427 | impl.mCache[id] = entry; |
436 | ++count; | 428 | ++count; |
437 | } | 429 | } |
@@ -451,9 +443,7 @@ bool LLCacheName::importFile(std::istream& istr) | |||
451 | LLCacheNameEntry* entry = new LLCacheNameEntry(); | 443 | LLCacheNameEntry* entry = new LLCacheNameEntry(); |
452 | entry->mIsGroup = true; | 444 | entry->mIsGroup = true; |
453 | entry->mCreateTime = ctime; | 445 | entry->mCreateTime = ctime; |
454 | std::string name = group[NAME].asString(); | 446 | entry->mGroupName = group[NAME].asString(); |
455 | name.copy(entry->mGroupName, DB_GROUP_NAME_BUF_SIZE, 0); | ||
456 | entry->mGroupName[llmin(name.size(), (std::string::size_type)DB_GROUP_NAME_BUF_SIZE-1)] = '\0'; | ||
457 | impl.mCache[id] = entry; | 447 | impl.mCache[id] = entry; |
458 | ++count; | 448 | ++count; |
459 | } | 449 | } |
@@ -471,8 +461,8 @@ void LLCacheName::exportFile(std::ostream& ostr) | |||
471 | // Only write entries for which we have valid data. | 461 | // Only write entries for which we have valid data. |
472 | LLCacheNameEntry* entry = iter->second; | 462 | LLCacheNameEntry* entry = iter->second; |
473 | if(!entry | 463 | if(!entry |
474 | || (NULL != strchr(entry->mFirstName, '?')) | 464 | || (std::string::npos != entry->mFirstName.find('?')) |
475 | || (NULL != strchr(entry->mGroupName, '?'))) | 465 | || (std::string::npos != entry->mGroupName.find('?'))) |
476 | { | 466 | { |
477 | continue; | 467 | continue; |
478 | } | 468 | } |
@@ -480,13 +470,13 @@ void LLCacheName::exportFile(std::ostream& ostr) | |||
480 | // store it | 470 | // store it |
481 | LLUUID id = iter->first; | 471 | LLUUID id = iter->first; |
482 | std::string id_str = id.asString(); | 472 | std::string id_str = id.asString(); |
483 | if(entry->mFirstName[0] && entry->mLastName[0]) | 473 | if(!entry->mFirstName.empty() && !entry->mLastName.empty()) |
484 | { | 474 | { |
485 | data[AGENTS][id_str][FIRST] = entry->mFirstName; | 475 | data[AGENTS][id_str][FIRST] = entry->mFirstName; |
486 | data[AGENTS][id_str][LAST] = entry->mLastName; | 476 | data[AGENTS][id_str][LAST] = entry->mLastName; |
487 | data[AGENTS][id_str][CTIME] = (S32)entry->mCreateTime; | 477 | data[AGENTS][id_str][CTIME] = (S32)entry->mCreateTime; |
488 | } | 478 | } |
489 | else if(entry->mIsGroup && entry->mGroupName[0]) | 479 | else if(entry->mIsGroup && !entry->mGroupName.empty()) |
490 | { | 480 | { |
491 | data[GROUPS][id_str][NAME] = entry->mGroupName; | 481 | data[GROUPS][id_str][NAME] = entry->mGroupName; |
492 | data[GROUPS][id_str][CTIME] = (S32)entry->mCreateTime; | 482 | data[GROUPS][id_str][CTIME] = (S32)entry->mCreateTime; |
@@ -534,16 +524,6 @@ BOOL LLCacheName::getFullName(const LLUUID& id, std::string& fullname) | |||
534 | return res; | 524 | return res; |
535 | } | 525 | } |
536 | 526 | ||
537 | // *TODO: Deprecate | ||
538 | BOOL LLCacheName::getName(const LLUUID& id, char* first, char* last) | ||
539 | { | ||
540 | std::string first_name, last_name; | ||
541 | BOOL res = getName(id, first_name, last_name); | ||
542 | strcpy(first, first_name.c_str()); | ||
543 | strcpy(last, last_name.c_str()); | ||
544 | return res; | ||
545 | } | ||
546 | |||
547 | BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group) | 527 | BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group) |
548 | { | 528 | { |
549 | if(id.isNull()) | 529 | if(id.isNull()) |
@@ -553,7 +533,7 @@ BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group) | |||
553 | } | 533 | } |
554 | 534 | ||
555 | LLCacheNameEntry* entry = get_ptr_in_map(impl.mCache,id); | 535 | LLCacheNameEntry* entry = get_ptr_in_map(impl.mCache,id); |
556 | if (entry && !entry->mGroupName[0]) | 536 | if (entry && entry->mGroupName.empty()) |
557 | { | 537 | { |
558 | // COUNTER-HACK to combat James' HACK in exportFile()... | 538 | // COUNTER-HACK to combat James' HACK in exportFile()... |
559 | // this group name was loaded from a name cache that did not | 539 | // this group name was loaded from a name cache that did not |
@@ -578,16 +558,6 @@ BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group) | |||
578 | } | 558 | } |
579 | } | 559 | } |
580 | 560 | ||
581 | // *TODO: Deprecate | ||
582 | BOOL LLCacheName::getGroupName(const LLUUID& id, char* group) | ||
583 | { | ||
584 | std::string group_name; | ||
585 | BOOL res = getGroupName(id, group_name); | ||
586 | strcpy(group, group_name.c_str()); | ||
587 | return res; | ||
588 | } | ||
589 | |||
590 | |||
591 | // TODO: Make the cache name callback take a SINGLE std::string, | 561 | // TODO: Make the cache name callback take a SINGLE std::string, |
592 | // not a separate first and last name. | 562 | // not a separate first and last name. |
593 | void LLCacheName::get(const LLUUID& id, BOOL is_group, LLCacheNameCallback callback, void* user_data) | 563 | void LLCacheName::get(const LLUUID& id, BOOL is_group, LLCacheNameCallback callback, void* user_data) |
@@ -716,9 +686,9 @@ void LLCacheName::dumpStats() | |||
716 | } | 686 | } |
717 | 687 | ||
718 | //static | 688 | //static |
719 | LLString LLCacheName::getDefaultName() | 689 | std::string LLCacheName::getDefaultName() |
720 | { | 690 | { |
721 | return LLString(CN_WAITING); | 691 | return CN_WAITING; |
722 | } | 692 | } |
723 | 693 | ||
724 | void LLCacheName::Impl::processPendingAsks() | 694 | void LLCacheName::Impl::processPendingAsks() |
@@ -813,7 +783,7 @@ void LLCacheName::Impl::sendRequest( | |||
813 | } | 783 | } |
814 | 784 | ||
815 | void LLCacheName::Impl::notifyObservers(const LLUUID& id, | 785 | void LLCacheName::Impl::notifyObservers(const LLUUID& id, |
816 | const char* first, const char* last, BOOL is_group) | 786 | const std::string& first, const std::string& last, BOOL is_group) |
817 | { | 787 | { |
818 | for (Observers::const_iterator i = mObservers.begin(), | 788 | for (Observers::const_iterator i = mObservers.begin(), |
819 | end = mObservers.end(); | 789 | end = mObservers.end(); |
@@ -917,19 +887,17 @@ void LLCacheName::Impl::processUUIDReply(LLMessageSystem* msg, bool isGroup) | |||
917 | entry->mCreateTime = (U32)time(NULL); | 887 | entry->mCreateTime = (U32)time(NULL); |
918 | if (!isGroup) | 888 | if (!isGroup) |
919 | { | 889 | { |
920 | msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_FirstName, DB_FIRST_NAME_BUF_SIZE, entry->mFirstName, i); | 890 | msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_FirstName, entry->mFirstName, i); |
921 | msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_LastName, DB_LAST_NAME_BUF_SIZE, entry->mLastName, i); | 891 | msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_LastName, entry->mLastName, i); |
922 | } | 892 | } |
923 | else | 893 | else |
924 | { | 894 | { |
925 | msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_GroupName, DB_GROUP_NAME_BUF_SIZE, entry->mGroupName, i); | 895 | msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_GroupName, entry->mGroupName, i); |
926 | } | 896 | } |
927 | 897 | ||
928 | if (!isGroup) | 898 | if (!isGroup) |
929 | { | 899 | { |
930 | notifyObservers(id, | 900 | notifyObservers(id, entry->mFirstName, entry->mLastName, FALSE); |
931 | entry->mFirstName, entry->mLastName, | ||
932 | FALSE); | ||
933 | } | 901 | } |
934 | else | 902 | else |
935 | { | 903 | { |