#ifndef QT_WAYLAND_IVI_CONTROLLER
#define QT_WAYLAND_IVI_CONTROLLER

#include "wayland-ivi-controller-client-protocol.h"
#include <QByteArray>
#include <QString>

struct wl_registry;

QT_BEGIN_NAMESPACE
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wmissing-field-initializers")

namespace QtWayland {
    class  ivi_controller_surface
    {
    public:
        ivi_controller_surface(struct ::wl_registry *registry, int id, int version);
        ivi_controller_surface(struct ::ivi_controller_surface *object);
        ivi_controller_surface();

        virtual ~ivi_controller_surface();

        void init(struct ::wl_registry *registry, int id, int version);
        void init(struct ::ivi_controller_surface *object);

        struct ::ivi_controller_surface *object() { return m_ivi_controller_surface; }
        const struct ::ivi_controller_surface *object() const { return m_ivi_controller_surface; }
        static ivi_controller_surface *fromObject(struct ::ivi_controller_surface *object);

        bool isInitialized() const;

        static const struct ::wl_interface *interface();

        enum orientation {
            orientation_0_degrees = 0, // not rotated
            orientation_90_degrees = 1, // rotated 90 degrees clockwise
            orientation_180_degrees = 2, // rotated 180 degrees clockwise
            orientation_270_degrees = 3 // rotated 270 degrees clockwise
        };

        enum pixelformat {
            pixelformat_r_8 = 0, // 8 bit luminance surface
            pixelformat_rgb_888 = 1, // 24 bit rgb surface
            pixelformat_rgba_8888 = 2, // 24 bit rgb surface with 8 bit alpha
            pixelformat_rgb_565 = 3, // 16 bit rgb surface
            pixelformat_rgba_5551 = 4, // 16 bit rgb surface with binary mask
            pixelformat_rgba_6661 = 5, // 18 bit rgb surface with binary mask
            pixelformat_rgba_4444 = 6, // 12 bit rgb surface with 4 bit alpha
            pixelformat_unknown = 7 // unknown
        };

        enum content_state {
            content_state_content_available = 1, // application provided wl_surface for this surface
            content_state_content_removed = 2 // wl_surface was removed for this surface
        };

        void set_visibility(uint32_t visibility);
        void set_opacity(wl_fixed_t opacity);
        void set_source_rectangle(int32_t x, int32_t y, int32_t width, int32_t height);
        void set_destination_rectangle(int32_t x, int32_t y, int32_t width, int32_t height);
        void set_configuration(int32_t width, int32_t height);
        void set_orientation(int32_t orientation);
        void screenshot(const QString &filename);
        void send_stats();
        void destroy(int32_t destroy_scene_object);

    protected:
        virtual void ivi_controller_surface_visibility(int32_t visibility);
        virtual void ivi_controller_surface_opacity(wl_fixed_t opacity);
        virtual void ivi_controller_surface_source_rectangle(int32_t x, int32_t y, int32_t width, int32_t height);
        virtual void ivi_controller_surface_destination_rectangle(int32_t x, int32_t y, int32_t width, int32_t height);
        virtual void ivi_controller_surface_configuration(int32_t width, int32_t height);
        virtual void ivi_controller_surface_orientation(int32_t orientation);
        virtual void ivi_controller_surface_pixelformat(int32_t pixelformat);
        virtual void ivi_controller_surface_layer(struct ::ivi_controller_layer *layer);
        virtual void ivi_controller_surface_stats(uint32_t redraw_count, uint32_t frame_count, uint32_t update_count, uint32_t pid, const QString &process_name);
        virtual void ivi_controller_surface_destroyed();
        virtual void ivi_controller_surface_content(int32_t content_state);

    private:
        void init_listener();
        static const struct ivi_controller_surface_listener m_ivi_controller_surface_listener;
        static void handle_visibility(
            void *data,
            struct ::ivi_controller_surface *object,
            int32_t visibility);
        static void handle_opacity(
            void *data,
            struct ::ivi_controller_surface *object,
            wl_fixed_t opacity);
        static void handle_source_rectangle(
            void *data,
            struct ::ivi_controller_surface *object,
            int32_t x,
            int32_t y,
            int32_t width,
            int32_t height);
        static void handle_destination_rectangle(
            void *data,
            struct ::ivi_controller_surface *object,
            int32_t x,
            int32_t y,
            int32_t width,
            int32_t height);
        static void handle_configuration(
            void *data,
            struct ::ivi_controller_surface *object,
            int32_t width,
            int32_t height);
        static void handle_orientation(
            void *data,
            struct ::ivi_controller_surface *object,
            int32_t orientation);
        static void handle_pixelformat(
            void *data,
            struct ::ivi_controller_surface *object,
            int32_t pixelformat);
        static void handle_layer(
            void *data,
            struct ::ivi_controller_surface *object,
            struct ::ivi_controller_layer *layer);
        static void handle_stats(
            void *data,
            struct ::ivi_controller_surface *object,
            uint32_t redraw_count,
            uint32_t frame_count,
            uint32_t update_count,
            uint32_t pid,
            const char *process_name);
        static void handle_destroyed(
            void *data,
            struct ::ivi_controller_surface *object);
        static void handle_content(
            void *data,
            struct ::ivi_controller_surface *object,
            int32_t content_state);
        struct ::ivi_controller_surface *m_ivi_controller_surface;
    };

    class  ivi_controller_layer
    {
    public:
        ivi_controller_layer(struct ::wl_registry *registry, int id, int version);
        ivi_controller_layer(struct ::ivi_controller_layer *object);
        ivi_controller_layer();

        virtual ~ivi_controller_layer();

        void init(struct ::wl_registry *registry, int id, int version);
        void init(struct ::ivi_controller_layer *object);

        struct ::ivi_controller_layer *object() { return m_ivi_controller_layer; }
        const struct ::ivi_controller_layer *object() const { return m_ivi_controller_layer; }
        static ivi_controller_layer *fromObject(struct ::ivi_controller_layer *object);

        bool isInitialized() const;

        static const struct ::wl_interface *interface();

        void set_visibility(uint32_t visibility);
        void set_opacity(wl_fixed_t opacity);
        void set_source_rectangle(int32_t x, int32_t y, int32_t width, int32_t height);
        void set_destination_rectangle(int32_t x, int32_t y, int32_t width, int32_t height);
        void set_configuration(int32_t width, int32_t height);
        void set_orientation(int32_t orientation);
        void screenshot(const QString &filename);
        void clear_surfaces();
        void add_surface(struct ::ivi_controller_surface *surface);
        void remove_surface(struct ::ivi_controller_surface *surface);
        void set_render_order(const QByteArray &id_surfaces);
        void destroy(int32_t destroy_scene_object);

    protected:
        virtual void ivi_controller_layer_visibility(int32_t visibility);
        virtual void ivi_controller_layer_opacity(wl_fixed_t opacity);
        virtual void ivi_controller_layer_source_rectangle(int32_t x, int32_t y, int32_t width, int32_t height);
        virtual void ivi_controller_layer_destination_rectangle(int32_t x, int32_t y, int32_t width, int32_t height);
        virtual void ivi_controller_layer_configuration(int32_t width, int32_t height);
        virtual void ivi_controller_layer_orientation(int32_t orientation);
        virtual void ivi_controller_layer_screen(struct ::wl_output *screen);
        virtual void ivi_controller_layer_destroyed();

    private:
        void init_listener();
        static const struct ivi_controller_layer_listener m_ivi_controller_layer_listener;
        static void handle_visibility(
            void *data,
            struct ::ivi_controller_layer *object,
            int32_t visibility);
        static void handle_opacity(
            void *data,
            struct ::ivi_controller_layer *object,
            wl_fixed_t opacity);
        static void handle_source_rectangle(
            void *data,
            struct ::ivi_controller_layer *object,
            int32_t x,
            int32_t y,
            int32_t width,
            int32_t height);
        static void handle_destination_rectangle(
            void *data,
            struct ::ivi_controller_layer *object,
            int32_t x,
            int32_t y,
            int32_t width,
            int32_t height);
        static void handle_configuration(
            void *data,
            struct ::ivi_controller_layer *object,
            int32_t width,
            int32_t height);
        static void handle_orientation(
            void *data,
            struct ::ivi_controller_layer *object,
            int32_t orientation);
        static void handle_screen(
            void *data,
            struct ::ivi_controller_layer *object,
            struct ::wl_output *screen);
        static void handle_destroyed(
            void *data,
            struct ::ivi_controller_layer *object);
        struct ::ivi_controller_layer *m_ivi_controller_layer;
    };

    class  ivi_controller_screen
    {
    public:
        ivi_controller_screen(struct ::wl_registry *registry, int id, int version);
        ivi_controller_screen(struct ::ivi_controller_screen *object);
        ivi_controller_screen();

        virtual ~ivi_controller_screen();

        void init(struct ::wl_registry *registry, int id, int version);
        void init(struct ::ivi_controller_screen *object);

        struct ::ivi_controller_screen *object() { return m_ivi_controller_screen; }
        const struct ::ivi_controller_screen *object() const { return m_ivi_controller_screen; }
        static ivi_controller_screen *fromObject(struct ::ivi_controller_screen *object);

        bool isInitialized() const;

        static const struct ::wl_interface *interface();

        void destroy();
        void clear();
        void add_layer(struct ::ivi_controller_layer *layer);
        void screenshot(const QString &filename);
        void set_render_order(const QByteArray &id_layers);

    private:
        struct ::ivi_controller_screen *m_ivi_controller_screen;
    };

    class  ivi_controller
    {
    public:
        ivi_controller(struct ::wl_registry *registry, int id, int version);
        ivi_controller(struct ::ivi_controller *object);
        ivi_controller();

        virtual ~ivi_controller();

        void init(struct ::wl_registry *registry, int id, int version);
        void init(struct ::ivi_controller *object);

        struct ::ivi_controller *object() { return m_ivi_controller; }
        const struct ::ivi_controller *object() const { return m_ivi_controller; }
        static ivi_controller *fromObject(struct ::ivi_controller *object);

        bool isInitialized() const;

        static const struct ::wl_interface *interface();

        enum object_type {
            object_type_surface = 1, // surface object type
            object_type_layer = 2, // layer object type
            object_type_screen = 3 // screen object type
        };

        enum error_code {
            error_code_unknown_error = 1, // unknown error encountered
            error_code_file_error = 2 // file i/o error encountered
        };

        void commit_changes();
        struct ::ivi_controller_layer *layer_create(uint32_t id_layer, int32_t width, int32_t height);
        struct ::ivi_controller_surface *surface_create(uint32_t id_surface);

    protected:
        virtual void ivi_controller_screen(uint32_t id_screen, struct ::ivi_controller_screen *screen);
        virtual void ivi_controller_layer(uint32_t id_layer);
        virtual void ivi_controller_surface(uint32_t id_surface);
        virtual void ivi_controller_error(int32_t object_id, int32_t object_type, int32_t error_code, const QString &error_text);

    private:
        void init_listener();
        static const struct ivi_controller_listener m_ivi_controller_listener;
        static void handle_screen(
            void *data,
            struct ::ivi_controller *object,
            uint32_t id_screen,
            struct ::ivi_controller_screen *screen);
        static void handle_layer(
            void *data,
            struct ::ivi_controller *object,
            uint32_t id_layer);
        static void handle_surface(
            void *data,
            struct ::ivi_controller *object,
            uint32_t id_surface);
        static void handle_error(
            void *data,
            struct ::ivi_controller *object,
            int32_t object_id,
            int32_t object_type,
            int32_t error_code,
            const char *error_text);
        struct ::ivi_controller *m_ivi_controller;
    };
}

QT_WARNING_POP
QT_END_NAMESPACE

#endif
