1 /* 2 * %kadu copyright begin% 3 * Copyright 2013 Bartosz Brachaczek (b.brachaczek@gmail.com) 4 * Copyright 2011, 2013 Rafał Przemysław Malinowski (rafal.przemyslaw.malinowski@gmail.com) 5 * %kadu copyright end% 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License as 9 * published by the Free Software Foundation; either version 2 of 10 * the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 #include "chat/chat.h" 22 #include "contacts/contact-set.h" 23 #include "contacts/contact.h" 24 25 #include "account-talkable-filter.h" 26 AccountTalkableFilter(QObject * parent)27AccountTalkableFilter::AccountTalkableFilter(QObject *parent) : 28 TalkableFilter(parent) 29 { 30 } 31 ~AccountTalkableFilter()32AccountTalkableFilter::~AccountTalkableFilter() 33 { 34 } 35 filterChat(const Chat & chat)36TalkableFilter::FilterResult AccountTalkableFilter::filterChat(const Chat &chat) 37 { 38 if (FilterAccount && chat.chatAccount() == FilterAccount) 39 return Undecided; 40 else 41 return Rejected; 42 } 43 filterBuddy(const Buddy & buddy)44TalkableFilter::FilterResult AccountTalkableFilter::filterBuddy(const Buddy &buddy) 45 { 46 if (FilterAccount && buddy.hasContact(FilterAccount)) 47 return Undecided; 48 else 49 return Rejected; 50 } 51 filterContact(const Contact & contact)52TalkableFilter::FilterResult AccountTalkableFilter::filterContact(const Contact &contact) 53 { 54 if (FilterAccount && contact.contactAccount() == FilterAccount) 55 return Undecided; 56 else 57 return Rejected; 58 } 59 setAccount(const Account & filterAccount)60void AccountTalkableFilter::setAccount(const Account &filterAccount) 61 { 62 if (FilterAccount == filterAccount) 63 return; 64 65 FilterAccount = filterAccount; 66 emit filterChanged(); 67 } 68 69 #include "moc_account-talkable-filter.cpp" 70