import 2.4.1.0

This commit is contained in:
shaozhimin 2024-03-30 17:17:18 +08:00
parent 38b185a34b
commit c85353a65a
9 changed files with 510 additions and 9 deletions

View File

@ -144,6 +144,11 @@ static void k_settings_class_init(KSettingsClass *class)
0);
}
static int verify_file(char *file_name)
{
return 1;
}
/**
* @brief _g_main_loop_thread main_loop获取消息循环
* @param data
@ -1180,7 +1185,9 @@ int kdk_conf2_save_user_configure(const char *path)
{
if(0 != access(path, F_OK))
{
if(mkdir(path, 0777) < 0)
if(!verify_file(path))
return FALSE;
if (mkdir(path, 0777) < 0)
return FALSE;
}

View File

@ -480,7 +480,7 @@ class KYSettingsDBusService(dbus.service.Object):
cursor.execute("SELECT id FROM configures WHERE version_id = ? AND parent = ? AND group_name = ?", (version_id, parent_id, group_name))
parent_id = cursor.fetchone()[0]
# cursor.execute("SELECT * FROM configures WHERE version_id = ? AND parent = ? AND property = ?", (version_id, parent_id, key))
cursor.execute("UPDATE configures SET user_value = NULL WHERE version_id = ? AND parent = ? AND property = ?", (version_id, parent_id, key))
cursor.execute("UPDATE configures SET user_value = default_value WHERE version_id = ? AND parent = ? AND property = ?", (version_id, parent_id, key))
conn.commit()
conn.close()
if user == 'root':

View File

@ -0,0 +1,9 @@
find_package(PkgConfig REQUIRED)
pkg_check_modules(CONF2 REQUIRED kysdk-conf2)
include_directories(${CONF2_INCLUDE_DIRS})
add_executable(kyconf2-test kyconf2-test.c)
target_link_libraries(kyconf2-test ${CONF2_LIBRARIES})
install(TARGETS kyconf2-test
DESTINATION /usr/bin)

View File

@ -0,0 +1,402 @@
control-center:
3.20.1.31-0k2.11:
children:
powermanager:
keys:
sleep:
_type: b
default: 'true'
dormant:
_type: b
default: 'true'
shutdown:
_type: b
default: 'true'
switch-user:
_type: b
default: 'true'
apt:
children:
proxy:
keys:
enabled:
_type: b
default: 'false'
description: This key is used to control whether to open apt-proxy.
summary: Whether open
host:
_type: s
default: ''
description: The machine name to proxy APT through.
summary: APT proxy host name
port:
_type: i
default: '8080'
description: "The port on the machine defined by “/apt/proxy/host”\
\ that you\n proxy through."
range: 0,65535
summary: APT proxy port
desktop:
keys:
computer-icon-locking:
_type: b
default: 'true'
description: Whether lock computer icon on start menu or not.
summary: Lock computer icon on start menu
computer-icon-visible:
_type: b
default: 'true'
description: Whether show computer icon on desktop or not.
summary: Show computer icon on desktop
home-icon-visible:
_type: b
default: 'true'
description: Whether show home icon on desktop or not.
summary: Show home icon on desktop
menufull-screen:
_type: b
default: 'false'
description: Whether to always use the start menu in full screen.
summary: menufull-screen switch button
network-icon-visible:
_type: b
default: 'true'
description: Whether show network icon on desktop or not.
summary: Show network icon on desktop
personal-icon-locking:
_type: b
default: 'false'
description: Whether personal icon on start menu or not.
summary: Lock personal icon on start menu
settings-icon-locking:
_type: b
default: 'true'
description: Whether lock settings icon on start menu or not.
summary: Lock settings icon on start menu
trash-icon-locking:
_type: b
default: 'false'
description: Whether lock trash icon on start menu or not.
summary: Lock trash icon on start menu
trash-icon-visible:
_type: b
default: 'true'
description: Whether show trash icon on desktop or not.
summary: Show trash icon on desktop
volumes-visible:
_type: b
default: 'true'
description: Whether show volumes icon on desktop or not.
summary: Show volumes icon on desktop
enum_org.ukui.control-center.noticeorigin.Type:
- nick: none
value: '0'
- nick: corner
value: '1'
- nick: all
value: '2'
experienceplan:
keys:
join:
_type: b
default: 'true'
description: Whether this plugin would be activated by ukui-settings-daemon
or not
summary: join user experience plan
keybinding:
keys:
action:
_type: s
default: ''
description: Command associated with a custom keybinding.
summary: Command
binding:
_type: s
default: ''
description: Keybinding associated with a custom shortcut.
summary: Keybinding
name:
_type: s
default: ''
description: Description associated with a custom keybinding.
summary: Name
keyboard: {}
notice:
keys:
blacklist:
_type: as
default: '[]'
description: Hidden DektopList
summary: ''
enable-notice:
_type: b
default: 'true'
description: Whether an OSD notification is shown to notify about changes
summary: Show OSD notification
iscn-env:
_type: b
default: 'true'
description: Determine whether the environment is Chinese
summary: ''
show-new-feature:
_type: b
default: 'true'
description: Whether this plugin would be activated by ukui-settings-daemon
or not
summary: Activation of this plugin
show-on-lockscreen:
_type: b
default: 'true'
description: Binding to eject an optical disc.
summary: Eject
noticeorigin:
keys:
maximize:
_type: i
default: '3'
description: The maximize num of messages on notice window.
summary: maximize num of messages
messages:
_type: b
default: 'true'
description: .
summary: messages notice
name-cn:
_type: s
default: ''
description: The name passed to the sidebar
summary: app's name
name-us:
_type: s
default: ''
description: The name passed to the sidebar
summary: app's name
notification-style:
_type: s
default: mutative
description: 'Select the notification style. Supported values are "none",
"mutative","always".
If this is "none", notifications don''t show up on the screen,
but go to the notification center
If this is "mutative", show on the upper right corner of the screen,
it will disappear automatically.
If this is "always", remain on the screen until turned off.'
summary: The display style of the notification
show-detail:
_type: b
default: 'false'
description: Whether the notification show detail on screenlock
summary: ''
show-on-screenlock:
_type: b
default: 'false'
description: Whether the notification show on screenlock
summary: ''
type:
_type: enum
default: corner
description: the type of notice in system.
range: '@enum_org.ukui.control-center.noticeorigin.Type'
summary: type of notice message
voice:
_type: b
default: 'true'
description: .
summary: voice notice
osd:
keys:
show-lock-tip:
_type: b
default: 'true'
description: show keyboard tip or not. eg. Caps Lock. Num Lock
summary: show keyboard tip
panel:
children:
plugins:
keys:
calendar:
_type: s
default: lunar
description: calendar system used in UKUI Desktop Environment ,ontrol
by ukui-panel and ukui-control-center
summary: Lunar calendar
date:
_type: s
default: cn
description: date format
summary: date formate
firstday:
_type: s
default: monday
description: Select the first day of the week
summary: first of week
hoursystem:
_type: s
default: '24'
description: hoursystem used in UKUI Desktop Environment ,ontrol by
ukui-panel and ukui-control-center
summary: HourSystem status
nightmodestatus:
_type: b
default: 'false'
description: ''
summary: ukui-control-center sets the night mode status so that ukui-panel
can get the status
ntp:
_type: s
default: ''
description: user-defined ntp server address
summary: customize ntp server address
showlanguage:
_type: as
default: '[]'
description: show language in plugin area
summary: show language in plugin area
synctime:
_type: b
default: 'true'
description: ''
summary: sync time from network
themebynight:
_type: b
default: 'false'
description: ''
summary: ukui-control-center theme changes follow with the night
mode
time:
_type: s
default: '24'
description: Select the first day of the week
summary: first of week
timezones:
_type: as
default: '[]'
description: other time zones
summary: all time zones of time display
personalise:
keys:
blurry:
_type: i
default: '3'
description: 1- Low effect;2-Middle effect;3-High effect
summary: Control the frosted glass effect of the component
custompower:
_type: b
default: 'false'
description: Used to determine that the control panel user has customized
a power plan
summary: Whether to customize the power plan
effect:
_type: b
default: 'true'
description: 'ture:Special effects open; false: Special effects off'
summary: Control panel special effects transmit signal
save-transparency:
_type: i
default: '100'
description: Save the transparency before the special effects mode is
turned off
summary: Save the transparency before the special effects mode is turned
off
transparency:
_type: d
default: '0.65'
description: Control the transparency of all components
summary: Control the transparency of all components
plugins:
keys:
plugin-name:
_type: s
default: ''
description: the name to match status
summary: plugin's name
show:
_type: b
default: 'true'
description: .
summary: whether the plugin's status
pluginstatus: {}
wifi:
children:
switch:
keys:
switch:
_type: b
default: 'true'
description: wifi switch
summary: wifi switch
switchor:
_type: b
default: 'true'
description: wifi switch of kylin network manager
summary: wifi switchor
wificard:
_type: b
default: 'true'
description: Determine if the wireless network card is inserted
summary: Wireless network card
keys:
fonts-list:
_type: as
default: '[''CESI仿宋-GB13000'',''CESI_FS_GB13000'', ''CESI仿宋-GB18030'',''CESI_FS_GB18030'',
''CESI仿宋-GB2312'',''CESI_FS_GB2312'', ''CESI宋体-GB13000'',''CESI_SS_GB13000'',
''CESI宋体-GB18030'',''CESI_SS_GB18030'', ''CESI宋体-GB2312'',''CESI_SS_GB2312'',
''CESI小标宋-GB13000'',''CESI_XBS_GB13000'', ''CESI小标宋-GB18030'',''CESI_XBS_GB18030'',
''CESI小标宋-GB2312'',''CESI_XBS_GB2312'', ''CESI楷体-GB13000'',''CESI_KT_GB13000'',
''CESI楷体-GB18030'',''CESI_KT_GB18030'', ''CESI楷体-GB2312'',''CESI_KT_GB2312'',
''CESI黑体-GB13000'',''CESI_HT_GB13000'', ''CESI黑体-GB18030'',''CESI_HT_GB18030'',
''CESI黑体-GB2312'',''CESI_HT_GB2312'', ''仿宋'', ''黑体'', ''楷体'', ''宋体'', ''华文彩云'',''STCaiyun'',
''华文仿宋'',''STFangsong'', ''华文琥珀'',''STHupo'', ''华文楷体'',''STKaiti'', ''华文隶书'',''STLiti'',
''华文宋体'',''STSong'', ''华文细黑'',''STXihei'', ''华文行楷'',''STXingkai'', ''华文新魏'',''STXinwei'',
''Noto Sans CJK SC'', ''Noto Sans CJK SC Black'', ''Noto Sans Mono CJK SC'',
''Noto Sans CJK SC DemiLight'', ''Noto Sans CJK SC Light'', ''Noto Sans
CJK SC Medium'', ''Noto Sans CJK SC'', ''Noto Sans CJK SC Thin'',''Dotted
Songti Square'',''WenQuanYi Bitmap Song'']'
description: Control panel default font list
summary: Control panel default font list
2.0.0.0-0k0.0:
children:
powermanager:
keys:
sleep:
_type: b
default: 'true'
dormant:
_type: b
default: 'true'
shutdown:
_type: b
default: 'true'
switch-user:
_type: b
default: 'true'
apt:
children:
proxy:
keys:
enabled:
_type: b
default: 'false'
description: This key is used to control whether to open apt-proxy.
summary: Whether open
host:
_type: s
default: ''
description: The machine name to proxy APT through.
summary: APT proxy host name
port:
_type: i
default: '8080'
description: "The port on the machine defined by “/apt/proxy/host”\
\ that you\n proxy through."
range: 0,65535
summary: APT proxy port

View File

@ -0,0 +1,68 @@
#include "../api/libkysettings.h"
#include <stdio.h>
#include <unistd.h>
//键值改变信号回调函数
static void on_key_changed(KSettings *setting, char *key, void *user_data)
{
printf("on key change signal\n");
}
int main(int argc, char *argv[])
{
KSettings *setting = kdk_conf2_new("systemd.powermanager", NULL);
if(NULL == setting)
{
printf("get handle failed\n");
return 0;
}
//链接键值改变信号
/**
*
*
*/
// kdk_conf2_connect_signal(setting, "changed::sleep", on_key_changed, NULL);
//读配置
char *value = kdk_conf2_get_value(setting, "sleep");
if(NULL != value)
{
printf("sleep user value: %s\n", value);
free(value);
}
//读默认配置
value = kdk_conf2_get_default_value(setting, "sleep");
if (NULL != value)
{
printf("sleep default value: %s\n", value);
free(value);
}
//读对应数据类型的值
//调用获取对应数据类型的接口前调用has_key确保键存在。否则无法保证返回值的准确性
if(kdk_conf2_has_key(setting, "sleep"))
{
int b_sleep = kdk_conf2_get_boolean(setting, "sleep");
printf("sleep user boolean: %s\n", b_sleep ? "true" : "false");
b_sleep = kdk_conf2_get_default_boolean(setting, "sleep");
printf("sleep defalut boolean: %s\n", b_sleep ? "true" : "false");
}
//设置键值
int success = kdk_conf2_set_value(setting, "sleep", "true");
if(0 == success)
{
printf("set value failed\n");
}
//其它接口参考头文件或接口文档
usleep(10);
//注销句柄
kdk_conf2_ksettings_destroy(setting);
return 0;
}

View File

@ -1070,7 +1070,7 @@
> 描述
>
> 注册回调函数以应键值改变信号
> 注册回调函数以应键值改变信号
> 参数
>

View File

@ -28,6 +28,10 @@
#include <stdlib.h>
#include <unistd.h>
#include "jsonparse.h"
#include "xmlparse.h"
#include "gsettingsparse.h"
typedef enum
{
KDK_CONF_XML,

View File

@ -24,6 +24,7 @@
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
static int verify_file(char *pFileName)

View File

@ -255,6 +255,8 @@ char *size_to_human_string(int options, uint64_t bytes, int base)
c = *(letters + (exp ? exp / 10 : 0));
dec = exp ? bytes / (1ULL << exp) : bytes;
frac = exp ? bytes % (1ULL << exp) : 0;
double result = (double)bytes / (1ULL << exp);
*psuf++ = c;
if ((options & SIZE_SUFFIX_3LETTER) && (c != 'B')) {
@ -270,25 +272,33 @@ char *size_to_human_string(int options, uint64_t bytes, int base)
*psuf = '\0';
char res[24] = {0};
if (frac) {
if (options & SIZE_DECIMAL_2DIGITS) {
// frac = (frac / (1ULL << (exp - 10)) + 5) / 10;
// if (frac % 10 == 0)
// frac /= 10; /* convert N.90 to N.9 */
sprintf(res, "%.2f", result);
frac = (frac / (1ULL << (exp - 10)) + 5) / 10;
if (frac % 10 == 0)
frac /= 10; /* convert N.90 to N.9 */
sprintf(res, "%.f", result);
} else {
frac = (frac / (1ULL << (exp - 10)) + 50) / 100;
if (frac == 10)
dec++, frac = 0;
// frac = (frac / (1ULL << (exp - 10)) + 50) / 100;
// if (frac == 10)
// dec++, frac = 0;
sprintf(res, "%.1f", result);
}
}
if (frac) {
struct lconv const *l = localeconv();
char *dp = l ? l->decimal_point : NULL;
if (!dp || !*dp)
dp = ".";
snprintf(buf, sizeof(buf), "%d%s%" PRIu64 "%s", dec, dp, frac, suffix);
snprintf(buf, sizeof(buf), "%s%s", res, suffix);
} else
snprintf(buf, sizeof(buf), "%d%s", dec, suffix);