/indra/newview/llfriendcard.h

https://bitbucket.org/lindenlab/viewer-beta/ · C++ Header · 149 lines · 50 code · 31 blank · 68 comment · 1 complexity · 7176558bbc2e059829f4dedfd4581d9a MD5 · raw file

  1. /**
  2. * @file llfriendcard.h
  3. * @brief Definition of classes to process Friends Cards
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLFRIENDCARD_H
  27. #define LL_LLFRIENDCARD_H
  28. #include "llcallingcard.h"
  29. #include "llinventorymodel.h" // for LLInventoryModel::item_array_t
  30. class LLViewerInventoryItem;
  31. class LLFriendCardsManager
  32. : public LLSingleton<LLFriendCardsManager>
  33. , public LLFriendObserver
  34. {
  35. LOG_CLASS(LLFriendCardsManager);
  36. friend class LLSingleton<LLFriendCardsManager>;
  37. friend class CreateFriendCardCallback;
  38. public:
  39. typedef std::map<LLUUID, uuid_vec_t > folderid_buddies_map_t;
  40. // LLFriendObserver implementation
  41. void changed(U32 mask)
  42. {
  43. onFriendListUpdate(mask);
  44. }
  45. /**
  46. * Determines if specified Inventory Calling Card exists in any of lists
  47. * in the Calling Card/Friends/ folder (Default, or Custom)
  48. */
  49. bool isItemInAnyFriendsList(const LLViewerInventoryItem* item);
  50. /**
  51. * Checks if specified category is contained in the Calling Card/Friends folder and
  52. * determines if specified Inventory Object exists in that category.
  53. */
  54. bool isObjDirectDescendentOfCategory(const LLInventoryObject* obj, const LLViewerInventoryCategory* cat) const;
  55. /**
  56. * Checks is the specified category is in the Calling Card/Friends folder
  57. */
  58. bool isCategoryInFriendFolder(const LLViewerInventoryCategory* cat) const;
  59. /**
  60. * Checks is the specified category is a Friend folder or any its subfolder
  61. */
  62. bool isAnyFriendCategory(const LLUUID& catID) const;
  63. /**
  64. * Checks whether "Friends" and "Friends/All" folders exist in "Calling Cards" category
  65. * (creates them otherwise) and fetches their contents to synchronize with Agent's Friends List.
  66. */
  67. void syncFriendCardsFolders();
  68. private:
  69. typedef boost::function<void()> callback_t;
  70. LLFriendCardsManager();
  71. ~LLFriendCardsManager();
  72. /**
  73. * Stores buddy id to avoid sent create_inventory_callingcard several time for the same Avatar
  74. */
  75. void putAvatarData(const LLUUID& avatarID);
  76. /**
  77. * Extracts buddy id of Created Friend Card
  78. */
  79. const LLUUID extractAvatarID(const LLUUID& avatarID);
  80. bool isAvatarDataStored(const LLUUID& avatarID) const
  81. {
  82. return (mBuddyIDSet.end() != mBuddyIDSet.find(avatarID));
  83. }
  84. const LLUUID& findChildFolderUUID(const LLUUID& parentFolderUUID, const std::string& nonLocalizedName) const;
  85. const LLUUID& findFriendFolderUUIDImpl() const;
  86. const LLUUID& findFriendAllSubfolderUUIDImpl() const;
  87. const LLUUID& findFriendCardInventoryUUIDImpl(const LLUUID& avatarID);
  88. void findMatchedFriendCards(const LLUUID& avatarID, LLInventoryModel::item_array_t& items) const;
  89. void fetchAndCheckFolderDescendents(const LLUUID& folder_id, callback_t cb);
  90. /**
  91. * Checks whether "Calling Cards/Friends" folder exists. If not, creates it with "All"
  92. * sub-folder and synchronizes its contents with buddies list.
  93. */
  94. void ensureFriendsFolderExists();
  95. /**
  96. * Checks whether "Calling Cards/Friends/All" folder exists. If not, creates it and
  97. * synchronizes its contents with buddies list.
  98. */
  99. void ensureFriendsAllFolderExists();
  100. /**
  101. * Synchronizes content of the Calling Card/Friends/All Global Inventory folder with Agent's Friend List
  102. */
  103. void syncFriendsFolder();
  104. /**
  105. * Adds avatar specified by its UUID into the Calling Card/Friends/All Global Inventory folder
  106. */
  107. void addFriendCardToInventory(const LLUUID& avatarID);
  108. /**
  109. * Removes an avatar specified by its UUID from the Calling Card/Friends/All Global Inventory folder
  110. * and from the all Custom Folders
  111. */
  112. void removeFriendCardFromInventory(const LLUUID& avatarID);
  113. void onFriendListUpdate(U32 changed_mask);
  114. private:
  115. typedef std::set<LLUUID> avatar_uuid_set_t;
  116. avatar_uuid_set_t mBuddyIDSet;
  117. };
  118. #endif // LL_LLFRIENDCARD_H