diff options
Diffstat (limited to 'linden/indra/llmessage/llcachename.cpp')
-rw-r--r-- | linden/indra/llmessage/llcachename.cpp | 228 |
1 files changed, 9 insertions, 219 deletions
diff --git a/linden/indra/llmessage/llcachename.cpp b/linden/indra/llmessage/llcachename.cpp index 3acd881..1e6584a 100644 --- a/linden/indra/llmessage/llcachename.cpp +++ b/linden/indra/llmessage/llcachename.cpp | |||
@@ -17,7 +17,8 @@ | |||
17 | * There are special exceptions to the terms and conditions of the GPL as | 17 | * There are special exceptions to the terms and conditions of the GPL as |
18 | * it is applied to this Source Code. View the full text of the exception | 18 | * it is applied to this Source Code. View the full text of the exception |
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | 19 | * in the file doc/FLOSS-exception.txt in this software distribution, or |
20 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | 20 | * online at |
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
21 | * | 22 | * |
22 | * By copying, modifying or distributing this software, you acknowledge | 23 | * By copying, modifying or distributing this software, you acknowledge |
23 | * that you have read and understood your obligations described above, | 24 | * that you have read and understood your obligations described above, |
@@ -41,8 +42,7 @@ | |||
41 | #include "llsdserialize.h" | 42 | #include "llsdserialize.h" |
42 | #include "lluuid.h" | 43 | #include "lluuid.h" |
43 | #include "message.h" | 44 | #include "message.h" |
44 | #include "llservicebuilder.h" | 45 | |
45 | #include "llframetimer.h" | ||
46 | // Constants | 46 | // Constants |
47 | static const std::string CN_WAITING("(Loading...)"); // *TODO: translate | 47 | static const std::string CN_WAITING("(Loading...)"); // *TODO: translate |
48 | static const std::string CN_NOBODY("(nobody)"); // *TODO: translate | 48 | static const std::string CN_NOBODY("(nobody)"); // *TODO: translate |
@@ -197,8 +197,6 @@ class LLCacheName::Impl | |||
197 | public: | 197 | public: |
198 | LLMessageSystem* mMsg; | 198 | LLMessageSystem* mMsg; |
199 | LLHost mUpstreamHost; | 199 | LLHost mUpstreamHost; |
200 | std::string mGroupNameURL; | ||
201 | std::string mAgentNameURL; | ||
202 | 200 | ||
203 | Cache mCache; | 201 | Cache mCache; |
204 | // the map of UUIDs to names | 202 | // the map of UUIDs to names |
@@ -224,8 +222,6 @@ public: | |||
224 | void processPendingReplies(); | 222 | void processPendingReplies(); |
225 | void sendRequest(const char* msg_name, const AskQueue& queue); | 223 | void sendRequest(const char* msg_name, const AskQueue& queue); |
226 | bool isRequestPending(const LLUUID& id); | 224 | bool isRequestPending(const LLUUID& id); |
227 | void getAgentName(const AskQueue&); | ||
228 | void getGroupName(const AskQueue&); | ||
229 | 225 | ||
230 | // Message system callbacks. | 226 | // Message system callbacks. |
231 | void processUUIDRequest(LLMessageSystem* msg, bool isGroup); | 227 | void processUUIDRequest(LLMessageSystem* msg, bool isGroup); |
@@ -239,35 +235,6 @@ public: | |||
239 | void notifyObservers(const LLUUID& id, const std::string& first, const std::string& last, BOOL group); | 235 | void notifyObservers(const LLUUID& id, const std::string& first, const std::string& last, BOOL group); |
240 | }; | 236 | }; |
241 | 237 | ||
242 | class LLHTTPAgentNamesResponse : public LLHTTPClient::Responder | ||
243 | { | ||
244 | public: | ||
245 | LLHTTPAgentNamesResponse(const LLSD& agent_ids) | ||
246 | : mAgentIDs(agent_ids) | ||
247 | { } | ||
248 | void result(const LLSD& content); | ||
249 | private: | ||
250 | LLHost mSender; | ||
251 | LLSD mAgentIDs; | ||
252 | |||
253 | }; | ||
254 | |||
255 | class LLHTTPGroupNamesResponse : public LLHTTPClient::Responder | ||
256 | { | ||
257 | public: | ||
258 | LLHTTPGroupNamesResponse(const LLSD& group_ids) | ||
259 | : mGroupIDs(group_ids) | ||
260 | { }; | ||
261 | |||
262 | void result(const LLSD& content); | ||
263 | private: | ||
264 | LLHost mSender; | ||
265 | LLSD mGroupIDs; | ||
266 | |||
267 | }; | ||
268 | |||
269 | |||
270 | |||
271 | 238 | ||
272 | /// -------------------------------------------------------------------------- | 239 | /// -------------------------------------------------------------------------- |
273 | /// class LLCacheName | 240 | /// class LLCacheName |
@@ -353,57 +320,6 @@ void LLCacheName::cancelCallback(const LLUUID& id, LLCacheNameCallback callback, | |||
353 | } | 320 | } |
354 | } | 321 | } |
355 | 322 | ||
356 | void LLCacheName::sendAgentNames(const LLUUID& id, std::string& first, std::string& last) | ||
357 | { | ||
358 | |||
359 | LLCacheNameEntry* entry = get_ptr_in_map(impl.mCache, id); | ||
360 | if (!entry) | ||
361 | { | ||
362 | entry = new LLCacheNameEntry; | ||
363 | impl.mCache[id] = entry; | ||
364 | |||
365 | } | ||
366 | entry->mIsGroup = false; | ||
367 | entry->mCreateTime = (U32)LLFrameTimer::getTotalSeconds(); | ||
368 | //entry->mFirstName = first; | ||
369 | //entry->mLastName = last; | ||
370 | //LLStringUtil::truncate(entry->mFirstName, DB_FIRST_NAME_BUF_SIZE); | ||
371 | //LLStringUtil::truncate(entry->mLastName, DB_LAST_NAME_BUF_SIZE); | ||
372 | entry->mFirstName = std::string(first, DB_FIRST_NAME_BUF_SIZE); | ||
373 | entry->mLastName = std::string(last, DB_LAST_NAME_BUF_SIZE); | ||
374 | |||
375 | impl.mPendingQueue.erase(id); | ||
376 | impl.notifyObservers(id, | ||
377 | entry->mFirstName, entry->mLastName, | ||
378 | FALSE); | ||
379 | |||
380 | } | ||
381 | |||
382 | void LLCacheName::sendGroupNames(const LLUUID& id, std::string& name) | ||
383 | { | ||
384 | |||
385 | LLCacheNameEntry* entry = get_ptr_in_map(impl.mCache, id); | ||
386 | if (!entry) | ||
387 | { | ||
388 | entry = new LLCacheNameEntry; | ||
389 | impl.mCache[id] = entry; | ||
390 | |||
391 | } | ||
392 | |||
393 | entry->mIsGroup = true; | ||
394 | entry->mCreateTime = (U32)time(NULL); | ||
395 | |||
396 | entry->mGroupName = std::string(name, DB_GROUP_NAME_BUF_SIZE); | ||
397 | |||
398 | impl.mPendingQueue.erase(id); | ||
399 | |||
400 | impl.notifyObservers(id, | ||
401 | entry->mFirstName, entry->mLastName, | ||
402 | FALSE); | ||
403 | |||
404 | |||
405 | } | ||
406 | |||
407 | void LLCacheName::importFile(LLFILE* fp) | 323 | void LLCacheName::importFile(LLFILE* fp) |
408 | { | 324 | { |
409 | S32 count = 0; | 325 | S32 count = 0; |
@@ -609,16 +525,6 @@ BOOL LLCacheName::getFullName(const LLUUID& id, std::string& fullname) | |||
609 | return res; | 525 | return res; |
610 | } | 526 | } |
611 | 527 | ||
612 | void LLCacheName::setGroupURL(const std::string& group_url) | ||
613 | { | ||
614 | impl.mGroupNameURL = group_url; | ||
615 | } | ||
616 | |||
617 | void LLCacheName::setAgentURL(const std::string& agent_url) | ||
618 | { | ||
619 | impl.mAgentNameURL = agent_url; | ||
620 | } | ||
621 | |||
622 | BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group) | 528 | BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group) |
623 | { | 529 | { |
624 | if(id.isNull()) | 530 | if(id.isNull()) |
@@ -653,111 +559,6 @@ BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group) | |||
653 | } | 559 | } |
654 | } | 560 | } |
655 | 561 | ||
656 | void LLCacheName::Impl::getAgentName(const AskQueue &queue) | ||
657 | { | ||
658 | |||
659 | // get the names from backbone module | ||
660 | if(queue.empty()) | ||
661 | { | ||
662 | return; | ||
663 | } | ||
664 | |||
665 | LLSD request; | ||
666 | request["action"] = "GET"; | ||
667 | LLSD id_block = LLSD::emptyArray(); | ||
668 | AskQueue::const_iterator it = queue.begin(); | ||
669 | AskQueue::const_iterator end = queue.end(); | ||
670 | for(;it!=end;++it) | ||
671 | { | ||
672 | id_block.append(*it); | ||
673 | } | ||
674 | lldebugs<<LLSDOStreamer<LLSDNotationFormatter>(id_block) <<llendl; | ||
675 | |||
676 | request["agents"] = id_block; | ||
677 | |||
678 | LLHTTPClient::post( | ||
679 | mAgentNameURL, | ||
680 | request, | ||
681 | new LLHTTPAgentNamesResponse(id_block)); | ||
682 | |||
683 | |||
684 | lldebugs<<"Service builder call to agent-name "<<mAgentNameURL<<llendl; | ||
685 | |||
686 | } | ||
687 | |||
688 | void LLHTTPAgentNamesResponse::result(const LLSD& content) | ||
689 | { | ||
690 | LLUUID id; | ||
691 | lldebugs<<LLSDOStreamer<LLSDNotationFormatter>(content) <<llendl; | ||
692 | |||
693 | LLSD::map_const_iterator iter = content.beginMap(); | ||
694 | for ( ; iter != content.endMap(); ++iter) | ||
695 | { | ||
696 | id.set((*iter).first); | ||
697 | LLSD name = (*iter).second; | ||
698 | LLCacheNameEntry* entry = new LLCacheNameEntry; | ||
699 | entry->mIsGroup = FALSE; | ||
700 | entry->mCreateTime = (U32)LLFrameTimer::getTotalSeconds(); | ||
701 | std::string first = name["first"]; | ||
702 | std::string last = name["last"]; | ||
703 | entry->mFirstName = std::string(first, DB_FIRST_NAME_BUF_SIZE); | ||
704 | entry->mLastName = std::string(last, DB_LAST_NAME_BUF_SIZE); | ||
705 | |||
706 | gCacheName->sendAgentNames(id,first,last); | ||
707 | } | ||
708 | } | ||
709 | |||
710 | |||
711 | void LLCacheName::Impl::getGroupName(const AskQueue &queue) | ||
712 | { | ||
713 | // get the group names from backbone module | ||
714 | if(queue.empty()) | ||
715 | { | ||
716 | return; | ||
717 | } | ||
718 | |||
719 | LLSD request; | ||
720 | request["action"] = "GET"; | ||
721 | LLSD id_block = LLSD::emptyArray(); | ||
722 | AskQueue::const_iterator it = queue.begin(); | ||
723 | AskQueue::const_iterator end = queue.end(); | ||
724 | for(;it!=end;++it) | ||
725 | { | ||
726 | id_block.append(*it); | ||
727 | } | ||
728 | |||
729 | request["groups"] = id_block; | ||
730 | |||
731 | if(!mGroupNameURL.empty()) | ||
732 | { | ||
733 | LLHTTPClient::post( | ||
734 | mGroupNameURL, | ||
735 | request, | ||
736 | new LLHTTPGroupNamesResponse(id_block)); | ||
737 | } | ||
738 | lldebugs<<"Service builder call to group-name "<< mGroupNameURL<<llendl; | ||
739 | } | ||
740 | |||
741 | void LLHTTPGroupNamesResponse::result(const LLSD& content) | ||
742 | { | ||
743 | lldebugs<<"Result"<<LLSDOStreamer<LLSDNotationFormatter>(content) << llendl; | ||
744 | LLUUID id; | ||
745 | |||
746 | LLSD::map_const_iterator iter = content.beginMap(); | ||
747 | for ( ; iter != content.endMap(); ++iter) | ||
748 | { | ||
749 | |||
750 | id.set((*iter).first); | ||
751 | std::string name = (*iter).second.asString(); | ||
752 | LLCacheNameEntry* entry = new LLCacheNameEntry; | ||
753 | entry->mIsGroup = TRUE; | ||
754 | entry->mCreateTime = (U32)time(NULL); | ||
755 | entry->mGroupName = std::string(name, DB_GROUP_NAME_BUF_SIZE); | ||
756 | lldebugs<<"Group Name"<<name<<llendl; | ||
757 | gCacheName->sendGroupNames(id,name); | ||
758 | } | ||
759 | } | ||
760 | |||
761 | // TODO: Make the cache name callback take a SINGLE std::string, | 562 | // TODO: Make the cache name callback take a SINGLE std::string, |
762 | // not a separate first and last name. | 563 | // not a separate first and last name. |
763 | void LLCacheName::get(const LLUUID& id, BOOL is_group, LLCacheNameCallback callback, void* user_data) | 564 | void LLCacheName::get(const LLUUID& id, BOOL is_group, LLCacheNameCallback callback, void* user_data) |
@@ -765,6 +566,7 @@ void LLCacheName::get(const LLUUID& id, BOOL is_group, LLCacheNameCallback callb | |||
765 | if(id.isNull()) | 566 | if(id.isNull()) |
766 | { | 567 | { |
767 | callback(id, CN_NOBODY, "", is_group, user_data); | 568 | callback(id, CN_NOBODY, "", is_group, user_data); |
569 | return; | ||
768 | } | 570 | } |
769 | 571 | ||
770 | LLCacheNameEntry* entry = get_ptr_in_map(impl.mCache, id ); | 572 | LLCacheNameEntry* entry = get_ptr_in_map(impl.mCache, id ); |
@@ -806,14 +608,12 @@ void LLCacheName::processPending() | |||
806 | return; | 608 | return; |
807 | } | 609 | } |
808 | 610 | ||
809 | /* | ||
810 | if(!impl.mUpstreamHost.isOk()) | 611 | if(!impl.mUpstreamHost.isOk()) |
811 | { | 612 | { |
812 | lldebugs << "LLCacheName::processPending() - bad upstream host." | 613 | lldebugs << "LLCacheName::processPending() - bad upstream host." |
813 | << llendl; | 614 | << llendl; |
814 | return; | 615 | return; |
815 | } | 616 | } |
816 | */ | ||
817 | 617 | ||
818 | impl.processPendingAsks(); | 618 | impl.processPendingAsks(); |
819 | impl.processPendingReplies(); | 619 | impl.processPendingReplies(); |
@@ -895,16 +695,8 @@ std::string LLCacheName::getDefaultName() | |||
895 | 695 | ||
896 | void LLCacheName::Impl::processPendingAsks() | 696 | void LLCacheName::Impl::processPendingAsks() |
897 | { | 697 | { |
898 | if (mUpstreamHost.isOk()) //its the vuewer asking for names send request to simulator | 698 | sendRequest(_PREHASH_UUIDNameRequest, mAskNameQueue); |
899 | { | 699 | sendRequest(_PREHASH_UUIDGroupNameRequest, mAskGroupQueue); |
900 | sendRequest(_PREHASH_UUIDNameRequest, mAskNameQueue); | ||
901 | sendRequest(_PREHASH_UUIDGroupNameRequest, mAskGroupQueue); | ||
902 | } | ||
903 | else //its simulator asking for names ask the backbone | ||
904 | { | ||
905 | getAgentName(mAskNameQueue); | ||
906 | getGroupName(mAskGroupQueue); | ||
907 | } | ||
908 | mAskNameQueue.clear(); | 700 | mAskNameQueue.clear(); |
909 | mAskGroupQueue.clear(); | 701 | mAskGroupQueue.clear(); |
910 | } | 702 | } |
@@ -1025,15 +817,12 @@ void LLCacheName::Impl::processUUIDRequest(LLMessageSystem* msg, bool isGroup) | |||
1025 | { | 817 | { |
1026 | // You should only get this message if the cache is at the simulator | 818 | // You should only get this message if the cache is at the simulator |
1027 | // level, hence having an upstream provider. | 819 | // level, hence having an upstream provider. |
1028 | // 03/31/2008 Simulator is talking to backbone and not dataserver | ||
1029 | // This check was for dataserver | ||
1030 | /* | ||
1031 | if (!mUpstreamHost.isOk()) | 820 | if (!mUpstreamHost.isOk()) |
1032 | { | 821 | { |
1033 | llwarns << "LLCacheName - got UUID name/group request, but no upstream provider!" << llendl; | 822 | llwarns << "LLCacheName - got UUID name/group request, but no upstream provider!" << llendl; |
1034 | return; | 823 | return; |
1035 | } | 824 | } |
1036 | */ | 825 | |
1037 | LLHost fromHost = msg->getSender(); | 826 | LLHost fromHost = msg->getSender(); |
1038 | ReplySender sender(msg); | 827 | ReplySender sender(msg); |
1039 | 828 | ||
@@ -1104,8 +893,9 @@ void LLCacheName::Impl::processUUIDReply(LLMessageSystem* msg, bool isGroup) | |||
1104 | msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_LastName, entry->mLastName, i); | 893 | msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_LastName, entry->mLastName, i); |
1105 | } | 894 | } |
1106 | else | 895 | else |
1107 | { | 896 | { // is group |
1108 | msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_GroupName, entry->mGroupName, i); | 897 | msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_GroupName, entry->mGroupName, i); |
898 | LLStringFn::replace_ascii_controlchars(entry->mGroupName, LL_UNKNOWN_CHAR); | ||
1109 | } | 899 | } |
1110 | 900 | ||
1111 | if (!isGroup) | 901 | if (!isGroup) |