Ignore group chat, from Imprudence
This commit is contained in:
@@ -3654,6 +3654,8 @@ void LLAppViewer::idleShutdown()
|
||||
// close IM interface
|
||||
if(gIMMgr)
|
||||
{
|
||||
// Save group chat ignore list -- MC
|
||||
gIMMgr->saveIgnoreGroup();
|
||||
gIMMgr->disconnectAllSessions();
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
@@ -605,6 +606,30 @@ void LLIMMgr::addMessage(
|
||||
// create IM window as necessary
|
||||
if(!floater)
|
||||
{
|
||||
if (gIMMgr->getIgnoreGroupListCount() > 0 && gAgent.isInGroup(session_id))
|
||||
{
|
||||
// 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<LLGroupData>::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 && gIMMgr->getIgnoreGroup(group_data->mID))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::string name = from;
|
||||
if(!session_name.empty() && session_name.size()>1)
|
||||
{
|
||||
@@ -1286,6 +1311,111 @@ void LLIMMgr::updateFloaterSessionID(
|
||||
}
|
||||
}
|
||||
|
||||
void LLIMMgr::loadIgnoreGroup()
|
||||
{
|
||||
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 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 << "can't load " << filename
|
||||
// << " (probably it doesn't exist yet)" << llendl;
|
||||
}
|
||||
}
|
||||
|
||||
void LLIMMgr::saveIgnoreGroup()
|
||||
{
|
||||
// llinfos << "saving ignore_groups.xml" << llendl;
|
||||
|
||||
std::string user_dir = gDirUtilp->getLindenUserDir();
|
||||
if (!user_dir.empty())
|
||||
{
|
||||
std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "ignore_groups.xml");
|
||||
|
||||
LLSD settings_llsd = LLSD::emptyArray();
|
||||
|
||||
for(std::list<LLUUID>::iterator iter = mIgnoreGroupList.begin();
|
||||
iter != mIgnoreGroupList.end(); ++iter)
|
||||
{
|
||||
settings_llsd.append(*iter);
|
||||
}
|
||||
|
||||
llofstream file;
|
||||
file.open(filename);
|
||||
LLSDSerialize::toPrettyXML(settings_llsd, file);
|
||||
}
|
||||
}
|
||||
|
||||
void LLIMMgr::updateIgnoreGroup(const LLUUID& group_id, bool ignore)
|
||||
{
|
||||
if (group_id.notNull())
|
||||
{
|
||||
std::list<LLUUID>::iterator found =
|
||||
std::find( mIgnoreGroupList.begin(), mIgnoreGroupList.end(),
|
||||
group_id);
|
||||
|
||||
if (found != mIgnoreGroupList.end() && !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
|
||||
{
|
||||
// nothing to do
|
||||
// llinfos << "no change to group " << group_id << ", it is already "
|
||||
// << (ignore ? "" : "not ") << "ignored" << llendl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool LLIMMgr::getIgnoreGroup(const LLUUID& group_id)
|
||||
{
|
||||
if (group_id.notNull())
|
||||
{
|
||||
std::list<LLUUID>::iterator found =
|
||||
std::find( mIgnoreGroupList.begin(), mIgnoreGroupList.end(),
|
||||
group_id);
|
||||
|
||||
if (found != mIgnoreGroupList.end())
|
||||
{
|
||||
// llinfos << "group " << group_id << " is ignored." << llendl;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// llinfos << "group " << group_id << " is not ignored." << llendl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////
|
||||
///// ChatterBox /////
|
||||
//////////////////////
|
||||
|
||||
|
||||
LLFloaterChatterBox* LLIMMgr::getFloater()
|
||||
{
|
||||
return LLFloaterChatterBox::getInstance(LLSD());
|
||||
|
||||
@@ -172,6 +172,12 @@ public:
|
||||
//HACK: need a better way of enumerating existing session, or listening to session create/destroy events
|
||||
const std::set<LLHandle<LLFloater> >& getIMFloaterHandles() { return mFloaters; }
|
||||
|
||||
void loadIgnoreGroup();
|
||||
void saveIgnoreGroup();
|
||||
void updateIgnoreGroup(const LLUUID& group_id, 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,12 @@ private:
|
||||
|
||||
LLSD mPendingInvitations;
|
||||
LLSD mPendingAgentListUpdates;
|
||||
|
||||
std::list<LLUUID> mIgnoreGroupList;
|
||||
|
||||
public:
|
||||
|
||||
S32 getIgnoreGroupListCount() { return mIgnoreGroupList.size(); }
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include "llcheckboxctrl.h"
|
||||
#include "llcombobox.h"
|
||||
#include "lldbstrings.h"
|
||||
#include "llimview.h"
|
||||
#include "lllineeditor.h"
|
||||
#include "llnamebox.h"
|
||||
#include "llnamelistctrl.h"
|
||||
@@ -91,6 +92,7 @@ LLPanelGroupGeneral::LLPanelGroupGeneral(const std::string& name,
|
||||
mCtrlEnrollmentFee(NULL),
|
||||
mSpinEnrollmentFee(NULL),
|
||||
mCtrlReceiveNotices(NULL),
|
||||
mCtrlReceiveChat(NULL),
|
||||
mCtrlListGroup(NULL),
|
||||
mActiveTitleLabel(NULL),
|
||||
mComboActiveTitle(NULL)
|
||||
@@ -219,6 +221,15 @@ BOOL LLPanelGroupGeneral::postBuild()
|
||||
mCtrlReceiveNotices->set(accept_notices);
|
||||
mCtrlReceiveNotices->setEnabled(data.mID.notNull());
|
||||
}
|
||||
|
||||
mCtrlReceiveChat = getChild<LLCheckBoxCtrl>("receive_chat", recurse);
|
||||
if (mCtrlReceiveChat)
|
||||
{
|
||||
mCtrlReceiveChat->setCommitCallback(onCommitUserOnly);
|
||||
mCtrlReceiveChat->setCallbackUserData(this);
|
||||
mCtrlReceiveChat->set(!gIMMgr->getIgnoreGroup(mGroupID));
|
||||
mCtrlReceiveChat->setEnabled(mGroupID.notNull());
|
||||
}
|
||||
|
||||
mCtrlListGroup = getChild<LLCheckBoxCtrl>("list_groups_in_profile", recurse);
|
||||
if (mCtrlListGroup)
|
||||
@@ -544,6 +555,14 @@ bool LLPanelGroupGeneral::apply(std::string& mesg)
|
||||
|
||||
gAgent.setUserGroupFlags(mGroupID, receive_notices, list_in_profile);
|
||||
|
||||
if (mCtrlReceiveChat)
|
||||
{
|
||||
bool 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;
|
||||
@@ -760,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);
|
||||
@@ -914,6 +940,7 @@ void LLPanelGroupGeneral::updateChanged()
|
||||
mCtrlEnrollmentFee,
|
||||
mSpinEnrollmentFee,
|
||||
mCtrlReceiveNotices,
|
||||
mCtrlReceiveChat,
|
||||
mCtrlListGroup,
|
||||
mActiveTitleLabel,
|
||||
mComboActiveTitle
|
||||
|
||||
@@ -107,6 +107,7 @@ private:
|
||||
LLCheckBoxCtrl *mCtrlEnrollmentFee;
|
||||
LLSpinCtrl *mSpinEnrollmentFee;
|
||||
LLCheckBoxCtrl *mCtrlReceiveNotices;
|
||||
LLCheckBoxCtrl *mCtrlReceiveChat;
|
||||
LLCheckBoxCtrl *mCtrlListGroup;
|
||||
LLTextBox *mActiveTitleLabel;
|
||||
LLComboBox *mComboActiveTitle;
|
||||
|
||||
@@ -119,6 +119,7 @@
|
||||
#include "llhudmanager.h"
|
||||
#include "llhttpclient.h"
|
||||
#include "llimagebmp.h"
|
||||
#include "llimview.h" // for gIMMgr
|
||||
#include "llinventorymodel.h"
|
||||
#include "llinventoryview.h"
|
||||
#include "llkeyboard.h"
|
||||
@@ -1833,6 +1834,8 @@ bool idle_startup()
|
||||
// OGPX : successful login path common to OGP and XML-RPC
|
||||
if (successful_login)
|
||||
{
|
||||
gIMMgr->loadIgnoreGroup();
|
||||
|
||||
// JC: gesture loading done below, when we have an asset system
|
||||
// in place. Don't delete/clear user_credentials until then.
|
||||
|
||||
|
||||
@@ -137,6 +137,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" />
|
||||
<check_box bottom_delta="-18" follows="left|top" font="SansSerifSmall" height="16"
|
||||
initial_value="false" label="Join group chat" left_delta="0"
|
||||
mouse_opaque="true" name="receive_chat" radio_style="false"
|
||||
tool_tip="Sets whether you want to participate in group chat. Uncheck this box if this group is spamming you."
|
||||
width="95" />
|
||||
<check_box bottom_delta="-18" follows="left|top" font="SansSerifSmall" height="16"
|
||||
initial_value="false" label="List group in my profile" left_delta="0"
|
||||
mouse_opaque="true" name="list_groups_in_profile" radio_style="false"
|
||||
|
||||
Reference in New Issue
Block a user