diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index dd0cd4c120..3f044793c7 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -99,6 +99,7 @@ set(viewer_SOURCE_FILES aoset.cpp chatbar_as_cmdline.cpp kcwlinterface.cpp + exogroupmutelist.cpp floatermedialists.cpp fscontactsfloater.cpp fsareasearch.cpp @@ -742,6 +743,7 @@ set(viewer_HEADER_FILES aoset.h chatbar_as_cmdline.h kcwlinterface.h + exogroupmutelist.h floatermedialists.h fscontactsfloater.h fsareasearch.h diff --git a/indra/newview/exogroupmutelist.cpp b/indra/newview/exogroupmutelist.cpp new file mode 100644 index 0000000000..95250adc72 --- /dev/null +++ b/indra/newview/exogroupmutelist.cpp @@ -0,0 +1,105 @@ +/** + * @file exogroupmutelist.cpp + * @brief Persistently stores groups to ignore. + * + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ + * Copyright (C) 2012 Katharine Berry + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU + * Lesser General Public License for more details. + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "lldir.h" +#include "llfile.h" +#include "llgroupactions.h" +#include "llsdserialize.h" + +#include "exogroupmutelist.h" + +exoGroupMuteList::exoGroupMuteList() +: mMuted() +{ + loadMuteList(); +} + +bool exoGroupMuteList::isMuted(const LLUUID& group) const +{ + return mMuted.count(group); +} + +void exoGroupMuteList::add(const LLUUID& group) +{ + LLGroupActions::endIM(group); // Actually kill ongoing conversation + if(mMuted.insert(group).second) + { + saveMuteList(); + } +} + +void exoGroupMuteList::remove(const LLUUID& group) +{ + if(mMuted.erase(group)) + { + saveMuteList(); + } +} + +bool exoGroupMuteList::loadMuteList() +{ + std::string path = getFilePath(); + if(!LLFile::isfile(path)) + { + // We consider the absence of a mute file to be a successful load + // because it won't exist if the user's never muted a group. + LL_INFOS("GroupMute") << "Mute file doesn't exist; skipping load." << LL_ENDL; + return true; + } + llifstream file(path); + if(!file.is_open()) + { + LL_WARNS("GroupMute") << "Failed to open group muting list." << LL_ENDL; + return false; + } + LLSD data; + LLSDSerialize::fromXMLDocument(data, file); + file.close(); + + std::copy(data.beginArray(), data.endArray(), inserter(mMuted, mMuted.begin())); + return true; +} + +bool exoGroupMuteList::saveMuteList() +{ + LLSD data; + // LLSD doesn't seem to expose insertion using iterators. + for(std::set::iterator it = mMuted.begin(); it != mMuted.end(); ++it) + { + data.append(*it); + } + + llofstream file(getFilePath()); + if(!file.is_open()) + { + LL_WARNS("GroupMute") << "Unable to save group muting list!" << LL_ENDL; + return false; + } + LLSDSerialize::toPrettyXML(data, file); + file.close(); + return true; +} + +std::string exoGroupMuteList::getFilePath() const +{ + return gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "muted_groups.xml"); +} + diff --git a/indra/newview/exogroupmutelist.h b/indra/newview/exogroupmutelist.h new file mode 100644 index 0000000000..1b88cb4c66 --- /dev/null +++ b/indra/newview/exogroupmutelist.h @@ -0,0 +1,41 @@ +/** + * @file exogroupmutelist.h + * @brief Persistently stores groups to ignore. + * + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ + * Copyright (C) 2012 Katharine Berry + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU + * Lesser General Public License for more details. + * $/LicenseInfo$ + */ + +#ifndef EXO_GROUPMUTELIST_H +#define EXO_GROUPMUTELIST_H + +#include "lluuid.h" + +class exoGroupMuteList : public LLSingleton +{ +public: + exoGroupMuteList(); + bool isMuted(const LLUUID &group) const; + void add(const LLUUID &group); + void remove(const LLUUID &group); + +private: + bool loadMuteList(); + bool saveMuteList(); + std::string getFilePath() const; + + std::set mMuted; +}; + +#endif diff --git a/indra/newview/llgroupactions.cpp b/indra/newview/llgroupactions.cpp index 0d05baa8e8..95eca9f5c8 100644 --- a/indra/newview/llgroupactions.cpp +++ b/indra/newview/llgroupactions.cpp @@ -53,6 +53,8 @@ #include "rlvhandler.h" // [/RLVa:KB] +#include "exogroupmutelist.h" + // // Globals // @@ -413,6 +415,10 @@ LLUUID LLGroupActions::startIM(const LLUUID& group_id) LLGroupData group_data; if (gAgent.getGroupData(group_id, group_data)) { + // + // Unmute the group if the user tries to start a session with it. + exoGroupMuteList::instance().remove(group_id); + // LLUUID session_id = gIMMgr->addSession( group_data.mName, IM_SESSION_GROUP_START, diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 444b6e938a..4a94c08277 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -70,6 +70,8 @@ #include "rlvhandler.h" // [/RLVa:KB] +#include "exogroupmutelist.h" + const static std::string ADHOC_NAME_SUFFIX(" Conference"); const static std::string NEARBY_P2P_BY_OTHER("nearby_P2P_by_other"); @@ -2658,7 +2660,9 @@ void LLIMMgr::addMessage( // Logically it would make more sense to reject the session sooner, in another area of the // code, but the session has to be established inside the server before it can be left. - if (LLMuteList::getInstance()->isMuted(other_participant_id) && !LLMuteList::getInstance()->isLinden(from)) + //if (LLMuteList::getInstance()->isMuted(other_participant_id) && !LLMuteList::getInstance()->isLinden(from)) + if ((LLMuteList::getInstance()->isMuted(other_participant_id) && !LLMuteList::getInstance()->isLinden(from)) + || exoGroupMuteList::instance().isMuted(new_session_id)) // { llwarns << "Leaving IM session from initiating muted resident " << from << llendl; if(!gIMMgr->leaveSession(new_session_id)) diff --git a/indra/newview/llpanelgroupgeneral.cpp b/indra/newview/llpanelgroupgeneral.cpp index 2986a3e791..b3fb5d338b 100644 --- a/indra/newview/llpanelgroupgeneral.cpp +++ b/indra/newview/llpanelgroupgeneral.cpp @@ -56,6 +56,8 @@ // for copy URI button #include "llclipboard.h" +#include "exogroupmutelist.h" + static LLRegisterPanelClassWrapper t_panel_group_general("panel_group_general"); // consts @@ -82,7 +84,8 @@ LLPanelGroupGeneral::LLPanelGroupGeneral() mCtrlReceiveNotices(NULL), mCtrlListGroup(NULL), mActiveTitleLabel(NULL), - mComboActiveTitle(NULL) + mComboActiveTitle(NULL), + mCtrlReceiveGroupChat(NULL) // { } @@ -169,6 +172,19 @@ BOOL LLPanelGroupGeneral::postBuild() mCtrlReceiveNotices->set(accept_notices); mCtrlReceiveNotices->setEnabled(data.mID.notNull()); } + + // + mCtrlReceiveGroupChat = getChild("receive_chat", recurse); + if(mCtrlReceiveGroupChat) + { + mCtrlReceiveNotices->setCommitCallback(onCommitUserOnly, this); + mCtrlReceiveNotices->setEnabled(data.mID.notNull()); + if(data.mID.notNull()) + { + mCtrlReceiveNotices->set(!exoGroupMuteList::instance().isMuted(data.mID)); + } + } + // mCtrlListGroup = getChild("list_groups_in_profile", recurse); if (mCtrlListGroup) @@ -449,6 +465,20 @@ bool LLPanelGroupGeneral::apply(std::string& mesg) gAgent.setUserGroupFlags(mGroupID, receive_notices, list_in_profile); + // + if(mCtrlReceiveGroupChat) + { + if(mCtrlReceiveGroupChat->get()) + { + exoGroupMuteList::instance().remove(mGroupID); + } + else + { + exoGroupMuteList::instance().add(mGroupID); + } + } + // + resetDirty(); mChanged = FALSE; @@ -649,6 +679,16 @@ void LLPanelGroupGeneral::update(LLGroupChange gc) } } + // + if (mCtrlReceiveGroupChat) + { + mCtrlReceiveGroupChat->setVisible(is_member); + if (is_member) + { + mCtrlReceiveGroupChat->setEnabled(mAllowEdit); + } + } + // if (mInsignia) mInsignia->setEnabled(mAllowEdit && can_change_ident); if (mEditCharter) mEditCharter->setEnabled(mAllowEdit && can_change_ident); @@ -812,7 +852,8 @@ void LLPanelGroupGeneral::updateChanged() mCtrlReceiveNotices, mCtrlListGroup, mActiveTitleLabel, - mComboActiveTitle + mComboActiveTitle, + mCtrlReceiveGroupChat // }; mChanged = FALSE; @@ -865,6 +906,12 @@ void LLPanelGroupGeneral::reset() mInsignia->setImageAssetName(mInsignia->getDefaultImageName()); + // + mCtrlReceiveGroupChat->set(false); + mCtrlReceiveGroupChat->setEnabled(false); + mCtrlReceiveGroupChat->setVisible(true); + // + { std::string empty_str = ""; mEditCharter->setText(empty_str); @@ -909,7 +956,8 @@ void LLPanelGroupGeneral::resetDirty() mCtrlReceiveNotices, mCtrlListGroup, mActiveTitleLabel, - mComboActiveTitle + mComboActiveTitle, + mCtrlReceiveGroupChat // }; for( size_t i=0; isetEnabled(data.mID.notNull()); } + // + mCtrlReceiveGroupChat = getChild("receive_chat"); + if (mCtrlReceiveGroupChat) + { + if(data.mID.notNull()) + { + mCtrlReceiveGroupChat->set(!exoGroupMuteList::instance().isMuted(data.mID)); + } + mCtrlReceiveGroupChat->setEnabled(data.mID.notNull()); + } + // + mCtrlShowInGroupList->setEnabled(data.mID.notNull()); mActiveTitleLabel = getChild("active_title_label"); diff --git a/indra/newview/llpanelgroupgeneral.h b/indra/newview/llpanelgroupgeneral.h index 9d3c035d6e..15345fc744 100644 --- a/indra/newview/llpanelgroupgeneral.h +++ b/indra/newview/llpanelgroupgeneral.h @@ -109,6 +109,7 @@ private: LLTextBox *mActiveTitleLabel; LLComboBox *mComboActiveTitle; LLComboBox *mComboMature; + LLCheckBoxCtrl *mCtrlReceiveGroupChat; // LLGroupMgrGroupData::member_list_t::iterator mMemberProgress; LLUUID mIteratorGroup; // FIRE-6074; UUID of the group mMemberProgress belongs to. diff --git a/indra/newview/skins/default/xui/en/panel_group_general.xml b/indra/newview/skins/default/xui/en/panel_group_general.xml index 36dbfa3282..5b5d1c308e 100644 --- a/indra/newview/skins/default/xui/en/panel_group_general.xml +++ b/indra/newview/skins/default/xui/en/panel_group_general.xml @@ -259,10 +259,23 @@ Hover your mouse over the options for more help. top_pad="4" width="300" /> + + + +