#ifndef SBK_ITEMCOPYJOBWRAPPER_H
#define SBK_ITEMCOPYJOBWRAPPER_H

// Workaround to access protected functions
#ifndef protected
#  define protected public
#endif

#include <itemcopyjob.h>

#include <sbkpython.h>

#include <array>
namespace Shiboken { struct AutoDecRef; class GilState; }

namespace PySide { class DynamicQMetaObject; }

class ItemCopyJobWrapper : public Akonadi::ItemCopyJob
{
public:
    ItemCopyJobWrapper(const ::Akonadi::Item & item, const ::Akonadi::Collection & target, ::QObject * parent = nullptr);
    ItemCopyJobWrapper(const ::QList<Akonadi::Item> & items, const ::Akonadi::Collection & target, ::QObject * parent = nullptr);
    ItemCopyJobWrapper(const ItemCopyJobWrapper &) = delete;
    ItemCopyJobWrapper& operator=(const ItemCopyJobWrapper &) = delete;
    ItemCopyJobWrapper(ItemCopyJobWrapper &&) = delete;
    ItemCopyJobWrapper& operator=(ItemCopyJobWrapper &&) = delete;
    ~ItemCopyJobWrapper() override;

    bool addSubjob(::KJob * job) override;
    void childEvent(::QChildEvent * event) override;
    void connectNotify(const ::QMetaMethod & signal) override;
    void customEvent(::QEvent * event) override;
    void disconnectNotify(const ::QMetaMethod & signal) override;
    bool doKill() override;
    bool doResume() override;
    void doStart() override;
    bool doSuspend() override;
    bool event(::QEvent * event) override;
    bool eventFilter(::QObject * watched, ::QEvent * event) override;
    bool removeSubjob(::KJob * job) override;
    void slotInfoMessage(::KJob * job, const ::QString & message) override;
    void slotResult(::KJob * job) override;
    void start() override;
    void timerEvent(::QTimerEvent * event) override;

    const ::QMetaObject * metaObject() const override;
    int qt_metacall(QMetaObject::Call call, int id, void **args) override;
    void *qt_metacast(const char *_clname) override;
    static void pysideInitQtMetaTypes();

    void resetPyMethodCache();

private:
    mutable std::array<PyObject *, 16> m_PyMethodCache = {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr};
};

#endif // SBK_ITEMCOPYJOBWRAPPER_H
