Skip to content

Commit

Permalink
More modern C++ and use of snake_case for function names
Browse files Browse the repository at this point in the history
  • Loading branch information
teusbenschop committed May 25, 2024
1 parent d9194c6 commit 3d04fd1
Show file tree
Hide file tree
Showing 65 changed files with 520 additions and 504 deletions.
2 changes: 1 addition & 1 deletion assets/header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ std::string Assets_Header::run ()
bool start_button = true;

// Whether tabbed mode is on.
bool tabbed_mode_on = menu_logic_can_do_tabbed_mode () && database::config::general::getMenuInTabbedViewOn ();
bool tabbed_mode_on = menu_logic_can_do_tabbed_mode () && database::config::general::get_menu_in_tabbed_view_on ();

std::string menublock {};
const std::string item = m_webserver_request.query ["item"];
Expand Down
10 changes: 5 additions & 5 deletions bb/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,16 +366,16 @@ void bible_logic::kick_unsent_data_timer ()
{
// The timer contains the oldest age of Bible data on a client not yet sent to the Cloud.
// If the timer has been set already, bail out.
if (database::config::general::getUnsentBibleDataTime () != 0) return;
if (database::config::general::get_unsent_bible_data_time () != 0) return;

// Stamp with the current time.
database::config::general::setUnsentBibleDataTime (filter::date::seconds_since_epoch ());
database::config::general::set_unsent_bible_data_time (filter::date::seconds_since_epoch ());
}


void bible_logic::kick_unreceived_data_timer ()
{
database::config::general::setUnreceivedBibleDataTime (filter::date::seconds_since_epoch ());
database::config::general::set_unreceived_bible_data_time (filter::date::seconds_since_epoch ());
}


Expand All @@ -388,7 +388,7 @@ std::string bible_logic::unsent_unreceived_data_warning ()
#ifdef HAVE_CLIENT

// Time-stamp for oldest unreceived Bible data.
int data_time = database::config::general::getUnreceivedBibleDataTime ();
int data_time = database::config::general::get_unreceived_bible_data_time ();
// A value of 0 means that it is not relevant.
if (data_time) {
const int now = filter::date::seconds_since_epoch ();
Expand All @@ -405,7 +405,7 @@ std::string bible_logic::unsent_unreceived_data_warning ()
}

// Time-stamp for oldest unsent Bible data.
data_time = database::config::general::getUnsentBibleDataTime ();
data_time = database::config::general::get_unsent_bible_data_time ();
// A value of 0 means that there's no pending data.
if (data_time) {
const int now = filter::date::seconds_since_epoch ();
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ void bootstrap_index (Webserver_Request& webserver_request)
}

// Force setup.
if (config::logic::version () != database::config::general::getInstalledInterfaceVersion ()) {
if (config::logic::version () != database::config::general::get_installed_interface_version ()) {
webserver_request.reply = setup_index (webserver_request);
return;
}
Expand Down
26 changes: 13 additions & 13 deletions client/index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ void client_index_enable_client (Webserver_Request& webserver_request, const std
database_bibleactions.create ();
webserver_request.session_logic ()->set_username (username);
webserver_request.database_config_user()->setUpdatedSettings ({});
database::config::general::setUnsentBibleDataTime (0);
database::config::general::setUnreceivedBibleDataTime (filter::date::seconds_since_epoch ());
database::config::general::set_unsent_bible_data_time (0);
database::config::general::set_unreceived_bible_data_time (filter::date::seconds_since_epoch ());

// Set flag for first run after connecting.
database::config::general::setJustConnectedToCloud (true);
database::config::general::set_just_connected_to_cloud (true);

// Set it to repeat sync every so often.
if (database::config::general::getRepeatSendReceive () == 0) {
database::config::general::setRepeatSendReceive (2);
if (database::config::general::get_repeat_send_receive () == 0) {
database::config::general::set_repeat_send_receive (2);
}

// Schedule a sync operation straightaway.
Expand All @@ -106,10 +106,10 @@ std::string client_index (Webserver_Request& webserver_request)
if (webserver_request.query.count ("disable")) {
client_logic_enable_client (false);
client_index_remove_all_users (webserver_request);
database::config::general::setRepeatSendReceive (0);
database::config::general::setUnsentBibleDataTime (0);
database::config::general::setUnreceivedBibleDataTime (0);
database::config::general::setJustConnectedToCloud (false);
database::config::general::set_repeat_send_receive (0);
database::config::general::set_unsent_bible_data_time (0);
database::config::general::set_unreceived_bible_data_time (0);
database::config::general::set_just_connected_to_cloud (false);
}

bool connect = webserver_request.post.count ("connect");
Expand Down Expand Up @@ -142,7 +142,7 @@ std::string client_index (Webserver_Request& webserver_request)
}
}
// Store the address.
database::config::general::setServerAddress (address);
database::config::general::set_server_address (address);

int port = filter::strings::convert_to_int (config::logic::http_network_port ());
if (proceed) port = filter::strings::convert_to_int (webserver_request.post ["port"]);
Expand All @@ -151,7 +151,7 @@ std::string client_index (Webserver_Request& webserver_request)
view.set_variable ("error", translate ("Supply a port number"));
proceed = false;
}
database::config::general::setServerPort (port);
database::config::general::set_server_port (port);

std::string user {};
if (proceed) user = webserver_request.post ["user"];
Expand Down Expand Up @@ -186,10 +186,10 @@ std::string client_index (Webserver_Request& webserver_request)
if (client_logic_client_enabled ()) view.enable_zone ("clienton");
else view.enable_zone ("clientoff");

const std::string address {database::config::general::getServerAddress ()};
const std::string address {database::config::general::get_server_address ()};
view.set_variable ("address", address);

const int port {database::config::general::getServerPort ()};
const int port {database::config::general::get_server_port ()};
view.set_variable ("port", filter::strings::convert_to_string (port));

view.set_variable ("url", client_logic_link_to_cloud ("", ""));
Expand Down
12 changes: 6 additions & 6 deletions client/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ bool client_logic_client_enabled ()
#ifndef HAVE_CLIENT
return false;
#endif
return database::config::general::getClientMode ();
return database::config::general::get_client_mode ();
}


// Sets the Client mode.
// $enable: boolean: true or false.
void client_logic_enable_client (bool enable)
{
database::config::general::setClientMode (enable);
database::config::general::set_client_mode (enable);
}


Expand Down Expand Up @@ -78,8 +78,8 @@ std::string client_logic_connection_setup (std::string user, std::string hash)

std::string encoded_user = filter::strings::bin2hex (user);

std::string address = database::config::general::getServerAddress ();
int port = database::config::general::getServerPort ();
std::string address = database::config::general::get_server_address ();
int port = database::config::general::get_server_port ();

std::string url = client_logic_url (address, port, sync_setup_url ()) + "?user=" + encoded_user + "&pass=" + hash;

Expand Down Expand Up @@ -172,8 +172,8 @@ std::string client_logic_link_to_cloud (std::string path, std::string linktext)
std::string url {};
std::string external {};
if (client_logic_client_enabled ()) {
std::string address = database::config::general::getServerAddress ();
int port = database::config::general::getServerPort ();
std::string address = database::config::general::get_server_address ();
int port = database::config::general::get_server_port ();
url = address + ":" + filter::strings::convert_to_string (port);
if (!path.empty ()) {
url.append ("/");
Expand Down
2 changes: 1 addition & 1 deletion config/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ std::string site_url (Webserver_Request& webserver_request)
// No URL found yet.
// This occurs during scheduled tasks that require the URL to add it to emails sent out.
// Take the URL stored on login.
url = database::config::general::getSiteURL ();
url = database::config::general::get_site_url ();
return url;
}

Expand Down
2 changes: 1 addition & 1 deletion database/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ void database_cache_trim (bool clear)
// By default keep the resources cache for 30 days.
std::string days = "+30";
// If keeping the resources cache for an extended period of time, keep it for a full year.
if (database::config::general::getKeepResourcesCacheForLong()) days = "+365";
if (database::config::general::get_keep_resources_cache_for_long()) days = "+365";
// If free disk space is tighter, keep the caches for a shorter period.
if (percentage_disk_in_use > 80) days = "+14";
if (percentage_disk_in_use > 85) days = "+7";
Expand Down
4 changes: 2 additions & 2 deletions database/config/bible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,11 @@ void Database_Config_Bible::setSprintTaskCompletionCategories (std::string bible
}


int Database_Config_Bible::getRepeatSendReceive (std::string bible)
int Database_Config_Bible::get_repeat_send_receive (std::string bible)
{
return getIValue (bible, "repeat-send-receive", 0);
}
void Database_Config_Bible::setRepeatSendReceive (std::string bible, int value)
void Database_Config_Bible::set_repeat_send_receive (std::string bible, int value)
{
setIValue (bible, "repeat-send-receive", value);
}
Expand Down
4 changes: 2 additions & 2 deletions database/config/bible.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ class Database_Config_Bible
static void setCheckValidUTF8Text (std::string bible, bool value);
static std::string getSprintTaskCompletionCategories (std::string bible);
static void setSprintTaskCompletionCategories (std::string bible, std::string value);
static int getRepeatSendReceive (std::string bible);
static void setRepeatSendReceive (std::string bible, int value);
static int get_repeat_send_receive (std::string bible);
static void set_repeat_send_receive (std::string bible, int value);
static bool getExportChapterDropCapsFrames (std::string bible);
static void setExportChapterDropCapsFrames (std::string bible, bool value);
static std::string getPageWidth (std::string bible);
Expand Down
Loading

0 comments on commit 3d04fd1

Please sign in to comment.