PageRenderTime 30ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llmessage/llavatarnamecache.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 106 lines | 33 code | 23 blank | 50 comment | 0 complexity | efc86fc9e411aea8155d9d0059d7e867 MD5 | raw file
Possible License(s): LGPL-2.1
  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. #ifndef LLAVATARNAMECACHE_H
  28. #define LLAVATARNAMECACHE_H
  29. #include "llavatarname.h" // for convenience
  30. #include <boost/signals2.hpp>
  31. class LLSD;
  32. class LLUUID;
  33. namespace LLAvatarNameCache
  34. {
  35. typedef boost::signals2::signal<void (void)> use_display_name_signal_t;
  36. // Until the cache is set running, immediate lookups will fail and
  37. // async lookups will be queued. This allows us to block requests
  38. // until we know if the first region supports display names.
  39. void initClass(bool running);
  40. void cleanupClass();
  41. void importFile(std::istream& istr);
  42. void exportFile(std::ostream& ostr);
  43. // On the viewer, usually a simulator capabilitity
  44. // If empty, name cache will fall back to using legacy name
  45. // lookup system
  46. void setNameLookupURL(const std::string& name_lookup_url);
  47. // Do we have a valid lookup URL, hence are we trying to use the
  48. // new display name lookup system?
  49. bool hasNameLookupURL();
  50. // Periodically makes a batch request for display names not already in
  51. // cache. Call once per frame.
  52. void idle();
  53. // If name is in cache, returns true and fills in provided LLAvatarName
  54. // otherwise returns false
  55. bool get(const LLUUID& agent_id, LLAvatarName *av_name);
  56. // Callback types for get() below
  57. typedef boost::signals2::signal<
  58. void (const LLUUID& agent_id, const LLAvatarName& av_name)>
  59. callback_signal_t;
  60. typedef callback_signal_t::slot_type callback_slot_t;
  61. // Fetches name information and calls callback.
  62. // If name information is in cache, callback will be called immediately.
  63. void get(const LLUUID& agent_id, callback_slot_t slot);
  64. // Allow display names to be explicitly disabled for testing.
  65. void setUseDisplayNames(bool use);
  66. bool useDisplayNames();
  67. void erase(const LLUUID& agent_id);
  68. /// Provide some fallback for agents that return errors
  69. void handleAgentError(const LLUUID& agent_id);
  70. // Force a re-fetch of the most recent data, but keep the current
  71. // data in cache
  72. void fetch(const LLUUID& agent_id);
  73. void insert(const LLUUID& agent_id, const LLAvatarName& av_name);
  74. // Compute name expiration time from HTTP Cache-Control header,
  75. // or return default value, in seconds from epoch.
  76. F64 nameExpirationFromHeaders(LLSD headers);
  77. void addUseDisplayNamesCallback(const use_display_name_signal_t::slot_type& cb);
  78. }
  79. // Parse a cache-control header to get the max-age delta-seconds.
  80. // Returns true if header has max-age param and it parses correctly.
  81. // Exported here to ease unit testing.
  82. bool max_age_from_cache_control(const std::string& cache_control, S32 *max_age);
  83. #endif