#ifndef APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_HISTORY_HPP #define APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_HISTORY_HPP #include #include #include #include #include #include #include #include #include namespace app::browser::main::tab::page::navigation { namespace history { class Back; class Forward; } class History : public Gtk::Box { public: /* * History class database * * Allowed parental access to enums and relationship methods */ struct DB { // APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_HISTORY__* struct SESSION { enum { ID, APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID, TIME, REQUEST, IS_CURRENT }; // table fields index static int init( sqlite3 * db ); // return sqlite3_exec status code static int clean( sqlite3 * db, const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID ); // return sqlite3_finalize status code static sqlite3_int64 add( sqlite3 * db, const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID, const int & TIME, const Glib::ustring & REQUEST, const bool & IS_CURRENT ); // return sqlite3_last_insert_rowid }; }; /* * Internal members */ private: // Database sqlite3 * db; // Components history::Back * historyBack; history::Forward * historyForward; // Extras int index = -1; /* * History class API */ public: // Extras struct Memory { Glib::ustring request; std::time_t time; // event unix time }; // Define navigation history storage std::vector memory; History( sqlite3 * db, const Glib::RefPtr & ACTION__HISTORY_BACK, const Glib::RefPtr & ACTION__HISTORY_FORWARD ); // Actions void add( const Glib::ustring & REQUEST, const bool & UPDATE_MEMORY_INDEX ); int restore( const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID ); // return sqlite3_finalize status code void save( const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID ); void update(); bool try_back( Memory & match, const bool & UPDATE_MEMORY_INDEX ); bool try_forward( Memory & match, const bool & UPDATE_MEMORY_INDEX ); }; } #endif // APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_HISTORY_HPP