Skip to content

Commit

Permalink
Add: Add settings for date and time format.
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h-abdelsalam committed Aug 21, 2024
1 parent 5ce67ca commit f05f839
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
48 changes: 47 additions & 1 deletion src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -16041,6 +16041,28 @@ check_db_settings ()
" || ' 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 16049 in src/manage_sql.c

View check run for this annotation

Codecov / codecov/patch

src/manage_sql.c#L16049

Added line #L16049 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 16060 in src/manage_sql.c

View check run for this annotation

Codecov / codecov/patch

src/manage_sql.c#L16060

Added line #L16060 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 @@ -52453,7 +52475,9 @@ modify_setting (const gchar *uuid, const gchar *name,
|| 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 52480 in src/manage_sql.c

View check run for this annotation

Codecov / codecov/patch

src/manage_sql.c#L52478-L52480

Added lines #L52478 - L52480 were not covered by tests
{
gsize value_size;
gchar *value, *quoted_uuid, *quoted_value;
Expand Down Expand Up @@ -52591,6 +52615,28 @@ modify_setting (const gchar *uuid, const gchar *name,
}
}

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 52623 in src/manage_sql.c

View check run for this annotation

Codecov / codecov/patch

src/manage_sql.c#L52623

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

Check warning on line 52626 in src/manage_sql.c

View check run for this annotation

Codecov / codecov/patch

src/manage_sql.c#L52625-L52626

Added lines #L52625 - L52626 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 52636 in src/manage_sql.c

View check run for this annotation

Codecov / codecov/patch

src/manage_sql.c#L52635-L52636

Added lines #L52635 - L52636 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

0 comments on commit f05f839

Please sign in to comment.