commit 8a87398ef98125d596168afe212f4902aad373ff
parent 2d6e6b6055b9db244a7f25c6421b29478d976cbc
Author: Kyle Milz <kmilz@ucalgary.ca>
Date: Fri, 4 Jan 2013 14:35:02 -0700
eet: include generated {c,h} files from geneet
Include the automatically generated files so that geneet.py is not
needed when installing the browser, eliminating 1 build time dependency.
These files will have to be updated with the geneet tool, the idea
though is that not everybody will need to have it.
Diffstat:
4 files changed, 1143 insertions(+), 8 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -3,6 +3,4 @@ viking
javascript.h
*.d
tags
-viking_state.c
-viking_state.h
*.edj
diff --git a/src/Makefile b/src/Makefile
@@ -8,7 +8,7 @@ MAN5 = evirc.5
# Used libraries to get needed CFLAGS and LDFLAGS form pkg-config
LIBS = elementary ewebkit2
# Files to removo by clean target
-CLEAN = $(TARGET) $(OBJ) $(DEPS) javascript.h viking_state.c viking_state.h default.edj
+CLEAN = $(TARGET) $(OBJ) $(DEPS) javascript.h default.edj
# Files to install by install target or remove by uninstall target
MANINSTALL = $(addprefix $(MANDIR)/man1/,$(MAN1)) \
$(addprefix $(MANDIR)/man5/,$(MAN5))
@@ -46,14 +46,10 @@ all: $(TARGET)
-include $(DEPS)
-main.o: javascript.h viking_state.c default.edj
+main.o: javascript.h default.edj
javascript.h: hinting.js
perl ./js-merge-helper.pl
-viking_state.c: viking_state.geneet
- geneet.py viking_state.geneet
- sed -i -e "s/hist_new()/hist_new(void)/" viking_state.h;
-
default.edj: default.edc
edje_cc default.edc
diff --git a/src/viking_state.c b/src/viking_state.c
@@ -0,0 +1,1012 @@
+/* This file has been automatically generated by geneet.py */
+/* DO NOT MODIFY */
+
+#include <limits.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "viking_state.h"
+
+struct _Config {
+ unsigned char allow_popup;
+ unsigned char enable_auto_load_images;
+ unsigned char enable_auto_shrink_images;
+ unsigned char enable_javascript;
+ unsigned char enable_touch_interface;
+ unsigned char enable_history;
+ const char * home_page;
+ const char * proxy;
+ unsigned char restore_state;
+ const char * user_agent;
+ unsigned char frame_flattening;
+ int text_zoom;
+ int minimum_font_size;
+ int cookie_policy;
+ const char *__eet_filename;
+};
+
+struct _Hist_Item {
+ unsigned char enabled;
+ const char * title;
+ const char * url;
+ const char * proto;
+ unsigned int visit_count;
+ double last_visit;
+};
+
+struct _Hist {
+ Eina_Hash * items;
+ const char *__eet_filename;
+};
+
+struct _Session_Item {
+ const char * url;
+ unsigned char focused;
+ int scroll_x;
+ int scroll_y;
+};
+
+struct _Session_Window {
+ Eina_List * tabs;
+ unsigned char focused;
+};
+
+struct _Session {
+ Eina_List * windows;
+ const char *__eet_filename;
+};
+
+static const char CONFIG_ENTRY[] = "config";
+static const char HIST_ITEM_ENTRY[] = "hist_item";
+static const char HIST_ENTRY[] = "hist";
+static const char SESSION_ITEM_ENTRY[] = "session_item";
+static const char SESSION_WINDOW_ENTRY[] = "session_window";
+static const char SESSION_ENTRY[] = "session";
+
+static Eet_Data_Descriptor *_config_descriptor = NULL;
+static Eet_Data_Descriptor *_hist_item_descriptor = NULL;
+static Eet_Data_Descriptor *_hist_descriptor = NULL;
+static Eet_Data_Descriptor *_session_item_descriptor = NULL;
+static Eet_Data_Descriptor *_session_window_descriptor = NULL;
+static Eet_Data_Descriptor *_session_descriptor = NULL;
+
+static inline void
+_config_init(void)
+{
+ Eet_Data_Descriptor_Class eddc;
+
+ if (_config_descriptor) return;
+
+ EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Config);
+ _config_descriptor = eet_data_descriptor_stream_new(&eddc);
+
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "allow_popup", allow_popup, EET_T_UCHAR);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "enable_auto_load_images", enable_auto_load_images, EET_T_UCHAR);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "enable_auto_shrink_images", enable_auto_shrink_images, EET_T_UCHAR);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "enable_javascript", enable_javascript, EET_T_UCHAR);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "enable_touch_interface", enable_touch_interface, EET_T_UCHAR);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "enable_history", enable_history, EET_T_UCHAR);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "home_page", home_page, EET_T_STRING);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "proxy", proxy, EET_T_STRING);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "restore_state", restore_state, EET_T_UCHAR);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "user_agent", user_agent, EET_T_STRING);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "frame_flattening", frame_flattening, EET_T_UCHAR);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "text_zoom", text_zoom, EET_T_INT);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "minimum_font_size", minimum_font_size, EET_T_INT);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "cookie_policy", cookie_policy, EET_T_INT);
+}
+
+static inline void
+_config_shutdown(void)
+{
+ if (!_config_descriptor) return;
+ eet_data_descriptor_free(_config_descriptor);
+ _config_descriptor = NULL;
+}
+
+Config *
+config_new(unsigned char allow_popup, unsigned char enable_auto_load_images, unsigned char enable_auto_shrink_images, unsigned char enable_javascript, unsigned char enable_touch_interface, unsigned char enable_history, const char * home_page, const char * proxy, unsigned char restore_state, const char * user_agent, unsigned char frame_flattening, int text_zoom, int minimum_font_size, int cookie_policy)
+{
+ Config *config = calloc(1, sizeof(Config));
+
+ if (!config)
+ {
+ fprintf(stderr, "ERROR: could not calloc Config\n");
+ return NULL;
+ }
+
+ config->allow_popup = allow_popup;
+ config->enable_auto_load_images = enable_auto_load_images;
+ config->enable_auto_shrink_images = enable_auto_shrink_images;
+ config->enable_javascript = enable_javascript;
+ config->enable_touch_interface = enable_touch_interface;
+ config->enable_history = enable_history;
+ config->home_page = eina_stringshare_add(home_page ? home_page : "http://www.getaddrinfo.net");
+ config->proxy = eina_stringshare_add(proxy);
+ config->restore_state = restore_state;
+ config->user_agent = eina_stringshare_add(user_agent ? user_agent : "chrome");
+ config->frame_flattening = frame_flattening;
+ config->text_zoom = text_zoom;
+ config->minimum_font_size = minimum_font_size;
+ config->cookie_policy = cookie_policy;
+
+ return config;
+}
+
+void
+config_free(Config *config)
+{
+ eina_stringshare_del(config->home_page);
+ eina_stringshare_del(config->proxy);
+ eina_stringshare_del(config->user_agent);
+ free(config);
+}
+
+inline unsigned char
+config_allow_popup_get(const Config *config)
+{
+ return config->allow_popup;
+}
+
+inline void
+config_allow_popup_set(Config *config, unsigned char allow_popup)
+{
+ EINA_SAFETY_ON_NULL_RETURN(config);
+ config->allow_popup = allow_popup;
+}
+
+inline unsigned char
+config_enable_auto_load_images_get(const Config *config)
+{
+ return config->enable_auto_load_images;
+}
+
+inline void
+config_enable_auto_load_images_set(Config *config, unsigned char enable_auto_load_images)
+{
+ EINA_SAFETY_ON_NULL_RETURN(config);
+ config->enable_auto_load_images = enable_auto_load_images;
+}
+
+inline unsigned char
+config_enable_auto_shrink_images_get(const Config *config)
+{
+ return config->enable_auto_shrink_images;
+}
+
+inline void
+config_enable_auto_shrink_images_set(Config *config, unsigned char enable_auto_shrink_images)
+{
+ EINA_SAFETY_ON_NULL_RETURN(config);
+ config->enable_auto_shrink_images = enable_auto_shrink_images;
+}
+
+inline unsigned char
+config_enable_javascript_get(const Config *config)
+{
+ return config->enable_javascript;
+}
+
+inline void
+config_enable_javascript_set(Config *config, unsigned char enable_javascript)
+{
+ EINA_SAFETY_ON_NULL_RETURN(config);
+ config->enable_javascript = enable_javascript;
+}
+
+inline unsigned char
+config_enable_touch_interface_get(const Config *config)
+{
+ return config->enable_touch_interface;
+}
+
+inline void
+config_enable_touch_interface_set(Config *config, unsigned char enable_touch_interface)
+{
+ EINA_SAFETY_ON_NULL_RETURN(config);
+ config->enable_touch_interface = enable_touch_interface;
+}
+
+inline unsigned char
+config_enable_history_get(const Config *config)
+{
+ return config->enable_history;
+}
+
+inline void
+config_enable_history_set(Config *config, unsigned char enable_history)
+{
+ EINA_SAFETY_ON_NULL_RETURN(config);
+ config->enable_history = enable_history;
+}
+
+inline const char *
+config_home_page_get(const Config *config)
+{
+ return config->home_page;
+}
+
+inline void
+config_home_page_set(Config *config, const char *home_page)
+{
+ EINA_SAFETY_ON_NULL_RETURN(config);
+ eina_stringshare_replace(&(config->home_page), home_page);
+}
+
+inline const char *
+config_proxy_get(const Config *config)
+{
+ return config->proxy;
+}
+
+inline void
+config_proxy_set(Config *config, const char *proxy)
+{
+ EINA_SAFETY_ON_NULL_RETURN(config);
+ eina_stringshare_replace(&(config->proxy), proxy);
+}
+
+inline unsigned char
+config_restore_state_get(const Config *config)
+{
+ return config->restore_state;
+}
+
+inline void
+config_restore_state_set(Config *config, unsigned char restore_state)
+{
+ EINA_SAFETY_ON_NULL_RETURN(config);
+ config->restore_state = restore_state;
+}
+
+inline const char *
+config_user_agent_get(const Config *config)
+{
+ return config->user_agent;
+}
+
+inline void
+config_user_agent_set(Config *config, const char *user_agent)
+{
+ EINA_SAFETY_ON_NULL_RETURN(config);
+ eina_stringshare_replace(&(config->user_agent), user_agent);
+}
+
+inline unsigned char
+config_frame_flattening_get(const Config *config)
+{
+ return config->frame_flattening;
+}
+
+inline void
+config_frame_flattening_set(Config *config, unsigned char frame_flattening)
+{
+ EINA_SAFETY_ON_NULL_RETURN(config);
+ config->frame_flattening = frame_flattening;
+}
+
+inline int
+config_text_zoom_get(const Config *config)
+{
+ return config->text_zoom;
+}
+
+inline void
+config_text_zoom_set(Config *config, int text_zoom)
+{
+ EINA_SAFETY_ON_NULL_RETURN(config);
+ config->text_zoom = text_zoom;
+}
+
+inline int
+config_minimum_font_size_get(const Config *config)
+{
+ return config->minimum_font_size;
+}
+
+inline void
+config_minimum_font_size_set(Config *config, int minimum_font_size)
+{
+ EINA_SAFETY_ON_NULL_RETURN(config);
+ config->minimum_font_size = minimum_font_size;
+}
+
+inline int
+config_cookie_policy_get(const Config *config)
+{
+ return config->cookie_policy;
+}
+
+inline void
+config_cookie_policy_set(Config *config, int cookie_policy)
+{
+ EINA_SAFETY_ON_NULL_RETURN(config);
+ config->cookie_policy = cookie_policy;
+}
+
+Config *
+config_load(const char *filename)
+{
+ Config *config = NULL;
+ Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ);
+ if (!ef)
+ {
+ fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
+ return NULL;
+ }
+
+ config = eet_data_read(ef, _config_descriptor, CONFIG_ENTRY);
+ if (!config) goto end;
+ config->__eet_filename = eina_stringshare_add(filename);
+
+end:
+ eet_close(ef);
+ return config;
+}
+
+Eina_Bool
+config_save(Config *config, const char *filename)
+{
+ Eet_File *ef;
+ Eina_Bool ret;
+
+ if (filename) eina_stringshare_replace(&(config->__eet_filename), filename);
+ else if (config->__eet_filename) filename = config->__eet_filename;
+ else return EINA_FALSE;
+
+ ef = eet_open(filename, EET_FILE_MODE_READ_WRITE);
+ if (!ef)
+ {
+ fprintf(stderr, "ERROR: could not open '%s' for write\n", filename);
+ return EINA_FALSE;
+ }
+
+ ret = !!eet_data_write(ef, _config_descriptor, CONFIG_ENTRY, config, EINA_TRUE);
+ eet_close(ef);
+
+ return ret;
+}
+
+static inline void
+_hist_item_init(void)
+{
+ Eet_Data_Descriptor_Class eddc;
+
+ if (_hist_item_descriptor) return;
+
+ EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Hist_Item);
+ _hist_item_descriptor = eet_data_descriptor_stream_new(&eddc);
+
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_hist_item_descriptor, Hist_Item, "enabled", enabled, EET_T_UCHAR);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_hist_item_descriptor, Hist_Item, "title", title, EET_T_STRING);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_hist_item_descriptor, Hist_Item, "url", url, EET_T_STRING);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_hist_item_descriptor, Hist_Item, "proto", proto, EET_T_STRING);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_hist_item_descriptor, Hist_Item, "visit_count", visit_count, EET_T_UINT);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_hist_item_descriptor, Hist_Item, "last_visit", last_visit, EET_T_DOUBLE);
+}
+
+static inline void
+_hist_item_shutdown(void)
+{
+ if (!_hist_item_descriptor) return;
+ eet_data_descriptor_free(_hist_item_descriptor);
+ _hist_item_descriptor = NULL;
+}
+
+Hist_Item *
+hist_item_new(unsigned char enabled, const char * title, const char * url, const char * proto, unsigned int visit_count, double last_visit)
+{
+ Hist_Item *hist_item = calloc(1, sizeof(Hist_Item));
+
+ if (!hist_item)
+ {
+ fprintf(stderr, "ERROR: could not calloc Hist_Item\n");
+ return NULL;
+ }
+
+ hist_item->enabled = enabled;
+ hist_item->title = eina_stringshare_add(title ? title : "Untitled");
+ hist_item->url = eina_stringshare_add(url ? url : "about:blank");
+ hist_item->proto = eina_stringshare_add(proto ? proto : "http");
+ hist_item->visit_count = visit_count;
+ hist_item->last_visit = last_visit;
+
+ return hist_item;
+}
+
+void
+hist_item_free(Hist_Item *hist_item)
+{
+ eina_stringshare_del(hist_item->title);
+ eina_stringshare_del(hist_item->url);
+ eina_stringshare_del(hist_item->proto);
+ free(hist_item);
+}
+
+inline unsigned char
+hist_item_enabled_get(const Hist_Item *hist_item)
+{
+ return hist_item->enabled;
+}
+
+inline void
+hist_item_enabled_set(Hist_Item *hist_item, unsigned char enabled)
+{
+ EINA_SAFETY_ON_NULL_RETURN(hist_item);
+ hist_item->enabled = enabled;
+}
+
+inline const char *
+hist_item_title_get(const Hist_Item *hist_item)
+{
+ return hist_item->title;
+}
+
+inline void
+hist_item_title_set(Hist_Item *hist_item, const char *title)
+{
+ EINA_SAFETY_ON_NULL_RETURN(hist_item);
+ eina_stringshare_replace(&(hist_item->title), title);
+}
+
+inline const char *
+hist_item_url_get(const Hist_Item *hist_item)
+{
+ return hist_item->url;
+}
+
+inline void
+hist_item_url_set(Hist_Item *hist_item, const char *url)
+{
+ EINA_SAFETY_ON_NULL_RETURN(hist_item);
+ eina_stringshare_replace(&(hist_item->url), url);
+}
+
+inline const char *
+hist_item_proto_get(const Hist_Item *hist_item)
+{
+ return hist_item->proto;
+}
+
+inline void
+hist_item_proto_set(Hist_Item *hist_item, const char *proto)
+{
+ EINA_SAFETY_ON_NULL_RETURN(hist_item);
+ eina_stringshare_replace(&(hist_item->proto), proto);
+}
+
+inline unsigned int
+hist_item_visit_count_get(const Hist_Item *hist_item)
+{
+ return hist_item->visit_count;
+}
+
+inline void
+hist_item_visit_count_set(Hist_Item *hist_item, unsigned int visit_count)
+{
+ EINA_SAFETY_ON_NULL_RETURN(hist_item);
+ hist_item->visit_count = visit_count;
+}
+
+inline double
+hist_item_last_visit_get(const Hist_Item *hist_item)
+{
+ return hist_item->last_visit;
+}
+
+inline void
+hist_item_last_visit_set(Hist_Item *hist_item, double last_visit)
+{
+ EINA_SAFETY_ON_NULL_RETURN(hist_item);
+ hist_item->last_visit = last_visit;
+}
+
+
+static inline void
+_hist_init(void)
+{
+ Eet_Data_Descriptor_Class eddc;
+
+ if (_hist_descriptor) return;
+
+ EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Hist);
+ _hist_descriptor = eet_data_descriptor_stream_new(&eddc);
+
+ EET_DATA_DESCRIPTOR_ADD_HASH(_hist_descriptor, Hist, "items", items, _hist_item_descriptor);
+}
+
+static inline void
+_hist_shutdown(void)
+{
+ if (!_hist_descriptor) return;
+ eet_data_descriptor_free(_hist_descriptor);
+ _hist_descriptor = NULL;
+}
+
+Hist *
+hist_new(void)
+{
+ Hist *hist = calloc(1, sizeof(Hist));
+
+ if (!hist)
+ {
+ fprintf(stderr, "ERROR: could not calloc Hist\n");
+ return NULL;
+ }
+
+ hist->items = eina_hash_stringshared_new(EINA_FREE_CB(hist_item_free));
+
+ return hist;
+}
+
+void
+hist_free(Hist *hist)
+{
+ if (hist->items) eina_hash_free(hist->items);
+ free(hist);
+}
+
+void
+hist_items_add(Hist *hist, const char * url, Hist_Item *hist_item)
+{
+ EINA_SAFETY_ON_NULL_RETURN(hist);
+ eina_hash_add(hist->items, url, hist_item);
+}
+
+void
+hist_items_del(Hist *hist, const char * url)
+{
+ EINA_SAFETY_ON_NULL_RETURN(hist);
+ eina_hash_del(hist->items, url, NULL);
+}
+
+inline Hist_Item *
+hist_items_get(const Hist *hist, const char * url)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hist, NULL);
+ return eina_hash_find(hist->items, url);
+}
+
+inline Eina_Hash *
+hist_items_hash_get(const Hist *hist)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(hist, NULL);
+ return hist->items;
+}
+
+void
+hist_items_modify(Hist *hist, const char * key, void *value)
+{
+ EINA_SAFETY_ON_NULL_RETURN(hist);
+ eina_hash_modify(hist->items, key, value);
+}
+
+Hist *
+hist_load(const char *filename)
+{
+ Hist *hist = NULL;
+ Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ);
+ if (!ef)
+ {
+ fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
+ return NULL;
+ }
+
+ hist = eet_data_read(ef, _hist_descriptor, HIST_ENTRY);
+ if (!hist) goto end;
+ hist->__eet_filename = eina_stringshare_add(filename);
+
+ if (!hist->items) hist->items = eina_hash_stringshared_new(EINA_FREE_CB(hist_item_free));
+
+end:
+ eet_close(ef);
+ return hist;
+}
+
+Eina_Bool
+hist_save(Hist *hist, const char *filename)
+{
+ Eet_File *ef;
+ Eina_Bool ret;
+
+ if (filename) eina_stringshare_replace(&(hist->__eet_filename), filename);
+ else if (hist->__eet_filename) filename = hist->__eet_filename;
+ else return EINA_FALSE;
+
+ ef = eet_open(filename, EET_FILE_MODE_READ_WRITE);
+ if (!ef)
+ {
+ fprintf(stderr, "ERROR: could not open '%s' for write\n", filename);
+ return EINA_FALSE;
+ }
+
+ ret = !!eet_data_write(ef, _hist_descriptor, HIST_ENTRY, hist, EINA_TRUE);
+ eet_close(ef);
+
+ return ret;
+}
+
+static inline void
+_session_item_init(void)
+{
+ Eet_Data_Descriptor_Class eddc;
+
+ if (_session_item_descriptor) return;
+
+ EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Session_Item);
+ _session_item_descriptor = eet_data_descriptor_stream_new(&eddc);
+
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_session_item_descriptor, Session_Item, "url", url, EET_T_STRING);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_session_item_descriptor, Session_Item, "focused", focused, EET_T_UCHAR);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_session_item_descriptor, Session_Item, "scroll_x", scroll_x, EET_T_INT);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_session_item_descriptor, Session_Item, "scroll_y", scroll_y, EET_T_INT);
+}
+
+static inline void
+_session_item_shutdown(void)
+{
+ if (!_session_item_descriptor) return;
+ eet_data_descriptor_free(_session_item_descriptor);
+ _session_item_descriptor = NULL;
+}
+
+Session_Item *
+session_item_new(const char * url, unsigned char focused, int scroll_x, int scroll_y)
+{
+ Session_Item *session_item = calloc(1, sizeof(Session_Item));
+
+ if (!session_item)
+ {
+ fprintf(stderr, "ERROR: could not calloc Session_Item\n");
+ return NULL;
+ }
+
+ session_item->url = eina_stringshare_add(url);
+ session_item->focused = focused;
+ session_item->scroll_x = scroll_x;
+ session_item->scroll_y = scroll_y;
+
+ return session_item;
+}
+
+void
+session_item_free(Session_Item *session_item)
+{
+ eina_stringshare_del(session_item->url);
+ free(session_item);
+}
+
+inline const char *
+session_item_url_get(const Session_Item *session_item)
+{
+ return session_item->url;
+}
+
+inline void
+session_item_url_set(Session_Item *session_item, const char *url)
+{
+ EINA_SAFETY_ON_NULL_RETURN(session_item);
+ eina_stringshare_replace(&(session_item->url), url);
+}
+
+inline unsigned char
+session_item_focused_get(const Session_Item *session_item)
+{
+ return session_item->focused;
+}
+
+inline void
+session_item_focused_set(Session_Item *session_item, unsigned char focused)
+{
+ EINA_SAFETY_ON_NULL_RETURN(session_item);
+ session_item->focused = focused;
+}
+
+inline int
+session_item_scroll_x_get(const Session_Item *session_item)
+{
+ return session_item->scroll_x;
+}
+
+inline void
+session_item_scroll_x_set(Session_Item *session_item, int scroll_x)
+{
+ EINA_SAFETY_ON_NULL_RETURN(session_item);
+ session_item->scroll_x = scroll_x;
+}
+
+inline int
+session_item_scroll_y_get(const Session_Item *session_item)
+{
+ return session_item->scroll_y;
+}
+
+inline void
+session_item_scroll_y_set(Session_Item *session_item, int scroll_y)
+{
+ EINA_SAFETY_ON_NULL_RETURN(session_item);
+ session_item->scroll_y = scroll_y;
+}
+
+
+static inline void
+_session_window_init(void)
+{
+ Eet_Data_Descriptor_Class eddc;
+
+ if (_session_window_descriptor) return;
+
+ EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Session_Window);
+ _session_window_descriptor = eet_data_descriptor_stream_new(&eddc);
+
+ EET_DATA_DESCRIPTOR_ADD_LIST(_session_window_descriptor, Session_Window, "tabs", tabs, _session_item_descriptor);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_session_window_descriptor, Session_Window, "focused", focused, EET_T_UCHAR);
+}
+
+static inline void
+_session_window_shutdown(void)
+{
+ if (!_session_window_descriptor) return;
+ eet_data_descriptor_free(_session_window_descriptor);
+ _session_window_descriptor = NULL;
+}
+
+Session_Window *
+session_window_new(Eina_List * tabs, unsigned char focused)
+{
+ Session_Window *session_window = calloc(1, sizeof(Session_Window));
+
+ if (!session_window)
+ {
+ fprintf(stderr, "ERROR: could not calloc Session_Window\n");
+ return NULL;
+ }
+
+ session_window->tabs = tabs;
+ session_window->focused = focused;
+
+ return session_window;
+}
+
+void
+session_window_free(Session_Window *session_window)
+{
+ if (session_window->tabs)
+ {
+ Session_Item *tabs_elem;
+ EINA_LIST_FREE(session_window->tabs, tabs_elem)
+ session_item_free(tabs_elem);
+ }
+ free(session_window);
+}
+
+inline void
+session_window_tabs_add(Session_Window *session_window, Session_Item *session_item)
+{
+ EINA_SAFETY_ON_NULL_RETURN(session_window);
+ session_window->tabs = eina_list_append(session_window->tabs, session_item);
+}
+
+inline void
+session_window_tabs_del(Session_Window *session_window, Session_Item *session_item)
+{
+ EINA_SAFETY_ON_NULL_RETURN(session_window);
+ session_window->tabs = eina_list_remove(session_window->tabs, session_item);
+}
+
+inline Session_Item *
+session_window_tabs_get(const Session_Window *session_window, unsigned int nth)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(session_window, NULL);
+ return eina_list_nth(session_window->tabs, nth);
+}
+
+inline unsigned int
+session_window_tabs_count(const Session_Window *session_window)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(session_window, 0);
+ return eina_list_count(session_window->tabs);
+}
+
+void
+session_window_tabs_list_clear(Session_Window *session_window)
+{
+ EINA_SAFETY_ON_NULL_RETURN(session_window);
+ Session_Item *data;
+ EINA_LIST_FREE(session_window->tabs, data) session_item_free(data);
+}
+
+inline Eina_List *
+session_window_tabs_list_get(const Session_Window *session_window)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(session_window, NULL);
+ return session_window->tabs;
+}
+
+inline void
+session_window_tabs_list_set(Session_Window *session_window, Eina_List *list)
+{
+ EINA_SAFETY_ON_NULL_RETURN(session_window);
+ session_window->tabs = list;
+}
+
+inline unsigned char
+session_window_focused_get(const Session_Window *session_window)
+{
+ return session_window->focused;
+}
+
+inline void
+session_window_focused_set(Session_Window *session_window, unsigned char focused)
+{
+ EINA_SAFETY_ON_NULL_RETURN(session_window);
+ session_window->focused = focused;
+}
+
+
+static inline void
+_session_init(void)
+{
+ Eet_Data_Descriptor_Class eddc;
+
+ if (_session_descriptor) return;
+
+ EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Session);
+ _session_descriptor = eet_data_descriptor_stream_new(&eddc);
+
+ EET_DATA_DESCRIPTOR_ADD_LIST(_session_descriptor, Session, "windows", windows, _session_window_descriptor);
+}
+
+static inline void
+_session_shutdown(void)
+{
+ if (!_session_descriptor) return;
+ eet_data_descriptor_free(_session_descriptor);
+ _session_descriptor = NULL;
+}
+
+Session *
+session_new(Eina_List * windows)
+{
+ Session *session = calloc(1, sizeof(Session));
+
+ if (!session)
+ {
+ fprintf(stderr, "ERROR: could not calloc Session\n");
+ return NULL;
+ }
+
+ session->windows = windows;
+
+ return session;
+}
+
+void
+session_free(Session *session)
+{
+ if (session->windows)
+ {
+ Session_Window *windows_elem;
+ EINA_LIST_FREE(session->windows, windows_elem)
+ session_window_free(windows_elem);
+ }
+ free(session);
+}
+
+inline void
+session_windows_add(Session *session, Session_Window *session_window)
+{
+ EINA_SAFETY_ON_NULL_RETURN(session);
+ session->windows = eina_list_append(session->windows, session_window);
+}
+
+inline void
+session_windows_del(Session *session, Session_Window *session_window)
+{
+ EINA_SAFETY_ON_NULL_RETURN(session);
+ session->windows = eina_list_remove(session->windows, session_window);
+}
+
+inline Session_Window *
+session_windows_get(const Session *session, unsigned int nth)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(session, NULL);
+ return eina_list_nth(session->windows, nth);
+}
+
+inline unsigned int
+session_windows_count(const Session *session)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(session, 0);
+ return eina_list_count(session->windows);
+}
+
+void
+session_windows_list_clear(Session *session)
+{
+ EINA_SAFETY_ON_NULL_RETURN(session);
+ Session_Window *data;
+ EINA_LIST_FREE(session->windows, data) session_window_free(data);
+}
+
+inline Eina_List *
+session_windows_list_get(const Session *session)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(session, NULL);
+ return session->windows;
+}
+
+inline void
+session_windows_list_set(Session *session, Eina_List *list)
+{
+ EINA_SAFETY_ON_NULL_RETURN(session);
+ session->windows = list;
+}
+
+Session *
+session_load(const char *filename)
+{
+ Session *session = NULL;
+ Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ);
+ if (!ef)
+ {
+ fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
+ return NULL;
+ }
+
+ session = eet_data_read(ef, _session_descriptor, SESSION_ENTRY);
+ if (!session) goto end;
+ session->__eet_filename = eina_stringshare_add(filename);
+
+end:
+ eet_close(ef);
+ return session;
+}
+
+Eina_Bool
+session_save(Session *session, const char *filename)
+{
+ Eet_File *ef;
+ Eina_Bool ret;
+
+ if (filename) eina_stringshare_replace(&(session->__eet_filename), filename);
+ else if (session->__eet_filename) filename = session->__eet_filename;
+ else return EINA_FALSE;
+
+ ef = eet_open(filename, EET_FILE_MODE_READ_WRITE);
+ if (!ef)
+ {
+ fprintf(stderr, "ERROR: could not open '%s' for write\n", filename);
+ return EINA_FALSE;
+ }
+
+ ret = !!eet_data_write(ef, _session_descriptor, SESSION_ENTRY, session, EINA_TRUE);
+ eet_close(ef);
+
+ return ret;
+}
+
+void
+viking_state_init(void)
+{
+ _config_init();
+ _hist_item_init();
+ _hist_init();
+ _session_item_init();
+ _session_window_init();
+ _session_init();
+}
+
+void
+viking_state_shutdown(void)
+{
+ _config_shutdown();
+ _hist_item_shutdown();
+ _hist_shutdown();
+ _session_item_shutdown();
+ _session_window_shutdown();
+ _session_shutdown();
+}
+
diff --git a/src/viking_state.h b/src/viking_state.h
@@ -0,0 +1,129 @@
+/* This file has been automatically generated by geneet.py */
+/* DO NOT MODIFY */
+
+#ifndef __VIKING_STATE_H__
+#define __VIKING_STATE_H__
+
+#include <Eina.h>
+#include <Eet.h>
+
+typedef struct _Config Config;
+typedef struct _Hist_Item Hist_Item;
+typedef struct _Hist Hist;
+typedef struct _Session_Item Session_Item;
+typedef struct _Session_Window Session_Window;
+typedef struct _Session Session;
+
+/* Config */
+Config *config_new(unsigned char allow_popup, unsigned char enable_auto_load_images, unsigned char enable_auto_shrink_images, unsigned char enable_javascript, unsigned char enable_touch_interface, unsigned char enable_history, const char * home_page, const char * proxy, unsigned char restore_state, const char * user_agent, unsigned char frame_flattening, int text_zoom, int minimum_font_size, int cookie_policy);
+void config_free(Config *config);
+
+void config_allow_popup_set(Config *config, unsigned char allow_popup);
+unsigned char config_allow_popup_get(const Config *config);
+void config_enable_auto_load_images_set(Config *config, unsigned char enable_auto_load_images);
+unsigned char config_enable_auto_load_images_get(const Config *config);
+void config_enable_auto_shrink_images_set(Config *config, unsigned char enable_auto_shrink_images);
+unsigned char config_enable_auto_shrink_images_get(const Config *config);
+void config_enable_javascript_set(Config *config, unsigned char enable_javascript);
+unsigned char config_enable_javascript_get(const Config *config);
+void config_enable_touch_interface_set(Config *config, unsigned char enable_touch_interface);
+unsigned char config_enable_touch_interface_get(const Config *config);
+void config_enable_history_set(Config *config, unsigned char enable_history);
+unsigned char config_enable_history_get(const Config *config);
+void config_home_page_set(Config *config, const char * home_page);
+const char * config_home_page_get(const Config *config);
+void config_proxy_set(Config *config, const char * proxy);
+const char * config_proxy_get(const Config *config);
+void config_restore_state_set(Config *config, unsigned char restore_state);
+unsigned char config_restore_state_get(const Config *config);
+void config_user_agent_set(Config *config, const char * user_agent);
+const char * config_user_agent_get(const Config *config);
+void config_frame_flattening_set(Config *config, unsigned char frame_flattening);
+unsigned char config_frame_flattening_get(const Config *config);
+void config_text_zoom_set(Config *config, int text_zoom);
+int config_text_zoom_get(const Config *config);
+void config_minimum_font_size_set(Config *config, int minimum_font_size);
+int config_minimum_font_size_get(const Config *config);
+void config_cookie_policy_set(Config *config, int cookie_policy);
+int config_cookie_policy_get(const Config *config);
+
+Config *config_load(const char *filename);
+Eina_Bool config_save(Config *config, const char *filename);
+
+/* Hist_Item */
+Hist_Item *hist_item_new(unsigned char enabled, const char * title, const char * url, const char * proto, unsigned int visit_count, double last_visit);
+void hist_item_free(Hist_Item *hist_item);
+
+void hist_item_enabled_set(Hist_Item *hist_item, unsigned char enabled);
+unsigned char hist_item_enabled_get(const Hist_Item *hist_item);
+void hist_item_title_set(Hist_Item *hist_item, const char * title);
+const char * hist_item_title_get(const Hist_Item *hist_item);
+void hist_item_url_set(Hist_Item *hist_item, const char * url);
+const char * hist_item_url_get(const Hist_Item *hist_item);
+void hist_item_proto_set(Hist_Item *hist_item, const char * proto);
+const char * hist_item_proto_get(const Hist_Item *hist_item);
+void hist_item_visit_count_set(Hist_Item *hist_item, unsigned int visit_count);
+unsigned int hist_item_visit_count_get(const Hist_Item *hist_item);
+void hist_item_last_visit_set(Hist_Item *hist_item, double last_visit);
+double hist_item_last_visit_get(const Hist_Item *hist_item);
+
+/* Hist */
+Hist *hist_new(void);
+void hist_free(Hist *hist);
+
+void hist_items_add(Hist *hist, const char * url, Hist_Item *hist_item);
+void hist_items_del(Hist *hist, const char * url);
+Hist_Item *hist_items_get(const Hist *hist, const char * key);
+Eina_Hash *hist_items_hash_get(const Hist *hist);
+void hist_items_modify(Hist *hist, const char * key, void *value);
+
+Hist *hist_load(const char *filename);
+Eina_Bool hist_save(Hist *hist, const char *filename);
+
+/* Session_Item */
+Session_Item *session_item_new(const char * url, unsigned char focused, int scroll_x, int scroll_y);
+void session_item_free(Session_Item *session_item);
+
+void session_item_url_set(Session_Item *session_item, const char * url);
+const char * session_item_url_get(const Session_Item *session_item);
+void session_item_focused_set(Session_Item *session_item, unsigned char focused);
+unsigned char session_item_focused_get(const Session_Item *session_item);
+void session_item_scroll_x_set(Session_Item *session_item, int scroll_x);
+int session_item_scroll_x_get(const Session_Item *session_item);
+void session_item_scroll_y_set(Session_Item *session_item, int scroll_y);
+int session_item_scroll_y_get(const Session_Item *session_item);
+
+/* Session_Window */
+Session_Window *session_window_new(Eina_List * tabs, unsigned char focused);
+void session_window_free(Session_Window *session_window);
+
+void session_window_tabs_add(Session_Window *session_window, Session_Item *session_item);
+void session_window_tabs_del(Session_Window *session_window, Session_Item *session_item);
+Session_Item *session_window_tabs_get(const Session_Window *session_window, unsigned int nth);
+unsigned int session_window_tabs_count(const Session_Window *session_window);
+Eina_List *session_window_tabs_list_get(const Session_Window *session_window);
+void session_window_tabs_list_clear(Session_Window *session_window);
+void session_window_tabs_list_set(Session_Window *session_window, Eina_List *list);
+void session_window_focused_set(Session_Window *session_window, unsigned char focused);
+unsigned char session_window_focused_get(const Session_Window *session_window);
+
+/* Session */
+Session *session_new(Eina_List * windows);
+void session_free(Session *session);
+
+void session_windows_add(Session *session, Session_Window *session_window);
+void session_windows_del(Session *session, Session_Window *session_window);
+Session_Window *session_windows_get(const Session *session, unsigned int nth);
+unsigned int session_windows_count(const Session *session);
+Eina_List *session_windows_list_get(const Session *session);
+void session_windows_list_clear(Session *session);
+void session_windows_list_set(Session *session, Eina_List *list);
+
+Session *session_load(const char *filename);
+Eina_Bool session_save(Session *session, const char *filename);
+
+/* Global initializer / shutdown functions */
+void viking_state_init(void);
+void viking_state_shutdown(void);
+
+#endif /* __VIKING_STATE_H__ */