pax_global_header 0000666 0000000 0000000 00000000064 15241041773 0014516 g ustar 00root root 0000000 0000000 52 comment=50de1cb639abd537228770b210c7f2b047635f94
ukui-settings-daemon-4.0.10.1/ 0000775 0000000 0000000 00000000000 15241041773 0016013 5 ustar 00root root 0000000 0000000 ukui-settings-daemon-4.0.10.1/LICENSE 0000664 0000000 0000000 00000016744 15241041773 0017034 0 ustar 00root root 0000000 0000000 GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
ukui-settings-daemon-4.0.10.1/README.md 0000664 0000000 0000000 00000121027 15241041773 0017275 0 ustar 00root root 0000000 0000000 # ukui-settings-daemon
## 1 引言
`ukui-settings-daemon` 是`UKUI`桌面环境下的底层守护程序;
负责设置`UKUI`会话的各种参数以及运行的应用程序。
本文档为用户配置服务的介绍,针对组件的结构,模块设计,程序接口进行介绍。
### 项目安装依赖
1. 执行: `sudo mk-build-deps -ir debian/control` 会安装项目所有依赖
### 项目运行
1. 项目打包
- 根目录下执行如下命令,在上层目录生成 `deb` 文件
```shell
debuild -D
```
2. 项目安装
上层目录生成 `deb` 二进制文件后,进入上层目录,执行 `sudo dpkg -i ./ukui-settings-daemon_xxxx.deb`
3. 项目运行
安装后运行:`ukui-settings-daemon --replace`
## 模块介绍
| 模块 | 功能 | 插件名称 |
|--|--|--|
| 磁盘监控 | 实现系统中磁盘空间的监听报警功能。并提醒用户清空回收站 |housekeeping|
|远程服务|开启、关闭本地远程服务|sharing|
|光标提醒|在登录系统后,根据设置按下ctrl时以圆圈的方式提醒光标位置|usd-locate-pointer|
|系统快捷键|实现系统快捷键、自定义快捷键|media-key|
|用户自定义快捷键|实现用户自定义快捷键|keybindings|
|媒体按键|向多媒体播放器传递播放信号|mpris|
|输入设备管理|实时设置鼠标、触摸板的参数,并在用户登录时恢复至用户使用的参数|input-device-manager|
|键盘参数管理|实时设置键盘的参数,并在用户登录时恢复至用户使用的参数|keyboard|
|显示模式切换模块|通过ui交互获取用户选择的显示模式,并进行显示|kds|
|显示器管理模块|登录或者插拔显示器时,恢复用户配置|xrandr|
|色温管理|依据参数在特定时刻调整显示器色温值|color|
## 接口介绍
控制面板后台部分使用的接口分为gsettings与DBus,提供给内外部进行使用。
### gsettings
应用程序可以使用gsettings来保存用户配置信息并且确保用户隔离。程序在运行中进行设置、修改gsettings的已有的键值,但是不能通过程序代码创建新的键值,gsettings在一个叫做schema的规范文件中创建,schema(主题)文档其实是一个规范的xml文档。
应用程序通过信号槽来监视文件改动,并根据改动的key处理对应事件。
控制面板后台使用到如下schema:
- org.ukui.peripherals-keyboard
- org.ukui.peripherals-mouse
- org.ukui.peripherals-touchpad
- org.ukui.SettingsDaemon.plugins.color
- org.ukui.SettingsDaemon.plugins.housekeeping
- org.ukui.SettingsDaemon.plugins.media-keys
### org.ukui.peripherals-keyboard
#### **repeat**
取值范围:true,false。
用户打开控制面板,设置按键重复设置时,即设置此值。值为true时,长按按键重复输出按键,值为false时,长按按键不重复输出按键。
#### **rate**
取值范围10-110。
repeat为true时,此值为连续输出字符的速度。
#### **delay**
取值范围200-2100
当repeat为true时,延迟此值时间后,按照rate设置的速度连续输出字符。
#### **capslock-state**
实时记录用户设置的大写锁定按键,在开机时恢复为该值的设置。
#### **numlock-state**
实时记录用户设置的数字按键,在开机时恢复为该值的设置。
### **org.ukui.peripherals-mouse**
#### **left-handed**
设置鼠标主按键位置,当用户设置为左键时,左键为选择按键,当用户设置为右键时,右键为选择按键。
#### **wheel-speed**
实时响应该键值的数值,提取键值设置为鼠标滚轮速度。
#### **double-click**
实时响应该键值的数值,提取键值设置为双击间隔时长。
#### **motion-acceleration**
实时响应该键值的数值,提取键值设置为指针速速度。
#### **mouse-accel**
实时响应该键值的数值,提取键值设置为指针加速度。
#### **locate-pointer**
实时响应该键值的数值,并根据该键值具体情况,按下ctrl显示鼠标具体位置。
### **org.ukui.peripherals-touchpad**
#### **disable-on-external-mouse**
取值范围:true,false。
功能:
当用户开启插入鼠标时禁用触摸板,则在鼠标接入时,触摸板将不会生效。
#### **disable-while-typing**
取值范围:true,false。
功能:当用户开启打字时禁用触摸板,则打字期间触摸板将不会有任何影响。
#### **vertical-two-finger-scrolling**
取值范围:true,false。
功能:用户开选择垂直双指滑动时,该键值为ture,双指在触摸板滑动时,滚动条可根据情况进行滑动。
#### **horizontal-two-finger-scrolling**
取值范围:true,false。
功能:用户开选择水平双指滑动时,该键值为ture,双指在触摸板滑动时,滚动条可根据情况进行滑动。
#### **horizontal-edge-scrolling**
取值范围:true,false。
功能:用户开选择水平边际滑动时,该键值为ture,手指在触摸板边缘滑动时,滚动条可根据情况进行滑动。
#### **vertical-edge-scrolling**
取值范围:true,false。
功能:用户开选择水平垂直滑动时,设置该键值为ture,手指在触摸板边缘滑动时,滚动条可根据情况进行滑动。
### **org.ukui.SettingsDaemon.plugins.color**
#### **eye-care**
取值范围:true,false。
开启时使用 eye-care-value设置色温以达到护眼效果。
#### **eye-care-value**
取值范围:1100~6500k(暖->冷)
护眼模式对应的色温值。
#### **night-light-enabled**
取值范围:true,false。
夜间模式打开时,该值设置为true,夜间模式关闭时此值为false。
#### **night-light-allday**
取值范围:true,false。
时间选择全天时,该键值为true,跟随日出日落,或者自定义时,该值为false。
#### **night-light-temperature**
取值范围:1100~6500k(暖->冷)
设置根据该键值,在特定时间依据该键值设置色温。
#### **night-light-schedule-automatic**
取值范围:true,false。
设置为true时,根据night-light-schedule-automatic-from,night-light-schedule-automatic-to自动计算出时间段进入夜间模式。
#### night-light-schedule-automatic-from**
取值范围:00~23.98
夜间模式开始时间。
#### night-light-schedule-automatic-to**
取值范围:00~23.98
夜间模式结束时间。
#### **night-light-****schedule-from**
取值范围:00~23.98
自定义夜间模式开始时间。
#### **nig****ht-light-schedule****-to**
取值范围:00~23.98
自定义夜间模式结束时间。
## **DBus**
D-BUS是一种消息总线系统,是进程相互通信(IPC)的一种简单方式。除了进程间通信,D-BUS还有助于协调进程生命周期;它使编写“单实例”应用程序或守护程序变得简单而可靠,并在需要应用程序和守护程序的服务时按需启动它们。
BUS同时提供系统守护进程(用于“添加新硬件设备”或“打印机队列更改”等事件)和每个用户登录会话守护进程(用于用户应用程序之间的一般IPC需求)。此外,消息总线构建在通用的一对一消息传递框架之上,任何两个应用程序都可以使用该框架直接通信(无需通过消息总线守护进程)。目前,通信应用程序位于一台计算机上,或者通过适合在防火墙后与共享NFS主目录一起使用的未加密TCP/IP进行通信。(需要更好的远程传输方面的帮助-传输机制具有良好的抽象性和可扩展性)。
### **接口**
#### **/org/ukui/SettingsDaemon/GammaManager**
通过调整drm的gamma值来管理色温与亮度
##### **方法**
int setScreenBrightness(QString appName, QString screenName, int screenBrightness);
功能:设置指定显示器的亮度
参数:
appName 使用此接口的进程名称
screenName 显示器名称
screenBrightness 指定亮度
返回值:类型int
int setAllScreenBrightness(QString appName,int screenBrightness);
功能:设置全部显示器的亮度
参数:
appName 使用此接口的进程名称
screenBrightness 指定亮度
OutputGammaInfo getScreensGamma(QString appName);
功能:废弃
OutputGammaInfoList getScreensGammaList(QString appName);
功能:获取全部显示器的gamma信息
参数:
appName 使用此接口的进程名称
返回值:显示器信息提取接口:名称,rgb转化的色温,亮度,设置色温
ps:rgb转化的色温是通过drm接口获取gamma的rgb通道,然后反算为色温,色温是通过映射表内插为rgb通道设置到色温。
[('HDMI-1', 4120, 100, 4121), ('DP-2', 4120, 100, 4121)]
QHash getScreensGammaInfo(QString appName);
int setColorTemperature(QString appName, int colorTemp);
#### **信号**
void screenGammaChanged(QString screenName, int screenBrightness, int screenGamma);
gamma值的改变。
void screenBrightnessChanged(QString screenName, int screenBrightness);
指定显示器信号改变
void allScreenBrightnessChanged(QString screenName,int screenBrightness);
指定所有显示器亮度改变
#### **/org/ukui/SettingsDaemon/MediaKeys**
对外提供快捷键的设置接口
##### **方法**
mediaKeyForOtherApp(int32 action, String appName)
##### **信号**
#### **/org/ukui/SettingsDaemon/Sharing**
远程协助
##### **方法**
DisableService(String serviceName)
EnableService(String serviceName)
##### **信号**
#### **/org/ukui/SettingsDaemon/xrandr**
显示器相关设置
##### **方法**
getScreenMode(String appName)
参数:使用此接口的进程名称
返回值:类型int
0:第一屏模式
1:镜像屏幕模式
2:拓展屏幕模式
3:其他屏幕模式
功能:获取当前屏幕模式
getScreenParam(String appName)
参数:使用此接口的进程名称
返回值:json格式的字符串
功能:获取当前屏幕参数
setScreenMode(String modeName, String appName)
参数:
modeName:模式名称
“firstScreenMode”:第一屏模式
“cloneScreenMode”:镜像屏幕模式
“extendScreenMode”:拓展屏幕模式
“secondScreenMode”:其他屏幕模式
appName:调用此接口的程序名(后续考虑加密)
返回值:
功能:设置当前屏幕模式
setScreensParam(String screensParam, String appName)
> 参数:
screensParam:Json格式的屏幕参数
appName:调用此接口的进程名称(后续考虑加密)
返回值:无
功能:设置当前屏幕参数
参数示例
```c++
[
{
"enabled": true,
"id": "e2add05191c5c70db7824c9cd76e19f5",
"metadata": {
"fullname": "xrandr-LEN LI2224A-U5619HB8",
"name": "DP-2"
},
"mode": {
"refresh": 59.93387985229492,
"size": {
"height": 1080,
"width": 1920
}
},
"pos": {
"x": 0,
"y": 0
},
"primary": false,
"rotation": 1,
"scale": 1
}
]
```
##### **信号**
##### screenModeChanged(int32)
参数
- 0:第一屏模式
- 1:镜像屏幕模式
- 2:拓展屏幕模式
- 3:其他屏幕模式
屏幕模式发生改变时发送信号
##### screensParamChanged(String)
屏幕信息发生改变时发送信号
> 参数
Json格式的屏幕参数
## 详细设计
### 加载流程
main函数启动后,通过遍历包含settings-daemon关键字段的gsettings,并找出后缀名称并根据后缀名称加载对应的so文件。
### **函数说明**
#### **main.cpp**
int main (int argc, char* argv[])
参数
argc 参数个数,
argv 参数地址
返回值:int
功能:程序入口,调用**PluginManager**类激活各个功能。
void handler(int no)
参数
no 异常代码
返回值:无
功能:捕获kill信号,释放资源
#### plugin-manager.cpp
功能:遍历加载控制面板后台所有功能组件,并逐个初始化,激活。
PluginManager::**PluginManager**
参数:无
功能:构造函数,初始化资源
PluginManager::**~PluginManager**
参数:无
功能:析构函数,释放资源
PluginManager* PluginManager::**getInstance**
参数:无
返回值:PluginManager*
功能:获取实例
bool PluginManager::**managerStart**
参数:无
功能:用于初始化后,开始装载模块插件,并进行激活各个功能模块。
void PluginManager::**managerStop**
参数:无
功能:程序退出时释放插件资源。
static bool register_manager
参数:PluginManager
功能:检查dbus服务中是否有org.ukui.settingsdaemon服务,并以此判断ukui-settings-daemon是否已经启动。
#### plugin-interface.h
所有模块基于此类,暴露出activate接口与deactivate接口。功能模块通过实现activate执行自身业务逻辑,通过实现**deactivate** 退出模块并主动释放资源。
virtual **~PluginInterface**_() {};
虚析构函数
void **activate** () = 0;
纯虚函数,需要功能模块自己实现功能,实现自身业务逻辑。
**deactivate** () = 0;
纯虚函数,需要功能模块自己实现功能,退出模块,并主动释放资源
## 磁盘容量监控(housekeeping)设计说明
### **程序模块说明**
磁盘容量监控根据用户设置的报警阈值,在登录后,以及每隔两分钟检测磁盘剩余,当满足设置阈值时弹窗告知用户当前剩余容量,用户可选择清空回收站释放一定资源空间
### **函数说明**
#### **housekeeping-plugin.cpp**
PluginInterface *createSettingsPlugin
参数:无
返回值:PluginInterface *
功能:创建插件接口
PluginInterface *HousekeepingPlugin::getInstance
参数:无
返回值:PluginInterface *
功能:获取实例
HousekeepingPlugin::activate
参数:无
返回值:无
功能:激活插件功能(由main加载参数时遍历处理)
HousekeepingPlugin::deactivate
参数:无
返回值:无
功能:注销插件,释放资源
#### **housekeeping-manager.cpp**
HousekeepingManager::HousekeepingManager
参数:无
返回值:无
功能:构造方法,初始化资源
HousekeepingManager::~HousekeepingManager
参数:无
返回值:无
功能:注销插件,释放资源
HousekeepingManager::HousekeepingManagerStart
参数:无
返回值:无
功能:检测当前容量,开启定时器固定时间触发功能。
HousekeepingManager::HousekeepingManagerStop
参数:无
返回值:无
功能:注销插件,释放资源
#### **ldsm-trash-empty.cpp**
实现容量监控报警弹窗,并根据功能清空回收站。
LdsmTrashEmpty::**LdsmTrashEmpty**(QWidget *parent) :
QDialog(parent),
ui(new Ui::LdsmTrashEmpty)
LdsmTrashEmpty::~**_LdsmTrashEmpty_**()
void LdsmTrashEmpty::**checkButtonCancel**()
执行取消按钮
void LdsmTrashEmpty::**checkButtonTrashEmpty**()
执行清空回收站
void LdsmTrashEmpty::**deleteContents**(const QString path)
void LdsmTrashEmpty::**connectEvent**()
建立信号槽绑定按钮与事件的关系
void LdsmTrashEmpty::**usdLdsmTrashEmpty**()
功能:判断回收站是否为空,不为空则显示清空回收站按钮。
void LdsmTrashEmpty::**windowLayoutInit**()
容量监控弹窗初始化
## **模式切换**(**kds**)设计说明
### **模块说明**
从显示器参数管理提供的DBus接口中获取当前屏幕数量,并将用户设置的模式通过DBus发送到显示器参数管理模块。
### **函数说明**
#### **main.cpp**
main()
#### **widget.cpp**
Widget::**Widget**(QWidget *parent) :QWidget(parent),ui(new Ui::Widget)
参数:parent父窗口
返回值:无
功能:构造函数
Widget::~**_Widget_**()
参数:无
返回值:无
功能:析构函数
void Widget::**screensParamChangedSignal**(QString screensParam)
参数:显示器模式
返回值:无
功能:该方法为链接xrandr提供的屏幕模式改变信号的槽函数,当接收到该信号后关闭页面,并退出。
void Widget::**beginSetup**()
参数:无
返回值:无
功能:初始化窗口参数,窗口资源,并建立信号的链接。
void Widget::**setupComponent**()
参数:无
返回值:无
功能:调用xrandr提供的DBus接口,查询当前屏幕参数,查询当前屏幕模式,并设置初始值。
void Widget::**setupConnect**()
参数:无
返回值:无
功能:链接界面按钮的click事件,并实现具体选项的功能
QString Widget::**getScreensParam**()
参数:无
返回值:无
功能:获取屏幕参数,被**setupComponent**()使用
int Widget::**getCurrentStatus**()
参数:无
返回值:无
功能:获取当前屏幕所处模式,传递给**initCurrentStatus**使用
void Widget::**initCurrentStatus**(int id)
参数:初始屏幕模式
返回值:无
功能:窗口打开标记当前所处的模式,
void Widget::**setScreenModeByDbus**(QString modeName)
参数:需要设置的屏幕模式
返回值:无
功能:当用户选需要设置的显示模式时,调用xrandr提供的DBus接口:setScreenMode,将用户选择的模式传递给xrandr组件,由xrandr组件实现具体功能。
## **键盘参数管理****(****keyboard****)设计说明**
### **模块说明**
针对控制面板的键盘设置项:按键重复,延迟,速度,按键提示提供接口,当用户操作控制面板时,由控制面板设置对应的参数,后台监控到参数改动时设置对应参数。
并且记录用户对与大小写,数字键的操作,当用户按下按键时,记录状态,重启后恢复用户的操作习惯。
### **算法及流程**
### **keyboard-manager.cpp**
static KeyboardManager *KeyboardManagerNew()
参数:无
返回值:无
功能:工厂模式,实例化一个mKeyboardManager对象,调用其他所需函数接口。
bool KeyboardManager::KeyboardManagerStart()
参数:无
返回值:无
功能:keyboard的启动函数,调用相关初始化函数进行启动项设置。
void KeyboardManager::numlock_install_xkb_callback ()
参数:无
返回值:无
功能:keyboard键盘大小写设置,开机检测是否开启大小写键,回调其函数调用x事件进行相关设定。
void KeyboardManager::start_keyboard_idle_cb ()
参数:无
返回值:无
功能:键盘设置的初始化函数,启动监盘时从此处开始进行,调用gsettings的相关配置文件,进行读取初始化。
void apply_settings (QString);
参数:str
返回值:无
功能:读取系统下的gsettings配置文件,进行读取设置相关参数与键盘功能是否开启,如大小写等。
void XkbEventsFilter(int keyCode);
参数:int
返回值:无
功能:在x服务事件下的,一些键值事件的处理。
void KeyboardManager::KeyboardManagerStop()
参数:无
返回值:无
功能:keyboard组件的disactive之前的操作,通过KeyboardManagerStop函数对其相关功能的关闭。
#### **keybindings-plugin.cpp**
PluginInterface *createSettingsPlugin
参数:无
返回值:PluginInterface *
功能:创建插件接口
PluginInterface *KeyboardPlugin::getInstance
参数:无
返回值:PluginInterface *
功能:获取实例交于main.cpp的方法使用
KeyboardPlugin::activate
参数:无
返回值:无
功能:激活插件功能(由main加载参数时遍历处理)
KeyboardPlugin::deactivate
参数:无
返回值:无
功能:注销插件,释放资源
KeyboardManager::KeyboardManager(QObject * parent)
参数:父窗口指针,当父窗口被delete时,会自动释放其关联的子窗口。
返回值:无
功能:构造函数
KeyboardManager::~KeyboardManager()
参数:无
返回值:无
功能:析构函数
KeyboardManager *KeyboardManager::KeyboardManagerNew()
参数:无
返回值:无
功能:实例化键盘管理
bool KeyboardManager::KeyboardManagerStart()
参数:无
返回值:无
功能:开启定时器,并绑定超时信号到槽方法start_keyboard_idle_cb。
void KeyboardManager::KeyboardManagerStop()
参数:无
返回值:无
功能:释放资源。
void KeyboardManager::start_keyboard_idle_cb ()
参数:无
返回值:无
功能:依次调用usd_keyboar_manager_apply_settings应用当前参数配置,并针对org.ukui.peripherals-keyboard的改变信号与槽函数apply_settings建立关联。
void KeyboardXkb::usd_keyboard_xkb_init(KeyboardManager* kbd_manager)
参数:无
返回值:无
功能:针对org.mate.peripherals-keyboard-xkb.general、org.mate.peripherals-keyboard-xkb.kbd建立相关槽函数,当发生改变时借由mate进行实现。
void numlock_xkb_init (KeyboardManager *manager)
参数:无
返回值:无
功能:字母灯状态初始化
usd_keyboard_manager_apply_settings (this);
参数:无
返回值:无
功能:应用当前所有配置
void KeyboardManager::apply_settings (QString keys)
参数:无
返回值:无
功能:并针对org.ukui.peripherals-keyboard的改变信号的槽函数,当产生改变信号后由此方法实现改变的键值。
## **系统快捷键****(****media-keys****)设计说明**
### **模块说明**
快捷键,又叫快速键或热键,指通过某些特定的按键、[按键](https://baike.baidu.com/item/%E6%8C%89%E9%94%AE/7194192)顺序或按键组合来完成一个操作,很多快捷键往往与如 Ctrl 键、Shift 键、Alt 键、Fn 键、 Enter键等配合使用。利用快捷键可以代替[鼠标](https://baike.baidu.com/item/%E9%BC%A0%E6%A0%87/122323)做一些工作,用户可以方便快速的完成一些操作。
### **算法及流程**
### **mediakey-manager.cpp**
bool MediaKeysManager::mediaKeysStart(GError*)
参数:GError
返回值:无
功能:mediakey激活之后的启动函数,此处开始调用相关的快捷键初始化接口,对其相关功能与配置进行初始化操作。
void mediaKeysStop();
参数:无
返回值:无
功能:mediakey组件相关功能的注销函数,此时相关功能处理挂起失效状态,还未注销其后台进程。
void initScreens();
参数:无
返回值:无
功能:初始化screen,调用函数gdk_display_get_default与gdk_display_get_default_screen(display)接口。
void MediaKeysManager::initXeventMonitor()
参数:无
返回值:无
功能:x服务下对keypress的监控响应与keyrelease事件的释放功能。
bool MediaKeysManager::getScreenLockState()
参数:无
返回值:无
功能:函数内部写有dbus接口,通过调用回调的mDbusScreensaveMessage获取当前的ScreenLockState的状态。
void doMicSoundAction()
参数:无
返回值:无
功能:键盘中声音快捷键设置的函数入口,通过键盘音量键,设置音量的大小与提示框的ui可视化显示。
void doBrightAction(int)
参数:int
返回值:无
功能:键盘中可视化亮度快捷键设置的函数入口,键盘的亮度调节功能,设置亮度的变化与可视化ui窗口的显示。
void doPowerOffAction();
参数:无
返回值:无
功能:对屏幕键盘的快捷键函数接口,按下电源power键,对屏幕的息屏相关操作的处理。
void doTouchpadAction(int);
参数:int
返回值:无
功能:对笔记本触摸板的相关设置,通过控制面板,调用读取触摸板的gesttings的配置文件org.ukui.peripherals-touchpad接口进行读与属性的设置。
#### **keybindings-plugin.cpp**
PluginInterface *createSettingsPlugin
参数:无
返回值:PluginInterface *
功能:创建插件接口
PluginInterface *HousekeepingPlugin::getInstance
参数:无
返回值:PluginInterface *
功能:获取实例
KeybindingsPlugin::activate
参数:无
返回值:无
功能:激活插件功能(由main加载参数时遍历处理)
KeybindingsPlugin::deactivate
参数:无
返回值:无
功能:注销插件,释放资源
## **定位器参数管理****(****input-device-manager****)设计说明**
### **模块说明**
## **代码文件说明**
### **input-device-manager.cpp**
Void managerStart()
参数:无
返回值:无
功能:组件启动入口函数
Bool initDeviceFactor()
参数:bool
返回值:无
功能:初始化设备工厂,根据环境(X/Wayland)创建不同设备工厂
Void eliminateSpecialDevice()
参数:无
返回值:无
功能:剔除和触摸板product ID 一致的mouse 设备
Void clearUpDeviceList()
参数:无
返回值:无
功能:清空设备列表
Void connctGsettings()
参数:无
返回值: 无
功能:gsettings 监听
Void classifyDevice(InputDevice* device)
参数:Inputdevice*
返回值:无
功能:根据设备类型进行筛选,放入对应的list
Void disconnectAll()
参数:无
返回值:无
功能:断开所有连接
Bool deleteDevice(QVariant deviceId)
参数:QVariant
返回值:bool
功能:根据设备ID 删除对应设备
Bool existMouse()
参数:无
返回值:bool
功能:检测鼠标设备是否存在
Void disbleTouchpadMousePresent()
参数:无
返回值:无
功能:插入鼠标禁用触摸板
Void deviceAdd(InputDevice* device)
参数:InputDevice*
返回值:无
功能:添加设备
Void deviceRemove(QVariant deviceId)
参数:QVariant
返回值:无
功能:设备拔出时的处理
Void onMouseChanged(const QString& , QVariant)
参数:const QString& , QVariant
返回值:无
功能:鼠标gsettings 值变化的处理
Void onTouchpadChanged(const QString& , QVariant)
参数:const QString& , QVariant
返回值:无
功能:触摸板gsettings值变化的处理
### **input-device/input-x-device/input-wayland-device(.cpp)**
InputXDevice InputWaylandDevice 继承自InputDevice,公共函数如下:
virtual void setEnable(QVariant value) = 0;
参数:QVarint
返回值:无
功能:设置设备使能状态
virtual void setLeftMode(QVariant value) = 0;
参数:QVarint
返回值:无
功能:设置设备左右手模式
virtual void setNaturalScroll(QVariant value) = 0;
参数:QVarint
返回值:无
功能:设置设备滚动方向
virtual void setTapclick(QVariant value) = 0;
参数:QVarint
返回值:无
功能:设置设备轻触点击
virtual void setTapDrag(QVariant value) = 0;
参数:QVarint
返回值:无
功能:设置设备轻触拖拽
virtual void setDisableTyping(QVariant value) = 0;
参数:QVarint
返回值:无
功能:设置设备打字禁用
virtual void setAccelSpeed(QVariant value) = 0;
参数:QVarint
返回值:无
功能:设置设备光标加速
virtual void setAcceleration(QVariant value) = 0;
参数:QVarint
返回值:无
功能:设置设备光标速度
virtual void setMiddleButtonEmulation(QVariant value) = 0;
参数:QVarint
返回值:无
功能:设置设备模拟中键点击
virtual void setScrolling(QVariant value) = 0;
参数:QVarint
返回值:无
功能:设置设备滚动状态
virtual void setDisableTpMoPresent(QVariant value) = 0;
参数:QVarint
返回值:无
功能:设置插入鼠标禁用触摸板
virtual void setWheelSpeed(QVariant value) = 0;
参数:QVarint
返回值:无
功能:设置设备滚轮速度
virtual QVariant getProductId() = 0;
参数:无
返回值:QVariant
功能:获取设备ProductID
### **input-device-factor.cpp**
void initInputDevices()
参数:无
返回值:无
功能:初始化设备列表
void connectMonitor()
参数:无
返回值:无
功能:启动设备监听
InputDevice* createInputDevice(QVariant deviceId, DeviceType type, QString name);
参数:QVariant , DeviceType ,QString
返回值:InputDevice*
功能:创建InputDevice设备
InputDevice* filterDevice(XDeviceInfo device / QDBusInterface * interface)
参数:XDeviceInfo (x环境)或者 QDBusInterface* (wayland)
返回值:InputDevice*
功能:根据设备属性过滤设备
### **input-device-helper.cpp**
bool supportXinputExtension();
参数:无
返回值:bool
功能:检测是否支持X扩展
Atom properyToAtom(const char* propery);
参数:const char*
返回值:Atom
功能:属性name 转换Atom
Atom deviceHadProperty(int device, const char* propName);
参数:int ,const char*
返回值:const char*
功能:功能:检测设备属性是否存在,返回此属性原子
Atom deviceHadProperty(int device, Atom prop);
参数:int , Atom
返回值:Atom
功能:检测设备属性是否存在,返回此属性原子
QVariantList getDeviceProp(int device, const char *property);
参数:int , const char*
返回值:QVariantList
功能: 获取设备属性值列表
QVariantList getDeviceProp(int device, Atom prop);
参数:int , Atom
返回值:QVariantList
功能: 获取设备属性值列表
void setDeviceProp(int device, const char *property ,QVariantList value);
参数:int , const char* ,QVariantList
返回值:无
功能: 设置设备属性
void setDeviceProp(int device, Atom prop, QVariantList value);
参数:int , Atom ,QVariantList
返回值:无
功能: 设置设备属性
int getDeviceButtonMap(int device, unsigned char** map);
参数:int , unsigned char**
返回值:int
功能: 获取设备的button map,存入map
void setDeviceButtonMap(int device, int buttons, unsigned char* map);
参数:int , int , unsigned char*
返回值:无
功能:设置按钮映射
void disable(int device);
参数:int
返回值:无
功能:禁用设备
void enabel(int device);
参数:int
返回值:无
功能:启用设备
### **input-gsettings.cpp**
管理输入设备的gsettings。
### **input-monitor.cpp**
X环境下监听设备插拔。
### **input-process-settings.cpp**
部分设备属性通过其他进程实现。
### **keybindings-plugin.cpp**
PluginInterface *createSettingsPlugin
参数:无
返回值:PluginInterface *
功能:创建插件接口
PluginInterface *InputDevicePlugin::getInstance
参数:无
返回值:PluginInterface *
功能:获取实例
InputDevicePlugin::activate
参数:无
返回值:无
功能:激活插件功能(由main加载参数时遍历处理)
InputDevicePlugin::deactivate
参数:无
返回值:无
功能:注销插件,释放资源
## **多媒体快捷键****(****mpris****)设计说明**
### **模块说明**
特殊媒体快捷按键,可以控制一些媒体播放器的快捷键,如: 播放、暂停、停止等。
### **mpris-manager.cpp**
bool MprisManagerStart(GError **error)
参数:GError
返回值:无
功能:媒体快捷键的函数启动初始化入口,实现了对dbus信号等的接收,对象的实例化,与回调的过程。
void MprisManagerStop()
参数:无
返回值:无
功能:mpris快捷键功能资源的释放与stop过程。
void MprisManager::serviceRegisteredSlot(const QString& service)
参数:const str
返回值:无
功能:A media player was just run and should be added to the head of @mPlayerQuque.。
void MprisManager::serviceUnregisteredSlot(const QString& service)
参数:const str
返回值:无
功能:if anyone dbus service that from @busNames quit,this func will be called。
void keyPressed(QString,QString)
参数:str
返回值:无
功能:after catch MediaPlayerKeyPressed() signal, this function will be called。
## **声音提醒****(**sound**)设计说明**
### **模块说明**
提示音设置,listen for org.mate.sound。
### **sound-manager.cpp**
bool SoundManagerStart(GError **error)
参数:GError
返回值:无
功能:Starting sound manager begin,use gsettings that We listen for change of the selected theme。
void SoundManagerStop()
参数:无
返回值:无
功能:Stopping sound manager,释放了一些所需要的object资源。
void SoundManager::trigger_flush ()
参数:无
返回值:无
功能:We delay the flushing a bit so that we can coalesce multiple changes into a single cache flush 。
bool SoundManager::register_directory_callback (const QString path, GError **error)
参数:const str,GError
返回值:bool
功能:对注册服务之后收到事件的回调,,并建立其对file_monitor_changed_cb接口的connect。
#### **keybindings-plugin.cpp**
PluginInterface *createSettingsPlugin
参数:无
返回值:PluginInterface *
功能:创建插件接口
PluginInterface *HousekeepingPlugin::getInstance
参数:无
返回值:PluginInterface *
功能:获取实例
KeybindingsPlugin::activate
参数:无
返回值:无
功能:激活插件功能(由main加载参数时遍历处理)
KeybindingsPlugin::deactivate
参数:无
返回值:无
功能:注销插件,释放资源
## **光标提醒****(****usd-locate-pointer****)设计说明**
### **模块说明**
对光标事件的设置,使用gdk的应用对光标的start、pause、rewind、fps、duration、running等可视化事件的处理配置。
参数:无
返回值:PluginInterface *
功能:创建插件接口
PluginInterface *HousekeepingPlugin::getInstance
参数:无
返回值:PluginInterface *
功能:获取实例
KeybindingsPlugin::activate
参数:无
返回值:无
功能:激活插件功能(由main加载参数时遍历处理)
KeybindingsPlugin::deactivate
参数:无
返回值:无
功能:注销插件,释放资源
## **热插拔设备管理****(****xinput****)设计说明**
### **模块说明**
xinput对输入设备的管理,主要通过预定设计的配置文件去管理与驱动一些input设备,可以降低出现问题的概率与多次热插拔之后响应速率延时的问题。
### **算法及流程**
### **xinputmanager.cpp**
void updateButtonMap()
参数:无
返回值:无
功能:更新触控笔映射
void XinputManager::SetPenRotation(int device_id)
参数:int
返回值:无
功能:触控笔函数的处理接口,通过对输入设备id的获取与识别,对其进行相关的屏幕触控映射处理。
int EventSift(XIHierarchyEvent *event, int flag)
参数:XIHierarchyEvent ,int
返回值:int
功能:筛选出发生事件的设备ID,所有设备的事件信息与当前发生的事件,若失败返回-1,成功则返回获取到的id值。
void ListeningToInputEvent()
参数:无
返回值:无
功能:ListeningToInputEvent此函数主要对其所有输入设备的事件进行监控。
#### **keybindings-plugin.cpp**
PluginInterface *createSettingsPlugin
参数:无
返回值:PluginInterface *
功能:创建插件接口
PluginInterface *HousekeepingPlugin::getInstance
参数:无
返回值:PluginInterface *
功能:获取实例
KeybindingsPlugin::activate
参数:无
返回值:无
功能:激活插件功能(由main加载参数时遍历处理)
KeybindingsPlugin::deactivate
参数:无
返回值:无
功能:注销插件,释放资源
## **显示器伽马参数管理****(****原color****)设计说明**
### **模块说明**
色温管理模块监听并读取控制面板设置参数:gsettings:org.ukui.SettingsDaemon.plugins.color,dbus:/org/ukui/SettingsDaemon/GammaManager
每分钟对比一次当前时间与预设的日出日落时间如果处于日落之后、日出之前则将当前显示器色温调整为预设色温。日出之后、日落之前则调整为正常状态。
日出日落的时间根据选项进行提取,如果是自定义则提取用户设置的值:
如果跟随日出日落则提取则提取系统缺省值。
#### **启动流程**
软件启动时,获取当前的桌面环境,如果是X则走X分支使用gamma管理色温,如果是wayland则走kwin接口设置色温。
### **gamma-manager-plugin.cpp**
插件入口,根据环境变量加载gamma-manager.cpp或者gamma-manager-wayland.cpp
### **gamma-manager.cpp**
x相关设置逻辑
### **gamma-manager-wayland.cpp**
wayland设置,
### **gamma-manager-location.cpp**
地理位置相关问题,提供给gamma-manager,gamma-manager-wayland使用
### **gamma-manager-helper.cpp**
设置gtk相关配置
### **gamma-manager-gtkconfig.cpp**
## **显示器参数管理****(****xrandr****)设计说明**
### **模块说明**
该模块记录用户设置的每组显示器参数,当接入已配置过的显示器时通过《显示参数恢复功能》恢复用户设置的参数,当显示器从未接入过,或者配置文件损坏时按照《缺省显示规则_》_进行设置,参数设置成功后,按照触摸设备映射规则进行重新映射触摸屏、触控笔与显示器的关系。
#### **显示参数恢复功能**
该功能将接入过的显示器参数保存至唯一码命名的配置文件,并根据当前的显示模式保存至:实时参数文件夹,第一屏参数文件夹,其他屏幕参数文件夹,镜像屏参数文件夹,通过此种方法可恢复用户在任意模式下的屏幕参数并进行恢复,无需用户再次针对特定屏幕组合进行设置,从而达到一次设置终身使用的效果。
#### **唯一码生成方式**
根据显示器的edid信息生成MD5-hash编码,当有多个显示器接入时采用多个显示器的信息生成显示器组MD5-hash编码。
#### **缺省显示规则**
第一屏
最大分辨率显示首个识别到的屏幕,设置为主屏并放置到(0,0)点坐标进行显示。
其他屏
最大分辨率显示器最后一个识别到的屏幕,设置为主屏并放置到(0,0)点坐标进行显示。
镜像屏幕
取出多个屏幕中共同存在的最大分辨率,并同时设置到(0,0)点进行显示。
拓展屏幕
将第一个识别到的屏幕设置为主屏,并放到(0,0)点,剩余的屏幕放到(第一个屏幕宽,0)坐标进行显示。
#### **触摸设备****映射****规则**
当插件启动以及显示参数(分辨率、角度)发生变化时会触发此功能,对触摸设备进行重新映射。
**映射规则:**
首先读取控制面板生成的触摸配置文件,按照配置内取到的映射关系进行映射。
当配置文件内的映射关系全部处理完毕后,仍有部分设备没有映射时则按照如下规则进行映射:
按照屏幕绝对尺寸和触摸设备尺寸误差2%进行匹配映射先进行映射。对于剩余设备直接映射。
触摸屏与触控笔可映射到同一显示器。
#### **启动流程**
软件启动时,获取当前的屏幕唯一码然后根据配置文件存在情况进行设置:如存在则读取恢复,如不存在则设置为缺省参数进行设置。
#### **事件循环流程**
当用户修改屏幕参数时,根据当前屏幕模式将参数实时保存至对应的文件夹内。
当用户切换模式时,取出该模式下的对应参数进行设置,如对应参数文件夹的配置不存在时,则按照缺省规则进行显示,并将参数文件复制一份到实时参数文件夹。
当接入屏幕时,首先识别出唯一码,而后读取实时参数文件夹下以唯一码命名的参数文件并设置显示器,如文件不存在则按照缺省规则进行显示。
### **xrandr-manager.cpp**
void XrandrManager::StartXrandrIdleCb()
参数:无
返回值:无
功能:屏幕事件相关的初始化回调函数,对screen设备的读取配置信息,模式的设置等相关入口。
void XrandrManager::applyConfig()
参数:无
返回值:无
功能:函数apply的入口,设置了autoRemapTouchscreen的功能与sendScreenModeToDbus的信号发送。
void XrandrManager::outputConnectedWithoutConfigFile(KScreen::Output *newOutput, char outputCount)
参数:KScreen::Output *newOutput, char outputCount
返回值:无
功能:接入时没有配置文件的处理函数,即处理预定设置,单屏位最优分辨率,多屏幕为镜像模式。
void XrandrManager::setScreenModeToFirst(bool isFirstMode)
参数:bool
返回值:无
功能:设置屏幕为第一屏的函数入口,通过遍历input设备找到第一个屏幕(默认为内屏)。
void XrandrManager::RotationChangedEvent(const QString &rotation)
参数:const str
返回值:无
功能:获取status-manager发来的信号的dbus值,通过对pc与rotation信号的解析,设置屏幕旋转的角度与模式。
void XrandrManager::SaveConfigTimerHandle()
参数:无
返回值:无
功能:处理来自控制面板操作的接口,获取控制面板中对screen参数的设定,写入相应的配置文件进行保存映射。
void XrandrManager::autoRemapTouchscreen()
参数:无
返回值:无
功能:处理触摸屏的配置映射关系,读取配置文件映射关系映射,配置文件不满足所有设备时,进行按照设备物理尺寸匹配进行自动映射。
#### **keybindings-plugin.cpp**
PluginInterface *createSettingsPlugin
参数:无
返回值:PluginInterface *
功能:创建插件接口
PluginInterface *HousekeepingPlugin::getInstance
参数:无
返回值:PluginInterface *
功能:获取实例
KeybindingsPlugin::activate
参数:无
返回值:无
功能:激活插件功能(由main加载参数时遍历处理)
KeybindingsPlugin::deactivate
参数:无
返回值:无
功能:注销插件,释放资源
## **GDK参数设置**(**xsettings**)设计说明**
### **模块说明**
设置底层系统主题变量,设定了一些光标等ui事件的gdk主题。
## 代码统计
wc -l `find ./ -name "*.c";find -name "*.h";find -name "*.cpp"`
整理前:39196
wc -c `find ./ -name "*.c";find -name "*.h";find -name "*.cpp"`
整理前:1242208
ukui-settings-daemon-4.0.10.1/common/ 0000775 0000000 0000000 00000000000 15241041773 0017303 5 ustar 00root root 0000000 0000000 ukui-settings-daemon-4.0.10.1/common/QGSettings/ 0000775 0000000 0000000 00000000000 15241041773 0021333 5 ustar 00root root 0000000 0000000 ukui-settings-daemon-4.0.10.1/common/QGSettings/qconftype.cpp 0000664 0000000 0000000 00000023251 15241041773 0024052 0 ustar 00root root 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*-
* -*- coding: utf-8 -*-
*
* Copyright (C) 2023 KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "qconftype.h"
#include
#include "clib-syslog.h"
/**
* GVariant Type Name/Code C++ Type Name QVariant Type Name
* --------------------------------------------------------------------------
* boolean b bool QVariant::Bool
* byte y char QVariant::Char
* int16 n int QVariant::Int
* uint16 q unsigned int QVariant::UInt
* int32 i int QVariant::Int
* uint32 u unsigned int QVariant::UInt
* int64 x long long QVariant::LongLong
* uint64 t unsigned long long QVariant::ULongLong
* double d double QVariant::Double
* string s QString QVariant::String
* string array* as QStringList QVariant::StringList
* byte array ay QByteArray QVariant::ByteArray
* dictionary a{ss} QVariantMap QVariant::Map
*/
QVariant::Type qconf_types_convert(const GVariantType *gtype)
{
switch (g_variant_type_peek_string(gtype)[0]) {
case G_VARIANT_CLASS_BOOLEAN:
return QVariant::Bool;
case G_VARIANT_CLASS_BYTE:
return QVariant::Char;
case G_VARIANT_CLASS_INT16:
return QVariant::Int;
case G_VARIANT_CLASS_UINT16:
return QVariant::UInt;
case G_VARIANT_CLASS_INT32:
return QVariant::Int;
case G_VARIANT_CLASS_UINT32:
return QVariant::UInt;
case G_VARIANT_CLASS_INT64:
return QVariant::LongLong;
case G_VARIANT_CLASS_UINT64:
return QVariant::ULongLong;
case G_VARIANT_CLASS_DOUBLE:
return QVariant::Double;
case G_VARIANT_CLASS_STRING:
return QVariant::String;
case G_VARIANT_CLASS_ARRAY:
if (g_variant_type_equal(gtype, G_VARIANT_TYPE_STRING_ARRAY))
return QVariant::StringList;
else if (g_variant_type_equal(gtype, G_VARIANT_TYPE_BYTESTRING))
return QVariant::ByteArray;
else if (g_variant_type_equal(gtype, G_VARIANT_TYPE ("a{ss}")))
return QVariant::Map;
// fall through
default:
USD_LOG(LOG_DEBUG,"invalid:%d,%s",g_variant_type_peek_string(gtype)[0],gtype);
return QVariant::Invalid;
}
}
GVariant *qconf_types_collect_from_variant(const GVariantType *gtype, const QVariant &v)
{
switch (g_variant_type_peek_string(gtype)[0]) {
case G_VARIANT_CLASS_BOOLEAN:
return g_variant_new_boolean(v.toBool());
case G_VARIANT_CLASS_BYTE:
return g_variant_new_byte(v.toChar().cell());
case G_VARIANT_CLASS_INT16:
return g_variant_new_int16(v.toInt());
case G_VARIANT_CLASS_UINT16:
return g_variant_new_uint16(v.toUInt());
case G_VARIANT_CLASS_INT32:
return g_variant_new_int32(v.toInt());
case G_VARIANT_CLASS_UINT32:
return g_variant_new_uint32(v.toUInt());
case G_VARIANT_CLASS_INT64:
return g_variant_new_int64(v.toLongLong());
case G_VARIANT_CLASS_UINT64:
return g_variant_new_int64(v.toULongLong());
case G_VARIANT_CLASS_DOUBLE:
return g_variant_new_double(v.toDouble());
case G_VARIANT_CLASS_STRING:
return g_variant_new_string(v.toString().toUtf8());
case G_VARIANT_CLASS_ARRAY:
if (g_variant_type_equal(gtype, G_VARIANT_TYPE_STRING_ARRAY)) {
const QStringList list = v.toStringList();
GVariantBuilder builder;
g_variant_builder_init(&builder, G_VARIANT_TYPE_STRING_ARRAY);
Q_FOREACH(const QString& string, list)
g_variant_builder_add(&builder, "s", string.toUtf8().constData());
return g_variant_builder_end(&builder);
} else if (g_variant_type_equal(gtype, G_VARIANT_TYPE_BYTESTRING)) {
const QByteArray array = v.toByteArray();
gsize size = array.size();
gpointer data;
data = g_memdup(array.data(), size);
return g_variant_new_from_data(G_VARIANT_TYPE_BYTESTRING,
data, size, TRUE, g_free, data);
} else if (g_variant_type_equal(gtype, G_VARIANT_TYPE("a{ss}"))) {
GVariantBuilder builder;
g_variant_builder_init(&builder, G_VARIANT_TYPE ("a{ss}"));
QMapIterator it(v.toMap());
while (it.hasNext()) {
it.next();
QByteArray key = it.key().toUtf8();
QByteArray val = it.value().toByteArray();
g_variant_builder_add (&builder, "{ss}", key.constData(), val.constData());
}
return g_variant_builder_end (&builder);
}
// fall through
case G_VARIANT_CLASS_TUPLE:
if (g_variant_type_equal(gtype, "(dd)")) {
QVariantList doubleList = v.value();
if (doubleList.count() == 2)
{
return g_variant_new ("(dd)", doubleList[0].toDouble(), doubleList[1].toDouble());
} else {
return NULL;
}
}
break;
default:
return NULL;
}
}
QVariant qconf_types_to_qvariant(GVariant *value)
{
switch (g_variant_classify(value)) {
case G_VARIANT_CLASS_BOOLEAN:
return QVariant((bool) g_variant_get_boolean(value));
case G_VARIANT_CLASS_BYTE:
return QVariant((char) g_variant_get_byte(value));
case G_VARIANT_CLASS_INT16:
return QVariant((int) g_variant_get_int16(value));
case G_VARIANT_CLASS_UINT16:
return QVariant((unsigned int) g_variant_get_uint16(value));
case G_VARIANT_CLASS_INT32:
return QVariant((int) g_variant_get_int32(value));
case G_VARIANT_CLASS_UINT32:
return QVariant((unsigned int) g_variant_get_uint32(value));
case G_VARIANT_CLASS_INT64:
return QVariant((long long) g_variant_get_int64(value));
case G_VARIANT_CLASS_UINT64:
return QVariant((unsigned long long) g_variant_get_uint64(value));
case G_VARIANT_CLASS_DOUBLE:
return QVariant(g_variant_get_double(value));
case G_VARIANT_CLASS_STRING:
return QVariant(g_variant_get_string(value, NULL));
case G_VARIANT_CLASS_ARRAY:
if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING_ARRAY)) {
GVariantIter iter;
QStringList list;
const gchar *str;
g_variant_iter_init (&iter, value);
while (g_variant_iter_next (&iter, "&s", &str))
list.append (str);
return QVariant(list);
} else if (g_variant_is_of_type(value, G_VARIANT_TYPE_BYTESTRING)) {
return QVariant(QByteArray(g_variant_get_bytestring(value)));
} else if (g_variant_is_of_type(value, G_VARIANT_TYPE("a{ss}"))) {
GVariantIter iter;
QMap map;
const gchar *key;
const gchar *val;
g_variant_iter_init (&iter, value);
while (g_variant_iter_next (&iter, "{&s&s}", &key, &val))
map.insert(key, QVariant(val));
return map;
}
break;
// fall throughsudo apt install qtbase5-dev qt5-qmake qtchooser qtscript5-dev qttools5-dev-tools qtbase5-dev-tools libgsettings-qt-dev
case G_VARIANT_CLASS_TUPLE:
if (g_variant_is_of_type(value, G_VARIANT_TYPE("(dd)"))) {
QVariantList varList;
QVariant var;
double latitude,longitude;
g_variant_get(value, "(dd)", &latitude, &longitude);
varList.append(latitude);
varList.append(longitude);
var = varList;
return var;
}
default:
g_assert_not_reached();
break;
}
g_assert_not_reached();
// return QVariant((bool) g_variant_get_boolean(value));
}
// trans 'aa-bb' to 'aaBb'
QString qtify_name(const char *name)
{
bool next_cap = false;
QString result;
while (*name) {
if (*name == '-') {
next_cap = true;
} else if (next_cap) {
result.append(QChar(*name).toUpper().toLatin1());
next_cap = false;
} else {
result.append(*name);
}
name++;
}
return result;
}
gchar * unqtify_name(const QString &name)
{
const gchar *p;
QByteArray bytes;
GString *str;
bytes = name.toUtf8();
str = g_string_new (NULL);
for (p = bytes.constData(); *p; p++) {
const QChar c(*p);
if (c.isUpper()) {
g_string_append_c (str, '-');
g_string_append_c (str, c.toLower().toLatin1());
}
else {
g_string_append_c (str, *p);
}
}
return g_string_free(str, FALSE);
}
ukui-settings-daemon-4.0.10.1/common/QGSettings/qconftype.h 0000664 0000000 0000000 00000002420 15241041773 0023512 0 ustar 00root root 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*-
* -*- coding: utf-8 -*-
*
* Copyright (C) 2023 KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef QCONFTYPE_H
#define QCONFTYPE_H
#include
#include
QVariant::Type qconf_types_convert (const GVariantType* gtype);
GVariant* qconf_types_collect (const GVariantType* gtype, const void* argument);
GVariant* qconf_types_collect_from_variant(const GVariantType* gtype, const QVariant& v);
QVariant qconf_types_to_qvariant (GVariant* value);
void qconf_types_unpack (GVariant* value, void* argument);
QString qtify_name(const char *name);
gchar * unqtify_name(const QString &name);
#endif // QCONFTYPE_H
ukui-settings-daemon-4.0.10.1/common/QGSettings/qgsettings.cpp 0000664 0000000 0000000 00000016360 15241041773 0024235 0 ustar 00root root 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*-
* -*- coding: utf-8 -*-
*
* Copyright (C) 2023 KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "qgsettings.h"
#include "qconftype.h"
#include
#include
#include
#include
#include "clib-syslog.h"
struct QGSettingsPrivate
{
QByteArray path;
GSettingsSchema *schema;
QByteArray schemaId;
GSettings *settings;
gulong signalHandlerId;
static void settingChanged(GSettings *settings, const gchar *key, gpointer userData);
};
void QGSettingsPrivate::settingChanged(GSettings *, const gchar *key, gpointer userData)
{
QGSettings *self = (QGSettings *)userData;
/**
* 这里不属于 QObject的子类,只能通过此方法强制调用 QObject 子类的方法或信号
*
* Qt::QueuedConnection 发送一个QEvent,并在应用程序进入主事件循环后立即调用该成员。
* Qt::DirectConnection 立即调用
* Qt::BlockingQueuedConnection 则将以与Qt::QueuedConnection相同的方式调用该方法,除了当前线程将阻塞直到事件被传递。使用此连接类型在同一线程中的对象之间进行通信将导致死锁
* Qt::AutoConnection 则如果obj与调用者位于同一个线程中,则会同步调用该成员; 否则它将异步调用该成员
*
*/
QMetaObject::invokeMethod(self, "changed", Qt::AutoConnection, Q_ARG(QString, key));
}
static bool is_item_in_schema (const gchar* const* items, const QByteArray & item)
{
while (*items) {
if (g_strcmp0 (*items++, item) == 0) {
return true;
}
}
return false;
}
QGSettings::QGSettings(const QByteArray &schemaId, const QByteArray &path, QObject *parent) : QObject(parent)
{
mPriv = new QGSettingsPrivate;
mPriv->schemaId = schemaId;
mPriv->path = path;
if (false == is_item_in_schema (g_settings_list_schemas(), schemaId)){
mPriv->settings = nullptr;
return;
}
if (mPriv->path.isEmpty()) {
mPriv->settings = g_settings_new(mPriv->schemaId.constData());
} else {
mPriv->settings = g_settings_new_with_path(mPriv->schemaId.constData(), mPriv->path.constData());
}
g_object_get(mPriv->settings, "settings-schema", &mPriv->schema, NULL);
mPriv->signalHandlerId = g_signal_connect(mPriv->settings, "changed", G_CALLBACK(QGSettingsPrivate::settingChanged), this);
}
QGSettings::~QGSettings()
{
if (mPriv->schema) {
g_settings_sync ();
g_signal_handler_disconnect(mPriv->settings, mPriv->signalHandlerId);
g_object_unref (mPriv->settings);
g_settings_schema_unref (mPriv->schema);
}
delete mPriv;
}
QVariant QGSettings::get(const QString &key) const
{
gchar *gkey = unqtify_name(key);
if (mPriv->settings == nullptr) {
return -1;
}
if (!keys().contains(gkey)) {
USD_LOG(LOG_ERR, "can't find int key:%s in %s", gkey, mPriv->schemaId.data());
return QVariant(0);
}
GVariant *value = g_settings_get_value(mPriv->settings, gkey);
if( NULL == value) {
USD_LOG(LOG_DEBUG,"g_settings_get_value is failed");
return QVariant(0);
}
QVariant qvalue = qconf_types_to_qvariant(value);
g_variant_unref(value);
g_free(gkey);
return qvalue;
}
void QGSettings::set(const QString &key, const QVariant &value)
{
if (mPriv->settings == nullptr) {
return;
}
gchar *gkey = unqtify_name(key);
if (keys().contains(gkey)) {
if (!trySet(key, value))
USD_LOG(LOG_ERR,"unable to set key '%s' to value '%s'", key.toUtf8().constData(), value.toString().toUtf8().constData());
} else {
USD_LOG(LOG_ERR, "can't find int key:%s in %s", gkey, mPriv->schemaId.data());
}
}
bool QGSettings::trySet(const QString &key, const QVariant &value)
{
gchar *gkey = unqtify_name(key);
bool success = false;
/* fetch current value to find out the exact type */
GVariant *cur = g_settings_get_value(mPriv->settings, gkey);
GVariant *new_value = qconf_types_collect_from_variant(g_variant_get_type (cur), value);
if (new_value)
success = g_settings_set_value(mPriv->settings, gkey, new_value);
g_free(gkey);
g_variant_unref (cur);
return success;
}
void QGSettings::setEnum(const QString& key,int value)
{
if (mPriv->settings == nullptr) {
return ;
}
g_settings_set_enum (mPriv->settings,key.toLatin1().data(),value);
}
int QGSettings::getEnum(const QString& key)
{
int enumNum;
if (mPriv->settings == nullptr) {
return -1;
}
enumNum = g_settings_get_enum (mPriv->settings,key.toLatin1().data());
return enumNum;
}
char **QGSettings::getStrv(const QString& key)
{
return g_settings_get_strv(mPriv->settings,key.toLatin1().data());
}
void QGSettings::delay()
{
g_settings_delay(mPriv->settings);
}
void QGSettings::apply()
{
g_settings_apply(mPriv->settings);
}
QStringList QGSettings::keys() const
{
QStringList list;
//gchar **keys = g_settings_list_keys(mPriv->settings);
gchar **keys = g_settings_schema_list_keys(mPriv->schema);
for (int i = 0; keys[i]; i++)
list.append(keys[i]);
// list.append(qtify_name(keys[i]));
g_strfreev(keys);
return list;
}
QVariantList QGSettings::choices(const QString &qkey) const
{
gchar *key = unqtify_name (qkey);
GSettingsSchemaKey *schema_key = g_settings_schema_get_key (mPriv->schema, key);
GVariant *range = g_settings_schema_key_get_range(schema_key);
g_settings_schema_key_unref (schema_key);
g_free(key);
if (range == NULL)
return QVariantList();
const gchar *type;
GVariant *value;
g_variant_get(range, "(&sv)", &type, &value);
QVariantList choices;
if (g_str_equal(type, "enum")) {
GVariantIter iter;
GVariant *child;
g_variant_iter_init (&iter, value);
while ((child = g_variant_iter_next_value(&iter))) {
choices.append(qconf_types_to_qvariant(child));
g_variant_unref(child);
}
}
g_variant_unref (value);
g_variant_unref (range);
return choices;
}
void QGSettings::reset(const QString &qkey)
{
gchar *key = unqtify_name(qkey);
g_settings_reset(mPriv->settings, key);
g_free(key);
}
bool QGSettings::isSchemaInstalled(const QByteArray &schemaId)
{
GSettingsSchemaSource *source = g_settings_schema_source_get_default ();
GSettingsSchema *schema = g_settings_schema_source_lookup (source, schemaId.constData(), TRUE);
if (schema) {
g_settings_schema_unref (schema);
return true;
} else {
return false;
}
}
ukui-settings-daemon-4.0.10.1/common/QGSettings/qgsettings.h 0000664 0000000 0000000 00000007440 15241041773 0023701 0 ustar 00root root 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*-
* -*- coding: utf-8 -*-
*
* Copyright (C) 2023 KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef QGSETTINGS_H
#define QGSETTINGS_H
#include
#include
/**
* gsettings 的 key 必须是小写字符和下划线组成
* 此类将所有key转为驼峰方式
*/
class QGSettings : public QObject
{
Q_OBJECT
public:
/* 根据 schemaId 和 path 创建QGSettings对象 */
explicit QGSettings(const QByteArray& schemaId, const QByteArray& path=QByteArray(), QObject *parent = nullptr);
~QGSettings();
/**
* 根据key获取值, key不存在则报错
*
*/
QVariant get (const QString& key) const;
/**
* 根据 key 设定值
*/
void set (const QString& key, const QVariant& value);
/**
* 将QGSettings对象更改为'delay-apply'模式。
* 在此模式下,对设置的更改不会立即传播到后端,
* 而是在本地保存,直到调用apply()。
*/
void delay();
/**
* 应用对设置所做的任何更改。
* 这个函数什么都不做,除非设置是在“延迟-应用”模式;
* 看到delay ()。在正常情况下,总是立即应用设置。
*/
void apply();
/**
* @brief setEnum
* @param key
* @param value
* 在设置中查找枚举类型的nick以获取值并将其写入键。
* 给出一个不包含在架构中的键来进行设置或未将其标记为枚举类型,
* 或者将值设为不是该命名类型的有效值是程序员的错误。
* 执行写操作后,直接使用g_settings_get_string()
* 访问密钥将返回与值关联的'nick'。
*/
void setEnum(const QString& key,int value);
/**
* 获取存储在key设置中的值,并将其转换为它表示的枚举值。
* 为了使用此函数,值的类型必须为字符串,并且必须在模式文件中将其标记为枚举类型。
* 给出不包含在设置模式中或未标记为枚举类型的密钥是程序员的错误。
* 如果配置数据库中存储的值不是该枚举类型的有效值,则此函数将返回默认值。
*/
int getEnum(const QString& key);
/**
* g_settings_get()字符串数组的便捷变体。
* 给出一个key 未指定为的架构中的字符串类型数组是程序员的错误settings 。
* return: 一个新分配的,NULL终止的字符串数组,该值存储在key 中settings
*/
char **getStrv(const QString& key);
/**
*
*/
bool trySet (const QString& key, const QVariant& value);
/**
* 获取 key 的列表
*/
QStringList keys() const;
/**
*
*/
QVariantList choices (const QString& key) const;
/**
* 将 key 设为默认值
*/
void reset (const QString& key);
/**
* 根据给定 id 检查是否存在schema
*/
static bool isSchemaInstalled (const QByteArray& schemaId);
Q_SIGNALS:
/**
* key 的值改变时发射信号
*
*/
void changed (const QString& key);
private:
struct QGSettingsPrivate* mPriv;
friend struct QGSettingsPrivate;
};
#endif // QGSETTINGS_H
ukui-settings-daemon-4.0.10.1/common/clib-syslog.c 0000664 0000000 0000000 00000033076 15241041773 0021707 0 ustar 00root root 0000000 0000000 /* -*- Mode: C; indent-tabs-mode: nil; tab-width: 4 -*-
* -*- coding: utf-8 -*-
*
* Copyright (C) 2023 KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "clib-syslog.h"
#include
static char sysCategory[128] = {0};
static int sysFacility = 0;
void syslog_init(const char *category, int facility)
{
if (NULL == category) {
return;
}
memset(sysCategory, 0, sizeof sysCategory);
strncpy(sysCategory, category, sizeof sysCategory - 1);
sysFacility = facility;
}
//LOG_DEBUG,最低级
void syslog_info(int logLevel, const char *moduleName, const char *fileName, const char *functionName, int line, const char* fmt, ...)
{
//if (logLevel > LOG_LEVEL) return;
static char hadInit=0;
char buf[2048] = {0};
char *logLevelstr = NULL;
unsigned long tagLen = 0;
va_list para;
va_start(para, fmt);
if (!hadInit){
hadInit = 1;
syslog_init("ukui-settings-daemon", LOG_LOCAL6);
}
memset(buf, 0, sizeof buf);
openlog("", LOG_NDELAY, sysFacility);
switch (logLevel) {
case LOG_EMERG:
logLevelstr = "EMERG";
break;
case LOG_ALERT:
logLevelstr = "ALERT";
break;
case LOG_CRIT:
logLevelstr = "CRIT";
break;
case LOG_ERR:
logLevelstr = "ERROR";
break;
case LOG_WARNING:
logLevelstr = "WARNING";
break;
case LOG_NOTICE:
logLevelstr = "NOTICE";
break;
case LOG_INFO:
logLevelstr = "INFO";
break;
case LOG_DEBUG:
logLevelstr = "DEBUG";
break;
default:
logLevelstr = "UNKNOWN";
}
snprintf(buf, sizeof buf - 1, "%s [%s] %s->%s %s line:%-5d ", logLevelstr, sysCategory, moduleName,fileName, functionName, line);
tagLen = strlen(buf);
vsnprintf(buf + tagLen, sizeof buf - 1 - tagLen, (const char*)fmt, para);
syslog(logLevel,"%s",buf);
printf ("%s\n",buf);
closelog();
va_end(para);
}
//////////////////flock////////////////////////////
/// \brief is_leap_year
/// \param year
/// \return
///
int is_leap_year(int year){
if(year%400==0 || (year%4==0 && year%100!=0)){
return 1;
}
return 0;
}
///
/// \brief nolocks_localtime
/// \param tmp
/// \param t
/// \param tz
/// \param dst
///
void nolocks_localtime(struct tm *tmp, time_t t, time_t tz, int dst) {
const time_t secs_min = 60;
const time_t secs_hour = 3600;
const time_t secs_day = 3600*24;
t -= tz; /* Adjust for timezone. */
t += 3600*dst; /* Adjust for daylight time. */
time_t days = t / secs_day; /* Days passed since epoch. */
time_t seconds = t % secs_day; /* Remaining seconds. */
tmp->tm_isdst = dst;
tmp->tm_hour = seconds / secs_hour;
tmp->tm_min = (seconds % secs_hour) / secs_min;
tmp->tm_sec = (seconds % secs_hour) % secs_min;
/* 1/1/1970 was a Thursday, that is, day 4 from the POV of the tm structure * where sunday = 0, so to calculate the day of the week we have to add 4 * and take the modulo by 7. */
tmp->tm_wday = (days+4)%7;
/* Calculate the current year. */
tmp->tm_year = 1970;
while(1) {
/* Leap years have one day more. */
time_t days_this_year = 365 + is_leap_year(tmp->tm_year);
if (days_this_year > days) break;
days -= days_this_year;
tmp->tm_year++;
}
tmp->tm_yday = days; /* Number of day of the current year. */
/* We need to calculate in which month and day of the month we are. To do * so we need to skip days according to how many days there are in each * month, and adjust for the leap year that has one more day in February. */
int mdays[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
mdays[1] += is_leap_year(tmp->tm_year);
tmp->tm_mon = 0;
while(days >= mdays[tmp->tm_mon]) {
days -= mdays[tmp->tm_mon];
tmp->tm_mon++;
}
tmp->tm_mday = days+1; /* Add 1 since our 'days' is zero-based. */
tmp->tm_year -= 1970; /* Surprisingly tm_year is year-1900. */
}
uint verify_file(char *pFileName) {
return !strncmp(pFileName, "/home", strlen("/home"));
}
///
/// \brief CreateDir
/// \param sPathName
/// \return
///
//使用realpath设计缺陷,指定缓冲区大小为PATH_MAX, 而非定义一个常量。
//参考:https://www.man7.org/linux/man-pages/man3/realpath.3.html (BUGS)
int CreateDir(const char *sPathName)
{
char DirName[256];
char canonical_filename[PATH_MAX] = {""};
strcpy(DirName, sPathName);
int i,len = strlen(DirName);
for(i=1; i 0) {
// canonical_filename = malloc(path_size);
// if (canonical_filename == NULL) {
// return -ENOMEM;
// }
memset(canonical_filename,0,path_size);
realpath_res = realpath(DirName, canonical_filename);
}
if(strlen(canonical_filename)<=0){
return -1;
}
if(!verify_file(canonical_filename)){
return -1;
}
if(mkdir(canonical_filename, 0755)==-1)
{
// printf("mkdir canonical_filename :%s error\n",canonical_filename);
return -1;
} else {
// printf("DirName %s create OK\n",DirName);
}
}
else{
// printf("Dir %s exist\n",DirName);
}
DirName[i] = '/';
}
}
return 0;
}
///
/// \brief checkLogDir
/// \param dir
/// \param logFileName
///
void checkLogDir(const char *dir, char *logFileName){
static uint hadCreaterDir = 0;
char *path;
char logDir[128]="";
if (hadCreaterDir) {
path = getenv("HOME");
snprintf(logDir,sizeof(logDir),"%s/.log/%s/",path,dir);
memcpy(logFileName, logDir, strlen(logDir));
return;
}
hadCreaterDir = 1;
path = getenv("HOME");
snprintf(logDir,sizeof(logDir),"%s/.log/%s/",path,dir);
if (0 != access(logDir,F_OK)){
CreateDir(logDir);
} else {
// printf("dir %s exist\n", logDir);
}
memcpy(logFileName, logDir, strlen(logDir));
}
//按照星期进行处理
char getWeek(){
time_t t;
struct tm tmTime;
time(&t);
// localtime_r(&t, tmTime);//虽然线程安全但是容易死锁
nolocks_localtime(&tmTime,t,-8*3600,0);
// printf("[%d-%02d-%02d %02d:%02d:%02d]today is %d\n",tmTime.tm_year+1970,tmTime.tm_mon+1,tmTime.tm_mday,tmTime.tm_hour,tmTime.tm_min,tmTime.tm_sec,tmTime.tm_wday);
return tmTime.tm_wday;
}
//加写锁
int wlock(int fd, int wait) {
struct flock lock;
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 0;
lock.l_pid = -1;
return fcntl(fd, wait ? F_SETLKW : F_SETLK, &lock);
}
//加读锁
int rlock(int fd, int wait) {
struct flock lock;
lock.l_type = F_RDLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 0;
lock.l_pid = -1;
return fcntl(fd, wait ? F_SETLKW : F_SETLK, &lock);
}
//解锁
int ulock(int fd) {
struct flock lock;
lock.l_type = F_UNLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 0;
lock.l_pid = -1;
return fcntl(fd, F_SETLK, &lock);
}
/*
以星期为划分,最多存七天的日志
当本次星期时间与上次不一致且并非初始值时,以清空文件的方式打开文件。
由于settings-daemon日志并不频繁,所以不需要进行缓冲区设置。
*/
void write_log_to_file(char *buf, __uint16_t buf_len)
{
static int lastWeekDay = 0xff;
static int hadError = 0;
int month = 0;
int day = 0;
const char *pWeekName[7] = {"SUN.log","MON.log","TUE.log","WED.log","THU.log","FRI.log","SAT.log"};
FILE *lockfp;
int fd;
int writeLen = buf_len;
int rtWeekDay;
char logFileName[128];
char *plogFile = NULL;
char *prealpathRes = NULL;
char logMsg[2048];
char readMsg[2048]="";
time_t t;
struct tm tmTime;
int reWriteTimes = 0;
if (hadError) {
return;
}
REWRITE:
t = writeLen;
time(&t);
// localtime_r(&t, tmTime);//虽然线程安全但是容易死锁
memset(logMsg,0x00,sizeof(logMsg));
memset(logFileName,0x00,sizeof(logFileName));
nolocks_localtime(&tmTime,t,-8*3600,0);
rtWeekDay = getWeek();
checkLogDir("usd", logFileName);
strcat(logFileName,pWeekName[rtWeekDay]);
if (0 != access(logFileName, F_OK)) {
return;
}
prealpathRes = realpath(logFileName, plogFile);
if(prealpathRes == NULL) {
hadError = 1;
syslog_info(LOG_ERR, "CORE", __FILE__, __FUNCTION__, __LINE__, "%s", "realpath check fail");
return;
}
if (/*strlen(prealpathRes) >= sizeof(logFileName) ||*/ !verify_file(prealpathRes)) {
free(prealpathRes);
prealpathRes = NULL;
hadError = 1;
syslog_info(LOG_ERR, "CORE", __FILE__, __FUNCTION__, __LINE__, "%s", "strlen check fail");
return;
}
if(rtWeekDay!=lastWeekDay && lastWeekDay!=0xff){
fd = open(prealpathRes, O_TRUNC | O_RDWR);
}
else {
fd = open(prealpathRes, O_RDWR | O_APPEND, S_IRUSR | S_IWUSR);//去掉 | O_CREAT,不再进行创建
}
free(prealpathRes);
prealpathRes = NULL;
if(fd <= 0) {
return;
}
lastWeekDay = rtWeekDay;
if (wlock(fd, 1) == -1) {
//加锁失败,可能是因为其他已上锁,需要close操作。
if (fd > 0) {
close(fd);
}
return;
}
lockfp = fdopen(fd,"w+");
if (lockfp == NULL) {
if (fd > 0) {
close(fd);
}
return;
}
snprintf(logMsg,sizeof(logMsg),"{%04d-%02d-%02d %02d:%02d:%02d}:%s\n",tmTime.tm_year+1970, tmTime.tm_mon+1, tmTime.tm_mday,tmTime.tm_hour, tmTime.tm_min,tmTime.tm_sec,buf);
writeLen = write(fd,(const void*)logMsg,strlen(logMsg));
fseek(lockfp,0L,SEEK_SET);//kill程序后,可能会因为资源释放,导致访问底层的malloc异常报错_IO_file_seekoff-》_IO_doallocbuf-》_IO_file_doallocate-》malloc
if (fgets(readMsg, sizeof(readMsg), lockfp)) {
month = (readMsg[6]-0x30)*10 + readMsg[7]-0x30;
day = (readMsg[9]-0x30)*10 + readMsg[10]-0x30;
if (month!=(tmTime.tm_mon+1) || day!=tmTime.tm_mday) {
if (0 == reWriteTimes) {
reWriteTimes++;
lastWeekDay=0xfe;
fflush(lockfp);
ulock(fd);
fclose (lockfp);
close(fd);
goto REWRITE;
}
}
}
printf("%s",logMsg);
fflush(lockfp);
ulock(fd);
fclose (lockfp);
close(fd);
}
void syslog_to_self_dir(int logLevel, const char *moduleName, const char *fileName, const char *functionName, int line, const char* fmt, ...)
{
char buf[2048] = {0};
char *logLevelstr = NULL;
unsigned long tagLen = 0;
va_list para;
va_start(para, fmt);
memset(buf, 0, sizeof buf);
switch (logLevel) {
case LOG_EMERG:
logLevelstr = "EMERG";
break;
case LOG_ALERT:
logLevelstr = "ALERT";
break;
case LOG_CRIT:
logLevelstr = "CRIT";
break;
case LOG_ERR:
logLevelstr = "ERROR";
break;
case LOG_WARNING:
logLevelstr = "WARNING";
break;
case LOG_NOTICE:
logLevelstr = "NOTICE";
break;
case LOG_INFO:
logLevelstr = "INFO";
break;
case LOG_DEBUG:
logLevelstr = "DEBUG";
break;
default:
logLevelstr = "UNKNOWN";
}
snprintf(buf, sizeof buf - 1, "[%s] %s->%s %s line:%-5d", logLevelstr, moduleName,fileName, functionName, line);
tagLen = strlen(buf);
vsnprintf(buf + tagLen, sizeof buf - 1 - tagLen, (const char*)fmt, para);
write_log_to_file(buf,strlen(buf));
va_end(para);
}
//////////Other function////////////////
int CheckProcessAlive(const char *pName){
int ret = 0;
char Cmd[512] = {0};
char *pAck = NULL;
char CmdAck[120];
FILE * pPipe;
ret = (int)pAck;
if (strlen(pName) > 400) {
return 0;
}
//ef列出所有进程,|grep %s | 仅显示含%s的进程, |grep -v grep过滤掉含grep的进程(本条指令),|wc -l 查看行数
sprintf(Cmd, "ps -ef |grep %s|grep -v grep|wc -l",pName);
pPipe = popen(Cmd,"r");
if (pPipe) {
pAck = fgets(CmdAck,sizeof(CmdAck),pPipe);
ret = atoi(CmdAck);
pclose(pPipe);
}
return ret;
}
ukui-settings-daemon-4.0.10.1/common/clib-syslog.h 0000664 0000000 0000000 00000007540 15241041773 0021711 0 ustar 00root root 0000000 0000000 /* -*- Mode: C; indent-tabs-mode: nil; tab-width: 4 -*-
* -*- coding: utf-8 -*-
*
* Copyright (C) 2023 KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef CLIB_SYSLOG_H
#define CLIB_SYSLOG_H
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "usd_global_define.h"
#define LOG_LEVEL LOG_DEBUG
#ifdef __cplusplus
extern "C" {
#endif
#include
#define SYS_LOG(logLevel,...) {\
syslog_info(logLevel, MODULE_NAME, __FILE__, __func__, __LINE__, ##__VA_ARGS__);\
}
#define USD_LOG(logLevel,...) {\
syslog_to_self_dir(logLevel, MODULE_NAME, __FILE__, __func__, __LINE__, ##__VA_ARGS__);\
}
#define USD_LOG_SHOW_OUTPUT(output) USD_LOG(LOG_DEBUG,":%s (%s)(%s) use [%s] mode at (%dx%d) id %d primary id:%s,rotation:%d", \
output->name().toLatin1().data(), output->isConnected()? "connect":"disconnect", output->isEnabled()? "Enable":"Disable", \
output->currentModeId().toLatin1().data(), output->pos().x(), output->pos().y(),output->id(), output->hash().toLatin1().data(), output->rotation())
#define USD_LOG_SHOW_OUTPUT_NOID(output) USD_LOG(LOG_DEBUG,":%s (%s)(%s) use [%s] mode at (%dx%d) ", \
output->name().toLatin1().data(), output->isConnected()? "connect":"disconnect", output->isEnabled()? "Enale":"Disable", \
output->currentModeId().toLatin1().data(), output->pos().x(), output->pos().y())
#define USD_LOG_SHOW_PARAM1(a) USD_LOG(LOG_DEBUG,"%s : %d",#a,a)
#define USD_LOG_SHOW_PARAMF(a) USD_LOG(LOG_DEBUG,"%s : %f",#a,a)
#define USD_LOG_SHOW_PARAMS(a) USD_LOG(LOG_DEBUG,"[%s] : [%s]",#a,a)
#define USD_LOG_SHOW_PARAM2(a,b) USD_LOG(LOG_DEBUG,"%s : %d,%s : %d",#a,a,#b, b)
#define USD_LOG_SHOW_PARAM3(a,b,c) USD_LOG(LOG_DEBUG,"%s : %d,%s : %d",#a, a, #b, b, #c, c)
#define USD_LOG_SHOW_PARAM4(a,b,c,d) USD_LOG(LOG_DEBUG,"%s : %d,%s : %d",#a, a, #b, b, #c, c, #d, d)
#define SYS_LOG_SHOW_PARAM1(a) SYS_LOG(LOG_DEBUG,"%s : %d",#a,a)
#define SYS_LOG_SHOW_PARAMS(a) SYS_LOG(LOG_DEBUG,"%s : %s",#a,a)
#define SYS_LOG_SHOW_PARAM2(a,b) SYS_LOG(LOG_DEBUG,"%s : %d,%s : %d",#a,a,#b, b)
#define SYS_LOG_SHOW_PARAM3(a,b,c) SYS_LOG(LOG_DEBUG,"%s : %d,%s : %d",#a, a, #b, b, #c, c)
#define SYS_LOG_SHOW_PARAM4(a,b,c,d) SYS_LOG(LOG_DEBUG,"%s : %d,%s : %d",#a, a, #b, b, #c, c, #d, d)
#define USD_LOG_SHOW_PARAM2F(a,b) USD_LOG(LOG_DEBUG,"%s : %f,%s : %f",#a,a,#b, b)
#define CHECK_PROJECT(A) ifdef A
#define CHECK_OVER endif
/*
* 日志参数初始化
* @param category: 标签
* @param facility: 设备文件
* @return
* void
*/
void syslog_init(const char *category, int facility);
/*
* 日志输出到system log,默认LOG_INFO级别
* @param loglevel: 日志级别
* @param file: 文件名
* @param function: 函数
* @param line: 函数
* @param fmt: 格式化字符串
* @return
* void
*/
void syslog_info(int logLevel, const char *moduleName, const char *fileName, const char *functionName, int line, const char* fmt, ...);
void syslog_to_self_dir(int logLevel, const char *moduleName, const char *fileName, const char *functionName, int line, const char* fmt, ...);
/*
* 检测进程是否存在
*/
int CheckProcessAlive(const char *pName);
#ifdef __cplusplus
}
#endif //__cplusplus
#endif
ukui-settings-daemon-4.0.10.1/common/common.pri 0000664 0000000 0000000 00000003223 15241041773 0021307 0 ustar 00root root 0000000 0000000 QT += core gui dbus gui-private gui core-private
CONFIG += c++20 no_keywords gui-private link_pkgconfig xrandr
CONFIG -= app_bundle
INCLUDEPATH += -I $$PWD/
PLUGIN_INSTALL_DIRS = $$[QT_INSTALL_LIBS]/ukui-settings-daemon
EXTRA_CFLAGS +=-Wno-date-time
PKGCONFIG += glib-2.0 gio-2.0 libxklavier x11 xrandr xtst atk gdk-3.0 gtk+-3.0 xi gudev-1.0
exists(/usr/include/kysdk/kysdk-system/libkysysinfo.h) {
DEFINES += KY_SDK_SYSINFO
PKGCONFIG += kysdk-sysinfo
}
exists(/usr/include/kysdk/kysdk-system/libkycpu.h) {
DEFINES += KY_SDK_HARDWARE
PKGCONFIG += kysdk-hardware
}
QMAKE_CXXFLAGS += -Wno-unused-parameter
SOURCES += \
$$PWD/clib-syslog.c \
$$PWD/QGSettings/qconftype.cpp \
$$PWD/QGSettings/qgsettings.cpp \
$$PWD/rfkillswitch.cpp \
$$PWD/touch-calibrate.cpp \
$$PWD/usd_base_class.cpp \
$$PWD/xeventmonitor.cpp \
$$PWD/eggaccelerators.c \
$$PWD/ukui-input-helper.c \
$$PWD/ukui-keygrab.cpp
HEADERS += \
$$PWD/clib-syslog.h \
$$PWD/plugin-interface.h \
$$PWD/QGSettings/qconftype.h \
$$PWD/QGSettings/qgsettings.h \
$$PWD/rfkillswitch.h \
$$PWD/touch-calibrate.h \
$$PWD/usd_base_class.h \
$$PWD/usd_global_define.h \
$$PWD/xeventmonitor.h \
$$PWD/eggaccelerators.h \
$$PWD/ukui-input-helper.h \
$$PWD/ukui-keygrab.h \
$$PWD/config.h \
$$PWD/xrandroutput.h \
$$PWD/plugin-manager-interface.h \
$$PWD/x11-head.h
RESOURCES += \
$$PWD/ukui_icon.qrc
ukui-settings-daemon-4.0.10.1/common/config.h 0000664 0000000 0000000 00000011043 15241041773 0020720 0 ustar 00root root 0000000 0000000 /* -*- Mode: C; indent-tabs-mode: nil; tab-width: 4 -*-
* -*- coding: utf-8 -*-
*
* Copyright (C) 2023 KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef USD_CONFIG_H
#define USD_CONFIG_H
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* always defined to indicate that i18n is enabled */
#define ENABLE_NLS 1
/* enable profiling */
/* #undef ENABLE_PROFILING */
/* Name of default gettext domain */
#define GETTEXT_PACKAGE "ukui-settings-daemon"
/* Warn on use of APIs added after GLib 2.36 */
#define GLIB_VERSION_MAX_ALLOWED GLIB_VERSION_2_36
/* Warn on use of APIs deprecated before GLib 2.36 */
#define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_36
/* Define to 1 if you have the `bind_textdomain_codeset' function. */
#define HAVE_BIND_TEXTDOMAIN_CODESET 1
/* Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the
CoreFoundation framework. */
/* #undef HAVE_CFLOCALECOPYCURRENT */
/* Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in
the CoreFoundation framework. */
/* #undef HAVE_CFPREFERENCESCOPYAPPVALUE */
/* Define to 1 if you have the `dcgettext' function. */
#define HAVE_DCGETTEXT 1
/* Define to 1 if you have the header file. */
#define HAVE_DLFCN_H 1
/* Define if the GNU gettext() function is already present or preinstalled. */
#define HAVE_GETTEXT 1
/* Define to 1 if you have the header file. */
#define HAVE_INTTYPES_H 1
/* Define if your file defines LC_MESSAGES. */
#define HAVE_LC_MESSAGES 1
/* Define if libcanberra-gtk3 is available */
#define HAVE_LIBCANBERRA 1
/* Define if libmatemixer is available */
#define HAVE_LIBMATEMIXER 1
/* Define if libnotify is available */
#define HAVE_LIBNOTIFY 1
/* Define to 1 if you have the header file. */
#define HAVE_LOCALE_H 1
/* Define to 1 if you have the header file. */
#define HAVE_MEMORY_H 1
/* Defined if PolicyKit support is enabled */
#define HAVE_POLKIT 1
/* Define if PulseAudio support is available */
/* #undef HAVE_PULSE */
/* Define to 1 if you have the header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if you have the header file. */
/* #undef HAVE_X11_EXTENSIONS_XF86MISC_H */
/* Define to 1 if you have the header file. */
#define HAVE_X11_EXTENSIONS_XKB_H 1
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#define LT_OBJDIR ".libs/"
/* Name of package */
#define PACKAGE "ukui-settings-daemon"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "http://www.ukui.org/"
/* Define to the full name of this package. */
#define PACKAGE_NAME "ukui-settings-daemon"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "ukui-settings-daemon 1.1.1"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "ukui-settings-daemon"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "3.0.0"
/* Define if smartcard support should be enabled */
#define SMARTCARD_SUPPORT 1
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Version number of package */
#define VERSION "3.0.0"
/* Define to 1 if the X Window System is missing or not being used. */
/* #undef X_DISPLAY_MISSING */
#endif //USD_CONFIG_H
ukui-settings-daemon-4.0.10.1/common/eggaccelerators.c 0000664 0000000 0000000 00000063663 15241041773 0022617 0 ustar 00root root 0000000 0000000 /* -*- Mode: C; indent-tabs-mode: nil; tab-width: 4 -*-
* -*- coding: utf-8 -*-
*
* Copyright (C) 2023 KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "config.h"
#include "eggaccelerators.h"
#include
#include
#include
#include
#include
enum
{
EGG_MODMAP_ENTRY_SHIFT = 0,
EGG_MODMAP_ENTRY_LOCK = 1,
EGG_MODMAP_ENTRY_CONTROL = 2,
EGG_MODMAP_ENTRY_MOD1 = 3,
EGG_MODMAP_ENTRY_MOD2 = 4,
EGG_MODMAP_ENTRY_MOD3 = 5,
EGG_MODMAP_ENTRY_MOD4 = 6,
EGG_MODMAP_ENTRY_MOD5 = 7,
EGG_MODMAP_ENTRY_LAST = 8
};
#define MODMAP_ENTRY_TO_MODIFIER(x) (1 << (x))
typedef struct
{
EggVirtualModifierType mapping[EGG_MODMAP_ENTRY_LAST];
} EggModmap;
const EggModmap* egg_keymap_get_modmap (GdkKeymap *keymap);
static inline gboolean
is_alt (const gchar *string)
{
return ((string[0] == '<') &&
(string[1] == 'a' || string[1] == 'A') &&
(string[2] == 'l' || string[2] == 'L') &&
(string[3] == 't' || string[3] == 'T') &&
(string[4] == '>'));
}
static inline gboolean
is_ctl (const gchar *string)
{
return ((string[0] == '<') &&
(string[1] == 'c' || string[1] == 'C') &&
(string[2] == 't' || string[2] == 'T') &&
(string[3] == 'l' || string[3] == 'L') &&
(string[4] == '>'));
}
static inline gboolean
is_modx (const gchar *string)
{
return ((string[0] == '<') &&
(string[1] == 'm' || string[1] == 'M') &&
(string[2] == 'o' || string[2] == 'O') &&
(string[3] == 'd' || string[3] == 'D') &&
(string[4] >= '1' && string[4] <= '5') &&
(string[5] == '>'));
}
static inline gboolean
is_ctrl (const gchar *string)
{
return ((string[0] == '<') &&
(string[1] == 'c' || string[1] == 'C') &&
(string[2] == 't' || string[2] == 'T') &&
(string[3] == 'r' || string[3] == 'R') &&
(string[4] == 'l' || string[4] == 'L') &&
(string[5] == '>'));
}
static inline gboolean
is_shft (const gchar *string)
{
return ((string[0] == '<') &&
(string[1] == 's' || string[1] == 'S') &&
(string[2] == 'h' || string[2] == 'H') &&
(string[3] == 'f' || string[3] == 'F') &&
(string[4] == 't' || string[4] == 'T') &&
(string[5] == '>'));
}
static inline gboolean
is_shift (const gchar *string)
{
return ((string[0] == '<') &&
(string[1] == 's' || string[1] == 'S') &&
(string[2] == 'h' || string[2] == 'H') &&
(string[3] == 'i' || string[3] == 'I') &&
(string[4] == 'f' || string[4] == 'F') &&
(string[5] == 't' || string[5] == 'T') &&
(string[6] == '>'));
}
static inline gboolean
is_control (const gchar *string)
{
return ((string[0] == '<') &&
(string[1] == 'c' || string[1] == 'C') &&
(string[2] == 'o' || string[2] == 'O') &&
(string[3] == 'n' || string[3] == 'N') &&
(string[4] == 't' || string[4] == 'T') &&
(string[5] == 'r' || string[5] == 'R') &&
(string[6] == 'o' || string[6] == 'O') &&
(string[7] == 'l' || string[7] == 'L') &&
(string[8] == '>'));
}
static inline gboolean
is_release (const gchar *string)
{
return ((string[0] == '<') &&
(string[1] == 'r' || string[1] == 'R') &&
(string[2] == 'e' || string[2] == 'E') &&
(string[3] == 'l' || string[3] == 'L') &&
(string[4] == 'e' || string[4] == 'E') &&
(string[5] == 'a' || string[5] == 'A') &&
(string[6] == 's' || string[6] == 'S') &&
(string[7] == 'e' || string[7] == 'E') &&
(string[8] == '>'));
}
static inline gboolean
is_meta (const gchar *string)
{
return ((string[0] == '<') &&
(string[1] == 'm' || string[1] == 'M') &&
(string[2] == 'e' || string[2] == 'E') &&
(string[3] == 't' || string[3] == 'T') &&
(string[4] == 'a' || string[4] == 'A') &&
(string[5] == '>'));
}
static inline gboolean
is_super (const gchar *string)
{
return ((string[0] == '<') &&
(string[1] == 's' || string[1] == 'S') &&
(string[2] == 'u' || string[2] == 'U') &&
(string[3] == 'p' || string[3] == 'P') &&
(string[4] == 'e' || string[4] == 'E') &&
(string[5] == 'r' || string[5] == 'R') &&
(string[6] == '>'));
}
static inline gboolean
is_win (const gchar *string)
{
return ((string[0] == '<') &&
(string[1] == 'w' || string[1] == 'W') &&
(string[2] == 'i' || string[2] == 'I') &&
(string[3] == 'n' || string[3] == 'N') &&
(string[4] == '>'));
}
static inline gboolean
is_hyper (const gchar *string)
{
return ((string[0] == '<') &&
(string[1] == 'h' || string[1] == 'H') &&
(string[2] == 'y' || string[2] == 'Y') &&
(string[3] == 'p' || string[3] == 'P') &&
(string[4] == 'e' || string[4] == 'E') &&
(string[5] == 'r' || string[5] == 'R') &&
(string[6] == '>'));
}
static inline gboolean is_primary(const gchar* string)
{
return ((string[0] == '<') &&
(string[1] == 'p' || string[1] == 'P') &&
(string[2] == 'r' || string[2] == 'R') &&
(string[3] == 'i' || string[3] == 'I') &&
(string[4] == 'm' || string[4] == 'M') &&
(string[5] == 'a' || string[5] == 'A') &&
(string[6] == 'r' || string[6] == 'R') &&
(string[7] == 'y' || string[7] == 'Y') &&
(string[8] == '>'));
}
static inline gboolean
is_keycode (const gchar *string)
{
return ((string[0] == '0') &&
(string[1] == 'x'));
}
/**
* egg_accelerator_parse_virtual:
* @accelerator: string representing an accelerator
* @accelerator_key: return location for accelerator keyval
* @accelerator_codes: return location for a 0-terminated array
* of accelerator keycodes
* @accelerator_mods: return location for accelerator modifier mask
*
* Parses a string representing a virtual accelerator. The format
* looks like "<Control>a" or "<Shift><Alt>F1" or
* "<Release>z" (the last one is for key release). The parser
* is fairly liberal and allows lower or upper case, and also
* abbreviations such as "<Ctl>" and "<Ctrl>".
*
* If the parse fails, @accelerator_key and @accelerator_mods will
* be set to 0 (zero) and %FALSE will be returned. If the string contains
* only modifiers, @accelerator_key will be set to 0 but %TRUE will be
* returned.
*
* The virtual vs. concrete accelerator distinction is a relic of
* how the X Window System works; there are modifiers Mod2-Mod5 that
* can represent various keyboard keys (numlock, meta, hyper, etc.),
* the virtual modifier represents the keyboard key, the concrete
* modifier the actual Mod2-Mod5 bits in the key press event.
*
* Returns: %TRUE on success.
*/
gboolean
egg_accelerator_parse_virtual (const gchar *accelerator,
guint *accelerator_key,
guint **accelerator_codes,
EggVirtualModifierType *accelerator_mods)
{
guint keyval;
GdkModifierType mods;
gint len;
gboolean bad_keyval;
if (accelerator_key)
*accelerator_key = 0;
if (accelerator_mods)
*accelerator_mods = 0;
if (accelerator_codes)
*accelerator_codes = NULL;
g_return_val_if_fail (accelerator != NULL, FALSE);
bad_keyval = FALSE;
keyval = 0;
mods = 0;
len = strlen (accelerator);
while (len)
{
if (*accelerator == '<')
{
if (len >= 9 && is_release (accelerator))
{
accelerator += 9;
len -= 9;
mods |= EGG_VIRTUAL_RELEASE_MASK;
}
else if (len >= 9 && is_primary (accelerator))
{
accelerator += 9;
len -= 9;
mods |= EGG_VIRTUAL_CONTROL_MASK;
}
else if (len >= 9 && is_control (accelerator))
{
accelerator += 9;
len -= 9;
mods |= EGG_VIRTUAL_CONTROL_MASK;
}
else if (len >= 7 && is_shift (accelerator))
{
accelerator += 7;
len -= 7;
mods |= EGG_VIRTUAL_SHIFT_MASK;
}
else if (len >= 6 && is_shft (accelerator))
{
accelerator += 6;
len -= 6;
mods |= EGG_VIRTUAL_SHIFT_MASK;
}
else if (len >= 6 && is_ctrl (accelerator))
{
accelerator += 6;
len -= 6;
mods |= EGG_VIRTUAL_CONTROL_MASK;
}
else if (len >= 6 && is_modx (accelerator))
{
static const guint mod_vals[] = {
EGG_VIRTUAL_ALT_MASK, EGG_VIRTUAL_MOD2_MASK, EGG_VIRTUAL_MOD3_MASK,
EGG_VIRTUAL_MOD4_MASK, EGG_VIRTUAL_MOD5_MASK
};
len -= 6;
accelerator += 4;
mods |= mod_vals[*accelerator - '1'];
accelerator += 2;
}
else if (len >= 5 && is_ctl (accelerator))
{
accelerator += 5;
len -= 5;
mods |= EGG_VIRTUAL_CONTROL_MASK;
}
else if (len >= 5 && is_alt (accelerator))
{
accelerator += 5;
len -= 5;
mods |= EGG_VIRTUAL_ALT_MASK;
}
else if (len >= 6 && is_meta (accelerator))
{
accelerator += 6;
len -= 6;
mods |= EGG_VIRTUAL_META_MASK;
}
else if (len >= 7 && is_hyper (accelerator))
{
accelerator += 7;
len -= 7;
mods |= EGG_VIRTUAL_HYPER_MASK;
}
else if (len >= 7 && is_super (accelerator))
{
accelerator += 7;
len -= 7;
mods |= EGG_VIRTUAL_SUPER_MASK;
}
else if (len >= 5 && is_win (accelerator))
{
accelerator += 5;
len -= 5;
mods |= EGG_VIRTUAL_MOD4_MASK;
}
else
{
gchar last_ch;
last_ch = *accelerator;
while (last_ch && last_ch != '>')
{
last_ch = *accelerator;
accelerator += 1;
len -= 1;
}
}
}
else {
if(len == 1) {
if(g_strcmp0(accelerator, "A") == 0)
keyval = gdk_keyval_from_name ("a");
else if(g_strcmp0(accelerator, "B") == 0)
keyval = gdk_keyval_from_name ("b");
else if(g_strcmp0(accelerator, "C") == 0)
keyval = gdk_keyval_from_name ("c");
else if(g_strcmp0(accelerator, "D") == 0)
keyval = gdk_keyval_from_name ("d");
else if(g_strcmp0(accelerator, "E") == 0)
keyval = gdk_keyval_from_name ("e");
else if(g_strcmp0(accelerator, "F") == 0)
keyval = gdk_keyval_from_name ("f");
else if(g_strcmp0(accelerator, "G") == 0)
keyval = gdk_keyval_from_name ("g");
else if(g_strcmp0(accelerator, "H") == 0)
keyval = gdk_keyval_from_name ("h");
else if(g_strcmp0(accelerator, "I") == 0)
keyval = gdk_keyval_from_name ("i");
else if(g_strcmp0(accelerator, "J") == 0)
keyval = gdk_keyval_from_name ("j");
else if(g_strcmp0(accelerator, "K") == 0)
keyval = gdk_keyval_from_name ("k");
else if(g_strcmp0(accelerator, "L") == 0)
keyval = gdk_keyval_from_name ("l");
else if(g_strcmp0(accelerator, "M") == 0)
keyval = gdk_keyval_from_name ("m");
else if(g_strcmp0(accelerator, "N") == 0)
keyval = gdk_keyval_from_name ("n");
else if(g_strcmp0(accelerator, "O") == 0)
keyval = gdk_keyval_from_name ("o");
else if(g_strcmp0(accelerator, "P") == 0)
keyval = gdk_keyval_from_name ("p");
else if(g_strcmp0(accelerator, "Q") == 0)
keyval = gdk_keyval_from_name ("q");
else if(g_strcmp0(accelerator, "R") == 0)
keyval = gdk_keyval_from_name ("r");
else if(g_strcmp0(accelerator, "S") == 0)
keyval = gdk_keyval_from_name ("s");
else if(g_strcmp0(accelerator, "T") == 0)
keyval = gdk_keyval_from_name ("t");
else if(g_strcmp0(accelerator, "U") == 0)
keyval = gdk_keyval_from_name ("u");
else if(g_strcmp0(accelerator, "V") == 0)
keyval = gdk_keyval_from_name ("v");
else if(g_strcmp0(accelerator, "W") == 0)
keyval = gdk_keyval_from_name ("w");
else if(g_strcmp0(accelerator, "X") == 0)
keyval = gdk_keyval_from_name ("x");
else if(g_strcmp0(accelerator, "Y") == 0)
keyval = gdk_keyval_from_name ("y");
else if(g_strcmp0(accelerator, "Z") == 0)
keyval = gdk_keyval_from_name ("z");
else if(g_strcmp0(accelerator, ".") == 0)
keyval = gdk_keyval_from_name ("period");
else if(g_strcmp0(accelerator, ",") == 0)
keyval = gdk_keyval_from_name ("comma");
else
keyval = gdk_keyval_from_name (accelerator);
}
else if(len == 2 || len == 3) {
if(g_strcmp0(accelerator, "Esc") == 0)
keyval = gdk_keyval_from_name ("Escape");
else if(g_strcmp0(accelerator, "f1") == 0)
keyval = gdk_keyval_from_name ("F1");
else if(g_strcmp0(accelerator, "f2") == 0)
keyval = gdk_keyval_from_name ("F2");
else if(g_strcmp0(accelerator, "f3") == 0)
keyval = gdk_keyval_from_name ("F3");
else if(g_strcmp0(accelerator, "f4") == 0)
keyval = gdk_keyval_from_name ("F4");
else if(g_strcmp0(accelerator, "f5") == 0)
keyval = gdk_keyval_from_name ("F5");
else if(g_strcmp0(accelerator, "f6") == 0)
keyval = gdk_keyval_from_name ("F6");
else if(g_strcmp0(accelerator, "f7") == 0)
keyval = gdk_keyval_from_name ("F7");
else if(g_strcmp0(accelerator, "f8") == 0)
keyval = gdk_keyval_from_name ("F8");
else if(g_strcmp0(accelerator, "f9") == 0)
keyval = gdk_keyval_from_name ("F9");
else if(g_strcmp0(accelerator, "f10") == 0)
keyval = gdk_keyval_from_name ("F10");
else if(g_strcmp0(accelerator, "f11") == 0)
keyval = gdk_keyval_from_name ("F11");
else if(g_strcmp0(accelerator, "f12") == 0)
keyval = gdk_keyval_from_name ("F12");
else
keyval = gdk_keyval_from_name (accelerator);
}else
keyval = gdk_keyval_from_name (accelerator);
if (keyval == 0)
{
/* If keyval is 0, then maybe it's a keycode. Check for 0x## */
if (len >= 4 && is_keycode (accelerator))
{
char keystring[5];
gchar *endptr;
gint tmp_keycode;
memcpy (keystring, accelerator, 4);
keystring [4] = '\000';
tmp_keycode = strtol (keystring, &endptr, 16);
if (endptr == NULL || *endptr != '\000')
{
bad_keyval = TRUE;
}
else if (accelerator_codes != NULL)
{
/* 0x00 is an invalid keycode too. */
if (tmp_keycode == 0) {
bad_keyval = TRUE;
} else {
*accelerator_codes = g_new0 (guint, 2);
(*accelerator_codes)[0] = tmp_keycode;
}
}
}
else {
bad_keyval = TRUE;
}
}
else if (accelerator_codes != NULL)
{
GdkKeymapKey *keys;
gint n_keys, i, j;
if (!gdk_keymap_get_entries_for_keyval (gdk_keymap_get_default(), keyval, &keys, &n_keys)) {
bad_keyval = TRUE;
} else {
*accelerator_codes = g_new0 (guint, n_keys + 1);
for (i = 0, j = 0; i < n_keys; ++i) {
if (keys[i].level == 0)
(*accelerator_codes)[j++] = keys[i].keycode;
}
if (j == 0) {
g_free (*accelerator_codes);
*accelerator_codes = NULL;
bad_keyval = TRUE;
}
g_free (keys);
}
}
accelerator += len;
len -= len;
}
}
if (accelerator_key)
*accelerator_key = gdk_keyval_to_lower (keyval);
if (accelerator_mods)
*accelerator_mods = mods;
return !bad_keyval;
}
/**
* egg_virtual_accelerator_name:
* @accelerator_key: accelerator keyval
* @accelerator_mods: accelerator modifier mask
* @returns: a newly-allocated accelerator name
*
* Converts an accelerator keyval and modifier mask
* into a string parseable by egg_accelerator_parse_virtual().
* For example, if you pass in #GDK_q and #EGG_VIRTUAL_CONTROL_MASK,
* this function returns "<Control>q".
*
* The caller of this function must free the returned string.
*/
gchar*
egg_virtual_accelerator_name (guint accelerator_key,
guint keycode,
EggVirtualModifierType accelerator_mods)
{
gchar *gtk_name;
GdkModifierType gdkmods = 0;
egg_keymap_resolve_virtual_modifiers (NULL, accelerator_mods, &gdkmods);
gtk_name = gtk_accelerator_name (accelerator_key, gdkmods);
if (!accelerator_key)
{
gchar *name;
name = g_strdup_printf ("%s0x%02x", gtk_name, keycode);
g_free (gtk_name);
return name;
}
return gtk_name;
}
/**
* egg_virtual_accelerator_label:
* @accelerator_key: accelerator keyval
* @accelerator_mods: accelerator modifier mask
* @returns: a newly-allocated accelerator label
*
* Converts an accelerator keyval and modifier mask
* into a (possibly translated) string that can be displayed to
* a user.
* For example, if you pass in #GDK_q and #EGG_VIRTUAL_CONTROL_MASK,
* and you use a German locale, this function returns "Strg+Q".
*
* The caller of this function must free the returned string.
*/
gchar*
egg_virtual_accelerator_label (guint accelerator_key,
guint keycode,
EggVirtualModifierType accelerator_mods)
{
gchar *gtk_label;
GdkModifierType gdkmods = 0;
egg_keymap_resolve_virtual_modifiers (NULL, accelerator_mods, &gdkmods);
gtk_label = gtk_accelerator_get_label (accelerator_key, gdkmods);
if (!accelerator_key)
{
gchar *label;
label = g_strdup_printf ("%s0x%02x", gtk_label, keycode);
g_free (gtk_label);
return label;
}
return gtk_label;
}
void
egg_keymap_resolve_virtual_modifiers (GdkKeymap *keymap,
EggVirtualModifierType virtual_mods,
GdkModifierType *concrete_mods)
{
GdkModifierType concrete;
int i;
const EggModmap *modmap;
g_return_if_fail (concrete_mods != NULL);
g_return_if_fail (keymap == NULL || GDK_IS_KEYMAP (keymap));
modmap = egg_keymap_get_modmap (keymap);
/* Not so sure about this algorithm. */
concrete = 0;
for (i = 0; i < EGG_MODMAP_ENTRY_LAST; ++i)
{
if (modmap->mapping[i] & virtual_mods)
concrete |= MODMAP_ENTRY_TO_MODIFIER (i);
}
*concrete_mods = concrete;
}
void
egg_keymap_virtualize_modifiers (GdkKeymap *keymap,
GdkModifierType concrete_mods,
EggVirtualModifierType *virtual_mods)
{
GdkModifierType virtual;
int i;
const EggModmap *modmap;
g_return_if_fail (virtual_mods != NULL);
g_return_if_fail (keymap == NULL || GDK_IS_KEYMAP (keymap));
modmap = egg_keymap_get_modmap (keymap);
/* Not so sure about this algorithm. */
virtual = 0;
for (i = 0; i < EGG_MODMAP_ENTRY_LAST; ++i)
{
if (MODMAP_ENTRY_TO_MODIFIER (i) & concrete_mods)
{
EggVirtualModifierType cleaned;
cleaned = modmap->mapping[i] & ~(EGG_VIRTUAL_MOD2_MASK |
EGG_VIRTUAL_MOD3_MASK |
EGG_VIRTUAL_MOD4_MASK |
EGG_VIRTUAL_MOD5_MASK);
if (cleaned != 0)
{
virtual |= cleaned;
}
else
{
/* Rather than dropping mod2->mod5 if not bound,
* go ahead and use the concrete names
*/
virtual |= modmap->mapping[i];
}
}
}
*virtual_mods = virtual;
}
static void
reload_modmap (GdkKeymap *keymap,
EggModmap *modmap)
{
XModifierKeymap *xmodmap;
int map_size;
int i;
/* FIXME multihead */
xmodmap = XGetModifierMapping (gdk_x11_get_default_xdisplay ());
memset (modmap->mapping, 0, sizeof (modmap->mapping));
/* there are 8 modifiers in the order shift, shift lock,
* control, mod1-5 with up to max_keypermod bindings each
*/
map_size = 8 * xmodmap->max_keypermod;
for (i = 3 * xmodmap->max_keypermod; i < map_size; ++i)
{
/* get the key code at this point in the map,
* see if its keysym is one we're interested in
*/
int keycode = xmodmap->modifiermap[i];
GdkKeymapKey *keys;
guint *keyvals;
int n_entries;
int j;
EggVirtualModifierType mask;
keys = NULL;
keyvals = NULL;
n_entries = 0;
gdk_keymap_get_entries_for_keycode (keymap,
keycode,
&keys, &keyvals, &n_entries);
mask = 0;
for (j = 0; j < n_entries; ++j)
{
if (keyvals[j] == GDK_KEY_Num_Lock)
mask |= EGG_VIRTUAL_NUM_LOCK_MASK;
else if (keyvals[j] == GDK_KEY_Scroll_Lock)
mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK;
else if (keyvals[j] == GDK_KEY_Meta_L ||
keyvals[j] == GDK_KEY_Meta_R)
mask |= EGG_VIRTUAL_META_MASK;
else if (keyvals[j] == GDK_KEY_Hyper_L ||
keyvals[j] == GDK_KEY_Hyper_R)
mask |= EGG_VIRTUAL_HYPER_MASK;
else if (keyvals[j] == GDK_KEY_Super_L ||
keyvals[j] == GDK_KEY_Super_R)
mask |= EGG_VIRTUAL_SUPER_MASK;
else if (keyvals[j] == GDK_KEY_Mode_switch)
mask |= EGG_VIRTUAL_MODE_SWITCH_MASK;
}
/* Mod1Mask is 1 << 3 for example, i.e. the
* fourth modifier, i / keyspermod is the modifier
* index
*/
modmap->mapping[i/xmodmap->max_keypermod] |= mask;
g_free (keyvals);
g_free (keys);
}
/* Add in the not-really-virtual fixed entries */
modmap->mapping[EGG_MODMAP_ENTRY_SHIFT] |= EGG_VIRTUAL_SHIFT_MASK;
modmap->mapping[EGG_MODMAP_ENTRY_CONTROL] |= EGG_VIRTUAL_CONTROL_MASK;
modmap->mapping[EGG_MODMAP_ENTRY_LOCK] |= EGG_VIRTUAL_LOCK_MASK;
modmap->mapping[EGG_MODMAP_ENTRY_MOD1] |= EGG_VIRTUAL_ALT_MASK;
modmap->mapping[EGG_MODMAP_ENTRY_MOD2] |= EGG_VIRTUAL_MOD2_MASK;
modmap->mapping[EGG_MODMAP_ENTRY_MOD3] |= EGG_VIRTUAL_MOD3_MASK;
modmap->mapping[EGG_MODMAP_ENTRY_MOD4] |= EGG_VIRTUAL_MOD4_MASK;
modmap->mapping[EGG_MODMAP_ENTRY_MOD5] |= EGG_VIRTUAL_MOD5_MASK;
XFreeModifiermap (xmodmap);
}
const EggModmap*
egg_keymap_get_modmap (GdkKeymap *keymap)
{
EggModmap *modmap;
if (keymap == NULL)
keymap = gdk_keymap_get_default ();
/* This is all a hack, much simpler when we can just
* modify GDK directly.
*/
modmap = g_object_get_data (G_OBJECT (keymap), "egg-modmap");
if (modmap == NULL)
{
modmap = g_new0 (EggModmap, 1);
/* FIXME modify keymap change events with an event filter
* and force a reload if we get one
*/
reload_modmap (keymap, modmap);
g_object_set_data_full (G_OBJECT (keymap),
"egg-modmap",
modmap,
g_free);
}
g_assert (modmap != NULL);
return modmap;
}
ukui-settings-daemon-4.0.10.1/common/eggaccelerators.h 0000664 0000000 0000000 00000006332 15241041773 0022612 0 ustar 00root root 0000000 0000000 /* -*- Mode: C; indent-tabs-mode: nil; tab-width: 4 -*-
* -*- coding: utf-8 -*-
*
* Copyright (C) 2023 KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef __EGG_ACCELERATORS_H__
#define __EGG_ACCELERATORS_H__
#include
#ifdef __cplusplus
extern "C" {
#endif
/* Where a value is also in GdkModifierType we coincide,
* otherwise we don't overlap.
*/
typedef enum
{
EGG_VIRTUAL_SHIFT_MASK = 1 << 0,
EGG_VIRTUAL_LOCK_MASK = 1 << 1,
EGG_VIRTUAL_CONTROL_MASK = 1 << 2,
EGG_VIRTUAL_ALT_MASK = 1 << 3, /* fixed as Mod1 */
EGG_VIRTUAL_MOD2_MASK = 1 << 4,
EGG_VIRTUAL_MOD3_MASK = 1 << 5,
EGG_VIRTUAL_MOD4_MASK = 1 << 6,
EGG_VIRTUAL_MOD5_MASK = 1 << 7,
#if 0
GDK_BUTTON1_MASK = 1 << 8,
GDK_BUTTON2_MASK = 1 << 9,
GDK_BUTTON3_MASK = 1 << 10,
GDK_BUTTON4_MASK = 1 << 11,
GDK_BUTTON5_MASK = 1 << 12,
/* 13, 14 are used by Xkb for the keyboard group */
#endif
EGG_VIRTUAL_MODE_SWITCH_MASK = 1 << 23,
EGG_VIRTUAL_NUM_LOCK_MASK = 1 << 24,
EGG_VIRTUAL_SCROLL_LOCK_MASK = 1 << 25,
/* Also in GdkModifierType */
EGG_VIRTUAL_SUPER_MASK = 1 << 26,
EGG_VIRTUAL_HYPER_MASK = 1 << 27,
EGG_VIRTUAL_META_MASK = 1 << 28,
/* Also in GdkModifierType */
EGG_VIRTUAL_RELEASE_MASK = 1 << 30,
/* 28-31 24-27 20-23 16-19 12-15 8-11 4-7 0-3
* 5 f 8 0 0 0 f f
*/
EGG_VIRTUAL_MODIFIER_MASK = 0x5f8000ff
} EggVirtualModifierType;
gboolean egg_accelerator_parse_virtual (const gchar *accelerator,
guint *accelerator_key,
guint **accelerator_codes,
EggVirtualModifierType *accelerator_mods);
void egg_keymap_resolve_virtual_modifiers (GdkKeymap *keymap,
EggVirtualModifierType virtual_mods,
GdkModifierType *concrete_mods);
void egg_keymap_virtualize_modifiers (GdkKeymap *keymap,
GdkModifierType concrete_mods,
EggVirtualModifierType *virtual_mods);
gchar* egg_virtual_accelerator_name (guint accelerator_key,
guint keycode,
EggVirtualModifierType accelerator_mods);
gchar* egg_virtual_accelerator_label (guint accelerator_key,
guint keycode,
EggVirtualModifierType accelerator_mods);
#ifdef __cplusplus
}
#endif
#endif /* __EGG_ACCELERATORS_H__ */
ukui-settings-daemon-4.0.10.1/common/plugin-interface.h 0000664 0000000 0000000 00000002052 15241041773 0022707 0 ustar 00root root 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*-
* -*- coding: utf-8 -*-
*
* Copyright (C) 2023 KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef PLUGIN_INTERFACE_H
#define PLUGIN_INTERFACE_H
#include
namespace UkuiSettingsDaemon {
class PluginInterface;
}
class PluginInterface
{
public:
virtual ~PluginInterface() {}
virtual void activate () = 0;
virtual void deactivate () = 0;
};
#endif // PLUGIN_INTERFACE_H
ukui-settings-daemon-4.0.10.1/common/plugin-manager-interface.h 0000664 0000000 0000000 00000002060 15241041773 0024316 0 ustar 00root root 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*-
* -*- coding: utf-8 -*-
*
* Copyright (C) 2023 KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef BASEMANAGER_H
#define BASEMANAGER_H
#include
namespace UkuiSettingsDaemon {
class ManagerInterface;
}
class ManagerInterface: public QObject
{
Q_OBJECT
public:
virtual ~ManagerInterface() {}
virtual bool Start () = 0;
virtual void Stop () = 0;
};
#endif // BASEMANAGER_H
ukui-settings-daemon-4.0.10.1/common/rfkillswitch.cpp 0000664 0000000 0000000 00000023076 15241041773 0022524 0 ustar 00root root 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*-
* -*- coding: utf-8 -*-
*
* Copyright (C) 2023 KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "rfkillswitch.h"
#include
#include
#include
#include
#include
#include
RfkillSwitch *RfkillSwitch::m_rfkillInstance = new RfkillSwitch();
bool RfkillSwitch::isVirtualWlan(QString dp){
QDir dir(VIRTUAL_PATH);
if (!dir.exists()){
return false;
}
dir.setFilter(QDir::Dirs);
dir.setSorting(QDir::Name);
int count = dir.count();
if (count <= 0){
return false;
}
QFileInfoList fileinfoList = dir.entryInfoList();
for(QFileInfo fileinfo : fileinfoList){
if (fileinfo.fileName() == "." || fileinfo.fileName() == ".."){
continue;
}
if (QString::compare(fileinfo.fileName(), dp) == 0){
return true;
}
}
return false;
}
int RfkillSwitch::getCurrentWlanMode(){
struct rfkill_event event;
ssize_t len;
int fd;
int bls = 0, unbls = 0;
QList status;
fd = open("/dev/rfkill", O_RDONLY);
if (fd < 0) {
qCritical("Can't open RFKILL control device");
return -1;
}
if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) {
qCritical("Can't set RFKILL control device to non-blocking");
close(fd);
return -1;
}
while (1) {
len = read(fd, &event, sizeof(event));
if (len < 0) {
if (errno == EAGAIN)
break;
qWarning("Reading of RFKILL events failed");
break;
}
if (len != RFKILL_EVENT_SIZE_V1) {
qWarning("Wrong size of RFKILL event\n");
continue;
}
// printf("%u - %u: %u\n", event.idx, event.type, event.soft);
if (event.type != RFKILL_TYPE_WLAN)
continue;
if (isVirtualWlan(QString(getRFkillName(event.idx)))){
continue;
}
status.append(event.soft ? 1 : 0);
}
close(fd);
if (status.length() == 0){
return -1;
}
for (int s : status){
s ? bls++ : unbls++;
}
if (bls == status.length()){ //block
return 0;
} else if (unbls == status.length()){ //unblock
return 1;
} else { //not block & not unblock
return 0;
}
}
int RfkillSwitch::getCurrentFlightMode(){
struct rfkill_event event;
ssize_t len;
int fd;
int bls = 0, unbls = 0;
QList status;
fd = open("/dev/rfkill", O_RDONLY);
if (fd < 0) {
qCritical("Can't open RFKILL control device");
return -1;
}
if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) {
qCritical("Can't set RFKILL control device to non-blocking");
close(fd);
return -1;
}
while (1) {
len = read(fd, &event, sizeof(event));
if (len < 0) {
if (errno == EAGAIN)
break;
qWarning("Reading of RFKILL events failed");
break;
}
if (len != RFKILL_EVENT_SIZE_V1) {
qWarning("Wrong size of RFKILL event\n");
continue;
}
if (isVirtualWlan(QString(getRFkillName(event.idx)))){
continue;
}
// printf("%u: %u\n", event.idx, event.soft);
status.append(event.soft ? 1 : 0);
}
close(fd);
if (status.length() == 0){
return -1;
}
for (int s : status){
s ? bls++ : unbls++;
}
if (bls == status.length()){ //block
return 1;
} else if (unbls == status.length()){ //unblock
return 0;
} else { //not block & not unblock
return 0;
}
}
QString RfkillSwitch::toggleFlightMode(bool enable){
struct rfkill_event event;
int fd;
ssize_t len;
__u8 block;
fd = open("/dev/rfkill", O_RDWR);
if (fd < 0) {
return QString("Can't open RFKILL control device");
}
block = enable ? 1 : 0;
memset(&event, 0, sizeof(event));
event.op= RFKILL_OP_CHANGE_ALL;
/* RFKILL_TYPE_ALL = 0 */
event.type = RFKILL_TYPE_ALL;
event.soft = block;
len = write(fd, &event, sizeof(event));
if (len < 0){
return QString("Failed to change RFKILL state");
}
close(fd);
return block ? QString("block"):QString("unblock");
}
QString RfkillSwitch::getWifiState()
{
if(!wifiDeviceIsPresent()){
return "";
}
QString cmd = "nmcli radio wifi";
QProcess process;
process.start(cmd);
process.waitForStarted();
process.waitForFinished();
QString wifiState = QString::fromLocal8Bit(process.readAllStandardOutput());
wifiState.replace("\n","");
return wifiState;
}
bool RfkillSwitch::wifiDeviceIsPresent()
{
QDBusInterface m_interface( "org.freedesktop.NetworkManager",
"/org/freedesktop/NetworkManager",
"org.freedesktop.NetworkManager",
QDBusConnection::systemBus() );
//先获取所有的网络设备的设备路径
QDBusReply> obj_reply = m_interface.call("GetAllDevices");
if (!obj_reply.isValid()) {
qDebug()<<"execute dbus method 'GetAllDevices' is invalid in func getObjectPath()";
return false;
}
QList obj_paths = obj_reply.value();
//再判断有无有线设备和无线设备的路径
Q_FOREACH(QDBusObjectPath obj_path, obj_paths) {
QDBusInterface interface( "org.freedesktop.NetworkManager",
obj_path.path(),
"org.freedesktop.DBus.Introspectable",
QDBusConnection::systemBus() );
QDBusReply reply = interface.call("Introspect");
if (reply.isValid()) {
if (reply.value().indexOf("org.freedesktop.NetworkManager.Device.Wireless") != -1) {
//表明有wifi设备
return true;
}
}
}
return false;
}
void RfkillSwitch::turnWifiOn()
{
QString cmd = "nmcli radio wifi on";
QProcess::execute(cmd);
}
void RfkillSwitch::turnWifiOff()
{
QString cmd = "nmcli radio wifi off";
QProcess::execute(cmd);
}
int RfkillSwitch::getCurrentBluetoothMode()
{
struct rfkill_event event;
ssize_t len;
int fd;
int bls = 0, unbls = 0;
QList status;
fd = open("/dev/rfkill", O_RDONLY);
if (fd < 0) {
qCritical("Can't open RFKILL control device");
return -1;
}
if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) {
qCritical("Can't set RFKILL control device to non-blocking");
close(fd);
return -1;
}
while (1) {
len = read(fd, &event, sizeof(event));
if (len < 0) {
qWarning("Reading of RFKILL events failed");
break;
}
if (len != RFKILL_EVENT_SIZE_V1) {
qWarning("Wrong size of RFKILL event\n");
continue;
}
// printf("%u - %u: %u\n", event.idx, event.type, event.soft);
if (event.type != RFKILL_TYPE_BLUETOOTH)
continue;
status.append(event.soft ? 1 : 0);
}
close(fd);
if (status.length() == 0){
return -1;
}
for (int s : status){
s ? bls++ : unbls++;
}
if (bls == status.length()){ //block
return 0;
} else if (unbls == status.length()){ //unblock
return 1;
} else { //not block & not unblock
return 0;
}
}
QString RfkillSwitch::toggleBluetoothMode(bool enable)
{
struct rfkill_event event;
int fd;
ssize_t len;
__u8 block;
fd = open("/dev/rfkill", O_RDWR);
if (fd < 0) {
return QString("Can't open RFKILL control device");
}
block = enable ? 0 : 1;
memset(&event, 0, sizeof(event));
event.op= RFKILL_OP_CHANGE_ALL;
event.type = RFKILL_TYPE_BLUETOOTH;
event.soft = block;
len = write(fd, &event, sizeof(event));
if (len < 0){
close(fd);
return QString("Failed to change RFKILL state");
}
close(fd);
return block ? QString("blocked") : QString("unblocked");
}
const char * getRFkillName(__u32 idx){
static char name[128] = {};
char *pos, filename[64];
int fd;
snprintf(filename, sizeof(filename) - 1,
"/sys/class/rfkill/rfkill%u/name", idx);
fd = open(filename, O_RDONLY);
if (fd < 0)
return NULL;
memset(name, 0, sizeof(name));
read(fd, name, sizeof(name) - 1);
pos = strchr(name, '\n');
if (pos)
*pos = '\0';
close(fd);
return name;
}
const char * getRFkillType(__u32 idx){
static char name[128] = {};
char *pos, filename[64];
int fd;
snprintf(filename, sizeof(filename) - 1,
"/sys/class/rfkill/rfkill%u/type", idx);
fd = open(filename, O_RDONLY);
if (fd < 0)
return NULL;
memset(name, 0, sizeof(name));
read(fd, name, sizeof(name) - 1);
pos = strchr(name, '\n');
if (pos)
*pos = '\0';
close(fd);
return name;
}
ukui-settings-daemon-4.0.10.1/common/rfkillswitch.h 0000664 0000000 0000000 00000004355 15241041773 0022170 0 ustar 00root root 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*-
* -*- coding: utf-8 -*-
*
* Copyright (C) 2023 KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef RFKILLSWITCH_H
#define RFKILLSWITCH_H
#include
#include
#include
extern "C" {
#include
#include
#include
#define RFKILL_EVENT_SIZE_V1 8
#define VIRTUAL_PATH "/sys/devices/virtual/ieee80211"
const char * getRFkillType(__u32 idx);
const char * getRFkillName(__u32 idx);
struct rfkill_event {
__u32 idx;
__u8 type;
__u8 op;
__u8 soft, hard;
};
enum rfkill_operation {
RFKILL_OP_ADD = 0,
RFKILL_OP_DEL,
RFKILL_OP_CHANGE,
RFKILL_OP_CHANGE_ALL,
};
enum rfkill_type {
RFKILL_TYPE_ALL = 0,
RFKILL_TYPE_WLAN,
RFKILL_TYPE_BLUETOOTH,
RFKILL_TYPE_UWB,
RFKILL_TYPE_WIMAX,
RFKILL_TYPE_WWAN,
RFKILL_TYPE_GPS,
RFKILL_TYPE_FM,
RFKILL_TYPE_NFC,
NUM_RFKILL_TYPES,
};
}
/* 无线设备软开关 */
class RfkillSwitch : public QObject
{
Q_OBJECT
public:
explicit RfkillSwitch(){}
RfkillSwitch(const RfkillSwitch&){}
RfkillSwitch& operator==(const RfkillSwitch&){}
static RfkillSwitch* instance(){return m_rfkillInstance;}
public:
bool isVirtualWlan(QString dp);
int getCurrentFlightMode();
QString toggleFlightMode(bool enable);
int getCurrentWlanMode();
QString getWifiState();
bool wifiDeviceIsPresent();
void turnWifiOff();
void turnWifiOn();
int getCurrentBluetoothMode();
QString toggleBluetoothMode(bool enable);
private:
static RfkillSwitch* m_rfkillInstance;
Q_SIGNALS:
};
#endif // RFKILLSWITCH_H
ukui-settings-daemon-4.0.10.1/common/touch-calibrate.cpp 0000664 0000000 0000000 00000030364 15241041773 0023063 0 ustar 00root root 0000000 0000000 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "touch-calibrate.h"
//尺寸检测
bool TouchCalibrate::checkMatch(double output_width, double output_height,
double input_width, double input_height)
{
double w_diff, h_diff;
w_diff = ABS(1 - (output_width / input_width));
h_diff = ABS(1 - (output_height / input_height));
SYS_LOG(LOG_DEBUG,"w_diff--------%f,h_diff----------%f", w_diff, h_diff);
if (w_diff < MAX_SIZE_MATCH_DIFF && h_diff < MAX_SIZE_MATCH_DIFF) {
return true;
}
return false;
}
QVariantList TouchCalibrate::getDeviceProductId(int id)
{
QVariantList valueList;
Atom real_type;
int real_format;
unsigned long nitems;
unsigned long bytes_after;
unsigned char* data = nullptr;
unsigned char* dataPtr = nullptr;
Atom prop = XInternAtom(UsdBaseClass::getQx11Info(), "Device Product ID", False);
if (Success == XIGetProperty(UsdBaseClass::getQx11Info(), id, prop, 0,
1000, False, AnyPropertyType, &real_type,
&real_format, &nitems, &bytes_after, &data)) {
dataPtr = data;
for (int i = 0; i < nitems; ++i) {
if (real_type == XA_INTEGER && real_format == 32) {
valueList << *(reinterpret_cast(dataPtr));
}
dataPtr += real_format / 8;
}
XFree(data);
}
return valueList;
}
//获取设备节点
QString TouchCalibrate::getDeviceNode(int id)
{
QString node;
Atom prop;
Atom act_type;
int act_format;
unsigned long nitems, bytes_after;
unsigned char *data;
prop = XInternAtom(m_display, "Device Node", False);
if (!prop) {
return node;
}
if (XIGetProperty(m_display, id, prop, 0, 1000, False,
AnyPropertyType, &act_type, &act_format, &nitems, &bytes_after, &data) == Success) {
node = QString::fromLatin1(reinterpret_cast(data));
XFree(data);
}
return node;
}
//获取触摸设备物理尺寸
void TouchCalibrate::getTouchSize(const char* node, int& width, int& height)
{
const char *udevSubsystems[] = {"input", NULL};
GUdevClient *udevClient = g_udev_client_new(udevSubsystems);
if (!udevClient) {
SYS_LOG(LOG_DEBUG, " Failed to new udev client.");
return;
}
GUdevDevice *udevDevice = g_udev_client_query_by_device_file(udevClient, node);
if (g_udev_device_has_property(udevDevice, "ID_INPUT_WIDTH_MM")) {
width = g_udev_device_get_property_as_uint64(udevDevice, "ID_INPUT_WIDTH_MM");
}
if (g_udev_device_has_property(udevDevice, "ID_INPUT_HEIGHT_MM")) {
height = g_udev_device_get_property_as_uint64(udevDevice, "ID_INPUT_HEIGHT_MM");
}
g_clear_object(&udevClient);
}
TouchCalibrate::TouchCalibrate(const QString& path, QObject *parent)
: QObject(parent)
, m_display(XOpenDisplay(NULL))
, m_touchConfigPath(path)
{
}
TouchCalibrate::~TouchCalibrate()
{
if (m_display) {
XCloseDisplay(m_display);
}
m_screenInfoMap.clear();
m_touchScreenList.clear();
m_tabletList.clear();
m_touchConfigList.clear();
}
bool TouchCalibrate::initDisplay()
{
}
//获取屏幕列表
void TouchCalibrate::getScreenList()
{
int event_base, error_base, major, minor;
Window root;
XRRScreenResources *res;
if (!XRRQueryExtension(m_display, &event_base, &error_base) ||
!XRRQueryVersion(m_display, &major, &minor)) {
SYS_LOG(LOG_ERR, "RandR extension missing.");
return;
}
root = DefaultRootWindow(m_display);
if (major >= 1 && minor >= 5) {
res = XRRGetScreenResources(m_display, root);
if (!res) {
SYS_LOG(LOG_ERR, "get screen resources failed");
return;
}
for (int o = 0; o < res->noutput; ++o) {
XRROutputInfo *output = XRRGetOutputInfo(m_display, res, res->outputs[o]);
if (!output){
SYS_LOG(LOG_ERR, "could not get output.");
continue;
}
if (output->connection == RR_Connected) {
ScreenInfoPtr screen(new ScreenInfo);
screen->name = QString::fromLatin1(output->name);
screen->width = output->mm_width;
screen->height = output->mm_height;
m_screenInfoMap.insert(screen->name, screen);
SYS_LOG(LOG_DEBUG, "%s width : %d height : %d",
screen->name.toLatin1().data(), screen->width, screen->height);
}
XRRFreeOutputInfo(output);
}
XRRFreeScreenResources(res);
}
}
void TouchCalibrate::addTouchDevice(const XDeviceInfo& device, TouchDeviceList& touchList)
{
const QString& node = getDeviceNode(device.id);
const QVariantList& product = getDeviceProductId(device.id);
if (!node.isEmpty()) {
TouchDevicePtr dev = TouchDevicePtr(new TouchDevice);
dev->id = device.id;
dev->name = QString::fromLatin1(device.name);
dev->node = node;
getTouchSize(node.toLatin1().data(), dev->width, dev->height);
if (product.count() > 1) {
dev->product.isValid = true;
dev->product.vid = product[0].toInt();
dev->product.pid = product[1].toInt();
}
touchList.append(dev);
SYS_LOG(LOG_DEBUG, "%s id : %d node: %s width : %d height : %d",
dev->name.toLatin1().data(), dev->id, dev->node.toLatin1().data(), dev->width, dev->height);
}
}
// 获取触摸设备列表
void TouchCalibrate::getTouchDeviceList()
{
int ndevices;
XDeviceInfo* deviceList = XListInputDevices(m_display ,&ndevices);
for (int i = 0 ; i < ndevices ; ++i) {
XDeviceInfo device = deviceList[i];
if (device.type == XInternAtom(m_display, XI_TOUCHSCREEN, False)) {
addTouchDevice(device, m_touchScreenList);
} else if (device.type == XInternAtom(m_display, XI_TABLET, False)) {
addTouchDevice(device, m_tabletList);
}
}
XFreeDeviceList(deviceList);
}
//获取触摸配置
void TouchCalibrate::getTouchConfigure()
{
QFileInfo file(m_touchConfigPath);
if(file.exists()) {
QSettings *configSettings = new QSettings(m_touchConfigPath, QSettings::IniFormat);
int mapNum = configSettings->value("/COUNT/num").toInt();
if (mapNum < 1) {
return;
}
for (int i = 0; i < mapNum ;++i) {
QString mapName = QString("/MAP%1/%2");
QString touchName = configSettings->value(mapName.arg(i+1).arg("name")).toString();
if(touchName.isEmpty()) {
continue;
}
QString scrname = configSettings->value(mapName.arg(i+1).arg("scrname")).toString();
if(scrname.isEmpty()) {
continue;
}
// serial 不判空,暂不关注,无法通过序列号匹配屏幕
QString serial = configSettings->value(mapName.arg(i+1).arg("serial")).toString();
TouchConfigPtr touchConfig(new TouchConfig);
touchConfig->sTouchName = touchName;
touchConfig->sMonitorName = scrname;
touchConfig->sTouchSerial = serial;
//读取配置中productId,如果无此配置则无效,不进行product比较
const QStringList& productList = configSettings->value(mapName.arg(i+1).arg("productId")).toString().split(" ");
if (productList.count() > 1) {
touchConfig->product.isValid = true;
touchConfig->product.vid = productList[0].toInt();
touchConfig->product.pid = productList[1].toInt();
}
m_touchConfigList.append(touchConfig);
}
configSettings->deleteLater();
}
}
//进行映射
void TouchCalibrate::calibrate()
{
if (!m_display) {
SYS_LOG(LOG_DEBUG, "Failed to get x display");
return;
}
//获取设备
getScreenList();
getTouchDeviceList();
getTouchConfigure();
calibrateTouchScreen();
calibrateTablet();
}
void TouchCalibrate::autoMaticMapping(TouchDeviceList &touchList, ScreenInfoMap &screenMap)
{
//如果配置文件无法覆盖所有的屏幕组合,继续通过比较触摸设备和屏幕物理尺寸进行映射
TouchDeviceList::iterator it_tc = touchList.begin();
while (it_tc != touchList.end()) {
if ((*it_tc)->isMapped) {
++it_tc;
continue;
}
ScreenInfoMap::iterator it_sc = screenMap.begin();
while (it_sc != screenMap.end()) {
if (it_sc.value()->isMapped || (*it_tc)->isMapped) {
++it_sc;
continue;
}
if (checkMatch(it_sc.value()->width, it_sc.value()->height, (*it_tc)->width, (*it_tc)->height)) {
calibrateDevice((*it_tc)->id, it_sc.value()->name);
(*it_tc)->isMapped = true;
it_sc.value()->isMapped = true;
}
++it_sc;
}
++it_tc;
}
//通过配置文件,尺寸比较后,仍然无法映射所有触摸设备与屏幕,则对剩下的设备进行随机映射
it_tc = touchList.begin();
while (it_tc != touchList.end()) {
if ((*it_tc)->isMapped) {
++it_tc;
continue;
}
ScreenInfoMap::iterator it_sc = screenMap.begin();
while (it_sc != screenMap.end()) {
if (it_sc.value()->isMapped || (*it_tc)->isMapped) {
++it_sc;
continue;
}
//此处不再比较触摸设备与屏幕大小,为映射过的设备和屏幕进行随机映射
calibrateDevice((*it_tc)->id, it_sc.value()->name);
++it_sc;
}
++it_tc;
}
}
//touchscreen
void TouchCalibrate::calibrateTouchScreen()
{
//首先配置文件映射
Q_FOREACH (const TouchConfigPtr& touchConfig, m_touchConfigList) {
Q_FOREACH (const TouchDevicePtr& touch , m_touchScreenList) {
if (touch->name == touchConfig->sTouchName) {
if (touchConfig->product.isValid) { // 检查配置里product id 是否有效,无效则不进行判断
if (touchConfig->product != touch->product) {
continue;
}
}
const ScreenInfoPtr& screen = m_screenInfoMap.value(touchConfig->sMonitorName);
if (screen.data()) {
calibrateDevice(touch->id, screen->name);
touch->isMapped = true;
screen->isMapped = true;
}
}
}
}
autoMaticMapping(m_touchScreenList, m_screenInfoMap);
}
//tablet
void TouchCalibrate::calibrateTablet()
{
//触摸笔映射,重置屏幕映射
ScreenInfoMap::iterator it_sc = m_screenInfoMap.begin();
while (it_sc != m_screenInfoMap.end()) {
if (it_sc.value()->isMapped) {
it_sc.value()->isMapped = false;
}
++it_sc;
}
autoMaticMapping(m_tabletList, m_screenInfoMap);
}
void TouchCalibrate::calibrateDevice(int id, const QString& output)
{
QStringList arguments;
arguments << "--map-to-output" << QString::number(id) << output;
QProcess process;
process.setProgram("xinput");
process.setArguments(arguments);
if (!process.startDetached()) {
SYS_LOG(LOG_DEBUG, "xinput map to output failed");
}
SYS_LOG(LOG_DEBUG, "xinput touch device map to output [%d : %s]", id, output.toLatin1().data());
}
ukui-settings-daemon-4.0.10.1/common/touch-calibrate.h 0000664 0000000 0000000 00000011144 15241041773 0022523 0 ustar 00root root 0000000 0000000 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef TOUCHCALIBRATE_H
#define TOUCHCALIBRATE_H
#include
#include
#include
#include
#include
#include
#include
#include
#include
extern "C"{
#include "clib-syslog.h"
}
#include "usd_base_class.h"
//添加product 识别,但对于同型号触摸屏product id和 name 完全一致,无法区分
struct Product
{
int32_t vid = 0;
int32_t pid = 0;
bool isValid = false; //有效性,是否需要有效匹配product
bool operator ==(const Product& other) {
return (this->vid == other.vid && this->pid == other.pid);
}
bool operator !=(const Product& other) {
return (this->vid != other.vid || this->pid != other.pid);
}
};
struct TouchDevice
{
QString name;
QString node;
int id;
int width = 0;
int height = 0;
bool isMapped = false; //已映射
Product product;
};
struct ScreenInfo
{
QString name;
int width = 0;
int height = 0;
bool isMapped = false;
};
struct TouchConfig
{
QString sTouchName; //触摸屏的名称
QString sTouchSerial; //触摸屏的序列号
QString sMonitorName; //显示器的名称
Product product; //配置存储的ProductId
};//配置文件中记录的映射关系信息
typedef QSharedPointer TouchDevicePtr;
typedef QList TouchDeviceList;
typedef QSharedPointer ScreenInfoPtr;
typedef QMap ScreenInfoMap;
typedef QSharedPointer TouchConfigPtr;
typedef QList TouchConfigList;
class TouchCalibrate : public QObject
{
Q_OBJECT
public:
explicit TouchCalibrate(const QString& path, QObject *parent = nullptr);
~TouchCalibrate();
private:
bool initDisplay();
/**
* @brief 获取已连接屏幕信息
*/
void getScreenList();
/**
* @brief 获取触摸设备信息
*/
void getTouchDeviceList();
/**
* @brief 获取屏幕映射信息
*/
void getTouchConfigure();
/**
* @brief touchscreen 映射
*/
void calibrateTouchScreen();
/**
* @brief tablet 映射
*/
void calibrateTablet();
/**
* @brief calibrateDevice
* @param id 触摸设备ID
* @param output 屏幕名称
*/
void calibrateDevice(int id, const QString &output);
/**
* @brief checkMatch
* @param output_width
* @param output_height
* @param input_width
* @param input_height
* @return 尺寸比较
*/
bool checkMatch(double output_width, double output_height, double input_width, double input_height);
/**
* @brief 获取设备节点
* @param id
* @return
*/
QString getDeviceNode(int id);
/**
* @brief 获取触摸设备尺寸
* @param node
* @param width
* @param height
*/
void getTouchSize(const char *node, int &width, int &height);
/**
* @brief 获取设备productId ,分为vid,pid
* @param id
* @return
*/
QVariantList getDeviceProductId(int id);
/**
* @brief createTouchDevice
* @param device
* @return
*/
void addTouchDevice(const XDeviceInfo& device, TouchDeviceList& touchList);
/**
* @brief autoMaticMapping 触摸笔,触摸屏,非配置部分映射
* @param touchMap 触摸设备
* @param screenMap 屏幕信息
*/
void autoMaticMapping(TouchDeviceList& touchList, ScreenInfoMap& screenMap);
public:
void calibrate();
Q_SIGNALS:
private:
Display *m_display = nullptr;
QString m_touchConfigPath;
ScreenInfoMap m_screenInfoMap;
TouchDeviceList m_touchScreenList;
TouchDeviceList m_tabletList;
TouchConfigList m_touchConfigList;
};
#endif // TOUCHCALIBRATE_H
ukui-settings-daemon-4.0.10.1/common/ukui-input-helper.c 0000664 0000000 0000000 00000007325 15241041773 0023045 0 ustar 00root root 0000000 0000000 /* -*- Mode: C; indent-tabs-mode: nil; tab-width: 4 -*-
* -*- coding: utf-8 -*-
*
* Copyright (C) 2023 KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "ukui-input-helper.h"
#include
#include
#include
#include
gboolean
supports_xinput_devices (void)
{
gint op_code, event, error;
return XQueryExtension (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
"XInputExtension",
&op_code,
&event,
&error);
}
static gboolean
device_has_property (XDevice *device,
const char *property_name)
{
Atom realtype, prop;
int realformat;
unsigned long nitems, bytes_after;
unsigned char *data;
prop = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), property_name, True);
if (!prop)
return FALSE;
gdk_x11_display_error_trap_push (gdk_display_get_default());
if ((XGetDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device, prop, 0, 1, False,
XA_INTEGER, &realtype, &realformat, &nitems,
&bytes_after, &data) == Success) && (realtype != None)) {
gdk_x11_display_error_trap_pop_ignored (gdk_display_get_default());
XFree (data);
return TRUE;
}
gdk_x11_display_error_trap_pop_ignored (gdk_display_get_default());
return FALSE;
}
XDevice*
device_is_touchpad (XDeviceInfo *deviceinfo)
{
XDevice *device;
if (deviceinfo->type != XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), XI_TOUCHPAD, True))
return NULL;
gdk_x11_display_error_trap_push (gdk_display_get_default());
device = XOpenDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), deviceinfo->id);
if (gdk_x11_display_error_trap_pop (gdk_display_get_default()) || (device == NULL))
return NULL;
if (device_has_property (device, "libinput Tapping Enabled") ||
device_has_property (device, "Synaptics Off")) {
return device;
}
XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device);
return NULL;
}
gboolean
touchpad_is_present (void)
{
XDeviceInfo *device_info;
int n_devices;
int i;
gboolean retval;
if (supports_xinput_devices () == FALSE)
return TRUE;
retval = FALSE;
device_info = XListInputDevices (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), &n_devices);
if (device_info == NULL)
return FALSE;
for (i = 0; i < n_devices; i++) {
XDevice *device;
device = device_is_touchpad (&device_info[i]);
if (device != NULL) {
retval = TRUE;
break;
}
}
if (device_info != NULL)
XFreeDeviceList (device_info);
return retval;
}
ukui-settings-daemon-4.0.10.1/common/ukui-input-helper.h 0000664 0000000 0000000 00000002106 15241041773 0023042 0 ustar 00root root 0000000 0000000 /* -*- Mode: C; indent-tabs-mode: nil; tab-width: 4 -*-
* -*- coding: utf-8 -*-
*
* Copyright (C) 2023 KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef __USD_INPUT_HELPER_H
#define __USD_INPUT_HELPER_H
#include
#include
#include
gboolean supports_xinput_devices (void);
XDevice *device_is_touchpad (XDeviceInfo *deviceinfo);
gboolean touchpad_is_present (void);
#endif /* __USD_INPUT_HELPER_H */
ukui-settings-daemon-4.0.10.1/common/ukui-keygrab.cpp 0000664 0000000 0000000 00000017617 15241041773 0022422 0 ustar 00root root 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*-
* -*- coding: utf-8 -*-
*
* Copyright (C) 2023 KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "config.h"
#include "ukui-keygrab.h"
#ifdef HAVE_X11_EXTENSIONS_XKB_H
#include
#include
#include
#include
#endif
#include "eggaccelerators.h"
/* these are the mods whose combinations are ignored by the keygrabbing code */
static GdkModifierType usd_ignored_mods = (GdkModifierType)0;
/* these are the ones we actually use for global keys, we always only check
* for these set */
static GdkModifierType usd_used_mods = (GdkModifierType)0;
static void
setup_modifiers (void)
{
if (usd_used_mods == 0 || usd_ignored_mods == 0) {
GdkModifierType dynmods;
/* default modifiers */
usd_ignored_mods = \
GdkModifierType(0x2000 /*Xkb modifier*/ | GDK_LOCK_MASK | GDK_HYPER_MASK);
usd_used_mods = \
GdkModifierType(GDK_SHIFT_MASK | GDK_CONTROL_MASK |\
GDK_MOD1_MASK | GDK_MOD2_MASK | GDK_MOD3_MASK | GDK_MOD4_MASK |\
GDK_MOD5_MASK | GDK_SUPER_MASK | GDK_META_MASK);
/* NumLock can be assigned to varying keys so we need to
* resolve and ignore it specially */
dynmods = (GdkModifierType)0;
egg_keymap_resolve_virtual_modifiers (gdk_keymap_get_for_display(gdk_display_get_default()),
EGG_VIRTUAL_NUM_LOCK_MASK,
&dynmods);
usd_ignored_mods = GdkModifierType (usd_ignored_mods | dynmods);
usd_used_mods = GdkModifierType (usd_used_mods & ~dynmods);
dynmods = (GdkModifierType)0;
egg_keymap_resolve_virtual_modifiers (gdk_keymap_get_for_display(gdk_display_get_default()),
EGG_VIRTUAL_SCROLL_LOCK_MASK,
&dynmods);
usd_ignored_mods = GdkModifierType (usd_ignored_mods | dynmods);
usd_used_mods = GdkModifierType (usd_used_mods & ~dynmods);
}
}
static void
grab_key_real (guint keycode,
GdkWindow *root,
bool grab,
int mask)
{
if (grab) {
XGrabKey (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
keycode,
mask,
GDK_WINDOW_XID (root),
True,
GrabModeAsync,
GrabModeAsync);
} else {
XUngrabKey (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
keycode,
mask,
GDK_WINDOW_XID (root));
}
}
/* Grab the key. In order to ignore USD_IGNORED_MODS we need to grab
* all combinations of the ignored modifiers and those actually used
* for the binding (if any).
*
* inspired by all_combinations from ukui-panel/ukui-panel/global-keys.c
*
* This may generate X errors. The correct way to use this is like:
*
* gdk_error_trap_push ();
*
* grab_key_unsafe (key, grab, screens);
*
* gdk_flush ();
* if (gdk_error_trap_pop ())
* g_warning ("Grab failed, another application may already have access to key '%u'",
* key->keycode);
*
* This is not done in the function itself, to allow doing multiple grab_key
* operations with one flush only.
*/
#define N_BITS 32
void
grab_key_unsafe (Key *key,
bool grab,
QList *screens)
{
int indexes[N_BITS]; /* indexes of bits we need to flip */
int i;
int bit;
int bits_set_cnt;
int uppervalue;
guint mask;
setup_modifiers ();
mask = usd_ignored_mods & ~key->state & GDK_MODIFIER_MASK;
bit = 0;
/* store the indexes of all set bits in mask in the array */
for (i = 0; mask; ++i, mask >>= 1) {
if (mask & 0x1) {
indexes[bit++] = i;
}
}
bits_set_cnt = bit;
uppervalue = 1 << bits_set_cnt;
/* grab all possible modifier combinations for our mask */
for (i = 0; i < uppervalue; ++i) {
QList::iterator l,begin,end;
int j;
int result = 0;
/* map bits in the counter to those in the mask */
for (j = 0; j < bits_set_cnt; ++j) {
if (i & (1 << j)) {
result |= (1 << indexes[j]);
}
}
l = begin = screens->begin();
end = screens->end();
for (; l != end; ++l) {
GdkScreen *screen = *l;
GdkWindow *window = gdk_screen_get_root_window (screen);
guint *code = key->keycodes ;
for (; code&&(*code); ++code) {
grab_key_real (*code,
window,
grab,
result | key->state);
}
}
}
}
static gboolean
have_xkb (Display *dpy)
{
static int have_xkb = -1;
if (have_xkb == -1) {
#ifdef HAVE_X11_EXTENSIONS_XKB_H
int opcode, error_base, major, minor, xkb_event_base;
have_xkb = XkbQueryExtension (dpy,
&opcode,
&xkb_event_base,
&error_base,
&major,
&minor)
&& XkbUseExtension (dpy, &major, &minor);
#else
have_xkb = 0;
#endif
}
return have_xkb;
}
gboolean
key_uses_keycode (const Key *key, guint keycode)
{
if (key->keycodes != NULL) {
guint *c;
for (c = key->keycodes; *c; ++c) {
if (*c == keycode)
return TRUE;
}
}
return FALSE;
}
gboolean
match_key (Key *key, XEvent *event)
{
guint keyval;
GdkModifierType consumed;
gint group;
if (key == NULL)
return FALSE;
setup_modifiers ();
#ifdef HAVE_X11_EXTENSIONS_XKB_H
if (have_xkb (event->xkey.display))
group = XkbGroupForCoreState (event->xkey.state);
else
#endif
group = (event->xkey.state & GDK_KEY_Mode_switch) ? 1 : 0;
/* Check if we find a keysym that matches our current state */
if (gdk_keymap_translate_keyboard_state (gdk_keymap_get_for_display(gdk_display_get_default()), event->xkey.keycode,
(GdkModifierType)event->xkey.state, group,
&keyval, NULL, NULL, &consumed)) {
guint lower, upper;
gdk_keyval_convert_case (keyval, &lower, &upper);
/* If we are checking against the lower version of the
* keysym, we might need the Shift state for matching,
* so remove it from the consumed modifiers */
if (lower == key->keysym)
consumed = GdkModifierType (consumed & ~GDK_SHIFT_MASK);
return ((lower == key->keysym || upper == key->keysym)
&& (event->xkey.state & ~consumed & usd_used_mods) == key->state);
}
/* The key we passed doesn't have a keysym, so try with just the keycode */
return (key != NULL
&& key->state == (event->xkey.state & usd_used_mods)
&& key_uses_keycode (key, event->xkey.keycode));
}
ukui-settings-daemon-4.0.10.1/common/ukui-keygrab.h 0000664 0000000 0000000 00000002726 15241041773 0022062 0 ustar 00root root 0000000 0000000 /* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*-
* -*- coding: utf-8 -*-
*
* Copyright (C) 2023 KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef __USD_COMMON_KEYGRAB_H
#define __USD_COMMON_KEYGRAB_H
#include
#ifdef signals
#undef signals
#endif
#ifdef __cplusplus
extern "C" {
#endif
#include
#include
#include
#include
typedef struct {
guint keysym;
guint state;
guint *keycodes;
} Key;
void grab_key_unsafe (Key *key,
bool grab,
QList *screens);
gboolean match_key (Key *key,
XEvent *event);
gboolean key_uses_keycode (const Key *key,
guint keycode);
#ifdef __cplusplus
}
#endif
#endif /* __USD_COMMON_KEYGRAB_H */
ukui-settings-daemon-4.0.10.1/common/ukui_icon.qrc 0000664 0000000 0000000 00000004540 15241041773 0022002 0 ustar 00root root 0000000 0000000 ukui_res/ukui/ukui-bluetooth-off.svgukui_res/ukui/ukui-bluetooth-on.svgukui_res/ukui/ukui-camera-off.svgukui_res/ukui/ukui-camera-on.svgukui_res/ukui/ukui-capslock-off.svgukui_res/ukui/ukui-capslock-on.svgukui_res/ukui/ukui-Fn-off.svgukui_res/ukui/ukui-Fn-on.svgukui_res/ukui/ukui-microphone-off.svgukui_res/ukui/ukui-microphone-on.svgukui_res/ukui/ukui-numlock-off.svgukui_res/ukui/ukui-numlock-on.svgukui_res/ukui/ukui-sound.svgukui_res/ukui/ukui-touchpad-off.svgukui_res/ukui/ukui-touchpad-on.svgukui_res/ukui/ukui-wifi-off.svgukui_res/ukui/ukui-wifi-on.svgukui_res/ukui_intel/ukui-bluetooth-off.svgukui_res/ukui_intel/ukui-bluetooth-on.svgukui_res/ukui_intel/ukui-camera-off.svgukui_res/ukui_intel/ukui-camera-on.svgukui_res/ukui_intel/ukui-capslock-off.svgukui_res/ukui_intel/ukui-capslock-on-symbolic.svgukui_res/ukui_intel/ukui-capslock-on.svgukui_res/ukui_intel/ukui-Fn-off.svgukui_res/ukui_intel/ukui-Fn-on.svgukui_res/ukui_intel/ukui-microphone-off.svgukui_res/ukui_intel/ukui-microphone-on.svgukui_res/ukui_intel/ukui-numlock-off.svgukui_res/ukui_intel/ukui-numlock-on.svgukui_res/ukui_intel/ukui-sound.svgukui_res/ukui_intel/ukui-touchpad-off.svgukui_res/ukui_intel/ukui-touchpad-on.svgukui_res/ukui_intel/ukui-wifi-off.svgukui_res/ukui_intel/ukui-airplane-on.svgukui_res/ukui_intel/ukui-airplane-off.svgukui_res/ukui/ukui-airplane-on.svgukui_res/ukui/ukui-airplane-off.svgukui_res/ukui/ukui-performance-symbolic.svgukui_res/ukui/ukui-eco-symbolic.svg
ukui-settings-daemon-4.0.10.1/common/ukui_res/ 0000775 0000000 0000000 00000000000 15241041773 0021131 5 ustar 00root root 0000000 0000000 ukui-settings-daemon-4.0.10.1/common/ukui_res/ukui/ 0000775 0000000 0000000 00000000000 15241041773 0022106 5 ustar 00root root 0000000 0000000 ukui-settings-daemon-4.0.10.1/common/ukui_res/ukui/ukui-Fn-off.svg 0000664 0000000 0000000 00000004150 15241041773 0024715 0 ustar 00root root 0000000 0000000
ukui-settings-daemon-4.0.10.1/common/ukui_res/ukui/ukui-Fn-on.svg 0000664 0000000 0000000 00000004006 15241041773 0024557 0 ustar 00root root 0000000 0000000
ukui-settings-daemon-4.0.10.1/common/ukui_res/ukui/ukui-airplane-off.svg 0000664 0000000 0000000 00000014371 15241041773 0026153 0 ustar 00root root 0000000 0000000
ukui-settings-daemon-4.0.10.1/common/ukui_res/ukui/ukui-airplane-on.svg 0000664 0000000 0000000 00000014245 15241041773 0026015 0 ustar 00root root 0000000 0000000
ukui-settings-daemon-4.0.10.1/common/ukui_res/ukui/ukui-bluetooth-off.svg 0000664 0000000 0000000 00000001374 15241041773 0026364 0 ustar 00root root 0000000 0000000
ukui-settings-daemon-4.0.10.1/common/ukui_res/ukui/ukui-bluetooth-on.svg 0000664 0000000 0000000 00000001256 15241041773 0026225 0 ustar 00root root 0000000 0000000
ukui-settings-daemon-4.0.10.1/common/ukui_res/ukui/ukui-camera-off.svg 0000664 0000000 0000000 00000003403 15241041773 0025602 0 ustar 00root root 0000000 0000000
ukui-settings-daemon-4.0.10.1/common/ukui_res/ukui/ukui-camera-on.svg 0000664 0000000 0000000 00000003224 15241041773 0025445 0 ustar 00root root 0000000 0000000
ukui-settings-daemon-4.0.10.1/common/ukui_res/ukui/ukui-capslock-off.svg 0000664 0000000 0000000 00000004216 15241041773 0026154 0 ustar 00root root 0000000 0000000
ukui-settings-daemon-4.0.10.1/common/ukui_res/ukui/ukui-capslock-on.svg 0000664 0000000 0000000 00000004054 15241041773 0026016 0 ustar 00root root 0000000 0000000
ukui-settings-daemon-4.0.10.1/common/ukui_res/ukui/ukui-eco-symbolic.svg 0000664 0000000 0000000 00000002550 15241041773 0026171 0 ustar 00root root 0000000 0000000
ukui-settings-daemon-4.0.10.1/common/ukui_res/ukui/ukui-microphone-off.svg 0000664 0000000 0000000 00000002470 15241041773 0026520 0 ustar 00root root 0000000 0000000
ukui-settings-daemon-4.0.10.1/common/ukui_res/ukui/ukui-microphone-on.svg 0000664 0000000 0000000 00000002333 15241041773 0026360 0 ustar 00root root 0000000 0000000
ukui-settings-daemon-4.0.10.1/common/ukui_res/ukui/ukui-numlock-off.svg 0000664 0000000 0000000 00000004177 15241041773 0026033 0 ustar 00root root 0000000 0000000
ukui-settings-daemon-4.0.10.1/common/ukui_res/ukui/ukui-numlock-on.svg 0000664 0000000 0000000 00000004035 15241041773 0025666 0 ustar 00root root 0000000 0000000
ukui-settings-daemon-4.0.10.1/common/ukui_res/ukui/ukui-performance-symbolic.svg 0000664 0000000 0000000 00000000464 15241041773 0027726 0 ustar 00root root 0000000 0000000