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

34
src/app/browser.cpp

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

10
src/app/browser.hpp

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

30
src/app/browser/main.cpp

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

10
src/app/browser/main.hpp

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -5,13 +5,13 @@ @@ -5,13 +5,13 @@
using namespace app::browser::main::tab::page::navigation;
History::History(
sqlite3 * db,
sqlite3 * database,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD
) {
// Init database
Database::Session::init(
this->db = db
this->database = database
);
// Init widget
@ -62,7 +62,7 @@ int History::session_restore( @@ -62,7 +62,7 @@ int History::session_restore(
sqlite3_stmt* statement; // @TODO move to the Database model namespace
const int PREPARE_STATUS = sqlite3_prepare_v3(
db,
database,
Glib::ustring::sprintf(
R"SQL(
SELECT * FROM `app_browser_main_tab_page_navigation_history__session`
@ -129,7 +129,7 @@ void History::session_save( @@ -129,7 +129,7 @@ void History::session_save(
) {
// Delete previous records for session
Database::Session::clean(
db,
database,
APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID
);
@ -137,7 +137,7 @@ void History::session_save( @@ -137,7 +137,7 @@ void History::session_save(
int offset = -1; for (const auto & MEMORY : memory)
{
Database::Session::add(
db,
database,
APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID,
MEMORY.time,
MEMORY.request,
@ -233,12 +233,12 @@ bool History::try_forward( @@ -233,12 +233,12 @@ bool History::try_forward(
// Database model
int History::Database::Session::init(
sqlite3 * db
sqlite3 * database
) {
char * error;
return sqlite3_exec(
db,
database,
R"SQL(
CREATE TABLE IF NOT EXISTS `app_browser_main_tab_page_navigation_history__session`
(
@ -255,14 +255,14 @@ int History::Database::Session::init( @@ -255,14 +255,14 @@ int History::Database::Session::init(
}
int History::Database::Session::clean(
sqlite3 * db,
sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID
) {
char * error; // @TODO
sqlite3_stmt * statement;
const int PREPARE_STATUS = sqlite3_prepare_v3(
db,
database,
Glib::ustring::sprintf(
R"SQL(
SELECT * FROM `app_browser_main_tab_page_navigation_history__session`
@ -282,7 +282,7 @@ int History::Database::Session::clean( @@ -282,7 +282,7 @@ int History::Database::Session::clean(
{
// Delete record
const int EXEC_STATUS = sqlite3_exec(
db,
database,
Glib::ustring::sprintf(
R"SQL(
DELETE FROM `app_browser_main_tab_page_navigation_history__session` WHERE `id` = %d
@ -311,7 +311,7 @@ int History::Database::Session::clean( @@ -311,7 +311,7 @@ int History::Database::Session::clean(
}
sqlite3_int64 History::Database::Session::add(
sqlite3 * db,
sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID,
const int & TIME,
const Glib::ustring & REQUEST,
@ -320,7 +320,7 @@ sqlite3_int64 History::Database::Session::add( @@ -320,7 +320,7 @@ sqlite3_int64 History::Database::Session::add(
char * error; // @TODO
sqlite3_exec(
db,
database,
Glib::ustring::sprintf(
R"SQL(
INSERT INTO `app_browser_main_tab_page_navigation_history__session` (
@ -346,6 +346,6 @@ sqlite3_int64 History::Database::Session::add( @@ -346,6 +346,6 @@ sqlite3_int64 History::Database::Session::add(
);
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 @@ -42,16 +42,16 @@ namespace app::browser::main::tab::page::navigation
}; // table fields index
static int init(
sqlite3 * db
sqlite3 * database
); // return sqlite3_exec status code
static int clean(
sqlite3 * db,
sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID
); // return sqlite3_finalize status code
static sqlite3_int64 add(
sqlite3 * db,
sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID,
const int & TIME,
const Glib::ustring & REQUEST,
@ -66,7 +66,7 @@ namespace app::browser::main::tab::page::navigation @@ -66,7 +66,7 @@ namespace app::browser::main::tab::page::navigation
private:
// Database
sqlite3 * db;
sqlite3 * database;
// Components
history::Back * historyBack;
@ -91,7 +91,7 @@ namespace app::browser::main::tab::page::navigation @@ -91,7 +91,7 @@ namespace app::browser::main::tab::page::navigation
std::vector<Memory> memory;
History(
sqlite3 * db,
sqlite3 * database,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,
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; @@ -4,13 +4,13 @@ using namespace app::browser::main::tab::page::navigation;
// Construct
Request::Request(
sqlite3 * db,
sqlite3 * database,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__RELOAD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE
) {
// Init database
Database::Session::init(
this->db = db
this->database = database
);
// Init actions
@ -95,7 +95,7 @@ int Request::session_restore( @@ -95,7 +95,7 @@ int Request::session_restore(
sqlite3_stmt* statement; // @TODO move to the Database model namespace
const int PREPARE_STATUS = sqlite3_prepare_v3(
db,
database,
Glib::ustring::sprintf(
R"SQL(
SELECT * FROM `app_browser_main_tab_page_navigation_request__session`
@ -139,13 +139,13 @@ int Request::session_save( @@ -139,13 +139,13 @@ int Request::session_save(
) {
// Delete previous records
Database::Session::clean(
db,
database,
APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID
);
// Add new record
return Database::Session::add(
db,
database,
APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID,
get_text()
);
@ -153,12 +153,12 @@ int Request::session_save( @@ -153,12 +153,12 @@ int Request::session_save(
// Database model
int Request::Database::Session::init(
sqlite3 * db
sqlite3 * database
) {
char * error;
return sqlite3_exec(
db,
database,
R"SQL(
CREATE TABLE IF NOT EXISTS `app_browser_main_tab_page_navigation_request__session`
(
@ -174,14 +174,14 @@ int Request::Database::Session::init( @@ -174,14 +174,14 @@ int Request::Database::Session::init(
}
int Request::Database::Session::clean(
sqlite3 * db,
sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID
) {
char * error; // @TODO
sqlite3_stmt * statement;
const int PREPARE_STATUS = sqlite3_prepare_v3(
db,
database,
Glib::ustring::sprintf(
R"SQL(
SELECT * FROM `app_browser_main_tab_page_navigation_request__session`
@ -201,7 +201,7 @@ int Request::Database::Session::clean( @@ -201,7 +201,7 @@ int Request::Database::Session::clean(
{
// Delete record
const int EXEC_STATUS = sqlite3_exec(
db,
database,
Glib::ustring::sprintf(
R"SQL(
DELETE FROM `app_browser_main_tab_page_navigation_request__session` WHERE `id` = %d
@ -230,14 +230,14 @@ int Request::Database::Session::clean( @@ -230,14 +230,14 @@ int Request::Database::Session::clean(
}
sqlite3_int64 Request::Database::Session::add(
sqlite3 * db,
sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID,
const Glib::ustring & TEXT
) {
char * error; // @TODO
sqlite3_exec(
db,
database,
Glib::ustring::sprintf(
R"SQL(
INSERT INTO `app_browser_main_tab_page_navigation_request__session` (
@ -257,6 +257,6 @@ sqlite3_int64 Request::Database::Session::add( @@ -257,6 +257,6 @@ sqlite3_int64 Request::Database::Session::add(
);
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 @@ -36,16 +36,16 @@ namespace app::browser::main::tab::page::navigation
}; // table fields index
static int init(
sqlite3 * db
sqlite3 * database
); // return sqlite3_exec status code
static int clean(
sqlite3 * db,
sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID
); // return sqlite3_finalize status code
static sqlite3_int64 add(
sqlite3 * db,
sqlite3 * database,
const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID,
const Glib::ustring & TEXT
); // return sqlite3_last_insert_rowid
@ -58,7 +58,7 @@ namespace app::browser::main::tab::page::navigation @@ -58,7 +58,7 @@ namespace app::browser::main::tab::page::navigation
private:
// Database
sqlite3 * db;
sqlite3 * database;
// Actions
Glib::RefPtr<Gio::SimpleAction> action__reload,
@ -79,7 +79,7 @@ namespace app::browser::main::tab::page::navigation @@ -79,7 +79,7 @@ namespace app::browser::main::tab::page::navigation
public:
Request(
sqlite3 * db,
sqlite3 * database,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__RELOAD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE
);

Loading…
Cancel
Save