llavatarpropertiesprocessor.cpp
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:22k
源码类别:

游戏引擎

开发平台:

C++ Builder

  1. /** 
  2.  * @file llavatarpropertiesprocessor.cpp
  3.  * @brief LLAvatarPropertiesProcessor class implementation
  4.  *
  5.  * $LicenseInfo:firstyear=2001&license=viewergpl$
  6.  * 
  7.  * Copyright (c) 2001-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. #include "llviewerprecompiledheaders.h"
  33. #include "llavatarpropertiesprocessor.h"
  34. // Viewer includes
  35. #include "llagent.h"
  36. #include "llagentpicksinfo.h"
  37. #include "llviewergenericmessage.h"
  38. // Linden library includes
  39. #include "llavatarconstants.h" // AVATAR_TRANSACTED, etc.
  40. #include "lldate.h"
  41. #include "lltrans.h"
  42. #include "llui.h" // LLUI::getLanguage()
  43. #include "message.h"
  44. LLAvatarPropertiesProcessor::LLAvatarPropertiesProcessor()
  45. {
  46. }
  47. LLAvatarPropertiesProcessor::~LLAvatarPropertiesProcessor()
  48. {
  49. }
  50. void LLAvatarPropertiesProcessor::addObserver(const LLUUID& avatar_id, LLAvatarPropertiesObserver* observer)
  51. {
  52. // Check if that observer is already in mObservers for that avatar_id
  53. observer_multimap_t::iterator it;
  54. // IAN BUG this should update the observer's UUID if this is a dupe - sent to PE
  55. it = mObservers.find(avatar_id);
  56. while (it != mObservers.end())
  57. {
  58. if (it->second == observer)
  59. {
  60. return;
  61. }
  62. else
  63. {
  64. ++it;
  65. }
  66. }
  67. mObservers.insert(std::pair<LLUUID, LLAvatarPropertiesObserver*>(avatar_id, observer));
  68. }
  69. void LLAvatarPropertiesProcessor::removeObserver(const LLUUID& avatar_id, LLAvatarPropertiesObserver* observer)
  70. {
  71. if (!observer)
  72. {
  73. return;
  74. }
  75. observer_multimap_t::iterator it;
  76. it = mObservers.find(avatar_id);
  77. while (it != mObservers.end())
  78. {
  79. if (it->second == observer)
  80. {
  81. mObservers.erase(it);
  82. break;
  83. }
  84. else
  85. {
  86. ++it;
  87. }
  88. }
  89. }
  90. void LLAvatarPropertiesProcessor::sendGenericRequest(const LLUUID& avatar_id, EAvatarProcessorType type, const std::string method)
  91. {
  92. // Suppress duplicate requests while waiting for a response from the network
  93. if (isPendingRequest(avatar_id, type))
  94. {
  95. // waiting for a response, don't re-request
  96. return;
  97. }
  98. // indicate we're going to make a request
  99. addPendingRequest(avatar_id, type);
  100. std::vector<std::string> strings;
  101. strings.push_back( avatar_id.asString() );
  102. send_generic_message(method, strings);
  103. }
  104. void LLAvatarPropertiesProcessor::sendAvatarPropertiesRequest(const LLUUID& avatar_id)
  105. {
  106. if (isPendingRequest(avatar_id, APT_PROPERTIES))
  107. {
  108. // waiting for a response, don't re-request
  109. return;
  110. }
  111. // indicate we're going to make a request
  112. addPendingRequest(avatar_id, APT_PROPERTIES);
  113. LLMessageSystem *msg = gMessageSystem;
  114. msg->newMessageFast(_PREHASH_AvatarPropertiesRequest);
  115. msg->nextBlockFast( _PREHASH_AgentData);
  116. msg->addUUIDFast(   _PREHASH_AgentID, gAgent.getID() );
  117. msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
  118. msg->addUUIDFast(   _PREHASH_AvatarID, avatar_id);
  119. gAgent.sendReliableMessage();
  120. }
  121. void LLAvatarPropertiesProcessor::sendAvatarPicksRequest(const LLUUID& avatar_id)
  122. {
  123. sendGenericRequest(avatar_id, APT_PICKS, "avatarpicksrequest");
  124. }
  125. void LLAvatarPropertiesProcessor::sendAvatarNotesRequest(const LLUUID& avatar_id)
  126. {
  127. sendGenericRequest(avatar_id, APT_NOTES, "avatarnotesrequest");
  128. }
  129. void LLAvatarPropertiesProcessor::sendAvatarGroupsRequest(const LLUUID& avatar_id)
  130. {
  131. sendGenericRequest(avatar_id, APT_GROUPS, "avatargroupsrequest");
  132. }
  133. void LLAvatarPropertiesProcessor::sendAvatarTexturesRequest(const LLUUID& avatar_id)
  134. {
  135. sendGenericRequest(avatar_id, APT_TEXTURES, "avatartexturesrequest");
  136. // No response expected.
  137. removePendingRequest(avatar_id, APT_TEXTURES);
  138. }
  139. void LLAvatarPropertiesProcessor::sendAvatarClassifiedsRequest(const LLUUID& avatar_id)
  140. {
  141. sendGenericRequest(avatar_id, APT_CLASSIFIEDS, "avatarclassifiedsrequest");
  142. }
  143. void LLAvatarPropertiesProcessor::sendAvatarPropertiesUpdate(const LLAvatarData* avatar_props)
  144. {
  145. llinfos << "Sending avatarinfo update" << llendl;
  146. // This value is required by sendAvatarPropertiesUpdate method.
  147. //A profile should never be mature. (From the original code)
  148. BOOL mature = FALSE;
  149. LLMessageSystem *msg = gMessageSystem;
  150. msg->newMessageFast(_PREHASH_AvatarPropertiesUpdate);
  151. msg->nextBlockFast(_PREHASH_AgentData);
  152. msg->addUUIDFast( _PREHASH_AgentID, gAgent.getID() );
  153. msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() );
  154. msg->nextBlockFast(_PREHASH_PropertiesData);
  155. msg->addUUIDFast( _PREHASH_ImageID, avatar_props->image_id);
  156. msg->addUUIDFast( _PREHASH_FLImageID, avatar_props->fl_image_id);
  157. msg->addStringFast( _PREHASH_AboutText, avatar_props->about_text);
  158. msg->addStringFast( _PREHASH_FLAboutText, avatar_props->fl_about_text);
  159. msg->addBOOL(_PREHASH_AllowPublish, avatar_props->allow_publish);
  160. msg->addBOOL(_PREHASH_MaturePublish, mature);
  161. msg->addString(_PREHASH_ProfileURL, avatar_props->profile_url);
  162. gAgent.sendReliableMessage();
  163. }
  164. //static
  165. std::string LLAvatarPropertiesProcessor::accountType(const LLAvatarData* avatar_data)
  166. {
  167. // If you have a special account, like M Linden ("El Jefe!")
  168. // return an untranslated "special" string
  169. if (!avatar_data->caption_text.empty())
  170. {
  171. return avatar_data->caption_text;
  172. }
  173. const char* const ACCT_TYPE[] = {
  174. "AcctTypeResident",
  175. "AcctTypeTrial",
  176. "AcctTypeCharterMember",
  177. "AcctTypeEmployee"
  178. };
  179. U8 caption_max = (U8)LL_ARRAY_SIZE(ACCT_TYPE)-1;
  180. U8 caption_index = llclamp(avatar_data->caption_index, (U8)0, caption_max);
  181. return LLTrans::getString(ACCT_TYPE[caption_index]);
  182. }
  183. //static
  184. std::string LLAvatarPropertiesProcessor::paymentInfo(const LLAvatarData* avatar_data)
  185. {
  186. // Special accounts like M Linden don't have payment info revealed.
  187. if (!avatar_data->caption_text.empty()) return "";
  188. // Linden employees don't have payment info revealed
  189. const S32 LINDEN_EMPLOYEE_INDEX = 3;
  190. if (avatar_data->caption_index == LINDEN_EMPLOYEE_INDEX) return "";
  191. BOOL transacted = (avatar_data->flags & AVATAR_TRANSACTED);
  192. BOOL identified = (avatar_data->flags & AVATAR_IDENTIFIED);
  193. // Not currently getting set in dataserver/lldataavatar.cpp for privacy considerations
  194. //BOOL age_verified = (avatar_data->flags & AVATAR_AGEVERIFIED); 
  195. const char* payment_text;
  196. if(transacted)
  197. {
  198. payment_text = "PaymentInfoUsed";
  199. }
  200. else if (identified)
  201. {
  202. payment_text = "PaymentInfoOnFile";
  203. }
  204. else
  205. {
  206. payment_text = "NoPaymentInfoOnFile";
  207. }
  208. return LLTrans::getString(payment_text);
  209. }
  210. void LLAvatarPropertiesProcessor::processAvatarPropertiesReply(LLMessageSystem* msg, void**)
  211. {
  212. LLAvatarData avatar_data;
  213. msg->getUUIDFast( _PREHASH_AgentData, _PREHASH_AgentID,  avatar_data.agent_id);
  214. msg->getUUIDFast( _PREHASH_AgentData, _PREHASH_AvatarID,  avatar_data.avatar_id);
  215. msg->getUUIDFast(   _PREHASH_PropertiesData, _PREHASH_ImageID, avatar_data.image_id);
  216. msg->getUUIDFast(   _PREHASH_PropertiesData, _PREHASH_FLImageID, avatar_data.fl_image_id);
  217. msg->getUUIDFast( _PREHASH_PropertiesData, _PREHASH_PartnerID, avatar_data.partner_id);
  218. msg->getStringFast( _PREHASH_PropertiesData, _PREHASH_AboutText, avatar_data.about_text);
  219. msg->getStringFast( _PREHASH_PropertiesData, _PREHASH_FLAboutText, avatar_data.fl_about_text);
  220. msg->getStringFast( _PREHASH_PropertiesData, _PREHASH_BornOn, avatar_data.born_on);
  221. msg->getString( _PREHASH_PropertiesData, _PREHASH_ProfileURL, avatar_data.profile_url);
  222. msg->getU32Fast( _PREHASH_PropertiesData, _PREHASH_Flags, avatar_data.flags);
  223. avatar_data.caption_index = 0;
  224. S32 charter_member_size = 0;
  225. charter_member_size = msg->getSize(_PREHASH_PropertiesData, _PREHASH_CharterMember);
  226. if(1 == charter_member_size)
  227. {
  228. msg->getBinaryData(_PREHASH_PropertiesData, _PREHASH_CharterMember, &avatar_data.caption_index, 1);
  229. }
  230. else if(1 < charter_member_size)
  231. {
  232. msg->getString(_PREHASH_PropertiesData, _PREHASH_CharterMember, avatar_data.caption_text);
  233. }
  234. LLAvatarPropertiesProcessor* self = getInstance();
  235. // Request processed, no longer pending
  236. self->removePendingRequest(avatar_data.avatar_id, APT_PROPERTIES);
  237. self->notifyObservers(avatar_data.avatar_id,&avatar_data,APT_PROPERTIES);
  238. }
  239. void LLAvatarPropertiesProcessor::processAvatarInterestsReply(LLMessageSystem* msg, void**)
  240. {
  241. /*
  242. AvatarInterestsReply is automatically sent by the server in response to the 
  243. AvatarPropertiesRequest sent when the panel is opened (in addition to the AvatarPropertiesReply message). 
  244. If the interests panel is no longer part of the design (?) we should just register the message 
  245. to a handler function that does nothing. 
  246. That will suppress the warnings and be compatible with old server versions.
  247. WARNING: LLTemplateMessageReader::decodeData: Message from 216.82.37.237:13000 with no handler function received: AvatarInterestsReply
  248. */
  249. }
  250. void LLAvatarPropertiesProcessor::processAvatarClassifiedsReply(LLMessageSystem* msg, void**)
  251. {
  252. LLAvatarClassifieds classifieds;
  253. msg->getUUID(_PREHASH_AgentData, _PREHASH_AgentID, classifieds.agent_id);
  254. msg->getUUID(_PREHASH_AgentData, _PREHASH_TargetID, classifieds.target_id);
  255. S32 block_count = msg->getNumberOfBlocks(_PREHASH_Data);
  256. for(int n = 0; n < block_count; ++n)
  257. {
  258. LLAvatarClassifieds::classified_data data;
  259. msg->getUUID(_PREHASH_Data, _PREHASH_ClassifiedID, data.classified_id, n);
  260. msg->getString(_PREHASH_Data, _PREHASH_Name, data.name, n);
  261. classifieds.classifieds_list.push_back(data);
  262. }
  263. LLAvatarPropertiesProcessor* self = getInstance();
  264. // Request processed, no longer pending
  265. self->removePendingRequest(classifieds.target_id, APT_CLASSIFIEDS);
  266. self->notifyObservers(classifieds.target_id,&classifieds,APT_CLASSIFIEDS);
  267. }
  268. void LLAvatarPropertiesProcessor::processClassifiedInfoReply(LLMessageSystem* msg, void**)
  269. {
  270. LLAvatarClassifiedInfo c_info;
  271. msg->getUUID(_PREHASH_AgentData, _PREHASH_AgentID, c_info.agent_id);
  272. msg->getUUID(_PREHASH_Data, _PREHASH_ClassifiedID, c_info.classified_id);
  273. msg->getUUID(_PREHASH_Data, _PREHASH_CreatorID, c_info.creator_id);
  274. msg->getU32(_PREHASH_Data, _PREHASH_CreationDate, c_info.creation_date);
  275. msg->getU32(_PREHASH_Data, _PREHASH_ExpirationDate, c_info.expiration_date);
  276. msg->getU32(_PREHASH_Data, _PREHASH_Category, c_info.category);
  277. msg->getString(_PREHASH_Data, _PREHASH_Name, c_info.name);
  278. msg->getString(_PREHASH_Data, _PREHASH_Desc, c_info.description);
  279. msg->getUUID(_PREHASH_Data, _PREHASH_ParcelID, c_info.parcel_id);
  280. msg->getU32(_PREHASH_Data, _PREHASH_ParentEstate, c_info.parent_estate);
  281. msg->getUUID(_PREHASH_Data, _PREHASH_SnapshotID, c_info.snapshot_id);
  282. msg->getString(_PREHASH_Data, _PREHASH_SimName, c_info.sim_name);
  283. msg->getVector3d(_PREHASH_Data, _PREHASH_PosGlobal, c_info.pos_global);
  284. msg->getString(_PREHASH_Data, _PREHASH_ParcelName, c_info.parcel_name);
  285. msg->getU8(_PREHASH_Data, _PREHASH_ClassifiedFlags, c_info.flags);
  286. msg->getS32(_PREHASH_Data, _PREHASH_PriceForListing, c_info.price_for_listing);
  287. LLAvatarPropertiesProcessor* self = getInstance();
  288. // Request processed, no longer pending
  289. self->removePendingRequest(c_info.creator_id, APT_CLASSIFIED_INFO);
  290. self->notifyObservers(c_info.creator_id, &c_info, APT_CLASSIFIED_INFO);
  291. }
  292. void LLAvatarPropertiesProcessor::processAvatarNotesReply(LLMessageSystem* msg, void**)
  293. {
  294. LLAvatarNotes avatar_notes;
  295. msg->getUUID(_PREHASH_AgentData, _PREHASH_AgentID, avatar_notes.agent_id);
  296. msg->getUUID(_PREHASH_Data, _PREHASH_TargetID, avatar_notes.target_id);
  297. msg->getString(_PREHASH_Data, _PREHASH_Notes, avatar_notes.notes);
  298. LLAvatarPropertiesProcessor* self = getInstance();
  299. // Request processed, no longer pending
  300. self->removePendingRequest(avatar_notes.target_id, APT_NOTES);
  301. self->notifyObservers(avatar_notes.target_id,&avatar_notes,APT_NOTES);
  302. }
  303. void LLAvatarPropertiesProcessor::processAvatarPicksReply(LLMessageSystem* msg, void**)
  304. {
  305. LLAvatarPicks avatar_picks;
  306. msg->getUUID(_PREHASH_AgentData, _PREHASH_AgentID, avatar_picks.target_id);
  307. msg->getUUID(_PREHASH_AgentData, _PREHASH_TargetID, avatar_picks.target_id);
  308. S32 block_count = msg->getNumberOfBlocks(_PREHASH_Data);
  309. for (int block = 0; block < block_count; ++block)
  310. {
  311. LLUUID pick_id;
  312. std::string pick_name;
  313. msg->getUUID(_PREHASH_Data, _PREHASH_PickID, pick_id, block);
  314. msg->getString(_PREHASH_Data, _PREHASH_PickName, pick_name, block);
  315. avatar_picks.picks_list.push_back(std::make_pair(pick_id,pick_name));
  316. }
  317. LLAvatarPropertiesProcessor* self = getInstance();
  318. // Request processed, no longer pending
  319. self->removePendingRequest(avatar_picks.target_id, APT_PICKS);
  320. self->notifyObservers(avatar_picks.target_id,&avatar_picks,APT_PICKS);
  321. }
  322. void LLAvatarPropertiesProcessor::processPickInfoReply(LLMessageSystem* msg, void**)
  323. {
  324. LLPickData pick_data;
  325. // Extract the agent id and verify the message is for this
  326. // client.
  327. msg->getUUID(_PREHASH_AgentData, _PREHASH_AgentID, pick_data.agent_id );
  328. msg->getUUID(_PREHASH_Data, _PREHASH_PickID, pick_data.pick_id);
  329. msg->getUUID(_PREHASH_Data, _PREHASH_CreatorID, pick_data.creator_id);
  330. // ** top_pick should be deleted, not being used anymore - angela
  331. msg->getBOOL(_PREHASH_Data, _PREHASH_TopPick, pick_data.top_pick);
  332. msg->getUUID(_PREHASH_Data, _PREHASH_ParcelID, pick_data.parcel_id);
  333. msg->getString(_PREHASH_Data, _PREHASH_Name, pick_data.name);
  334. msg->getString(_PREHASH_Data, _PREHASH_Desc, pick_data.desc);
  335. msg->getUUID(_PREHASH_Data, _PREHASH_SnapshotID, pick_data.snapshot_id);
  336. msg->getString(_PREHASH_Data, _PREHASH_User, pick_data.user_name);
  337. msg->getString(_PREHASH_Data, _PREHASH_OriginalName, pick_data.original_name);
  338. msg->getString(_PREHASH_Data, _PREHASH_SimName, pick_data.sim_name);
  339. msg->getVector3d(_PREHASH_Data, _PREHASH_PosGlobal, pick_data.pos_global);
  340. msg->getS32(_PREHASH_Data, _PREHASH_SortOrder, pick_data.sort_order);
  341. msg->getBOOL(_PREHASH_Data, _PREHASH_Enabled, pick_data.enabled);
  342. LLAvatarPropertiesProcessor* self = getInstance();
  343. // don't need to remove pending request as we don't track pick info
  344. self->notifyObservers(pick_data.creator_id, &pick_data, APT_PICK_INFO);
  345. }
  346. void LLAvatarPropertiesProcessor::processAvatarGroupsReply(LLMessageSystem* msg, void**)
  347. {
  348. LLAvatarGroups avatar_groups;
  349. msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, avatar_groups.agent_id );
  350. msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AvatarID, avatar_groups.avatar_id );
  351. S32 group_count = msg->getNumberOfBlocksFast(_PREHASH_GroupData);
  352. for(S32 i = 0; i < group_count; ++i)
  353. {
  354. LLAvatarGroups::LLGroupData group_data;
  355. msg->getU64(    _PREHASH_GroupData, _PREHASH_GroupPowers, group_data.group_powers, i );
  356. msg->getStringFast(_PREHASH_GroupData, _PREHASH_GroupTitle, group_data.group_title, i );
  357. msg->getUUIDFast(  _PREHASH_GroupData, _PREHASH_GroupID, group_data.group_id, i);
  358. msg->getStringFast(_PREHASH_GroupData, _PREHASH_GroupName, group_data.group_name, i );
  359. msg->getUUIDFast(  _PREHASH_GroupData, _PREHASH_GroupInsigniaID, group_data.group_insignia_id, i );
  360. avatar_groups.group_list.push_back(group_data);
  361. }
  362. LLAvatarPropertiesProcessor* self = getInstance();
  363. self->removePendingRequest(avatar_groups.avatar_id, APT_GROUPS);
  364. self->notifyObservers(avatar_groups.avatar_id,&avatar_groups,APT_GROUPS);
  365. }
  366. void LLAvatarPropertiesProcessor::notifyObservers(const LLUUID& id,void* data, EAvatarProcessorType type)
  367. {
  368. // Copy the map (because observers may delete themselves when updated?)
  369. LLAvatarPropertiesProcessor::observer_multimap_t observers = mObservers;
  370. observer_multimap_t::iterator oi = observers.begin();
  371. observer_multimap_t::iterator end = observers.end();
  372. for (; oi != end; ++oi)
  373. {
  374. // only notify observers for the same agent, or if the observer
  375. // didn't know the agent ID and passed a NULL id.
  376. const LLUUID &agent_id = oi->first;
  377. if (agent_id == id || agent_id.isNull())
  378. {
  379. oi->second->processProperties(data,type);
  380. }
  381. }
  382. }
  383. void LLAvatarPropertiesProcessor::sendFriendRights(const LLUUID& avatar_id, S32 rights)
  384. {
  385. if(!avatar_id.isNull())
  386. {
  387. LLMessageSystem* msg = gMessageSystem;
  388. // setup message header
  389. msg->newMessageFast(_PREHASH_GrantUserRights);
  390. msg->nextBlockFast(_PREHASH_AgentData);
  391. msg->addUUID(_PREHASH_AgentID, gAgent.getID());
  392. msg->addUUID(_PREHASH_SessionID, gAgent.getSessionID());
  393. msg->nextBlockFast(_PREHASH_Rights);
  394. msg->addUUID(_PREHASH_AgentRelated, avatar_id);
  395. msg->addS32(_PREHASH_RelatedRights, rights);
  396. gAgent.sendReliableMessage();
  397. }
  398. }
  399. void LLAvatarPropertiesProcessor::sendNotes(const LLUUID& avatar_id, const std::string notes)
  400. {
  401. if(!avatar_id.isNull())
  402. {
  403. LLMessageSystem* msg = gMessageSystem;
  404. // setup message header
  405. msg->newMessageFast(_PREHASH_AvatarNotesUpdate);
  406. msg->nextBlockFast(_PREHASH_AgentData);
  407. msg->addUUID(_PREHASH_AgentID, gAgent.getID());
  408. msg->addUUID(_PREHASH_SessionID, gAgent.getSessionID());
  409. msg->nextBlockFast(_PREHASH_Data);
  410. msg->addUUID(_PREHASH_TargetID, avatar_id);
  411. msg->addString(_PREHASH_Notes, notes);
  412. gAgent.sendReliableMessage();
  413. }
  414. }
  415. void LLAvatarPropertiesProcessor::sendPickDelete( const LLUUID& pick_id )
  416. {
  417. LLMessageSystem* msg = gMessageSystem; 
  418. msg->newMessage(_PREHASH_PickDelete);
  419. msg->nextBlock(_PREHASH_AgentData);
  420. msg->addUUID(_PREHASH_AgentID, gAgent.getID());
  421. msg->addUUID(_PREHASH_SessionID, gAgent.getSessionID());
  422. msg->nextBlock(_PREHASH_Data);
  423. msg->addUUID(_PREHASH_PickID, pick_id);
  424. gAgent.sendReliableMessage();
  425. LLAgentPicksInfo::getInstance()->requestNumberOfPicks();
  426. LLAgentPicksInfo::getInstance()->decrementNumberOfPicks();
  427. }
  428. void LLAvatarPropertiesProcessor::sendClassifiedDelete(const LLUUID& classified_id)
  429. {
  430. LLMessageSystem* msg = gMessageSystem; 
  431. msg->newMessage(_PREHASH_ClassifiedDelete);
  432. msg->nextBlock(_PREHASH_AgentData);
  433. msg->addUUID(_PREHASH_AgentID, gAgent.getID());
  434. msg->addUUID(_PREHASH_SessionID, gAgent.getSessionID());
  435. msg->nextBlock(_PREHASH_Data);
  436. msg->addUUID(_PREHASH_ClassifiedID, classified_id);
  437. gAgent.sendReliableMessage();
  438. }
  439. void LLAvatarPropertiesProcessor::sendPickInfoUpdate(const LLPickData* new_pick)
  440. {
  441. if (!new_pick) return;
  442. LLMessageSystem* msg = gMessageSystem;
  443. msg->newMessage(_PREHASH_PickInfoUpdate);
  444. msg->nextBlock(_PREHASH_AgentData);
  445. msg->addUUID(_PREHASH_AgentID, gAgent.getID());
  446. msg->addUUID(_PREHASH_SessionID, gAgent.getSessionID());
  447. msg->nextBlock(_PREHASH_Data);
  448. msg->addUUID(_PREHASH_PickID, new_pick->pick_id);
  449. msg->addUUID(_PREHASH_CreatorID, new_pick->creator_id);
  450. //legacy var need to be deleted
  451. msg->addBOOL(_PREHASH_TopPick, FALSE);
  452. // fills in on simulator if null
  453. msg->addUUID(_PREHASH_ParcelID, new_pick->parcel_id);
  454. msg->addString(_PREHASH_Name, new_pick->name);
  455. msg->addString(_PREHASH_Desc, new_pick->desc);
  456. msg->addUUID(_PREHASH_SnapshotID, new_pick->snapshot_id);
  457. msg->addVector3d(_PREHASH_PosGlobal, new_pick->pos_global);
  458. // Only top picks have a sort order
  459. msg->addS32(_PREHASH_SortOrder, 0);
  460. msg->addBOOL(_PREHASH_Enabled, new_pick->enabled);
  461. gAgent.sendReliableMessage();
  462. LLAgentPicksInfo::getInstance()->requestNumberOfPicks();
  463. }
  464. void LLAvatarPropertiesProcessor::sendClassifiedInfoUpdate(const LLAvatarClassifiedInfo* c_data)
  465. {
  466. if(!c_data)
  467. {
  468. return;
  469. }
  470. LLMessageSystem* msg = gMessageSystem;
  471. msg->newMessage(_PREHASH_ClassifiedInfoUpdate);
  472. msg->nextBlock(_PREHASH_AgentData);
  473. msg->addUUID(_PREHASH_AgentID, gAgent.getID());
  474. msg->addUUID(_PREHASH_SessionID, gAgent.getSessionID());
  475. msg->nextBlock(_PREHASH_Data);
  476. msg->addUUID(_PREHASH_ClassifiedID, c_data->classified_id);
  477. msg->addU32(_PREHASH_Category, c_data->category);
  478. msg->addString(_PREHASH_Name, c_data->name);
  479. msg->addString(_PREHASH_Desc, c_data->description);
  480. msg->addUUID(_PREHASH_ParcelID, c_data->parcel_id);
  481. msg->addU32(_PREHASH_ParentEstate, 0);
  482. msg->addUUID(_PREHASH_SnapshotID, c_data->snapshot_id);
  483. msg->addVector3d(_PREHASH_PosGlobal, c_data->pos_global);
  484. msg->addU8(_PREHASH_ClassifiedFlags, c_data->flags);
  485. msg->addS32(_PREHASH_PriceForListing, c_data->price_for_listing);
  486. gAgent.sendReliableMessage();
  487. }
  488. void LLAvatarPropertiesProcessor::sendPickInfoRequest(const LLUUID& creator_id, const LLUUID& pick_id)
  489. {
  490. // Must ask for a pick based on the creator id because
  491. // the pick database is distributed to the inventory cluster. JC
  492. std::vector<std::string> request_params;
  493. request_params.push_back(creator_id.asString() );
  494. request_params.push_back(pick_id.asString() );
  495. send_generic_message("pickinforequest", request_params);
  496. }
  497. void LLAvatarPropertiesProcessor::sendClassifiedInfoRequest(const LLUUID& classified_id)
  498. {
  499. LLMessageSystem* msg = gMessageSystem;
  500. msg->newMessage(_PREHASH_ClassifiedInfoRequest);
  501. msg->nextBlock(_PREHASH_AgentData);
  502. msg->addUUID(_PREHASH_AgentID, gAgent.getID());
  503. msg->addUUID(_PREHASH_SessionID, gAgent.getSessionID());
  504. msg->nextBlock(_PREHASH_Data);
  505. msg->addUUID(_PREHASH_ClassifiedID, classified_id);
  506. gAgent.sendReliableMessage();
  507. }
  508. bool LLAvatarPropertiesProcessor::isPendingRequest(const LLUUID& avatar_id, EAvatarProcessorType type)
  509. {
  510. timestamp_map_t::key_type key = std::make_pair(avatar_id, type);
  511. timestamp_map_t::iterator it = mRequestTimestamps.find(key);
  512. // Is this a new request?
  513. if (it == mRequestTimestamps.end()) return false;
  514. // We found a request, check if it has timed out
  515. U32 now = time(NULL);
  516. const U32 REQUEST_EXPIRE_SECS = 5;
  517. U32 expires = it->second + REQUEST_EXPIRE_SECS;
  518. // Request is still pending if it hasn't expired yet
  519. // *NOTE: Expired requests will accumulate in this map, but they are rare,
  520. // the data is small, and they will be updated if the same data is
  521. // re-requested
  522. return (now < expires);
  523. }
  524. void LLAvatarPropertiesProcessor::addPendingRequest(const LLUUID& avatar_id, EAvatarProcessorType type)
  525. {
  526. timestamp_map_t::key_type key = std::make_pair(avatar_id, type);
  527. U32 now = time(NULL);
  528. // Add or update existing (expired) request
  529. mRequestTimestamps[ key ] = now;
  530. }
  531. void LLAvatarPropertiesProcessor::removePendingRequest(const LLUUID& avatar_id, EAvatarProcessorType type)
  532. {
  533. timestamp_map_t::key_type key = std::make_pair(avatar_id, type);
  534. mRequestTimestamps.erase(key);
  535. }