diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llmessage/llcachename.h | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llmessage/llcachename.h')
-rw-r--r-- | linden/indra/llmessage/llcachename.h | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/linden/indra/llmessage/llcachename.h b/linden/indra/llmessage/llcachename.h new file mode 100644 index 0000000..4dd42cb --- /dev/null +++ b/linden/indra/llmessage/llcachename.h | |||
@@ -0,0 +1,109 @@ | |||
1 | /** | ||
2 | * @file llcachename.h | ||
3 | * @brief A cache of names from UUIDs. | ||
4 | * | ||
5 | * Copyright (c) 2002-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #ifndef LL_LLCACHENAME_H | ||
29 | #define LL_LLCACHENAME_H | ||
30 | |||
31 | // Forward declarations | ||
32 | #include <stdio.h> | ||
33 | |||
34 | class LLMessageSystem; | ||
35 | class LLHost; | ||
36 | class LLUUID; | ||
37 | |||
38 | // agent_id/group_id, first_name, last_name, is_group, user_data | ||
39 | typedef void (*LLCacheNameCallback)(const LLUUID&, const char*, const char*, BOOL, void*); | ||
40 | |||
41 | // Here's the theory: | ||
42 | // If you request a name that isn't in the cache, it returns "waiting" | ||
43 | // and requests the data. After the data arrives, you get that on | ||
44 | // subsequent calls. | ||
45 | // If the data hasn't been updated in an hour, it requests it again, | ||
46 | // but keeps giving you the old value until new data arrives. | ||
47 | // If you haven't requested the data in an hour, it releases it. | ||
48 | class LLCacheName | ||
49 | { | ||
50 | public: | ||
51 | LLCacheName(LLMessageSystem* msg); | ||
52 | LLCacheName(LLMessageSystem* msg, const LLHost& upstream_host); | ||
53 | ~LLCacheName(); | ||
54 | |||
55 | // registers the upstream host | ||
56 | // for viewers, this is the currently connected simulator | ||
57 | // for simulators, this is the data server | ||
58 | void setUpstream(const LLHost& upstream_host); | ||
59 | |||
60 | void addObserver(LLCacheNameCallback callback); | ||
61 | void removeObserver(LLCacheNameCallback callback); | ||
62 | |||
63 | // storing cache on disk; for viewer, in name.cache | ||
64 | void importFile(FILE* fp); | ||
65 | void exportFile(FILE* fp); | ||
66 | |||
67 | // If available, copies the first and last name into the strings provided. | ||
68 | // first must be at least DB_FIRST_NAME_BUF_SIZE characters. | ||
69 | // last must be at least DB_LAST_NAME_BUF_SIZE characters. | ||
70 | // If not available, copies the string "waiting". | ||
71 | // Returns TRUE iff available. | ||
72 | BOOL getName(const LLUUID& id, char* first, char* last); | ||
73 | |||
74 | // If available, this method copies the group name into the string | ||
75 | // provided. The caller must allocate at least | ||
76 | // DB_GROUP_NAME_BUF_SIZE characters. If not available, this | ||
77 | // method copies the string "waiting". Returns TRUE iff available. | ||
78 | BOOL getGroupName(const LLUUID& id, char* group); | ||
79 | |||
80 | // Call the callback with the group or avatar name. | ||
81 | // If the data is currently available, may call the callback immediatly | ||
82 | // otherwise, will request the data, and will call the callback when | ||
83 | // available. There is no garuntee the callback will ever be called. | ||
84 | void get(const LLUUID& id, BOOL is_group, LLCacheNameCallback callback, void* user_data = NULL); | ||
85 | |||
86 | // LEGACY | ||
87 | void getName(const LLUUID& id, LLCacheNameCallback callback, void* user_data = NULL) | ||
88 | { get(id, FALSE, callback, user_data); } | ||
89 | |||
90 | // This method needs to be called from time to time to send out | ||
91 | // requests. | ||
92 | void processPending(); | ||
93 | |||
94 | // Expire entries created more than "secs" seconds ago. | ||
95 | void deleteEntriesOlderThan(S32 secs); | ||
96 | |||
97 | // Debugging | ||
98 | void dump(); | ||
99 | |||
100 | private: | ||
101 | class Impl; | ||
102 | Impl& impl; | ||
103 | }; | ||
104 | |||
105 | |||
106 | |||
107 | extern LLCacheName* gCacheName; | ||
108 | |||
109 | #endif | ||