From 05da24f82bad8cf31de5cb6a3a6aaac73c94810e Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Mon, 23 Aug 2010 23:45:31 -0500 Subject: Finished up ability to ignore group chat from specific groups. Uncheck the "Join group chat" checkbox in the group info window. The list of ignored groups is saved per-account in ignore_groups.xml. --- linden/indra/newview/llimview.cpp | 79 +++++++++++++++++----------- linden/indra/newview/llimview.h | 2 +- linden/indra/newview/llpanelgroupgeneral.cpp | 10 ++-- linden/indra/newview/llstartup.cpp | 4 ++ linden/indra/newview/llviewerwindow.cpp | 4 -- 5 files changed, 56 insertions(+), 43 deletions(-) diff --git a/linden/indra/newview/llimview.cpp b/linden/indra/newview/llimview.cpp index 2ad743b..e3ec5e6 100644 --- a/linden/indra/newview/llimview.cpp +++ b/linden/indra/newview/llimview.cpp @@ -535,8 +535,6 @@ LLIMMgr::LLIMMgr() : mPendingInvitations = LLSD::emptyMap(); mPendingAgentListUpdates = LLSD::emptyMap(); - - loadIgnoreGroup(); } LLIMMgr::~LLIMMgr() @@ -615,8 +613,9 @@ void LLIMMgr::addMessage( } // If the group is in our list then return - if (group_data && (mIgnoreGroupList.count(group_data->mID) == 1)) + if (group_data && getIgnoreGroup(group_data->mID)) { + // llinfos << "ignoring chat from group " << group_data->mID << llendl; return; } } @@ -1304,7 +1303,6 @@ 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; @@ -1312,38 +1310,41 @@ void LLIMMgr::loadIgnoreGroup() file.open(filename); if (file.is_open()) { - llinfos << "loading ignore_groups.xml" << llendl; + // llinfos << "loading group chat ignore from " << filename << "..." << llendl; LLSDSerialize::fromXML(settings_llsd, file); + + mIgnoreGroupList.clear(); + + for(LLSD::array_const_iterator iter = settings_llsd.beginArray(); + iter != settings_llsd.endArray(); ++iter) + { + // llinfos << "added " << iter->asUUID() + // << " to group chat ignore list" << llendl; + mIgnoreGroupList.push_back( iter->asUUID() ); + } } 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()))); + // llinfos << "can't load " << filename + // << " (probably it doesn't exist yet)" << llendl; } } void LLIMMgr::saveIgnoreGroup() { - // Save groups we want to ignore in chat before killing gIMMgr + // llinfos << "saving ignore_groups.xml" << llendl; + 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) + LLSD settings_llsd = LLSD::emptyArray(); + + for(std::list::iterator iter = mIgnoreGroupList.begin(); + iter != mIgnoreGroupList.end(); ++iter) { - settings_llsd[iter->first.asString()] = iter->second; + settings_llsd.append(*iter); } llofstream file; @@ -1356,16 +1357,27 @@ 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()) + std::list::iterator found = + std::find( mIgnoreGroupList.begin(), mIgnoreGroupList.end(), + group_id); + + if (found != mIgnoreGroupList.end() && !ignore) { - llinfos << "existing group " << group_id << " updated to " << ignore << llendl; - mIgnoreGroupList[group_id] = ignore; + // change from ignored to not ignored + // llinfos << "unignoring group " << group_id << llendl; + mIgnoreGroupList.remove(group_id); + } + else if (found == mIgnoreGroupList.end() && ignore) + { + // change from not ignored to ignored + // llinfos << "ignoring group " << group_id << llendl; + mIgnoreGroupList.push_back(group_id); } else { - llinfos << "new group " << group_id << " created and set to " << ignore << llendl; - mIgnoreGroupList.insert(std::make_pair(group_id, ignore)); + // nothing to do + // llinfos << "no change to group " << group_id << ", it is already " + // << (ignore ? "" : "not ") << "ignored" << llendl; } } } @@ -1374,14 +1386,17 @@ 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()) + std::list::iterator found = + std::find( mIgnoreGroupList.begin(), mIgnoreGroupList.end(), + group_id); + + if (found != mIgnoreGroupList.end()) { - llinfos << "group found in ignore_groups.xml, " << found_it->second << llendl; - return found_it->second; + // llinfos << "group " << group_id << " is ignored." << llendl; + return true; } } - llinfos << "no group info found in ignore_groups.xml" << llendl; + // llinfos << "group " << group_id << " is not ignored." << llendl; return false; } diff --git a/linden/indra/newview/llimview.h b/linden/indra/newview/llimview.h index a7a088a..8f665d2 100644 --- a/linden/indra/newview/llimview.h +++ b/linden/indra/newview/llimview.h @@ -218,7 +218,7 @@ private: LLSD mPendingInvitations; LLSD mPendingAgentListUpdates; - std::map mIgnoreGroupList; + std::list mIgnoreGroupList; }; diff --git a/linden/indra/newview/llpanelgroupgeneral.cpp b/linden/indra/newview/llpanelgroupgeneral.cpp index 402929e..55e1b33 100644 --- a/linden/indra/newview/llpanelgroupgeneral.cpp +++ b/linden/indra/newview/llpanelgroupgeneral.cpp @@ -545,7 +545,6 @@ 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(); @@ -556,13 +555,12 @@ bool LLPanelGroupGeneral::apply(std::string& mesg) if (mCtrlReceiveChat) { - receive_chat = mCtrlReceiveChat->get(); + bool receive_chat = mCtrlReceiveChat->get(); + gIMMgr->updateIgnoreGroup(mGroupID, !receive_chat); + // Save here too in case we crash somewhere down the road -- MC + gIMMgr->saveIgnoreGroup(); } - gIMMgr->updateIgnoreGroup(mGroupID, receive_chat); - // Save here too in case we crash somewhere down the road -- MC - gIMMgr->saveIgnoreGroup(); - mChanged = FALSE; return true; diff --git a/linden/indra/newview/llstartup.cpp b/linden/indra/newview/llstartup.cpp index 3f55fd8..0464e99 100644 --- a/linden/indra/newview/llstartup.cpp +++ b/linden/indra/newview/llstartup.cpp @@ -111,6 +111,7 @@ #include "llhudmanager.h" #include "llhttpclient.h" #include "llimagebmp.h" +#include "llimview.h" // for gIMMgr #include "llinventorymodel.h" #include "llinventoryview.h" #include "llkeyboard.h" @@ -1716,6 +1717,9 @@ bool idle_startup() gHippoGridManager->saveFile(); gHippoLimits->setLimits(); + // Load list of groups to ignore incoming chat from. + gIMMgr->loadIgnoreGroup(); + // JC: gesture loading done below, when we have an asset system // in place. Don't delete/clear user_credentials until then. diff --git a/linden/indra/newview/llviewerwindow.cpp b/linden/indra/newview/llviewerwindow.cpp index dd27726..c89e0c5 100644 --- a/linden/indra/newview/llviewerwindow.cpp +++ b/linden/indra/newview/llviewerwindow.cpp @@ -1660,10 +1660,6 @@ void LLViewerWindow::initWorldUI() mRootView->addChild(gHoverView); gIMMgr = LLIMMgr::getInstance(); - if (gIMMgr) - { - gIMMgr->loadIgnoreGroup(); - } if ( gSavedPerAccountSettings.getBOOL("LogShowHistory") ) { -- cgit v1.1