Beispiel #1
0
bool ChatFilterPage::addChatFilter(const string& aNick, const string& aText, StringMatch::Method aNickMethod, StringMatch::Method aTextMethod, bool aMainChat, bool aPM) {
	auto i = find_if(ChatFilterItems.begin(), ChatFilterItems.end(), [aNick, aText](const ChatFilterItem& s) {
		return ((s.getNickPattern().empty() || compare(s.getNickPattern(), aNick) == 0) && (s.getTextPattern().empty() || compare(s.getTextPattern(), aText) == 0));
	});
	if (i == ChatFilterItems.end()){
		ChatFilterItems.push_back(ChatFilterItem(aNick, aText, aNickMethod, aTextMethod, aMainChat, aPM));
		return true;
	}
	return false;
}
Beispiel #2
0
void MessageManager::load(SimpleXML& aXml) {

    if (aXml.findChild("ChatFilterItems")) {
        aXml.stepIn();
        while (aXml.findChild("ChatFilterItem")) {
            WLock l(Ignorecs);
            ChatFilterItems.push_back(ChatFilterItem(aXml.getChildAttrib("Nick"), aXml.getChildAttrib("Text"),
                                      (StringMatch::Method)aXml.getIntChildAttrib("NickMethod"), (StringMatch::Method)aXml.getIntChildAttrib("TextMethod"),
                                      aXml.getBoolChildAttrib("MC"), aXml.getBoolChildAttrib("PM"), aXml.getBoolChildAttrib("Enabled")));
        }
        aXml.stepOut();
    }
    loadUsers();
}
Beispiel #3
0
LRESULT ChatFilterPage::onChatFilterEdit(WORD /* wNotifyCode */, WORD /*wID*/, HWND /* hWndCtl */, BOOL& /* bHandled */) {
	int sel = ChatFilterListCtrl.GetSelectedIndex();
	if (sel == -1)
		return 0;

	auto olditem = getChatFilter(sel);
	bool enable = ChatFilterListCtrl.GetCheckState(sel) ? true : false;
	ChatFilterDlg dlg(olditem.getNickPattern(), olditem.getTextPattern(), olditem.getNickMethod(), olditem.getTextMethod(), olditem.matchMainchat, olditem.matchPM);
	if (dlg.DoModal() == IDOK) {
		auto newitem = ChatFilterItem(dlg.nick, dlg.text, dlg.nickMethod, dlg.textMethod, dlg.MC, dlg.PM, enable);
		updateChatFilter(newitem, sel);
		ChatFilterListCtrl.SetItemText(sel, 1, Text::toT(dlg.nick).c_str());
		ChatFilterListCtrl.SetItemText(sel, 2, Text::toT(dlg.text).c_str());
		ChatFilterListCtrl.SetItemText(sel, 3, dlg.MC ? CTSTRING(YES) : CTSTRING(NO));
		ChatFilterListCtrl.SetItemText(sel, 4, dlg.PM ? CTSTRING(YES) : CTSTRING(NO));
	}

	return 0;
}