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