#ifndef CSMSDATABASE_H
#define CSMSDATABASE_H


#include "SMSConversation.h"
#include "SMSMessage.h"
#include "ContactRepository.h"
#include <QList>
#include <QHash>

class CSMSClient;


class CSMSDatabase
{
public:
    enum eNewMessageReadStatus
    {
        DB_NEW_MSG_READ,
        DB_NEW_MSG_UNREAD
    };

    CSMSDatabase();
    ~CSMSDatabase();

    CSMSClient *mProgramHandle;
    CContactRepository *mContactRepository;

    QList<CSMSConversation*> mConversations;
    QString mClientDID, mFormattedDID;

    QHash<QString,int> mContactsHash;
    int mNbUnreadMessages;

    int SetAllMessages(QString DID, QList<CSMSMessage> *MessagesList);
    int SetNewMessages(QString DID, QList<CSMSMessage> *MessagesList);
    int SetDID(QString DID);
    int SetConversationAsRead(CSMSConversation* Conversation, bool ForceAll = false);
    int ContactsRepositoryChanged();

    QList<CSMSConversation *> *GetConversations(QString DID = "");
    CSMSConversation* GetConversation(QString Contact);
    QString GetDID(){return mClientDID;}
    QString GetFormattedDID(){return mFormattedDID;}
    int GetNbUnreadMsgs(){return mNbUnreadMessages;}

//    bool SortConversations();


};

#endif // CSMSDATABASE_H
