#pragma once

#include "../synchronizer.h"
#include <QObject>
#include "../../core/eventbus.h"
#include "../../core/models/account.h"
#include "../../core/models/folder.h"
#include "../../core/mailitem.h"

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

    // Synchronizer interface
    bool initialize(const Account& account) override;
    bool syncFolder(const Folder& folder) override;
    QVector<Folder> getFolders() const override;
    QVector<MailItem> fetchMailItems(const QString& folderId, 
                                     qint64 sinceUid = 0) override;
    bool appendMailItem(const QString& folderId, const MailItem& item) override;
    bool updateMailItemFlags(const QString& folderId, 
                            const QString& itemUid,
                            bool read, bool flagged) override;
    bool deleteMailItem(const QString& folderId, 
                       const QString& itemUid) override;

private:
    // Placeholder for IMAP connection state (would use libetpan in reality)
    bool m_connected{false};
    QString m_host;
    quint16 m_port{993};
    QString m_username;
    QString m_password;
    bool m_useSsl{true};
    
    // Helper para generar IDs únicos de eventos
    QString generateEventId() const;
};