1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
|
/**
* @file llavatarpropertiesprocessor.cpp
* @brief LLAvatarPropertiesProcessor class implementation
*
* $LicenseInfo:firstyear=2001&license=viewergpl$
*
* Copyright (c) 2001-2009, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "llavatarpropertiesprocessor.h"
#include "message.h"
#include "llagent.h"
#include "llviewergenericmessage.h"
LLAvatarPropertiesProcessor::LLAvatarPropertiesProcessor()
{
}
void LLAvatarPropertiesProcessor::addObserver(const LLUUID& avatar_id, LLAvatarPropertiesObserver* observer)
{
// Check if that observer is already in mObservers for that avatar_id
observer_multimap_t::iterator it;
// IAN BUG this should update the observer's UUID if this is a dupe - sent to PE
it = mObservers.find(avatar_id);
while (it != mObservers.end())
{
if (it->second == observer)
{
return;
}
else
{
++it;
}
}
mObservers.insert(std::pair<LLUUID, LLAvatarPropertiesObserver*>(avatar_id, observer));
}
void LLAvatarPropertiesProcessor::removeObserver(const LLUUID& avatar_id, LLAvatarPropertiesObserver* observer)
{
if (!observer)
{
return;
}
observer_multimap_t::iterator it;
it = mObservers.find(avatar_id);
while (it != mObservers.end())
{
if (it->second == observer)
{
mObservers.erase(it);
break;
}
else
{
++it;
}
}
}
void LLAvatarPropertiesProcessor::sendDataRequest(const LLUUID& avatar_id, EAvatarProcessorType type,
const void * data)
{
switch(type)
{
case APT_PROPERTIES:
sendAvatarPropertiesRequest(avatar_id);
break;
case APT_PICKS:
sendGenericRequest(avatar_id, "avatarpicksrequest");
break;
case APT_PICK_INFO:
if (data) {
sendPickInfoRequest(avatar_id, *static_cast<const LLUUID*>(data));
}
case APT_NOTES:
sendGenericRequest(avatar_id, "avatarnotesrequest");
break;
case APT_GROUPS:
sendGenericRequest(avatar_id, "avatargroupsrequest");
break;
default:
break;
}
}
void LLAvatarPropertiesProcessor::sendGenericRequest(const LLUUID& avatar_id, const std::string method)
{
std::vector<std::string> strings;
strings.push_back( avatar_id.asString() );
send_generic_message(method, strings);
}
void LLAvatarPropertiesProcessor::sendAvatarPropertiesRequest(const LLUUID& avatar_id)
{
LLMessageSystem *msg = gMessageSystem;
msg->newMessageFast(_PREHASH_AvatarPropertiesRequest);
msg->nextBlockFast( _PREHASH_AgentData);
msg->addUUIDFast( _PREHASH_AgentID, gAgent.getID() );
msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
msg->addUUIDFast( _PREHASH_AvatarID, avatar_id);
gAgent.sendReliableMessage();
}
void LLAvatarPropertiesProcessor::sendDataUpdate(const void* data, EAvatarProcessorType type)
{
switch(type)
{
case APT_PROPERTIES:
sendAvatarPropertiesUpdate(data);
break;
case APT_PICK_INFO:
sendPicInfoUpdate(data);
case APT_PICKS:
// sendGenericRequest(avatar_id, "avatarpicksrequest");
break;
case APT_NOTES:
// sendGenericRequest(avatar_id, "avatarnotesrequest");
break;
case APT_GROUPS:
// sendGenericRequest(avatar_id, "avatargroupsrequest");
break;
default:
break;
}
}
void LLAvatarPropertiesProcessor::sendAvatarPropertiesUpdate(const void* data)
{
llinfos << "Sending avatarinfo update" << llendl;
const LLAvatarData* avatar_props = static_cast<const LLAvatarData*>(data);
// This value is required by sendAvatarPropertiesUpdate method.
//A profile should never be mature. (From the original code)
BOOL mature = FALSE;
LLMessageSystem *msg = gMessageSystem;
msg->newMessageFast(_PREHASH_AvatarPropertiesUpdate);
msg->nextBlockFast(_PREHASH_AgentData);
msg->addUUIDFast( _PREHASH_AgentID, gAgent.getID() );
msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() );
msg->nextBlockFast(_PREHASH_PropertiesData);
msg->addUUIDFast( _PREHASH_ImageID, avatar_props->image_id);
msg->addUUIDFast( _PREHASH_FLImageID, avatar_props->fl_image_id);
msg->addStringFast( _PREHASH_AboutText, avatar_props->about_text);
msg->addStringFast( _PREHASH_FLAboutText, avatar_props->fl_about_text);
msg->addBOOL(_PREHASH_AllowPublish, avatar_props->allow_publish);
msg->addBOOL(_PREHASH_MaturePublish, mature);
msg->addString(_PREHASH_ProfileURL, avatar_props->profile_url);
gAgent.sendReliableMessage();
}
void LLAvatarPropertiesProcessor::processAvatarPropertiesReply(LLMessageSystem* msg, void**)
{
LLAvatarData avatar_data;
msg->getUUIDFast( _PREHASH_AgentData, _PREHASH_AgentID, avatar_data.agent_id);
msg->getUUIDFast( _PREHASH_AgentData, _PREHASH_AvatarID, avatar_data.avatar_id);
msg->getUUIDFast( _PREHASH_PropertiesData, _PREHASH_ImageID, avatar_data.image_id);
msg->getUUIDFast( _PREHASH_PropertiesData, _PREHASH_FLImageID, avatar_data.fl_image_id);
msg->getUUIDFast( _PREHASH_PropertiesData, _PREHASH_PartnerID, avatar_data.partner_id);
msg->getStringFast( _PREHASH_PropertiesData, _PREHASH_AboutText, avatar_data.about_text);
msg->getStringFast( _PREHASH_PropertiesData, _PREHASH_FLAboutText, avatar_data.fl_about_text);
msg->getStringFast( _PREHASH_PropertiesData, _PREHASH_BornOn, avatar_data.born_on);
msg->getString( _PREHASH_PropertiesData, _PREHASH_ProfileURL, avatar_data.profile_url);
msg->getU32Fast( _PREHASH_PropertiesData, _PREHASH_Flags, avatar_data.flags);
avatar_data.caption_index = 0;
S32 charter_member_size = 0;
charter_member_size = msg->getSize(_PREHASH_PropertiesData, _PREHASH_CharterMember);
if(1 == charter_member_size)
{
msg->getBinaryData(_PREHASH_PropertiesData, _PREHASH_CharterMember, &avatar_data.caption_index, 1);
}
else if(1 < charter_member_size)
{
msg->getString(_PREHASH_PropertiesData, _PREHASH_CharterMember, avatar_data.caption_text);
}
notifyObservers(avatar_data.avatar_id,&avatar_data,APT_PROPERTIES);
}
void LLAvatarPropertiesProcessor::processAvatarInterestsReply(LLMessageSystem* msg, void**)
{
/*
AvatarInterestsReply is automatically sent by the server in response to the
AvatarPropertiesRequest sent when the panel is opened (in addition to the AvatarPropertiesReply message).
If the interests panel is no longer part of the design (?) we should just register the message
to a handler function that does nothing.
That will suppress the warnings and be compatible with old server versions.
WARNING: LLTemplateMessageReader::decodeData: Message from 216.82.37.237:13000 with no handler function received: AvatarInterestsReply
*/
}
void LLAvatarPropertiesProcessor::processAvatarClassifiedReply(LLMessageSystem* msg, void**)
{
// avatarclassifiedsrequest is not sent according to new UI design but
// keep this method according to resolved issues.
}
void LLAvatarPropertiesProcessor::processAvatarNotesReply(LLMessageSystem* msg, void**)
{
LLAvatarNotes avatar_notes;
msg->getUUID(_PREHASH_AgentData, _PREHASH_AgentID, avatar_notes.agent_id);
msg->getUUID(_PREHASH_Data, _PREHASH_TargetID, avatar_notes.target_id);
msg->getString(_PREHASH_Data, _PREHASH_Notes, avatar_notes.notes);
notifyObservers(avatar_notes.target_id,&avatar_notes,APT_NOTES);
}
void LLAvatarPropertiesProcessor::processAvatarPicksReply(LLMessageSystem* msg, void**)
{
LLAvatarPicks avatar_picks;
msg->getUUID(_PREHASH_AgentData, _PREHASH_AgentID, avatar_picks.target_id);
msg->getUUID(_PREHASH_AgentData, _PREHASH_TargetID, avatar_picks.target_id);
S32 block_count = msg->getNumberOfBlocks(_PREHASH_Data);
for (int block = 0; block < block_count; ++block)
{
LLUUID pick_id;
std::string pick_name;
msg->getUUID(_PREHASH_Data, _PREHASH_PickID, pick_id, block);
msg->getString(_PREHASH_Data, _PREHASH_PickName, pick_name, block);
avatar_picks.picks_list.push_back(std::make_pair(pick_id,pick_name));
}
notifyObservers(avatar_picks.target_id,&avatar_picks,APT_PICKS);
}
void LLAvatarPropertiesProcessor::processPickInfoReply(LLMessageSystem* msg, void**)
{
LLPickData pick_data;
// Extract the agent id and verify the message is for this
// client.
msg->getUUID(_PREHASH_AgentData, _PREHASH_AgentID, pick_data.agent_id );
msg->getUUID(_PREHASH_Data, _PREHASH_PickID, pick_data.pick_id);
msg->getUUID(_PREHASH_Data, _PREHASH_CreatorID, pick_data.creator_id);
// ** top_pick should be deleted, not being used anymore - angela
msg->getBOOL(_PREHASH_Data, _PREHASH_TopPick, pick_data.top_pick);
msg->getUUID(_PREHASH_Data, _PREHASH_ParcelID, pick_data.parcel_id);
msg->getString(_PREHASH_Data, _PREHASH_Name, pick_data.name);
msg->getString(_PREHASH_Data, _PREHASH_Desc, pick_data.desc);
msg->getUUID(_PREHASH_Data, _PREHASH_SnapshotID, pick_data.snapshot_id);
// "Location text" is actually the owner name, the original
// name that owner gave the parcel, and the location.
msg->getString(_PREHASH_Data, _PREHASH_User, pick_data.location_text);
pick_data.location_text.append(", ");
msg->getString(_PREHASH_Data, _PREHASH_OriginalName, pick_data.original_name);
if (!pick_data.original_name.empty())
{
pick_data.location_text.append(pick_data.original_name);
pick_data.location_text.append(", ");
}
msg->getString(_PREHASH_Data, _PREHASH_SimName, pick_data.sim_name);
pick_data.location_text.append(pick_data.sim_name);
pick_data.location_text.append(" ");
msg->getVector3d(_PREHASH_Data, _PREHASH_PosGlobal, pick_data.pos_global);
S32 region_x = llround((F32)pick_data.pos_global.mdV[VX]) % REGION_WIDTH_UNITS;
S32 region_y = llround((F32)pick_data.pos_global.mdV[VY]) % REGION_WIDTH_UNITS;
S32 region_z = llround((F32)pick_data.pos_global.mdV[VZ]);
pick_data.location_text.append(llformat("(%d, %d, %d)", region_x, region_y, region_z));
msg->getS32(_PREHASH_Data, _PREHASH_SortOrder, pick_data.sort_order);
msg->getBOOL(_PREHASH_Data, _PREHASH_Enabled, pick_data.enabled);
notifyObservers(pick_data.agent_id, &pick_data, APT_PICK_INFO);
}
void LLAvatarPropertiesProcessor::processAvatarGroupsReply(LLMessageSystem* msg, void**)
{
LLAvatarGroups avatar_groups;
msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, avatar_groups.agent_id );
msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AvatarID, avatar_groups.avatar_id );
S32 group_count = msg->getNumberOfBlocksFast(_PREHASH_GroupData);
for(S32 i = 0; i < group_count; ++i)
{
LLAvatarGroups::LLGroupData group_data;
msg->getU64( _PREHASH_GroupData, _PREHASH_GroupPowers, group_data.group_powers, i );
msg->getStringFast(_PREHASH_GroupData, _PREHASH_GroupTitle, group_data.group_title, i );
msg->getUUIDFast( _PREHASH_GroupData, _PREHASH_GroupID, group_data.group_id, i);
msg->getStringFast(_PREHASH_GroupData, _PREHASH_GroupName, group_data.group_name, i );
msg->getUUIDFast( _PREHASH_GroupData, _PREHASH_GroupInsigniaID, group_data.group_insignia_id, i );
avatar_groups.group_list.push_back(group_data);
}
notifyObservers(avatar_groups.avatar_id,&avatar_groups,APT_GROUPS);
}
void LLAvatarPropertiesProcessor::notifyObservers(const LLUUID& id,void* data, EAvatarProcessorType type)
{
LLAvatarPropertiesProcessor::observer_multimap_t observers = LLAvatarPropertiesProcessor::getInstance()->mObservers;
observer_multimap_t::iterator oi = observers.lower_bound(id);
observer_multimap_t::iterator end = observers.upper_bound(id);
for (; oi != end; ++oi)
{
oi->second->processProperties(data,type);
}
}
void LLAvatarPropertiesProcessor::sendFriendRights(const LLUUID& avatar_id, S32 rights)
{
if(!avatar_id.isNull())
{
LLMessageSystem* msg = gMessageSystem;
// setup message header
msg->newMessageFast(_PREHASH_GrantUserRights);
msg->nextBlockFast(_PREHASH_AgentData);
msg->addUUID(_PREHASH_AgentID, gAgent.getID());
msg->addUUID(_PREHASH_SessionID, gAgent.getSessionID());
msg->nextBlockFast(_PREHASH_Rights);
msg->addUUID(_PREHASH_AgentRelated, avatar_id);
msg->addS32(_PREHASH_RelatedRights, rights);
gAgent.sendReliableMessage();
}
}
void LLAvatarPropertiesProcessor::sendNotes(const LLUUID& avatar_id, const std::string notes)
{
if(!avatar_id.isNull())
{
LLMessageSystem* msg = gMessageSystem;
// setup message header
msg->newMessageFast(_PREHASH_AvatarNotesUpdate);
msg->nextBlockFast(_PREHASH_AgentData);
msg->addUUID(_PREHASH_AgentID, gAgent.getID());
msg->addUUID(_PREHASH_SessionID, gAgent.getSessionID());
msg->nextBlockFast(_PREHASH_Data);
msg->addUUID(_PREHASH_TargetID, avatar_id);
msg->addString(_PREHASH_Notes, notes);
gAgent.sendReliableMessage();
}
}
void LLAvatarPropertiesProcessor::sendPickDelete( const LLUUID& pick_id )
{
LLMessageSystem* msg = gMessageSystem;
msg->newMessage(_PREHASH_PickDelete);
msg->nextBlock(_PREHASH_AgentData);
msg->addUUID(_PREHASH_AgentID, gAgent.getID());
msg->addUUID(_PREHASH_SessionID, gAgent.getSessionID());
msg->nextBlock(_PREHASH_Data);
msg->addUUID(_PREHASH_PickID, pick_id);
gAgent.sendReliableMessage();
}
void LLAvatarPropertiesProcessor::sendPicInfoUpdate(const void* pick_data)
{
if (!pick_data) return;
const LLPickData *new_pick = static_cast<const LLPickData*>(pick_data);
if (!new_pick) return;
LLMessageSystem* msg = gMessageSystem;
msg->newMessage(_PREHASH_PickInfoUpdate);
msg->nextBlock(_PREHASH_AgentData);
msg->addUUID(_PREHASH_AgentID, gAgent.getID());
msg->addUUID(_PREHASH_SessionID, gAgent.getSessionID());
msg->nextBlock(_PREHASH_Data);
msg->addUUID(_PREHASH_PickID, new_pick->pick_id);
msg->addUUID(_PREHASH_CreatorID, new_pick->creator_id);
//legacy var need to be deleted
msg->addBOOL(_PREHASH_TopPick, FALSE);
// fills in on simulator if null
msg->addUUID(_PREHASH_ParcelID, new_pick->parcel_id);
msg->addString(_PREHASH_Name, new_pick->name);
msg->addString(_PREHASH_Desc, new_pick->desc);
msg->addUUID(_PREHASH_SnapshotID, new_pick->snapshot_id);
msg->addVector3d(_PREHASH_PosGlobal, new_pick->pos_global);
// Only top picks have a sort order
msg->addS32(_PREHASH_SortOrder, 0);
msg->addBOOL(_PREHASH_Enabled, new_pick->enabled);
gAgent.sendReliableMessage();
}
void LLAvatarPropertiesProcessor::sendPickInfoRequest(const LLUUID& creator_id, const LLUUID& pick_id)
{
// Must ask for a pick based on the creator id because
// the pick database is distributed to the inventory cluster. JC
std::vector<std::string> request_params;
request_params.push_back(creator_id.asString() );
request_params.push_back(pick_id.asString() );
send_generic_message("pickinforequest", request_params);
}
|