PageRenderTime 27ms CodeModel.GetById 13ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llavatarpropertiesprocessor.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 278 lines | 171 code | 59 blank | 48 comment | 0 complexity | 3821254ed50f9e9fb8f6424d6a710c8b MD5 | raw file
  1/** 
  2 * @file llavatarpropertiesprocessor.h
  3 * @brief LLAvatatIconCtrl base class
  4 *
  5 * $LicenseInfo:firstyear=2001&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_LLAVATARPROPERTIESPROCESSOR_H
 28#define LL_LLAVATARPROPERTIESPROCESSOR_H
 29
 30#include "lluuid.h"
 31#include "llsingleton.h"
 32#include "v3dmath.h"	// LLVector3d
 33#include <list>
 34#include <map>
 35
 36/*
 37*TODO Vadim: This needs some refactoring:
 38- Remove EAvatarProcessorType in favor of separate observers, derived from a common parent (to get rid of void*).
 39*/
 40
 41class LLMessageSystem;
 42
 43enum EAvatarProcessorType
 44{
 45	APT_PROPERTIES,
 46	APT_NOTES,
 47	APT_GROUPS,
 48	APT_PICKS,
 49	APT_PICK_INFO,
 50	APT_TEXTURES,
 51	APT_CLASSIFIEDS,
 52	APT_CLASSIFIED_INFO
 53};
 54
 55struct LLAvatarData
 56{
 57	LLUUID 		agent_id;
 58	LLUUID		avatar_id; //target id
 59	LLUUID		image_id;
 60	LLUUID		fl_image_id;
 61	LLUUID		partner_id;
 62	std::string	about_text;
 63	std::string	fl_about_text;
 64	LLDate		born_on;
 65	std::string	profile_url;
 66	U8			caption_index;
 67	std::string	caption_text;
 68	U32			flags;
 69	BOOL		allow_publish;
 70};
 71
 72struct LLAvatarPicks
 73{
 74	LLUUID agent_id;
 75	LLUUID target_id; //target id
 76
 77	typedef std::pair<LLUUID,std::string> pick_data_t;
 78	typedef std::list< pick_data_t> picks_list_t;
 79	picks_list_t picks_list;
 80};
 81
 82struct LLPickData
 83{
 84	LLUUID agent_id;
 85	LLUUID pick_id;
 86	LLUUID creator_id;
 87	BOOL top_pick;
 88	LLUUID parcel_id;
 89	std::string name;
 90	std::string desc;
 91	LLUUID snapshot_id;
 92	LLVector3d pos_global;
 93	S32 sort_order;
 94	BOOL enabled;
 95
 96	//used only in read requests
 97	std::string user_name;
 98	std::string original_name;
 99	std::string sim_name;
100
101	//used only in write (update) requests
102	LLUUID session_id;
103
104};
105
106struct LLAvatarNotes
107{
108	LLUUID agent_id;
109	LLUUID target_id; //target id
110	std::string notes;
111};
112
113struct LLAvatarGroups
114{
115	LLUUID agent_id;
116	LLUUID avatar_id; //target id
117	BOOL list_in_profile;
118
119	struct LLGroupData;
120	typedef std::list<LLGroupData> group_list_t;
121
122	group_list_t group_list;
123
124	struct LLGroupData
125	{
126		U64 group_powers;
127		BOOL accept_notices;
128		std::string group_title;
129		LLUUID group_id;
130		std::string group_name;
131		LLUUID group_insignia_id;
132	};
133};
134
135struct LLAvatarClassifieds
136{
137	LLUUID agent_id;
138	LLUUID target_id;
139
140	struct classified_data;
141	typedef std::list<classified_data> classifieds_list_t;
142
143	classifieds_list_t classifieds_list;
144
145	struct classified_data
146	{
147		LLUUID classified_id;
148		std::string name;
149	};
150};
151
152struct LLAvatarClassifiedInfo
153{
154	LLUUID agent_id;
155	LLUUID classified_id;
156	LLUUID creator_id;
157	U32 creation_date;
158	U32 expiration_date;
159	U32 category;
160	std::string name;
161	std::string description;
162	LLUUID parcel_id;
163	U32 parent_estate;
164	LLUUID snapshot_id;
165	std::string sim_name;
166	LLVector3d pos_global;
167	std::string parcel_name;
168	U8 flags;
169	S32 price_for_listing;
170};
171
172class LLAvatarPropertiesObserver
173{
174public:
175	virtual ~LLAvatarPropertiesObserver() {}
176	virtual void processProperties(void* data, EAvatarProcessorType type) = 0;
177};
178
179class LLAvatarPropertiesProcessor
180	: public LLSingleton<LLAvatarPropertiesProcessor>
181{
182public:
183	
184	LLAvatarPropertiesProcessor();
185	virtual ~LLAvatarPropertiesProcessor();
186
187	void addObserver(const LLUUID& avatar_id, LLAvatarPropertiesObserver* observer);
188	
189	void removeObserver(const LLUUID& avatar_id, LLAvatarPropertiesObserver* observer);
190
191	// Request various types of avatar data.  Duplicate requests will be
192	// suppressed while waiting for a response from the network.
193	void sendAvatarPropertiesRequest(const LLUUID& avatar_id);
194	void sendAvatarPicksRequest(const LLUUID& avatar_id);
195	void sendAvatarNotesRequest(const LLUUID& avatar_id);
196	void sendAvatarGroupsRequest(const LLUUID& avatar_id);
197	void sendAvatarTexturesRequest(const LLUUID& avatar_id);
198	void sendAvatarClassifiedsRequest(const LLUUID& avatar_id);
199
200	// Duplicate pick info requests are not suppressed.
201	void sendPickInfoRequest(const LLUUID& creator_id, const LLUUID& pick_id);
202
203	void sendClassifiedInfoRequest(const LLUUID& classified_id);
204
205	void sendAvatarPropertiesUpdate(const LLAvatarData* avatar_props);
206
207	void sendPickInfoUpdate(const LLPickData* new_pick);
208
209	void sendClassifiedInfoUpdate(const LLAvatarClassifiedInfo* c_data);
210
211	void sendFriendRights(const LLUUID& avatar_id, S32 rights);
212
213	void sendNotes(const LLUUID& avatar_id, const std::string notes);
214
215	void sendPickDelete(const LLUUID& pick_id);
216
217	void sendClassifiedDelete(const LLUUID& classified_id);
218
219	// Returns translated, human readable string for account type, such
220	// as "Resident" or "Linden Employee".  Used for profiles, inspectors.
221	static std::string accountType(const LLAvatarData* avatar_data);
222
223	// Returns translated, human readable string for payment info, such
224	// as "Payment Info on File" or "Payment Info Used".
225	// Used for profiles, inspectors.
226	static std::string paymentInfo(const LLAvatarData* avatar_data);
227
228	static void processAvatarPropertiesReply(LLMessageSystem* msg, void**);
229
230	static void processAvatarInterestsReply(LLMessageSystem* msg, void**);
231
232	static void processAvatarClassifiedsReply(LLMessageSystem* msg, void**);
233
234	static void processClassifiedInfoReply(LLMessageSystem* msg, void**);
235
236	static void processAvatarGroupsReply(LLMessageSystem* msg, void**);
237
238	static void processAvatarNotesReply(LLMessageSystem* msg, void**);
239
240	static void processAvatarPicksReply(LLMessageSystem* msg, void**);
241
242	static void processPickInfoReply(LLMessageSystem* msg, void**);
243
244protected:
245
246	void sendGenericRequest(const LLUUID& avatar_id, EAvatarProcessorType type, const std::string method);
247
248	void notifyObservers(const LLUUID& id,void* data, EAvatarProcessorType type);
249
250	// Is there a pending, not timed out, request for this avatar's data?
251	// Use this to suppress duplicate requests for data when a request is
252	// pending.
253	bool isPendingRequest(const LLUUID& avatar_id, EAvatarProcessorType type);
254
255	// Call this when a request has been sent
256	void addPendingRequest(const LLUUID& avatar_id, EAvatarProcessorType type);
257
258	// Call this when the reply to the request is received
259	void removePendingRequest(const LLUUID& avatar_id, EAvatarProcessorType type);
260
261	typedef void* (*processor_method_t)(LLMessageSystem*);
262	static processor_method_t getProcessor(EAvatarProcessorType type);
263
264protected:
265	
266	typedef std::multimap<LLUUID, LLAvatarPropertiesObserver*> observer_multimap_t;
267	
268	observer_multimap_t mObservers;
269
270	// Keep track of pending requests for data by avatar id and type.
271	// Maintain a timestamp for each request so a request that receives no reply
272	// does not block future requests forever.
273	// Map avatar_id+request_type -> U32 timestamp in seconds
274	typedef std::map< std::pair<LLUUID, EAvatarProcessorType>, U32> timestamp_map_t;
275	timestamp_map_t mRequestTimestamps;
276};
277
278#endif  // LL_LLAVATARPROPERTIESPROCESSOR_H