aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/llavatarnamecache.h
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmessage/llavatarnamecache.h')
-rw-r--r--linden/indra/llmessage/llavatarnamecache.h105
1 files changed, 105 insertions, 0 deletions
diff --git a/linden/indra/llmessage/llavatarnamecache.h b/linden/indra/llmessage/llavatarnamecache.h
new file mode 100644
index 0000000..a2519cd
--- /dev/null
+++ b/linden/indra/llmessage/llavatarnamecache.h
@@ -0,0 +1,105 @@
1/**
2 * @file llavatarnamecache.h
3 * @brief Provides lookup of avatar SLIDs ("bobsmith123") and display names
4 * ("James Cook") from avatar UUIDs.
5 *
6 * $LicenseInfo:firstyear=2010&license=viewerlgpl$
7 * Second Life Viewer Source Code
8 * Copyright (C) 2010, Linden Research, Inc.
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation;
13 * version 2.1 of the License only.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 *
24 * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
25 * $/LicenseInfo$
26 */
27
28#ifndef LLAVATARNAMECACHE_H
29#define LLAVATARNAMECACHE_H
30
31#include "llavatarname.h" // for convenience
32
33#include <boost/signals2.hpp>
34
35// We have display names support (this is for use by patches)
36#define LL_DISPLAY_NAMES
37
38class LLSD;
39class LLUUID;
40
41namespace LLAvatarNameCache
42{
43
44 typedef boost::signals2::signal<void (void)> use_display_name_signal_t;
45
46 // Until the cache is set running, immediate lookups will fail and
47 // async lookups will be queued. This allows us to block requests
48 // until we know if the first region supports display names.
49 void initClass(bool running);
50 void cleanupClass();
51
52 void importFile(std::istream& istr);
53 void exportFile(std::ostream& ostr);
54
55 // On the viewer, usually a simulator capabilitity
56 // If empty, name cache will fall back to using legacy name
57 // lookup system
58 void setNameLookupURL(const std::string& name_lookup_url);
59
60 // Do we have a valid lookup URL, hence are we trying to use the
61 // new display name lookup system?
62 bool hasNameLookupURL();
63
64 // Periodically makes a batch request for display names not already in
65 // cache. Call once per frame.
66 void idle();
67
68 // If name is in cache, returns true and fills in provided LLAvatarName
69 // otherwise returns false
70 bool get(const LLUUID& agent_id, LLAvatarName *av_name);
71
72 // Callback types for get() below
73 typedef boost::signals2::signal<
74 void (const LLUUID& agent_id, const LLAvatarName& av_name)>
75 callback_signal_t;
76 typedef callback_signal_t::slot_type callback_slot_t;
77
78 // Fetches name information and calls callback.
79 // If name information is in cache, callback will be called immediately.
80 void get(const LLUUID& agent_id, callback_slot_t slot);
81
82 void setUseDisplayNames(U32 use);
83 U32 useDisplayNames();
84
85 void erase(const LLUUID& agent_id);
86
87 // Force a re-fetch of the most recent data, but keep the current
88 // data in cache
89 void fetch(const LLUUID& agent_id);
90
91 void insert(const LLUUID& agent_id, const LLAvatarName& av_name);
92
93 // Compute name expiration time from HTTP Cache-Control header,
94 // or return default value, in seconds from epoch.
95 F64 nameExpirationFromHeaders(LLSD headers);
96
97 void addUseDisplayNamesCallback(const use_display_name_signal_t::slot_type& cb);
98}
99
100// Parse a cache-control header to get the max-age delta-seconds.
101// Returns true if header has max-age param and it parses correctly.
102// Exported here to ease unit testing.
103bool max_age_from_cache_control(const std::string& cache_control, S32 *max_age);
104
105#endif