diff options
Diffstat (limited to 'indra/newview/llimfloatercontainer.cpp')
-rw-r--r-- | indra/newview/llimfloatercontainer.cpp | 162 |
1 files changed, 122 insertions, 40 deletions
diff --git a/indra/newview/llimfloatercontainer.cpp b/indra/newview/llimfloatercontainer.cpp index d25a195f33..a33fc2c57e 100644 --- a/indra/newview/llimfloatercontainer.cpp +++ b/indra/newview/llimfloatercontainer.cpp @@ -39,6 +39,7 @@ #include "llavatariconctrl.h" #include "llavatarnamecache.h" #include "llcallbacklist.h" +#include "llgroupactions.h" #include "llgroupiconctrl.h" #include "llfloateravatarpicker.h" #include "llfloaterpreference.h" @@ -64,6 +65,8 @@ LLIMFloaterContainer::LLIMFloaterContainer(const LLSD& seed) mEnableCallbackRegistrar.add("Avatar.CheckItem", boost::bind(&LLIMFloaterContainer::checkContextMenuItem, this, _2)); mEnableCallbackRegistrar.add("Avatar.EnableItem", boost::bind(&LLIMFloaterContainer::enableContextMenuItem, this, _2)); mCommitCallbackRegistrar.add("Avatar.DoToSelected", boost::bind(&LLIMFloaterContainer::doToSelected, this, _2)); + + mCommitCallbackRegistrar.add("Group.DoToSelected", boost::bind(&LLIMFloaterContainer::doToSelectedGroup, this, _2)); // Firstly add our self to IMSession observers, so we catch session events LLIMMgr::getInstance()->addSessionObserver(this); @@ -731,81 +734,160 @@ void LLIMFloaterContainer::getSelectedUUIDs(uuid_vec_t& selected_uuids) selected_uuids.push_back(conversationItem->getUUID()); } } -void LLIMFloaterContainer::doToSelected(const LLSD& userdata) + +const LLConversationItem * LLIMFloaterContainer::getCurSelectedViewModelItem() { - std::string command = userdata.asString(); - uuid_vec_t selected_uuids; - LLUUID currentSelectedUUID; - LLIMFloater * conversation; + LLConversationItem * conversationItem = NULL; - getSelectedUUIDs(selected_uuids); - //Find the conversation floater associated with the selected id - conversation = LLIMFloater::findInstance(selected_uuids.front()); - - //When a one-on-one conversation exists, retrieve the participant id from the conversation floater b/c - //selected_uuids.front() does not pertain to the UUID of the person you are having the conversation with. - if(conversation && - mConversationsRoot && - mConversationsRoot->getCurSelectedItem() && - mConversationsRoot->getCurSelectedItem()->getViewModelItem() && - static_cast<LLConversationItem *>(mConversationsRoot->getCurSelectedItem()->getViewModelItem())->getType() == LLConversationItem::CONV_SESSION_1_ON_1) + if(mConversationsRoot && + mConversationsRoot->getCurSelectedItem() && + mConversationsRoot->getCurSelectedItem()->getViewModelItem()) { - currentSelectedUUID = conversation->getOtherParticipantUUID(); - } - //Otherwise can get the UUID directly from selected_uuids - else - { - currentSelectedUUID = selected_uuids.front(); + conversationItem = static_cast<LLConversationItem *>(mConversationsRoot->getCurSelectedItem()->getViewModelItem()); } - //Close the selected conversation - if(conversation && "close_conversation" == command) - { - LLFloater::onClickClose(conversation); - } - else if ("view_profile" == command) + return conversationItem; +} + +void LLIMFloaterContainer::doToUsers(const std::string& command, uuid_vec_t selectedIDS) +{ + LLUUID userID; + userID = selectedIDS.front(); + + if ("view_profile" == command) { - LLAvatarActions::showProfile(currentSelectedUUID); + LLAvatarActions::showProfile(userID); } else if("im" == command) { - LLAvatarActions::startIM(currentSelectedUUID); + LLAvatarActions::startIM(userID); } else if("offer_teleport" == command) { - LLAvatarActions::offerTeleport(selected_uuids); + LLAvatarActions::offerTeleport(selectedIDS); } else if("voice_call" == command) { - LLAvatarActions::startCall(currentSelectedUUID); + LLAvatarActions::startCall(userID); + } + else if("chat_history" == command) + { + LLAvatarActions::viewChatHistory(userID); } else if("add_friend" == command) { - LLAvatarActions::requestFriendshipDialog(currentSelectedUUID); + LLAvatarActions::requestFriendshipDialog(userID); } else if("remove_friend" == command) { - LLAvatarActions::removeFriendDialog(currentSelectedUUID); + LLAvatarActions::removeFriendDialog(userID); } else if("invite_to_group" == command) { - LLAvatarActions::inviteToGroup(currentSelectedUUID); + LLAvatarActions::inviteToGroup(userID); } else if("map" == command) { - LLAvatarActions::showOnMap(currentSelectedUUID); + LLAvatarActions::showOnMap(userID); } else if("share" == command) { - LLAvatarActions::share(currentSelectedUUID); + LLAvatarActions::share(userID); } else if("pay" == command) { - LLAvatarActions::pay(currentSelectedUUID); + LLAvatarActions::pay(userID); } else if("block_unblock" == command) { - LLAvatarActions::toggleBlock(currentSelectedUUID); + LLAvatarActions::toggleBlock(userID); + } +} + +void LLIMFloaterContainer::doToSelectedParticipant(const std::string& command) +{ + uuid_vec_t selected_uuids; + getSelectedUUIDs(selected_uuids); + + doToUsers(command, selected_uuids); +} + +void LLIMFloaterContainer::doToSelectedConversation(const std::string& command) +{ + LLUUID participantID; + + //Find the conversation floater associated with the selected id + const LLConversationItem * conversationItem = getCurSelectedViewModelItem(); + LLIMFloater *conversationFloater = LLIMFloater::findInstance(conversationItem->getUUID()); + + if(conversationFloater) + { + //When a one-on-one conversation exists, retrieve the participant id from the conversation floater b/c + //selected_uuids.front() does not pertain to the UUID of the person you are having the conversation with. + if(conversationItem->getType() == LLConversationItem::CONV_SESSION_1_ON_1) + { + participantID = conversationFloater->getOtherParticipantUUID(); + } + + //Close the selected conversation + if("close_conversation" == command) + { + LLFloater::onClickClose(conversationFloater); + } + else if("open_voice_conversation" == command) + { + gIMMgr->startCall(conversationItem->getUUID()); + } + else if("disconnect_from_voice" == command) + { + gIMMgr->endCall(conversationItem->getUUID()); + } + else if("chat_history" == command) + { + LLAvatarActions::viewChatHistory(conversationItem->getUUID()); + } + else + { + uuid_vec_t selected_uuids; + selected_uuids.push_back(participantID); + doToUsers(command, selected_uuids); + } + } +} + +void LLIMFloaterContainer::doToSelected(const LLSD& userdata) +{ + std::string command = userdata.asString(); + const LLConversationItem * conversationItem = getCurSelectedViewModelItem(); + + if(conversationItem->getType() == LLConversationItem::CONV_SESSION_1_ON_1 || + conversationItem->getType() == LLConversationItem::CONV_SESSION_GROUP || + conversationItem->getType() == LLConversationItem::CONV_SESSION_AD_HOC) + { + doToSelectedConversation(command); + } + else + { + doToSelectedParticipant(command); + } +} + +void LLIMFloaterContainer::doToSelectedGroup(const LLSD& userdata) +{ + std::string action = userdata.asString(); + LLUUID selected_group = getCurSelectedViewModelItem()->getUUID(); + + if (action == "group_profile") + { + LLGroupActions::show(selected_group); + } + else if (action == "activate_group") + { + LLGroupActions::activate(selected_group); + } + else if (action == "leave_group") + { + LLGroupActions::leave(selected_group); } } @@ -896,7 +978,7 @@ bool LLIMFloaterContainer::enableContextMenuItem(const LLSD& userdata) bool LLIMFloaterContainer::checkContextMenuItem(const LLSD& userdata) { std::string item = userdata.asString(); - const LLUUID& id = static_cast<LLConversationItem *>(mConversationsRoot->getCurSelectedItem()->getViewModelItem())->getUUID(); + const LLUUID& id = getCurSelectedViewModelItem()->getUUID(); if (item == std::string("is_blocked")) { |