From bcb704366cb5e333a626c18c308c7e0448a8e69f Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kopete/libkopete/kopeteblacklister.h | 124 +++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 kopete/libkopete/kopeteblacklister.h (limited to 'kopete/libkopete/kopeteblacklister.h') diff --git a/kopete/libkopete/kopeteblacklister.h b/kopete/libkopete/kopeteblacklister.h new file mode 100644 index 00000000..ed3e5566 --- /dev/null +++ b/kopete/libkopete/kopeteblacklister.h @@ -0,0 +1,124 @@ +/* + kopeteblacklister.h - Kopete BlackLister + + Copyright (c) 2004 by Roie Kerstein + + ************************************************************************* + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + ************************************************************************* +*/ + +#ifndef KOPETEBLACKLISTER_H +#define KOPETEBLACKLISTER_H + +#include + +namespace Kopete +{ + +class Contact; + +/** + * @brief Manages the list of blacklisted contacts for an account + * + * This class manages the list of contacts the user wishes + * to ignore permanently. In order to use the this class, there is no need to + * create an instance. Use the @ref Kopete::Account::blackLister() instead. + * + * Keep in mind that this class does not discard messages from blocked + * users - It only manages the list. It is the up to the protocol to + * check whether a user is blocked, and act accordingly. A protocol may + * re-implement @ref Kopete::Account::block() and @ref Kopete::Account::unblock() + * and use @ref Kopete::Account::blackLister() as a persistent list manager + * only, or connect the signals @ref contactAdded() and @ref contactRemoved() + * to its slots. + * + * @sa Kopete::Account::block() Kopete::Account::unblock() + * + * @author Roie Kerstein + */ +class BlackLister : public QObject +{ + Q_OBJECT + +public: + /** + * Create an instance, and read the blacklist from disk if it exists. + * @param protocolId is the ID of the protocol owning accountId + * @param accountId is the ID of the owning Account. + * @param parent The QObject parent for this class. + * @param name The QObject name for this class. + */ + BlackLister( const QString &protocolId, const QString &accountId, QObject *parent = 0, const char *name = 0 ); + ~BlackLister(); + + /** + * \return @c true if @p contact is blocked, @c false otherwise. + */ + bool isBlocked( Contact *contact ); + + /** + * \return @c true if the contact with ID @p contactId is blocked, @c false otherwise. + */ + bool isBlocked( const QString &contactId ); + +public slots: + /** + * Add a contact to the blacklist. + * + * This function emits the @ref contactAdded() signal. + * @param contactId is the ID of the contact to be added to the list. + */ + void addContact( const QString &contactId ); + + /** + * @overload + */ + void addContact( Contact *contact ); + + /** + * \brief Remove a contact from the blacklist. + * + * Removes the contact from the blacklist. + * This function emits the @ref contactRemoved() signal. + * @param contact is the contact to be removed from the list. + */ + void removeContact( Contact *contact ); + + /** + * @overload + */ + void removeContact( const QString &contactId ); + +signals: + /** + * \brief A new contact has been added to the list + * + * Connect to this signal if you want to perform additional actions, + * and you prefer not to derive from this class. + */ + void contactAdded( const QString &contactId ); + + /** + * \brief A contact has been removed from the list + * + * Connect to this signal if you want to perform additional actions, + * and you prefer not to derive from this class. + */ + void contactRemoved( const QString &contactId ); + +private: + void saveToDisk(); + + class Private; + Private *d; +}; + +} + +#endif -- cgit v1.2.1