aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfloatermap.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2009-10-29 02:03:04 -0500
committerJacek Antonelli2009-10-29 02:45:02 -0500
commit5969412f5e9342955c79b57a10d3d6f987a06d1c (patch)
tree0eecf3faa609ae2b371641a6ed55de457a0698f9 /linden/indra/newview/llfloatermap.cpp
parentMoved radar XML to panel_radar.xml and cleaned it up. (diff)
downloadmeta-impy-5969412f5e9342955c79b57a10d3d6f987a06d1c.zip
meta-impy-5969412f5e9342955c79b57a10d3d6f987a06d1c.tar.gz
meta-impy-5969412f5e9342955c79b57a10d3d6f987a06d1c.tar.bz2
meta-impy-5969412f5e9342955c79b57a10d3d6f987a06d1c.tar.xz
Added PanelRadar class, refactored from LLFloaterMap.
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llfloatermap.cpp903
1 files changed, 15 insertions, 888 deletions
diff --git a/linden/indra/newview/llfloatermap.cpp b/linden/indra/newview/llfloatermap.cpp
index 3807a90..b9dc80e 100644
--- a/linden/indra/newview/llfloatermap.cpp
+++ b/linden/indra/newview/llfloatermap.cpp
@@ -41,46 +41,20 @@
41#include "llregionhandle.h" 41#include "llregionhandle.h"
42#include "llresizebar.h" 42#include "llresizebar.h"
43#include "lluictrlfactory.h" 43#include "lluictrlfactory.h"
44
45// radar
46#include "llchat.h"
47#include "llfirstuse.h" 44#include "llfirstuse.h"
48#include "llfloateravatarinfo.h" 45#include "panelradar.h"
49#include "llfloaterchat.h" 46
50#include "llfloaterfriends.h"
51#include "llfloatergroupinvite.h"
52#include "llfloatergroups.h"
53#include "llfloaterreporter.h"
54#include "llimview.h"
55#include "llmutelist.h"
56#include "llparcel.h"
57#include "llregionposition.h"
58#include "roles_constants.h"
59#include "llscrolllistctrl.h"
60#include "lltracker.h"
61#include "llviewerobjectlist.h"
62#include "llviewermenu.h"
63#include "llviewermessage.h"
64#include "llviewerparcelmgr.h"
65#include "llviewerregion.h"
66#include "llviewerwindow.h"
67#include "llvoavatar.h"
68#include "llworld.h"
69 47
70LLFloaterMap::LLFloaterMap(const LLSD& key) 48LLFloaterMap::LLFloaterMap(const LLSD& key)
71 : 49 :
72 LLFloater(std::string("minimap")), 50 LLFloater(std::string("minimap")),
73 mPanelMap(NULL), 51 mPanelMap(NULL),
74 mUpdate(TRUE), 52 mPanelRadar(NULL)
75 mSelectedAvatar(LLUUID::null)
76
77{ 53{
78 LLCallbackMap::map_t factory_map; 54 LLCallbackMap::map_t factory_map;
79 factory_map["mini_mapview"] = LLCallbackMap(createPanelMiniMap, this); 55 factory_map["mini_mapview"] = LLCallbackMap(createPanelMiniMap, this);
56 factory_map["RadarPanel"] = LLCallbackMap(createPanelRadar, this);
80 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_mini_map.xml", &factory_map, FALSE); 57 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_mini_map.xml", &factory_map, FALSE);
81
82 mChatAvatars.clear();
83 mTypingAvatars.clear();
84} 58}
85 59
86 60
@@ -92,6 +66,15 @@ void* LLFloaterMap::createPanelMiniMap(void* data)
92 return self->mPanelMap; 66 return self->mPanelMap;
93} 67}
94 68
69// static
70void* LLFloaterMap::createPanelRadar(void* data)
71{
72 LLFloaterMap* self = (LLFloaterMap*)data;
73 self->mPanelRadar = new PanelRadar();
74 return self->mPanelRadar;
75}
76
77
95BOOL LLFloaterMap::postBuild() 78BOOL LLFloaterMap::postBuild()
96{ 79{
97 // Send the drag handle to the back, but make sure close stays on top 80 // Send the drag handle to the back, but make sure close stays on top
@@ -100,29 +83,6 @@ BOOL LLFloaterMap::postBuild()
100 sendChildToFront(getChild<LLButton>("llfloater_close_btn")); 83 sendChildToFront(getChild<LLButton>("llfloater_close_btn"));
101 setIsChrome(TRUE); 84 setIsChrome(TRUE);
102 85
103 mRadarList = getChild<LLScrollListCtrl>("RadarList");
104 childSetCommitCallback("RadarList", onList, this);
105 mRadarList->setDoubleClickCallback(onClickIM);
106
107 childSetFocusChangedCallback("near_me_range", onRangeChange, this);
108
109 childSetAction("im_btn", onClickIM, this);
110 childSetAction("profile_btn", onClickProfile, this);
111 childSetAction("offer_teleport_btn", onClickOfferTeleport, this);
112 childSetAction("track_btn", onClickTrack, this);
113 childSetAction("invite_btn", onClickInvite, this);
114 childSetAction("add_btn", onClickAddFriend, this);
115 childSetAction("freeze_btn", onClickFreeze, this);
116 childSetAction("eject_btn", onClickEject, this);
117 childSetAction("mute_btn", onClickMute, this);
118 childSetAction("unmute_btn", onClickUnmute, this);
119 childSetAction("ar_btn", onClickAR, this);
120 childSetAction("estate_eject_btn", onClickEjectFromEstate, this);
121
122 setDefaultBtn("im_btn");
123
124 populateRadar();
125
126 return TRUE; 86 return TRUE;
127} 87}
128 88
@@ -189,841 +149,8 @@ void LLFloaterMap::open()
189} 149}
190// [/RLVa:KB] 150// [/RLVa:KB]
191 151
192// TODO: make this detachable
193// TODO: make this expand/collapse
194
195/*
196* Imprudence Radar
197* @brief inworld radar integrated with the minimap
198* by McCabe Maxsted
199* Estate tab portion by Dale Glass
200*/
201
202//static
203bool LLFloaterMap::isImpDev(LLUUID agent_id)
204{
205 // We use strings here as avatar keys change across grids.
206 // Feel free to add/remove yourself.
207 std::string agent_name = getSelectedName(agent_id);
208 if (agent_name == "McCabe Maxsted" ||
209 agent_name == "Jacek Antonelli" ||
210 agent_name == "Armin Weatherwax")
211 {
212 return true;
213 }
214 return false;
215}
216
217//static
218void LLFloaterMap::updateRadar()
219{
220 LLFloaterMap::getInstance()->populateRadar();
221}
222
223void LLFloaterMap::populateRadar()
224{
225 if (!mUpdate || !LLFloaterMap::getInstance()->getVisible())
226 {
227 return;
228 }
229
230 if (visibleItemsSelected())
231 {
232 mSelectedAvatar = mRadarList->getFirstSelected()->getUUID();
233 }
234 else
235 {
236 mSelectedAvatar.setNull();
237 }
238
239 S32 scroll_pos = mRadarList->getScrollPos();
240
241 // clear count
242 std::stringstream avatar_count;
243 avatar_count.str("");
244
245 // find what avatars you can see
246 F32 range = gSavedSettings.getF32("NearMeRange");
247 LLVector3d current_pos = gAgent.getPositionGlobal();
248 std::vector<LLUUID> avatar_ids;
249 std::vector<LLVector3d> positions;
250 LLWorld::getInstance()->getAvatars(&avatar_ids, &positions);
251
252 LLSD element;
253
254 mRadarList->deleteAllItems();
255
256 if (!avatar_ids.empty())
257 {
258 for (U32 i=0; i<avatar_ids.size(); i++)
259 {
260 if (avatar_ids[i] == gAgent.getID() ||
261 avatar_ids[i].isNull())
262 {
263 continue;
264 }
265
266 // Add to list only if we get their name
267 std::string fullname = getSelectedName(avatar_ids[i]);
268 if (!fullname.empty())
269 {
270 bool notify_chat = gSavedSettings.getBOOL("MiniMapNotifyChatRange");
271 bool notify_sim = gSavedSettings.getBOOL("MiniMapNotifySimRange");
272 // [RLVa:KB] - Alternate: Imprudence-1.2.0
273 if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES))
274 {
275 fullname = gRlvHandler.getAnonym(fullname);
276 notify_chat = false;
277 notify_sim = false;
278 }
279 // [/RLVa:KB]
280
281 // check if they're in certain ranges and notify user if we've enabled that
282 LLVector3d temp = positions[i];
283 if (positions[i].mdV[VZ] == 0.0f) // LL only sends height value up to 1024m, try to work around it
284 {
285 LLViewerObject *av_obj = gObjectList.findObject(avatar_ids[i]);
286 if (av_obj != NULL && av_obj->isAvatar())
287 {
288 LLVOAvatar* avatarp = (LLVOAvatar*)av_obj;
289 if (avatarp != NULL)
290 {
291 temp = avatarp->getPositionGlobal();
292 }
293 }
294 }
295 F64 distance = dist_vec(temp, current_pos);
296 // we round for accuracy when avs tp in
297 std::string dist_string = llformat("%.1f", llround((F32)distance, 0.1f));
298
299 /*llinfos << "Avatar :" << fullname << " Position: " << positions[i] << " Your Position: "
300 << current_pos << " Distance: " << distance << llendl;*/
301
302 if (notify_chat)
303 {
304 if (distance < 20.0f)
305 {
306 if (!isInChatList(avatar_ids[i]))
307 {
308 addToChatList(avatar_ids[i], dist_string);
309 }
310 }
311 else
312 {
313 if (isInChatList(avatar_ids[i]))
314 {
315 removeFromChatList(avatar_ids[i]);
316 }
317 }
318 updateChatList(avatar_ids);
319 }
320 else if (!mChatAvatars.empty())
321 {
322 mChatAvatars.clear();
323 }
324
325 if (notify_sim)
326 {
327 if (!isInChatList(avatar_ids[i]) && !getInSimAvList(avatar_ids[i]))
328 {
329 LLViewerObject *av_obj = gObjectList.findObject(avatar_ids[i]);
330 if (av_obj != NULL && av_obj->isAvatar())
331 {
332 LLVOAvatar* avatarp = (LLVOAvatar*)av_obj;
333 if (avatarp != NULL)
334 {
335 if (avatarp->getRegion() == gAgent.getRegion())
336 {
337 addToSimAvList(avatar_ids[i], dist_string);
338 }
339 }
340 }
341 }
342 updateSimAvList(avatar_ids);
343 }
344 else if (!mSimAvatars.empty())
345 {
346 mSimAvatars.clear();
347 }
348
349 // only display avatars in range
350 if (distance <= range)
351 {
352 // append typing string
353 std::string typing = "";
354 if (isTyping(avatar_ids[i]))
355 {
356 typing = getString("is_typing")+ " ";
357 }
358
359 std::string mute_text = LLMuteList::getInstance()->isMuted(avatar_ids[i]) ? getString("is_muted") : "";
360 element["id"] = avatar_ids[i];
361 element["columns"][0]["column"] = "avatar_name";
362 element["columns"][0]["type"] = "text";
363 element["columns"][0]["value"] = typing + fullname + " " + mute_text;
364 element["columns"][1]["column"] = "avatar_distance";
365 element["columns"][1]["type"] = "text";
366 element["columns"][1]["value"] = dist_string+"m";
367
368 mRadarList->addElement(element, ADD_BOTTOM);
369 }
370 }
371 }
372
373 mRadarList->sortItems();
374 mRadarList->setScrollPos(scroll_pos);
375 if (mSelectedAvatar.notNull())
376 {
377 mRadarList->selectByID(mSelectedAvatar);
378 }
379 avatar_count << (int)avatar_ids.size();
380 }
381 else
382 {
383 mTypingAvatars.clear();
384 mRadarList->addCommentText(getString("no_one_near"), ADD_TOP);
385 avatar_count << "0";
386 }
387
388 childSetText("lblAvatarCount", avatar_count.str());
389
390 toggleButtons();
391
392 //llinfos << "mSelectedAvatar: " << mSelectedAvatar.asString() << llendl;
393}
394
395void LLFloaterMap::updateChatList(std::vector<LLUUID> agent_ids)
396{
397 std::set<LLUUID>::iterator it;
398 std::vector<LLUUID>::iterator result;
399 for (it = mChatAvatars.begin(); it != mChatAvatars.end(); )
400 {
401 result = find(agent_ids.begin(), agent_ids.end(), *it);
402 if (result == agent_ids.end())
403 {
404 mChatAvatars.erase(it++);
405 }
406 else
407 {
408 it++;
409 }
410 }
411}
412
413bool LLFloaterMap::isInChatList(LLUUID agent_id)
414{
415 if (mChatAvatars.count(agent_id) > 0)
416 {
417 return true;
418 }
419 return false;
420}
421
422void LLFloaterMap::addToChatList(LLUUID agent_id, std::string distance)
423{
424 mChatAvatars.insert(agent_id);
425 LLChat chat;
426
427 LLUIString notify = getString("entering_chat_range");
428 notify.setArg("[NAME]", getSelectedName(agent_id));
429 notify.setArg("[DISTANCE]", distance);
430
431 chat.mText = notify;
432 chat.mSourceType = CHAT_SOURCE_SYSTEM;
433 LLFloaterChat::addChat(chat, FALSE, FALSE);
434}
435
436void LLFloaterMap::removeFromChatList(LLUUID agent_id)
437{
438 // Do we want to add a notice?
439 mChatAvatars.erase(agent_id);
440}
441
442bool LLFloaterMap::isTyping(LLUUID agent_id)
443{
444 if (mTypingAvatars.count(agent_id) > 0)
445 {
446 return true;
447 }
448 return false;
449}
450
451void LLFloaterMap::updateTypingList(LLUUID agent_id, bool remove)
452{
453 if (remove)
454 {
455 if (isTyping(agent_id))
456 {
457 mTypingAvatars.erase(agent_id);
458 }
459 }
460 else
461 {
462 mTypingAvatars.insert(agent_id);
463 }
464}
465
466void LLFloaterMap::updateSimAvList(std::vector<LLUUID> agent_ids)
467{
468 std::set<LLUUID>::iterator it;
469 std::vector<LLUUID>::iterator result;
470 for (it = mSimAvatars.begin(); it != mSimAvatars.end(); )
471 {
472 result = find(agent_ids.begin(), agent_ids.end(), *it);
473 if (result == agent_ids.end())
474 {
475 mSimAvatars.erase(it++);
476 }
477 else
478 {
479 it++;
480 }
481 }
482}
483
484void LLFloaterMap::addToSimAvList(LLUUID agent_id, std::string distance)
485{
486 mSimAvatars.insert(agent_id);
487 LLChat chat;
488
489 LLUIString notify = getString("entering_sim_range");
490 notify.setArg("[NAME]", getSelectedName(agent_id));
491 notify.setArg("[DISTANCE]", distance);
492
493 chat.mText = notify;
494 chat.mSourceType = CHAT_SOURCE_SYSTEM;
495 LLFloaterChat::addChat(chat, FALSE, FALSE);
496}
497
498bool LLFloaterMap::getInSimAvList(LLUUID agent_id)
499{
500 if (mSimAvatars.count(agent_id) > 0)
501 {
502 return true;
503 }
504 return false;
505}
506
507void LLFloaterMap::toggleButtons()
508{
509 BOOL enable = FALSE;
510 BOOL enable_unmute = FALSE;
511 BOOL enable_track = FALSE;
512 BOOL enable_estate = FALSE;
513 BOOL enable_friend = FALSE;
514 if (childHasFocus("RadarPanel"))
515 {
516 enable = mSelectedAvatar.notNull() ? visibleItemsSelected() : FALSE;
517 enable_unmute = mSelectedAvatar.notNull() ? LLMuteList::getInstance()->isMuted(mSelectedAvatar) : FALSE;
518 enable_track = gAgent.isGodlike() || is_agent_mappable(mSelectedAvatar);
519 enable_estate = isKickable(mSelectedAvatar);
520 enable_friend = !is_agent_friend(mSelectedAvatar);
521 }
522 else
523 {
524 mRadarList->deselect();
525 }
526
527 childSetEnabled("im_btn", enable);
528 childSetEnabled("profile_btn", enable);
529 childSetEnabled("offer_teleport_btn", enable);
530 childSetEnabled("track_btn", enable_track);
531 childSetEnabled("invite_btn", enable);
532 childSetEnabled("add_btn", enable);
533 childSetEnabled("freeze_btn", enable_estate);
534 childSetEnabled("eject_btn", enable_estate);
535 childSetEnabled("mute_btn", enable);
536 childSetEnabled("ar_btn", enable);
537 childSetEnabled("estate_eject_btn", enable_estate);
538
539 if (enable_unmute)
540 {
541 childSetVisible("mute_btn", false);
542 childSetEnabled("unmute_btn", true);
543 childSetVisible("unmute_btn", true);
544 }
545 else
546 {
547 childSetVisible("mute_btn", true);
548 childSetVisible("unmute_btn", false);
549 }
550
551// [RLVa:KB] - Imprudence-1.2.0
552 // Bit clumsy, but this way the RLV stuff is in its own separate block and keeps the code above clean - Kitty
553 if ( (rlv_handler_t::isEnabled()) && (mSelectedAvatar.notNull()) )
554 {
555 if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES))
556 {
557 childSetEnabled("im_btn", FALSE);
558 childSetEnabled("profile_btn", FALSE);
559 childSetEnabled("invite_btn", FALSE);
560 childSetEnabled("add_btn", FALSE);
561 childSetEnabled("mute_btn", FALSE);
562 childSetEnabled("unmute_btn", FALSE);
563 }
564
565 // Even though the avie is in the same sim (so they already know where we are) the tp would just get blocked by different code
566 // so it's actually less confusing to the user if we just disable the teleport button here so they'll at least have a visual cue
567 BOOL rlv_enable_tp = (!gRlvHandler.hasBehaviour(RLV_BHVR_TPLURE)) || (gRlvHandler.isException(RLV_BHVR_TPLURE, mSelectedAvatar));
568 if ( (rlv_enable_tp) && (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) )
569 {
570 const LLRelationship* pBuddyInfo = LLAvatarTracker::instance().getBuddyInfo(mSelectedAvatar);
571 if ( ((!pBuddyInfo) || (!pBuddyInfo->isOnline()) || (!pBuddyInfo->isRightGrantedTo(LLRelationship::GRANT_MAP_LOCATION))) )
572 rlv_enable_tp = FALSE;
573 }
574 childSetEnabled("offer_teleport_btn", rlv_enable_tp);
575 }
576// [/RLVa:KB]
577}
578
579BOOL LLFloaterMap::isKickable(const LLUUID &agent_id)
580{
581 if (agent_id.notNull())
582 {
583 LLViewerObject* av_obj = gObjectList.findObject(agent_id);
584 if (av_obj != NULL && av_obj->isAvatar())
585 {
586 LLVOAvatar* avatar = (LLVOAvatar*)av_obj;
587 LLViewerRegion* region = avatar->getRegion();
588 if (region)
589 {
590 const LLVector3& pos = avatar->getPositionRegion();
591 const LLVector3d& pos_global = avatar->getPositionGlobal();
592 if (LLWorld::getInstance()->positionRegionValidGlobal(pos_global))
593 {
594 LLParcel* parcel = LLViewerParcelMgr::getInstance()->selectParcelAt(pos_global)->getParcel();
595 LLViewerParcelMgr::getInstance()->deselectLand();
596
597 BOOL new_value = (region != NULL);
598
599 if (new_value)
600 {
601 new_value = region->isOwnedSelf(pos);
602 if (!new_value || region->isOwnedGroup(pos))
603 {
604 new_value = LLViewerParcelMgr::getInstance()->isParcelOwnedByAgent(parcel,GP_LAND_ADMIN);
605 }
606 }
607 return new_value;
608 }
609 }
610 }
611 }
612 return FALSE;
613}
614
615// static
616void LLFloaterMap::onList(LLUICtrl* ctrl, void* user_data)
617{
618 LLFloaterMap* self = (LLFloaterMap*)user_data;
619 if (self)
620 {
621 self->toggleButtons();
622 }
623}
624
625BOOL LLFloaterMap::visibleItemsSelected() const
626{
627 if (mRadarList->getFirstSelectedIndex() >= 0)
628 {
629 return TRUE;
630 }
631 return FALSE;
632}
633
634// static
635void LLFloaterMap::onRangeChange(LLFocusableElement* focus, void* user_data)
636{
637 LLFloaterMap* self = (LLFloaterMap*)user_data;
638 if (self)
639 {
640 self->mUpdate = !(self->childHasFocus("near_me_range"));
641 }
642}
643
644// static
645LLUUID LLFloaterMap::getSelected()
646{
647 return LLFloaterMap::getInstance()->mSelectedAvatar;
648}
649
650//
651// Avatar tab
652//
653
654// static
655void LLFloaterMap::onClickIM(void* user_data)
656{
657 LLFloaterMap* self = (LLFloaterMap*) user_data;
658 LLScrollListItem *item = self->mRadarList->getFirstSelected();
659 if (item != NULL)
660 {
661 LLUUID agent_id = item->getUUID();
662 gIMMgr->setFloaterOpen(TRUE);
663 gIMMgr->addSession(getSelectedName(agent_id), IM_NOTHING_SPECIAL, agent_id);
664 }
665}
666
667// static
668void LLFloaterMap::onClickProfile(void* user_data)
669{
670 LLFloaterMap* self = (LLFloaterMap*) user_data;
671 LLScrollListItem *item = self->mRadarList->getFirstSelected();
672 if (item != NULL)
673 {
674 LLUUID agent_id = item->getUUID();
675 LLFloaterAvatarInfo::show(agent_id);
676 }
677}
678
679// static
680void LLFloaterMap::onClickOfferTeleport(void* user_data)
681{
682 LLFloaterMap* self = (LLFloaterMap*) user_data;
683 LLScrollListItem *item = self->mRadarList->getFirstSelected();
684 if (item != NULL)
685 {
686 LLUUID agent_id = item->getUUID();
687 handle_lure(agent_id);
688 }
689}
690
691// static
692void LLFloaterMap::onClickTrack(void* user_data)
693{
694 LLFloaterMap* self = (LLFloaterMap*) user_data;
695 LLTracker::ETrackingStatus tracking_status = LLTracker::getTrackingStatus();
696
697 if (LLTracker::TRACKING_AVATAR == tracking_status)
698 {
699 LLTracker::stopTracking(NULL);
700 }
701 else
702 {
703 LLScrollListItem *item = self->mRadarList->getFirstSelected();
704 if (item != NULL)
705 {
706 LLUUID agent_id = item->getUUID();
707 LLTracker::trackAvatar(agent_id, getSelectedName(agent_id));
708 }
709 }
710}
711
712// static
713void LLFloaterMap::onClickInvite(void* user_data)
714{
715 LLFloaterMap* self = (LLFloaterMap*) user_data;
716 LLScrollListItem *item = self->mRadarList->getFirstSelected();
717 if (item != NULL)
718 {
719 LLUUID agent_id = item->getUUID();
720 LLFloaterGroupPicker* widget;
721 widget = LLFloaterGroupPicker::showInstance(LLSD(gAgent.getID()));
722 if (widget)
723 {
724 widget->center();
725 widget->setPowersMask(GP_MEMBER_INVITE);
726 widget->setSelectCallback(callback_invite_to_group, (void *)&agent_id);
727 }
728 }
729}
730
731// static
732void LLFloaterMap::callback_invite_to_group(LLUUID group_id, void *user_data)
733{
734 std::vector<LLUUID> agent_ids;
735 agent_ids.push_back(*(LLUUID *)user_data);
736
737 LLFloaterGroupInvite::showForGroup(group_id, &agent_ids);
738}
739
740// static
741void LLFloaterMap::onClickAddFriend(void* user_data)
742{
743 LLFloaterMap* self = (LLFloaterMap*) user_data;
744 LLScrollListItem *item = self->mRadarList->getFirstSelected();
745 if (item != NULL)
746 {
747 LLUUID agent_id = item->getUUID();
748 LLPanelFriends::requestFriendshipDialog(agent_id, getSelectedName(agent_id));
749 }
750}
751
752//
753// Estate tab
754//
755
756//static
757std::string LLFloaterMap::getSelectedName(const LLUUID &agent_id)
758{
759 std::string agent_name;
760 if(gCacheName->getFullName(agent_id, agent_name) && agent_name != " ")
761 {
762 return agent_name;
763 }
764 return LLStringUtil::null;
765}
766
767//static
768void LLFloaterMap::callbackFreeze(S32 option, void *user_data)
769{
770 LLFloaterMap *self = (LLFloaterMap*)user_data;
771
772 if ( option == 0 )
773 {
774 sendFreeze(self->mSelectedAvatar, true);
775 }
776 else if ( option == 1 )
777 {
778 sendFreeze(self->mSelectedAvatar, false);
779 }
780}
781
782//static
783void LLFloaterMap::callbackEject(S32 option, void *user_data)
784{
785 LLFloaterMap *self = (LLFloaterMap*)user_data;
786
787 if ( option == 0 )
788 {
789 sendEject(self->mSelectedAvatar, false);
790 }
791 else if ( option == 1 )
792 {
793 sendEject(self->mSelectedAvatar, true);
794 }
795}
796
797//static
798void LLFloaterMap::callbackEjectFromEstate(S32 option, void *user_data)
799{
800 LLFloaterMap *self = (LLFloaterMap*)user_data;
801
802 if ( option == 0 )
803 {
804 cmdEstateEject(self->mSelectedAvatar);
805 }
806 else if ( option == 1 )
807 {
808 cmdEstateBan(self->mSelectedAvatar);
809 }
810}
811
812void LLFloaterMap::onClickFreeze(void *user_data)
813{
814 LLFloaterMap *self = (LLFloaterMap*)user_data;
815 LLStringUtil::format_map_t args;
816 LLSD payload;
817 args["[AVATAR_NAME]"] = getSelectedName(self->mSelectedAvatar);
818 gViewerWindow->alertXml("FreezeAvatarFullname", args, callbackFreeze, user_data);
819}
820
821//static
822void LLFloaterMap::onClickEject(void *user_data)
823{
824 LLFloaterMap *self = (LLFloaterMap*)user_data;
825 LLStringUtil::format_map_t args;
826 LLSD payload;
827 args["AVATAR_NAME"] = getSelectedName(self->mSelectedAvatar);
828 gViewerWindow->alertXml("EjectAvatarFullName", args, callbackEject, user_data);
829}
830
831//static
832void LLFloaterMap::onClickMute(void *user_data)
833{
834 LLFloaterMap *self = (LLFloaterMap*)user_data;
835 LLScrollListItem *item = self->mRadarList->getFirstSelected();
836 if (item != NULL)
837 {
838 LLUUID agent_id = item->getUUID();
839 std::string agent_name = getSelectedName(agent_id);
840 if (LLMuteList::getInstance()->isMuted(agent_id))
841 {
842 //LLMute mute(agent_id, agent_name, LLMute::AGENT);
843 //LLMuteList::getInstance()->remove(mute);
844 //LLFloaterMute::getInstance()->selectMute(agent_id);
845 }
846 else
847 {
848 LLMute mute(agent_id, agent_name, LLMute::AGENT);
849 LLMuteList::getInstance()->add(mute);
850 }
851 }
852}
853
854//static
855void LLFloaterMap::onClickUnmute(void *user_data)
856{
857 LLFloaterMap *self = (LLFloaterMap*)user_data;
858 LLScrollListItem *item = self->mRadarList->getFirstSelected();
859 if (item != NULL)
860 {
861 LLUUID agent_id = item->getUUID();
862 std::string agent_name = getSelectedName(agent_id);
863 if (LLMuteList::getInstance()->isMuted(agent_id))
864 {
865 LLMute mute(agent_id, agent_name, LLMute::AGENT);
866 LLMuteList::getInstance()->remove(mute);
867 //LLFloaterMute::getInstance()->selectMute(agent_id);
868 }
869 else
870 {
871 //LLMute mute(agent_id, agent_name, LLMute::AGENT);
872 //LLMuteList::getInstance()->add(mute);
873 }
874 }
875}
876 152
877//static 153PanelRadar* LLFloaterMap::getRadar()
878void LLFloaterMap::onClickEjectFromEstate(void *user_data)
879{ 154{
880 LLFloaterMap *self = (LLFloaterMap*)user_data; 155 return mPanelRadar;
881 LLStringUtil::format_map_t args;
882 LLSD payload;
883 args["EVIL_USER"] = getSelectedName(self->mSelectedAvatar);
884 gViewerWindow->alertXml("EstateKickUser", args, callbackEjectFromEstate, user_data);
885}
886
887//static
888void LLFloaterMap::onClickAR(void *user_data)
889{
890 LLFloaterMap *self = (LLFloaterMap*)user_data;
891 LLUUID agent_id = self->mSelectedAvatar;
892
893 if (agent_id.notNull())
894 {
895 LLFloaterReporter::showFromObject(agent_id);
896 }
897}
898
899// static
900void LLFloaterMap::cmdEstateEject(const LLUUID &avatar)
901{
902 sendEstateMessage("teleporthomeuser", avatar);
903}
904
905// static
906void LLFloaterMap::cmdEstateBan(const LLUUID &avatar)
907{
908 sendEstateMessage("teleporthomeuser", avatar); // Kick first, just to be sure
909 sendEstateBan(avatar);
910}
911
912// static
913void LLFloaterMap::sendFreeze(const LLUUID& avatar_id, bool freeze)
914{
915 U32 flags = 0x0;
916 if (!freeze)
917 {
918 // unfreeze
919 flags |= 0x1;
920 }
921
922 LLMessageSystem* msg = gMessageSystem;
923 LLViewerObject* avatar = gObjectList.findObject(avatar_id);
924
925 if (avatar)
926 {
927 msg->newMessage("FreezeUser");
928 msg->nextBlock("AgentData");
929 msg->addUUID("AgentID", gAgent.getID());
930 msg->addUUID("SessionID", gAgent.getSessionID());
931 msg->nextBlock("Data");
932 msg->addUUID("TargetID", avatar_id );
933 msg->addU32("Flags", flags );
934 msg->sendReliable( avatar->getRegion()->getHost() );
935 }
936}
937
938// static
939void LLFloaterMap::sendEject(const LLUUID& avatar_id, bool ban)
940{
941 LLMessageSystem* msg = gMessageSystem;
942 LLViewerObject* avatar = gObjectList.findObject(avatar_id);
943
944 if (avatar)
945 {
946 U32 flags = 0x0;
947 if ( ban )
948 {
949 // eject and add to ban list
950 flags |= 0x1;
951 }
952
953 msg->newMessage("EjectUser");
954 msg->nextBlock("AgentData");
955 msg->addUUID("AgentID", gAgent.getID() );
956 msg->addUUID("SessionID", gAgent.getSessionID() );
957 msg->nextBlock("Data");
958 msg->addUUID("TargetID", avatar_id );
959 msg->addU32("Flags", flags );
960 msg->sendReliable( avatar->getRegion()->getHost() );
961 }
962}
963
964// static
965void LLFloaterMap::sendEstateMessage(const char* request, const LLUUID &target)
966{
967
968 LLMessageSystem* msg = gMessageSystem;
969 LLUUID invoice;
970
971 // This seems to provide an ID so that the sim can say which request it's
972 // replying to. I think this can be ignored for now.
973 invoice.generate();
974
975 llinfos << "Sending estate request '" << request << "'" << llendl;
976 msg->newMessage("EstateOwnerMessage");
977 msg->nextBlockFast(_PREHASH_AgentData);
978 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
979 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
980 msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used
981 msg->nextBlock("MethodData");
982 msg->addString("Method", request);
983 msg->addUUID("Invoice", invoice);
984
985 // Agent id
986 msg->nextBlock("ParamList");
987 msg->addString("Parameter", gAgent.getID().asString().c_str());
988
989 // Target
990 msg->nextBlock("ParamList");
991 msg->addString("Parameter", target.asString().c_str());
992
993 msg->sendReliable(gAgent.getRegion()->getHost());
994}
995
996// static
997void LLFloaterMap::sendEstateBan(const LLUUID& agent)
998{
999 LLUUID invoice;
1000 U32 flags = ESTATE_ACCESS_BANNED_AGENT_ADD;
1001
1002 invoice.generate();
1003
1004 LLMessageSystem* msg = gMessageSystem;
1005 msg->newMessage("EstateOwnerMessage");
1006 msg->nextBlockFast(_PREHASH_AgentData);
1007 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
1008 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
1009 msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used
1010
1011 msg->nextBlock("MethodData");
1012 msg->addString("Method", "estateaccessdelta");
1013 msg->addUUID("Invoice", invoice);
1014
1015 char buf[MAX_STRING]; /* Flawfinder: ignore*/
1016 gAgent.getID().toString(buf);
1017 msg->nextBlock("ParamList");
1018 msg->addString("Parameter", buf);
1019
1020 snprintf(buf, MAX_STRING, "%u", flags); /* Flawfinder: ignore */
1021 msg->nextBlock("ParamList");
1022 msg->addString("Parameter", buf);
1023
1024 agent.toString(buf);
1025 msg->nextBlock("ParamList");
1026 msg->addString("Parameter", buf);
1027
1028 gAgent.sendReliableMessage();
1029} 156}