Beispiel #1
0
// static
void LLFloaterFriends::onClickRemove(void* user_data)
{
	//llinfos << "LLFloaterFriends::onClickRemove()" << llendl;
	LLDynamicArray<LLUUID> ids = getSelectedIDs();
	LLStringBase<char>::format_map_t args;
	if(ids.size() > 0)
	{
		LLString msgType = "RemoveFromFriends";
		if(ids.size() == 1)
		{
			LLUUID agent_id = ids[0];
			char first[DB_FIRST_NAME_BUF_SIZE];		/*Flawfinder: ignore*/
			char last[DB_LAST_NAME_BUF_SIZE];		/*Flawfinder: ignore*/
			if(gCacheName->getName(agent_id, first, last))
			{
				args["[FIRST_NAME]"] = first;
				args["[LAST_NAME]"] = last;	
			}
		}
		else
		{
			msgType = "RemoveMultipleFromFriends";
		}
		gViewerWindow->alertXml(msgType,
			args,
			&handleRemove,
			(void*)new LLDynamicArray<LLUUID>(ids));
	}
}
void LLPanelFriends::refreshNames(U32 changed_mask)
{
	LLDynamicArray<LLUUID> selected_ids = getSelectedIDs();	
	S32 pos = mFriendsList->getScrollPos();	
	
	// get all buddies we know about
	LLAvatarTracker::buddy_map_t all_buddies;
	LLAvatarTracker::instance().copyBuddyList(all_buddies);

	BOOL have_names = TRUE;

	if(changed_mask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE))
	{
		have_names &= refreshNamesSync(all_buddies);
	}

	if(changed_mask & LLFriendObserver::ONLINE)
	{
		have_names &= refreshNamesPresence(all_buddies);
	}

	if (!have_names)
	{
		mEventTimer.start();
	}
	// Changed item in place, need to request sort and update columns
	// because we might have changed data in a column on which the user
	// has already sorted. JC
	mFriendsList->sortItems();

	// re-select items
	mFriendsList->selectMultiple(selected_ids);
	mFriendsList->setScrollPos(pos);
}
Beispiel #3
0
// static
void LLFloaterFriends::onClickIM(void* user_data)
{
	//llinfos << "LLFloaterFriends::onClickIM()" << llendl;
	LLDynamicArray<LLUUID> ids = getSelectedIDs();
	if(ids.size() > 0)
	{
		if(ids.size() == 1)
		{
			LLUUID agent_id = ids[0];
			const LLRelationship* info = LLAvatarTracker::instance().getBuddyInfo(agent_id);
			char first[DB_FIRST_NAME_BUF_SIZE];	/* Flawfinder: ignore */
			char last[DB_LAST_NAME_BUF_SIZE];	/* Flawfinder: ignore */
			if(info && gCacheName->getName(agent_id, first, last))
			{
				char buffer[MAX_STRING];	/* Flawfinder: ignore */
				snprintf(buffer, MAX_STRING, "%s %s", first, last);	/* Flawfinder: ignore */
				gIMMgr->setFloaterOpen(TRUE);
				gIMMgr->addSession(
					buffer,
					IM_NOTHING_SPECIAL,
					agent_id);
			}		
		}
		else
		{
			gIMMgr->setFloaterOpen(TRUE);
			gIMMgr->addSession("Friends Conference",
								IM_SESSION_CONFERENCE_START,
								ids[0],
								ids);
		}
		make_ui_sound("UISndStartIM");
	}
}
Beispiel #4
0
// static
void LLFloaterFriends::onClickPay(void*)
{
	LLDynamicArray<LLUUID> ids = getSelectedIDs();
	if(ids.size() == 1)
	{	
		handle_pay_by_id(ids[0]);
	}
}
Beispiel #5
0
// static
void LLFloaterFriends::onClickOfferTeleport(void*)
{
	LLDynamicArray<LLUUID> ids = getSelectedIDs();
	if(ids.size() > 0)
	{	
		handle_lure(ids);
	}
}
Beispiel #6
0
void LLFloaterFriends::refreshRightsChangeList()
{
	if (!sInstance) return;
	LLDynamicArray<LLUUID> friends = getSelectedIDs();
	S32 num_selected = friends.size();

	bool can_offer_teleport = num_selected >= 1;
	bool selected_friends_online = true;

	LLTextBox* processing_label = LLUICtrlFactory::getTextBoxByName(this, "process_rights_label");

	if(!mAllowRightsChange)
	{
		if(processing_label)
		{
			processing_label->setVisible(true);
			// ignore selection for now
			friends.clear();
			num_selected = 0;
		}
	}
	else if(processing_label)
	{
		processing_label->setVisible(false);
	}

	const LLRelationship* friend_status = NULL;
	for(LLDynamicArray<LLUUID>::iterator itr = friends.begin(); itr != friends.end(); ++itr)
	{
		friend_status = LLAvatarTracker::instance().getBuddyInfo(*itr);
		if (friend_status)
		{
			if(!friend_status->isOnline())
			{
				can_offer_teleport = false;
				selected_friends_online = false;
			}
		}
		else // missing buddy info, don't allow any operations
		{
			can_offer_teleport = false;
		}
	}
	
	if (num_selected == 0)  // nothing selected
	{
		childSetEnabled("im_btn", FALSE);
		childSetEnabled("offer_teleport_btn", FALSE);
	}
	else // we have at least one friend selected...
	{
		// only allow IMs to groups when everyone in the group is online
		// to be consistent with context menus in inventory and because otherwise
		// offline friends would be silently dropped from the session
		childSetEnabled("im_btn", selected_friends_online || num_selected == 1);
		childSetEnabled("offer_teleport_btn", can_offer_teleport);
	}
}
Beispiel #7
0
// static
void LLFloaterFriends::onClickProfile(void* user_data)
{
	//llinfos << "LLFloaterFriends::onClickProfile()" << llendl;
	LLDynamicArray<LLUUID> ids = getSelectedIDs();
	if(ids.size() > 0)
	{
		LLUUID agent_id = ids[0];
		BOOL online;
		online = LLAvatarTracker::instance().isBuddyOnline(agent_id);
		LLFloaterAvatarInfo::showFromFriend(agent_id, online);
	}
}
void LLPanelFriends::updateFriends(U32 changed_mask)
{
	LLUUID selected_id;
	LLCtrlListInterface *friends_list = childGetListInterface("friend_list");
	if (!friends_list) return;
	LLCtrlScrollInterface *friends_scroll = childGetScrollInterface("friend_list");
	if (!friends_scroll) return;
	
	// We kill the selection warning, otherwise we'll spam with warning popups
	// if the maximum amount of friends are selected
	mShowMaxSelectWarning = false;

	LLDynamicArray<LLUUID> selected_friends = getSelectedIDs();
	if(changed_mask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE | LLFriendObserver::ONLINE))
	{
		refreshNames(changed_mask);
	}
	else if(changed_mask & LLFriendObserver::POWERS)
	{
		--mNumRightsChanged;
		if(mNumRightsChanged > 0)
		{
			mPeriod = RIGHTS_CHANGE_TIMEOUT;	
			mEventTimer.start();
			mAllowRightsChange = FALSE;
		}
		else
		{
			tick();
		}
	}
	if(selected_friends.size() > 0)
	{
		// only non-null if friends was already found. This may fail,
		// but we don't really care here, because refreshUI() will
		// clean up the interface.
		friends_list->setCurrentByID(selected_id);
		for(LLDynamicArray<LLUUID>::iterator itr = selected_friends.begin(); itr != selected_friends.end(); ++itr)
		{
			friends_list->setSelectedByValue(*itr, true);
		}
	}

	refreshUI();
	mShowMaxSelectWarning = true;
}
void LLPanelFriends::refreshRightsChangeList()
{
	std::vector<LLUUID> friends = getSelectedIDs();
	S32 num_selected = friends.size();

	bool can_offer_teleport = num_selected >= 1;
	bool selected_friends_online = true;

	const LLRelationship* friend_status = NULL;
	for(std::vector<LLUUID>::iterator itr = friends.begin(); itr != friends.end(); ++itr)
	{
		friend_status = LLAvatarTracker::instance().getBuddyInfo(*itr);
		if (friend_status)
		{
			if(!friend_status->isOnline())
			{
				can_offer_teleport = false;
				selected_friends_online = false;
			}
		}
		else // missing buddy info, don't allow any operations
		{
			can_offer_teleport = false;
		}
	}
	
	if (num_selected == 0)  // nothing selected
	{
		childSetEnabled("im_btn", FALSE);
		childSetEnabled("offer_teleport_btn", FALSE);
	}
	else // we have at least one friend selected...
	{
		// only allow IMs to groups when everyone in the group is online
		// to be consistent with context menus in inventory and because otherwise
		// offline friends would be silently dropped from the session
		childSetEnabled("im_btn", selected_friends_online || num_selected == 1);
		childSetEnabled("offer_teleport_btn", can_offer_teleport);
	}
}
Beispiel #10
0
void LLFloaterFriends::refreshNames()
{
	if (!sInstance) return;
	LLDynamicArray<LLUUID> selected_ids = getSelectedIDs();	
	S32 pos = mFriendsList->getScrollPos();	
	
	// get all buddies we know about
	LLAvatarTracker::buddy_map_t all_buddies;
	LLAvatarTracker::instance().copyBuddyList(all_buddies);
	
	// get all friends in list and sort by UUID
	std::vector<LLScrollListItem*> items = mFriendsList->getAllData();
	std::sort(items.begin(), items.end(), SortFriendsByID());

	std::vector<LLScrollListItem*>::iterator item_it = items.begin();
	std::vector<LLScrollListItem*>::iterator item_end = items.end();
	
	LLAvatarTracker::buddy_map_t::iterator buddy_it;
	for (buddy_it = all_buddies.begin() ; buddy_it != all_buddies.end(); ++buddy_it)
	{
		// erase any items that reflect residents who are no longer buddies
		while(item_it != item_end && buddy_it->first > (*item_it)->getValue().asUUID())
		{
			mFriendsList->deleteItems((*item_it)->getValue());
			++item_it;
		}

		// update existing friends with new info
		if (item_it != item_end && buddy_it->first == (*item_it)->getValue().asUUID())
		{
			const LLRelationship* info = buddy_it->second;
			if (!info) 
			{	
				++item_it;
				continue;
			}
			
			S32 last_change_generation = (*item_it)->getColumn(LIST_FRIEND_UPDATE_GEN)->getValue().asInteger();
			if (last_change_generation < info->getChangeSerialNum())
			{
				// update existing item in UI
				updateFriendItem(mFriendsList->getItem(buddy_it->first), info);
			}
			++item_it;
		}
		// add new friend to list
		else 
		{
			const LLUUID& buddy_id = buddy_it->first;
			char first_name[DB_FIRST_NAME_BUF_SIZE];	/*Flawfinder: ignore*/	
			char last_name[DB_LAST_NAME_BUF_SIZE];		/*Flawfinder: ignore*/

			gCacheName->getName(buddy_id, first_name, last_name);
			std::ostringstream fullname;
			fullname << first_name << " " << last_name;
			addFriend(fullname.str(), buddy_id);
		}
	}

	mFriendsList->selectMultiple(selected_ids);
	mFriendsList->setScrollPos(pos);
}
Beispiel #11
0
void LLPanelFriends::refreshNames(U32 changed_mask, const std::string& search_string)
{
    LLDynamicArray<LLUUID> selected_ids = getSelectedIDs();
    S32 pos = mFriendsList->getScrollPos();

    // get all buddies we know about
    LLAvatarTracker::buddy_map_t all_buddies;
    LLAvatarTracker::instance().copyBuddyList(all_buddies);

    BOOL have_names = TRUE;

    // I hate doing it this way. There's no need for it. I blame LL -- MC
    if (search_string.empty())
    {
        if(changed_mask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE))
        {
            have_names &= refreshNamesSync(all_buddies);
        }

        if(changed_mask & LLFriendObserver::ONLINE)
        {
            have_names &= refreshNamesPresence(all_buddies);
        }
    }
    else
    {
        std::string firstname;
        std::string lastname;
        std::string filter = search_string;
        LLStringUtil::toLower(filter);
        LLAvatarTracker::buddy_map_t temp_buddies;

        for (LLAvatarTracker::buddy_map_t::reverse_iterator bIt = all_buddies.rbegin();
                bIt != all_buddies.rend(); ++bIt)
        {
            if (gCacheName->getName((*bIt).first, firstname, lastname))
            {
                std::string l_name(firstname);
                LLStringUtil::toLower(l_name);
                std::string l_sname(lastname);
                LLStringUtil::toLower(l_sname);
                if (l_name.find(filter) == 0 || l_sname.find(filter) == 0)
                {
                    temp_buddies.insert(temp_buddies.begin(), std::pair<LLUUID, LLRelationship*>((*bIt).first, (*bIt).second));
                }
            }
        }
        if(changed_mask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE))
        {
            have_names &= refreshNamesSync(temp_buddies);
        }

        if(changed_mask & LLFriendObserver::ONLINE)
        {
            have_names &= refreshNamesPresence(temp_buddies);
        }
    }

    if (!have_names)
    {
        mEventTimer.start();
    }
    // Changed item in place, need to request sort and update columns
    // because we might have changed data in a column on which the user
    // has already sorted. JC
    mFriendsList->sortItems();

    // re-select items
    mFriendsList->selectMultiple(selected_ids);
    mFriendsList->setScrollPos(pos);
}
Beispiel #12
0
void LLPanelFriends::refreshRightsChangeList()
{

	LLDynamicArray<LLUUID> friends = getSelectedIDs();
	
	S32 num_selected = friends.size();
	bool can_offer_teleport = num_selected >= 1;
	bool selected_friends_online = true;

	/*LLTextBox* processing_label = getChild<LLTextBox>("process_rights_label");

	if(!mAllowRightsChange)
	{
		if(processing_label)
		{
			processing_label->setVisible(true);
			// ignore selection for now
			friends.clear();
			num_selected = 0;
		}
	}
	else if(processing_label)
	{
		processing_label->setVisible(false);
	} Making Dummy View -HgB */
	const LLRelationship* friend_status = NULL;
	for(LLDynamicArray<LLUUID>::iterator itr = friends.begin(); itr != friends.end(); ++itr)
	{
		friend_status = LLAvatarTracker::instance().getBuddyInfo(*itr);
		if (friend_status)
		{
			if(!friend_status->isOnline())
			{
				can_offer_teleport = false;
				selected_friends_online = false;
			}
		}
		else // missing buddy info, don't allow any operations
		{
			can_offer_teleport = false;
		}
	}

	//Stuff for the online/total/select counts.
	
	getChild<LLTextBox>("s_num")->setValue(llformat("%d", num_selected));
	getChild<LLTextBox>("f_num")->setValue(llformat("%d / %d", mNumOnline, mFriendsList->getItemCount()));
	
	if (num_selected == 0)  // nothing selected
	{
		childSetEnabled("im_btn", FALSE);
		childSetEnabled("assign_btn", FALSE);
		childSetEnabled("offer_teleport_btn", FALSE);
	}
	else // we have at least one friend selected...
	{
		// only allow IMs to groups when everyone in the group is online
		// to be consistent with context menus in inventory and because otherwise
		// offline friends would be silently dropped from the session
		childSetEnabled("im_btn", selected_friends_online || num_selected == 1);
		childSetEnabled("assign_btn", num_selected == 1);
		childSetEnabled("offer_teleport_btn", can_offer_teleport);
	}
}