PageRenderTime 24ms CodeModel.GetById 1ms app.highlight 16ms RepoModel.GetById 2ms app.codeStats 0ms

/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
 27#ifndef LL_LLFRIENDCARD_H
 28#define LL_LLFRIENDCARD_H
 29
 30
 31#include "llcallingcard.h"
 32#include "llinventorymodel.h" // for LLInventoryModel::item_array_t
 33
 34class LLViewerInventoryItem;
 35
 36class LLFriendCardsManager
 37	: public LLSingleton<LLFriendCardsManager>
 38	, public LLFriendObserver
 39{
 40	LOG_CLASS(LLFriendCardsManager);
 41
 42	friend class LLSingleton<LLFriendCardsManager>;
 43	friend class CreateFriendCardCallback;
 44
 45public:
 46	typedef std::map<LLUUID, uuid_vec_t > folderid_buddies_map_t;
 47
 48	// LLFriendObserver implementation
 49	void changed(U32 mask)
 50	{
 51		onFriendListUpdate(mask);
 52	}
 53
 54	/**
 55	 *	Determines if specified Inventory Calling Card exists in any of lists 
 56	 *	in the Calling Card/Friends/ folder (Default, or Custom)
 57	 */
 58	bool isItemInAnyFriendsList(const LLViewerInventoryItem* item);
 59
 60	/**
 61	 *	Checks if specified category is contained in the Calling Card/Friends folder and 
 62	 *	determines if specified Inventory Object exists in that category.
 63	 */
 64	bool isObjDirectDescendentOfCategory(const LLInventoryObject* obj, const LLViewerInventoryCategory* cat) const;
 65
 66	/**
 67	 *	Checks is the specified category is in the Calling Card/Friends folder
 68	 */
 69	bool isCategoryInFriendFolder(const LLViewerInventoryCategory* cat) const;
 70
 71	/**
 72	 *	Checks is the specified category is a Friend folder or any its subfolder
 73	 */
 74	bool isAnyFriendCategory(const LLUUID& catID) const;
 75
 76	/**
 77	 *	Checks whether "Friends" and "Friends/All" folders exist in "Calling Cards" category
 78	 *	(creates them otherwise) and fetches their contents to synchronize with Agent's Friends List.
 79	 */
 80	void syncFriendCardsFolders();
 81
 82private:
 83	typedef boost::function<void()> callback_t;
 84
 85	LLFriendCardsManager();
 86	~LLFriendCardsManager();
 87
 88
 89	/**
 90	 *	Stores buddy id to avoid sent create_inventory_callingcard several time for the same Avatar
 91	 */
 92	void putAvatarData(const LLUUID& avatarID);
 93
 94	/**
 95	 *	Extracts buddy id of Created Friend Card
 96	 */
 97	const LLUUID extractAvatarID(const LLUUID& avatarID);
 98
 99	bool isAvatarDataStored(const LLUUID& avatarID) const
100	{
101		return (mBuddyIDSet.end() != mBuddyIDSet.find(avatarID));
102	}
103
104	const LLUUID& findChildFolderUUID(const LLUUID& parentFolderUUID, const std::string& nonLocalizedName) const;
105	const LLUUID& findFriendFolderUUIDImpl() const;
106	const LLUUID& findFriendAllSubfolderUUIDImpl() const;
107	const LLUUID& findFriendCardInventoryUUIDImpl(const LLUUID& avatarID);
108	void findMatchedFriendCards(const LLUUID& avatarID, LLInventoryModel::item_array_t& items) const;
109
110	void fetchAndCheckFolderDescendents(const LLUUID& folder_id, callback_t cb);
111
112	/**
113	 *	Checks whether "Calling Cards/Friends" folder exists. If not, creates it with "All"
114	 *	sub-folder and synchronizes its contents with buddies list.
115	 */
116	void ensureFriendsFolderExists();
117
118	/**
119	 *	Checks whether "Calling Cards/Friends/All" folder exists. If not, creates it and
120	 *	synchronizes its contents with buddies list.
121	 */
122	void ensureFriendsAllFolderExists();
123
124	/**
125	 *	Synchronizes content of the Calling Card/Friends/All Global Inventory folder with Agent's Friend List
126	 */
127	void syncFriendsFolder();
128
129	/**
130	 *	Adds avatar specified by its UUID into the Calling Card/Friends/All Global Inventory folder
131	 */
132	void addFriendCardToInventory(const LLUUID& avatarID);
133
134	/**
135	 *	Removes an avatar specified by its UUID from the Calling Card/Friends/All Global Inventory folder
136	 *		and from the all Custom Folders
137	 */
138	void removeFriendCardFromInventory(const LLUUID& avatarID);
139
140	void onFriendListUpdate(U32 changed_mask);
141
142
143private:
144	typedef std::set<LLUUID> avatar_uuid_set_t;
145
146	avatar_uuid_set_t mBuddyIDSet;
147};
148
149#endif // LL_LLFRIENDCARD_H