From 4945ae17d3692f089ce6c996f6585a5e5b308e4d Mon Sep 17 00:00:00 2001 From: Baker Linden Date: Thu, 29 Aug 2013 11:36:45 -0700 Subject: Initial commit for GroupBan - Lots of crap isn't working as intended yet. --- indra/newview/llpanelgroupinvite.cpp | 673 ++++++++--------------------------- 1 file changed, 156 insertions(+), 517 deletions(-) (limited to 'indra/newview/llpanelgroupinvite.cpp') diff --git a/indra/newview/llpanelgroupinvite.cpp b/indra/newview/llpanelgroupinvite.cpp index 133b269c11..c990584d22 100755 --- a/indra/newview/llpanelgroupinvite.cpp +++ b/indra/newview/llpanelgroupinvite.cpp @@ -26,6 +26,8 @@ #include "llviewerprecompiledheaders.h" #include "llpanelgroupinvite.h" +#include "llpanelgroupbulk.h" +#include "llpanelgroupbulkimpl.h" #include "llagent.h" #include "llavatarnamecache.h" @@ -45,203 +47,216 @@ #include "lluictrlfactory.h" #include "llviewerwindow.h" -class LLPanelGroupInvite::impl + +// BAKER TODO: +// Figure out how to use LLHandle to make this safer +//bool invite_owner_callback(LLPanelGroupInvite panel, const LLSD& notification, const LLSD& response) +bool invite_owner_callback(LLHandle panel_handle, const LLSD& notification, const LLSD& response) { -public: - impl(const LLUUID& group_id); - ~impl(); - - void addUsers(const std::vector& names, - const uuid_vec_t& agent_ids); - void submitInvitations(); - void addRoleNames(LLGroupMgrGroupData* gdatap); - void handleRemove(); - void handleSelection(); - - static void callbackClickCancel(void* userdata); - static void callbackClickOK(void* userdata); - static void callbackClickAdd(void* userdata); - static void callbackClickRemove(void* userdata); - static void callbackSelect(LLUICtrl* ctrl, void* userdata); - static void callbackAddUsers(const uuid_vec_t& agent_ids, - void* user_data); - - static void onAvatarNameCache(const LLUUID& agent_id, - const LLAvatarName& av_name, - void* user_data); - - bool inviteOwnerCallback(const LLSD& notification, const LLSD& response); - -public: - LLUUID mGroupID; - - std::string mLoadingText; - LLNameListCtrl *mInvitees; - LLComboBox *mRoleNames; - LLButton *mOKButton; - LLButton *mRemoveButton; - LLTextBox *mGroupName; - std::string mOwnerWarning; - std::string mAlreadyInGroup; - std::string mTooManySelected; - bool mConfirmedOwnerInvite; - - void (*mCloseCallback)(void* data); - - void* mCloseCallbackUserData; - - boost::signals2::connection mAvatarNameCacheConnection; -}; - - -LLPanelGroupInvite::impl::impl(const LLUUID& group_id): - mGroupID( group_id ), - mLoadingText (), - mInvitees ( NULL ), - mRoleNames( NULL ), - mOKButton ( NULL ), - mRemoveButton( NULL ), - mGroupName( NULL ), - mConfirmedOwnerInvite( false ), - mCloseCallback( NULL ), - mCloseCallbackUserData( NULL ), - mAvatarNameCacheConnection() + LLPanelGroupInvite* panel = dynamic_cast(panel_handle.get()); + if(!panel) + return false; + + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + switch(option) + { + case 0: + // user confirmed that they really want a new group owner + panel->mImplementation->mConfirmedOwnerInvite = true; + panel->submit(); + break; + case 1: + // fall through + default: + break; + } + return false; +} + + +LLPanelGroupInvite::LLPanelGroupInvite(const LLUUID& group_id) : LLPanelGroupBulk(group_id) { + // Pass on construction of this panel to the control factory. + buildFromFile( "panel_group_invite.xml"); } -LLPanelGroupInvite::impl::~impl() +void LLPanelGroupInvite::clear() { - if (mAvatarNameCacheConnection.connected()) + LLPanelGroupBulk::clear(); + + if(mImplementation->mRoleNames) { - mAvatarNameCacheConnection.disconnect(); + mImplementation->mRoleNames->clear(); + mImplementation->mRoleNames->removeall(); + mImplementation->mRoleNames->setCurrentByID(LLUUID::null); } } -void LLPanelGroupInvite::impl::addUsers(const std::vector& names, - const uuid_vec_t& agent_ids) +void LLPanelGroupInvite::update() { - std::string name; - LLUUID id; + LLPanelGroupBulk::update(); - for (S32 i = 0; i < (S32)names.size(); i++) + if(mImplementation->mRoleNames) { - name = names[i]; - id = agent_ids[i]; - - // Make sure this agent isn't already in the list. - bool already_in_list = false; - std::vector items = mInvitees->getAllData(); - for (std::vector::iterator iter = items.begin(); - iter != items.end(); ++iter) + LLUUID store_selected_role = mImplementation->mRoleNames->getCurrentID(); + mImplementation->mRoleNames->clear(); + mImplementation->mRoleNames->removeall(); + mImplementation->mRoleNames->setCurrentByID(LLUUID::null); + + if(!mPendingRoleDataUpdate && !mPendingMemberDataUpdate) { - LLScrollListItem* item = *iter; - if (item->getUUID() == id) - { - already_in_list = true; - break; - } + ////////////////////////////////////////////////////////////////////////// + // Add role names + addRoleNames(); + //////////////////////////////////////////////////////////////////////////// + mImplementation->mRoleNames->setCurrentByID(store_selected_role); } - if (already_in_list) + else { - continue; + mImplementation->mRoleNames->add(mImplementation->mLoadingText, LLUUID::null, ADD_BOTTOM); } + + } +} + +BOOL LLPanelGroupInvite::postBuild() +{ + BOOL recurse = TRUE; - //add the name to the names list - LLSD row; - row["id"] = id; - row["columns"][0]["value"] = name; + mImplementation->mLoadingText = getString("loading"); + mImplementation->mRoleNames = getChild("role_name", + recurse); + mImplementation->mGroupName = getChild("group_name_text", recurse); + mImplementation->mBulkAgentList = getChild("invitee_list", recurse); + if ( mImplementation->mBulkAgentList ) + { + mImplementation->mBulkAgentList->setCommitOnSelectionChange(TRUE); + mImplementation->mBulkAgentList->setCommitCallback(LLPanelGroupBulkImpl::callbackSelect, mImplementation); + } - mInvitees->addElement(row); + LLButton* button = getChild("add_button", recurse); + if ( button ) + { + // default to opening avatarpicker automatically + // (*impl::callbackClickAdd)((void*)this); + button->setClickedCallback(LLPanelGroupBulkImpl::callbackClickAdd, this); } + + mImplementation->mRemoveButton = + getChild("remove_button", recurse); + if ( mImplementation->mRemoveButton ) + { + mImplementation->mRemoveButton->setClickedCallback(LLPanelGroupBulkImpl::callbackClickRemove, mImplementation); + mImplementation->mRemoveButton->setEnabled(FALSE); + } + + mImplementation->mOKButton = getChild("invite_button", recurse); + if ( mImplementation->mOKButton ) + { + mImplementation->mOKButton->setClickedCallback(LLPanelGroupInvite::callbackClickSubmit, this); + mImplementation->mOKButton->setEnabled(FALSE); + } + + button = getChild("cancel_button", recurse); + if ( button ) + { + button->setClickedCallback(LLPanelGroupBulkImpl::callbackClickCancel, mImplementation); + } + + mImplementation->mOwnerWarning = getString("confirm_invite_owner_str"); + mImplementation->mAlreadyInGroup = getString("already_in_group"); + mImplementation->mTooManySelected = getString("invite_selection_too_large"); + + update(); + + return (mImplementation->mRoleNames && + mImplementation->mBulkAgentList && + mImplementation->mRemoveButton); +} + +void LLPanelGroupInvite::callbackClickSubmit(void* userdata) +{ + LLPanelGroupInvite* selfp = (LLPanelGroupInvite*)userdata; + + if(selfp) + selfp->submit(); } -void LLPanelGroupInvite::impl::submitInvitations() +void LLPanelGroupInvite::submit() { std::map role_member_pairs; - LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID); + LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mImplementation->mGroupID); // Default to everyone role. LLUUID role_id = LLUUID::null; - if (mRoleNames) + if (mImplementation->mRoleNames) { - role_id = mRoleNames->getCurrentID(); - + role_id = mImplementation->mRoleNames->getCurrentID(); + + //LLUUID t_ownerUUID = gdatap->mOwnerRole; + //bool t_confirmInvite = mImplementation->mConfirmedOwnerInvite; + // owner role: display confirmation and wait for callback - if ((role_id == gdatap->mOwnerRole) && (!mConfirmedOwnerInvite)) + if ((role_id == gdatap->mOwnerRole) && (!mImplementation->mConfirmedOwnerInvite)) { LLSD args; - args["MESSAGE"] = mOwnerWarning; - LLNotificationsUtil::add("GenericAlertYesCancel", args, LLSD(), boost::bind(&LLPanelGroupInvite::impl::inviteOwnerCallback, this, _1, _2)); + args["MESSAGE"] = mImplementation->mOwnerWarning; + LLNotificationsUtil::add( "GenericAlertYesCancel", + args, + LLSD(), + boost::bind(invite_owner_callback, + this->getHandle(), + _1, _2)); return; // we'll be called again if user confirms } } bool already_in_group = false; //loop over the users - std::vector items = mInvitees->getAllData(); + std::vector items = mImplementation->mBulkAgentList->getAllData(); for (std::vector::iterator iter = items.begin(); - iter != items.end(); ++iter) + iter != items.end(); ++iter) { LLScrollListItem* item = *iter; - if(LLGroupActions::isAvatarMemberOfGroup(mGroupID, item->getUUID())) + if(LLGroupActions::isAvatarMemberOfGroup(mImplementation->mGroupID, item->getUUID())) { already_in_group = true; continue; } role_member_pairs[item->getUUID()] = role_id; } - + const S32 MAX_GROUP_INVITES = 100; // Max invites per request. 100 to match server cap. if (role_member_pairs.size() > MAX_GROUP_INVITES) { // Fail! LLSD msg; - msg["MESSAGE"] = mTooManySelected; + msg["MESSAGE"] = mImplementation->mTooManySelected; LLNotificationsUtil::add("GenericAlert", msg); - (*mCloseCallback)(mCloseCallbackUserData); + (*(mImplementation->mCloseCallback))(mImplementation->mCloseCallbackUserData); return; } - LLGroupMgr::getInstance()->sendGroupMemberInvites(mGroupID, role_member_pairs); - + LLGroupMgr::getInstance()->sendGroupMemberInvites(mImplementation->mGroupID, role_member_pairs); + if(already_in_group) { LLSD msg; - msg["MESSAGE"] = mAlreadyInGroup; + msg["MESSAGE"] = mImplementation->mAlreadyInGroup; LLNotificationsUtil::add("GenericAlert", msg); } //then close - (*mCloseCallback)(mCloseCallbackUserData); + (*(mImplementation->mCloseCallback))(mImplementation->mCloseCallbackUserData); } -bool LLPanelGroupInvite::impl::inviteOwnerCallback(const LLSD& notification, const LLSD& response) +void LLPanelGroupInvite::addRoleNames() { - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - - switch(option) - { - case 0: - // user confirmed that they really want a new group owner - mConfirmedOwnerInvite = true; - submitInvitations(); - break; - case 1: - // fall through - default: - break; - } - return false; -} - + LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mImplementation->mGroupID); - -void LLPanelGroupInvite::impl::addRoleNames(LLGroupMgrGroupData* gdatap) -{ - LLGroupMgrGroupData::member_list_t::iterator agent_iter = - gdatap->mMembers.find(gAgent.getID()); + LLGroupMgrGroupData::member_list_t::iterator agent_iter = gdatap->mMembers.find(gAgent.getID()); //get the member data for the agent if it exists if ( agent_iter != gdatap->mMembers.end() ) @@ -251,7 +266,7 @@ void LLPanelGroupInvite::impl::addRoleNames(LLGroupMgrGroupData* gdatap) //loop over the agent's roles in the group //then add those roles to the list of roles that the agent //can invite people to be - if ( member_data && mRoleNames) + if ( member_data && mImplementation->mRoleNames) { //if the user is the owner then we add //all of the roles in the group @@ -261,10 +276,10 @@ void LLPanelGroupInvite::impl::addRoleNames(LLGroupMgrGroupData* gdatap) //we add every role the user is in //else we just add to everyone bool is_owner = member_data->isInRole(gdatap->mOwnerRole); - bool can_assign_any = gAgent.hasPowerInGroup(mGroupID, - GP_ROLE_ASSIGN_MEMBER); - bool can_assign_limited = gAgent.hasPowerInGroup(mGroupID, - GP_ROLE_ASSIGN_MEMBER_LIMITED); + bool can_assign_any = gAgent.hasPowerInGroup(mImplementation->mGroupID, + GP_ROLE_ASSIGN_MEMBER); + bool can_assign_limited = gAgent.hasPowerInGroup(mImplementation->mGroupID, + GP_ROLE_ASSIGN_MEMBER_LIMITED); LLGroupMgrGroupData::role_list_t::iterator rit = gdatap->mRoles.begin(); LLGroupMgrGroupData::role_list_t::iterator end = gdatap->mRoles.end(); @@ -279,394 +294,18 @@ void LLPanelGroupInvite::impl::addRoleNames(LLGroupMgrGroupData* gdatap) // Owners can add any role. if ( is_owner // Even 'can_assign_any' can't add owner role. - || (can_assign_any && role_id != gdatap->mOwnerRole) + || (can_assign_any && role_id != gdatap->mOwnerRole) // Add all roles user is in - || (can_assign_limited && member_data->isInRole(role_id)) + || (can_assign_limited && member_data->isInRole(role_id)) // Everyone role. - || role_id == LLUUID::null ) + || role_id == LLUUID::null ) { - mRoleNames->add(rd.mRoleName, - role_id, - ADD_BOTTOM); + mImplementation->mRoleNames->add(rd.mRoleName, + role_id, + ADD_BOTTOM); } } } }//end if member data is not null }//end if agent is in the group } - -//static -void LLPanelGroupInvite::impl::callbackClickAdd(void* userdata) -{ - LLPanelGroupInvite* panelp = (LLPanelGroupInvite*) userdata; - - if ( panelp ) - { - //Right now this is hard coded with some knowledge that it is part - //of a floater since the avatar picker needs to be added as a dependent - //floater to the parent floater. - //Soon the avatar picker will be embedded into this panel - //instead of being it's own separate floater. But that is next week. - //This will do for now. -jwolk May 10, 2006 - LLView * button = panelp->findChild("add_button"); - LLFloater * root_floater = gFloaterView->getParentFloater(panelp); - LLFloaterAvatarPicker* picker = LLFloaterAvatarPicker::show( - boost::bind(impl::callbackAddUsers, _1, panelp->mImplementation), TRUE, FALSE, FALSE, root_floater->getName(), button); - if (picker) - { - root_floater->addDependentFloater(picker); - } - } -} - -//static -void LLPanelGroupInvite::impl::callbackClickRemove(void* userdata) -{ - impl* selfp = (impl*) userdata; - - if ( selfp ) selfp->handleRemove(); -} - -void LLPanelGroupInvite::impl::handleRemove() -{ - // Check if there is anything selected. - std::vector selection = - mInvitees->getAllSelected(); - if (selection.empty()) return; - - // Remove all selected invitees. - mInvitees->deleteSelectedItems(); - mRemoveButton->setEnabled(FALSE); -} - -// static -void LLPanelGroupInvite::impl::callbackSelect( - LLUICtrl* ctrl, void* userdata) -{ - impl* selfp = (impl*) userdata; - if ( selfp ) selfp->handleSelection(); -} - -void LLPanelGroupInvite::impl::handleSelection() -{ - // Check if there is anything selected. - std::vector selection = - mInvitees->getAllSelected(); - if (selection.empty()) - { - mRemoveButton->setEnabled(FALSE); - } - else - { - mRemoveButton->setEnabled(TRUE); - } -} - -void LLPanelGroupInvite::impl::callbackClickCancel(void* userdata) -{ - impl* selfp = (impl*) userdata; - - if ( selfp ) - { - (*(selfp->mCloseCallback))(selfp->mCloseCallbackUserData); - } -} - -void LLPanelGroupInvite::impl::callbackClickOK(void* userdata) -{ - impl* selfp = (impl*) userdata; - - if ( selfp ) selfp->submitInvitations(); -} - - - -//static -void LLPanelGroupInvite::impl::callbackAddUsers(const uuid_vec_t& agent_ids, void* user_data) -{ - std::vector names; - for (S32 i = 0; i < (S32)agent_ids.size(); i++) - { - LLAvatarName av_name; - if (LLAvatarNameCache::get(agent_ids[i], &av_name)) - { - LLPanelGroupInvite::impl::onAvatarNameCache(agent_ids[i], av_name, user_data); - } - else - { - impl* selfp = (impl*) user_data; - if (selfp) - { - if (selfp->mAvatarNameCacheConnection.connected()) - { - selfp->mAvatarNameCacheConnection.disconnect(); - } - // *TODO : Add a callback per avatar name being fetched. - selfp->mAvatarNameCacheConnection = LLAvatarNameCache::get(agent_ids[i],boost::bind(&LLPanelGroupInvite::impl::onAvatarNameCache, _1, _2, user_data)); - } - } - } - -} - -void LLPanelGroupInvite::impl::onAvatarNameCache(const LLUUID& agent_id, - const LLAvatarName& av_name, - void* user_data) -{ - impl* selfp = (impl*) user_data; - - if (selfp) - { - if (selfp->mAvatarNameCacheConnection.connected()) - { - selfp->mAvatarNameCacheConnection.disconnect(); - } - std::vector names; - uuid_vec_t agent_ids; - agent_ids.push_back(agent_id); - names.push_back(av_name.getCompleteName()); - - selfp->addUsers(names, agent_ids); - } -} - - -LLPanelGroupInvite::LLPanelGroupInvite(const LLUUID& group_id) - : LLPanel(), - mImplementation(new impl(group_id)), - mPendingUpdate(FALSE) -{ - // Pass on construction of this panel to the control factory. - buildFromFile( "panel_group_invite.xml"); -} - -LLPanelGroupInvite::~LLPanelGroupInvite() -{ - delete mImplementation; -} - -void LLPanelGroupInvite::setCloseCallback(void (*close_callback)(void*), - void* data) -{ - mImplementation->mCloseCallback = close_callback; - mImplementation->mCloseCallbackUserData = data; -} - -void LLPanelGroupInvite::clear() -{ - mStoreSelected = LLUUID::null; - mImplementation->mInvitees->deleteAllItems(); - mImplementation->mRoleNames->clear(); - mImplementation->mRoleNames->removeall(); - mImplementation->mOKButton->setEnabled(FALSE); -} - -void LLPanelGroupInvite::addUsers(uuid_vec_t& agent_ids) -{ - std::vector names; - for (S32 i = 0; i < (S32)agent_ids.size(); i++) - { - std::string fullname; - LLUUID agent_id = agent_ids[i]; - LLViewerObject* dest = gObjectList.findObject(agent_id); - if(dest && dest->isAvatar()) - { - LLNameValue* nvfirst = dest->getNVPair("FirstName"); - LLNameValue* nvlast = dest->getNVPair("LastName"); - if(nvfirst && nvlast) - { - fullname = LLCacheName::buildFullName( - nvfirst->getString(), nvlast->getString()); - - } - if (!fullname.empty()) - { - names.push_back(fullname); - } - else - { - llwarns << "llPanelGroupInvite: Selected avatar has no name: " << dest->getID() << llendl; - names.push_back("(Unknown)"); - } - } - else - { - //looks like user try to invite offline friend - //for offline avatar_id gObjectList.findObject() will return null - //so we need to do this additional search in avatar tracker, see EXT-4732 - if (LLAvatarTracker::instance().isBuddy(agent_id)) - { - LLAvatarName av_name; - if (!LLAvatarNameCache::get(agent_id, &av_name)) - { - // actually it should happen, just in case - //LLAvatarNameCache::get(LLUUID(agent_id), boost::bind(&LLPanelGroupInvite::addUserCallback, this, _1, _2)); - // for this special case! - //when there is no cached name we should remove resident from agent_ids list to avoid breaking of sequence - // removed id will be added in callback - agent_ids.erase(agent_ids.begin() + i); - } - else - { - names.push_back(av_name.getAccountName()); - } - } - } - } - mImplementation->addUsers(names, agent_ids); -} - -void LLPanelGroupInvite::addUserCallback(const LLUUID& id, const LLAvatarName& av_name) -{ - std::vector names; - uuid_vec_t agent_ids; - agent_ids.push_back(id); - names.push_back(av_name.getAccountName()); - - mImplementation->addUsers(names, agent_ids); -} - -void LLPanelGroupInvite::draw() -{ - LLPanel::draw(); - if (mPendingUpdate) - { - updateLists(); - } -} - -void LLPanelGroupInvite::update() -{ - mPendingUpdate = FALSE; - if (mImplementation->mGroupName) - { - mImplementation->mGroupName->setText(mImplementation->mLoadingText); - } - if ( mImplementation->mRoleNames ) - { - mStoreSelected = mImplementation->mRoleNames->getCurrentID(); - mImplementation->mRoleNames->clear(); - mImplementation->mRoleNames->removeall(); - mImplementation->mRoleNames->add(mImplementation->mLoadingText, LLUUID::null, ADD_BOTTOM); - mImplementation->mRoleNames->setCurrentByID(LLUUID::null); - } - - updateLists(); -} - -void LLPanelGroupInvite::updateLists() -{ - LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mImplementation->mGroupID); - bool waiting = false; - - if (gdatap) - { - if (gdatap->isGroupPropertiesDataComplete()) - { - if (mImplementation->mGroupName) - { - mImplementation->mGroupName->setText(gdatap->mName); - } - } - else - { - waiting = true; - } - if (gdatap->isRoleDataComplete() && gdatap->isMemberDataComplete()) - { - if ( mImplementation->mRoleNames ) - { - mImplementation->mRoleNames->clear(); - mImplementation->mRoleNames->removeall(); - - //add the role names and select the everybody role by default - mImplementation->addRoleNames(gdatap); - mImplementation->mRoleNames->setCurrentByID(mStoreSelected); - } - } - else - { - waiting = true; - } - } - else - { - waiting = true; - } - - if (waiting) - { - if (!mPendingUpdate) - { - LLGroupMgr::getInstance()->sendGroupPropertiesRequest(mImplementation->mGroupID); - LLGroupMgr::getInstance()->sendGroupRoleDataRequest(mImplementation->mGroupID); - LLGroupMgr::getInstance()->sendCapGroupMembersRequest(mImplementation->mGroupID); - } - mPendingUpdate = TRUE; - } - else - { - mPendingUpdate = FALSE; - if (mImplementation->mOKButton && mImplementation->mRoleNames->getItemCount()) - { - mImplementation->mOKButton->setEnabled(TRUE); - } - } -} - -BOOL LLPanelGroupInvite::postBuild() -{ - BOOL recurse = TRUE; - - mImplementation->mLoadingText = getString("loading"); - mImplementation->mRoleNames = getChild("role_name", - recurse); - mImplementation->mGroupName = getChild("group_name_text", recurse); - mImplementation->mInvitees = - getChild("invitee_list", recurse); - if ( mImplementation->mInvitees ) - { - mImplementation->mInvitees->setCommitOnSelectionChange(TRUE); - mImplementation->mInvitees->setCommitCallback(impl::callbackSelect, mImplementation); - } - - LLButton* button = getChild("add_button", recurse); - if ( button ) - { - // default to opening avatarpicker automatically - // (*impl::callbackClickAdd)((void*)this); - button->setClickedCallback(impl::callbackClickAdd, this); - } - - mImplementation->mRemoveButton = - getChild("remove_button", recurse); - if ( mImplementation->mRemoveButton ) - { - mImplementation->mRemoveButton->setClickedCallback(impl::callbackClickRemove, mImplementation); - mImplementation->mRemoveButton->setEnabled(FALSE); - } - - mImplementation->mOKButton = - getChild("ok_button", recurse); - if ( mImplementation->mOKButton ) - { - mImplementation->mOKButton->setClickedCallback(impl::callbackClickOK, mImplementation); - mImplementation->mOKButton->setEnabled(FALSE); - } - - button = getChild("cancel_button", recurse); - if ( button ) - { - button->setClickedCallback(impl::callbackClickCancel, mImplementation); - } - - mImplementation->mOwnerWarning = getString("confirm_invite_owner_str"); - mImplementation->mAlreadyInGroup = getString("already_in_group"); - mImplementation->mTooManySelected = getString("invite_selection_too_large"); - - update(); - - return (mImplementation->mRoleNames && - mImplementation->mInvitees && - mImplementation->mRemoveButton); -} -- cgit v1.3 From 1299f6d63fbe313329e6e5ced7be797e2a23d6a7 Mon Sep 17 00:00:00 2001 From: Baker Linden Date: Fri, 30 Aug 2013 16:38:25 -0700 Subject: - Got all major functionality working - Changed PUT and DEL to POST which accepts an enum for a create or delete --- indra/newview/llgroupmgr.cpp | 43 ++++++++--------- indra/newview/llgroupmgr.h | 21 +++++--- indra/newview/llpanelgroupbulkban.cpp | 2 +- indra/newview/llpanelgroupinvite.cpp | 3 -- indra/newview/llpanelgrouproles.cpp | 90 ++++++++++++++++++++--------------- indra/newview/llpanelgrouproles.h | 4 +- 6 files changed, 88 insertions(+), 75 deletions(-) (limited to 'indra/newview/llpanelgroupinvite.cpp') diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp index 0d4b678019..bfdb8588e4 100755 --- a/indra/newview/llgroupmgr.cpp +++ b/indra/newview/llgroupmgr.cpp @@ -235,8 +235,7 @@ LLGroupMgrGroupData::LLGroupMgrGroupData(const LLUUID& id) : mRoleDataComplete(false), mRoleMemberDataComplete(false), mGroupPropertiesDataComplete(false), - mGroupBanStatus(STATUS_INIT), - mGroupBanDataComplete(false), + mGroupBanStatus(LLGroupMgrGroupData::STATUS_INIT), mPendingRoleMemberRequest(false), mAccessTime(0.0f) { @@ -748,13 +747,14 @@ void LLGroupMgrGroupData::cancelRoleChanges() void LLGroupMgrGroupData::createBanEntry(const LLUUID& ban_id, const LLGroupBanData& ban_data) { mBanList[ban_id] = ban_data; + // Refresh the list } -bool LLGroupMgrGroupData::removeBanEntry(const LLUUID& ban_id) +void LLGroupMgrGroupData::removeBanEntry(const LLUUID& ban_id) { // Once we get this hooked up to the backend, we want to confirm the create or delete worked. mBanList.erase(ban_id); - return true; + // Refresh the list } @@ -1880,7 +1880,10 @@ void GroupBanDataResponder::result(const LLSD& content) LLGroupMgr::processGroupBanRequest(content); } -void LLGroupMgr::sendGroupBanRequest(EBanRequestType request_type, const LLUUID& group_id, const std::vector ban_list /* = std::vector() */) +void LLGroupMgr::sendGroupBanRequest( EBanRequestType request_type, + const LLUUID& group_id, + EBanRequestAction ban_action, /* = BAN_NO_ACTION */ + const std::vector ban_list) /* = std::vector() */ { LLViewerRegion* currentRegion = gAgent.getRegion(); if(!currentRegion) @@ -1902,39 +1905,31 @@ void LLGroupMgr::sendGroupBanRequest(EBanRequestType request_type, const LLUUID& { return; } + cap_url += "?group_id=" + group_id.asString(); - LLHTTPClient::ResponderPtr grp_ban_responder = new GroupBanDataResponder(); - // PUT to our service. Add a body containing the group_id and list of agents to ban. - LLSD ban_ids = LLSD::emptyMap(); - ban_ids["group_id"] = group_id; + LLSD body = LLSD::emptyMap(); + body["ban_action"] = ban_action; // Add our list of potential banned agents to the list - ban_ids["ban_ids"] = LLSD::emptyArray(); + body["ban_ids"] = LLSD::emptyArray(); LLSD ban_entry; - std::vector::const_iterator iter = ban_list.cbegin(); + + uuid_vec_t::const_iterator iter = ban_list.begin(); for(;iter != ban_list.end(); ++iter) { ban_entry = (*iter); - ban_ids["ban_ids"].append(ban_entry); + body["ban_ids"].append(ban_entry); } + LLHTTPClient::ResponderPtr grp_ban_responder = new GroupBanDataResponder(); switch(request_type) { case REQUEST_GET: - cap_url += "?group_id=" + group_id.asString(); LLHTTPClient::get(cap_url, grp_ban_responder); break; - case REQUEST_PUT: - // BAKER TODO: Figure out which 'body' is correct. - LLHTTPClient::put(cap_url, ban_ids, grp_ban_responder, LLSD(), 60); - break; - case REQUEST_DEL: - LLHTTPClient::del(cap_url, grp_ban_responder, ban_ids, 60); + case REQUEST_POST: + LLHTTPClient::post(cap_url, body, grp_ban_responder); break; } - - LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(group_id); - if (gdatap) - gdatap->setGroupBanStatus(LLGroupMgrGroupData::STATUS_REQUESTING); } @@ -1953,7 +1948,7 @@ void LLGroupMgr::processGroupBanRequest(const LLSD& content) if (!gdatap) return; - LLSD banlist = LLSD::emptyMap(); + //LLSD banlist = LLSD::emptyMap(); LLSD::map_const_iterator i = content["ban_list"].beginMap(); diff --git a/indra/newview/llgroupmgr.h b/indra/newview/llgroupmgr.h index 876883e87e..49e354a26c 100755 --- a/indra/newview/llgroupmgr.h +++ b/indra/newview/llgroupmgr.h @@ -215,7 +215,7 @@ friend class LLGroupMgr; public: enum EGroupDataStatus { - STATUS_NONE, + STATUS_INIT, STATUS_REQUESTING, STATUS_COMPLETE }; @@ -250,7 +250,6 @@ public: bool isRoleDataComplete() { return mRoleDataComplete; } bool isRoleMemberDataComplete() { return mRoleMemberDataComplete; } bool isGroupPropertiesDataComplete() { return mGroupPropertiesDataComplete; } - bool isGroupBanDataComplete() { return mGroupBanDataComplete; } EGroupDataStatus getGroupBanStatus() { return mGroupBanStatus; } void setGroupBanStatus(EGroupDataStatus status) { mGroupBanStatus = status; } @@ -269,7 +268,7 @@ public: const LLGroupBanData& getBanEntry(const LLUUID& ban_id) { return mBanList[ban_id]; } void createBanEntry(const LLUUID& ban_id, const LLGroupBanData& ban_data = LLGroupBanData()); - bool removeBanEntry(const LLUUID& ban_id); + void removeBanEntry(const LLUUID& ban_id); @@ -322,8 +321,6 @@ private: bool mGroupPropertiesDataComplete; EGroupDataStatus mGroupBanStatus; - bool mGroupBanDataComplete; - bool mGroupBanDataPending; bool mPendingRoleMemberRequest; F32 mAccessTime; @@ -356,10 +353,18 @@ public: enum EBanRequestType { REQUEST_GET = 0, + REQUEST_POST, REQUEST_PUT, REQUEST_DEL }; + enum EBanRequestAction + { + BAN_NO_ACTION = 0, + BAN_CREATE = 1, + BAN_DELETE = 2 + }; + public: LLGroupMgr(); ~LLGroupMgr(); @@ -394,7 +399,11 @@ public: static void sendGroupMemberEjects(const LLUUID& group_id, uuid_vec_t& member_ids); // BAKER - Group Ban - static void sendGroupBanRequest(EBanRequestType request_type, const LLUUID& group_id, const std::vector ban_list = std::vector()); + static void sendGroupBanRequest(EBanRequestType request_type, + const LLUUID& group_id, + EBanRequestAction ban_action = BAN_NO_ACTION, + const uuid_vec_t ban_list = uuid_vec_t()); + static void processGroupBanRequest(const LLSD& content); // BAKER diff --git a/indra/newview/llpanelgroupbulkban.cpp b/indra/newview/llpanelgroupbulkban.cpp index 57bab0c813..d6bb669275 100644 --- a/indra/newview/llpanelgroupbulkban.cpp +++ b/indra/newview/llpanelgroupbulkban.cpp @@ -141,7 +141,7 @@ void LLPanelGroupBulkBan::submit() return; } - LLGroupMgr::getInstance()->sendGroupBanRequest(LLGroupMgr::REQUEST_PUT, mImplementation->mGroupID, banned_agent_list); + LLGroupMgr::getInstance()->sendGroupBanRequest(LLGroupMgr::REQUEST_POST, mImplementation->mGroupID, LLGroupMgr::BAN_CREATE, banned_agent_list); // BAKER TEMP: // For now, don't close, but clear the list. diff --git a/indra/newview/llpanelgroupinvite.cpp b/indra/newview/llpanelgroupinvite.cpp index c990584d22..43d94b36fc 100755 --- a/indra/newview/llpanelgroupinvite.cpp +++ b/indra/newview/llpanelgroupinvite.cpp @@ -48,9 +48,6 @@ #include "llviewerwindow.h" -// BAKER TODO: -// Figure out how to use LLHandle to make this safer -//bool invite_owner_callback(LLPanelGroupInvite panel, const LLSD& notification, const LLSD& response) bool invite_owner_callback(LLHandle panel_handle, const LLSD& notification, const LLSD& response) { LLPanelGroupInvite* panel = dynamic_cast(panel_handle.get()); diff --git a/indra/newview/llpanelgrouproles.cpp b/indra/newview/llpanelgrouproles.cpp index 8d7b3c38ee..f3cb9900fe 100755 --- a/indra/newview/llpanelgrouproles.cpp +++ b/indra/newview/llpanelgrouproles.cpp @@ -1763,18 +1763,20 @@ void LLPanelGroupMembersSubTab::handleBanMember() return; } + uuid_vec_t ban_ids; std::vector::iterator itor; for(itor = selection.begin(); itor != selection.end(); ++itor) { LLUUID ban_id = (*itor)->getUUID(); + ban_ids.push_back(ban_id); + LLGroupBanData ban_data; - - // DEL to People API somewhere in this chain... gdatap->createBanEntry(ban_id, ban_data); - mMembersList->removeNameItem(ban_id); - } + LLGroupMgr::getInstance()->sendGroupBanRequest(LLGroupMgr::REQUEST_POST, mGroupID, LLGroupMgr::BAN_CREATE, ban_ids); + // Will this work? + handleEjectMembers(); } @@ -2721,8 +2723,7 @@ LLPanelGroupBanListSubTab::LLPanelGroupBanListSubTab() : LLPanelGroupSubTab(), mBanList(NULL), mCreateBanButton(NULL), - mDeleteBanButton(NULL), - mUpdateBanList(true) + mDeleteBanButton(NULL) { LL_INFOS("BAKER") << "[BAKER] LLPanelGroupBanListSubTab::ctor()" << LL_ENDL; } @@ -2763,6 +2764,13 @@ BOOL LLPanelGroupBanListSubTab::postBuildSubTab(LLView* root) setFooterEnabled(FALSE); + LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID); + if(gdatap && (gdatap->getGroupBanStatus() == LLGroupMgrGroupData::STATUS_INIT)) + { + LLGroupMgr::getInstance()->sendGroupBanRequest(LLGroupMgr::REQUEST_GET, mGroupID); + gdatap->setGroupBanStatus(LLGroupMgrGroupData::STATUS_REQUESTING); + } + return TRUE; } @@ -2809,8 +2817,8 @@ void LLPanelGroupBanListSubTab::update(LLGroupChange gc) { LL_INFOS("BAKER") << "[BAKER] LLPanelGroupBanListSubTab::update()" << LL_ENDL; - if (gc != GC_ALL || gc != GC_BANLIST) - return; + //if (gc != GC_ALL && gc != GC_BANLIST) + // return; LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID); if(!gdatap) @@ -2826,6 +2834,7 @@ void LLPanelGroupBanListSubTab::update(LLGroupChange gc) // Request our ban list! case LLGroupMgrGroupData::STATUS_INIT: LLGroupMgr::getInstance()->sendGroupBanRequest(LLGroupMgr::REQUEST_GET, mGroupID); + gdatap->setGroupBanStatus(LLGroupMgrGroupData::STATUS_REQUESTING); break; // Already have a request out -- don't bother sending another one @@ -2839,31 +2848,38 @@ void LLPanelGroupBanListSubTab::update(LLGroupChange gc) // [SOMETHING CHANGED] - Don't panic! Just repopulate the ban list! case LLGroupMgrGroupData::STATUS_COMPLETE: populateBanList(); - - break; } } +void LLPanelGroupBanListSubTab::draw() +{ + LLPanelGroupSubTab::draw(); + + // if(mPendingBanUpdate) + // populateBanList(); +} void LLPanelGroupBanListSubTab::populateBanList() { - //if(gdatap->getGroupBanStatus() == ) - + LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID); + if(!gdatap) + { + LL_INFOS("BAKER") << "[BAKER] No group data!" << LL_ENDL; + return; + } + if(gdatap->getGroupBanStatus() != LLGroupMgrGroupData::STATUS_COMPLETE) + return; -// mBanList->deleteAllItems(); -// LLGroupMgr::getInstance()->sendGroupBanRequest(LLGroupMgr::REQUEST_GET, mGroupID); -// -// std::map::const_iterator entry = gdatap->mBanList.begin(); -// for(; entry != gdatap->mBanList.end(); entry++) -// { -// LLNameListCtrl::NameItem ban_entry; -// ban_entry.value = entry->first; -// mBanList->addNameItemRow(ban_entry); -// } - - mUpdateBanList = false; + mBanList->deleteAllItems(); + std::map::const_iterator entry = gdatap->mBanList.begin(); + for(; entry != gdatap->mBanList.end(); entry++) + { + LLNameListCtrl::NameItem ban_entry; + ban_entry.value = entry->first; + mBanList->addNameItemRow(ban_entry); + } } @@ -2885,7 +2901,7 @@ void LLPanelGroupBanListSubTab::handleBanEntrySelect() // BAKER TODO: -- MOVE TO SELECT BAN ENTRY // Make sure only authorized people have access to adding / deleting bans //if (gAgent.hasPowerInGroup(mGroupID, GP_GROUP_BAN_ACCESS)) - mCreateBanButton->setEnabled(TRUE); + mCreateBanButton->setEnabled(TRUE); // Check if the agent has the ability to unban this person //if (gAgent.hasPowerInGroup(mGroupID, GP_GROUP_BAN_ACCESS)) @@ -3000,26 +3016,22 @@ void LLPanelGroupBanListSubTab::handleDeleteBanEntry() } } + std::vector ban_ids; std::vector::iterator itor; for(itor = selection.begin(); itor != selection.end(); ++itor) { - // STUB - // Attempt to remove entry from the database - // If there was a problem with the delete, don't remove it from the list yet! - // Otherwise, remove it from our local list. - // - LLUUID ban_id = (*itor)->getUUID(); - if(gdatap->removeBanEntry(ban_id)) - { - mBanList->removeNameItem(ban_id); - // Removing an item removes the selection, we shouldn't be able to click - // the button anymore until we reselect another entry. - mDeleteBanButton->setEnabled(FALSE); - } + ban_ids.push_back(ban_id); + + //gdatap->removeBanEntry(ban_id); + //mBanList->removeNameItem(ban_id); + + // Removing an item removes the selection, we shouldn't be able to click + // the button anymore until we reselect another entry. + mDeleteBanButton->setEnabled(FALSE); } - + LLGroupMgr::getInstance()->sendGroupBanRequest(LLGroupMgr::REQUEST_POST, mGroupID, LLGroupMgr::BAN_DELETE, ban_ids); } diff --git a/indra/newview/llpanelgrouproles.h b/indra/newview/llpanelgrouproles.h index 1695097fc5..01c1d8c16d 100755 --- a/indra/newview/llpanelgrouproles.h +++ b/indra/newview/llpanelgrouproles.h @@ -335,6 +335,8 @@ public: // Triggered when group information changes in the group manager. virtual void update(LLGroupChange gc); + // + virtual void draw(); static void onBanEntrySelect(LLUICtrl* ctrl, void* user_data); void handleBanEntrySelect(); @@ -358,8 +360,6 @@ protected: LLNameListCtrl* mBanList; LLButton* mCreateBanButton; LLButton* mDeleteBanButton; - - bool mUpdateBanList; }; -- cgit v1.3 From 8bf4760552b61808d403885b6f9d562b1b8f7e6c Mon Sep 17 00:00:00 2001 From: Baker Linden Date: Tue, 1 Oct 2013 15:58:39 -0700 Subject: Hand-merge of some viewer-release code --- indra/newview/llpanelgroupbulk.cpp | 36 +++++++++++++++++++++--------------- indra/newview/llpanelgroupbulkimpl.h | 23 +++++++++++++++-------- indra/newview/llpanelgroupinvite.cpp | 5 ++--- 3 files changed, 38 insertions(+), 26 deletions(-) (limited to 'indra/newview/llpanelgroupinvite.cpp') diff --git a/indra/newview/llpanelgroupbulk.cpp b/indra/newview/llpanelgroupbulk.cpp index ed05a5c7d1..86ac1867df 100644 --- a/indra/newview/llpanelgroupbulk.cpp +++ b/indra/newview/llpanelgroupbulk.cpp @@ -172,6 +172,12 @@ void LLPanelGroupBulkImpl::handleRemove() if (selection.empty()) return; + std::vector::iterator iter; + for(iter = selection.begin(); iter != selection.end(); ++iter) + { + mInviteeIDs.erase((*iter)->getUUID()); + } + mBulkAgentList->deleteSelectedItems(); mRemoveButton->setEnabled(FALSE); @@ -195,26 +201,23 @@ void LLPanelGroupBulkImpl::addUsers(const std::vector& names, const { std::string name; LLUUID id; + + if(names.size() + mInviteeIDs.size() > MAX_GROUP_INVITES) + { + // Fail! Show a warning and don't add any names. + LLSD msg; + msg["MESSAGE"] = mTooManySelected; + LLNotificationsUtil::add("GenericAlert", msg); + return; + } + for (S32 i = 0; i < (S32)names.size(); ++i) { name = names[i]; id = agent_ids[i]; - // Make sure this agent isn't already in the list. - bool already_in_list = false; - std::vector items = mBulkAgentList->getAllData(); - std::vector::iterator iter = items.begin(); - for (; iter != items.end(); ++iter) - { - LLScrollListItem* item = *iter; - if (item->getUUID() == id) - { - already_in_list = true; - break; - } - } - if (already_in_list) + if(mInviteeIDs.find(id) != mInviteeIDs.end()) { continue; } @@ -225,7 +228,8 @@ void LLPanelGroupBulkImpl::addUsers(const std::vector& names, const row["columns"][0]["value"] = name; mBulkAgentList->addElement(row); - + mInviteeIDs.insert(id); + // We've successfully added someone to the list. if(mOKButton && !mOKButton->getEnabled()) mOKButton->setEnabled(TRUE); @@ -254,6 +258,8 @@ LLPanelGroupBulk::~LLPanelGroupBulk() void LLPanelGroupBulk::clear() { + mImplementation->mInviteeIDs.clear(); + if(mImplementation->mBulkAgentList) mImplementation->mBulkAgentList->deleteAllItems(); diff --git a/indra/newview/llpanelgroupbulkimpl.h b/indra/newview/llpanelgroupbulkimpl.h index 74da542eb8..3241c019de 100644 --- a/indra/newview/llpanelgroupbulkimpl.h +++ b/indra/newview/llpanelgroupbulkimpl.h @@ -1,6 +1,6 @@ /** * @file llpanelgroupbulkimpl.h -* @brief Header file for llpanelgroupbulkimpl +* @brief Class definition for implementation class of LLPanelGroupBulk * @author Baker@lindenlab.com * * $LicenseInfo:firstyear=2013&license=viewerlgpl$ @@ -35,6 +35,9 @@ class LLNameListCtrl; class LLTextBox; class LLComboBox; +////////////////////////////////////////////////////////////////////////// +// Implementation found in llpanelgroupbulk.cpp +////////////////////////////////////////////////////////////////////////// class LLPanelGroupBulkImpl { public: @@ -59,15 +62,19 @@ public: public: - LLUUID mGroupID; + static const S32 MAX_GROUP_INVITES = 100; // Max invites per request. 100 to match server cap. - LLNameListCtrl* mBulkAgentList; - LLButton* mOKButton; - LLButton* mRemoveButton; - LLTextBox* mGroupName; + LLUUID mGroupID; - std::string mLoadingText; - std::string mTooManySelected; + LLNameListCtrl* mBulkAgentList; + LLButton* mOKButton; + LLButton* mRemoveButton; + LLTextBox* mGroupName; + + std::string mLoadingText; + std::string mTooManySelected; + + std::set mInviteeIDs; void (*mCloseCallback)(void* data); void* mCloseCallbackUserData; diff --git a/indra/newview/llpanelgroupinvite.cpp b/indra/newview/llpanelgroupinvite.cpp index 43d94b36fc..19689e7f4b 100755 --- a/indra/newview/llpanelgroupinvite.cpp +++ b/indra/newview/llpanelgroupinvite.cpp @@ -80,7 +80,7 @@ LLPanelGroupInvite::LLPanelGroupInvite(const LLUUID& group_id) : LLPanelGroupBul void LLPanelGroupInvite::clear() { LLPanelGroupBulk::clear(); - + if(mImplementation->mRoleNames) { mImplementation->mRoleNames->clear(); @@ -225,8 +225,7 @@ void LLPanelGroupInvite::submit() role_member_pairs[item->getUUID()] = role_id; } - const S32 MAX_GROUP_INVITES = 100; // Max invites per request. 100 to match server cap. - if (role_member_pairs.size() > MAX_GROUP_INVITES) + if (role_member_pairs.size() > LLPanelGroupBulkImpl::MAX_GROUP_INVITES) { // Fail! LLSD msg; -- cgit v1.3 From 454c5ed631d15441dd50503ab457688fe0289867 Mon Sep 17 00:00:00 2001 From: Baker Linden Date: Thu, 13 Feb 2014 10:25:33 -0800 Subject: [MAINT-3721] - Viewer crash upon click invite - Fixed a crash that would happen when a resident attempts to invite someone into a group --- indra/newview/llpanelgroupinvite.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/newview/llpanelgroupinvite.cpp') diff --git a/indra/newview/llpanelgroupinvite.cpp b/indra/newview/llpanelgroupinvite.cpp index 19689e7f4b..a368baee48 100755 --- a/indra/newview/llpanelgroupinvite.cpp +++ b/indra/newview/llpanelgroupinvite.cpp @@ -251,6 +251,10 @@ void LLPanelGroupInvite::submit() void LLPanelGroupInvite::addRoleNames() { LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mImplementation->mGroupID); + if(!gdatap) + { + return; + } LLGroupMgrGroupData::member_list_t::iterator agent_iter = gdatap->mMembers.find(gAgent.getID()); -- cgit v1.3 From b0c1dd4790847364ebcab1cb1d4103500f64072e Mon Sep 17 00:00:00 2001 From: Baker Linden Date: Tue, 11 Mar 2014 16:19:49 -0700 Subject: - Added null checks in a couple places. --- indra/newview/llpanelgroupinvite.cpp | 5 +++++ indra/newview/llpanelgrouproles.cpp | 6 ++++++ 2 files changed, 11 insertions(+) (limited to 'indra/newview/llpanelgroupinvite.cpp') diff --git a/indra/newview/llpanelgroupinvite.cpp b/indra/newview/llpanelgroupinvite.cpp index a368baee48..48736be253 100755 --- a/indra/newview/llpanelgroupinvite.cpp +++ b/indra/newview/llpanelgroupinvite.cpp @@ -184,6 +184,11 @@ void LLPanelGroupInvite::submit() std::map role_member_pairs; LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mImplementation->mGroupID); + if(!gdatap) + { + LL_WARNS("Groups") << "Unable to get group data for group " << mImplementation->mGroupID << LL_ENDL; + return; + } // Default to everyone role. LLUUID role_id = LLUUID::null; diff --git a/indra/newview/llpanelgrouproles.cpp b/indra/newview/llpanelgrouproles.cpp index 06932a7ec5..b1ea8b7e57 100755 --- a/indra/newview/llpanelgrouproles.cpp +++ b/indra/newview/llpanelgrouproles.cpp @@ -1903,6 +1903,12 @@ bool LLPanelGroupRolesSubTab::needsApply(std::string& mesg) lldebugs << "LLPanelGroupRolesSubTab::needsApply()" << llendl; LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID); + if(!gdatap) + { + llwarns << "Unable to get group data for group " << mGroupID << llendl; + return; + } + return (mHasRoleChange // Text changed in current role || (gdatap && gdatap->pendingRoleChanges())); // Pending role changes in the group -- cgit v1.3 From a54e975b37426bd9c33d00067d171a285a7d6175 Mon Sep 17 00:00:00 2001 From: AndreyL ProductEngine Date: Thu, 15 May 2014 04:22:54 +0300 Subject: MAINT-3932 FIXED [vwr] "Owner" role is sometimes (always?) removed from group Invite floater. --- indra/newview/llpanelgroupinvite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llpanelgroupinvite.cpp') diff --git a/indra/newview/llpanelgroupinvite.cpp b/indra/newview/llpanelgroupinvite.cpp index 48736be253..f3833ed6e4 100755 --- a/indra/newview/llpanelgroupinvite.cpp +++ b/indra/newview/llpanelgroupinvite.cpp @@ -280,7 +280,7 @@ void LLPanelGroupInvite::addRoleNames() //else if they have the limited add to roles power //we add every role the user is in //else we just add to everyone - bool is_owner = member_data->isInRole(gdatap->mOwnerRole); + bool is_owner = member_data->isOwner(); bool can_assign_any = gAgent.hasPowerInGroup(mImplementation->mGroupID, GP_ROLE_ASSIGN_MEMBER); bool can_assign_limited = gAgent.hasPowerInGroup(mImplementation->mGroupID, -- cgit v1.3 From 7a3859dc48360156b85ff85104d4c81de003e8ac Mon Sep 17 00:00:00 2001 From: maksymsproductengine Date: Tue, 10 Jun 2014 20:11:30 +0300 Subject: Import llpanelgroupinvite from viewer_lion --- indra/newview/llpanelgroupinvite.cpp | 685 +++++++++++++++++++++++++++-------- indra/newview/llpanelgroupinvite.h | 29 +- 2 files changed, 543 insertions(+), 171 deletions(-) (limited to 'indra/newview/llpanelgroupinvite.cpp') diff --git a/indra/newview/llpanelgroupinvite.cpp b/indra/newview/llpanelgroupinvite.cpp index f3833ed6e4..a9a3c686a6 100755 --- a/indra/newview/llpanelgroupinvite.cpp +++ b/indra/newview/llpanelgroupinvite.cpp @@ -26,8 +26,6 @@ #include "llviewerprecompiledheaders.h" #include "llpanelgroupinvite.h" -#include "llpanelgroupbulk.h" -#include "llpanelgroupbulkimpl.h" #include "llagent.h" #include "llavatarnamecache.h" @@ -47,221 +45,203 @@ #include "lluictrlfactory.h" #include "llviewerwindow.h" - -bool invite_owner_callback(LLHandle panel_handle, const LLSD& notification, const LLSD& response) +class LLPanelGroupInvite::impl { - LLPanelGroupInvite* panel = dynamic_cast(panel_handle.get()); - if(!panel) - return false; - - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - switch(option) - { - case 0: - // user confirmed that they really want a new group owner - panel->mImplementation->mConfirmedOwnerInvite = true; - panel->submit(); - break; - case 1: - // fall through - default: - break; - } - return false; -} - - -LLPanelGroupInvite::LLPanelGroupInvite(const LLUUID& group_id) : LLPanelGroupBulk(group_id) +public: + impl(const LLUUID& group_id); + ~impl(); + + void addUsers(const std::vector& names, + const uuid_vec_t& agent_ids); + void submitInvitations(); + void addRoleNames(LLGroupMgrGroupData* gdatap); + void handleRemove(); + void handleSelection(); + + static void callbackClickCancel(void* userdata); + static void callbackClickOK(void* userdata); + static void callbackClickAdd(void* userdata); + static void callbackClickRemove(void* userdata); + static void callbackSelect(LLUICtrl* ctrl, void* userdata); + static void callbackAddUsers(const uuid_vec_t& agent_ids, + void* user_data); + + static void onAvatarNameCache(const LLUUID& agent_id, + const LLAvatarName& av_name, + void* user_data); + + bool inviteOwnerCallback(const LLSD& notification, const LLSD& response); + +public: + LLUUID mGroupID; + + std::string mLoadingText; + LLNameListCtrl *mInvitees; + LLComboBox *mRoleNames; + LLButton *mOKButton; + LLButton *mRemoveButton; + LLTextBox *mGroupName; + std::string mOwnerWarning; + std::string mAlreadyInGroup; + std::string mTooManySelected; + bool mConfirmedOwnerInvite; + std::set mInviteeIDs; + + void (*mCloseCallback)(void* data); + + void* mCloseCallbackUserData; + + boost::signals2::connection mAvatarNameCacheConnection; +}; + + +LLPanelGroupInvite::impl::impl(const LLUUID& group_id): + mGroupID( group_id ), + mLoadingText (), + mInvitees ( NULL ), + mRoleNames( NULL ), + mOKButton ( NULL ), + mRemoveButton( NULL ), + mGroupName( NULL ), + mConfirmedOwnerInvite( false ), + mCloseCallback( NULL ), + mCloseCallbackUserData( NULL ), + mAvatarNameCacheConnection() { - // Pass on construction of this panel to the control factory. - buildFromFile( "panel_group_invite.xml"); } -void LLPanelGroupInvite::clear() +LLPanelGroupInvite::impl::~impl() { - LLPanelGroupBulk::clear(); - - if(mImplementation->mRoleNames) + if (mAvatarNameCacheConnection.connected()) { - mImplementation->mRoleNames->clear(); - mImplementation->mRoleNames->removeall(); - mImplementation->mRoleNames->setCurrentByID(LLUUID::null); + mAvatarNameCacheConnection.disconnect(); } } -void LLPanelGroupInvite::update() -{ - LLPanelGroupBulk::update(); - - if(mImplementation->mRoleNames) - { - LLUUID store_selected_role = mImplementation->mRoleNames->getCurrentID(); - mImplementation->mRoleNames->clear(); - mImplementation->mRoleNames->removeall(); - mImplementation->mRoleNames->setCurrentByID(LLUUID::null); - - if(!mPendingRoleDataUpdate && !mPendingMemberDataUpdate) - { - ////////////////////////////////////////////////////////////////////////// - // Add role names - addRoleNames(); - //////////////////////////////////////////////////////////////////////////// - mImplementation->mRoleNames->setCurrentByID(store_selected_role); - } - else - { - mImplementation->mRoleNames->add(mImplementation->mLoadingText, LLUUID::null, ADD_BOTTOM); - } - - } -} +const S32 MAX_GROUP_INVITES = 100; // Max invites per request. 100 to match server cap. -BOOL LLPanelGroupInvite::postBuild() +void LLPanelGroupInvite::impl::addUsers(const std::vector& names, + const uuid_vec_t& agent_ids) { - BOOL recurse = TRUE; + std::string name; + LLUUID id; - mImplementation->mLoadingText = getString("loading"); - mImplementation->mRoleNames = getChild("role_name", - recurse); - mImplementation->mGroupName = getChild("group_name_text", recurse); - mImplementation->mBulkAgentList = getChild("invitee_list", recurse); - if ( mImplementation->mBulkAgentList ) + if (names.size() + mInviteeIDs.size() > MAX_GROUP_INVITES) { - mImplementation->mBulkAgentList->setCommitOnSelectionChange(TRUE); - mImplementation->mBulkAgentList->setCommitCallback(LLPanelGroupBulkImpl::callbackSelect, mImplementation); + // Fail! Show a warning and don't add any names. + LLSD msg; + msg["MESSAGE"] = mTooManySelected; + LLNotificationsUtil::add("GenericAlert", msg); + return; } - LLButton* button = getChild("add_button", recurse); - if ( button ) + for (S32 i = 0; i < (S32)names.size(); i++) { - // default to opening avatarpicker automatically - // (*impl::callbackClickAdd)((void*)this); - button->setClickedCallback(LLPanelGroupBulkImpl::callbackClickAdd, this); - } + name = names[i]; + id = agent_ids[i]; - mImplementation->mRemoveButton = - getChild("remove_button", recurse); - if ( mImplementation->mRemoveButton ) - { - mImplementation->mRemoveButton->setClickedCallback(LLPanelGroupBulkImpl::callbackClickRemove, mImplementation); - mImplementation->mRemoveButton->setEnabled(FALSE); - } + // Make sure this agent isn't already in the list. + if (mInviteeIDs.find(id) != mInviteeIDs.end()) + { + continue; + } - mImplementation->mOKButton = getChild("invite_button", recurse); - if ( mImplementation->mOKButton ) - { - mImplementation->mOKButton->setClickedCallback(LLPanelGroupInvite::callbackClickSubmit, this); - mImplementation->mOKButton->setEnabled(FALSE); - } + //add the name to the names list + LLSD row; + row["id"] = id; + row["columns"][0]["value"] = name; - button = getChild("cancel_button", recurse); - if ( button ) - { - button->setClickedCallback(LLPanelGroupBulkImpl::callbackClickCancel, mImplementation); + mInvitees->addElement(row); + mInviteeIDs.insert(id); } - - mImplementation->mOwnerWarning = getString("confirm_invite_owner_str"); - mImplementation->mAlreadyInGroup = getString("already_in_group"); - mImplementation->mTooManySelected = getString("invite_selection_too_large"); - - update(); - - return (mImplementation->mRoleNames && - mImplementation->mBulkAgentList && - mImplementation->mRemoveButton); -} - -void LLPanelGroupInvite::callbackClickSubmit(void* userdata) -{ - LLPanelGroupInvite* selfp = (LLPanelGroupInvite*)userdata; - - if(selfp) - selfp->submit(); } -void LLPanelGroupInvite::submit() +void LLPanelGroupInvite::impl::submitInvitations() { std::map role_member_pairs; - LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mImplementation->mGroupID); - if(!gdatap) - { - LL_WARNS("Groups") << "Unable to get group data for group " << mImplementation->mGroupID << LL_ENDL; - return; - } + LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID); // Default to everyone role. LLUUID role_id = LLUUID::null; - if (mImplementation->mRoleNames) + if (mRoleNames) { - role_id = mImplementation->mRoleNames->getCurrentID(); - - //LLUUID t_ownerUUID = gdatap->mOwnerRole; - //bool t_confirmInvite = mImplementation->mConfirmedOwnerInvite; - + role_id = mRoleNames->getCurrentID(); + // owner role: display confirmation and wait for callback - if ((role_id == gdatap->mOwnerRole) && (!mImplementation->mConfirmedOwnerInvite)) + if ((role_id == gdatap->mOwnerRole) && (!mConfirmedOwnerInvite)) { LLSD args; - args["MESSAGE"] = mImplementation->mOwnerWarning; - LLNotificationsUtil::add( "GenericAlertYesCancel", - args, - LLSD(), - boost::bind(invite_owner_callback, - this->getHandle(), - _1, _2)); + args["MESSAGE"] = mOwnerWarning; + LLNotificationsUtil::add("GenericAlertYesCancel", args, LLSD(), boost::bind(&LLPanelGroupInvite::impl::inviteOwnerCallback, this, _1, _2)); return; // we'll be called again if user confirms } } bool already_in_group = false; //loop over the users - std::vector items = mImplementation->mBulkAgentList->getAllData(); + std::vector items = mInvitees->getAllData(); for (std::vector::iterator iter = items.begin(); - iter != items.end(); ++iter) + iter != items.end(); ++iter) { LLScrollListItem* item = *iter; - if(LLGroupActions::isAvatarMemberOfGroup(mImplementation->mGroupID, item->getUUID())) + if(LLGroupActions::isAvatarMemberOfGroup(mGroupID, item->getUUID())) { already_in_group = true; continue; } role_member_pairs[item->getUUID()] = role_id; } - - if (role_member_pairs.size() > LLPanelGroupBulkImpl::MAX_GROUP_INVITES) + + if (role_member_pairs.size() > MAX_GROUP_INVITES) { // Fail! LLSD msg; - msg["MESSAGE"] = mImplementation->mTooManySelected; + msg["MESSAGE"] = mTooManySelected; LLNotificationsUtil::add("GenericAlert", msg); - (*(mImplementation->mCloseCallback))(mImplementation->mCloseCallbackUserData); + (*mCloseCallback)(mCloseCallbackUserData); return; } - LLGroupMgr::getInstance()->sendGroupMemberInvites(mImplementation->mGroupID, role_member_pairs); - + LLGroupMgr::getInstance()->sendGroupMemberInvites(mGroupID, role_member_pairs); + if(already_in_group) { LLSD msg; - msg["MESSAGE"] = mImplementation->mAlreadyInGroup; + msg["MESSAGE"] = mAlreadyInGroup; LLNotificationsUtil::add("GenericAlert", msg); } //then close - (*(mImplementation->mCloseCallback))(mImplementation->mCloseCallbackUserData); + (*mCloseCallback)(mCloseCallbackUserData); } -void LLPanelGroupInvite::addRoleNames() +bool LLPanelGroupInvite::impl::inviteOwnerCallback(const LLSD& notification, const LLSD& response) { - LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mImplementation->mGroupID); - if(!gdatap) + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + + switch(option) { - return; + case 0: + // user confirmed that they really want a new group owner + mConfirmedOwnerInvite = true; + submitInvitations(); + break; + case 1: + // fall through + default: + break; } + return false; +} + - LLGroupMgrGroupData::member_list_t::iterator agent_iter = gdatap->mMembers.find(gAgent.getID()); + +void LLPanelGroupInvite::impl::addRoleNames(LLGroupMgrGroupData* gdatap) +{ + LLGroupMgrGroupData::member_list_t::iterator agent_iter = + gdatap->mMembers.find(gAgent.getID()); //get the member data for the agent if it exists if ( agent_iter != gdatap->mMembers.end() ) @@ -271,7 +251,7 @@ void LLPanelGroupInvite::addRoleNames() //loop over the agent's roles in the group //then add those roles to the list of roles that the agent //can invite people to be - if ( member_data && mImplementation->mRoleNames) + if ( member_data && mRoleNames) { //if the user is the owner then we add //all of the roles in the group @@ -280,11 +260,11 @@ void LLPanelGroupInvite::addRoleNames() //else if they have the limited add to roles power //we add every role the user is in //else we just add to everyone - bool is_owner = member_data->isOwner(); - bool can_assign_any = gAgent.hasPowerInGroup(mImplementation->mGroupID, - GP_ROLE_ASSIGN_MEMBER); - bool can_assign_limited = gAgent.hasPowerInGroup(mImplementation->mGroupID, - GP_ROLE_ASSIGN_MEMBER_LIMITED); + bool is_owner = member_data->isInRole(gdatap->mOwnerRole); + bool can_assign_any = gAgent.hasPowerInGroup(mGroupID, + GP_ROLE_ASSIGN_MEMBER); + bool can_assign_limited = gAgent.hasPowerInGroup(mGroupID, + GP_ROLE_ASSIGN_MEMBER_LIMITED); LLGroupMgrGroupData::role_list_t::iterator rit = gdatap->mRoles.begin(); LLGroupMgrGroupData::role_list_t::iterator end = gdatap->mRoles.end(); @@ -299,18 +279,401 @@ void LLPanelGroupInvite::addRoleNames() // Owners can add any role. if ( is_owner // Even 'can_assign_any' can't add owner role. - || (can_assign_any && role_id != gdatap->mOwnerRole) + || (can_assign_any && role_id != gdatap->mOwnerRole) // Add all roles user is in - || (can_assign_limited && member_data->isInRole(role_id)) + || (can_assign_limited && member_data->isInRole(role_id)) // Everyone role. - || role_id == LLUUID::null ) + || role_id == LLUUID::null ) { - mImplementation->mRoleNames->add(rd.mRoleName, - role_id, - ADD_BOTTOM); + mRoleNames->add(rd.mRoleName, + role_id, + ADD_BOTTOM); } } } }//end if member data is not null }//end if agent is in the group } + +//static +void LLPanelGroupInvite::impl::callbackClickAdd(void* userdata) +{ + LLPanelGroupInvite* panelp = (LLPanelGroupInvite*) userdata; + + if ( panelp ) + { + //Right now this is hard coded with some knowledge that it is part + //of a floater since the avatar picker needs to be added as a dependent + //floater to the parent floater. + //Soon the avatar picker will be embedded into this panel + //instead of being it's own separate floater. But that is next week. + //This will do for now. -jwolk May 10, 2006 + LLView * button = panelp->findChild("add_button"); + LLFloater * root_floater = gFloaterView->getParentFloater(panelp); + LLFloaterAvatarPicker* picker = LLFloaterAvatarPicker::show( + boost::bind(impl::callbackAddUsers, _1, panelp->mImplementation), TRUE, FALSE, FALSE, root_floater->getName(), button); + if (picker) + { + root_floater->addDependentFloater(picker); + } + } +} + +//static +void LLPanelGroupInvite::impl::callbackClickRemove(void* userdata) +{ + impl* selfp = (impl*) userdata; + + if ( selfp ) selfp->handleRemove(); +} + +void LLPanelGroupInvite::impl::handleRemove() +{ + // Check if there is anything selected. + std::vector selection = + mInvitees->getAllSelected(); + if (selection.empty()) return; + + std::vector::iterator iter; + for(iter = selection.begin(); iter != selection.end(); ++iter) + { + mInviteeIDs.erase( (*iter)->getUUID() ); + } + + // Remove all selected invitees. + mInvitees->deleteSelectedItems(); + mRemoveButton->setEnabled(FALSE); +} + +// static +void LLPanelGroupInvite::impl::callbackSelect( + LLUICtrl* ctrl, void* userdata) +{ + impl* selfp = (impl*) userdata; + if ( selfp ) selfp->handleSelection(); +} + +void LLPanelGroupInvite::impl::handleSelection() +{ + // Check if there is anything selected. + std::vector selection = + mInvitees->getAllSelected(); + if (selection.empty()) + { + mRemoveButton->setEnabled(FALSE); + } + else + { + mRemoveButton->setEnabled(TRUE); + } +} + +void LLPanelGroupInvite::impl::callbackClickCancel(void* userdata) +{ + impl* selfp = (impl*) userdata; + + if ( selfp ) + { + (*(selfp->mCloseCallback))(selfp->mCloseCallbackUserData); + } +} + +void LLPanelGroupInvite::impl::callbackClickOK(void* userdata) +{ + impl* selfp = (impl*) userdata; + + if ( selfp ) selfp->submitInvitations(); +} + + + +//static +void LLPanelGroupInvite::impl::callbackAddUsers(const uuid_vec_t& agent_ids, void* user_data) +{ + std::vector names; + for (S32 i = 0; i < (S32)agent_ids.size(); i++) + { + LLAvatarName av_name; + if (LLAvatarNameCache::get(agent_ids[i], &av_name)) + { + LLPanelGroupInvite::impl::onAvatarNameCache(agent_ids[i], av_name, user_data); + } + else + { + impl* selfp = (impl*) user_data; + if (selfp) + { + if (selfp->mAvatarNameCacheConnection.connected()) + { + selfp->mAvatarNameCacheConnection.disconnect(); + } + // *TODO : Add a callback per avatar name being fetched. + selfp->mAvatarNameCacheConnection = LLAvatarNameCache::get(agent_ids[i],boost::bind(&LLPanelGroupInvite::impl::onAvatarNameCache, _1, _2, user_data)); + } + } + } + +} + +void LLPanelGroupInvite::impl::onAvatarNameCache(const LLUUID& agent_id, + const LLAvatarName& av_name, + void* user_data) +{ + impl* selfp = (impl*) user_data; + + if (selfp) + { + if (selfp->mAvatarNameCacheConnection.connected()) + { + selfp->mAvatarNameCacheConnection.disconnect(); + } + std::vector names; + uuid_vec_t agent_ids; + agent_ids.push_back(agent_id); + names.push_back(av_name.getCompleteName()); + + selfp->addUsers(names, agent_ids); + } +} + + +LLPanelGroupInvite::LLPanelGroupInvite(const LLUUID& group_id) + : LLPanel(), + mImplementation(new impl(group_id)), + mPendingUpdate(FALSE) +{ + // Pass on construction of this panel to the control factory. + buildFromFile( "panel_group_invite.xml"); +} + +LLPanelGroupInvite::~LLPanelGroupInvite() +{ + delete mImplementation; +} + +void LLPanelGroupInvite::setCloseCallback(void (*close_callback)(void*), + void* data) +{ + mImplementation->mCloseCallback = close_callback; + mImplementation->mCloseCallbackUserData = data; +} + +void LLPanelGroupInvite::clear() +{ + mStoreSelected = LLUUID::null; + mImplementation->mInvitees->deleteAllItems(); + mImplementation->mRoleNames->clear(); + mImplementation->mRoleNames->removeall(); + mImplementation->mOKButton->setEnabled(FALSE); + mImplementation->mInviteeIDs.clear(); +} + +void LLPanelGroupInvite::addUsers(uuid_vec_t& agent_ids) +{ + std::vector names; + for (S32 i = 0; i < (S32)agent_ids.size(); i++) + { + std::string fullname; + LLUUID agent_id = agent_ids[i]; + LLViewerObject* dest = gObjectList.findObject(agent_id); + if(dest && dest->isAvatar()) + { + LLNameValue* nvfirst = dest->getNVPair("FirstName"); + LLNameValue* nvlast = dest->getNVPair("LastName"); + if(nvfirst && nvlast) + { + fullname = LLCacheName::buildFullName( + nvfirst->getString(), nvlast->getString()); + + } + if (!fullname.empty()) + { + names.push_back(fullname); + } + else + { + llwarns << "llPanelGroupInvite: Selected avatar has no name: " << dest->getID() << llendl; + names.push_back("(Unknown)"); + } + } + else + { + //looks like user try to invite offline friend + //for offline avatar_id gObjectList.findObject() will return null + //so we need to do this additional search in avatar tracker, see EXT-4732 + if (LLAvatarTracker::instance().isBuddy(agent_id)) + { + LLAvatarName av_name; + if (!LLAvatarNameCache::get(agent_id, &av_name)) + { + // actually it should happen, just in case + //LLAvatarNameCache::get(LLUUID(agent_id), boost::bind(&LLPanelGroupInvite::addUserCallback, this, _1, _2)); + // for this special case! + //when there is no cached name we should remove resident from agent_ids list to avoid breaking of sequence + // removed id will be added in callback + agent_ids.erase(agent_ids.begin() + i); + } + else + { + names.push_back(av_name.getAccountName()); + } + } + } + } + mImplementation->addUsers(names, agent_ids); +} + +void LLPanelGroupInvite::addUserCallback(const LLUUID& id, const LLAvatarName& av_name) +{ + std::vector names; + uuid_vec_t agent_ids; + agent_ids.push_back(id); + names.push_back(av_name.getAccountName()); + + mImplementation->addUsers(names, agent_ids); +} + +void LLPanelGroupInvite::draw() +{ + LLPanel::draw(); + if (mPendingUpdate) + { + updateLists(); + } +} + +void LLPanelGroupInvite::update() +{ + mPendingUpdate = FALSE; + if (mImplementation->mGroupName) + { + mImplementation->mGroupName->setText(mImplementation->mLoadingText); + } + if ( mImplementation->mRoleNames ) + { + mStoreSelected = mImplementation->mRoleNames->getCurrentID(); + mImplementation->mRoleNames->clear(); + mImplementation->mRoleNames->removeall(); + mImplementation->mRoleNames->add(mImplementation->mLoadingText, LLUUID::null, ADD_BOTTOM); + mImplementation->mRoleNames->setCurrentByID(LLUUID::null); + } + + updateLists(); +} + +void LLPanelGroupInvite::updateLists() +{ + LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mImplementation->mGroupID); + bool waiting = false; + + if (gdatap) + { + if (gdatap->isGroupPropertiesDataComplete()) + { + if (mImplementation->mGroupName) + { + mImplementation->mGroupName->setText(gdatap->mName); + } + } + else + { + waiting = true; + } + if (gdatap->isRoleDataComplete() && gdatap->isMemberDataComplete()) + { + if ( mImplementation->mRoleNames ) + { + mImplementation->mRoleNames->clear(); + mImplementation->mRoleNames->removeall(); + + //add the role names and select the everybody role by default + mImplementation->addRoleNames(gdatap); + mImplementation->mRoleNames->setCurrentByID(mStoreSelected); + } + } + else + { + waiting = true; + } + } + else + { + waiting = true; + } + + if (waiting) + { + if (!mPendingUpdate) + { + LLGroupMgr::getInstance()->sendGroupPropertiesRequest(mImplementation->mGroupID); + LLGroupMgr::getInstance()->sendGroupRoleDataRequest(mImplementation->mGroupID); + LLGroupMgr::getInstance()->sendCapGroupMembersRequest(mImplementation->mGroupID); + } + mPendingUpdate = TRUE; + } + else + { + mPendingUpdate = FALSE; + if (mImplementation->mOKButton && mImplementation->mRoleNames->getItemCount()) + { + mImplementation->mOKButton->setEnabled(TRUE); + } + } +} + +BOOL LLPanelGroupInvite::postBuild() +{ + BOOL recurse = TRUE; + + mImplementation->mLoadingText = getString("loading"); + mImplementation->mRoleNames = getChild("role_name", + recurse); + mImplementation->mGroupName = getChild("group_name_text", recurse); + mImplementation->mInvitees = + getChild("invitee_list", recurse); + if ( mImplementation->mInvitees ) + { + mImplementation->mInvitees->setCommitOnSelectionChange(TRUE); + mImplementation->mInvitees->setCommitCallback(impl::callbackSelect, mImplementation); + } + + LLButton* button = getChild("add_button", recurse); + if ( button ) + { + // default to opening avatarpicker automatically + // (*impl::callbackClickAdd)((void*)this); + button->setClickedCallback(impl::callbackClickAdd, this); + } + + mImplementation->mRemoveButton = + getChild("remove_button", recurse); + if ( mImplementation->mRemoveButton ) + { + mImplementation->mRemoveButton->setClickedCallback(impl::callbackClickRemove, mImplementation); + mImplementation->mRemoveButton->setEnabled(FALSE); + } + + mImplementation->mOKButton = + getChild("ok_button", recurse); + if ( mImplementation->mOKButton ) + { + mImplementation->mOKButton->setClickedCallback(impl::callbackClickOK, mImplementation); + mImplementation->mOKButton->setEnabled(FALSE); + } + + button = getChild("cancel_button", recurse); + if ( button ) + { + button->setClickedCallback(impl::callbackClickCancel, mImplementation); + } + + mImplementation->mOwnerWarning = getString("confirm_invite_owner_str"); + mImplementation->mAlreadyInGroup = getString("already_in_group"); + mImplementation->mTooManySelected = getString("invite_selection_too_large"); + + update(); + + return (mImplementation->mRoleNames && + mImplementation->mInvitees && + mImplementation->mRemoveButton); +} diff --git a/indra/newview/llpanelgroupinvite.h b/indra/newview/llpanelgroupinvite.h index b87a5883b8..9f7b5ae9be 100755 --- a/indra/newview/llpanelgroupinvite.h +++ b/indra/newview/llpanelgroupinvite.h @@ -27,27 +27,36 @@ #define LL_LLPANELGROUPINVITE_H #include "llpanel.h" -#include "llpanelgroupbulk.h" #include "lluuid.h" class LLAvatarName; -class LLPanelGroupInvite : public LLPanelGroupBulk +class LLPanelGroupInvite +: public LLPanel { public: LLPanelGroupInvite(const LLUUID& group_id); - ~LLPanelGroupInvite() {}; + ~LLPanelGroupInvite(); - virtual void clear(); - virtual void update(); + void addUsers(uuid_vec_t& agent_ids); + /** + * this callback is being used to add a user whose fullname isn't been loaded before invoking of addUsers(). + */ + void addUserCallback(const LLUUID& id, const LLAvatarName& av_name); + void clear(); + void update(); - virtual BOOL postBuild(); + void setCloseCallback(void (*close_callback)(void*), void* data); - static void callbackClickSubmit(void* userdata); - virtual void submit(); + virtual void draw(); + virtual BOOL postBuild(); +protected: + class impl; + impl* mImplementation; -private: - void addRoleNames(); + BOOL mPendingUpdate; + LLUUID mStoreSelected; + void updateLists(); }; #endif -- cgit v1.3 From dc44604484294d49c4821282315d826972481e6c Mon Sep 17 00:00:00 2001 From: andreylproductengine Date: Thu, 10 Apr 2014 07:05:34 +0300 Subject: MAINT-4133 FIXED Import llpanelgroupinvite.cpp from viewer_lion to voorhees_groupban: import of changes for MAINT-3846. --- indra/newview/llpanelgroupinvite.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/newview/llpanelgroupinvite.cpp') diff --git a/indra/newview/llpanelgroupinvite.cpp b/indra/newview/llpanelgroupinvite.cpp index a9a3c686a6..bb4bfb2f96 100755 --- a/indra/newview/llpanelgroupinvite.cpp +++ b/indra/newview/llpanelgroupinvite.cpp @@ -260,7 +260,7 @@ void LLPanelGroupInvite::impl::addRoleNames(LLGroupMgrGroupData* gdatap) //else if they have the limited add to roles power //we add every role the user is in //else we just add to everyone - bool is_owner = member_data->isInRole(gdatap->mOwnerRole); + bool is_owner = member_data->isOwner(); bool can_assign_any = gAgent.hasPowerInGroup(mGroupID, GP_ROLE_ASSIGN_MEMBER); bool can_assign_limited = gAgent.hasPowerInGroup(mGroupID, @@ -579,7 +579,7 @@ void LLPanelGroupInvite::updateLists() { waiting = true; } - if (gdatap->isRoleDataComplete() && gdatap->isMemberDataComplete()) + if (gdatap->isRoleDataComplete() && gdatap->isMemberDataComplete() && gdatap->isRoleMemberDataComplete()) { if ( mImplementation->mRoleNames ) { @@ -607,6 +607,7 @@ void LLPanelGroupInvite::updateLists() { LLGroupMgr::getInstance()->sendGroupPropertiesRequest(mImplementation->mGroupID); LLGroupMgr::getInstance()->sendGroupRoleDataRequest(mImplementation->mGroupID); + LLGroupMgr::getInstance()->sendGroupRoleMembersRequest(mImplementation->mGroupID); LLGroupMgr::getInstance()->sendCapGroupMembersRequest(mImplementation->mGroupID); } mPendingUpdate = TRUE; -- cgit v1.3 From a92dbb592b338f48f7b75b68a9da511dc95279f9 Mon Sep 17 00:00:00 2001 From: maksymsproductengine Date: Wed, 11 Jun 2014 20:24:25 +0300 Subject: MAINT-4133 FIXED Import llpanelgroupinvite.cpp from viewer_lion to voorhees_groupban. --- indra/newview/llpanelgroupinvite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llpanelgroupinvite.cpp') diff --git a/indra/newview/llpanelgroupinvite.cpp b/indra/newview/llpanelgroupinvite.cpp index bb4bfb2f96..236ad861a5 100755 --- a/indra/newview/llpanelgroupinvite.cpp +++ b/indra/newview/llpanelgroupinvite.cpp @@ -655,7 +655,7 @@ BOOL LLPanelGroupInvite::postBuild() } mImplementation->mOKButton = - getChild("ok_button", recurse); + getChild("invite_button", recurse); if ( mImplementation->mOKButton ) { mImplementation->mOKButton->setClickedCallback(impl::callbackClickOK, mImplementation); -- cgit v1.3