Browse Source

rename database pointer

CPP-GTK4
yggverse 2 months ago
parent
commit
9904dfcb34
  1. 6
      src/app.cpp
  2. 34
      src/app/browser.cpp
  3. 10
      src/app/browser.hpp
  4. 30
      src/app/browser/main.cpp
  5. 10
      src/app/browser/main.hpp
  6. 34
      src/app/browser/main/tab.cpp
  7. 10
      src/app/browser/main/tab.hpp
  8. 24
      src/app/browser/main/tab/label.cpp
  9. 10
      src/app/browser/main/tab/label.hpp
  10. 28
      src/app/browser/main/tab/page.cpp
  11. 10
      src/app/browser/main/tab/page.hpp
  12. 34
      src/app/browser/main/tab/page/navigation.cpp
  13. 10
      src/app/browser/main/tab/page/navigation.hpp
  14. 26
      src/app/browser/main/tab/page/navigation/history.cpp
  15. 10
      src/app/browser/main/tab/page/navigation/history.hpp
  16. 26
      src/app/browser/main/tab/page/navigation/request.cpp
  17. 10
      src/app/browser/main/tab/page/navigation/request.hpp

6
src/app.cpp

@ -6,11 +6,11 @@ int main(
char * argv[] char * argv[]
) { ) {
// Init database // Init database
sqlite3 * db; sqlite3 * database;
sqlite3_open( sqlite3_open(
"app.sqlite3", "app.sqlite3",
&db &database
); );
// Init application // Init application
@ -22,6 +22,6 @@ int main(
return app->make_window_and_run<app::Browser>( return app->make_window_and_run<app::Browser>(
argc, argc,
argv, argv,
db database
); );
} }

34
src/app/browser.cpp

@ -5,11 +5,11 @@
using namespace app; using namespace app;
Browser::Browser( Browser::Browser(
sqlite3 * db sqlite3 * database
) { ) {
// Init database // Init database
Database::Session::init( Database::Session::init(
this->db = db this->database = database
); );
// Init window actions // Init window actions
@ -189,7 +189,7 @@ Browser::Browser(
); );
browserMain = Gtk::make_managed<browser::Main>( browserMain = Gtk::make_managed<browser::Main>(
db, database,
ACTION__TAB_CLOSE, ACTION__TAB_CLOSE,
ACTION__TAB_CLOSE_ALL, ACTION__TAB_CLOSE_ALL,
ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK, ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK,
@ -252,7 +252,7 @@ Browser::Browser(
{ {
session_save(); session_save();
// @TODO sqlite3_close(db); // @TODO sqlite3_close(database);
return false; return false;
}, },
@ -266,7 +266,7 @@ int Browser::session_restore()
sqlite3_stmt* statement; // @TODO move to the Database model namespace sqlite3_stmt* statement; // @TODO move to the Database model namespace
const int PREPARE_STATUS = sqlite3_prepare_v3( const int PREPARE_STATUS = sqlite3_prepare_v3(
db, database,
R"SQL( R"SQL(
SELECT * FROM `app_browser__session` SELECT * FROM `app_browser__session`
)SQL", )SQL",
@ -315,7 +315,7 @@ int Browser::session_restore()
void Browser::session_clean() void Browser::session_clean()
{ {
Database::Session::clean( Database::Session::clean(
db database
); );
browserMain->tab_close_all(); browserMain->tab_close_all();
@ -327,12 +327,12 @@ void Browser::session_save()
// Delete previous data // Delete previous data
Database::Session::clean( Database::Session::clean(
db database
); // @TODO run on background ); // @TODO run on background
// Create new session // Create new session
const sqlite3_int64 APP_BROWSER__SESSION__ID = Database::Session::add( const sqlite3_int64 APP_BROWSER__SESSION__ID = Database::Session::add(
db, database,
get_width(), get_width(),
get_height(), get_height(),
is_fullscreen() is_fullscreen()
@ -346,12 +346,12 @@ void Browser::session_save()
// Database // Database
int Browser::Database::Session::init( int Browser::Database::Session::init(
sqlite3 * db sqlite3 * database
) { ) {
char * error; char * error;
return sqlite3_exec( return sqlite3_exec(
db, database,
R"SQL( R"SQL(
CREATE TABLE IF NOT EXISTS `app_browser__session` CREATE TABLE IF NOT EXISTS `app_browser__session`
( (
@ -369,13 +369,13 @@ int Browser::Database::Session::init(
} }
int Browser::Database::Session::clean( int Browser::Database::Session::clean(
sqlite3 * db sqlite3 * database
) { ) {
char * error; // @TODO char * error; // @TODO
sqlite3_stmt * statement; sqlite3_stmt * statement;
const int PREPARE_STATUS = sqlite3_prepare_v3( const int PREPARE_STATUS = sqlite3_prepare_v3(
db, database,
R"SQL( R"SQL(
SELECT * FROM `app_browser__session` SELECT * FROM `app_browser__session`
)SQL", )SQL",
@ -396,7 +396,7 @@ int Browser::Database::Session::clean(
// Delete record // Delete record
const int EXEC_STATUS = sqlite3_exec( const int EXEC_STATUS = sqlite3_exec(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
DELETE FROM `app_browser__session` WHERE `id` = %d DELETE FROM `app_browser__session` WHERE `id` = %d
@ -412,7 +412,7 @@ int Browser::Database::Session::clean(
if (EXEC_STATUS == SQLITE_OK) if (EXEC_STATUS == SQLITE_OK)
{ {
browser::Main::Database::Session::clean( browser::Main::Database::Session::clean(
db, database,
APP_BROWSER__SESSION__ID APP_BROWSER__SESSION__ID
); );
} }
@ -425,7 +425,7 @@ int Browser::Database::Session::clean(
} }
sqlite3_int64 Browser::Database::Session::add( sqlite3_int64 Browser::Database::Session::add(
sqlite3 * db, sqlite3 * database,
const int & WIDTH, const int & WIDTH,
const int & HEIGHT, const int & HEIGHT,
const bool & IS_FULLSCREEN const bool & IS_FULLSCREEN
@ -433,7 +433,7 @@ sqlite3_int64 Browser::Database::Session::add(
char * error; // @TODO char * error; // @TODO
sqlite3_exec( sqlite3_exec(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
INSERT INTO `app_browser__session` ( INSERT INTO `app_browser__session` (
@ -456,6 +456,6 @@ sqlite3_int64 Browser::Database::Session::add(
); );
return sqlite3_last_insert_rowid( return sqlite3_last_insert_rowid(
db database
); );
} }

10
src/app/browser.hpp

@ -42,15 +42,15 @@ namespace app
}; // table fields index }; // table fields index
static int init( static int init(
sqlite3 * db sqlite3 * database
); // return sqlite3_exec status code ); // return sqlite3_exec status code
static int clean( static int clean(
sqlite3 * db sqlite3 * database
); // return sqlite3_finalize status code ); // return sqlite3_finalize status code
static sqlite3_int64 add( static sqlite3_int64 add(
sqlite3 * db, sqlite3 * database,
const int & WIDTH, const int & WIDTH,
const int & HEIGHT, const int & HEIGHT,
const bool & IS_FULLSCREEN const bool & IS_FULLSCREEN
@ -64,7 +64,7 @@ namespace app
private: private:
// Database // Database
sqlite3 * db; sqlite3 * database;
// Components // Components
app::browser::Header * browserHeader; app::browser::Header * browserHeader;
@ -81,7 +81,7 @@ namespace app
public: public:
Browser( Browser(
sqlite3 * db sqlite3 * database
); );
// Actions // Actions

30
src/app/browser/main.cpp

@ -4,7 +4,7 @@
using namespace app::browser; using namespace app::browser;
Main::Main( Main::Main(
sqlite3 * db, sqlite3 * database,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE_ALL, const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE_ALL,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,
@ -14,7 +14,7 @@ Main::Main(
) { ) {
// Init database // Init database
Database::Session::init( Database::Session::init(
this->db = db this->database = database
); );
// Init widget // Init widget
@ -28,7 +28,7 @@ Main::Main(
// Init components // Init components
mainTab = Gtk::make_managed<main::Tab>( mainTab = Gtk::make_managed<main::Tab>(
db, database,
ACTION__CLOSE, ACTION__CLOSE,
ACTION__CLOSE_ALL, ACTION__CLOSE_ALL,
ACTION__HISTORY_BACK, ACTION__HISTORY_BACK,
@ -51,7 +51,7 @@ int Main::session_restore(
sqlite3_stmt* statement; // @TODO move to the Database model namespace sqlite3_stmt* statement; // @TODO move to the Database model namespace
const int PREPARE_STATUS = sqlite3_prepare_v3( const int PREPARE_STATUS = sqlite3_prepare_v3(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
SELECT * FROM `app_browser_main__session` SELECT * FROM `app_browser_main__session`
@ -90,13 +90,13 @@ void Main::session_save(
// Delete previous data // Delete previous data
Database::Session::clean( Database::Session::clean(
db, database,
APP_BROWSER__SESSION__ID APP_BROWSER__SESSION__ID
); // @TODO run on background ); // @TODO run on background
// Create new session // Create new session
const sqlite3_int64 APP_BROWSER_MAIN__SESSION__ID = Database::Session::add( const sqlite3_int64 APP_BROWSER_MAIN__SESSION__ID = Database::Session::add(
db, database,
APP_BROWSER__SESSION__ID APP_BROWSER__SESSION__ID
); );
@ -185,12 +185,12 @@ Glib::ustring Main::get_tab_page_description()
// Database // Database
int Main::Database::Session::init( int Main::Database::Session::init(
sqlite3 * db sqlite3 * database
) { ) {
char * error; char * error;
return sqlite3_exec( return sqlite3_exec(
db, database,
R"SQL( R"SQL(
CREATE TABLE IF NOT EXISTS `app_browser_main__session` CREATE TABLE IF NOT EXISTS `app_browser_main__session`
( (
@ -205,14 +205,14 @@ int Main::Database::Session::init(
} }
int Main::Database::Session::clean( int Main::Database::Session::clean(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER__SESSION__ID const sqlite3_int64 & APP_BROWSER__SESSION__ID
) { ) {
char * error; // @TODO char * error; // @TODO
sqlite3_stmt * statement; sqlite3_stmt * statement;
const int PREPARE_STATUS = sqlite3_prepare_v3( const int PREPARE_STATUS = sqlite3_prepare_v3(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
SELECT * FROM `app_browser_main__session` SELECT * FROM `app_browser_main__session`
@ -237,7 +237,7 @@ int Main::Database::Session::clean(
// Delete record // Delete record
const int EXEC_STATUS = sqlite3_exec( const int EXEC_STATUS = sqlite3_exec(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
DELETE FROM `app_browser_main__session` WHERE `id` = %d DELETE FROM `app_browser_main__session` WHERE `id` = %d
@ -253,7 +253,7 @@ int Main::Database::Session::clean(
if (EXEC_STATUS == SQLITE_OK) if (EXEC_STATUS == SQLITE_OK)
{ {
main::Tab::Database::Session::clean( main::Tab::Database::Session::clean(
db, database,
APP_BROWSER_MAIN__SESSION__ID APP_BROWSER_MAIN__SESSION__ID
); );
} }
@ -266,13 +266,13 @@ int Main::Database::Session::clean(
} }
sqlite3_int64 Main::Database::Session::add( sqlite3_int64 Main::Database::Session::add(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER__SESSION__ID const sqlite3_int64 & APP_BROWSER__SESSION__ID
) { ) {
char * error; // @TODO char * error; // @TODO
sqlite3_exec( sqlite3_exec(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
INSERT INTO `app_browser_main__session` ( INSERT INTO `app_browser_main__session` (
@ -289,6 +289,6 @@ sqlite3_int64 Main::Database::Session::add(
); );
return sqlite3_last_insert_rowid( return sqlite3_last_insert_rowid(
db database
); );
} }

10
src/app/browser/main.hpp

@ -38,16 +38,16 @@ namespace app::browser
}; // table fields index }; // table fields index
static int init( static int init(
sqlite3 * db sqlite3 * database
); // return sqlite3_exec status code ); // return sqlite3_exec status code
static int clean( static int clean(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER__SESSION__ID const sqlite3_int64 & APP_BROWSER__SESSION__ID
); // return sqlite3_finalize status code ); // return sqlite3_finalize status code
static sqlite3_int64 add( static sqlite3_int64 add(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER__SESSION__ID const sqlite3_int64 & APP_BROWSER__SESSION__ID
); // return sqlite3_last_insert_rowid ); // return sqlite3_last_insert_rowid
@ -60,7 +60,7 @@ namespace app::browser
private: private:
// Database // Database
sqlite3 * db; sqlite3 * database;
// Components // Components
main::Tab * mainTab; main::Tab * mainTab;
@ -74,7 +74,7 @@ namespace app::browser
public: public:
Main( Main(
sqlite3 * db, sqlite3 * database,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE_ALL, const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE_ALL,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,

34
src/app/browser/main/tab.cpp

@ -5,7 +5,7 @@
using namespace app::browser::main; using namespace app::browser::main;
Tab::Tab( Tab::Tab(
sqlite3 * db, sqlite3 * database,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE_ALL, const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE_ALL,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,
@ -15,7 +15,7 @@ Tab::Tab(
) { ) {
// Init database // Init database
Database::Session::init( Database::Session::init(
this->db = db this->database = database
); );
// Init actions // Init actions
@ -46,7 +46,7 @@ int Tab::session_restore(
sqlite3_stmt* statement; // @TODO move to the Database model namespace sqlite3_stmt* statement; // @TODO move to the Database model namespace
const int PREPARE_STATUS = sqlite3_prepare_v3( const int PREPARE_STATUS = sqlite3_prepare_v3(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
SELECT * FROM `app_browser_main_tab__session` SELECT * FROM `app_browser_main_tab__session`
@ -106,7 +106,7 @@ void Tab::session_save(
// Delete previous data // Delete previous data
Database::Session::clean( Database::Session::clean(
db, database,
APP_BROWSER_MAIN__SESSION__ID APP_BROWSER_MAIN__SESSION__ID
); // @TODO run on background ); // @TODO run on background
@ -115,7 +115,7 @@ void Tab::session_save(
{ {
// Create new session // Create new session
const sqlite3_int64 APP_BROWSER_MAIN_TAB__SESSION__ID = Database::Session::add( const sqlite3_int64 APP_BROWSER_MAIN_TAB__SESSION__ID = Database::Session::add(
db, database,
APP_BROWSER_MAIN__SESSION__ID, APP_BROWSER_MAIN__SESSION__ID,
page_number, page_number,
page_number == get_current_page() page_number == get_current_page()
@ -169,7 +169,7 @@ int Tab::append(
const bool & IS_CURRENT const bool & IS_CURRENT
) { ) {
const auto TAB_PAGE = new tab::Page( // @TODO manage const auto TAB_PAGE = new tab::Page( // @TODO manage
db, database,
action__history_back, action__history_back,
action__history_forward, action__history_forward,
action__reload, action__reload,
@ -177,7 +177,7 @@ int Tab::append(
); );
const auto TAB_LABEL = new tab::Label( // @TODO manage const auto TAB_LABEL = new tab::Label( // @TODO manage
db, database,
action__close action__close
); );
@ -340,12 +340,12 @@ tab::Page * Tab::get_tabPage(
// Database // Database
int Tab::Database::Session::init( int Tab::Database::Session::init(
sqlite3 * db sqlite3 * database
) { ) {
char * error; char * error;
return sqlite3_exec( return sqlite3_exec(
db, database,
R"SQL( R"SQL(
CREATE TABLE IF NOT EXISTS `app_browser_main_tab__session` CREATE TABLE IF NOT EXISTS `app_browser_main_tab__session`
( (
@ -362,14 +362,14 @@ int Tab::Database::Session::init(
} }
int Tab::Database::Session::clean( int Tab::Database::Session::clean(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN__SESSION__ID const sqlite3_int64 & APP_BROWSER_MAIN__SESSION__ID
) { ) {
char * error; // @TODO char * error; // @TODO
sqlite3_stmt * statement; sqlite3_stmt * statement;
const int PREPARE_STATUS = sqlite3_prepare_v3( const int PREPARE_STATUS = sqlite3_prepare_v3(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
SELECT * FROM `app_browser_main_tab__session` SELECT * FROM `app_browser_main_tab__session`
@ -394,7 +394,7 @@ int Tab::Database::Session::clean(
// Delete record // Delete record
const int EXEC_STATUS = sqlite3_exec( const int EXEC_STATUS = sqlite3_exec(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
DELETE FROM `app_browser_main_tab__session` WHERE `id` = %d DELETE FROM `app_browser_main_tab__session` WHERE `id` = %d
@ -410,12 +410,12 @@ int Tab::Database::Session::clean(
if (EXEC_STATUS == SQLITE_OK) if (EXEC_STATUS == SQLITE_OK)
{ {
tab::Label::Database::Session::clean( tab::Label::Database::Session::clean(
db, database,
APP_BROWSER_MAIN_TAB__SESSION__ID APP_BROWSER_MAIN_TAB__SESSION__ID
); );
tab::Page::Database::Session::clean( tab::Page::Database::Session::clean(
db, database,
APP_BROWSER_MAIN_TAB__SESSION__ID APP_BROWSER_MAIN_TAB__SESSION__ID
); );
} }
@ -428,7 +428,7 @@ int Tab::Database::Session::clean(
} }
sqlite3_int64 Tab::Database::Session::add( sqlite3_int64 Tab::Database::Session::add(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN__SESSION__ID, const sqlite3_int64 & APP_BROWSER_MAIN__SESSION__ID,
const int & PAGE_NUMBER, const int & PAGE_NUMBER,
const bool & IS_CURRENT const bool & IS_CURRENT
@ -436,7 +436,7 @@ sqlite3_int64 Tab::Database::Session::add(
char * error; // @TODO char * error; // @TODO
sqlite3_exec( sqlite3_exec(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
INSERT INTO `app_browser_main_tab__session` ( INSERT INTO `app_browser_main_tab__session` (
@ -459,6 +459,6 @@ sqlite3_int64 Tab::Database::Session::add(
); );
return sqlite3_last_insert_rowid( return sqlite3_last_insert_rowid(
db database
); );
} }

10
src/app/browser/main/tab.hpp

@ -40,16 +40,16 @@ namespace app::browser::main
}; // table fields index }; // table fields index
static int init( static int init(
sqlite3 * db sqlite3 * database
); // return sqlite3_exec status code ); // return sqlite3_exec status code
static int clean( static int clean(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN__SESSION__ID const sqlite3_int64 & APP_BROWSER_MAIN__SESSION__ID
); // return sqlite3_finalize status code ); // return sqlite3_finalize status code
static sqlite3_int64 add( static sqlite3_int64 add(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN__SESSION__ID, const sqlite3_int64 & APP_BROWSER_MAIN__SESSION__ID,
const int & PAGE_NUMBER, const int & PAGE_NUMBER,
const bool & IS_CURRENT const bool & IS_CURRENT
@ -64,7 +64,7 @@ namespace app::browser::main
private: private:
// Database // Database
sqlite3 * db; sqlite3 * database;
// Actions // Actions
Glib::RefPtr<Gio::SimpleAction> action__close_all, Glib::RefPtr<Gio::SimpleAction> action__close_all,
@ -84,7 +84,7 @@ namespace app::browser::main
public: public:
Tab( Tab(
sqlite3 * db, sqlite3 * database,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE_ALL, const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE_ALL,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,

24
src/app/browser/main/tab/label.cpp

@ -3,12 +3,12 @@
using namespace app::browser::main::tab; using namespace app::browser::main::tab;
Label::Label( Label::Label(
sqlite3 * db, sqlite3 * database,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE
) { ) {
// Init database // Init database
Database::Session::init( Database::Session::init(
this->db = db this->database = database
); );
// Init actions // Init actions
@ -90,7 +90,7 @@ int Label::session_restore(
sqlite3_stmt * statement; sqlite3_stmt * statement;
const int PREPARE_STATUS = sqlite3_prepare_v3( const int PREPARE_STATUS = sqlite3_prepare_v3(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
SELECT * FROM `app_browser_main_tab_label__session` SELECT * FROM `app_browser_main_tab_label__session`
@ -140,7 +140,7 @@ int Label::session_save(
// Save label session // Save label session
return Database::Session::add( return Database::Session::add(
db, database,
APP_BROWSER_MAIN_TAB__SESSION__ID, APP_BROWSER_MAIN_TAB__SESSION__ID,
is_pinned, is_pinned,
text text
@ -211,12 +211,12 @@ void Label::update(
// Database model // Database model
int Label::Database::Session::init( int Label::Database::Session::init(
sqlite3 * db sqlite3 * database
) { ) {
char * error; char * error;
return sqlite3_exec( return sqlite3_exec(
db, database,
R"SQL( R"SQL(
CREATE TABLE IF NOT EXISTS `app_browser_main_tab_label__session` CREATE TABLE IF NOT EXISTS `app_browser_main_tab_label__session`
( (
@ -233,14 +233,14 @@ int Label::Database::Session::init(
} }
int Label::Database::Session::clean( int Label::Database::Session::clean(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB__SESSION__ID const sqlite3_int64 & APP_BROWSER_MAIN_TAB__SESSION__ID
) { ) {
char * error; // @TODO char * error; // @TODO
sqlite3_stmt * statement; sqlite3_stmt * statement;
const int PREPARE_STATUS = sqlite3_prepare_v3( const int PREPARE_STATUS = sqlite3_prepare_v3(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
SELECT * FROM `app_browser_main_tab_label__session` SELECT * FROM `app_browser_main_tab_label__session`
@ -260,7 +260,7 @@ int Label::Database::Session::clean(
{ {
// Delete record // Delete record
const int EXEC_STATUS = sqlite3_exec( const int EXEC_STATUS = sqlite3_exec(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
DELETE FROM `app_browser_main_tab_label__session` WHERE `id` = %d DELETE FROM `app_browser_main_tab_label__session` WHERE `id` = %d
@ -289,7 +289,7 @@ int Label::Database::Session::clean(
} }
sqlite3_int64 Label::Database::Session::add( sqlite3_int64 Label::Database::Session::add(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB__SESSION__ID, const sqlite3_int64 & APP_BROWSER_MAIN_TAB__SESSION__ID,
const bool & IS_PINNED, const bool & IS_PINNED,
const Glib::ustring & TEXT const Glib::ustring & TEXT
@ -297,7 +297,7 @@ sqlite3_int64 Label::Database::Session::add(
char * error; // @TODO char * error; // @TODO
sqlite3_exec( sqlite3_exec(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
INSERT INTO `app_browser_main_tab_label__session` ( INSERT INTO `app_browser_main_tab_label__session` (
@ -320,6 +320,6 @@ sqlite3_int64 Label::Database::Session::add(
); );
return sqlite3_last_insert_rowid( return sqlite3_last_insert_rowid(
db database
); );
} }

10
src/app/browser/main/tab/label.hpp

@ -37,16 +37,16 @@ namespace app::browser::main::tab
}; // table fields index }; // table fields index
static int init( static int init(
sqlite3 * db sqlite3 * database
); // return sqlite3_exec status code ); // return sqlite3_exec status code
static int clean( static int clean(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB__SESSION__ID const sqlite3_int64 & APP_BROWSER_MAIN_TAB__SESSION__ID
); // return sqlite3_finalize status code ); // return sqlite3_finalize status code
static sqlite3_int64 add( static sqlite3_int64 add(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB__SESSION__ID, const sqlite3_int64 & APP_BROWSER_MAIN_TAB__SESSION__ID,
const bool & IS_PINNED, const bool & IS_PINNED,
const Glib::ustring & TEXT const Glib::ustring & TEXT
@ -60,7 +60,7 @@ namespace app::browser::main::tab
private: private:
// Database // Database
sqlite3 * db; sqlite3 * database;
// Actions // Actions
Glib::RefPtr<Gio::SimpleAction> action__tab_close; Glib::RefPtr<Gio::SimpleAction> action__tab_close;
@ -78,7 +78,7 @@ namespace app::browser::main::tab
public: public:
Label( Label(
sqlite3 * db, sqlite3 * database,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE
); );

28
src/app/browser/main/tab/page.cpp

@ -5,7 +5,7 @@
using namespace app::browser::main::tab; using namespace app::browser::main::tab;
Page::Page( Page::Page(
sqlite3 * db, sqlite3 * database,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__RELOAD, const Glib::RefPtr<Gio::SimpleAction> & ACTION__RELOAD,
@ -18,7 +18,7 @@ Page::Page(
// Init database // Init database
Database::Session::init( Database::Session::init(
this->db = db this->database = database
); );
// Init shared actions // Init shared actions
@ -59,7 +59,7 @@ Page::Page(
// Init widget components // Init widget components
pageNavigation = Gtk::make_managed<page::Navigation>( pageNavigation = Gtk::make_managed<page::Navigation>(
this->db, this->database,
ACTION__HISTORY_BACK, ACTION__HISTORY_BACK,
ACTION__HISTORY_FORWARD, ACTION__HISTORY_FORWARD,
ACTION__OPEN_LINK_VARIANT, ACTION__OPEN_LINK_VARIANT,
@ -96,7 +96,7 @@ int Page::session_restore(
sqlite3_stmt* statement; // @TODO move to the Database model namespace sqlite3_stmt* statement; // @TODO move to the Database model namespace
const int PREPARE_STATUS = sqlite3_prepare_v3( const int PREPARE_STATUS = sqlite3_prepare_v3(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
SELECT * FROM `app_browser_main_tab_page__session` SELECT * FROM `app_browser_main_tab_page__session`
@ -165,7 +165,7 @@ void Page::session_save(
// Delegate save action to child components // Delegate save action to child components
pageNavigation->session_save( pageNavigation->session_save(
Database::Session::add( Database::Session::add(
db, database,
APP_BROWSER_MAIN_TAB__SESSION__ID, APP_BROWSER_MAIN_TAB__SESSION__ID,
mime, mime,
title, title,
@ -520,12 +520,12 @@ Glib::ustring Page::get_description()
// Database model // Database model
int Page::Database::Session::init( int Page::Database::Session::init(
sqlite3 * db sqlite3 * database
) { ) {
char * error; char * error;
return sqlite3_exec( return sqlite3_exec(
db, database,
R"SQL( R"SQL(
CREATE TABLE IF NOT EXISTS `app_browser_main_tab_page__session` CREATE TABLE IF NOT EXISTS `app_browser_main_tab_page__session`
( (
@ -543,14 +543,14 @@ int Page::Database::Session::init(
} }
int Page::Database::Session::clean( int Page::Database::Session::clean(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB__SESSION__ID const sqlite3_int64 & APP_BROWSER_MAIN_TAB__SESSION__ID
) { ) {
char * error; // @TODO char * error; // @TODO
sqlite3_stmt * statement; sqlite3_stmt * statement;
const int PREPARE_STATUS = sqlite3_prepare_v3( const int PREPARE_STATUS = sqlite3_prepare_v3(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
SELECT * FROM `app_browser_main_tab_page__session` WHERE `app_browser_main_tab__session__id` = %d SELECT * FROM `app_browser_main_tab_page__session` WHERE `app_browser_main_tab__session__id` = %d
@ -574,7 +574,7 @@ int Page::Database::Session::clean(
// Delete record // Delete record
const int EXEC_STATUS = sqlite3_exec( const int EXEC_STATUS = sqlite3_exec(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
DELETE FROM `app_browser_main_tab_page__session` WHERE `id` = %d DELETE FROM `app_browser_main_tab_page__session` WHERE `id` = %d
@ -590,7 +590,7 @@ int Page::Database::Session::clean(
if (EXEC_STATUS == SQLITE_OK) if (EXEC_STATUS == SQLITE_OK)
{ {
page::Navigation::Database::Session::clean( page::Navigation::Database::Session::clean(
db, database,
APP_BROWSER_MAIN_TAB_PAGE__SESSION__ID APP_BROWSER_MAIN_TAB_PAGE__SESSION__ID
); );
} }
@ -603,7 +603,7 @@ int Page::Database::Session::clean(
} }
sqlite3_int64 Page::Database::Session::add( sqlite3_int64 Page::Database::Session::add(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB__SESSION__ID, const sqlite3_int64 & APP_BROWSER_MAIN_TAB__SESSION__ID,
const Page::MIME & MIME, const Page::MIME & MIME,
const Glib::ustring & TITLE, const Glib::ustring & TITLE,
@ -612,7 +612,7 @@ sqlite3_int64 Page::Database::Session::add(
char * error; // @TODO char * error; // @TODO
sqlite3_exec( sqlite3_exec(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
INSERT INTO `app_browser_main_tab_page__session` ( INSERT INTO `app_browser_main_tab_page__session` (
@ -638,7 +638,7 @@ sqlite3_int64 Page::Database::Session::add(
); );
return sqlite3_last_insert_rowid( return sqlite3_last_insert_rowid(
db database
); );
} }

10
src/app/browser/main/tab/page.hpp

@ -59,16 +59,16 @@ namespace app::browser::main::tab
}; // table fields index }; // table fields index
static int init( static int init(
sqlite3 * db sqlite3 * database
); // return sqlite3_exec status code ); // return sqlite3_exec status code
static int clean( static int clean(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB__SESSION__ID const sqlite3_int64 & APP_BROWSER_MAIN_TAB__SESSION__ID
); // return sqlite3_finalize status code ); // return sqlite3_finalize status code
static sqlite3_int64 add( static sqlite3_int64 add(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB__SESSION__ID, const sqlite3_int64 & APP_BROWSER_MAIN_TAB__SESSION__ID,
const Page::MIME & MIME, const Page::MIME & MIME,
const Glib::ustring & TITLE, const Glib::ustring & TITLE,
@ -182,7 +182,7 @@ namespace app::browser::main::tab
Glib::RefPtr<Gio::SimpleAction> action__update; Glib::RefPtr<Gio::SimpleAction> action__update;
// Database // Database
sqlite3 * db; sqlite3 * database;
// Socket // Socket
char buffer[0xfffff]; // 1Mb char buffer[0xfffff]; // 1Mb
@ -201,7 +201,7 @@ namespace app::browser::main::tab
public: public:
Page( Page(
sqlite3 * db, sqlite3 * database,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__RELOAD, const Glib::RefPtr<Gio::SimpleAction> & ACTION__RELOAD,

34
src/app/browser/main/tab/page/navigation.cpp

@ -8,7 +8,7 @@
using namespace app::browser::main::tab::page; using namespace app::browser::main::tab::page;
Navigation::Navigation( Navigation::Navigation(
sqlite3 * db, sqlite3 * database,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__OPEN_LINK_VARIANT, const Glib::RefPtr<Gio::SimpleAction> & ACTION__OPEN_LINK_VARIANT,
@ -17,7 +17,7 @@ Navigation::Navigation(
) { ) {
// Init database // Init database
Database::Session::init( Database::Session::init(
this->db = db this->database = database
); );
// Init container // Init container
@ -55,7 +55,7 @@ Navigation::Navigation(
); );
navigationHistory = Gtk::make_managed<navigation::History>( navigationHistory = Gtk::make_managed<navigation::History>(
db, database,
ACTION__HISTORY_BACK, ACTION__HISTORY_BACK,
ACTION__HISTORY_FORWARD ACTION__HISTORY_FORWARD
); );
@ -73,7 +73,7 @@ Navigation::Navigation(
); );
navigationRequest = Gtk::make_managed<navigation::Request>( navigationRequest = Gtk::make_managed<navigation::Request>(
db, database,
ACTION__RELOAD, ACTION__RELOAD,
ACTION__UPDATE ACTION__UPDATE
); );
@ -115,7 +115,7 @@ int Navigation::session_restore(
sqlite3_stmt* statement; // @TODO move to the Database model namespace sqlite3_stmt* statement; // @TODO move to the Database model namespace
const int PREPARE_STATUS = sqlite3_prepare_v3( const int PREPARE_STATUS = sqlite3_prepare_v3(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
SELECT * FROM `app_browser_main_tab_page_navigation__session` SELECT * FROM `app_browser_main_tab_page_navigation__session`
@ -162,13 +162,13 @@ void Navigation::session_save(
) { ) {
// Delete previous session // Delete previous session
Database::Session::clean( Database::Session::clean(
db, database,
APP_BROWSER_MAIN_TAB_PAGE__SESSION__ID APP_BROWSER_MAIN_TAB_PAGE__SESSION__ID
); );
// Create new record // Create new record
const sqlite3_int64 APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID = Database::Session::add( const sqlite3_int64 APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID = Database::Session::add(
db, database,
APP_BROWSER_MAIN_TAB_PAGE__SESSION__ID APP_BROWSER_MAIN_TAB_PAGE__SESSION__ID
); );
@ -257,12 +257,12 @@ void Navigation::set_request_text(
// Database model // Database model
int Navigation::Database::Session::init( int Navigation::Database::Session::init(
sqlite3 * db sqlite3 * database
) { ) {
char * error; char * error;
return sqlite3_exec( return sqlite3_exec(
db, database,
R"SQL( R"SQL(
CREATE TABLE IF NOT EXISTS `app_browser_main_tab_page_navigation__session` CREATE TABLE IF NOT EXISTS `app_browser_main_tab_page_navigation__session`
( (
@ -277,14 +277,14 @@ int Navigation::Database::Session::init(
} }
int Navigation::Database::Session::clean( int Navigation::Database::Session::clean(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE__SESSION__ID const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE__SESSION__ID
) { ) {
char * error; // @TODO char * error; // @TODO
sqlite3_stmt * statement; sqlite3_stmt * statement;
const int PREPARE_STATUS = sqlite3_prepare_v3( const int PREPARE_STATUS = sqlite3_prepare_v3(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
SELECT * FROM `app_browser_main_tab_page_navigation__session` SELECT * FROM `app_browser_main_tab_page_navigation__session`
@ -309,7 +309,7 @@ int Navigation::Database::Session::clean(
// Delete record // Delete record
const int EXEC_STATUS = sqlite3_exec( const int EXEC_STATUS = sqlite3_exec(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
DELETE FROM `app_browser_main_tab_page_navigation__session` WHERE `id` = %d DELETE FROM `app_browser_main_tab_page_navigation__session` WHERE `id` = %d
@ -325,12 +325,12 @@ int Navigation::Database::Session::clean(
if (EXEC_STATUS == SQLITE_OK) if (EXEC_STATUS == SQLITE_OK)
{ {
navigation::History::Database::Session::clean( navigation::History::Database::Session::clean(
db, database,
APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID
); );
navigation::Request::Database::Session::clean( navigation::Request::Database::Session::clean(
db, database,
APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID
); );
} }
@ -343,13 +343,13 @@ int Navigation::Database::Session::clean(
} }
sqlite3_int64 Navigation::Database::Session::add( sqlite3_int64 Navigation::Database::Session::add(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE__SESSION__ID const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE__SESSION__ID
) { ) {
char * error; // @TODO char * error; // @TODO
sqlite3_exec( sqlite3_exec(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
INSERT INTO `app_browser_main_tab_page_navigation__session` ( INSERT INTO `app_browser_main_tab_page_navigation__session` (
@ -366,6 +366,6 @@ sqlite3_int64 Navigation::Database::Session::add(
); );
return sqlite3_last_insert_rowid( return sqlite3_last_insert_rowid(
db database
); );
} }

10
src/app/browser/main/tab/page/navigation.hpp

@ -41,16 +41,16 @@ namespace app::browser::main::tab::page
}; // table fields index }; // table fields index
static int init( static int init(
sqlite3 * db sqlite3 * database
); // return sqlite3_exec status code ); // return sqlite3_exec status code
static int clean( static int clean(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE__SESSION__ID const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE__SESSION__ID
); // return sqlite3_finalize status code ); // return sqlite3_finalize status code
static sqlite3_int64 add( static sqlite3_int64 add(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE__SESSION__ID const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE__SESSION__ID
); // return sqlite3_last_insert_rowid ); // return sqlite3_last_insert_rowid
}; };
@ -62,7 +62,7 @@ namespace app::browser::main::tab::page
private: private:
// Database // Database
sqlite3 * db; sqlite3 * database;
// Components // Components
navigation::Base * navigationBase; navigation::Base * navigationBase;
@ -81,7 +81,7 @@ namespace app::browser::main::tab::page
public: public:
Navigation( Navigation(
sqlite3 * db, sqlite3 * database,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__OPEN_LINK_VARIANT, const Glib::RefPtr<Gio::SimpleAction> & ACTION__OPEN_LINK_VARIANT,

26
src/app/browser/main/tab/page/navigation/history.cpp

@ -5,13 +5,13 @@
using namespace app::browser::main::tab::page::navigation; using namespace app::browser::main::tab::page::navigation;
History::History( History::History(
sqlite3 * db, sqlite3 * database,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD
) { ) {
// Init database // Init database
Database::Session::init( Database::Session::init(
this->db = db this->database = database
); );
// Init widget // Init widget
@ -62,7 +62,7 @@ int History::session_restore(
sqlite3_stmt* statement; // @TODO move to the Database model namespace sqlite3_stmt* statement; // @TODO move to the Database model namespace
const int PREPARE_STATUS = sqlite3_prepare_v3( const int PREPARE_STATUS = sqlite3_prepare_v3(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
SELECT * FROM `app_browser_main_tab_page_navigation_history__session` SELECT * FROM `app_browser_main_tab_page_navigation_history__session`
@ -129,7 +129,7 @@ void History::session_save(
) { ) {
// Delete previous records for session // Delete previous records for session
Database::Session::clean( Database::Session::clean(
db, database,
APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID
); );
@ -137,7 +137,7 @@ void History::session_save(
int offset = -1; for (const auto & MEMORY : memory) int offset = -1; for (const auto & MEMORY : memory)
{ {
Database::Session::add( Database::Session::add(
db, database,
APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID, APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID,
MEMORY.time, MEMORY.time,
MEMORY.request, MEMORY.request,
@ -233,12 +233,12 @@ bool History::try_forward(
// Database model // Database model
int History::Database::Session::init( int History::Database::Session::init(
sqlite3 * db sqlite3 * database
) { ) {
char * error; char * error;
return sqlite3_exec( return sqlite3_exec(
db, database,
R"SQL( R"SQL(
CREATE TABLE IF NOT EXISTS `app_browser_main_tab_page_navigation_history__session` CREATE TABLE IF NOT EXISTS `app_browser_main_tab_page_navigation_history__session`
( (
@ -255,14 +255,14 @@ int History::Database::Session::init(
} }
int History::Database::Session::clean( int History::Database::Session::clean(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID
) { ) {
char * error; // @TODO char * error; // @TODO
sqlite3_stmt * statement; sqlite3_stmt * statement;
const int PREPARE_STATUS = sqlite3_prepare_v3( const int PREPARE_STATUS = sqlite3_prepare_v3(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
SELECT * FROM `app_browser_main_tab_page_navigation_history__session` SELECT * FROM `app_browser_main_tab_page_navigation_history__session`
@ -282,7 +282,7 @@ int History::Database::Session::clean(
{ {
// Delete record // Delete record
const int EXEC_STATUS = sqlite3_exec( const int EXEC_STATUS = sqlite3_exec(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
DELETE FROM `app_browser_main_tab_page_navigation_history__session` WHERE `id` = %d DELETE FROM `app_browser_main_tab_page_navigation_history__session` WHERE `id` = %d
@ -311,7 +311,7 @@ int History::Database::Session::clean(
} }
sqlite3_int64 History::Database::Session::add( sqlite3_int64 History::Database::Session::add(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID, const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID,
const int & TIME, const int & TIME,
const Glib::ustring & REQUEST, const Glib::ustring & REQUEST,
@ -320,7 +320,7 @@ sqlite3_int64 History::Database::Session::add(
char * error; // @TODO char * error; // @TODO
sqlite3_exec( sqlite3_exec(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
INSERT INTO `app_browser_main_tab_page_navigation_history__session` ( INSERT INTO `app_browser_main_tab_page_navigation_history__session` (
@ -346,6 +346,6 @@ sqlite3_int64 History::Database::Session::add(
); );
return sqlite3_last_insert_rowid( return sqlite3_last_insert_rowid(
db database
); );
} }

10
src/app/browser/main/tab/page/navigation/history.hpp

@ -42,16 +42,16 @@ namespace app::browser::main::tab::page::navigation
}; // table fields index }; // table fields index
static int init( static int init(
sqlite3 * db sqlite3 * database
); // return sqlite3_exec status code ); // return sqlite3_exec status code
static int clean( static int clean(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID
); // return sqlite3_finalize status code ); // return sqlite3_finalize status code
static sqlite3_int64 add( static sqlite3_int64 add(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID, const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID,
const int & TIME, const int & TIME,
const Glib::ustring & REQUEST, const Glib::ustring & REQUEST,
@ -66,7 +66,7 @@ namespace app::browser::main::tab::page::navigation
private: private:
// Database // Database
sqlite3 * db; sqlite3 * database;
// Components // Components
history::Back * historyBack; history::Back * historyBack;
@ -91,7 +91,7 @@ namespace app::browser::main::tab::page::navigation
std::vector<Memory> memory; std::vector<Memory> memory;
History( History(
sqlite3 * db, sqlite3 * database,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD
); );

26
src/app/browser/main/tab/page/navigation/request.cpp

@ -4,13 +4,13 @@ using namespace app::browser::main::tab::page::navigation;
// Construct // Construct
Request::Request( Request::Request(
sqlite3 * db, sqlite3 * database,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__RELOAD, const Glib::RefPtr<Gio::SimpleAction> & ACTION__RELOAD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE
) { ) {
// Init database // Init database
Database::Session::init( Database::Session::init(
this->db = db this->database = database
); );
// Init actions // Init actions
@ -95,7 +95,7 @@ int Request::session_restore(
sqlite3_stmt* statement; // @TODO move to the Database model namespace sqlite3_stmt* statement; // @TODO move to the Database model namespace
const int PREPARE_STATUS = sqlite3_prepare_v3( const int PREPARE_STATUS = sqlite3_prepare_v3(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
SELECT * FROM `app_browser_main_tab_page_navigation_request__session` SELECT * FROM `app_browser_main_tab_page_navigation_request__session`
@ -139,13 +139,13 @@ int Request::session_save(
) { ) {
// Delete previous records // Delete previous records
Database::Session::clean( Database::Session::clean(
db, database,
APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID
); );
// Add new record // Add new record
return Database::Session::add( return Database::Session::add(
db, database,
APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID, APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID,
get_text() get_text()
); );
@ -153,12 +153,12 @@ int Request::session_save(
// Database model // Database model
int Request::Database::Session::init( int Request::Database::Session::init(
sqlite3 * db sqlite3 * database
) { ) {
char * error; char * error;
return sqlite3_exec( return sqlite3_exec(
db, database,
R"SQL( R"SQL(
CREATE TABLE IF NOT EXISTS `app_browser_main_tab_page_navigation_request__session` CREATE TABLE IF NOT EXISTS `app_browser_main_tab_page_navigation_request__session`
( (
@ -174,14 +174,14 @@ int Request::Database::Session::init(
} }
int Request::Database::Session::clean( int Request::Database::Session::clean(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID
) { ) {
char * error; // @TODO char * error; // @TODO
sqlite3_stmt * statement; sqlite3_stmt * statement;
const int PREPARE_STATUS = sqlite3_prepare_v3( const int PREPARE_STATUS = sqlite3_prepare_v3(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
SELECT * FROM `app_browser_main_tab_page_navigation_request__session` SELECT * FROM `app_browser_main_tab_page_navigation_request__session`
@ -201,7 +201,7 @@ int Request::Database::Session::clean(
{ {
// Delete record // Delete record
const int EXEC_STATUS = sqlite3_exec( const int EXEC_STATUS = sqlite3_exec(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
DELETE FROM `app_browser_main_tab_page_navigation_request__session` WHERE `id` = %d DELETE FROM `app_browser_main_tab_page_navigation_request__session` WHERE `id` = %d
@ -230,14 +230,14 @@ int Request::Database::Session::clean(
} }
sqlite3_int64 Request::Database::Session::add( sqlite3_int64 Request::Database::Session::add(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID, const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID,
const Glib::ustring & TEXT const Glib::ustring & TEXT
) { ) {
char * error; // @TODO char * error; // @TODO
sqlite3_exec( sqlite3_exec(
db, database,
Glib::ustring::sprintf( Glib::ustring::sprintf(
R"SQL( R"SQL(
INSERT INTO `app_browser_main_tab_page_navigation_request__session` ( INSERT INTO `app_browser_main_tab_page_navigation_request__session` (
@ -257,6 +257,6 @@ sqlite3_int64 Request::Database::Session::add(
); );
return sqlite3_last_insert_rowid( return sqlite3_last_insert_rowid(
db database
); );
} }

10
src/app/browser/main/tab/page/navigation/request.hpp

@ -36,16 +36,16 @@ namespace app::browser::main::tab::page::navigation
}; // table fields index }; // table fields index
static int init( static int init(
sqlite3 * db sqlite3 * database
); // return sqlite3_exec status code ); // return sqlite3_exec status code
static int clean( static int clean(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID
); // return sqlite3_finalize status code ); // return sqlite3_finalize status code
static sqlite3_int64 add( static sqlite3_int64 add(
sqlite3 * db, sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID, const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID,
const Glib::ustring & TEXT const Glib::ustring & TEXT
); // return sqlite3_last_insert_rowid ); // return sqlite3_last_insert_rowid
@ -58,7 +58,7 @@ namespace app::browser::main::tab::page::navigation
private: private:
// Database // Database
sqlite3 * db; sqlite3 * database;
// Actions // Actions
Glib::RefPtr<Gio::SimpleAction> action__reload, Glib::RefPtr<Gio::SimpleAction> action__reload,
@ -79,7 +79,7 @@ namespace app::browser::main::tab::page::navigation
public: public:
Request( Request(
sqlite3 * db, sqlite3 * database,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__RELOAD, const Glib::RefPtr<Gio::SimpleAction> & ACTION__RELOAD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE
); );

Loading…
Cancel
Save