#ifndef DCANTISPAM_H
#define DCANTISPAM_H

#include <QObject>
#include <QList>

enum AntiSpamObjectState{
    eIN_BLACK=0,
    eIN_GRAY,
    eIN_WHITE
};

class DCAntiSpam : public QObject
{
    Q_OBJECT

public:
    DCAntiSpam();
    virtual ~DCAntiSpam();

    bool isInBlack(QString);
    bool isInWhite(QString);
    bool isInGray (QString);
    bool isInAny  (QString);

    void move(QString, AntiSpamObjectState);

    void addToBlack(QList<QString> &list);
    void addToWhite(QList<QString> &list);
    void addToGray (QList<QString> &list);
    void remFromBlack(QList<QString> &list);
    void remFromWhite(QList<QString> &list);
    void remFromGray (QList<QString> &list);
    void clearBlack();
    void clearGray();
    void clearWhite();
    void clearAll();

    QList<QString> getBlack();
    QList<QString> getGray();
    QList<QString> getWhite();

    void loadSettings();
    void saveSettings();
    void loadLists();
    void saveLists();

    QString getPhrase() const;
    void    setPhrase(QString &phrase);
    QString getKey() const;
    void    setKey(QString &key);

private:

    inline void addToList  (QList<QString>&, QList<QString>&);
    inline void remFromList(QList<QString>&, QList<QString>&);

    void loadBlack();
    void loadWhite();
    void loadGray();
    void saveBlack();
    void saveWhite();
    void saveGray();


    void readFile(QString, QList<QString>&);
    void saveFile(QString, QList<QString>&);

    QList<QString> white_list, black_list, gray_list;

    QString phrase, key;

public slots:

    /** */
    void slotObjectChangeState(QString obj, AntiSpamObjectState from, AntiSpamObjectState to);

};

extern DCAntiSpam *g_pAntiSpam;

#endif // DCANTISPAM_H
