From 615b9f34fb21b40cb3ba9489c00ba8f5338e3a7d Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Sun, 22 Aug 2010 19:38:52 -0700 Subject: Wip - mute group chat --- linden/indra/newview/llappviewer.cpp | 2 + linden/indra/newview/llimview.cpp | 116 +++++++++++++++++++++ linden/indra/newview/llimview.h | 8 ++ linden/indra/newview/llpanelgroupgeneral.cpp | 29 ++++++ linden/indra/newview/llpanelgroupgeneral.h | 1 + linden/indra/newview/llviewerwindow.cpp | 4 + .../default/xui/en-us/panel_group_general.xml | 5 + 7 files changed, 165 insertions(+) (limited to 'linden') diff --git a/linden/indra/newview/llappviewer.cpp b/linden/indra/newview/llappviewer.cpp index bcfeaa3..89eeb13 100644 --- a/linden/indra/newview/llappviewer.cpp +++ b/linden/indra/newview/llappviewer.cpp @@ -3734,6 +3734,8 @@ void LLAppViewer::idleShutdown() // close IM interface if(gIMMgr) { + // Save group chat ignore list -- MC + gIMMgr->saveIgnoreGroup(); gIMMgr->disconnectAllSessions(); } diff --git a/linden/indra/newview/llimview.cpp b/linden/indra/newview/llimview.cpp index 790e20b..2ad743b 100644 --- a/linden/indra/newview/llimview.cpp +++ b/linden/indra/newview/llimview.cpp @@ -53,6 +53,7 @@ #include "llhttpnode.h" #include "llimpanel.h" #include "llresizebar.h" +#include "llsdserialize.h" #include "lltabcontainer.h" #include "llviewercontrol.h" #include "llfloater.h" @@ -534,6 +535,8 @@ LLIMMgr::LLIMMgr() : mPendingInvitations = LLSD::emptyMap(); mPendingAgentListUpdates = LLSD::emptyMap(); + + loadIgnoreGroup(); } LLIMMgr::~LLIMMgr() @@ -594,6 +597,30 @@ void LLIMMgr::addMessage( // create IM window as necessary if(!floater) { + if (!mIgnoreGroupList.empty()) + { + // Check to see if we're blocking this group's chat + LLGroupData *group_data = NULL; + + // Search for this group in the agent's groups list + LLDynamicArray::iterator i; + + for (i = gAgent.mGroups.begin(); i != gAgent.mGroups.end(); i++) + { + if (i->mID == session_id) + { + group_data = &*i; + break; + } + } + + // If the group is in our list then return + if (group_data && (mIgnoreGroupList.count(group_data->mID) == 1)) + { + return; + } + } + std::string name = from; if(!session_name.empty() && session_name.size()>1) { @@ -1275,6 +1302,95 @@ void LLIMMgr::updateFloaterSessionID( } } +void LLIMMgr::loadIgnoreGroup() +{ + // Load groups we want to ignore in chat -- MC + std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "ignore_groups.xml"); + + LLSD settings_llsd; + llifstream file; + file.open(filename); + if (file.is_open()) + { + llinfos << "loading ignore_groups.xml" << llendl; + LLSDSerialize::fromXML(settings_llsd, file); + } + else + { + llinfos << "creating blank ignore_groups.xml" << llendl; + FILE* fp = LLFile::fopen(filename, "w+"); + fclose(fp); + } + + for (LLSD::map_const_iterator iter = settings_llsd.beginMap(); + iter != settings_llsd.endMap(); ++iter) + { + llinfos << "group chat for id " << iter->first << " is ignored? " << iter->second << llendl; + mIgnoreGroupList.insert(std::make_pair(LLUUID(iter->first), (bool)(iter->second.asBoolean()))); + } +} + +void LLIMMgr::saveIgnoreGroup() +{ + // Save groups we want to ignore in chat before killing gIMMgr + std::string user_dir = gDirUtilp->getLindenUserDir(); + if (!user_dir.empty()) + { + llinfos << "saving ignore_groups.xml" << llendl; + std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "ignore_groups.xml"); + LLSD settings_llsd; + + for(std::map::iterator iter = mIgnoreGroupList.begin(); + iter != mIgnoreGroupList.end(); ++iter) + { + settings_llsd[iter->first.asString()] = iter->second; + } + + llofstream file; + file.open(filename); + LLSDSerialize::toPrettyXML(settings_llsd, file); + } +} + +void LLIMMgr::updateIgnoreGroup(const LLUUID& group_id, const bool& ignore) +{ + if (group_id.notNull()) + { + std::map::iterator found_it = mIgnoreGroupList.find(group_id); + if (found_it != mIgnoreGroupList.end()) + { + llinfos << "existing group " << group_id << " updated to " << ignore << llendl; + mIgnoreGroupList[group_id] = ignore; + } + else + { + llinfos << "new group " << group_id << " created and set to " << ignore << llendl; + mIgnoreGroupList.insert(std::make_pair(group_id, ignore)); + } + } +} + +bool LLIMMgr::getIgnoreGroup(const LLUUID& group_id) +{ + if (group_id.notNull()) + { + std::map::iterator found_it = mIgnoreGroupList.find(group_id); + if (found_it != mIgnoreGroupList.end()) + { + llinfos << "group found in ignore_groups.xml, " << found_it->second << llendl; + return found_it->second; + } + } + llinfos << "no group info found in ignore_groups.xml" << llendl; + return false; +} + + +////////////////////// +///// ChatterBox ///// +////////////////////// + + LLFloaterChatterBox* LLIMMgr::getFloater() { return LLFloaterChatterBox::getInstance(LLSD()); diff --git a/linden/indra/newview/llimview.h b/linden/indra/newview/llimview.h index b03036b..a7a088a 100644 --- a/linden/indra/newview/llimview.h +++ b/linden/indra/newview/llimview.h @@ -172,6 +172,12 @@ public: //HACK: need a better way of enumerating existing session, or listening to session create/destroy events const std::set >& getIMFloaterHandles() { return mFloaters; } + void loadIgnoreGroup(); + void saveIgnoreGroup(); + void updateIgnoreGroup(const LLUUID& group_id, const bool& ignore); + // Returns true if group chat is ignored for the UUID, false if not + bool getIgnoreGroup(const LLUUID& group_id); + private: // create a panel and update internal representation for // consistency. Returns the pointer, caller (the class instance @@ -211,6 +217,8 @@ private: LLSD mPendingInvitations; LLSD mPendingAgentListUpdates; + + std::map mIgnoreGroupList; }; diff --git a/linden/indra/newview/llpanelgroupgeneral.cpp b/linden/indra/newview/llpanelgroupgeneral.cpp index 8006981..402929e 100644 --- a/linden/indra/newview/llpanelgroupgeneral.cpp +++ b/linden/indra/newview/llpanelgroupgeneral.cpp @@ -47,6 +47,7 @@ #include "llcheckboxctrl.h" #include "llcombobox.h" #include "lldbstrings.h" +#include "llimview.h" #include "lllineeditor.h" #include "llnamebox.h" #include "llnamelistctrl.h" @@ -89,6 +90,7 @@ LLPanelGroupGeneral::LLPanelGroupGeneral(const std::string& name, mCtrlEnrollmentFee(NULL), mSpinEnrollmentFee(NULL), mCtrlReceiveNotices(NULL), + mCtrlReceiveChat(NULL), mCtrlListGroup(NULL), mActiveTitleLabel(NULL), mComboActiveTitle(NULL) @@ -217,6 +219,15 @@ BOOL LLPanelGroupGeneral::postBuild() mCtrlReceiveNotices->set(accept_notices); mCtrlReceiveNotices->setEnabled(data.mID.notNull()); } + + mCtrlReceiveChat = getChild("receive_chat", recurse); + if (mCtrlReceiveChat) + { + mCtrlReceiveChat->setCommitCallback(onCommitUserOnly); + mCtrlReceiveChat->setCallbackUserData(this); + mCtrlReceiveChat->set(!gIMMgr->getIgnoreGroup(mGroupID)); + mCtrlReceiveChat->setEnabled(mGroupID.notNull()); + } mCtrlListGroup = getChild("list_groups_in_profile", recurse); if (mCtrlListGroup) @@ -534,6 +545,7 @@ bool LLPanelGroupGeneral::apply(std::string& mesg) } BOOL receive_notices = false; + BOOL receive_chat = false; BOOL list_in_profile = false; if (mCtrlReceiveNotices) receive_notices = mCtrlReceiveNotices->get(); @@ -542,6 +554,15 @@ bool LLPanelGroupGeneral::apply(std::string& mesg) gAgent.setUserGroupFlags(mGroupID, receive_notices, list_in_profile); + if (mCtrlReceiveChat) + { + receive_chat = mCtrlReceiveChat->get(); + } + + gIMMgr->updateIgnoreGroup(mGroupID, receive_chat); + // Save here too in case we crash somewhere down the road -- MC + gIMMgr->saveIgnoreGroup(); + mChanged = FALSE; return true; @@ -758,6 +779,13 @@ void LLPanelGroupGeneral::update(LLGroupChange gc) mCtrlReceiveNotices->resetDirty(); } + if (mCtrlReceiveChat) + { + mCtrlReceiveChat->setVisible(is_member); + mCtrlReceiveChat->setEnabled(TRUE); + mCtrlReceiveChat->resetDirty(); + } + if (mInsignia) mInsignia->setEnabled(mAllowEdit && can_change_ident); if (mEditCharter) mEditCharter->setEnabled(mAllowEdit && can_change_ident); @@ -902,6 +930,7 @@ void LLPanelGroupGeneral::updateChanged() mCtrlEnrollmentFee, mSpinEnrollmentFee, mCtrlReceiveNotices, + mCtrlReceiveChat, mCtrlListGroup, mActiveTitleLabel, mComboActiveTitle diff --git a/linden/indra/newview/llpanelgroupgeneral.h b/linden/indra/newview/llpanelgroupgeneral.h index 7135667..c4572e2 100644 --- a/linden/indra/newview/llpanelgroupgeneral.h +++ b/linden/indra/newview/llpanelgroupgeneral.h @@ -107,6 +107,7 @@ private: LLCheckBoxCtrl *mCtrlEnrollmentFee; LLSpinCtrl *mSpinEnrollmentFee; LLCheckBoxCtrl *mCtrlReceiveNotices; + LLCheckBoxCtrl *mCtrlReceiveChat; LLCheckBoxCtrl *mCtrlListGroup; LLTextBox *mActiveTitleLabel; LLComboBox *mComboActiveTitle; diff --git a/linden/indra/newview/llviewerwindow.cpp b/linden/indra/newview/llviewerwindow.cpp index c89e0c5..dd27726 100644 --- a/linden/indra/newview/llviewerwindow.cpp +++ b/linden/indra/newview/llviewerwindow.cpp @@ -1660,6 +1660,10 @@ void LLViewerWindow::initWorldUI() mRootView->addChild(gHoverView); gIMMgr = LLIMMgr::getInstance(); + if (gIMMgr) + { + gIMMgr->loadIgnoreGroup(); + } if ( gSavedPerAccountSettings.getBOOL("LogShowHistory") ) { diff --git a/linden/indra/newview/skins/default/xui/en-us/panel_group_general.xml b/linden/indra/newview/skins/default/xui/en-us/panel_group_general.xml index 3e2a34a..a967a90 100644 --- a/linden/indra/newview/skins/default/xui/en-us/panel_group_general.xml +++ b/linden/indra/newview/skins/default/xui/en-us/panel_group_general.xml @@ -129,6 +129,11 @@ Hover your mouse over the options for more help. mouse_opaque="true" name="receive_notices" radio_style="false" tool_tip="Sets whether you want to receive Notices from this group. Uncheck this box if this group is spamming you." width="95" /> +