#pragma once

#include "fsearch_array.h"
#include "fsearch_database_index_properties.h"

typedef enum {
    FSEARCH_DATABASE_INDEX_EVENT_SCAN_STARTED,
    FSEARCH_DATABASE_INDEX_EVENT_SCAN_FINISHED,
    FSEARCH_DATABASE_INDEX_EVENT_MONITORING_STARTED,
    FSEARCH_DATABASE_INDEX_EVENT_MONITORING_FINISHED,
    FSEARCH_DATABASE_INDEX_EVENT_ENTRY_CREATED,
    FSEARCH_DATABASE_INDEX_EVENT_ENTRY_DELETED,
    FSEARCH_DATABASE_INDEX_EVENT_SCANNING,
    NUM_FSEARCH_DATABASE_INDEX_EVENTS,
} FsearchDatabaseIndexEventKind;

typedef struct {
    FsearchDatabaseIndexEventKind kind;

    union {
        struct {
            DynamicArray *folders;
            DynamicArray *files;
            FsearchDatabaseIndexPropertyFlags affected_sort_orders;
            bool marked;
        } entries;

        char *path;
    };
} FsearchDatabaseIndexEvent;

FsearchDatabaseIndexEvent *
fsearch_database_index_event_new(FsearchDatabaseIndexEventKind kind,
                                 DynamicArray *folders,
                                 DynamicArray *files,
                                 const char *path,
                                 FsearchDatabaseIndexPropertyFlags affected_sort_orders,
                                 bool marked);

void
fsearch_database_index_event_free(FsearchDatabaseIndexEvent *event);

G_DEFINE_AUTOPTR_CLEANUP_FUNC(FsearchDatabaseIndexEvent, fsearch_database_index_event_free);