llinventorymodelfetch.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /**
  2. * @file llinventorymodelfetch.h
  3. * @brief LLInventoryModelFetch class header file
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewergpl$
  6. *
  7. * Copyright (c) 2010, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  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
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLINVENTORYMODELFETCH_H
  33. #define LL_LLINVENTORYMODELFETCH_H
  34. #include <deque>
  35. #include "llsingleton.h"
  36. #include "lluuid.h"
  37. class LLInventoryItem;
  38. class LLTimer;
  39. // This class handles background fetches, which are fetches of inventory
  40. // folder. Fetches can be recursive or not.
  41. class LLInventoryModelFetch final : public LLSingleton<LLInventoryModelFetch>
  42. {
  43. friend class LLSingleton<LLInventoryModelFetch>;
  44. protected:
  45. LOG_CLASS(LLInventoryModelFetch);
  46. public:
  47. LLInventoryModelFetch();
  48. // Start and stop background breadth-first fetching of inventory contents.
  49. // This gets triggered when performing a filter-search.
  50. void start(const LLUUID& cat_id = LLUUID::null, bool recursive = true);
  51. void scheduleFolderFetch(const LLUUID& cat_id, bool force = false);
  52. void scheduleItemFetch(const LLUUID& item_id, bool force = false);
  53. LL_INLINE bool backgroundFetchActive() const
  54. {
  55. return mBackgroundFetchActive;
  56. }
  57. // Completing the fetch once per session should be sufficient:
  58. LL_INLINE bool isEverythingFetched() const
  59. {
  60. return mAllRecursiveFoldersFetched;
  61. }
  62. LL_INLINE bool libraryFetchStarted() const
  63. {
  64. return mRecursiveLibraryFetchStarted;
  65. }
  66. bool libraryFetchCompleted() const;
  67. LL_INLINE bool libraryFetchInProgress() const
  68. {
  69. return mRecursiveLibraryFetchStarted && !libraryFetchCompleted();
  70. }
  71. LL_INLINE bool inventoryFetchStarted() const
  72. {
  73. return mRecursiveInventoryFetchStarted;
  74. }
  75. bool inventoryFetchCompleted() const;
  76. LL_INLINE bool inventoryFetchInProgress() const
  77. {
  78. return mRecursiveInventoryFetchStarted && !inventoryFetchCompleted();
  79. }
  80. void findLostItems();
  81. void incrFetchCount(S32 fetching);
  82. void incrFetchFolderCount(S32 fetching);
  83. bool isBulkFetchProcessingComplete() const;
  84. bool isFolderFetchProcessingComplete() const;
  85. void setAllFoldersFetched();
  86. void addRequestAtFront(const LLUUID& id, bool recursive, bool is_category);
  87. void addRequestAtBack(const LLUUID& id, bool recursive, bool is_category);
  88. void onAISContentsCallback(const uuid_vec_t& content_ids,
  89. const LLUUID& response_id);
  90. void onAISFolderCallback(const LLUUID& cat_id,
  91. const LLUUID& response_id, U32 fetch_type);
  92. LL_INLINE static void setUseAISFetching(bool b) { sUseAISFetching = b; }
  93. static bool useAISFetching();
  94. // Helpers for force-fetching inventory items and folders. HB
  95. static void forceFetchFolder(const LLUUID& cat_id);
  96. static void forceFetchItem(const LLUUID& item_id);
  97. // Use this when you got the item pointer (faster).
  98. static void forceFetchItem(const LLInventoryItem* itemp);
  99. private:
  100. typedef enum : U32
  101. {
  102. FT_DEFAULT = 0,
  103. FT_FORCED, // Non-recursively even if already loaded
  104. FT_CONTENT_RECURSIVE, // Request content recursively
  105. FT_FOLDER_AND_CONTENT, // Request folder, then content recursively
  106. FT_RECURSIVE, // Request everything recursively
  107. } EFetchType;
  108. struct FetchQueueInfo
  109. {
  110. FetchQueueInfo(const LLUUID& id, U32 fetch_type, bool is_category)
  111. : mUUID(id),
  112. mFetchType(fetch_type),
  113. mIsCategory(is_category)
  114. {
  115. }
  116. LLUUID mUUID;
  117. U32 mFetchType;
  118. bool mIsCategory;
  119. };
  120. void bulkFetch(const std::string& url);
  121. void bulkFetchAIS();
  122. void bulkFetchAIS(const FetchQueueInfo& fetch_info);
  123. void backgroundFetch();
  124. static void backgroundFetchCB(void*); // Background fetch idle method
  125. bool fetchQueueContainsNoDescendentsOf(const LLUUID& cat_id) const;
  126. private:
  127. typedef std::deque<FetchQueueInfo> fetch_queue_t;
  128. fetch_queue_t mFetchFolderQueue;
  129. fetch_queue_t mFetchItemQueue;
  130. uuid_list_t mExpectedFolderIds;
  131. LLTimer mFetchTimer;
  132. #if 0 // Not yet used by the Cool VL Viewer. HB
  133. typedef boost::signals2::signal<void()> signal_t;
  134. signal_t mFoldersFetchedSignal;
  135. #endif
  136. S32 mFetchCount;
  137. S32 mLastFetchCount;
  138. S32 mFetchFolderCount;
  139. bool mRecursiveInventoryFetchStarted;
  140. bool mRecursiveLibraryFetchStarted;
  141. bool mAllRecursiveFoldersFetched;
  142. bool mBackgroundFetchActive;
  143. bool mFolderFetchActive;
  144. static bool sUseAISFetching;
  145. };
  146. #endif // LL_LLINVENTORYMODELFETCH_H