#ifndef RKTWEBVIEW_H
#define RKTWEBVIEW_H

#include "rktwebview_global.h"
#include "rktwebview_types.h"

#define RKT_WEBVIEW_API_MAJOR 0
#define RKT_WEBVIEW_API_MINOR 3
#define RKT_WEBVIEW_API_PATCH 1

extern "C" {

RKTWEBVIEW_EXPORT void rkt_webview_env(const char *env_cmds[]);
RKTWEBVIEW_EXPORT void rkt_webview_init(const char *from);
RKTWEBVIEW_EXPORT void rkt_webview_cleanup();
RKTWEBVIEW_EXPORT void rkt_webview_exit_done(int done);
RKTWEBVIEW_EXPORT int rkt_webview_register_evt_callback(void (*f)(int));

RKTWEBVIEW_EXPORT void rkt_webview_set_loglevel(rkt_webview_loglevel_t l);
RKTWEBVIEW_EXPORT rkt_data_t *rkt_webview_info();

RKTWEBVIEW_EXPORT void rkt_webview_free_data(rkt_data_t *d);
RKTWEBVIEW_EXPORT rkt_data_t *rkt_webview_version();

RKTWEBVIEW_EXPORT int rkt_webview_events_waiting();
RKTWEBVIEW_EXPORT rkt_data_t *rkt_webview_get_event();

RKTWEBVIEW_EXPORT rkt_wv_context_t rkt_webview_new_context(const char *boilerplate_js, const char *optional_server_cert_pem);
RKTWEBVIEW_EXPORT int rkt_webview_create(rkt_wv_context_t context, rktwebview_t parent);

RKTWEBVIEW_EXPORT void rkt_webview_close(rktwebview_t wv);
RKTWEBVIEW_EXPORT bool rkt_webview_valid(rktwebview_t wv);
RKTWEBVIEW_EXPORT result_t rkt_webview_set_title(rktwebview_t wv, const char *title);
RKTWEBVIEW_EXPORT result_t rkt_webview_set_icon(rktwebview_t wv, const char *icon_file);
RKTWEBVIEW_EXPORT void rkt_webview_set_ou_token(rktwebview_t wv, const char *token);

RKTWEBVIEW_EXPORT result_t rkt_webview_set_url(rktwebview_t wv, const char *url);
RKTWEBVIEW_EXPORT result_t rkt_webview_set_html(rktwebview_t wv, const char *html);

RKTWEBVIEW_EXPORT result_t rkt_webview_run_js(rktwebview_t wv, const char *js);
RKTWEBVIEW_EXPORT rkt_data_t *rkt_webview_call_js(rktwebview_t wv, const char *js);

RKTWEBVIEW_EXPORT result_t rkt_webview_open_devtools(rktwebview_t wv);

RKTWEBVIEW_EXPORT result_t rkt_webview_move(rktwebview_t w, int x, int y);
RKTWEBVIEW_EXPORT result_t rkt_webview_resize(rktwebview_t w, int width, int height);
RKTWEBVIEW_EXPORT result_t rkt_webview_hide(rktwebview_t w);
RKTWEBVIEW_EXPORT result_t rkt_webview_show(rktwebview_t w);
RKTWEBVIEW_EXPORT result_t rkt_webview_show_normal(rktwebview_t w);
RKTWEBVIEW_EXPORT result_t rkt_webview_present(rktwebview_t w);
RKTWEBVIEW_EXPORT result_t rkt_webview_maximize(rktwebview_t w);
RKTWEBVIEW_EXPORT result_t rkt_webview_minimize(rktwebview_t w);
RKTWEBVIEW_EXPORT window_state_t rkt_webview_window_state(rktwebview_t w);

RKTWEBVIEW_EXPORT result_t rkt_webview_choose_dir(rktwebview_t w, const char *title, const char *base_dir);
RKTWEBVIEW_EXPORT result_t rkt_webview_file_open(rktwebview_t w, const char *title, const char *base_dir, const char *permitted_exts);
RKTWEBVIEW_EXPORT result_t rkt_webview_file_save(rktwebview_t w, const char *title, const char *base_dir, const char *permitted_exts);

RKTWEBVIEW_EXPORT result_t rkt_webview_message_box(rktwebview_t w, const char *title, const char *message, const char *submessage, rkt_messagetype_t type);

// Tray Icon functions (note, also hide/show/close can be used).
RKTWEBVIEW_EXPORT rktwebview_t rkt_webview_tray_create(const char *icon_file, const char *tooltip);
RKTWEBVIEW_EXPORT result_t rkt_webview_tray_set_icon(rktwebview_t tray, const char *icon_file);
RKTWEBVIEW_EXPORT result_t rkt_webview_tray_set_tooltip(rktwebview_t tray, const char *tooltip);
RKTWEBVIEW_EXPORT result_t rkt_webview_tray_show_message(rktwebview_t tray, const char *title, const char *message);
RKTWEBVIEW_EXPORT result_t rkt_webview_tray_set_menu(rktwebview_t tray, const char *menu_json);

}

#endif // RKTWEBVIEW_H
