#ifndef RKTWEBVIEW_TYPES_H
#define RKTWEBVIEW_TYPES_H

extern "C" {

typedef int rktwebview_t;
typedef int rkt_wv_context_t;

typedef struct {
    rktwebview_t wv;
    char        *event;
} rkt_event_t;


typedef enum {
    log_error = 1,
    log_warning = 2,
    log_info = 3,
    log_debug = 4
} rkt_webview_loglevel_t;

typedef enum {
    no_result_yet = -1,
    oke = 0,
    set_html_failed = 1,
    set_navigate_failed = 2,
    eval_js_failed = 3,
    no_devtools_on_platform = 4,
    no_delegate_for_context = 5,
    webview_missing_dependency = 6,
    webview_canceled = 7,
    webview_invalid_state = 8,
    webview_invalid_argument = 9,
    webview_unspecified = 10,
    webview_dispatch_failed = 11,
    move_failed = 12,
    resize_failed = 13,
    choose_dir_failed = 14,
    open_file_failed = 15,
    save_file_failed = 16,
    failed = 17,
    invalid_handle = 18
} result_t;

typedef struct {
    result_t result;
    char    *value;
} rkt_js_result_t;

typedef enum {
    invalid = -1,
    normal = 0,
    minimized = 1,
    maximized = 2,
    hidden = 3,
    normal_active = 16,
    maximized_active = 18
} window_state_t;

typedef enum {
    info = 1,
    error = 2,
    warning = 3,
    yes_no = 4,
    oke_cancel = 5
} rkt_messagetype_t;

typedef struct {
    int api_major;
    int api_minor;
    int api_patch;
} rkt_version_t;

typedef struct {
    int shm_usage;
    int shm_free_depth;
    int shm_free_size;
    int shm_item_depth;
    int shm_item_size;
    double shm_item_usage_factor;
    int open_windows;
    int function_calls;
    int events;
    char *log_file;
} rkt_metrics_t;

typedef enum {
    version = 1,
    event = 2,
    js_result = 3,
    metrics = 4
} rkt_data_kind_t;

typedef struct {
    rkt_data_kind_t kind;
    union {
        rkt_version_t    version;
        rkt_event_t      event;
        rkt_js_result_t  js_result;
        rkt_metrics_t    metrics;
    } data;
} rkt_data_t;

typedef void (*event_cb_t)(rkt_data_t *);

}

#endif // RKTWEBVIEW_TYPES_H
