Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: Add settings for date and time format. #2283

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -16042,6 +16042,28 @@
" || ' in SecInfo updates before the end of the file'"
" || ' being processed.',"
" '100' );");

if (sql_int ("SELECT count(*) FROM settings"
" WHERE uuid = '" SETTING_UUID_USER_INTERFACE_TIME_FORMAT "'"
" AND " ACL_IS_GLOBAL () ";")
== 0)
sql ("INSERT into settings (uuid, owner, name, comment, value)"

Check warning on line 16050 in src/manage_sql.c

View check run for this annotation

Codecov / codecov/patch

src/manage_sql.c#L16050

Added line #L16050 was not covered by tests
" VALUES"
" ('" SETTING_UUID_USER_INTERFACE_TIME_FORMAT "', NULL,"
" 'User Interface Time Format',"
" 'Preferred time format to be used in client user interfaces.',"
" '24' );");

if (sql_int ("SELECT count(*) FROM settings"
" WHERE uuid = '" SETTING_UUID_USER_INTERFACE_DATE_FORMAT "'"
" AND " ACL_IS_GLOBAL () ";")
== 0)
sql ("INSERT into settings (uuid, owner, name, comment, value)"

Check warning on line 16061 in src/manage_sql.c

View check run for this annotation

Codecov / codecov/patch

src/manage_sql.c#L16061

Added line #L16061 was not covered by tests
" VALUES"
" ('" SETTING_UUID_USER_INTERFACE_DATE_FORMAT "', NULL,"
" 'User Interface Date Format',"
" 'Preferred date format to be used in client user interfaces.',"
" 'wdmy' );");
}

/**
Expand Down Expand Up @@ -52455,7 +52477,9 @@
|| strcmp (uuid, "578a1c14-e2dc-45ef-a591-89d31391d007") == 0
|| strcmp (uuid, "02e294fa-061b-11e6-ae64-28d24461215b") == 0
|| strcmp (uuid, "5a9046cc-0628-11e6-ba53-28d24461215b") == 0
|| strcmp (uuid, "a09285b0-2d47-49b6-a4ef-946ee71f1d5c") == 0))
|| strcmp (uuid, "a09285b0-2d47-49b6-a4ef-946ee71f1d5c") == 0
|| strcmp (uuid, "11deb7ff-550b-4950-aacf-06faeb7c61b9") == 0
|| strcmp (uuid, "d9857b7c-1159-4193-9bc0-18fae5473a69") == 0))

Check warning on line 52482 in src/manage_sql.c

View check run for this annotation

Codecov / codecov/patch

src/manage_sql.c#L52480-L52482

Added lines #L52480 - L52482 were not covered by tests
{
gsize value_size;
gchar *value, *quoted_uuid, *quoted_value;
Expand Down Expand Up @@ -52593,6 +52617,28 @@
}
}

if (strcmp (uuid, "11deb7ff-550b-4950-aacf-06faeb7c61b9") == 0)
{
int value_int;
/* User Interface Time Format */
if (sscanf (value, "%d", &value_int) != 1
|| (strcmp (value, "12") && strcmp (value, "24")))

Check warning on line 52625 in src/manage_sql.c

View check run for this annotation

Codecov / codecov/patch

src/manage_sql.c#L52625

Added line #L52625 was not covered by tests
{
g_free (value);
return 2;

Check warning on line 52628 in src/manage_sql.c

View check run for this annotation

Codecov / codecov/patch

src/manage_sql.c#L52627-L52628

Added lines #L52627 - L52628 were not covered by tests
}
}

if (strcmp (uuid, "d9857b7c-1159-4193-9bc0-18fae5473a69") == 0)
{
/* User Interface Date Format */
if (strcmp (value, "wmdy") && strcmp (value, "wdmy"))
{
g_free (value);
return 2;

Check warning on line 52638 in src/manage_sql.c

View check run for this annotation

Codecov / codecov/patch

src/manage_sql.c#L52637-L52638

Added lines #L52637 - L52638 were not covered by tests
}
}

quoted_value = sql_quote (value);
g_free (value);

Expand Down
10 changes: 10 additions & 0 deletions src/manage_sql.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@
*/
#define SETTING_UUID_SECINFO_SQL_BUFFER_THRESHOLD "316275a9-3629-49ad-9cea-5b3ab155b93f"

/**
* @brief UUID of 'User Interface Time Format' setting.
*/
#define SETTING_UUID_USER_INTERFACE_TIME_FORMAT "11deb7ff-550b-4950-aacf-06faeb7c61b9"

/**
* @brief UUID of 'User Interface Date Format' setting.
*/
#define SETTING_UUID_USER_INTERFACE_DATE_FORMAT "d9857b7c-1159-4193-9bc0-18fae5473a69"

/**
* @brief Trust constant for error.
*/
Expand Down
Loading