aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/panelradar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/panelradar.cpp')
-rw-r--r--linden/indra/newview/panelradar.cpp935
1 files changed, 935 insertions, 0 deletions
diff --git a/linden/indra/newview/panelradar.cpp b/linden/indra/newview/panelradar.cpp
new file mode 100644
index 0000000..e85af44
--- /dev/null
+++ b/linden/indra/newview/panelradar.cpp
@@ -0,0 +1,935 @@
1/**
2 * @file panelradar.cpp
3 * @brief PanelRadar class (list of nearby agents)
4 *
5 * Copyright (c) 2009, McCabe Maxsted, Jacek Antonelli, Dale Glass
6 *
7 * The source code in this file ("Source Code") is provided to you
8 * under the terms of the GNU General Public License, version 2.0
9 * ("GPL"). Terms of the GPL can be found in doc/GPL-license.txt in
10 * this distribution, or online at
11 * http://secondlifegrid.net/programs/open_source/licensing/gplv2
12 *
13 * There are special exceptions to the terms and conditions of the GPL as
14 * it is applied to this Source Code. View the full text of the exception
15 * in the file doc/FLOSS-exception.txt in this software distribution, or
16 * online at
17 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL SOURCE CODE IS PROVIDED "AS IS." THE AUTHOR MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#include "llviewerprecompiledheaders.h"
29
30#include "panelradar.h"
31
32#include "llagent.h"
33#include "llchat.h"
34#include "llfloateravatarinfo.h"
35#include "llfloaterchat.h"
36#include "llfloaterfriends.h"
37#include "llfloatergroupinvite.h"
38#include "llfloatergroups.h"
39#include "llfloaterreporter.h"
40#include "llimview.h"
41#include "llmutelist.h"
42#include "llparcel.h"
43#include "llregionposition.h"
44#include "roles_constants.h"
45#include "llscrolllistctrl.h"
46#include "lltracker.h"
47#include "lluictrlfactory.h"
48#include "llviewerobjectlist.h"
49#include "llviewermenu.h"
50#include "llviewermessage.h"
51#include "llviewerparcelmgr.h"
52#include "llviewerregion.h"
53#include "llviewerwindow.h"
54#include "llvoavatar.h"
55#include "llworld.h"
56
57
58PanelRadar::PanelRadar()
59 :
60 LLPanel(),
61 mSelectedAvatar(LLUUID::null)
62{
63 LLUICtrlFactory::getInstance()->buildPanel(this, "panel_radar.xml");
64
65 mChatAvatars.clear();
66 mTypingAvatars.clear();
67 mSimAvatars.clear();
68}
69
70
71BOOL PanelRadar::postBuild()
72{
73 mRadarList = getChild<LLScrollListCtrl>("RadarList");
74 childSetCommitCallback("RadarList", onUseRadarList, this);
75 mRadarList->setDoubleClickCallback(onClickIM);
76
77 childSetAction("im_btn", onClickIM, this);
78 childSetAction("profile_btn", onClickProfile, this);
79 childSetAction("offer_teleport_btn", onClickOfferTeleport, this);
80 childSetAction("track_btn", onClickTrack, this);
81 childSetAction("invite_btn", onClickInvite, this);
82 childSetAction("add_btn", onClickAddFriend, this);
83 childSetAction("freeze_btn", onClickFreeze, this);
84 childSetAction("eject_btn", onClickEject, this);
85 childSetAction("mute_btn", onClickMute, this);
86 childSetAction("unmute_btn", onClickUnmute, this);
87 childSetAction("ar_btn", onClickAR, this);
88 childSetAction("estate_eject_btn", onClickEjectFromEstate, this);
89
90 setDefaultBtn("im_btn");
91
92 populateRadar();
93
94 return TRUE;
95}
96
97
98PanelRadar::~PanelRadar()
99{
100}
101
102
103//static
104bool PanelRadar::isImpDev(LLUUID agent_id)
105{
106 // We use strings here as avatar keys change across grids.
107 // Feel free to add/remove yourself.
108 std::string agent_name = getSelectedName(agent_id);
109 return (agent_name == "McCabe Maxsted" ||
110 agent_name == "Jacek Antonelli" ||
111 agent_name == "Armin Weatherwax");
112}
113
114
115void PanelRadar::populateRadar()
116{
117 if (!getVisible())
118 {
119 return;
120 }
121
122 if (visibleItemsSelected())
123 {
124 mSelectedAvatar = mRadarList->getFirstSelected()->getUUID();
125 }
126 else
127 {
128 mSelectedAvatar.setNull();
129 }
130
131 S32 scroll_pos = mRadarList->getScrollPos();
132
133 // clear count
134 std::stringstream avatar_count;
135 avatar_count.str("");
136
137 // find what avatars you can see
138 F32 range = gSavedSettings.getF32("NearMeRange");
139 LLVector3d current_pos = gAgent.getPositionGlobal();
140 std::vector<LLUUID> avatar_ids;
141 std::vector<LLVector3d> positions;
142 LLWorld::getInstance()->getAvatars(&avatar_ids, &positions);
143
144 LLSD element;
145
146 mRadarList->deleteAllItems();
147
148 if (!avatar_ids.empty())
149 {
150 for (U32 i=0; i<avatar_ids.size(); i++)
151 {
152 if (avatar_ids[i] == gAgent.getID() ||
153 avatar_ids[i].isNull())
154 {
155 continue;
156 }
157
158 // Add to list only if we get their name
159 std::string fullname = getSelectedName(avatar_ids[i]);
160 if (!fullname.empty())
161 {
162 bool notify_chat = gSavedSettings.getBOOL("MiniMapNotifyChatRange");
163 bool notify_sim = gSavedSettings.getBOOL("MiniMapNotifySimRange");
164 // [RLVa:KB] - Alternate: Imprudence-1.2.0
165 if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES))
166 {
167 fullname = gRlvHandler.getAnonym(fullname);
168 notify_chat = false;
169 notify_sim = false;
170 }
171 // [/RLVa:KB]
172
173 // check if they're in certain ranges and notify user if we've enabled that
174 LLVector3d temp = positions[i];
175 if (positions[i].mdV[VZ] == 0.0f) // LL only sends height value up to 1024m, try to work around it
176 {
177 LLViewerObject *av_obj = gObjectList.findObject(avatar_ids[i]);
178 if (av_obj != NULL && av_obj->isAvatar())
179 {
180 LLVOAvatar* avatarp = (LLVOAvatar*)av_obj;
181 if (avatarp != NULL)
182 {
183 temp = avatarp->getPositionGlobal();
184 }
185 }
186 }
187 F64 distance = dist_vec(temp, current_pos);
188 // we round for accuracy when avs tp in
189 std::string dist_string = llformat("%.1f", llround((F32)distance, 0.1f));
190
191 /*llinfos << "Avatar :" << fullname << " Position: " << positions[i] << " Your Position: "
192 << current_pos << " Distance: " << distance << llendl;*/
193
194 if (notify_chat)
195 {
196 if (distance < 20.0f)
197 {
198 if (!isInChatList(avatar_ids[i]))
199 {
200 addToChatList(avatar_ids[i], dist_string);
201 }
202 }
203 else
204 {
205 if (isInChatList(avatar_ids[i]))
206 {
207 removeFromChatList(avatar_ids[i]);
208 }
209 }
210 updateChatList(avatar_ids);
211 }
212 else if (!mChatAvatars.empty())
213 {
214 mChatAvatars.clear();
215 }
216
217 if (notify_sim)
218 {
219 if (!isInChatList(avatar_ids[i]) && !isInSimAvList(avatar_ids[i]))
220 {
221 LLViewerObject *av_obj = gObjectList.findObject(avatar_ids[i]);
222 if (av_obj != NULL && av_obj->isAvatar())
223 {
224 LLVOAvatar* avatarp = (LLVOAvatar*)av_obj;
225 if (avatarp != NULL)
226 {
227 if (avatarp->getRegion() == gAgent.getRegion())
228 {
229 addToSimAvList(avatar_ids[i], dist_string);
230 }
231 }
232 }
233 }
234 updateSimAvList(avatar_ids);
235 }
236 else if (!mSimAvatars.empty())
237 {
238 mSimAvatars.clear();
239 }
240
241 // only display avatars in range
242 if (distance <= range)
243 {
244 // append typing string
245 std::string typing = "";
246 if (isTyping(avatar_ids[i]))
247 {
248 typing = getString("is_typing")+ " ";
249 }
250
251 std::string mute_text = LLMuteList::getInstance()->isMuted(avatar_ids[i]) ? getString("is_muted") : "";
252 element["id"] = avatar_ids[i];
253 element["columns"][0]["column"] = "avatar_name";
254 element["columns"][0]["type"] = "text";
255 element["columns"][0]["value"] = typing + fullname + " " + mute_text;
256 element["columns"][1]["column"] = "avatar_distance";
257 element["columns"][1]["type"] = "text";
258 element["columns"][1]["value"] = dist_string+"m";
259
260 mRadarList->addElement(element, ADD_BOTTOM);
261 }
262 }
263 }
264
265 mRadarList->sortItems();
266 mRadarList->setScrollPos(scroll_pos);
267 if (mSelectedAvatar.notNull())
268 {
269 mRadarList->selectByID(mSelectedAvatar);
270 }
271 avatar_count << (int)avatar_ids.size();
272 }
273 else
274 {
275 mTypingAvatars.clear();
276 mRadarList->addCommentText(getString("no_one_near"), ADD_TOP);
277 avatar_count << "0";
278 }
279
280 childSetText("lblAvatarCount", avatar_count.str());
281
282 updateButtonStates();
283
284 //llinfos << "mSelectedAvatar: " << mSelectedAvatar.asString() << llendl;
285}
286
287
288void PanelRadar::updateChatList(std::vector<LLUUID> agent_ids)
289{
290 std::set<LLUUID>::iterator it;
291 std::vector<LLUUID>::iterator result;
292 for (it = mChatAvatars.begin(); it != mChatAvatars.end(); )
293 {
294 result = find(agent_ids.begin(), agent_ids.end(), *it);
295 if (result == agent_ids.end())
296 {
297 mChatAvatars.erase(it++);
298 }
299 else
300 {
301 it++;
302 }
303 }
304}
305
306
307bool PanelRadar::isInChatList(LLUUID agent_id)
308{
309 return (mChatAvatars.count(agent_id) > 0);
310}
311
312
313void PanelRadar::addToChatList(LLUUID agent_id, std::string distance)
314{
315 mChatAvatars.insert(agent_id);
316 LLChat chat;
317
318 LLUIString notify = getString("entering_chat_range");
319 notify.setArg("[NAME]", getSelectedName(agent_id));
320 notify.setArg("[DISTANCE]", distance);
321
322 chat.mText = notify;
323 chat.mSourceType = CHAT_SOURCE_SYSTEM;
324 LLFloaterChat::addChat(chat, FALSE, FALSE);
325}
326
327
328void PanelRadar::removeFromChatList(LLUUID agent_id)
329{
330 // Do we want to add a notice?
331 mChatAvatars.erase(agent_id);
332}
333
334
335bool PanelRadar::isTyping(LLUUID agent_id)
336{
337 return (mTypingAvatars.count(agent_id) > 0);
338}
339
340
341void PanelRadar::addToTypingList(LLUUID agent_id)
342{
343 mTypingAvatars.insert(agent_id);
344}
345
346
347void PanelRadar::removeFromTypingList(LLUUID agent_id)
348{
349 mTypingAvatars.erase(agent_id);
350}
351
352
353void PanelRadar::updateSimAvList(std::vector<LLUUID> agent_ids)
354{
355 std::set<LLUUID>::iterator it;
356 std::vector<LLUUID>::iterator result;
357 for (it = mSimAvatars.begin(); it != mSimAvatars.end(); )
358 {
359 result = find(agent_ids.begin(), agent_ids.end(), *it);
360 if (result == agent_ids.end())
361 {
362 mSimAvatars.erase(it++);
363 }
364 else
365 {
366 it++;
367 }
368 }
369}
370
371
372void PanelRadar::addToSimAvList(LLUUID agent_id, std::string distance)
373{
374 mSimAvatars.insert(agent_id);
375 LLChat chat;
376
377 LLUIString notify = getString("entering_sim_range");
378 notify.setArg("[NAME]", getSelectedName(agent_id));
379 notify.setArg("[DISTANCE]", distance);
380
381 chat.mText = notify;
382 chat.mSourceType = CHAT_SOURCE_SYSTEM;
383 LLFloaterChat::addChat(chat, FALSE, FALSE);
384}
385
386
387bool PanelRadar::isInSimAvList(LLUUID agent_id)
388{
389 if (mSimAvatars.count(agent_id) > 0)
390 {
391 return true;
392 }
393 return false;
394}
395
396
397void PanelRadar::updateButtonStates()
398{
399 bool enable = false;
400 bool enable_unmute = false;
401 bool enable_track = false;
402 bool enable_estate = false;
403 bool enable_friend = false;
404 if (hasFocus())
405 {
406 enable = mSelectedAvatar.notNull() ? visibleItemsSelected() : false;
407 enable_unmute = mSelectedAvatar.notNull() ? LLMuteList::getInstance()->isMuted(mSelectedAvatar) : false;
408 enable_track = gAgent.isGodlike() || is_agent_mappable(mSelectedAvatar);
409 enable_estate = isKickable(mSelectedAvatar);
410 enable_friend = !is_agent_friend(mSelectedAvatar);
411 }
412 else
413 {
414 mRadarList->deselect();
415 }
416
417 childSetEnabled("im_btn", enable);
418 childSetEnabled("profile_btn", enable);
419 childSetEnabled("offer_teleport_btn", enable);
420 childSetEnabled("track_btn", enable_track);
421 childSetEnabled("invite_btn", enable);
422 childSetEnabled("add_btn", enable);
423 childSetEnabled("freeze_btn", enable_estate);
424 childSetEnabled("eject_btn", enable_estate);
425 childSetEnabled("mute_btn", enable);
426 childSetEnabled("ar_btn", enable);
427 childSetEnabled("estate_eject_btn", enable_estate);
428
429 if (enable_unmute)
430 {
431 childSetVisible("mute_btn", false);
432 childSetEnabled("unmute_btn", true);
433 childSetVisible("unmute_btn", true);
434 }
435 else
436 {
437 childSetVisible("mute_btn", true);
438 childSetVisible("unmute_btn", false);
439 }
440
441// [RLVa:KB] - Imprudence-1.2.0
442 // Bit clumsy, but this way the RLV stuff is in its own separate
443 // block and keeps the code above clean - Kitty
444 if ( (rlv_handler_t::isEnabled()) && (mSelectedAvatar.notNull()) )
445 {
446 if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES))
447 {
448 childSetEnabled("im_btn", false);
449 childSetEnabled("profile_btn", false);
450 childSetEnabled("invite_btn", false);
451 childSetEnabled("add_btn", false);
452 childSetEnabled("mute_btn", false);
453 childSetEnabled("unmute_btn", false);
454 }
455
456 // Even though the avie is in the same sim (so they already know
457 // where we are) the tp would just get blocked by different code
458 // so it's actually less confusing to the user if we just disable
459 // the teleport button here so they'll at least have a visual cue
460 BOOL rlv_enable_tp = (!gRlvHandler.hasBehaviour(RLV_BHVR_TPLURE)) || (gRlvHandler.isException(RLV_BHVR_TPLURE, mSelectedAvatar));
461 if ( (rlv_enable_tp) && (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) )
462 {
463 const LLRelationship* pBuddyInfo = LLAvatarTracker::instance().getBuddyInfo(mSelectedAvatar);
464 if ( ((!pBuddyInfo) || (!pBuddyInfo->isOnline()) || (!pBuddyInfo->isRightGrantedTo(LLRelationship::GRANT_MAP_LOCATION))) )
465 rlv_enable_tp = FALSE;
466 }
467 childSetEnabled("offer_teleport_btn", rlv_enable_tp);
468 }
469// [/RLVa:KB]
470}
471
472
473bool PanelRadar::isKickable(const LLUUID &agent_id)
474{
475 if (agent_id.notNull())
476 {
477 LLViewerObject* av_obj = gObjectList.findObject(agent_id);
478 if (av_obj != NULL && av_obj->isAvatar())
479 {
480 LLVOAvatar* avatar = (LLVOAvatar*)av_obj;
481 LLViewerRegion* region = avatar->getRegion();
482 if (region)
483 {
484 const LLVector3& pos = avatar->getPositionRegion();
485 const LLVector3d& pos_global = avatar->getPositionGlobal();
486 if (LLWorld::getInstance()->positionRegionValidGlobal(pos_global))
487 {
488 LLParcel* parcel = LLViewerParcelMgr::getInstance()->selectParcelAt(pos_global)->getParcel();
489 LLViewerParcelMgr::getInstance()->deselectLand();
490
491 bool new_value = (region != NULL);
492
493 if (new_value)
494 {
495 new_value = region->isOwnedSelf(pos);
496 if (!new_value || region->isOwnedGroup(pos))
497 {
498 new_value = LLViewerParcelMgr::getInstance()->isParcelOwnedByAgent(parcel,GP_LAND_ADMIN);
499 }
500 }
501 return new_value;
502 }
503 }
504 }
505 }
506 return false;
507}
508
509
510// static
511void PanelRadar::onUseRadarList(LLUICtrl* ctrl, void* user_data)
512{
513 PanelRadar* self = (PanelRadar*)user_data;
514 if (self)
515 {
516 self->updateButtonStates();
517 }
518}
519
520
521bool PanelRadar::visibleItemsSelected() const
522{
523 return (mRadarList->getFirstSelectedIndex() >= 0);
524}
525
526
527LLUUID PanelRadar::getSelected()
528{
529 return mSelectedAvatar;
530}
531
532
533//static
534std::string PanelRadar::getSelectedName(const LLUUID &agent_id)
535{
536 std::string agent_name;
537 if(gCacheName->getFullName(agent_id, agent_name) && agent_name != " ")
538 {
539 return agent_name;
540 }
541 return LLStringUtil::null;
542}
543
544
545//
546// Avatar tab
547//
548
549// static
550void PanelRadar::onClickIM(void* user_data)
551{
552 PanelRadar* self = (PanelRadar*) user_data;
553 LLScrollListItem *item = self->mRadarList->getFirstSelected();
554 if (item != NULL)
555 {
556 LLUUID agent_id = item->getUUID();
557 gIMMgr->setFloaterOpen(TRUE);
558 gIMMgr->addSession(getSelectedName(agent_id), IM_NOTHING_SPECIAL, agent_id);
559 }
560}
561
562
563// static
564void PanelRadar::onClickProfile(void* user_data)
565{
566 PanelRadar* self = (PanelRadar*) user_data;
567 LLScrollListItem *item = self->mRadarList->getFirstSelected();
568 if (item != NULL)
569 {
570 LLUUID agent_id = item->getUUID();
571 LLFloaterAvatarInfo::show(agent_id);
572 }
573}
574
575
576// static
577void PanelRadar::onClickOfferTeleport(void* user_data)
578{
579 PanelRadar* self = (PanelRadar*) user_data;
580 LLScrollListItem *item = self->mRadarList->getFirstSelected();
581 if (item != NULL)
582 {
583 LLUUID agent_id = item->getUUID();
584 handle_lure(agent_id);
585 }
586}
587
588
589// static
590void PanelRadar::onClickTrack(void* user_data)
591{
592 PanelRadar* self = (PanelRadar*) user_data;
593 LLTracker::ETrackingStatus tracking_status = LLTracker::getTrackingStatus();
594
595 if (LLTracker::TRACKING_AVATAR == tracking_status)
596 {
597 LLTracker::stopTracking(NULL);
598 }
599 else
600 {
601 LLScrollListItem *item = self->mRadarList->getFirstSelected();
602 if (item != NULL)
603 {
604 LLUUID agent_id = item->getUUID();
605 LLTracker::trackAvatar(agent_id, getSelectedName(agent_id));
606 }
607 }
608}
609
610
611// static
612void PanelRadar::onClickInvite(void* user_data)
613{
614 PanelRadar* self = (PanelRadar*) user_data;
615 LLScrollListItem *item = self->mRadarList->getFirstSelected();
616 if (item != NULL)
617 {
618 LLUUID agent_id = item->getUUID();
619 LLFloaterGroupPicker* widget;
620 widget = LLFloaterGroupPicker::showInstance(LLSD(gAgent.getID()));
621 if (widget)
622 {
623 widget->center();
624 widget->setPowersMask(GP_MEMBER_INVITE);
625 widget->setSelectCallback(callback_invite_to_group, (void *)&agent_id);
626 }
627 }
628}
629
630
631// static
632void PanelRadar::callback_invite_to_group(LLUUID group_id, void *user_data)
633{
634 std::vector<LLUUID> agent_ids;
635 agent_ids.push_back(*(LLUUID *)user_data);
636
637 LLFloaterGroupInvite::showForGroup(group_id, &agent_ids);
638}
639
640
641// static
642void PanelRadar::onClickAddFriend(void* user_data)
643{
644 PanelRadar* self = (PanelRadar*) user_data;
645 LLScrollListItem *item = self->mRadarList->getFirstSelected();
646 if (item != NULL)
647 {
648 LLUUID agent_id = item->getUUID();
649 LLPanelFriends::requestFriendshipDialog(agent_id, getSelectedName(agent_id));
650 }
651}
652
653
654
655//
656// Estate tab
657//
658
659//static
660void PanelRadar::callbackFreeze(S32 option, void *user_data)
661{
662 PanelRadar *self = (PanelRadar*)user_data;
663
664 if ( option == 0 )
665 {
666 sendFreeze(self->mSelectedAvatar, true);
667 }
668 else if ( option == 1 )
669 {
670 sendFreeze(self->mSelectedAvatar, false);
671 }
672}
673
674
675//static
676void PanelRadar::callbackEject(S32 option, void *user_data)
677{
678 PanelRadar *self = (PanelRadar*)user_data;
679
680 if ( option == 0 )
681 {
682 sendEject(self->mSelectedAvatar, false);
683 }
684 else if ( option == 1 )
685 {
686 sendEject(self->mSelectedAvatar, true);
687 }
688}
689
690
691//static
692void PanelRadar::callbackEjectFromEstate(S32 option, void *user_data)
693{
694 PanelRadar *self = (PanelRadar*)user_data;
695
696 if ( option == 0 )
697 {
698 cmdEstateEject(self->mSelectedAvatar);
699 }
700 else if ( option == 1 )
701 {
702 cmdEstateBan(self->mSelectedAvatar);
703 }
704}
705
706
707void PanelRadar::onClickFreeze(void *user_data)
708{
709 PanelRadar *self = (PanelRadar*)user_data;
710 LLStringUtil::format_map_t args;
711 LLSD payload;
712 args["[AVATAR_NAME]"] = getSelectedName(self->mSelectedAvatar);
713 gViewerWindow->alertXml("FreezeAvatarFullname", args, callbackFreeze, user_data);
714}
715
716
717//static
718void PanelRadar::onClickEject(void *user_data)
719{
720 PanelRadar *self = (PanelRadar*)user_data;
721 LLStringUtil::format_map_t args;
722 LLSD payload;
723 args["AVATAR_NAME"] = getSelectedName(self->mSelectedAvatar);
724 gViewerWindow->alertXml("EjectAvatarFullName", args, callbackEject, user_data);
725}
726
727
728//static
729void PanelRadar::onClickMute(void *user_data)
730{
731 PanelRadar *self = (PanelRadar*)user_data;
732 LLScrollListItem *item = self->mRadarList->getFirstSelected();
733 if (item != NULL)
734 {
735 LLUUID agent_id = item->getUUID();
736 std::string agent_name = getSelectedName(agent_id);
737 if (LLMuteList::getInstance()->isMuted(agent_id))
738 {
739 //LLMute mute(agent_id, agent_name, LLMute::AGENT);
740 //LLMuteList::getInstance()->remove(mute);
741 //LLFloaterMute::getInstance()->selectMute(agent_id);
742 }
743 else
744 {
745 LLMute mute(agent_id, agent_name, LLMute::AGENT);
746 LLMuteList::getInstance()->add(mute);
747 }
748 }
749}
750
751
752//static
753void PanelRadar::onClickUnmute(void *user_data)
754{
755 PanelRadar *self = (PanelRadar*)user_data;
756 LLScrollListItem *item = self->mRadarList->getFirstSelected();
757 if (item != NULL)
758 {
759 LLUUID agent_id = item->getUUID();
760 std::string agent_name = getSelectedName(agent_id);
761 if (LLMuteList::getInstance()->isMuted(agent_id))
762 {
763 LLMute mute(agent_id, agent_name, LLMute::AGENT);
764 LLMuteList::getInstance()->remove(mute);
765 //LLFloaterMute::getInstance()->selectMute(agent_id);
766 }
767 else
768 {
769 //LLMute mute(agent_id, agent_name, LLMute::AGENT);
770 //LLMuteList::getInstance()->add(mute);
771 }
772 }
773}
774
775
776//static
777void PanelRadar::onClickEjectFromEstate(void *user_data)
778{
779 PanelRadar *self = (PanelRadar*)user_data;
780 LLStringUtil::format_map_t args;
781 LLSD payload;
782 args["EVIL_USER"] = getSelectedName(self->mSelectedAvatar);
783 gViewerWindow->alertXml("EstateKickUser", args, callbackEjectFromEstate, user_data);
784}
785
786
787//static
788void PanelRadar::onClickAR(void *user_data)
789{
790 PanelRadar *self = (PanelRadar*)user_data;
791 LLUUID agent_id = self->mSelectedAvatar;
792
793 if (agent_id.notNull())
794 {
795 LLFloaterReporter::showFromObject(agent_id);
796 }
797}
798
799
800// static
801void PanelRadar::cmdEstateEject(const LLUUID &avatar)
802{
803 sendEstateMessage("teleporthomeuser", avatar);
804}
805
806
807// static
808void PanelRadar::cmdEstateBan(const LLUUID &avatar)
809{
810 sendEstateMessage("teleporthomeuser", avatar); // Kick first, just to be sure
811 sendEstateBan(avatar);
812}
813
814
815// static
816void PanelRadar::sendFreeze(const LLUUID& avatar_id, bool freeze)
817{
818 U32 flags = 0x0;
819 if (!freeze)
820 {
821 // unfreeze
822 flags |= 0x1;
823 }
824
825 LLMessageSystem* msg = gMessageSystem;
826 LLViewerObject* avatar = gObjectList.findObject(avatar_id);
827
828 if (avatar)
829 {
830 msg->newMessage("FreezeUser");
831 msg->nextBlock("AgentData");
832 msg->addUUID("AgentID", gAgent.getID());
833 msg->addUUID("SessionID", gAgent.getSessionID());
834 msg->nextBlock("Data");
835 msg->addUUID("TargetID", avatar_id );
836 msg->addU32("Flags", flags );
837 msg->sendReliable( avatar->getRegion()->getHost() );
838 }
839}
840
841
842// static
843void PanelRadar::sendEject(const LLUUID& avatar_id, bool ban)
844{
845 LLMessageSystem* msg = gMessageSystem;
846 LLViewerObject* avatar = gObjectList.findObject(avatar_id);
847
848 if (avatar)
849 {
850 U32 flags = 0x0;
851 if ( ban )
852 {
853 // eject and add to ban list
854 flags |= 0x1;
855 }
856
857 msg->newMessage("EjectUser");
858 msg->nextBlock("AgentData");
859 msg->addUUID("AgentID", gAgent.getID() );
860 msg->addUUID("SessionID", gAgent.getSessionID() );
861 msg->nextBlock("Data");
862 msg->addUUID("TargetID", avatar_id );
863 msg->addU32("Flags", flags );
864 msg->sendReliable( avatar->getRegion()->getHost() );
865 }
866}
867
868
869// static
870void PanelRadar::sendEstateMessage(const char* request, const LLUUID &target)
871{
872
873 LLMessageSystem* msg = gMessageSystem;
874 LLUUID invoice;
875
876 // This seems to provide an ID so that the sim can say which request it's
877 // replying to. I think this can be ignored for now.
878 invoice.generate();
879
880 llinfos << "Sending estate request '" << request << "'" << llendl;
881 msg->newMessage("EstateOwnerMessage");
882 msg->nextBlockFast(_PREHASH_AgentData);
883 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
884 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
885 msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used
886 msg->nextBlock("MethodData");
887 msg->addString("Method", request);
888 msg->addUUID("Invoice", invoice);
889
890 // Agent id
891 msg->nextBlock("ParamList");
892 msg->addString("Parameter", gAgent.getID().asString().c_str());
893
894 // Target
895 msg->nextBlock("ParamList");
896 msg->addString("Parameter", target.asString().c_str());
897
898 msg->sendReliable(gAgent.getRegion()->getHost());
899}
900
901
902// static
903void PanelRadar::sendEstateBan(const LLUUID& agent)
904{
905 LLUUID invoice;
906 U32 flags = ESTATE_ACCESS_BANNED_AGENT_ADD;
907
908 invoice.generate();
909
910 LLMessageSystem* msg = gMessageSystem;
911 msg->newMessage("EstateOwnerMessage");
912 msg->nextBlockFast(_PREHASH_AgentData);
913 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
914 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
915 msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used
916
917 msg->nextBlock("MethodData");
918 msg->addString("Method", "estateaccessdelta");
919 msg->addUUID("Invoice", invoice);
920
921 char buf[MAX_STRING]; /* Flawfinder: ignore*/
922 gAgent.getID().toString(buf);
923 msg->nextBlock("ParamList");
924 msg->addString("Parameter", buf);
925
926 snprintf(buf, MAX_STRING, "%u", flags); /* Flawfinder: ignore */
927 msg->nextBlock("ParamList");
928 msg->addString("Parameter", buf);
929
930 agent.toString(buf);
931 msg->nextBlock("ParamList");
932 msg->addString("Parameter", buf);
933
934 gAgent.sendReliableMessage();
935}