1 /* 2 * %kadu copyright begin% 3 * Copyright 2011, 2013, 2014 Rafał Przemysław Malinowski (rafal.przemyslaw.malinowski@gmail.com) 4 * %kadu copyright end% 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef ACCOUNT_TALKABLE_FILTER_H 21 #define ACCOUNT_TALKABLE_FILTER_H 22 23 #include "accounts/account.h" 24 25 #include "talkable/filter/talkable-filter.h" 26 27 /** 28 * @addtogroup Talkable 29 * @{ 30 */ 31 32 /** 33 * @class AccountTalkableFilter 34 * @author Rafał 'Vogel' Malinowski 35 * @short Filter that removes values that do not belong to specified account. 36 * 37 * This filter removes values that do not belong to specified account. Chat and Contacts are removed 38 * if their accounts are different than specified one. Buddy instances are removed if it does not 39 * contain any Contact with given Account. Other items are passed to next filters. 40 */ 41 class AccountTalkableFilter : public TalkableFilter 42 { 43 Q_OBJECT 44 45 Account FilterAccount; 46 47 public: 48 /** 49 * @author Rafał 'Vogel' Malinowski 50 * @short Create new instance of TalkableFilter with given parent. 51 * @param parent QObject parent of new object 52 * 53 * Create new instance of AccountTalkableFilter with given parent. 54 */ 55 explicit AccountTalkableFilter(QObject *parent = nullptr); 56 virtual ~AccountTalkableFilter(); 57 58 virtual FilterResult filterChat(const Chat &chat); 59 virtual FilterResult filterBuddy(const Buddy &buddy); 60 virtual FilterResult filterContact(const Contact &contact); 61 62 public slots: 63 /** 64 * @author Rafał 'Vogel' Malinowski 65 * @short Sets account to filter objects by. 66 * @param filterAccount account to filter objects by 67 * 68 * Sets account to filter objects by. If filterAccount is null then every item will get Rejected result. 69 * If filterAccount is not null then Contact and Chat items that belong to this Account will get Undecided 70 * result. 71 */ 72 void setAccount(const Account &filterAccount); 73 74 }; 75 76 /** 77 * @} 78 */ 79 80 #endif // ACCOUNT_TALKABLE_FILTER_H 81