#ifndef MAILSERVICE_H
#define MAILSERVICE_H

#include <QObject>
#include <QVector>
#include <QSslSocket>
#include <QString>
#include "core/mailitem.h"
#include "core/emailcomposerbridge.h"
#include "core/synchronizerprovider.h"
#include "models/account.h"
#include "db/dao/mailitemdao.h"
#include "db/dao/folderdao.h"

class MailService : public QObject
{
    Q_OBJECT
public:
    explicit MailService(QObject *parent = nullptr);
    ~MailService() override = default;

    QVector<MailItem> getMails(const QString &folderId);
    void sendMail(const MailItem &mail, const QString &accountId);
    void fetchMails(const QString &accountId, const QString &folderId);
    void moveMail(const QString &mailItemId, const QString &targetFolderId);
    void deleteMail(const QString &mailItemId);
    void markAsRead(const QString &mailItemId, bool read);

signals:
    void mailSent(const QString &mailItemId);
    void mailSendFailed(const QString &mailItemId, const QString &error);
    void mailFetched(const QString &accountId, const QString &folderId, const QVector<MailItem> &items);
    void mailMoved(const QString &mailItemId);
    void mailDeleted(const QString &mailItemId);
    void mailReadStateChanged(const QString &mailItemId, bool read);

private:
    EmailComposerBridge *m_composer;
};

#endif // MAILSERVICE_H
