refact: remove almost all files

This is a prepare commit for the following refactor of
dde-application-manager.

I remove almost all files in this git repository.

We will start the refactor in later commits.

Signed-off-by: black-desk <me@black-desk.cn>
This commit is contained in:
black-desk
2023-05-25 17:10:09 +08:00
parent 06b051fda3
commit 235db8ab0c
250 changed files with 0 additions and 28982 deletions

6
.gitignore vendored
View File

@ -1,6 +0,0 @@
CMakeLists.txt.user
build/
# translations files
*.qm
.vscode/

View File

@ -1,10 +0,0 @@
[main]
host = https://www.transifex.com
minimum_perc = 80
mode = developer
[o:linuxdeepin:p:deepin-desktop-environment:r:dde-application-manager]
file_filter = translations/dde-application-manager_<lang>.ts
source_file = translations/dde-application-manager.ts
source_lang = en_US
type = QT

View File

@ -1,2 +0,0 @@
[transifex]
branch = m20

View File

@ -1,28 +0,0 @@
cmake_minimum_required(VERSION 3.11)
project(dde-application-manager)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(GNUInstallDirs)
#install settings
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX /usr)
endif ()
add_subdirectory(src)
add_subdirectory(misc)
if (NOT (${CMAKE_BUILD_TYPE} MATCHES "Debug"))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ofast")
# generate qm
execute_process(COMMAND bash "translate_generation.sh"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
endif ()
# qm files
file(GLOB QM_FILES "translations/*.qm")
install(FILES ${QM_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/dde-application-manager/translations)

View File

@ -1,8 +0,0 @@
<interface name='org.deepin.dde.Application1.Instance'>
<method name='Exit'>
</method>
<method name='Kill'>
</method>
<property access='read' type='t(116)' name='startuptime' />
<property access='read' type='o' name='id' />
</interface>

View File

@ -1,51 +0,0 @@
<interface name='org.deepin.dde.Application1.Manager'>
<method name='AddAutostart'>
<arg type='s' name='fileNamae' direction='in' />
<arg type='b' name='outArg0' direction='out' />
</method>
<method name='AutostartList'>
<arg type='as' name='outArg0' direction='out' />
</method>
<method name='IsAutostart'>
<arg type='s' name='fileName' direction='in' />
<arg type='b' name='outArg0' direction='out' />
</method>
<method name='RemoveAutostart'>
<arg type='s' name='fileNamae' direction='in' />
<arg type='b' name='outArg0' direction='out' />
</method>
<method name="Launch">
<arg type='s' name='desktopFile' direction='in'/>
</method>
<method name="LaunchApp">
<arg type='s' name='desktopFile' direction='in'/>
<arg type='u' name='timestamp' direction='in'/>
<arg type='as' name='files' direction='in'/>
</method>
<method name='LaunchAppAction'>
<arg type='s' name='desktopFile' direction='in' />
<arg type='s' name='action' direction='in' />
<arg type='u' name='timestamp' direction='in' />
</method>
<method name="LaunchAppWithOptions">
<arg name="desktopFile" type="s" direction="in"></arg>
<arg name="timestamp" type="u" direction="in"></arg>
<arg name="files" type="as" direction="in"></arg>
<arg name="options" type="a{sv}" direction="in"></arg>
<annotation name="org.qtproject.QtDBus.QtTypeName.In3" value="QVariantMap"/>
</method>
<method name="RunCommand">
<arg name="exe" type="s" direction="in"></arg>
<arg name="args" type="as" direction="in"></arg>
</method>
<method name="RunCommandWithOptions">
<arg name="exe" type="s" direction="in"></arg>
<arg name="args" type="as" direction="in"></arg>
<arg name="options" type="a{sv}" direction="in"></arg>
<annotation name="org.qtproject.QtDBus.QtTypeName.In2" value="QVariantMap"/>
</method>
<signal name='AutostartChanged'>
<arg type='s' name='status' />
<arg type='s' name='filePath' />
</signal>
</interface>

View File

@ -1,15 +0,0 @@
<interface name='org.deepin.dde.Application1'>
<method name='Name'>
<arg type='s' name='locale' direction='in' />
<arg type='s' name='value' direction='out' />
</method>
<method name='Comment'>
<arg type='s' name='comment' direction='in' />
<arg type='s' name='value' direction='out' />
</method>
<property access='read' type='as' name='categories' />
<property access='read' type='as' name='mimetypes' />
<property access='read' type='s' name='id' />
<property access="read" type='s' name='icon' />
<property access='read' type='ao' name='instances' />
</interface>

View File

@ -1,30 +0,0 @@
<interface name='org.deepin.dde.Mime1'>
<method name='AddUserApp'>
<arg type='as' name='mimeTypes' direction='in'/>
<arg type='s' name='desktopId' direction='in'/>
</method>
<method name='DeleteApp'>
<arg type='as' name='mimeTypes' direction='in'/>
<arg type='s' name='desktopId' direction='in'/>
</method>
<method name='DeleteUserApp'>
<arg type='s' name='desktopId' direction='in'/>
</method>
<method name='GetDefaultApp'>
<arg type='s' name='mimeType' direction='in'/>
<arg type='s' name='defaultApp' direction='out'/>
</method>
<method name='ListApps'>
<arg type='s' name='mimeType' direction='in'/>
<arg type='s' name='apps' direction='out'/>
</method>
<method name='ListUserApps'>
<arg type='s' name='mimeType' direction='in'/>
<arg type='s' name='userApps' direction='out'/>
</method>
<method name='SetDefaultApp'>
<arg type='as' name='mimeTypes' direction='in'/>
<arg type='s' name='desktopId' direction='in'/>
</method>
<signal name="Change"></signal>
</interface>

View File

@ -1,14 +0,0 @@
#!/bin/bash
cp ".transifexrc" ${HOME}/
cd ./translations
#rm -f dde-launcher.ts
#根据源码生成翻译英文翻译文件
lupdate ../src/ -ts -no-obsolete dde-application-manager.ts
cd ../
lupdate ./ -ts -no-obsolete translations/dde-application-manager.ts
tx push -s -b m23

View File

@ -1,2 +0,0 @@
add_subdirectory(systemd)
add_subdirectory(dconf)

View File

@ -1,9 +0,0 @@
set(DCONFIG_FILES
com.deepin.dde.launcher.json
com.deepin.dde.dock.json
com.deepin.dde.appearance.json
com.deepin.dde.startdde.json
com.deepin.xsettings.json
)
install(FILES ${DCONFIG_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/dsg/configs/dde-application-manager)

View File

@ -1,145 +0,0 @@
{
"magic": "dsg.config.meta",
"version": "1.0",
"contents": {
"Extra_Picture_Uris": {
"serial": 0,
"flags": [],
"name": "Extra_Picture_Uris",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Font_Standard": {
"value": "Noto Sans",
"serial": 0,
"flags": [],
"name": "Font_Standard",
"name[zh_CN]": "*****",
"description": "The standard font for desktop",
"permissions": "readwrite",
"visibility": "private"
},
"Theme_Auto": {
"value": false,
"serial": 0,
"flags": [],
"name": "Theme_Auto",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Wallpaper_Slideshow": {
"value": "",
"serial": 0,
"flags": [],
"name": "Wallpaper_Slideshow",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Cursor_Theme": {
"value": "bloom",
"serial": 0,
"flags": [],
"name": "Cursor_Theme",
"name[zh_CN]": "*****",
"description": "Cursor theme name. Used only by Xservers that support the Xcursor extension.",
"permissions": "readwrite",
"visibility": "private"
},
"Font_Size": {
"value": 10.5,
"serial": 0,
"flags": [],
"name": "Font_Size",
"name[zh_CN]": "*****",
"description": "The desktop font size",
"permissions": "readwrite",
"visibility": "private"
},
"Wallpaper_Uris": {
"value": "",
"serial": 0,
"flags": [],
"name": "Wallpaper_Uris",
"name[zh_CN]": "*****",
"description": "wallpaper json string",
"permissions": "readwrite",
"visibility": "private"
},
"Icon_Theme": {
"value": "bloom",
"serial": 0,
"flags": [],
"name": "Icon_Theme",
"name[zh_CN]": "*****",
"description": "Icon theme to use for the panel, nautilus etc.",
"permissions": "readwrite",
"visibility": "private"
},
"Opacity": {
"value": 0.4,
"serial": 0,
"flags": [],
"name": "Opacity",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Font_Monospace": {
"value": "Noto Mono",
"serial": 0,
"flags": [],
"name": "Font_Monospace",
"name[zh_CN]": "*****",
"description": "The monospace font for desktop",
"permissions": "readwrite",
"visibility": "private"
},
"Excluded_Icon_Themes": {
"value": ["hicolor", "gnome", "Adwaita"],
"serial": 0,
"flags": [],
"name": "Excluded_Icon_Themes",
"name[zh_CN]": "*****",
"description": "Icon theme black list.",
"permissions": "readwrite",
"visibility": "private"
},
"Gtk_Theme": {
"value": "deepin",
"serial": 0,
"flags": [],
"name": "Gtk_Theme",
"name[zh_CN]": "*****",
"description": "Basename of the default theme used by gtk+.",
"permissions": "readwrite",
"visibility": "private"
},
"Sound_Theme": {
"value": "deepin",
"serial": 0,
"flags": [],
"name": "Sound_Theme",
"name[zh_CN]": "*****",
"description": "Set the system sound theme",
"permissions": "readwrite",
"visibility": "private"
},
"Background_Uris": {
"value": ["file:///usr/share/backgrounds/default_background.jpg"],
"serial": 0,
"flags": [],
"name": "Background_Uris",
"name[zh_CN]": "*****",
"description": "Note that the backend only supports local (file://) URIs.",
"permissions": "readwrite",
"visibility": "private"
}
}
}

View File

@ -1,176 +0,0 @@
{
"magic": "dsg.config.meta",
"version": "1.0",
"contents": {
"Window_Size_Fashion": {
"value": 48,
"serial": 0,
"flags": [],
"name": "Window_Size_Fashion",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Icon_Size": {
"value": 36,
"serial": 0,
"flags": [],
"name": "Icon_Size",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Position": {
"value": "bottom",
"serial": 0,
"flags": [],
"name": "Position",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Wireless_Scan_Interval": {
"value": 5,
"serial": 0,
"flags": [],
"name": "Wireless_Scan_Interval",
"name[zh_CN]": "*****",
"description": "wireless scan interval",
"permissions": "readwrite",
"visibility": "private"
},
"Hide_Timeout": {
"value": 0,
"serial": 0,
"flags": [],
"name": "Hide_Timeout",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Hide_Mode": {
"value": "keep-showing",
"serial": 0,
"flags": [],
"name": "Hide_Mode",
"name[zh_CN]": "*****",
"description": "The value will influence when the dock is shown or hidden.",
"permissions": "readwrite",
"visibility": "private"
},
"Show_Timeout": {
"value": 100,
"serial": 0,
"flags": [],
"name": "Show_Timeout",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Window_Size_Efficient": {
"value": 40,
"serial": 0,
"flags": [],
"name": "Window_Size_Efficient",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Plugin_Settings": {
"value": "{}",
"serial": 0,
"flags": [],
"name": "Plugin_Settings",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Docked_Apps": {
"value": ["/usr/share/applications/dde-file-manager", "/usr/share/applications/uos-browser", "/usr/share/applications/org.deepin.browser", "/usr/share/applications/deepin-appstore", "/usr/share/applications/deepin-app-store", "/usr/share/applications/com.deepin.store.intranet", "/usr/share/applications/deepin-album", "/usr/share/applications/deepin-music", "/usr/share/applications/deepin-contacts", "/usr/share/applications/dde-calendar", "/usr/share/applications/dde-control-center"],
"serial": 0,
"flags": [],
"name": "Docked_Apps",
"name[zh_CN]": "*****",
"description": "The default apps which is docked when dock is started.",
"permissions": "readwrite",
"visibility": "private"
},
"Win_Icon_Preferred_Apps": {
"value": ["apps.com.qq.im", "deepin.com.qq.im", "apps.com.qq.im.light", "apps.com.qq.b.eim", "apps.com.qq.rtxclient"],
"serial": 0,
"flags": [],
"name": "Win_Icon_Preferred_Apps",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Delay_Plugins_Time": {
"value": 0,
"serial": 0,
"flags": [],
"name": "Delay_Plugins_Time",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Force_Quit_App": {
"value": "enabled",
"serial": 0,
"flags": [],
"name": "Force_Quit_App",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Display_Mode": {
"value": "",
"serial": 0,
"flags": [],
"name": "Display_Mode",
"name[zh_CN]": "*****",
"description": "The dock gets different display mode, for instance, dock looks like win7 taskbar on classic mode.",
"permissions": "readwrite",
"visibility": "private"
},
"Recent_App": {
"value": [],
"serial": 0,
"flags": [],
"name": "Recent_App",
"name[zh_CN]": "*****",
"description": "The apps which has been opened recently when dock is started",
"permissions": "readwrite",
"visibility": "private"
},
"Show_Recent": {
"value": false,
"serial": 0,
"flags": [],
"name": "Show_Recent",
"name[zh_CN]": "*****",
"description": "show or hide recent app in dock",
"permissions": "readwrite",
"visibility": "private"
},
"Show_MultiWindow": {
"value": false,
"serial": 0,
"flags": [],
"name": "Show_MultiWindow",
"name[zh_CN]": "*****",
"description": "show or hide Multi Window in dock when the Entry has subWindow",
"permissions": "readwrite",
"visibility": "private"
}
}
}

View File

@ -1,246 +0,0 @@
{
"magic": "dsg.config.meta",
"version": "1.0",
"contents": {
"Apps_Disable_AutoStart": {
"value": [],
"serial": 0,
"flags": [],
"name": "Apps_Disable_AutoStart",
"name[zh_CN]": "*****",
"description": "apps not allowed to start up",
"permissions": "readwrite",
"visibility": "private"
},
"Apps_Order_Zh_Cn": {
"value": ["uos-browser", "org.deepin.browser", "dde-file-manager", "deepin-app-store", "deepin-appstore", "deepin-music", "deepin-movie", "deepin-screen-recorder", "deepin-image-viewer", "deepin-album", "deepin-draw", "deepin-reader", "deepin-editor", "deepin-mail", "thunderbird", "deepin-terminal", "terminal", "org.gnome.Terminal", "deepin-contacts", "deepin-voice-note", "downloader", "deepin-manual", "org.deepin.scanner", "org.deepin.scaner", "dde-computer", "dde-trash", "deepin-defender", "dde-control-center", "chineseime-setting", "fcitx-config-gtk3", "chineseime-setting-wizard", "deepin-system-monitor", "deepin-boot-maker", "deepin-devicemanager", "deepin-log-viewer", "dde-printer", "dde-calendar", "deepin-calculator", "deepin-font-manager", "deepin-compressor", "deepin-deb-installer", "deepin-diskmanager", "dde-introduction", "uos-service-support", "uos-remote-assistance", "deepin-camera", "deepin-phone-master", "gparted", "org.gnome.Cheese", "Cheese", "gnome.Cheese"],
"serial": 0,
"flags": [],
"name": "Apps_Order_Zh_Cn",
"name[zh_CN]": "*****",
"description": "launcher apps order, ensure that all lowercase.",
"permissions": "readwrite",
"visibility": "private"
},
"Apps_Icon_Ratio": {
"value": 0.5,
"serial": 0,
"flags": [],
"name": "Apps_Icon_Ratio",
"name[zh_CN]": "*****",
"description": "(null)",
"permissions": "readwrite",
"visibility": "private"
},
"Apps_Disable_UseProxy": {
"value": [],
"serial": 0,
"flags": [],
"name": "Apps_Disable_UseProxy",
"name[zh_CN]": "*****",
"description": "apps disable use proxy menu",
"permissions": "readwrite",
"visibility": "private"
},
"Apps_Without_AutoStart": {
"value": [],
"serial": 0,
"flags": [],
"name": "Apps_Without_AutoStart",
"name[zh_CN]": "*****",
"description": "apps hide function start up",
"permissions": "readwrite",
"visibility": "private"
},
"Fullscreen": {
"value": true,
"serial": 0,
"flags": [],
"name": "Fullscreen",
"name[zh_CN]": "*****",
"description": "(null)",
"permissions": "readwrite",
"visibility": "private"
},
"Mini_Frame_Right_Bar_Hide_List": {
"value": [],
"serial": 0,
"flags": [],
"name": "Mini_Frame_Right_Bar_Hide_List",
"name[zh_CN]": "*****",
"description": "icons not allowed to show on mini frame right bar",
"permissions": "readwrite",
"visibility": "private"
},
"Auto_Exit": {
"value": false,
"serial": 0,
"flags": [],
"name": "Auto_Exit",
"name[zh_CN]": "*****",
"description": "(null)",
"permissions": "readwrite",
"visibility": "private"
},
"Apps_Order_Zh_Tw": {
"value": ["uos-browser", "org.deepin.browser", "dde-file-manager", "deepin-app-store", "deepin-appstore", "deepin-music", "deepin-movie", "deepin-screen-recorder", "deepin-image-viewer", "deepin-album", "deepin-draw", "deepin-reader", "deepin-editor", "deepin-mail", "thunderbird", "deepin-terminal", "terminal", "org.gnome.Terminal", "deepin-contacts", "deepin-voice-note", "downloader", "deepin-manual", "org.deepin.scanner", "org.deepin.scaner", "dde-computer", "dde-trash", "deepin-defender", "dde-control-center", "chineseime-setting", "fcitx-config-gtk3", "chineseime-setting-wizard", "deepin-system-monitor", "deepin-boot-maker", "deepin-devicemanager", "deepin-log-viewer", "dde-printer", "dde-calendar", "deepin-calculator", "deepin-font-manager", "deepin-compressor", "deepin-deb-installer", "deepin-diskmanager", "dde-introduction", "uos-service-support", "uos-remote-assistance", "deepin-camera", "deepin-phone-master", "gparted", "org.gnome.Cheese", "Cheese", "gnome.Cheese"],
"serial": 0,
"flags": [],
"name": "Apps_Order_Zh_Tw",
"name[zh_CN]": "*****",
"description": "launcher apps order, ensure that all lowercase.",
"permissions": "readwrite",
"visibility": "private"
},
"Apps_Disable_SendDock": {
"value": [],
"serial": 0,
"flags": [],
"name": "Apps_Disable_SendDock",
"name[zh_CN]": "*****",
"description": "apps not allowed to send to Dock",
"permissions": "readwrite",
"visibility": "private"
},
"Apps_Disable_SendDesktop": {
"value": [],
"serial": 0,
"flags": [],
"name": "Apps_Disable_SendDesktop",
"name[zh_CN]": "*****",
"description": "apps not allowed to send to Desktop",
"permissions": "readwrite",
"visibility": "private"
},
"Apps_Without_SendDesktop": {
"value": [],
"serial": 0,
"flags": [],
"name": "Apps_Without_SendDesktop",
"name[zh_CN]": "*****",
"description": "apps hide function send to desktop",
"permissions": "readwrite",
"visibility": "private"
},
"Apps_Hold_List": {
"value": ["dde-introduction", "dde-file-manager", "deepin-appstore", "deepin-app-store", "deepin-terminal", "deepin-manual", "dde-computer", "dde-trash", "deepin-defender", "dde-control-center", "fcitx-config-gtk3", "fcitx-configtool", "deepin-system-monitor", "deepin-devicemanager", "dde-printer", "dde-calendar", "uos-service-support", "deepin-toggle-desktop", "deepin-wm-multitaskingview", "kwin-wm-multitaskingview", "com.deepin.store.intranet", "chineseime-setting"],
"serial": 0,
"flags": [],
"name": "Apps_Hold_List",
"name[zh_CN]": "*****",
"description": "apps not allowed to uninstall",
"permissions": "readwrite",
"visibility": "private"
},
"Apps_Without_Open": {
"value": [],
"serial": 0,
"flags": [],
"name": "Apps_Without_Open",
"name[zh_CN]": "*****",
"description": "apps hide function open",
"permissions": "readwrite",
"visibility": "private"
},
"Apps_Disable_Open": {
"value": [],
"serial": 0,
"flags": [],
"name": "Apps_Disable_Open",
"name[zh_CN]": "*****",
"description": "apps not allowed to open",
"permissions": "readwrite",
"visibility": "private"
},
"Apps_Use_Proxy": {
"value": [],
"serial": 0,
"flags": [],
"name": "Apps_Use_Proxy",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Search_Package_Name": {
"value": false,
"serial": 0,
"flags": [],
"name": "Search_Package_Name",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Apps_Order": {
"value": ["uos-browser", "org.deepin.browser", "dde-file-manager", "deepin-app-store", "deepin-appstore", "deepin-music", "deepin-movie", "deepin-screen-recorder", "deepin-image-viewer", "deepin-album", "deepin-draw", "deepin-reader", "deepin-editor", "deepin-mail", "thunderbird", "deepin-terminal", "terminal", "org.gnome.Terminal", "deepin-contacts", "deepin-voice-note", "downloader", "deepin-manual", "org.deepin.scanner", "org.deepin.scaner", "dde-computer", "dde-trash", "deepin-defender", "dde-control-center", "chineseime-setting", "fcitx-config-gtk3", "chineseime-setting-wizard", "deepin-system-monitor", "deepin-boot-maker", "deepin-devicemanager", "deepin-log-viewer", "dde-printer", "dde-calendar", "deepin-calculator", "deepin-font-manager", "deepin-compressor", "deepin-deb-installer", "deepin-diskmanager", "dde-introduction", "uos-service-support", "uos-remote-assistance", "deepin-camera", "deepin-phone-master", "gparted", "org.gnome.Cheese", "Cheese", "gnome.Cheese"],
"serial": 0,
"flags": [],
"name": "Apps_Order",
"name[zh_CN]": "*****",
"description": "launcher apps order, ensure that all lowercase.",
"permissions": "readwrite",
"visibility": "private"
},
"Apps_Without_UseProxy": {
"value": [],
"serial": 0,
"flags": [],
"name": "Apps_Without_UseProxy",
"name[zh_CN]": "*****",
"description": "apps hide use proxy menu",
"permissions": "readwrite",
"visibility": "private"
},
"Apps_Disable_Scaling": {
"value": [],
"serial": 0,
"flags": [],
"name": "Apps_Disable_Scaling",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Apps_Hidden": {
"value": [],
"serial": 0,
"flags": [],
"name": "Apps_Hidden",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Apps_Without_SendDock": {
"value": [],
"serial": 0,
"flags": [],
"name": "Apps_Without_SendDock",
"name[zh_CN]": "*****",
"description": "apps hide function send to dock",
"permissions": "readwrite",
"visibility": "private"
},
"Apps_Without_Uninstall": {
"value": [],
"serial": 0,
"flags": [],
"name": "Apps_Without_Uninstall",
"name[zh_CN]": "*****",
"description": "apps hide function uninstall",
"permissions": "readwrite",
"visibility": "private"
},
"Display_Mode": {
"value": "free",
"serial": 0,
"flags": [],
"name": "Display_Mode",
"name[zh_CN]": "*****",
"description": "Launcher display mode.",
"permissions": "readwrite",
"visibility": "private"
}
}
}

View File

@ -1,96 +0,0 @@
{
"magic": "dsg.config.meta",
"version": "1.0",
"contents": {
"Wm_Cmd": {
"value": "",
"serial": 0,
"flags": [],
"name": "Wm_Cmd",
"name[zh_CN]": "*****",
"description": "This key will special window manager at startdde startup. If empty, using deepin-wm.",
"permissions": "readwrite",
"visibility": "private"
},
"Quick_Black_Screen": {
"value": true,
"serial": 0,
"flags": [],
"name": "Quick_Black_Screen",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Swap_Sched_Enabled": {
"value": true,
"serial": 0,
"flags": [],
"name": "Swap_Sched_Enabled",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Launch_Welcome": {
"value": true,
"serial": 0,
"flags": [],
"name": "Launch_Welcome",
"name[zh_CN]": "*****",
"description": "This key will indicate whether showing dde-welcome.",
"permissions": "readwrite",
"visibility": "private"
},
"Autostart_Delay": {
"value": 0,
"serial": 0,
"flags": [],
"name": "Autostart_Delay",
"name[zh_CN]": "*****",
"description": "The delay seconds for autostart",
"permissions": "readwrite",
"visibility": "private"
},
"Turbo_Invoker_Enabled": {
"value": false,
"serial": 0,
"flags": [],
"name": "Turbo_Invoker_Enabled",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Login_Reminder": {
"value": false,
"serial": 0,
"flags": [],
"name": "Login_Reminder",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Iowait_Enabled": {
"value": false,
"serial": 0,
"flags": [],
"name": "Iowait_Enabled",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Memchecker_Enabled": {
"value": false,
"serial": 0,
"flags": [],
"name": "Memchecker_Enabled",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
}
}
}

View File

@ -1,337 +0,0 @@
{
"magic": "dsg.config.meta",
"version": "1.0",
"contents": {
"Qt_Active_Color": {
"value": "0,33153,65535,65535",
"serial": 0,
"flags": [],
"name": "Qt_Active_Color",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Xft_Antialias": {
"value": true,
"serial": 0,
"flags": [],
"name": "Xft_Antialias",
"name[zh_CN]": "*****",
"description": "Whether to antialias Xft fonts; 0=no, 1=yes, -1=default.",
"permissions": "readwrite",
"visibility": "private"
},
"Gtk_Cursor_Theme_Name": {
"value": "bloom",
"serial": 0,
"flags": [],
"name": "Gtk_Cursor_Theme_Name",
"name[zh_CN]": "*****",
"description": "Cursor theme name. Used only by Xservers that support the Xcursor extension.",
"permissions": "readwrite",
"visibility": "private"
},
"Dtk_Window_Radius": {
"value": 18,
"serial": 0,
"flags": [],
"name": "Dtk_Window_Radius",
"name[zh_CN]": "*****",
"description": "The window radius last time",
"permissions": "readwrite",
"visibility": "private"
},
"Gtk_Cursor_Blink_Timeout": {
"value": 10,
"serial": 0,
"flags": [],
"name": "Gtk_Cursor_Blink_Timeout",
"name[zh_CN]": "*****",
"description": "Time after which the cursor stops blinking, in seconds.",
"permissions": "readwrite",
"visibility": "private"
},
"Scale_Factor": {
"value": 1.0,
"serial": 0,
"flags": [],
"name": "Scale_Factor",
"name[zh_CN]": "*****",
"description": "Text scale for Gdk.",
"permissions": "readwrite",
"visibility": "private"
},
"Gtk_Key_Theme_Name": {
"value": "default",
"serial": 0,
"flags": [],
"name": "Gtk_Key_Theme_Name",
"name[zh_CN]": "*****",
"description": "Basename of the default keybinding theme used by gtk+.",
"permissions": "readwrite",
"visibility": "private"
},
"Cursor_Blink_Time": {
"value": 1200,
"serial": 0,
"flags": [],
"name": "Cursor_Blink_Time",
"name[zh_CN]": "*****",
"description": "Length of the cursor blink cycle, in milliseconds.",
"permissions": "readwrite",
"visibility": "private"
},
"Enable_Event_Sounds": {
"value": true,
"serial": 0,
"flags": [],
"name": "Enable_Event_Sounds",
"name[zh_CN]": "*****",
"description": "Whether to play any event sounds at all.",
"permissions": "readwrite",
"visibility": "private"
},
"Qt_Font_Name": {
"value": "",
"serial": 0,
"flags": [],
"name": "Qt_Font_Name",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Gtk_Theme_Name": {
"value": "deepin",
"serial": 0,
"flags": [],
"name": "Gtk_Theme_Name",
"name[zh_CN]": "*****",
"description": "Basename of the default theme used by gtk+.",
"permissions": "readwrite",
"visibility": "private"
},
"Double_Click_Time": {
"value": 250,
"serial": 0,
"flags": [],
"name": "Double_Click_Time",
"name[zh_CN]": "*****",
"description": "Maximum time allowed between two clicks for them to be considered a double click (in milliseconds).",
"permissions": "readwrite",
"visibility": "private"
},
"Icon_Theme_Name": {
"value": "deepin",
"serial": 0,
"flags": [],
"name": "Icon_Theme_Name",
"name[zh_CN]": "*****",
"description": "Icon theme to use for the panel, nautilus etc.",
"permissions": "readwrite",
"visibility": "private"
},
"Primary_Monitor_Name": {
"value": "eDP-1",
"serial": 0,
"flags": [],
"name": "Primary_Monitor_Name",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Dnd_Drag_Threshold": {
"value": 8,
"serial": 0,
"flags": [],
"name": "Dnd_Drag_Threshold",
"name[zh_CN]": "*****",
"description": "A palette of named colors for use in themes.",
"permissions": "readwrite",
"visibility": "private"
},
"Sound_Theme_Name": {
"value": "deepin",
"serial": 0,
"flags": [],
"name": "Sound_Theme_Name",
"name[zh_CN]": "*****",
"description": "Set the system sound theme",
"permissions": "readwrite",
"visibility": "private"
},
"Double_Click_Distance": {
"value": 5,
"serial": 0,
"flags": [],
"name": "Double_Click_Distance",
"name[zh_CN]": "*****",
"description": "Maximum distance allowed between two clicks for them to be considered a double click (in pixels).",
"permissions": "readwrite",
"visibility": "private"
},
"Xft_Hinting": {
"value": true,
"serial": 0,
"flags": [],
"name": "Xft_Hinting",
"name[zh_CN]": "*****",
"description": "Whether to hint Xft fonts; 0=no, 1=yes, -1=default.",
"permissions": "readwrite",
"visibility": "private"
},
"Theme_Name": {
"value": "deepin",
"serial": 0,
"flags": [],
"name": "Theme_Name",
"name[zh_CN]": "*****",
"description": "Theme to use for gtk+ and qt.",
"permissions": "readwrite",
"visibility": "private"
},
"Gtk_Cursor_Theme_Size": {
"value": 24,
"serial": 0,
"flags": [],
"name": "Gtk_Cursor_Theme_Size",
"name[zh_CN]": "*****",
"description": "Timeout in milliseconds before a click starts repeating (onspinner buttons for example).",
"permissions": "readwrite",
"visibility": "private"
},
"Icon_Theme_Fallback": {
"value": "default",
"serial": 0,
"flags": [],
"name": "Icon_Theme_Fallback",
"name[zh_CN]": "*****",
"description": "Name of a icon theme to fall back to.",
"permissions": "readwrite",
"visibility": "private"
},
"Xft_Rgba": {
"value": "rgb",
"serial": 0,
"flags": [],
"name": "Xft_Rgba",
"name[zh_CN]": "*****",
"description": "Type of subpixel antialiasing; none, rgb, bgr, vrgb, vbgr.",
"permissions": "readwrite",
"visibility": "private"
},
"Window_Scale": {
"value": 1,
"serial": 0,
"flags": [],
"name": "Window_Scale",
"name[zh_CN]": "*****",
"description": "Window scale for Gdk.",
"permissions": "readwrite",
"visibility": "private"
},
"Gtk_Recent_Files_Enabled": {
"value": true,
"serial": 0,
"flags": [],
"name": "Gtk_Recent_Files_Enabled",
"name[zh_CN]": "*****",
"description": "Whether GTK+ should keep track of items inside the recently used resources list.",
"permissions": "readwrite",
"visibility": "private"
},
"Qt_Mono_Font_Name": {
"value": "",
"serial": 0,
"flags": [],
"name": "Qt_Mono_Font_Name",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Cursor_Blink": {
"value": true,
"serial": 0,
"flags": [],
"name": "Cursor_Blink",
"name[zh_CN]": "*****",
"description": "Whether the cursor should blink.",
"permissions": "readwrite",
"visibility": "private"
},
"Individual_Scaling": {
"value": "",
"serial": 0,
"flags": [],
"name": "Individual_Scaling",
"name[zh_CN]": "*****",
"description": "Semicolon-separated list of name=value pairs, as used in QT_SCREEN_SCALE_FACTORS.",
"permissions": "readwrite",
"visibility": "private"
},
"Xft_Dpi": {
"value": -1,
"serial": 0,
"flags": [],
"name": "Xft_Dpi",
"name[zh_CN]": "*****",
"description": "Resolution for Xft, in 1024 * dots/inch. -1 to use default value. Do not modify it manually.",
"permissions": "readwrite",
"visibility": "private"
},
"Enable_Input_Feedback_Sounds": {
"value": true,
"serial": 0,
"flags": [],
"name": "Enable_Input_Feedback_Sounds",
"name[zh_CN]": "*****",
"description": "Whether to play event sounds as feedback to user input.",
"permissions": "readwrite",
"visibility": "private"
},
"Xft_Hintstyle": {
"value": "hintfull",
"serial": 0,
"flags": [],
"name": "Xft_Hintstyle",
"name[zh_CN]": "*****",
"description": "What degree of hinting to use; hintnone, hintslight, hintmedium, or hintfull.",
"permissions": "readwrite",
"visibility": "private"
},
"Qt_Font_Point_Size": {
"value": 10.5,
"serial": 0,
"flags": [],
"name": "Qt_Font_Point_Size",
"name[zh_CN]": "*****",
"description": "",
"permissions": "readwrite",
"visibility": "private"
},
"Gtk_Recent_Files_Max_Age": {
"value": 30,
"serial": 0,
"flags": [],
"name": "Gtk_Recent_Files_Max_Age",
"name[zh_CN]": "*****",
"description": "The maximum age, in days, of the items inside the recently used resources list. Items older than this setting will be excised from the list. If set to 0, the list will always be empty; if set to -1, no item will be removed.",
"permissions": "readwrite",
"visibility": "private"
},
"Gtk_Font_Name": {
"value": "sans-serif 10.5",
"serial": 0,
"flags": [],
"name": "Gtk_Font_Name",
"name[zh_CN]": "*****",
"description": "Name of the default font used by gtk+.",
"permissions": "readwrite",
"visibility": "private"
}
}
}

View File

@ -1,6 +0,0 @@
set(SYSTEMD_FILES
org.deepin.dde.Application1.Instance@.service
org.deepin.dde.Application1.Manager.service
)
install(FILES ${SYSTEMD_FILES} DESTINATION lib/systemd/user/)

View File

@ -1,9 +0,0 @@
[Unit]
Description=DDE Application Loader is managing %I
[Service]
Type=simple
Environment="DAM_TASK_HASH=%I"
Environment="DAM_TASK_TYPE=freedesktop"
ExecStart=/usr/bin/dde-application-loader
Slice=app.slice

View File

@ -1,19 +0,0 @@
[Unit]
Description=DDE Application Manager service
RefuseManualStart=no
RefuseManualStop=no
OnFailureJobMode=replace-irreversibly
CollectMode=inactive-or-failed
StartLimitIntervalSec=10s
StartLimitBurst=30
Requires=dde-session-pre.target
After=dde-session-pre.target
[Service]
Type=dbus
BusName=org.deepin.dde.Application1.Manager
ExecStart=/usr/bin/dde-application-manager
Slice=app.slice
Restart=on-failure
RestartSec=300ms

View File

@ -1,16 +0,0 @@
include(FindPkgConfig)
find_package(PkgConfig REQUIRED)
find_package(Qt5 REQUIRED COMPONENTS Core DBus Concurrent)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DDEFINE_LOADER_PATH)
set(LOADER_PATH ${PROJECT_BINARY_DIR}/src/loader/deepin-application-loader)
endif()
configure_file(
"${PROJECT_SOURCE_DIR}/src/define.h.in"
"${PROJECT_BINARY_DIR}/src/define.h"
)
add_subdirectory("service")
add_subdirectory("loader")

View File

@ -1,6 +0,0 @@
#ifndef DEFINE_H_IN
#define DEFINE_H_IN
#define LOADER_PATH "@LOADER_PATH@"
#endif // DEFINE_H_IN

View File

@ -1,73 +0,0 @@
/*
* This file was generated by qdbusxml2cpp-fix version 0.8
* Command line was: qdbusxml2cpp-fix -c BamfApplication -p BamfApplication Application.xml
*
* qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
* before re-generating it.
*/
#include "dbusbamfapplication.h"
/*
* Implementation of interface class __BamfApplication
*/
class __BamfApplicationPrivate
{
public:
__BamfApplicationPrivate() = default;
// begin member variables
public:
QMap<QString, QDBusPendingCallWatcher *> m_processingCalls;
QMap<QString, QList<QVariant>> m_waittingCalls;
};
__BamfApplication::__BamfApplication(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
: DBusExtendedAbstractInterface(service, path, staticInterfaceName(), connection, parent)
, d_ptr(new __BamfApplicationPrivate)
{
if (QMetaType::type("QList<uint>") == QMetaType::UnknownType) {
qRegisterMetaType< QList<uint> >("QList<uint>");
qDBusRegisterMetaType< QList<uint> >();
}
}
__BamfApplication::~__BamfApplication()
{
qDeleteAll(d_ptr->m_processingCalls.values());
delete d_ptr;
}
void __BamfApplication::CallQueued(const QString &callName, const QList<QVariant> &args)
{
if (d_ptr->m_waittingCalls.contains(callName))
{
d_ptr->m_waittingCalls[callName] = args;
return;
}
if (d_ptr->m_processingCalls.contains(callName))
{
d_ptr->m_waittingCalls.insert(callName, args);
} else {
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(asyncCallWithArgumentList(callName, args));
connect(watcher, &QDBusPendingCallWatcher::finished, this, &__BamfApplication::onPendingCallFinished);
d_ptr->m_processingCalls.insert(callName, watcher);
}
}
void __BamfApplication::onPendingCallFinished(QDBusPendingCallWatcher *w)
{
w->deleteLater();
const auto callName = d_ptr->m_processingCalls.key(w);
Q_ASSERT(!callName.isEmpty());
d_ptr->m_processingCalls.remove(callName);
if (!d_ptr->m_waittingCalls.contains(callName))
return;
const auto args = d_ptr->m_waittingCalls.take(callName);
CallQueued(callName, args);
}

View File

@ -1,134 +0,0 @@
/*
* This file was generated by qdbusxml2cpp-fix version 0.8
* Command line was: qdbusxml2cpp-fix -c BamfApplication -p BamfApplication Application.xml
*
* qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
*/
#ifndef BAMFAPPLICATION_H
#define BAMFAPPLICATION_H
#include <QtCore/QObject>
#include <QtCore/QByteArray>
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QVariant>
#include <DBusExtendedAbstractInterface>
#include <QtDBus/QtDBus>
/*
* Proxy class for interface org.ayatana.bamf.application
*/
class __BamfApplicationPrivate;
class __BamfApplication : public DBusExtendedAbstractInterface
{
Q_OBJECT
public:
static inline const char *staticInterfaceName()
{ return "org.ayatana.bamf.application"; }
public:
explicit __BamfApplication(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
~__BamfApplication();
public Q_SLOTS: // METHODS
inline Q_DECL_DEPRECATED QDBusPendingReply<QString, QString> ApplicationMenu()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("ApplicationMenu"), argumentList);
}
inline Q_DECL_DEPRECATED QDBusReply<QString> ApplicationMenu(QString &objectpath)
{
QList<QVariant> argumentList;
QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("ApplicationMenu"), argumentList);
if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 2) {
objectpath = qdbus_cast<QString>(reply.arguments().at(1));
}
return reply;
}
inline QDBusPendingReply<QString> ApplicationType()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("ApplicationType"), argumentList);
}
inline QDBusPendingReply<QString> DesktopFile()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("DesktopFile"), argumentList);
}
inline QDBusPendingReply<QString> FocusableChild()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("FocusableChild"), argumentList);
}
inline QDBusPendingReply<bool> ShowStubs()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("ShowStubs"), argumentList);
}
inline QDBusPendingReply<QStringList> SupportedMimeTypes()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("SupportedMimeTypes"), argumentList);
}
inline QDBusPendingReply<QList<uint> > Xids()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("Xids"), argumentList);
}
Q_SIGNALS: // SIGNALS
void DesktopFileUpdated(const QString &desktop_file);
void SupportedMimeTypesChanged(const QStringList &dnd_mimes);
Q_DECL_DEPRECATED void WindowAdded(const QString &path);
Q_DECL_DEPRECATED void WindowRemoved(const QString &path);
// begin property changed signals
public Q_SLOTS:
void CallQueued(const QString &callName, const QList<QVariant> &args);
private Q_SLOTS:
void onPendingCallFinished(QDBusPendingCallWatcher *w);
private:
__BamfApplicationPrivate *d_ptr;
};
namespace org {
namespace ayatana {
namespace bamf {
typedef ::__BamfApplication BamfApplication;
}
}
}
#endif

View File

@ -1,75 +0,0 @@
/*
* This file was generated by qdbusxml2cpp-fix version 0.8
* Command line was: qdbusxml2cpp-fix -c BamfMatcher -p BamfMatcher Matcher.xml
*
* qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
* before re-generating it.
*/
#include "dbusbamfmatcher.h"
/*
* Implementation of interface class __BamfMatcher
*/
class __BamfMatcherPrivate
{
public:
__BamfMatcherPrivate() = default;
// begin member variables
public:
QMap<QString, QDBusPendingCallWatcher *> m_processingCalls;
QMap<QString, QList<QVariant>> m_waittingCalls;
};
__BamfMatcher::__BamfMatcher(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
: DBusExtendedAbstractInterface(service, path, staticInterfaceName(), connection, parent)
, d_ptr(new __BamfMatcherPrivate)
{
if (QMetaType::type("QList<uint>") == QMetaType::UnknownType) {
qRegisterMetaType< QList<uint> >("QList<uint>");
qDBusRegisterMetaType< QList<uint> >();
}
}
__BamfMatcher::~__BamfMatcher()
{
qDeleteAll(d_ptr->m_processingCalls.values());
delete d_ptr;
}
void __BamfMatcher::CallQueued(const QString &callName, const QList<QVariant> &args)
{
if (d_ptr->m_waittingCalls.contains(callName))
{
d_ptr->m_waittingCalls[callName] = args;
return;
}
if (d_ptr->m_processingCalls.contains(callName))
{
d_ptr->m_waittingCalls.insert(callName, args);
} else {
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(asyncCallWithArgumentList(callName, args));
connect(watcher, &QDBusPendingCallWatcher::finished, this, &__BamfMatcher::onPendingCallFinished);
d_ptr->m_processingCalls.insert(callName, watcher);
}
}
void __BamfMatcher::onPendingCallFinished(QDBusPendingCallWatcher *w)
{
w->deleteLater();
const auto callName = d_ptr->m_processingCalls.key(w);
Q_ASSERT(!callName.isEmpty());
if (callName.isEmpty())
return;
d_ptr->m_processingCalls.remove(callName);
if (!d_ptr->m_waittingCalls.contains(callName))
return;
const auto args = d_ptr->m_waittingCalls.take(callName);
CallQueued(callName, args);
}

View File

@ -1,188 +0,0 @@
/*
* This file was generated by qdbusxml2cpp-fix version 0.8
* Command line was: qdbusxml2cpp-fix -c BamfMatcher -p BamfMatcher Matcher.xml
*
* qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
*/
#ifndef BAMFMATCHER_H
#define BAMFMATCHER_H
#include <QtCore/QObject>
#include <QtCore/QByteArray>
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QVariant>
#include <DBusExtendedAbstractInterface>
#include <QtDBus/QtDBus>
/*
* Proxy class for interface org.ayatana.bamf.matcher
*/
class __BamfMatcherPrivate;
class __BamfMatcher : public DBusExtendedAbstractInterface
{
Q_OBJECT
public:
static inline const char *staticInterfaceName()
{ return "org.ayatana.bamf.matcher"; }
public:
explicit __BamfMatcher(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
~__BamfMatcher();
public Q_SLOTS: // METHODS
inline QDBusPendingReply<QString> ActiveApplication()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("ActiveApplication"), argumentList);
}
inline QDBusPendingReply<QString> ActiveWindow()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("ActiveWindow"), argumentList);
}
inline QDBusPendingReply<QString> ApplicationForXid(uint xid)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(xid);
return asyncCallWithArgumentList(QStringLiteral("ApplicationForXid"), argumentList);
}
inline QDBusPendingReply<bool> ApplicationIsRunning(const QString &desktop_file)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(desktop_file);
return asyncCallWithArgumentList(QStringLiteral("ApplicationIsRunning"), argumentList);
}
inline QDBusPendingReply<QStringList> ApplicationPaths()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("ApplicationPaths"), argumentList);
}
inline QDBusPendingReply<QString> PathForApplication(const QString &desktop_file)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(desktop_file);
return asyncCallWithArgumentList(QStringLiteral("PathForApplication"), argumentList);
}
inline QDBusPendingReply<> RegisterFavorites(const QStringList &favorites)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(favorites);
return asyncCallWithArgumentList(QStringLiteral("RegisterFavorites"), argumentList);
}
inline void RegisterFavoritesQueued(const QStringList &favorites)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(favorites);
CallQueued(QStringLiteral("RegisterFavorites"), argumentList);
}
inline QDBusPendingReply<QStringList> RunningApplications()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("RunningApplications"), argumentList);
}
inline QDBusPendingReply<QStringList> RunningApplicationsDesktopFiles()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("RunningApplicationsDesktopFiles"), argumentList);
}
inline QDBusPendingReply<QStringList> TabPaths()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("TabPaths"), argumentList);
}
inline QDBusPendingReply<QStringList> WindowPaths()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("WindowPaths"), argumentList);
}
inline QDBusPendingReply<QStringList> WindowStackForMonitor(int monitor_id)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(monitor_id);
return asyncCallWithArgumentList(QStringLiteral("WindowStackForMonitor"), argumentList);
}
inline QDBusPendingReply<QList<uint> > XidsForApplication(const QString &desktop_file)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(desktop_file);
return asyncCallWithArgumentList(QStringLiteral("XidsForApplication"), argumentList);
}
Q_SIGNALS: // SIGNALS
void ActiveApplicationChanged(const QString &old_app, const QString &new_app);
void ActiveWindowChanged(const QString &old_win, const QString &new_win);
void RunningApplicationsChanged(const QStringList &opened_desktop_files, const QStringList &closed_desktop_files);
void StackingOrderChanged();
void ViewClosed(const QString &path, const QString &type);
void ViewOpened(const QString &path, const QString &type);
// begin property changed signals
public Q_SLOTS:
void CallQueued(const QString &callName, const QList<QVariant> &args);
private Q_SLOTS:
void onPendingCallFinished(QDBusPendingCallWatcher *w);
private:
__BamfMatcherPrivate *d_ptr;
};
namespace org {
namespace ayatana {
namespace bamf {
typedef ::__BamfMatcher BamfMatcher;
}
}
}
#endif

View File

@ -1,71 +0,0 @@
/*
* This file was generated by qdbusxml2cpp-fix version 0.8
* Command line was: qdbusxml2cpp-fix -c OutputManagement -p generated/outputmanagement ../xml/OutputManagement.xml
*
* qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
* before re-generating it.
*/
#include "dbuskwaylandoutput.h"
/*
* Implementation of interface class __OutputManagement
*/
class __OutputManagementPrivate
{
public:
__OutputManagementPrivate() = default;
// begin member variables
public:
QMap<QString, QDBusPendingCallWatcher *> m_processingCalls;
QMap<QString, QList<QVariant>> m_waittingCalls;
};
__OutputManagement::__OutputManagement(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
: DBusExtendedAbstractInterface(service, path, staticInterfaceName(), connection, parent)
, d_ptr(new __OutputManagementPrivate)
{
}
__OutputManagement::~__OutputManagement()
{
qDeleteAll(d_ptr->m_processingCalls.values());
delete d_ptr;
}
void __OutputManagement::CallQueued(const QString &callName, const QList<QVariant> &args)
{
if (d_ptr->m_waittingCalls.contains(callName))
{
d_ptr->m_waittingCalls[callName] = args;
return;
}
if (d_ptr->m_processingCalls.contains(callName))
{
d_ptr->m_waittingCalls.insert(callName, args);
} else {
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(asyncCallWithArgumentList(callName, args));
connect(watcher, &QDBusPendingCallWatcher::finished, this, &__OutputManagement::onPendingCallFinished);
d_ptr->m_processingCalls.insert(callName, watcher);
}
}
void __OutputManagement::onPendingCallFinished(QDBusPendingCallWatcher *w)
{
w->deleteLater();
const auto callName = d_ptr->m_processingCalls.key(w);
Q_ASSERT(!callName.isEmpty());
if (callName.isEmpty())
return;
d_ptr->m_processingCalls.remove(callName);
if (!d_ptr->m_waittingCalls.contains(callName))
return;
const auto args = d_ptr->m_waittingCalls.take(callName);
CallQueued(callName, args);
}

View File

@ -1,119 +0,0 @@
/*
* This file was generated by qdbusxml2cpp-fix version 0.8
* Command line was: qdbusxml2cpp-fix -c OutputManagement -p generated/outputmanagement ../xml/OutputManagement.xml
*
* qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
*/
#ifndef OUTPUTMANAGEMENT_H
#define OUTPUTMANAGEMENT_H
#include <QtCore/QObject>
#include <QtCore/QByteArray>
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QVariant>
#include <DBusExtendedAbstractInterface>
#include <QtDBus/QtDBus>
/*
* Proxy class for interface org.deepin.dde.KWayland1.Output
*/
class __OutputManagementPrivate;
class __OutputManagement : public DBusExtendedAbstractInterface
{
Q_OBJECT
public:
static inline const char *staticInterfaceName()
{ return "org.deepin.dde.KWayland1.Output"; }
public:
explicit __OutputManagement(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
~__OutputManagement();
public Q_SLOTS: // METHODS
inline QDBusPendingReply<> Apply(const QString &outputs)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(outputs);
return asyncCallWithArgumentList(QStringLiteral("Apply"), argumentList);
}
inline void ApplyQueued(const QString &outputs)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(outputs);
CallQueued(QStringLiteral("Apply"), argumentList);
}
inline QDBusPendingReply<QString> GetOutput(const QString &uuid)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(uuid);
return asyncCallWithArgumentList(QStringLiteral("GetOutput"), argumentList);
}
inline QDBusPendingReply<QString> ListOutput()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("ListOutput"), argumentList);
}
inline QDBusPendingReply<> WlSimulateKey(int state)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(state);
return asyncCallWithArgumentList(QStringLiteral("WlSimulateKey"), argumentList);
}
inline void WlSimulateKeyQueued(int state)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(state);
CallQueued(QStringLiteral("WlSimulateKey"), argumentList);
}
Q_SIGNALS: // SIGNALS
void OutputAdded(const QString &output);
void OutputChanged(const QString &output);
void OutputRemoved(const QString &output);
// begin property changed signals
public Q_SLOTS:
void CallQueued(const QString &callName, const QList<QVariant> &args);
private Q_SLOTS:
void onPendingCallFinished(QDBusPendingCallWatcher *w);
private:
__OutputManagementPrivate *d_ptr;
};
namespace com {
namespace deepin {
namespace dde {
namespace kwayland1 {
typedef ::__OutputManagement Output;
}
}
}
}
#endif

View File

@ -1,71 +0,0 @@
/*
* This file was generated by qdbusxml2cpp-fix version 0.8
* Command line was: qdbusxml2cpp-fix -c kwaylandmanager -p kwaylandmanager org.deepin.dde.KWayland1.WindowManager.xml
*
* qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
* before re-generating it.
*/
#include "dbuskwaylandwindowmanager.h"
/*
* Implementation of interface class __kwaylandmanager
*/
class __kwaylandmanagerPrivate
{
public:
__kwaylandmanagerPrivate() = default;
// begin member variables
public:
QMap<QString, QDBusPendingCallWatcher *> m_processingCalls;
QMap<QString, QList<QVariant>> m_waittingCalls;
};
__KwaylandManager::__KwaylandManager(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
: DBusExtendedAbstractInterface(service, path, staticInterfaceName(), connection, parent)
, d_ptr(new __kwaylandmanagerPrivate)
{
}
__KwaylandManager::~__KwaylandManager()
{
qDeleteAll(d_ptr->m_processingCalls.values());
delete d_ptr;
}
void __KwaylandManager::CallQueued(const QString &callName, const QList<QVariant> &args)
{
if (d_ptr->m_waittingCalls.contains(callName))
{
d_ptr->m_waittingCalls[callName] = args;
return;
}
if (d_ptr->m_processingCalls.contains(callName))
{
d_ptr->m_waittingCalls.insert(callName, args);
} else {
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(asyncCallWithArgumentList(callName, args));
connect(watcher, &QDBusPendingCallWatcher::finished, this, &__KwaylandManager::onPendingCallFinished);
d_ptr->m_processingCalls.insert(callName, watcher);
}
}
void __KwaylandManager::onPendingCallFinished(QDBusPendingCallWatcher *w)
{
w->deleteLater();
const auto callName = d_ptr->m_processingCalls.key(w);
Q_ASSERT(!callName.isEmpty());
if (callName.isEmpty())
return;
d_ptr->m_processingCalls.remove(callName);
if (!d_ptr->m_waittingCalls.contains(callName))
return;
const auto args = d_ptr->m_waittingCalls.take(callName);
CallQueued(callName, args);
}

View File

@ -1,94 +0,0 @@
/*
* This file was generated by qdbusxml2cpp-fix version 0.8
* Command line was: qdbusxml2cpp-fix -c kwaylandmanager -p kwaylandmanager org.deepin.dde.KWayland1.WindowManager.xml
*
* qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
*/
#ifndef KWAYLANDMANAGER_H
#define KWAYLANDMANAGER_H
#include <QtCore/QObject>
#include <QtCore/QByteArray>
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QVariant>
#include <DBusExtendedAbstractInterface>
#include <QtDBus/QtDBus>
/*
* Proxy class for interface org.deepin.dde.KWayland1.WindowManager
*/
class __kwaylandmanagerPrivate;
class __KwaylandManager : public DBusExtendedAbstractInterface
{
Q_OBJECT
public:
static inline const char *staticInterfaceName()
{ return "org.deepin.dde.KWayland1.WindowManager"; }
public:
explicit __KwaylandManager(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
~__KwaylandManager();
public Q_SLOTS: // METHODS
inline QDBusPendingReply<uint> ActiveWindow()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("ActiveWindow"), argumentList);
}
inline QDBusPendingReply<bool> IsShowingDesktop()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("IsShowingDesktop"), argumentList);
}
inline QDBusPendingReply<QVariantList> Windows()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("Windows"), argumentList);
}
Q_SIGNALS: // SIGNALS
void ActiveWindowChanged();
void WindowCreated(const QString &ObjPath);
void WindowRemove(const QString &ObjPath);
// begin property changed signals
public Q_SLOTS:
void CallQueued(const QString &callName, const QList<QVariant> &args);
private Q_SLOTS:
void onPendingCallFinished(QDBusPendingCallWatcher *w);
private:
__kwaylandmanagerPrivate *d_ptr;
};
namespace org {
namespace deepin {
namespace dde {
namespace kwayland1 {
typedef ::__KwaylandManager WindowManager;
}
}
}
}
#endif

View File

@ -1,129 +0,0 @@
/*
* This file was generated by qdbusxml2cpp-fix version 0.8
* Command line was: qdbusxml2cpp-fix -c Launcherd -p generated/org_deepin_dde_daemon_launcherd ../xml/org.deepin.dde.daemon.Launcherd.xml
*
* qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
* before re-generating it.
*/
#include "dbuslauncher.h"
/*
* Implementation of interface class __Launcherd
*/
class __LauncherdPrivate
{
public:
__LauncherdPrivate() = default;
// begin member variables
int DisplayMode;
bool Fullscreen;
public:
QMap<QString, QDBusPendingCallWatcher *> m_processingCalls;
QMap<QString, QList<QVariant>> m_waittingCalls;
};
LauncherBackEnd::LauncherBackEnd(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
: DBusExtendedAbstractInterface(service, path, staticInterfaceName(), connection, parent)
, d_ptr(new __LauncherdPrivate)
{
connect(this, &LauncherBackEnd::propertyChanged, this, &LauncherBackEnd::onPropertyChanged);
if (QMetaType::type("LauncherItemInfo") == QMetaType::UnknownType)
registerLauncherItemInfoMetaType();
if (QMetaType::type("LauncherItemInfoList") == QMetaType::UnknownType)
registerLauncherItemInfoListMetaType();
}
LauncherBackEnd::~LauncherBackEnd()
{
qDeleteAll(d_ptr->m_processingCalls.values());
delete d_ptr;
}
void LauncherBackEnd::onPropertyChanged(const QString &propName, const QVariant &value)
{
if (propName == QStringLiteral("DisplayMode"))
{
const int &DisplayMode = qvariant_cast<int>(value);
if (d_ptr->DisplayMode != DisplayMode)
{
d_ptr->DisplayMode = DisplayMode;
Q_EMIT DisplayModeChanged(d_ptr->DisplayMode);
}
return;
}
if (propName == QStringLiteral("Fullscreen"))
{
const bool &Fullscreen = qvariant_cast<bool>(value);
if (d_ptr->Fullscreen != Fullscreen)
{
d_ptr->Fullscreen = Fullscreen;
Q_EMIT FullscreenChanged(d_ptr->Fullscreen);
}
return;
}
qWarning() << "property not handle: " << propName;
return;
}
int LauncherBackEnd::displayMode()
{
return qvariant_cast<int>(internalPropGet("DisplayMode", &d_ptr->DisplayMode));
}
void LauncherBackEnd::setDisplayMode(int value)
{
internalPropSet("DisplayMode", QVariant::fromValue(value), &d_ptr->DisplayMode);
}
bool LauncherBackEnd::fullscreen()
{
return qvariant_cast<bool>(internalPropGet("Fullscreen", &d_ptr->Fullscreen));
}
void LauncherBackEnd::setFullscreen(bool value)
{
internalPropSet("Fullscreen", QVariant::fromValue(value), &d_ptr->Fullscreen);
}
void LauncherBackEnd::CallQueued(const QString &callName, const QList<QVariant> &args)
{
if (d_ptr->m_waittingCalls.contains(callName))
{
d_ptr->m_waittingCalls[callName] = args;
return;
}
if (d_ptr->m_processingCalls.contains(callName))
{
d_ptr->m_waittingCalls.insert(callName, args);
} else {
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(asyncCallWithArgumentList(callName, args));
connect(watcher, &QDBusPendingCallWatcher::finished, this, &LauncherBackEnd::onPendingCallFinished);
d_ptr->m_processingCalls.insert(callName, watcher);
}
}
void LauncherBackEnd::onPendingCallFinished(QDBusPendingCallWatcher *w)
{
w->deleteLater();
const auto callName = d_ptr->m_processingCalls.key(w);
Q_ASSERT(!callName.isEmpty());
if (callName.isEmpty())
return;
d_ptr->m_processingCalls.remove(callName);
if (!d_ptr->m_waittingCalls.contains(callName))
return;
const auto args = d_ptr->m_waittingCalls.take(callName);
CallQueued(callName, args);
}

View File

@ -1,235 +0,0 @@
/*
* This file was generated by qdbusxml2cpp-fix version 0.8
* Command line was: qdbusxml2cpp-fix -c Launcherd -p generated/com_deepin_dde_daemon_launcher1 ../xml/org.deepin.dde.daemon.Launcher1.xml
*
* qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
*/
#ifndef ORG_DEEPIN_DDE_DAEMON_LAUNCHER1_H
#define ORG_DEEPIN_DDE_DAEMON_LAUNCHER1_H
#include <QtCore/QObject>
#include <QtCore/QByteArray>
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QVariant>
#include <DBusExtendedAbstractInterface>
#include <QtDBus/QtDBus>
#include "types/launcheriteminfo.h"
#include "types/launcheriteminfolist.h"
/*
* Proxy class for interface org.deepin.dde.daemon.Launcher1
*/
class __LauncherdPrivate;
class LauncherBackEnd : public DBusExtendedAbstractInterface
{
Q_OBJECT
public:
static inline const char *staticInterfaceName()
{ return "org.deepin.dde.daemon.Launcher1"; }
public:
explicit LauncherBackEnd(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
~LauncherBackEnd();
Q_PROPERTY(int DisplayMode READ displayMode WRITE setDisplayMode NOTIFY DisplayModeChanged)
int displayMode();
void setDisplayMode(int value);
Q_PROPERTY(bool Fullscreen READ fullscreen WRITE setFullscreen NOTIFY FullscreenChanged)
bool fullscreen();
void setFullscreen(bool value);
public Q_SLOTS: // METHODS
inline QDBusPendingReply<LauncherItemInfoList> GetAllItemInfos()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("GetAllItemInfos"), argumentList);
}
inline QDBusPendingReply<QStringList> GetAllNewInstalledApps()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("GetAllNewInstalledApps"), argumentList);
}
inline QDBusPendingReply<bool> GetDisableScaling(const QString &id)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(id);
return asyncCallWithArgumentList(QStringLiteral("GetDisableScaling"), argumentList);
}
inline QDBusPendingReply<LauncherItemInfo> GetItemInfo(const QString &id)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(id);
return asyncCallWithArgumentList(QStringLiteral("GetItemInfo"), argumentList);
}
inline QDBusPendingReply<bool> GetUseProxy(const QString &id)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(id);
return asyncCallWithArgumentList(QStringLiteral("GetUseProxy"), argumentList);
}
inline QDBusPendingReply<bool> IsItemOnDesktop(const QString &id)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(id);
return asyncCallWithArgumentList(QStringLiteral("IsItemOnDesktop"), argumentList);
}
inline QDBusPendingReply<> MarkLaunched(const QString &id)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(id);
return asyncCallWithArgumentList(QStringLiteral("MarkLaunched"), argumentList);
}
inline void MarkLaunchedQueued(const QString &id)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(id);
CallQueued(QStringLiteral("MarkLaunched"), argumentList);
}
inline QDBusPendingReply<bool> RequestRemoveFromDesktop(const QString &id)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(id);
return asyncCallWithArgumentList(QStringLiteral("RequestRemoveFromDesktop"), argumentList);
}
inline QDBusPendingReply<bool> RequestSendToDesktop(const QString &id)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(id);
return asyncCallWithArgumentList(QStringLiteral("RequestSendToDesktop"), argumentList);
}
inline QDBusPendingReply<> RequestUninstall(const QString &id, bool purge)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(id) << QVariant::fromValue(purge);
return asyncCallWithArgumentList(QStringLiteral("RequestUninstall"), argumentList);
}
inline void RequestUninstallQueued(const QString &id, bool purge)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(id) << QVariant::fromValue(purge);
CallQueued(QStringLiteral("RequestUninstall"), argumentList);
}
inline QDBusPendingReply<> Search(const QString &key)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(key);
return asyncCallWithArgumentList(QStringLiteral("Search"), argumentList);
}
inline void SearchQueued(const QString &key)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(key);
CallQueued(QStringLiteral("Search"), argumentList);
}
inline QDBusPendingReply<> SetDisableScaling(const QString &id, bool value)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(id) << QVariant::fromValue(value);
return asyncCallWithArgumentList(QStringLiteral("SetDisableScaling"), argumentList);
}
inline void SetDisableScalingQueued(const QString &id, bool value)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(id) << QVariant::fromValue(value);
CallQueued(QStringLiteral("SetDisableScaling"), argumentList);
}
inline QDBusPendingReply<> SetUseProxy(const QString &id, bool value)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(id) << QVariant::fromValue(value);
return asyncCallWithArgumentList(QStringLiteral("SetUseProxy"), argumentList);
}
inline void SetUseProxyQueued(const QString &id, bool value)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(id) << QVariant::fromValue(value);
CallQueued(QStringLiteral("SetUseProxy"), argumentList);
}
Q_SIGNALS: // SIGNALS
void ItemChanged(const QString &status, LauncherItemInfo itemInfo, qlonglong categoryID);
void NewAppLaunched(const QString &appID);
void SearchDone(const QStringList &apps);
void UninstallFailed(const QString &appId, const QString &errMsg);
void UninstallSuccess(const QString &appID);
// begin property changed signals
void DisplayModeChanged(int value) const;
void FullscreenChanged(bool value) const;
public Q_SLOTS:
void CallQueued(const QString &callName, const QList<QVariant> &args);
private Q_SLOTS:
void onPendingCallFinished(QDBusPendingCallWatcher *w);
void onPropertyChanged(const QString &propName, const QVariant &value);
private:
__LauncherdPrivate *d_ptr;
};
namespace org {
namespace deepin {
namespace dde {
namespace daemon {
typedef ::LauncherBackEnd LauncherBackEnd;
}
}
}
}
#endif

View File

@ -1,96 +0,0 @@
/*
* This file was generated by qdbusxml2cpp-fix version 0.8
* Command line was: qdbusxml2cpp-fix -c Launcher -p generated/org_deepin_dde_launcher1 ../xml/org.deepin.dde.Launcher1.xml
*
* qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
* before re-generating it.
*/
#include "dbuslauncherfront.h"
/*
* Implementation of interface class __Launcher
*/
class __LauncherPrivate
{
public:
__LauncherPrivate() = default;
// begin member variables
bool Visible;
public:
QMap<QString, QDBusPendingCallWatcher *> m_processingCalls;
QMap<QString, QList<QVariant>> m_waittingCalls;
};
LauncherFront::LauncherFront(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
: DBusExtendedAbstractInterface(service, path, staticInterfaceName(), connection, parent)
, d_ptr(new __LauncherPrivate)
{
connect(this, &LauncherFront::propertyChanged, this, &LauncherFront::onPropertyChanged);
}
LauncherFront::~LauncherFront()
{
qDeleteAll(d_ptr->m_processingCalls.values());
delete d_ptr;
}
void LauncherFront::onPropertyChanged(const QString &propName, const QVariant &value)
{
if (propName == QStringLiteral("Visible"))
{
const bool &Visible = qvariant_cast<bool>(value);
if (d_ptr->Visible != Visible)
{
d_ptr->Visible = Visible;
Q_EMIT VisibleChanged(d_ptr->Visible);
}
return;
}
qWarning() << "property not handle: " << propName;
return;
}
bool LauncherFront::visible()
{
return qvariant_cast<bool>(internalPropGet("Visible", &d_ptr->Visible));
}
void LauncherFront::CallQueued(const QString &callName, const QList<QVariant> &args)
{
if (d_ptr->m_waittingCalls.contains(callName))
{
d_ptr->m_waittingCalls[callName] = args;
return;
}
if (d_ptr->m_processingCalls.contains(callName))
{
d_ptr->m_waittingCalls.insert(callName, args);
} else {
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(asyncCallWithArgumentList(callName, args));
connect(watcher, &QDBusPendingCallWatcher::finished, this, &LauncherFront::onPendingCallFinished);
d_ptr->m_processingCalls.insert(callName, watcher);
}
}
void LauncherFront::onPendingCallFinished(QDBusPendingCallWatcher *w)
{
w->deleteLater();
const auto callName = d_ptr->m_processingCalls.key(w);
Q_ASSERT(!callName.isEmpty());
if (callName.isEmpty())
return;
d_ptr->m_processingCalls.remove(callName);
if (!d_ptr->m_waittingCalls.contains(callName))
return;
const auto args = d_ptr->m_waittingCalls.take(callName);
CallQueued(callName, args);
}

View File

@ -1,169 +0,0 @@
/*
* This file was generated by qdbusxml2cpp-fix version 0.8
* Command line was: qdbusxml2cpp-fix -c Launcher -p generated/org_deepin_dde_launcher1 ../xml/org.deepin.dde.Launcher1.xml
*
* qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
*/
#ifndef ORG_DEEPIN_DDE_LAUNCHER1_H
#define ORG_DEEPIN_DDE_LAUNCHER1_H
#include <QtCore/QObject>
#include <QtCore/QByteArray>
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QVariant>
#include <DBusExtendedAbstractInterface>
#include <QtDBus/QtDBus>
/*
* Proxy class for interface org.deepin.dde.Launcher1
*/
class __LauncherPrivate;
class LauncherFront : public DBusExtendedAbstractInterface
{
Q_OBJECT
public:
static inline const char *staticInterfaceName()
{ return "org.deepin.dde.Launcher1"; }
public:
explicit LauncherFront(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
~LauncherFront();
Q_PROPERTY(bool Visible READ visible NOTIFY VisibleChanged)
bool visible();
public Q_SLOTS: // METHODS
inline QDBusPendingReply<> Exit()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("Exit"), argumentList);
}
inline void ExitQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("Exit"), argumentList);
}
inline QDBusPendingReply<> Hide()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("Hide"), argumentList);
}
inline void HideQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("Hide"), argumentList);
}
inline QDBusPendingReply<bool> IsVisible()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("IsVisible"), argumentList);
}
inline QDBusPendingReply<> Show()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("Show"), argumentList);
}
inline void ShowQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("Show"), argumentList);
}
inline QDBusPendingReply<> ShowByMode(qlonglong in0)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(in0);
return asyncCallWithArgumentList(QStringLiteral("ShowByMode"), argumentList);
}
inline void ShowByModeQueued(qlonglong in0)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(in0);
CallQueued(QStringLiteral("ShowByMode"), argumentList);
}
inline QDBusPendingReply<> Toggle()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("Toggle"), argumentList);
}
inline void ToggleQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("Toggle"), argumentList);
}
inline QDBusPendingReply<> UninstallApp(const QString &appKey)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(appKey);
return asyncCallWithArgumentList(QStringLiteral("UninstallApp"), argumentList);
}
inline void UninstallAppQueued(const QString &appKey)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(appKey);
CallQueued(QStringLiteral("UninstallApp"), argumentList);
}
Q_SIGNALS: // SIGNALS
void Closed();
void Shown();
void VisibleChanged(bool visible);
// begin property changed signals
//void VisibleChanged(bool value) const;
public Q_SLOTS:
void CallQueued(const QString &callName, const QList<QVariant> &args);
private Q_SLOTS:
void onPendingCallFinished(QDBusPendingCallWatcher *w);
void onPropertyChanged(const QString &propName, const QVariant &value);
private:
__LauncherPrivate *d_ptr;
};
namespace org {
namespace deepin {
namespace dde {
typedef ::LauncherFront LauncherFront;
}
}
}
#endif

View File

@ -1,73 +0,0 @@
/*
* This file was generated by qdbusxml2cpp-fix version 0.8
* Command line was: qdbusxml2cpp-fix -c Window -p generated/window ../xml/Window.xml
*
* qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
* before re-generating it.
*/
#include "dbusplasmawindow.h"
/*
* Implementation of interface class __Window
*/
class __WindowPrivate
{
public:
__WindowPrivate() = default;
// begin member variables
public:
QMap<QString, QDBusPendingCallWatcher *> m_processingCalls;
QMap<QString, QList<QVariant>> m_waittingCalls;
};
__PlasmaWindow::__PlasmaWindow(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
: DBusExtendedAbstractInterface(service, path, staticInterfaceName(), connection, parent)
, d_ptr(new __WindowPrivate)
{
if (QMetaType::type("DockRect") == QMetaType::UnknownType)
registerRectMetaType();
}
__PlasmaWindow::~__PlasmaWindow()
{
qDeleteAll(d_ptr->m_processingCalls.values());
delete d_ptr;
}
void __PlasmaWindow::CallQueued(const QString &callName, const QList<QVariant> &args)
{
if (d_ptr->m_waittingCalls.contains(callName))
{
d_ptr->m_waittingCalls[callName] = args;
return;
}
if (d_ptr->m_processingCalls.contains(callName))
{
d_ptr->m_waittingCalls.insert(callName, args);
} else {
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(asyncCallWithArgumentList(callName, args));
connect(watcher, &QDBusPendingCallWatcher::finished, this, &__PlasmaWindow::onPendingCallFinished);
d_ptr->m_processingCalls.insert(callName, watcher);
}
}
void __PlasmaWindow::onPendingCallFinished(QDBusPendingCallWatcher *w)
{
w->deleteLater();
const auto callName = d_ptr->m_processingCalls.key(w);
Q_ASSERT(!callName.isEmpty());
if (callName.isEmpty())
return;
d_ptr->m_processingCalls.remove(callName);
if (!d_ptr->m_waittingCalls.contains(callName))
return;
const auto args = d_ptr->m_waittingCalls.take(callName);
CallQueued(callName, args);
}

View File

@ -1,437 +0,0 @@
/*
* This file was generated by qdbusxml2cpp-fix version 0.8
* Command line was: qdbusxml2cpp-fix -c Window -p generated/window ../xml/Window.xml
*
* qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
*/
#ifndef WINDOW_H
#define WINDOW_H
#include <QtCore/QObject>
#include <QtCore/QByteArray>
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QVariant>
#include <DBusExtendedAbstractInterface>
#include <QtDBus/QtDBus>
#include "types/dockrect.h"
/*
* Proxy class for interface org.deepin.dde.KWayland1.PlasmaWindow
*/
class __WindowPrivate;
class __PlasmaWindow : public DBusExtendedAbstractInterface
{
Q_OBJECT
public:
static inline const char *staticInterfaceName()
{ return "org.deepin.dde.KWayland1.PlasmaWindow"; }
public:
explicit __PlasmaWindow(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
~__PlasmaWindow();
public Q_SLOTS: // METHODS
inline QDBusPendingReply<QString> AppId()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("AppId"), argumentList);
}
inline QDBusPendingReply<DockRect> Geometry()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("Geometry"), argumentList);
}
inline QDBusPendingReply<QString> Icon()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("Icon"), argumentList);
}
inline QDBusPendingReply<uint> InternalId()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("InternalId"), argumentList);
}
inline QDBusPendingReply<bool> IsActive()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("IsActive"), argumentList);
}
inline QDBusPendingReply<bool> IsCloseable()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("IsCloseable"), argumentList);
}
inline QDBusPendingReply<bool> IsDemandingAttention()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("IsDemandingAttention"), argumentList);
}
inline QDBusPendingReply<bool> IsFullscreen()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("IsFullscreen"), argumentList);
}
inline QDBusPendingReply<bool> IsFullscreenable()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("IsFullscreenable"), argumentList);
}
inline QDBusPendingReply<bool> IsKeepAbove()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("IsKeepAbove"), argumentList);
}
inline QDBusPendingReply<bool> IsMaximizeable()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("IsMaximizeable"), argumentList);
}
inline QDBusPendingReply<bool> IsMaximized()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("IsMaximized"), argumentList);
}
inline QDBusPendingReply<bool> IsMinimizeable()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("IsMinimizeable"), argumentList);
}
inline QDBusPendingReply<bool> IsMinimized()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("IsMinimized"), argumentList);
}
inline QDBusPendingReply<bool> IsMovable()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("IsMovable"), argumentList);
}
inline QDBusPendingReply<bool> IsOnAllDesktops()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("IsOnAllDesktops"), argumentList);
}
inline QDBusPendingReply<bool> IsResizable()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("IsResizable"), argumentList);
}
inline QDBusPendingReply<bool> IsShadeable()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("IsShadeable"), argumentList);
}
inline QDBusPendingReply<bool> IsShaded()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("IsShaded"), argumentList);
}
inline QDBusPendingReply<bool> IsValid()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("IsValid"), argumentList);
}
inline QDBusPendingReply<bool> IsVirtualDesktopChangeable()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("IsVirtualDesktopChangeable"), argumentList);
}
inline QDBusPendingReply<uint> Pid()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("Pid"), argumentList);
}
inline QDBusPendingReply<> RequestActivate()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("RequestActivate"), argumentList);
}
inline void RequestActivateQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("RequestActivate"), argumentList);
}
inline QDBusPendingReply<> RequestClose()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("RequestClose"), argumentList);
}
inline void RequestCloseQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("RequestClose"), argumentList);
}
inline QDBusPendingReply<> RequestEnterNewVirtualDesktop()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("RequestEnterNewVirtualDesktop"), argumentList);
}
inline void RequestEnterNewVirtualDesktopQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("RequestEnterNewVirtualDesktop"), argumentList);
}
inline QDBusPendingReply<> RequestEnterVirtualDesktop(const QString &argin0)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(argin0);
return asyncCallWithArgumentList(QStringLiteral("RequestEnterVirtualDesktop"), argumentList);
}
inline void RequestEnterVirtualDesktopQueued(const QString &argin0)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(argin0);
CallQueued(QStringLiteral("RequestEnterVirtualDesktop"), argumentList);
}
inline QDBusPendingReply<> RequestLeaveVirtualDesktop(const QString &argin0)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(argin0);
return asyncCallWithArgumentList(QStringLiteral("RequestLeaveVirtualDesktop"), argumentList);
}
inline void RequestLeaveVirtualDesktopQueued(const QString &argin0)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(argin0);
CallQueued(QStringLiteral("RequestLeaveVirtualDesktop"), argumentList);
}
inline QDBusPendingReply<> RequestMove()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("RequestMove"), argumentList);
}
inline void RequestMoveQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("RequestMove"), argumentList);
}
inline QDBusPendingReply<> RequestResize()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("RequestResize"), argumentList);
}
inline void RequestResizeQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("RequestResize"), argumentList);
}
inline QDBusPendingReply<> RequestToggleKeepAbove()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("RequestToggleKeepAbove"), argumentList);
}
inline void RequestToggleKeepAboveQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("RequestToggleKeepAbove"), argumentList);
}
inline QDBusPendingReply<> RequestToggleKeepBelow()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("RequestToggleKeepBelow"), argumentList);
}
inline void RequestToggleKeepBelowQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("RequestToggleKeepBelow"), argumentList);
}
inline QDBusPendingReply<> RequestToggleMaximized()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("RequestToggleMaximized"), argumentList);
}
inline void RequestToggleMaximizedQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("RequestToggleMaximized"), argumentList);
}
inline QDBusPendingReply<> RequestToggleMinimized()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("RequestToggleMinimized"), argumentList);
}
inline void RequestToggleMinimizedQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("RequestToggleMinimized"), argumentList);
}
inline QDBusPendingReply<> RequestToggleShaded()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("RequestToggleShaded"), argumentList);
}
inline void RequestToggleShadedQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("RequestToggleShaded"), argumentList);
}
inline QDBusPendingReply<> RequestVirtualDesktop(uint argin0)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(argin0);
return asyncCallWithArgumentList(QStringLiteral("RequestVirtualDesktop"), argumentList);
}
inline void RequestVirtualDesktopQueued(uint argin0)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(argin0);
CallQueued(QStringLiteral("RequestVirtualDesktop"), argumentList);
}
inline QDBusPendingReply<bool> SkipSwitcher()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("SkipSwitcher"), argumentList);
}
inline QDBusPendingReply<bool> SkipTaskbar()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("SkipTaskbar"), argumentList);
}
inline QDBusPendingReply<QString> Title()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("Title"), argumentList);
}
inline QDBusPendingReply<uint> VirtualDesktop()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("VirtualDesktop"), argumentList);
}
inline QDBusPendingReply<uint> WindowId()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("WindowId"), argumentList);
}
inline QDBusPendingReply<QByteArray> Uuid()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("uuid"), argumentList);;
}
Q_SIGNALS: // SIGNALS
void ActiveChanged();
void AppIdChanged();
void CloseableChanged();
void DemandsAttentionChanged();
void FullscreenChanged();
void FullscreenableChanged();
void GeometryChanged();
void IconChanged();
void KeepAboveChanged();
void KeepBelowChanged();
void MaximizeableChanged();
void MaximizedChanged();
void MinimizeableChanged();
void MinimizedChanged();
void MovableChanged();
void OnAllDesktopsChanged();
void ParentWindowChanged();
void ResizableChanged();
void ShadeableChanged();
void ShadedChanged();
void SkipSwitcherChanged();
void SkipTaskbarChanged();
void TitleChanged();
void Unmapped();
void VirtualDesktopChangeableChanged();
void VirtualDesktopChanged();
void WindowIdChanged();
// begin property changed signals
public Q_SLOTS:
void CallQueued(const QString &callName, const QList<QVariant> &args);
private Q_SLOTS:
void onPendingCallFinished(QDBusPendingCallWatcher *w);
private:
__WindowPrivate *d_ptr;
};
namespace org {
namespace deepin {
namespace dde {
namespace kwayland1 {
typedef ::__PlasmaWindow PlasmaWindow;
}
}
}
}
#endif

View File

@ -1,209 +0,0 @@
/*
* This file was generated by qdbusxml2cpp-fix version 0.8
* Command line was: qdbusxml2cpp-fix -c wm -p generated/com_deepin_wm ../xml/com.deepin.wm.xml
*
* qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
* before re-generating it.
*/
#include "dbuswm.h"
/*
* Implementation of interface class __wm
*/
class __wmPrivate
{
public:
__wmPrivate() = default;
// begin member variables
bool compositingAllowSwitch;
bool compositingEnabled;
bool compositingPossible;
int cursorSize;
QString cursorTheme;
bool zoneEnabled;
public:
QMap<QString, QDBusPendingCallWatcher *> m_processingCalls;
QMap<QString, QList<QVariant>> m_waittingCalls;
};
__wm::__wm(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
: DBusExtendedAbstractInterface(service, path, staticInterfaceName(), connection, parent)
, d_ptr(new __wmPrivate)
{
connect(this, &__wm::propertyChanged, this, &__wm::onPropertyChanged);
if (QMetaType::type("QList<uint>") == QMetaType::UnknownType) {
qRegisterMetaType< QList<uint> >("QList<uint>");
qDBusRegisterMetaType< QList<uint> >();
}
}
__wm::~__wm()
{
qDeleteAll(d_ptr->m_processingCalls.values());
delete d_ptr;
}
void __wm::onPropertyChanged(const QString &propName, const QVariant &value)
{
if (propName == QStringLiteral("compositingAllowSwitch"))
{
const bool &compositingAllowSwitch = qvariant_cast<bool>(value);
if (d_ptr->compositingAllowSwitch != compositingAllowSwitch)
{
d_ptr->compositingAllowSwitch = compositingAllowSwitch;
Q_EMIT CompositingAllowSwitchChanged(d_ptr->compositingAllowSwitch);
}
return;
}
if (propName == QStringLiteral("compositingEnabled"))
{
const bool &compositingEnabled = qvariant_cast<bool>(value);
if (d_ptr->compositingEnabled != compositingEnabled)
{
d_ptr->compositingEnabled = compositingEnabled;
Q_EMIT CompositingEnabledChanged(d_ptr->compositingEnabled);
}
return;
}
if (propName == QStringLiteral("compositingPossible"))
{
const bool &compositingPossible = qvariant_cast<bool>(value);
if (d_ptr->compositingPossible != compositingPossible)
{
d_ptr->compositingPossible = compositingPossible;
Q_EMIT CompositingPossibleChanged(d_ptr->compositingPossible);
}
return;
}
if (propName == QStringLiteral("cursorSize"))
{
const int &cursorSize = qvariant_cast<int>(value);
if (d_ptr->cursorSize != cursorSize)
{
d_ptr->cursorSize = cursorSize;
Q_EMIT CursorSizeChanged(d_ptr->cursorSize);
}
return;
}
if (propName == QStringLiteral("cursorTheme"))
{
const QString &cursorTheme = qvariant_cast<QString>(value);
if (d_ptr->cursorTheme != cursorTheme)
{
d_ptr->cursorTheme = cursorTheme;
Q_EMIT CursorThemeChanged(d_ptr->cursorTheme);
}
return;
}
if (propName == QStringLiteral("zoneEnabled"))
{
const bool &zoneEnabled = qvariant_cast<bool>(value);
if (d_ptr->zoneEnabled != zoneEnabled)
{
d_ptr->zoneEnabled = zoneEnabled;
Q_EMIT ZoneEnabledChanged(d_ptr->zoneEnabled);
}
return;
}
qWarning() << "property not handle: " << propName;
return;
}
bool __wm::compositingAllowSwitch()
{
return qvariant_cast<bool>(internalPropGet("compositingAllowSwitch", &d_ptr->compositingAllowSwitch));
}
bool __wm::compositingEnabled()
{
return qvariant_cast<bool>(internalPropGet("compositingEnabled", &d_ptr->compositingEnabled));
}
void __wm::setCompositingEnabled(bool value)
{
internalPropSet("compositingEnabled", QVariant::fromValue(value), &d_ptr->compositingEnabled);
}
bool __wm::compositingPossible()
{
return qvariant_cast<bool>(internalPropGet("compositingPossible", &d_ptr->compositingPossible));
}
int __wm::cursorSize()
{
return qvariant_cast<int>(internalPropGet("cursorSize", &d_ptr->cursorSize));
}
void __wm::setCursorSize(int value)
{
internalPropSet("cursorSize", QVariant::fromValue(value), &d_ptr->cursorSize);
}
QString __wm::cursorTheme()
{
return qvariant_cast<QString>(internalPropGet("cursorTheme", &d_ptr->cursorTheme));
}
void __wm::setCursorTheme(const QString &value)
{
internalPropSet("cursorTheme", QVariant::fromValue(value), &d_ptr->cursorTheme);
}
bool __wm::zoneEnabled()
{
return qvariant_cast<bool>(internalPropGet("zoneEnabled", &d_ptr->zoneEnabled));
}
void __wm::setZoneEnabled(bool value)
{
internalPropSet("zoneEnabled", QVariant::fromValue(value), &d_ptr->zoneEnabled);
}
void __wm::CallQueued(const QString &callName, const QList<QVariant> &args)
{
if (d_ptr->m_waittingCalls.contains(callName))
{
d_ptr->m_waittingCalls[callName] = args;
return;
}
if (d_ptr->m_processingCalls.contains(callName))
{
d_ptr->m_waittingCalls.insert(callName, args);
} else {
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(asyncCallWithArgumentList(callName, args));
connect(watcher, &QDBusPendingCallWatcher::finished, this, &__wm::onPendingCallFinished);
d_ptr->m_processingCalls.insert(callName, watcher);
}
}
void __wm::onPendingCallFinished(QDBusPendingCallWatcher *w)
{
w->deleteLater();
const auto callName = d_ptr->m_processingCalls.key(w);
Q_ASSERT(!callName.isEmpty());
if (callName.isEmpty())
return;
d_ptr->m_processingCalls.remove(callName);
if (!d_ptr->m_waittingCalls.contains(callName))
return;
const auto args = d_ptr->m_waittingCalls.take(callName);
CallQueued(callName, args);
}

View File

@ -1,708 +0,0 @@
/*
* This file was generated by qdbusxml2cpp-fix version 0.8
* Command line was: qdbusxml2cpp-fix -c wm -p generated/com_deepin_wm ../xml/com.deepin.wm.xml
*
* qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
*/
#ifndef COM_DEEPIN_WM_H
#define COM_DEEPIN_WM_H
#include <QtCore/QObject>
#include <QtCore/QByteArray>
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QVariant>
#include <DBusExtendedAbstractInterface>
#include <QtDBus/QtDBus>
/*
* Proxy class for interface com.deepin.wm
*/
class __wmPrivate;
class __wm : public DBusExtendedAbstractInterface
{
Q_OBJECT
public:
static inline const char *staticInterfaceName()
{ return "com.deepin.wm"; }
public:
explicit __wm(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
~__wm();
Q_PROPERTY(bool compositingAllowSwitch READ compositingAllowSwitch NOTIFY CompositingAllowSwitchChanged)
bool compositingAllowSwitch();
Q_PROPERTY(bool compositingEnabled READ compositingEnabled WRITE setCompositingEnabled NOTIFY CompositingEnabledChanged)
bool compositingEnabled();
void setCompositingEnabled(bool value);
Q_PROPERTY(bool compositingPossible READ compositingPossible NOTIFY CompositingPossibleChanged)
bool compositingPossible();
Q_PROPERTY(int cursorSize READ cursorSize WRITE setCursorSize NOTIFY CursorSizeChanged)
int cursorSize();
void setCursorSize(int value);
Q_PROPERTY(QString cursorTheme READ cursorTheme WRITE setCursorTheme NOTIFY CursorThemeChanged)
QString cursorTheme();
void setCursorTheme(const QString &value);
Q_PROPERTY(bool zoneEnabled READ zoneEnabled WRITE setZoneEnabled NOTIFY ZoneEnabledChanged)
bool zoneEnabled();
void setZoneEnabled(bool value);
public Q_SLOTS: // METHODS
inline QDBusPendingReply<> BeginToMoveActiveWindow()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("BeginToMoveActiveWindow"), argumentList);
}
inline void BeginToMoveActiveWindowQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("BeginToMoveActiveWindow"), argumentList);
}
inline QDBusPendingReply<> CancelPreviewWindow()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("CancelPreviewWindow"), argumentList);
}
inline void CancelPreviewWindowQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("CancelPreviewWindow"), argumentList);
}
inline QDBusPendingReply<> ChangeCurrentWorkspaceBackground(const QString &uri)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(uri);
return asyncCallWithArgumentList(QStringLiteral("ChangeCurrentWorkspaceBackground"), argumentList);
}
inline void ChangeCurrentWorkspaceBackgroundQueued(const QString &uri)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(uri);
CallQueued(QStringLiteral("ChangeCurrentWorkspaceBackground"), argumentList);
}
inline QDBusPendingReply<> ClearMoveStatus()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("ClearMoveStatus"), argumentList);
}
inline void ClearMoveStatusQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("ClearMoveStatus"), argumentList);
}
inline QDBusPendingReply<> EnableZoneDetected(bool enabled)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(enabled);
return asyncCallWithArgumentList(QStringLiteral("EnableZoneDetected"), argumentList);
}
inline void EnableZoneDetectedQueued(bool enabled)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(enabled);
CallQueued(QStringLiteral("EnableZoneDetected"), argumentList);
}
inline QDBusPendingReply<QStringList> GetAccel(const QString &id)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(id);
return asyncCallWithArgumentList(QStringLiteral("GetAccel"), argumentList);
}
inline QDBusPendingReply<QString> GetAllAccels()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("GetAllAccels"), argumentList);
}
inline QDBusPendingReply<bool> GetCurrentDesktopStatus()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("GetCurrentDesktopStatus"), argumentList);
}
inline QDBusPendingReply<int> GetCurrentWorkspace()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("GetCurrentWorkspace"), argumentList);
}
inline QDBusPendingReply<QString> GetCurrentWorkspaceBackground()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("GetCurrentWorkspaceBackground"), argumentList);
}
inline QDBusPendingReply<QString> GetCurrentWorkspaceBackgroundForMonitor(const QString &strMonitorName)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(strMonitorName);
return asyncCallWithArgumentList(QStringLiteral("GetCurrentWorkspaceBackgroundForMonitor"), argumentList);
}
inline QDBusPendingReply<QStringList> GetDefaultAccel(const QString &id)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(id);
return asyncCallWithArgumentList(QStringLiteral("GetDefaultAccel"), argumentList);
}
inline QDBusPendingReply<bool> GetIsShowDesktop()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("GetIsShowDesktop"), argumentList);
}
inline QDBusPendingReply<bool> GetMultiTaskingStatus()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("GetMultiTaskingStatus"), argumentList);
}
inline QDBusPendingReply<double> GetTouchBorderInterval()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("GetTouchBorderInterval"), argumentList);
}
inline QDBusPendingReply<QString> GetWorkspaceBackground(int index)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(index);
return asyncCallWithArgumentList(QStringLiteral("GetWorkspaceBackground"), argumentList);
}
inline QDBusPendingReply<QString> GetWorkspaceBackgroundForMonitor(int index, const QString &strMonitorName)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(index) << QVariant::fromValue(strMonitorName);
return asyncCallWithArgumentList(QStringLiteral("GetWorkspaceBackgroundForMonitor"), argumentList);
}
inline QDBusPendingReply<> MinimizeActiveWindow()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("MinimizeActiveWindow"), argumentList);
}
inline void MinimizeActiveWindowQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("MinimizeActiveWindow"), argumentList);
}
inline QDBusPendingReply<> NextWorkspace()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("NextWorkspace"), argumentList);
}
inline void NextWorkspaceQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("NextWorkspace"), argumentList);
}
inline QDBusPendingReply<> PerformAction(int type)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(type);
return asyncCallWithArgumentList(QStringLiteral("PerformAction"), argumentList);
}
inline void PerformActionQueued(int type)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(type);
CallQueued(QStringLiteral("PerformAction"), argumentList);
}
inline QDBusPendingReply<> PresentWindows(const QList<uint> &xids)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(xids);
return asyncCallWithArgumentList(QStringLiteral("PresentWindows"), argumentList);
}
inline void PresentWindowsQueued(const QList<uint> &xids)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(xids);
CallQueued(QStringLiteral("PresentWindows"), argumentList);
}
inline QDBusPendingReply<> PreviewWindow(uint xid)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(xid);
return asyncCallWithArgumentList(QStringLiteral("PreviewWindow"), argumentList);
}
inline void PreviewWindowQueued(uint xid)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(xid);
CallQueued(QStringLiteral("PreviewWindow"), argumentList);
}
inline QDBusPendingReply<> PreviousWorkspace()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("PreviousWorkspace"), argumentList);
}
inline void PreviousWorkspaceQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("PreviousWorkspace"), argumentList);
}
inline QDBusPendingReply<> RemoveAccel(const QString &id)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(id);
return asyncCallWithArgumentList(QStringLiteral("RemoveAccel"), argumentList);
}
inline void RemoveAccelQueued(const QString &id)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(id);
CallQueued(QStringLiteral("RemoveAccel"), argumentList);
}
inline QDBusPendingReply<bool> SetAccel(const QString &data)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(data);
return asyncCallWithArgumentList(QStringLiteral("SetAccel"), argumentList);
}
inline QDBusPendingReply<> SetCurrentWorkspace(int index)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(index);
return asyncCallWithArgumentList(QStringLiteral("SetCurrentWorkspace"), argumentList);
}
inline void SetCurrentWorkspaceQueued(int index)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(index);
CallQueued(QStringLiteral("SetCurrentWorkspace"), argumentList);
}
inline QDBusPendingReply<> SetCurrentWorkspaceBackground(const QString &uri)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(uri);
return asyncCallWithArgumentList(QStringLiteral("SetCurrentWorkspaceBackground"), argumentList);
}
inline void SetCurrentWorkspaceBackgroundQueued(const QString &uri)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(uri);
CallQueued(QStringLiteral("SetCurrentWorkspaceBackground"), argumentList);
}
inline QDBusPendingReply<> SetCurrentWorkspaceBackgroundForMonitor(const QString &uri, const QString &strMonitorName)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(uri) << QVariant::fromValue(strMonitorName);
return asyncCallWithArgumentList(QStringLiteral("SetCurrentWorkspaceBackgroundForMonitor"), argumentList);
}
inline void SetCurrentWorkspaceBackgroundForMonitorQueued(const QString &uri, const QString &strMonitorName)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(uri) << QVariant::fromValue(strMonitorName);
CallQueued(QStringLiteral("SetCurrentWorkspaceBackgroundForMonitor"), argumentList);
}
inline QDBusPendingReply<> SetDecorationDeepinTheme(const QString &deepinThemeName)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(deepinThemeName);
return asyncCallWithArgumentList(QStringLiteral("SetDecorationDeepinTheme"), argumentList);
}
inline void SetDecorationDeepinThemeQueued(const QString &deepinThemeName)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(deepinThemeName);
CallQueued(QStringLiteral("SetDecorationDeepinTheme"), argumentList);
}
inline QDBusPendingReply<> SetDecorationTheme(const QString &themeType, const QString &themeName)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(themeType) << QVariant::fromValue(themeName);
return asyncCallWithArgumentList(QStringLiteral("SetDecorationTheme"), argumentList);
}
inline void SetDecorationThemeQueued(const QString &themeType, const QString &themeName)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(themeType) << QVariant::fromValue(themeName);
CallQueued(QStringLiteral("SetDecorationTheme"), argumentList);
}
inline QDBusPendingReply<> SetMultiTaskingStatus(bool isActive)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(isActive);
return asyncCallWithArgumentList(QStringLiteral("SetMultiTaskingStatus"), argumentList);
}
inline void SetMultiTaskingStatusQueued(bool isActive)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(isActive);
CallQueued(QStringLiteral("SetMultiTaskingStatus"), argumentList);
}
inline QDBusPendingReply<> SetShowDesktop(bool isShowDesktop)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(isShowDesktop);
return asyncCallWithArgumentList(QStringLiteral("SetShowDesktop"), argumentList);
}
inline void SetShowDesktopQueued(bool isShowDesktop)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(isShowDesktop);
CallQueued(QStringLiteral("SetShowDesktop"), argumentList);
}
inline QDBusPendingReply<> SetTouchBorderInterval(double interval)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(interval);
return asyncCallWithArgumentList(QStringLiteral("SetTouchBorderInterval"), argumentList);
}
inline void SetTouchBorderIntervalQueued(double interval)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(interval);
CallQueued(QStringLiteral("SetTouchBorderInterval"), argumentList);
}
inline QDBusPendingReply<> SetTransientBackground(const QString &in0)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(in0);
return asyncCallWithArgumentList(QStringLiteral("SetTransientBackground"), argumentList);
}
inline void SetTransientBackgroundQueued(const QString &in0)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(in0);
CallQueued(QStringLiteral("SetTransientBackground"), argumentList);
}
inline QDBusPendingReply<> SetTransientBackgroundForMonitor(const QString &uri, const QString &strMonitorName)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(uri) << QVariant::fromValue(strMonitorName);
return asyncCallWithArgumentList(QStringLiteral("SetTransientBackgroundForMonitor"), argumentList);
}
inline void SetTransientBackgroundForMonitorQueued(const QString &uri, const QString &strMonitorName)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(uri) << QVariant::fromValue(strMonitorName);
CallQueued(QStringLiteral("SetTransientBackgroundForMonitor"), argumentList);
}
inline QDBusPendingReply<> SetWorkspaceBackground(int index, const QString &uri)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(index) << QVariant::fromValue(uri);
return asyncCallWithArgumentList(QStringLiteral("SetWorkspaceBackground"), argumentList);
}
inline void SetWorkspaceBackgroundQueued(int index, const QString &uri)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(index) << QVariant::fromValue(uri);
CallQueued(QStringLiteral("SetWorkspaceBackground"), argumentList);
}
inline QDBusPendingReply<> SetWorkspaceBackgroundForMonitor(int index, const QString &strMonitorName, const QString &uri)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(index) << QVariant::fromValue(strMonitorName) << QVariant::fromValue(uri);
return asyncCallWithArgumentList(QStringLiteral("SetWorkspaceBackgroundForMonitor"), argumentList);
}
inline void SetWorkspaceBackgroundForMonitorQueued(int index, const QString &strMonitorName, const QString &uri)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(index) << QVariant::fromValue(strMonitorName) << QVariant::fromValue(uri);
CallQueued(QStringLiteral("SetWorkspaceBackgroundForMonitor"), argumentList);
}
inline QDBusPendingReply<> ShowAllWindow()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("ShowAllWindow"), argumentList);
}
inline void ShowAllWindowQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("ShowAllWindow"), argumentList);
}
inline QDBusPendingReply<> ShowWindow()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("ShowWindow"), argumentList);
}
inline void ShowWindowQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("ShowWindow"), argumentList);
}
inline QDBusPendingReply<> ShowWorkspace()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("ShowWorkspace"), argumentList);
}
inline void ShowWorkspaceQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("ShowWorkspace"), argumentList);
}
inline QDBusPendingReply<> SwitchApplication(bool backward)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(backward);
return asyncCallWithArgumentList(QStringLiteral("SwitchApplication"), argumentList);
}
inline void SwitchApplicationQueued(bool backward)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(backward);
CallQueued(QStringLiteral("SwitchApplication"), argumentList);
}
inline QDBusPendingReply<> SwitchToWorkspace(bool backward)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(backward);
return asyncCallWithArgumentList(QStringLiteral("SwitchToWorkspace"), argumentList);
}
inline void SwitchToWorkspaceQueued(bool backward)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(backward);
CallQueued(QStringLiteral("SwitchToWorkspace"), argumentList);
}
inline QDBusPendingReply<> TileActiveWindow(uint side)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(side);
return asyncCallWithArgumentList(QStringLiteral("TileActiveWindow"), argumentList);
}
inline void TileActiveWindowQueued(uint side)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(side);
CallQueued(QStringLiteral("TileActiveWindow"), argumentList);
}
inline QDBusPendingReply<> ToggleActiveWindowMaximize()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("ToggleActiveWindowMaximize"), argumentList);
}
inline void ToggleActiveWindowMaximizeQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("ToggleActiveWindowMaximize"), argumentList);
}
inline QDBusPendingReply<> TouchToMove(int x, int y)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(x) << QVariant::fromValue(y);
return asyncCallWithArgumentList(QStringLiteral("TouchToMove"), argumentList);
}
inline void TouchToMoveQueued(int x, int y)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(x) << QVariant::fromValue(y);
CallQueued(QStringLiteral("TouchToMove"), argumentList);
}
inline QDBusPendingReply<int> WorkspaceCount()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("WorkspaceCount"), argumentList);
}
Q_SIGNALS: // SIGNALS
void WorkspaceBackgroundChanged(int index, const QString &newUri);
void WorkspaceBackgroundChangedForMonitor(int index, const QString &strMonitorName, const QString &uri);
void WorkspaceSwitched(int from, int to);
void compositingEnabledChanged(bool enabled);
void wmCompositingEnabledChanged(bool enabled);
void workspaceCountChanged(int count);
// begin property changed signals
void CompositingAllowSwitchChanged(bool value) const;
void CompositingEnabledChanged(bool value) const;
void CompositingPossibleChanged(bool value) const;
void CursorSizeChanged(int value) const;
void CursorThemeChanged(const QString & value) const;
void ZoneEnabledChanged(bool value) const;
public Q_SLOTS:
void CallQueued(const QString &callName, const QList<QVariant> &args);
private Q_SLOTS:
void onPendingCallFinished(QDBusPendingCallWatcher *w);
void onPropertyChanged(const QString &propName, const QVariant &value);
private:
__wmPrivate *d_ptr;
};
namespace com {
namespace deepin {
typedef ::__wm WM;
}
}
#endif

View File

@ -1,71 +0,0 @@
/*
* This file was generated by qdbusxml2cpp-fix version 0.8
* Command line was: qdbusxml2cpp-fix -c WMSwitcher -p generated/org_deepin_dde_wmswitcher1 ../xml/org.deepin.dde.WMSwitcher1.xml
*
* qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
* before re-generating it.
*/
#include "dbuswmswitcher.h"
/*
* Implementation of interface class __WMSwitcher
*/
class __WMSwitcherPrivate
{
public:
__WMSwitcherPrivate() = default;
// begin member variables
public:
QMap<QString, QDBusPendingCallWatcher *> m_processingCalls;
QMap<QString, QList<QVariant>> m_waittingCalls;
};
__WMSwitcher::__WMSwitcher(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
: DBusExtendedAbstractInterface(service, path, staticInterfaceName(), connection, parent)
, d_ptr(new __WMSwitcherPrivate)
{
}
__WMSwitcher::~__WMSwitcher()
{
qDeleteAll(d_ptr->m_processingCalls.values());
delete d_ptr;
}
void __WMSwitcher::CallQueued(const QString &callName, const QList<QVariant> &args)
{
if (d_ptr->m_waittingCalls.contains(callName))
{
d_ptr->m_waittingCalls[callName] = args;
return;
}
if (d_ptr->m_processingCalls.contains(callName))
{
d_ptr->m_waittingCalls.insert(callName, args);
} else {
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(asyncCallWithArgumentList(callName, args));
connect(watcher, &QDBusPendingCallWatcher::finished, this, &__WMSwitcher::onPendingCallFinished);
d_ptr->m_processingCalls.insert(callName, watcher);
}
}
void __WMSwitcher::onPendingCallFinished(QDBusPendingCallWatcher *w)
{
w->deleteLater();
const auto callName = d_ptr->m_processingCalls.key(w);
Q_ASSERT(!callName.isEmpty());
if (callName.isEmpty())
return;
d_ptr->m_processingCalls.remove(callName);
if (!d_ptr->m_waittingCalls.contains(callName))
return;
const auto args = d_ptr->m_waittingCalls.take(callName);
CallQueued(callName, args);
}

View File

@ -1,124 +0,0 @@
/*
* This file was generated by qdbusxml2cpp-fix version 0.8
* Command line was: qdbusxml2cpp-fix -c WMSwitcher -p generated/org_deepin_dde_wmswitcher1 ../xml/org.deepin.dde.WMSwitcher1.xml
*
* qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
*/
#ifndef ORG_DEEPIN_WMSWITCHER1_H
#define ORG_DEEPIN_WMSWITCHER1_H
#include <QtCore/QObject>
#include <QtCore/QByteArray>
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QVariant>
#include <DBusExtendedAbstractInterface>
#include <QtDBus/QtDBus>
/*
* Proxy class for interface org.deepin.dde.WMSwitcher1
*/
class __WMSwitcherPrivate;
class __WMSwitcher : public DBusExtendedAbstractInterface
{
Q_OBJECT
public:
static inline const char *staticInterfaceName()
{ return "org.deepin.dde.WMSwitcher1"; }
public:
explicit __WMSwitcher(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
~__WMSwitcher();
public Q_SLOTS: // METHODS
inline QDBusPendingReply<bool> AllowSwitch()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("AllowSwitch"), argumentList);
}
inline QDBusPendingReply<QString> CurrentWM()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("CurrentWM"), argumentList);
}
inline QDBusPendingReply<> RequestSwitchWM()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("RequestSwitchWM"), argumentList);
}
inline void RequestSwitchWMQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("RequestSwitchWM"), argumentList);
}
inline QDBusPendingReply<> RestartWM()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("RestartWM"), argumentList);
}
inline void RestartWMQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("RestartWM"), argumentList);
}
inline QDBusPendingReply<> Start2DWM()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("Start2DWM"), argumentList);
}
inline void Start2DWMQueued()
{
QList<QVariant> argumentList;
CallQueued(QStringLiteral("Start2DWM"), argumentList);
}
Q_SIGNALS: // SIGNALS
void WMChanged(const QString &in0);
// begin property changed signals
public Q_SLOTS:
void CallQueued(const QString &callName, const QList<QVariant> &args);
private Q_SLOTS:
void onPendingCallFinished(QDBusPendingCallWatcher *w);
private:
__WMSwitcherPrivate *d_ptr;
};
namespace org {
namespace deepin {
namespace dde {
typedef ::__WMSwitcher WMSwitcher1;
}
}
}
#endif

View File

@ -1,73 +0,0 @@
/*
* This file was generated by qdbusxml2cpp-fix version 0.8
* Command line was: qdbusxml2cpp-fix -c org_deepin_api_XEventMonitor -p /home/donghl/work/code/dde-dock/frame/dbusinterface/generation_dbus_interface/org_deepin_api_xeventmonitor /home/donghl/work/code/dde-dock/frame/dbusinterface/xml/org.deepin.api.XEventMonitor.xml
*
* qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
* before re-generating it.
*/
#include "dbusxeventmonitor.h"
/*
* Implementation of interface class __org_deepin_dde_XEventMonitor
*/
class __org_deepin_dde_XEventMonitorPrivate
{
public:
__org_deepin_dde_XEventMonitorPrivate() = default;
// begin member variables
public:
QMap<QString, QDBusPendingCallWatcher *> m_processingCalls;
QMap<QString, QList<QVariant>> m_waittingCalls;
};
__org_deepin_dde_XEventMonitor::__org_deepin_dde_XEventMonitor(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
: DBusExtendedAbstractInterface(service, path, staticInterfaceName(), connection, parent)
, d_ptr(new __org_deepin_dde_XEventMonitorPrivate)
{
if (QMetaType::type("AreaList") == QMetaType::UnknownType)
registerAreaListMetaType();
}
__org_deepin_dde_XEventMonitor::~__org_deepin_dde_XEventMonitor()
{
qDeleteAll(d_ptr->m_processingCalls.values());
delete d_ptr;
}
void __org_deepin_dde_XEventMonitor::CallQueued(const QString &callName, const QList<QVariant> &args)
{
if (d_ptr->m_waittingCalls.contains(callName)) {
d_ptr->m_waittingCalls[callName] = args;
return;
}
if (d_ptr->m_processingCalls.contains(callName)) {
d_ptr->m_waittingCalls.insert(callName, args);
} else {
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(asyncCallWithArgumentList(callName, args));
connect(watcher, &QDBusPendingCallWatcher::finished, this, &__org_deepin_dde_XEventMonitor::onPendingCallFinished);
d_ptr->m_processingCalls.insert(callName, watcher);
}
}
void __org_deepin_dde_XEventMonitor::onPendingCallFinished(QDBusPendingCallWatcher *w)
{
w->deleteLater();
const auto callName = d_ptr->m_processingCalls.key(w);
Q_ASSERT(!callName.isEmpty());
if (callName.isEmpty())
return;
d_ptr->m_processingCalls.remove(callName);
if (!d_ptr->m_waittingCalls.contains(callName))
return;
const auto args = d_ptr->m_waittingCalls.take(callName);
CallQueued(callName, args);
}

View File

@ -1,101 +0,0 @@
/*
* This file was generated by qdbusxml2cpp-fix version 0.8
* Command line was: qdbusxml2cpp-fix -c org_deepin_api_XEventMonitor -p /home/donghl/work/code/dde-dock/frame/dbusinterface/generation_dbus_interface/org_deepin_api_xeventmonitor /home/donghl/work/code/dde-dock/frame/dbusinterface/xml/org.deepin.api.XEventMonitor.xml
*
* qdbusxml2cpp-fix is Copyright (C) 2016 Deepin Technology Co., Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
*/
#ifndef ORG_DEEPIN_API_XEVENTMONITOR_H
#define ORG_DEEPIN_API_XEVENTMONITOR_H
#include "types/arealist.h"
#include <DBusExtendedAbstractInterface>
#include <QtCore/QObject>
#include <QtCore/QByteArray>
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QVariant>
#include <QtDBus/QtDBus>
/*
* Proxy class for interface org.deepin.dde.XEventMonitor1
*/
class __org_deepin_dde_XEventMonitorPrivate;
class __org_deepin_dde_XEventMonitor : public DBusExtendedAbstractInterface
{
Q_OBJECT
public:
static inline const char *staticInterfaceName()
{ return "org.deepin.dde.XEventMonitor1"; }
public:
explicit __org_deepin_dde_XEventMonitor(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
~__org_deepin_dde_XEventMonitor();
public Q_SLOTS: // METHODS
inline QDBusPendingReply<QString> RegisterArea(int in0, int in1, int in2, int in3, int in4)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2) << QVariant::fromValue(in3) << QVariant::fromValue(in4);
return asyncCallWithArgumentList(QStringLiteral("RegisterArea"), argumentList);
}
inline QDBusPendingReply<QString> RegisterAreas(AreaList in0, int in1)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1);
return asyncCallWithArgumentList(QStringLiteral("RegisterAreas"), argumentList);
}
inline QDBusPendingReply<QString> RegisterFullScreen()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("RegisterFullScreen"), argumentList);
}
inline QDBusPendingReply<bool> UnregisterArea(const QString &in0)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(in0);
return asyncCallWithArgumentList(QStringLiteral("UnregisterArea"), argumentList);
}
Q_SIGNALS: // SIGNALS
void ButtonPress(int in0, int in1, int in2, const QString &in3);
void ButtonRelease(int in0, int in1, int in2, const QString &in3);
void CancelAllArea();
void CursorInto(int in0, int in1, const QString &in2);
void CursorMove(int in0, int in1, const QString &in2);
void CursorOut(int in0, int in1, const QString &in2);
void KeyPress(const QString &in0, int in1, int in2, const QString &in3);
void KeyRelease(const QString &in0, int in1, int in2, const QString &in3);
// begin property changed signals
public Q_SLOTS:
void CallQueued(const QString &callName, const QList<QVariant> &args);
private Q_SLOTS:
void onPendingCallFinished(QDBusPendingCallWatcher *w);
private:
__org_deepin_dde_XEventMonitorPrivate *d_ptr;
};
namespace org {
namespace deepin {
namespace dde {
typedef ::__org_deepin_dde_XEventMonitor XEventMonitor1;
}
}
}
#endif

View File

@ -1 +0,0 @@
#include "dbusextended.h"

View File

@ -1 +0,0 @@
#include "dbusextendedabstractinterface.h"

View File

@ -1,15 +0,0 @@
// SPDX-FileCopyrightText: 2015 Jolla Ltd.
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef QT_DBUS_EXTENDED_H
#define QT_DBUS_EXTENDED_H
#if defined(QT_DBUS_EXTENDED_LIBRARY)
# define QT_DBUS_EXTENDED_EXPORT Q_DECL_EXPORT
#else
# define QT_DBUS_EXTENDED_EXPORT Q_DECL_IMPORT
#endif
#endif /* QT_DBUS_EXTENDED_H */

View File

@ -1,505 +0,0 @@
// SPDX-FileCopyrightText: 2015 Jolla Ltd.
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "dbusextendedpendingcallwatcher_p.h"
#include <DBusExtendedAbstractInterface>
#include <QtDBus/QDBusMetaType>
#include <QtDBus/QDBusMessage>
#include <QtDBus/QDBusPendingCall>
#include <QtDBus/QDBusPendingCallWatcher>
#include <QtDBus/QDBusPendingReply>
#include <QtCore/QDebug>
#include <QtCore/QMetaProperty>
Q_GLOBAL_STATIC_WITH_ARGS(QByteArray, dBusInterface, ("org.freedesktop.DBus"))
Q_GLOBAL_STATIC_WITH_ARGS(QByteArray, dBusPropertiesInterface, ("org.freedesktop.DBus.Properties"))
Q_GLOBAL_STATIC_WITH_ARGS(QByteArray, dBusPropertiesChangedSignal, ("PropertiesChanged"))
Q_GLOBAL_STATIC_WITH_ARGS(QByteArray, propertyChangedSignature, ("propertyChanged(QString,QVariant)"))
Q_GLOBAL_STATIC_WITH_ARGS(QByteArray, propertyInvalidatedSignature, ("propertyInvalidated(QString)"))
DBusExtendedAbstractInterface::DBusExtendedAbstractInterface(const QString &service, const QString &path, const char *interface, const QDBusConnection &connection, QObject *parent)
: QDBusAbstractInterface(service, path, interface, connection, parent)
, m_sync(true)
, m_useCache(false)
, m_getAllPendingCallWatcher(0)
, m_propertiesChangedConnected(false)
{
const_cast<QDBusConnection&>(connection).connect(QString("org.freedesktop.DBus"), QString("/org/freedesktop/DBus"), QString("org.freedesktop.DBus"), QString("NameOwnerChanged"), this, SLOT(onDBusNameOwnerChanged(QString,QString,QString)));
}
DBusExtendedAbstractInterface::~DBusExtendedAbstractInterface()
{
}
void DBusExtendedAbstractInterface::setSync(bool sync) { setSync(sync, true); }
/*
* Note: After sync is set to false, it will always return a empty value
* if you call the property's get function directly. So you can only get it
* through the changed signal when you get an property, and it's also a good idea
* to save a cache yourself.
*/
/*
* 注意: 如果设置 sync 为 false 那么在调用属性的 get 函数获取一个属性时会一直返回空值,
* 解决方法是监听属性的 changed 信号并自行保存一份缓存, 让 changed 信号修改这个缓存
*/
void DBusExtendedAbstractInterface::setSync(bool sync, bool autoStart)
{
m_sync = sync;
// init all properties
if (autoStart && !m_sync && !isValid())
startServiceProcess();
}
void DBusExtendedAbstractInterface::getAllProperties()
{
m_lastExtendedError = QDBusError();
if (!isValid()) {
QString errorMessage = QStringLiteral("This Extended DBus interface is not valid yet.");
m_lastExtendedError = QDBusMessage::createError(QDBusError::Failed, errorMessage);
qDebug() << Q_FUNC_INFO << errorMessage;
return;
}
if (!m_sync && m_getAllPendingCallWatcher) {
// Call already in place, not repeating ...
return;
}
QDBusMessage msg = QDBusMessage::createMethodCall(service(), path(), *dBusPropertiesInterface(), QStringLiteral("GetAll"));
msg << interface();
if (m_sync) {
QDBusMessage reply = connection().call(msg);
if (reply.type() != QDBusMessage::ReplyMessage) {
m_lastExtendedError = QDBusError(reply);
qWarning() << Q_FUNC_INFO << m_lastExtendedError.message();
return;
}
if (reply.signature() != QLatin1String("a{sv}")) {
QString errorMessage = QStringLiteral("Invalid signature \"%1\" in return from call to %2")
.arg(reply.signature(),
QString(*dBusPropertiesInterface()));
qWarning() << Q_FUNC_INFO << errorMessage;
m_lastExtendedError = QDBusError(QDBusError::InvalidSignature, errorMessage);
return;
}
QVariantMap value = reply.arguments().at(0).toMap();
onPropertiesChanged(interface(), value, QStringList());
} else {
QDBusPendingReply<QVariantMap> async = connection().asyncCall(msg);
m_getAllPendingCallWatcher = new QDBusPendingCallWatcher(async, this);
connect(m_getAllPendingCallWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(onAsyncGetAllPropertiesFinished(QDBusPendingCallWatcher*)));
return;
}
}
void DBusExtendedAbstractInterface::connectNotify(const QMetaMethod &signal)
{
if (signal.methodType() == QMetaMethod::Signal
&& (signal.methodSignature() == *propertyChangedSignature()
|| signal.methodSignature() == *propertyInvalidatedSignature())) {
if (!m_propertiesChangedConnected) {
QStringList argumentMatch;
argumentMatch << interface();
connection().connect(service(), path(), *dBusPropertiesInterface(), *dBusPropertiesChangedSignal(),
argumentMatch, QString(),
this, SLOT(onPropertiesChanged(QString, QVariantMap, QStringList)));
m_propertiesChangedConnected = true;
return;
}
} else {
QDBusAbstractInterface::connectNotify(signal);
}
}
void DBusExtendedAbstractInterface::disconnectNotify(const QMetaMethod &signal)
{
if (signal.methodType() == QMetaMethod::Signal
&& (signal.methodSignature() == *propertyChangedSignature()
|| signal.methodSignature() == *propertyInvalidatedSignature())) {
if (m_propertiesChangedConnected
&& 0 == receivers(propertyChangedSignature()->constData())
&& 0 == receivers(propertyInvalidatedSignature()->constData())) {
QStringList argumentMatch;
argumentMatch << interface();
connection().disconnect(service(), path(), *dBusPropertiesInterface(), *dBusPropertiesChangedSignal(),
argumentMatch, QString(),
this, SLOT(onPropertiesChanged(QString, QVariantMap, QStringList)));
m_propertiesChangedConnected = false;
return;
}
} else {
QDBusAbstractInterface::disconnectNotify(signal);
}
}
QVariant DBusExtendedAbstractInterface::internalPropGet(const char *propname, void *propertyPtr)
{
m_lastExtendedError = QDBusError();
if (m_useCache) {
int propertyIndex = metaObject()->indexOfProperty(propname);
QMetaProperty metaProperty = metaObject()->property(propertyIndex);
return QVariant(metaProperty.userType(), propertyPtr);
}
if (m_sync) {
QVariant ret = property(propname);
QMetaType::construct(ret.userType(), propertyPtr, ret.constData());
return ret;
} else {
if (!isValid()) {
QString errorMessage = QStringLiteral("This Extended DBus interface is not valid yet.");
m_lastExtendedError = QDBusMessage::createError(QDBusError::Failed, errorMessage);
qDebug() << Q_FUNC_INFO << errorMessage;
return QVariant();
}
int propertyIndex = metaObject()->indexOfProperty(propname);
if (-1 == propertyIndex) {
QString errorMessage = QStringLiteral("Got unknown property \"%1\" to read")
.arg(QString::fromLatin1(propname));
m_lastExtendedError = QDBusMessage::createError(QDBusError::Failed, errorMessage);
qWarning() << Q_FUNC_INFO << errorMessage;
return QVariant();
}
QMetaProperty metaProperty = metaObject()->property(propertyIndex);
if (!metaProperty.isReadable()) {
QString errorMessage = QStringLiteral("Property \"%1\" is NOT readable")
.arg(QString::fromLatin1(propname));
m_lastExtendedError = QDBusMessage::createError(QDBusError::Failed, errorMessage);
qWarning() << Q_FUNC_INFO << errorMessage;
return QVariant();
}
// is this metatype registered?
const char *expectedSignature = "";
if (int(metaProperty.type()) != QMetaType::QVariant) {
expectedSignature = QDBusMetaType::typeToSignature(metaProperty.userType());
if (0 == expectedSignature) {
QString errorMessage =
QStringLiteral("Type %1 must be registered with Qt D-Bus "
"before it can be used to read property "
"%2.%3")
.arg(metaProperty.typeName(),
interface(),
propname);
m_lastExtendedError = QDBusMessage::createError(QDBusError::Failed, errorMessage);
qWarning() << Q_FUNC_INFO << errorMessage;
return QVariant();
}
}
asyncProperty(propname);
return QVariant(metaProperty.userType(), propertyPtr);
}
}
void DBusExtendedAbstractInterface::internalPropSet(const char *propname, const QVariant &value, void *propertyPtr)
{
m_lastExtendedError = QDBusError();
if (m_sync) {
setProperty(propname, value);
} else {
if (!isValid()) {
QString errorMessage = QStringLiteral("This interface is not yet valid");
m_lastExtendedError = QDBusMessage::createError(QDBusError::Failed, errorMessage);
qDebug() << Q_FUNC_INFO << errorMessage;
return;
}
int propertyIndex = metaObject()->indexOfProperty(propname);
if (-1 == propertyIndex) {
QString errorMessage = QStringLiteral("Got unknown property \"%1\" to write")
.arg(QString::fromLatin1(propname));
m_lastExtendedError = QDBusMessage::createError(QDBusError::Failed, errorMessage);
qWarning() << Q_FUNC_INFO << errorMessage;
return;
}
QMetaProperty metaProperty = metaObject()->property(propertyIndex);
if (!metaProperty.isWritable()) {
QString errorMessage = QStringLiteral("Property \"%1\" is NOT writable")
.arg(QString::fromLatin1(propname));
m_lastExtendedError = QDBusMessage::createError(QDBusError::Failed, errorMessage);
qWarning() << Q_FUNC_INFO << errorMessage;
return;
}
QVariant variant = QVariant(metaProperty.type(), propertyPtr);
variant = value;
asyncSetProperty(propname, variant);
}
}
QVariant DBusExtendedAbstractInterface::asyncProperty(const QString &propertyName)
{
QDBusMessage msg = QDBusMessage::createMethodCall(service(), path(), *dBusPropertiesInterface(), QStringLiteral("Get"));
msg << interface() << propertyName;
QDBusPendingReply<QVariant> async = connection().asyncCall(msg);
DBusExtendedPendingCallWatcher *watcher = new DBusExtendedPendingCallWatcher(async, propertyName, QVariant(), this);
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(onAsyncPropertyFinished(QDBusPendingCallWatcher*)));
return QVariant();
}
void DBusExtendedAbstractInterface::asyncSetProperty(const QString &propertyName, const QVariant &value)
{
QDBusMessage msg = QDBusMessage::createMethodCall(service(), path(), *dBusPropertiesInterface(), QStringLiteral("Set"));
msg << interface() << propertyName << QVariant::fromValue(QDBusVariant(value));
QDBusPendingReply<> async = connection().asyncCall(msg);
DBusExtendedPendingCallWatcher *watcher = new DBusExtendedPendingCallWatcher(async, propertyName, value, this);
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(onAsyncSetPropertyFinished(QDBusPendingCallWatcher*)));
}
void DBusExtendedAbstractInterface::startServiceProcess()
{
const QString &servName = service();
if (isValid())
{
qWarning() << "Service" << servName << "is already started.";
return;
}
QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.DBus", "/", *dBusInterface(), QStringLiteral("StartServiceByName"));
msg << servName << quint32(0);
QDBusPendingReply<quint32> async = connection().asyncCall(msg);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, &DBusExtendedAbstractInterface::onStartServiceProcessFinished);
}
void DBusExtendedAbstractInterface::onStartServiceProcessFinished(QDBusPendingCallWatcher *w)
{
if (w->isError())
{
m_lastExtendedError = w->error();
} else {
m_lastExtendedError = QDBusError();
}
QDBusPendingReply<quint32> reply = *w;
Q_EMIT serviceStartFinished(reply.value());
w->deleteLater();
}
void DBusExtendedAbstractInterface::onAsyncPropertyFinished(QDBusPendingCallWatcher *w)
{
DBusExtendedPendingCallWatcher *watcher = qobject_cast<DBusExtendedPendingCallWatcher *>(w);
Q_ASSERT(watcher);
QDBusPendingReply<QVariant> reply = *watcher;
if (reply.isError()) {
m_lastExtendedError = reply.error();
} else {
int propertyIndex = metaObject()->indexOfProperty(watcher->asyncProperty().toLatin1().constData());
QVariant value = demarshall(interface(),
metaObject()->property(propertyIndex),
reply.value(),
&m_lastExtendedError);
if (m_lastExtendedError.isValid()) {
Q_EMIT propertyInvalidated(watcher->asyncProperty());
} else {
Q_EMIT propertyChanged(watcher->asyncProperty(), value);
}
}
Q_EMIT asyncPropertyFinished(watcher->asyncProperty());
watcher->deleteLater();
}
void DBusExtendedAbstractInterface::onAsyncSetPropertyFinished(QDBusPendingCallWatcher *w)
{
DBusExtendedPendingCallWatcher *watcher = qobject_cast<DBusExtendedPendingCallWatcher *>(w);
Q_ASSERT(watcher);
QDBusPendingReply<> reply = *watcher;
if (reply.isError()) {
m_lastExtendedError = reply.error();
} else {
m_lastExtendedError = QDBusError();
}
Q_EMIT asyncSetPropertyFinished(watcher->asyncProperty());
// Resetting the property to its previous value after sending the
// finished signal
if (reply.isError()) {
m_lastExtendedError = QDBusError();
Q_EMIT propertyChanged(watcher->asyncProperty(), watcher->previousValue());
}
watcher->deleteLater();
}
void DBusExtendedAbstractInterface::onAsyncGetAllPropertiesFinished(QDBusPendingCallWatcher *watcher)
{
m_getAllPendingCallWatcher = 0;
QDBusPendingReply<QVariantMap> reply = *watcher;
if (reply.isError()) {
m_lastExtendedError = reply.error();
} else {
m_lastExtendedError = QDBusError();
}
Q_EMIT asyncGetAllPropertiesFinished();
if (!reply.isError()) {
onPropertiesChanged(interface(), reply.value(), QStringList());
}
watcher->deleteLater();
}
void DBusExtendedAbstractInterface::onPropertiesChanged(const QString& interfaceName,
const QVariantMap& changedProperties,
const QStringList& invalidatedProperties)
{
if (interfaceName == interface()) {
QVariantMap::const_iterator i = changedProperties.constBegin();
while (i != changedProperties.constEnd()) {
int propertyIndex = metaObject()->indexOfProperty(i.key().toLatin1().constData());
if (-1 == propertyIndex) {
qDebug() << Q_FUNC_INFO << "Got unknown changed property" << i.key();
} else {
QVariant value = demarshall(interface(), metaObject()->property(propertyIndex), i.value(), &m_lastExtendedError);
if (m_lastExtendedError.isValid()) {
Q_EMIT propertyInvalidated(i.key());
} else {
Q_EMIT propertyChanged(i.key(), value);
}
}
++i;
}
QStringList::const_iterator j = invalidatedProperties.constBegin();
while (j != invalidatedProperties.constEnd()) {
if (-1 == metaObject()->indexOfProperty(j->toLatin1().constData())) {
qDebug() << Q_FUNC_INFO << "Got unknown invalidated property" << *j;
} else {
m_lastExtendedError = QDBusError();
Q_EMIT propertyInvalidated(*j);
}
++j;
}
}
}
void DBusExtendedAbstractInterface::onDBusNameOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner)
{
if (name == service() && oldOwner.isEmpty())
{
m_dbusOwner = newOwner;
Q_EMIT serviceValidChanged(true);
}
else if (name == m_dbusOwner && newOwner.isEmpty())
{
m_dbusOwner.clear();
Q_EMIT serviceValidChanged(false);
}
}
QVariant DBusExtendedAbstractInterface::demarshall(const QString &interface, const QMetaProperty &metaProperty, const QVariant &value, QDBusError *error)
{
Q_ASSERT(metaProperty.isValid());
Q_ASSERT(error != 0);
if (value.userType() == metaProperty.userType()) {
// No need demarshalling. Passing back straight away ...
*error = QDBusError();
return value;
}
QVariant result = QVariant(metaProperty.userType(), (void*)0);
QString errorMessage;
const char *expectedSignature = QDBusMetaType::typeToSignature(metaProperty.userType());
if (value.userType() == qMetaTypeId<QDBusArgument>()) {
// demarshalling a DBus argument ...
QDBusArgument dbusArg = value.value<QDBusArgument>();
if (expectedSignature == dbusArg.currentSignature().toLatin1()) {
QDBusMetaType::demarshall(dbusArg, metaProperty.userType(), result.data());
if (!result.isValid()) {
errorMessage = QStringLiteral("Unexpected failure demarshalling "
"upon PropertiesChanged signal arrival "
"for property `%3.%4' (expected type `%5' (%6))")
.arg(interface,
QString::fromLatin1(metaProperty.name()),
QString::fromLatin1(metaProperty.typeName()),
expectedSignature);
}
} else {
errorMessage = QStringLiteral("Unexpected `user type' (%2) "
"upon PropertiesChanged signal arrival "
"for property `%3.%4' (expected type `%5' (%6))")
.arg(dbusArg.currentSignature(),
interface,
QString::fromLatin1(metaProperty.name()),
QString::fromLatin1(metaProperty.typeName()),
QString::fromLatin1(expectedSignature));
}
} else {
const char *actualSignature = QDBusMetaType::typeToSignature(value.userType());
errorMessage = QStringLiteral("Unexpected `%1' (%2) "
"upon PropertiesChanged signal arrival "
"for property `%3.%4' (expected type `%5' (%6))")
.arg(QString::fromLatin1(value.typeName()),
QString::fromLatin1(actualSignature),
interface,
QString::fromLatin1(metaProperty.name()),
QString::fromLatin1(metaProperty.typeName()),
QString::fromLatin1(expectedSignature));
}
if (errorMessage.isEmpty()) {
*error = QDBusError();
} else {
*error = QDBusMessage::createError(QDBusError::InvalidSignature, errorMessage);
qDebug() << Q_FUNC_INFO << errorMessage;
}
return result;
}

View File

@ -1,83 +0,0 @@
// SPDX-FileCopyrightText: 2015 Jolla Ltd.
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef DBUSEXTENDEDABSTRACTINTERFACE_H
#define DBUSEXTENDEDABSTRACTINTERFACE_H
#include <DBusExtended>
#include <QDBusAbstractInterface>
#include <QDBusError>
class QDBusPendingCallWatcher;
class DBusExtendedPendingCallWatcher;
class QT_DBUS_EXTENDED_EXPORT DBusExtendedAbstractInterface: public QDBusAbstractInterface
{
Q_OBJECT
public:
virtual ~DBusExtendedAbstractInterface();
Q_PROPERTY(bool sync READ sync WRITE setSync)
inline bool sync() const { return m_sync; }
void setSync(bool sync);
void setSync(bool sync, bool autoStart);
Q_PROPERTY(bool useCache READ useCache WRITE setUseCache)
inline bool useCache() const { return m_useCache; }
inline void setUseCache(bool useCache) { m_useCache = useCache; }
void getAllProperties();
inline QDBusError lastExtendedError() const { return m_lastExtendedError; }
public Q_SLOTS:
void startServiceProcess();
protected:
DBusExtendedAbstractInterface(const QString &service,
const QString &path,
const char *interface,
const QDBusConnection &connection,
QObject *parent);
void connectNotify(const QMetaMethod &signal);
void disconnectNotify(const QMetaMethod &signal);
QVariant internalPropGet(const char *propname, void *propertyPtr);
void internalPropSet(const char *propname, const QVariant &value, void *propertyPtr);
Q_SIGNALS:
void serviceValidChanged(const bool valid) const;
void serviceStartFinished(const quint32 ret) const;
void propertyChanged(const QString &propertyName, const QVariant &value);
void propertyInvalidated(const QString &propertyName);
void asyncPropertyFinished(const QString &propertyName);
void asyncSetPropertyFinished(const QString &propertyName);
void asyncGetAllPropertiesFinished();
private Q_SLOTS:
void onPropertiesChanged(const QString& interfaceName,
const QVariantMap& changedProperties,
const QStringList& invalidatedProperties);
void onDBusNameOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner);
void onAsyncPropertyFinished(QDBusPendingCallWatcher *w);
void onAsyncSetPropertyFinished(QDBusPendingCallWatcher *w);
void onAsyncGetAllPropertiesFinished(QDBusPendingCallWatcher *watcher);
void onStartServiceProcessFinished(QDBusPendingCallWatcher *w);
private:
QVariant asyncProperty(const QString &propertyName);
void asyncSetProperty(const QString &propertyName, const QVariant &value);
static QVariant demarshall(const QString &interface, const QMetaProperty &metaProperty, const QVariant &value, QDBusError *error);
bool m_sync;
bool m_useCache;
QDBusPendingCallWatcher *m_getAllPendingCallWatcher;
QDBusError m_lastExtendedError;
QString m_dbusOwner;
bool m_propertiesChangedConnected;
};
#endif /* DBUSEXTENDEDABSTRACTINTERFACE_H */

View File

@ -1,18 +0,0 @@
// SPDX-FileCopyrightText: 2015 Jolla Ltd.
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "dbusextendedpendingcallwatcher_p.h"
DBusExtendedPendingCallWatcher::DBusExtendedPendingCallWatcher(const QDBusPendingCall &call, const QString &asyncProperty, const QVariant &previousValue, QObject *parent)
: QDBusPendingCallWatcher(call, parent)
, m_asyncProperty(asyncProperty)
, m_previousValue(previousValue)
{
}
DBusExtendedPendingCallWatcher::~DBusExtendedPendingCallWatcher()
{
}

View File

@ -1,47 +0,0 @@
// SPDX-FileCopyrightText: 2015 Jolla Ltd.
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
// W A R N I N G
// -------------
//
// This file is not part of the public API. This header file may
// change from version to version without notice, or even be
// removed.
//
// We mean it.
//
//
#ifndef DBUSEXTENDEDPENDINGCALLWATCHER_P_H
#define DBUSEXTENDEDPENDINGCALLWATCHER_P_H
#include <QDBusPendingCallWatcher>
#include <QDBusError>
class DBusExtendedPendingCallWatcher: public QDBusPendingCallWatcher
{
Q_OBJECT
public:
explicit DBusExtendedPendingCallWatcher(const QDBusPendingCall &call,
const QString &asyncProperty,
const QVariant &previousValue,
QObject *parent = 0);
~DBusExtendedPendingCallWatcher();
Q_PROPERTY(QString AsyncProperty READ asyncProperty)
inline QString asyncProperty() const { return m_asyncProperty; }
Q_PROPERTY(QVariant PreviousValue READ previousValue)
inline QVariant previousValue() const { return m_previousValue; }
private:
QString m_asyncProperty;
QVariant m_previousValue;
};
#endif /* DBUSEXTENDEDPENDINGCALLWATCHER_P_H */

View File

@ -1,38 +0,0 @@
// SPDX-FileCopyrightText: 2011 ~ 2017 Deepin Technology Co., Ltd.
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "arealist.h"
bool MonitRect::operator ==(const MonitRect &rect)
{
return x1 == rect.x1 && y1 == rect.y1 && x2 == rect.x2 && y2 == rect.y2;
}
QDBusArgument &operator<<(QDBusArgument &arg, const MonitRect &rect)
{
arg.beginStructure();
arg << rect.x1 << rect.y1 << rect.x2 << rect.y2;
arg.endStructure();
return arg;
}
const QDBusArgument &operator>>(const QDBusArgument &arg, MonitRect &rect)
{
arg.beginStructure();
arg >> rect.x1 >> rect.y1 >> rect.x2 >> rect.y2;
arg.endStructure();
return arg;
}
void registerAreaListMetaType()
{
qRegisterMetaType<MonitRect>("MonitRect");
qDBusRegisterMetaType<MonitRect>();
qRegisterMetaType<AreaList>("AreaList");
qDBusRegisterMetaType<AreaList>();
}

View File

@ -1,32 +0,0 @@
// SPDX-FileCopyrightText: 2011 ~ 2017 Deepin Technology Co., Ltd.
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef AREALIST_H
#define AREALIST_H
#include <QDBusMetaType>
#include <QRect>
#include <QList>
struct MonitRect {
int x1;
int y1;
int x2;
int y2;
bool operator ==(const MonitRect& rect);
};
typedef QList<MonitRect> AreaList;
Q_DECLARE_METATYPE(MonitRect)
Q_DECLARE_METATYPE(AreaList)
QDBusArgument &operator<<(QDBusArgument &arg, const MonitRect &rect);
const QDBusArgument &operator>>(const QDBusArgument &arg, MonitRect &rect);
void registerAreaListMetaType();
#endif // AREALIST_H

View File

@ -1,54 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "dockrect.h"
#include <QDebug>
DockRect::DockRect()
: X(0)
, Y(0)
, Width(0)
, Height(0)
{
}
QDebug operator<<(QDebug debug, const DockRect &rect)
{
debug << QString("DockRect(%1, %2, %3, %4)").arg(rect.X)
.arg(rect.Y)
.arg(rect.Width)
.arg(rect.Height);
return debug;
}
DockRect::operator QRect() const
{
return QRect(X, Y, Width, Height);
}
QDBusArgument &operator<<(QDBusArgument &arg, const DockRect &rect)
{
arg.beginStructure();
arg << rect.X << rect.Y << rect.Width << rect.Height;
arg.endStructure();
return arg;
}
const QDBusArgument &operator>>(const QDBusArgument &arg, DockRect &rect)
{
arg.beginStructure();
arg >> rect.X >> rect.Y >> rect.Width >> rect.Height;
arg.endStructure();
return arg;
}
void registerRectMetaType()
{
qRegisterMetaType<DockRect>("DockRect");
qDBusRegisterMetaType<DockRect>();
}

View File

@ -1,28 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef DOCKRECT_H
#define DOCKRECT_H
#include <QRect>
#include <QDBusMetaType>
struct DockRect
{
public:
DockRect();
operator QRect() const;
friend QDebug operator<<(QDebug debug, const DockRect &rect);
friend const QDBusArgument &operator>>(const QDBusArgument &arg, DockRect &rect);
friend QDBusArgument &operator<<(QDBusArgument &arg, const DockRect &rect);
qint32 X, Y, Width, Height;
};
Q_DECLARE_METATYPE(DockRect)
void registerRectMetaType();
#endif // DOCKRECT_H

View File

@ -1,33 +0,0 @@
// SPDX-FileCopyrightText: 2017 ~ 2019 Deepin Technology Co., Ltd.
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "launcheriteminfo.h"
bool LauncherItemInfo::operator!=(const LauncherItemInfo &itemInfo)
{
return itemInfo.path != path;
}
QDBusArgument &operator<<(QDBusArgument &argument, const LauncherItemInfo &itemInfo)
{
argument.beginStructure();
argument << itemInfo.path << itemInfo.name << itemInfo.id << itemInfo.icon << itemInfo.categoryId << itemInfo.timeInstalled << itemInfo.keywords;
argument.endStructure();
return argument;
}
const QDBusArgument &operator>>(const QDBusArgument &argument, LauncherItemInfo &itemInfo)
{
argument.beginStructure();
argument >> itemInfo.path >> itemInfo.name >> itemInfo.id >> itemInfo.icon >> itemInfo.categoryId >> itemInfo.timeInstalled >> itemInfo.keywords;
argument.endStructure();
return argument;
}
void registerLauncherItemInfoMetaType()
{
qRegisterMetaType<LauncherItemInfo>("ItemInfo");
qDBusRegisterMetaType<LauncherItemInfo>();
}

View File

@ -1,37 +0,0 @@
// SPDX-FileCopyrightText: 2017 ~ 2019 Deepin Technology Co., Ltd.
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <QtCore/QString>
#include <QtDBus/QtDBus>
#include <QtCore/QList>
#include <QDBusMetaType>
#include <QDebug>
struct LauncherItemInfo {
QString path;
QString name;
QString id;
QString icon;
qint64 categoryId;
qint64 timeInstalled;
QStringList keywords;
bool operator!=(const LauncherItemInfo &versionInfo);
friend QDebug operator<<(QDebug argument, const LauncherItemInfo &info)
{
argument << info.path << info.name << info.id;
argument << info.icon << info.categoryId << info.timeInstalled << info.keywords;
return argument;
}
};
Q_DECLARE_METATYPE(LauncherItemInfo)
QDBusArgument &operator<<(QDBusArgument &argument, const LauncherItemInfo &versionInfo);
const QDBusArgument &operator>>(const QDBusArgument &argument, LauncherItemInfo &versionInfo);
void registerLauncherItemInfoMetaType();

View File

@ -1,12 +0,0 @@
// SPDX-FileCopyrightText: 2017 ~ 2019 Deepin Technology Co., Ltd.
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "launcheriteminfolist.h"
void registerLauncherItemInfoListMetaType()
{
qRegisterMetaType<LauncherItemInfo>("ItemInfoList");
qDBusRegisterMetaType<LauncherItemInfoList>();
}

View File

@ -1,17 +0,0 @@
// SPDX-FileCopyrightText: 2017 ~ 2019 Deepin Technology Co., Ltd.
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include "launcheriteminfo.h"
#include <QtCore/QList>
#include <QDBusMetaType>
typedef QList<LauncherItemInfo> LauncherItemInfoList;
Q_DECLARE_METATYPE(LauncherItemInfoList)
void registerLauncherItemInfoListMetaType();

View File

@ -1,11 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "unlaunchedappmap.h"
void registerUnLaunchedAppMapMetaType()
{
qRegisterMetaType<UnLaunchedAppMap>("UnLaunchedAppMap");
qDBusRegisterMetaType<UnLaunchedAppMap>();
}

View File

@ -1,18 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef TYPES_H
#define TYPES_H
#include <QMap>
#include <QStringList>
#include <QDBusMetaType>
typedef QMap<QString, QStringList> UnLaunchedAppMap;
Q_DECLARE_METATYPE(UnLaunchedAppMap)
void registerUnLaunchedAppMapMetaType();
#endif // TYPES_H

View File

@ -1,53 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "windowinfomap.h"
#include <QDBusMetaType>
void registerWindowInfoMapMetaType()
{
registerWindowInfoMetaType();
qRegisterMetaType<WindowInfoMap>("WindowInfoMap");
qDBusRegisterMetaType<WindowInfoMap>();
}
void registerWindowInfoMetaType()
{
qRegisterMetaType<WindowInfo>("WindowInfo");
qDBusRegisterMetaType<WindowInfo>();
}
QDebug operator<<(QDebug argument, const WindowInfo &info)
{
argument << '(' << info.title << ',' << info.attention << info.uuid << ')';
return argument;
}
QDBusArgument &operator<<(QDBusArgument &argument, const WindowInfo &info)
{
argument.beginStructure();
argument << info.title << info.attention << info.uuid;
argument.endStructure();
return argument;
}
const QDBusArgument &operator>>(const QDBusArgument &argument, WindowInfo &info)
{
argument.beginStructure();
argument >> info.title >> info.attention >> info.uuid;
argument.endStructure();
return argument;
}
bool WindowInfo::operator==(const WindowInfo &rhs) const
{
return attention == rhs.attention &&
title == rhs.title &&
uuid == rhs.uuid;
}

View File

@ -1,34 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef WINDOWINFOLIST_H
#define WINDOWINFOLIST_H
#include <QDebug>
#include <QList>
#include <QDBusArgument>
class WindowInfo
{
public:
friend QDebug operator<<(QDebug argument, const WindowInfo &info);
friend QDBusArgument &operator<<(QDBusArgument &argument, const WindowInfo &info);
friend const QDBusArgument &operator>>(const QDBusArgument &argument, WindowInfo &info);
bool operator==(const WindowInfo &rhs) const;
public:
bool attention;
QString title;
QString uuid;
};
Q_DECLARE_METATYPE(WindowInfo)
typedef QMap<quint32, WindowInfo> WindowInfoMap;
Q_DECLARE_METATYPE(WindowInfoMap)
void registerWindowInfoMetaType();
void registerWindowInfoMapMetaType();
#endif // WINDOWINFOLIST_H

View File

@ -1,414 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "appinfo.h"
#include "utils.h"
#include "dlocale.h"
#include "appinfocommon.h"
#include <string>
#include <gio/gio.h>
#include <gio/gdesktopappinfo.h>
#include <string.h>
#include <QDir>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
bool AppInfoManger::onceInit = false;
std::vector<std::string> AppInfoManger::xdgDataDirs;
std::vector<std::string> AppInfoManger::xdgAppDirs;
AppInfoManger::AppInfoManger()
{
canDelete = false;
}
std::vector<std::string> AppInfoManger::getStringList(std::string session, std::string key)
{
return keyFile.getStrList(session, key);
}
std::string AppInfoManger::toJson()
{
QJsonDocument doc;
QJsonObject obj;
obj["Id"] = desktopId.c_str();
obj["Name"] = appName.c_str();
obj["DisplayName"] = displayName.c_str();
obj["Description"] = comment.c_str();
obj["Icon"] = icon.c_str();
obj["Exec"] = cmdline.c_str();
obj["CanDelete"] = canDelete;
if (!obj.isEmpty()) {
doc.setObject(obj);
}
return doc.toJson(QJsonDocument::Compact).toStdString();
}
std::string AppInfoManger::getFileName()
{
return fileName;
}
std::shared_ptr<AppInfoManger> AppInfoManger::loadByDesktopId(std::string desktopId)
{
std::shared_ptr<AppInfoManger> appInfo;
if (!hasEnding(desktopId, AppinfoCommon::DesktopExt)) {
desktopId += AppinfoCommon::DesktopExt;
}
if (QDir::isAbsolutePath(desktopId.c_str())) {
appInfo = AppInfoManger::initAppInfoByFile(desktopId);
if (appInfo) {
appInfo->desktopId = AppInfoManger::getDesktopIdFile(desktopId);
}
return appInfo;
}
std::vector<std::string> appDirs = AppInfoManger::getXdgAppsDirs();
for (auto iter : appDirs) {
appInfo = AppInfoManger::initAppInfoByFile(iter + "/" + desktopId);
if (appInfo) {
appInfo->desktopId = desktopId;
return appInfo;
}
}
return appInfo;
}
std::shared_ptr<AppInfoManger> AppInfoManger::initAppInfoByFile(std::string fileName)
{
std::shared_ptr<AppInfoManger> appInfo;
KeyFile keyFile;
bool bSuccess = keyFile.loadFile(fileName);
if (!bSuccess) {
return appInfo;
}
std::string type = keyFile.getStr(AppinfoCommon::MainSection, AppinfoCommon::KeyType);
if (type != AppinfoCommon::TypeApplication) {
return appInfo;
}
appInfo = std::make_shared<AppInfoManger>();
appInfo->appName = getAppName(keyFile);
appInfo->icon = AppInfoManger::getIconByKeyFile(keyFile);
appInfo->displayName = appInfo->appName;
appInfo->comment = keyFile.getLocaleStr(AppinfoCommon::MainSection, AppinfoCommon::KeyComment);
appInfo->cmdline = keyFile.getStr(AppinfoCommon::MainSection, AppinfoCommon::KeyExec);
appInfo->fileName = fileName;
appInfo->keyFile = keyFile;
if (!appInfo->shouldShow()) {
return nullptr;
}
return appInfo;
}
std::string AppInfoManger::getIconByKeyFile(KeyFile& keyFile)
{
std::string icon = keyFile.getStr(AppinfoCommon::MainSection, AppinfoCommon::KeyIcon);
if (!QDir::isAbsolutePath(icon.c_str())) {
if (hasEnding(icon, ".png")) {
icon = icon.substr(0, icon.length() - strlen(".png"));
}
if (hasEnding(icon, ".xpm")) {
icon = icon.substr(0, icon.length() - strlen(".xpm"));
}
if (hasEnding(icon, ".svg")) {
icon = icon.substr(0, icon.length() - strlen(".svg"));
}
}
return icon;
}
std::string AppInfoManger::getDesktopIdFile(std::string fileName)
{
if (hasEnding(fileName, AppinfoCommon::DesktopExt)) {
fileName = fileName.substr(0, fileName.size() - strlen(AppinfoCommon::DesktopExt.c_str()) + 1);
}
auto index = fileName.find("/applications/");
if (index == fileName.npos) {
return "";
}
std::string dir = fileName.substr(0, index);
std::vector<std::string> dataDIrs = AppInfoManger::getXdgDataDirs();
if (std::find(dataDIrs.begin(), dataDIrs.end(), dir) != dataDIrs.end()) {
return fileName.substr(index + 14, fileName.size() - (index + 14 + 1));
}
return fileName;
}
bool AppInfoManger::shouldShow()
{
if (!keyFile.getStr(AppinfoCommon::MainSection, AppinfoCommon::KeyNoDisplay).empty()) {
return false;
}
if (!keyFile.getStr(AppinfoCommon::MainSection, AppinfoCommon::KeyHidden).empty()) {
return false;
}
QString deskEnv = getenv("XDG_CURRENT_DESKTOP");
auto envList = deskEnv.split(":");
std::vector<std::string> onlyShowIn = keyFile.getStrList(AppinfoCommon::MainSection, AppinfoCommon::KeyOnlyShowIn);
std::vector<std::string> notShowIn = keyFile.getStrList(AppinfoCommon::MainSection, AppinfoCommon::KeyNotShowIn);
for (auto iter : envList) {
if (std::find(onlyShowIn.begin(), onlyShowIn.end(), iter.toStdString()) != onlyShowIn.end()) {
return true;
}
if (std::find(notShowIn.begin(), notShowIn.end(), iter.toStdString()) != notShowIn.end()) {
return false;
}
}
return onlyShowIn.empty();
}
std::string AppInfoManger::getDefaultApp(std::string mimeType, bool supportUri)
{
GAppInfo* gAppInfo = g_app_info_get_default_for_type(mimeType.c_str(), supportUri);
if (gAppInfo == nullptr) {
return "";
}
if (supportUri && !g_app_info_supports_uris(gAppInfo)) {
return "";
}
return g_app_info_get_id(gAppInfo);
}
std::vector<std::string> AppInfoManger::getAppList(std::string mimeType)
{
std::vector<std::string> retVector;
GList* appInfoList = g_app_info_get_all_for_type(mimeType.c_str());
while (appInfoList) {
GAppInfo* gAppInfo = static_cast<GAppInfo*>(appInfoList->data);
const char* appId = g_app_info_get_id(gAppInfo);
if (appId) {
retVector.push_back(appId);
}
appInfoList = appInfoList->next;
}
return retVector;
}
bool AppInfoManger::setDefaultApp(std::string mimeType, std::string desktopId)
{
GDesktopAppInfo* gDesktopAppInfo = g_desktop_app_info_new(desktopId.c_str());
if (gDesktopAppInfo == nullptr) {
return false;
}
GAppInfo* gAppInfo = G_APP_INFO(gDesktopAppInfo);
GError* err = nullptr;
g_app_info_set_as_default_for_type(gAppInfo, mimeType.c_str(), &err);
if (err != nullptr) {
return false;
}
return true;
}
std::string AppInfoManger::getAppName(KeyFile& keyFile)
{
std::string name;
std::string xDeepinVendor = keyFile.getStr(AppinfoCommon::MainSection, AppinfoCommon::DeepinVendor);
if (xDeepinVendor == "deepin") {
name = keyFile.getLocaleStr(AppinfoCommon::MainSection, AppinfoCommon::KeyGenericName);
} else {
name = keyFile.getLocaleStr(AppinfoCommon::MainSection, AppinfoCommon::KeyName);
}
if (name.empty()) {
name = AppInfoManger::getDesktopIdFile(keyFile.getFilePath());
}
return name;
}
std::vector<std::string>& AppInfoManger::getXdgDataDirs()
{
if (!AppInfoManger::onceInit) {
AppInfoManger::onceInit = true;
AppInfoManger::xdgDataDirs.push_back(getUserDataDir());
for (auto iter : getSystemDataDirs()) {
xdgDataDirs.push_back(iter);
}
for (auto dataDir : AppInfoManger::xdgDataDirs) {
AppInfoManger::xdgAppDirs.push_back(dataDir + "/applications");
}
}
return AppInfoManger::xdgDataDirs;
}
std::vector<std::string>& AppInfoManger::getXdgAppsDirs()
{
if (!AppInfoManger::onceInit) {
AppInfoManger::onceInit = true;
AppInfoManger::xdgDataDirs.push_back(getUserDataDir());
for (auto iter : getSystemDataDirs()) {
xdgDataDirs.push_back(iter);
}
for (auto dataDir : AppInfoManger::xdgDataDirs) {
AppInfoManger::xdgAppDirs.push_back(dataDir + "/applications");
}
}
return AppInfoManger::xdgAppDirs;
}
std::vector<std::shared_ptr<AppInfoManger>> AppInfoManger::getAll(std::map<std::string, std::vector<std::string>> skipDirs)
{
std::vector<std::shared_ptr<AppInfoManger>> ret;
std::vector<std::string> xdgAppDirs = AppInfoManger::getXdgAppsDirs();
std::vector<std::pair<std::string, std::map<std::string, int>>> appPathNameInfos;
for (auto iter : xdgAppDirs) {
std::map<std::string, int> tempMap;
if (skipDirs.count(iter) != 0) {
walk(iter, skipDirs[iter], tempMap);
} else {
std::vector<std::string> temp;
walk(iter, temp, tempMap);
}
appPathNameInfos.push_back(std::make_pair(iter, tempMap));
}
std::map<std::string, int> recordMap;
for (auto appPathNameInfo : appPathNameInfos) {
for (auto appName : appPathNameInfo.second) {
std::string tempAppName = appName.first;
if (hasBeginWith(appName.first, "./")) {
tempAppName = appName.first.substr(appName.first.find_first_of("./") + 2, appName.first.size() - 2);
}
if (recordMap.count(tempAppName)) {
continue;
}
std::shared_ptr<AppInfoManger> appInfo = AppInfoManger::loadByDesktopId(appPathNameInfo.first + "/" + tempAppName);
if (!appInfo) {
continue;
}
recordMap[tempAppName] = 0;
if (appInfo->shouldShow()) {
ret.push_back(appInfo);
}
}
}
return ret;
}
std::string AppInfoManger::getDesktopId()
{
return desktopId;
}
std::string AppInfoManger::getAppName()
{
return appName;
}
std::string AppInfoManger::getDisplayName()
{
return displayName;
}
std::string AppInfoManger::getComment()
{
return comment;
}
std::string AppInfoManger::getIcon()
{
return icon;
}
std::string AppInfoManger::getCmdline()
{
return cmdline;
}
bool AppInfoManger::getCanDelete()
{
return canDelete;
}
void AppInfoManger::setCanDelete(bool bCanDelete)
{
canDelete = bCanDelete;
}
std::vector<std::string> AppInfoManger::getCategories()
{
return keyFile.getStrList(AppinfoCommon::MainSection, AppinfoCommon::KeyCategories);
}
void AppInfoManger::setDesktopId(std::string desktopId)
{
this->desktopId = desktopId;
}
std::string AppInfoManger::toJson(std::vector<std::shared_ptr<AppInfoManger>> appInfos)
{
QJsonDocument doc;
QJsonObject obj;
QJsonArray arr;
for (auto iter : appInfos) {
obj["Id"] = iter->getDesktopId().c_str();
obj["Name"] = iter->getAppName().c_str();
obj["DisplayName"] = iter->getDisplayName().c_str();
obj["Description"] = iter->getComment().c_str();
obj["Icon"] = iter->getIcon().c_str();
obj["Exec"] = iter->getCmdline().c_str();
obj["CanDelete"] = iter->getCanDelete();
arr.push_back(obj);
}
if (!arr.empty()) {
doc.setArray(arr);
}
return doc.toJson(QJsonDocument::Compact).toStdString();
}

View File

@ -1,60 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef APPINFO_H
#define APPINFO_H
#include "keyfile.h"
#include <vector>
#include <memory>
class AppInfoManger
{
public:
AppInfoManger();
std::vector<std::string> getStringList(std::string session, std::string key);
std::string toJson();
std::string getFileName();
static std::shared_ptr<AppInfoManger> loadByDesktopId(std::string desktopId);
static std::string getDefaultApp(std::string mimeType, bool supportUri);
static std::vector<std::string> getAppList(std::string mimeType);
static bool setDefaultApp(std::string mimeType, std::string desktopId);
static std::vector<std::string>& getXdgDataDirs();
static std::vector<std::string>& getXdgAppsDirs();
static std::vector<std::shared_ptr<AppInfoManger>> getAll(std::map<std::string, std::vector<std::string>> skipDirs);
std::string getDesktopId();
std::string getAppName();
std::string getDisplayName();
std::string getComment();
std::string getIcon();
std::string getCmdline();
bool getCanDelete();
void setCanDelete(bool bCanDelete);
std::vector<std::string> getCategories();
void setDesktopId(std::string desktopId);
static std::string toJson(std::vector<std::shared_ptr<AppInfoManger>> appInfos);
private:
static std::shared_ptr<AppInfoManger> initAppInfoByFile(std::string fileName);
static std::string getAppName(KeyFile& keyFile);
static std::string getIconByKeyFile(KeyFile& keyFile);
static std::string getDesktopIdFile(std::string fileName);
bool shouldShow();
private:
std::string desktopId;
std::string appName;
std::string displayName;
std::string comment;
std::string icon;
std::string cmdline;
bool canDelete;
std::string fileName;
KeyFile keyFile;
static std::vector<std::string> xdgDataDirs;
static std::vector<std::string> xdgAppDirs;
static bool onceInit;
};
#endif // APPINFO_H

View File

@ -1,43 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "appinfocommon.h"
const std::string AppinfoCommon::MainSection = "Desktop Entry";
const std::string AppinfoCommon::KeyType = "Type";
const std::string AppinfoCommon::KeyVersion = "Version";
const std::string AppinfoCommon::KeyName = "Name";
const std::string AppinfoCommon::KeyGenericName = "GenericName";
const std::string AppinfoCommon::KeyNoDisplay = "NoDisplay";
const std::string AppinfoCommon::KeyComment = "Comment";
const std::string AppinfoCommon::KeyIcon = "Icon";
const std::string AppinfoCommon::KeyHidden = "Hidden";
const std::string AppinfoCommon::KeyOnlyShowIn = "OnlyShowIn";
const std::string AppinfoCommon::KeyNotShowIn = "NotShowIn";
const std::string AppinfoCommon::KeyTryExec = "TryExec";
const std::string AppinfoCommon::KeyExec = "Exec";
const std::string AppinfoCommon::KeyPath = "Path";
const std::string AppinfoCommon::KeyTerminal = "Terminal";
const std::string AppinfoCommon::KeyMimeType = "MimeType";
const std::string AppinfoCommon::KeyCategories = "Categories";
const std::string AppinfoCommon::KeyKeywords = "Keywords";
const std::string AppinfoCommon::KeyStartupNotify = "StartupNotify";
const std::string AppinfoCommon::KeyStartupWMClass = "StartupWMClass";
const std::string AppinfoCommon::KeyURL = "URL";
const std::string AppinfoCommon::KeyActions = "Actions";
const std::string AppinfoCommon::KeyDBusActivatable = "DBusActivatable";
const std::string AppinfoCommon::TypeApplication = "Application";
const std::string AppinfoCommon::TypeLink = "Link";
const std::string AppinfoCommon::TypeDirectory = "Directory";
const std::string AppinfoCommon::EnvDesktopEnv = "XDG_CURRENT_DESKTOP";
const std::string AppinfoCommon::DesktopExt = ".desktop";
const std::string AppinfoCommon::EnableInvoker = "ENABLE_TURBO_INVOKER";
const std::string AppinfoCommon::TurboInvokerFailedMsg = "Failed to invoke: Booster:";
const std::string AppinfoCommon::TurboInvokerErrMsg = "deepin-turbo-invoker: error";
const std::string AppinfoCommon::SectionDefaultApps = "Default Applications";
const std::string AppinfoCommon::SectionAddedAssociations = "Added Associations";
const std::string AppinfoCommon::DeepinVendor = "X-Deepin-Vendor";
const std::string AppinfoCommon::AppMimeTerminal = "application/x-terminal";

View File

@ -1,51 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef APPINFOCOMMON_H
#define APPINFOCOMMON_H
#include <string>
class AppinfoCommon
{
public:
const static std::string MainSection;
const static std::string KeyType;
const static std::string KeyVersion;
const static std::string KeyName;
const static std::string KeyGenericName;
const static std::string KeyNoDisplay;
const static std::string KeyComment;
const static std::string KeyIcon;
const static std::string KeyHidden;
const static std::string KeyOnlyShowIn;
const static std::string KeyNotShowIn;
const static std::string KeyTryExec;
const static std::string KeyExec;
const static std::string KeyPath;
const static std::string KeyTerminal;
const static std::string KeyMimeType;
const static std::string KeyCategories;
const static std::string KeyKeywords;
const static std::string KeyStartupNotify;
const static std::string KeyStartupWMClass;
const static std::string KeyURL;
const static std::string KeyActions;
const static std::string KeyDBusActivatable;
const static std::string TypeApplication;
const static std::string TypeLink;
const static std::string TypeDirectory;
const static std::string EnvDesktopEnv;
const static std::string DesktopExt;
const static std::string EnableInvoker;
const static std::string TurboInvokerFailedMsg;
const static std::string TurboInvokerErrMsg;
const static std::string SectionDefaultApps;
const static std::string SectionAddedAssociations;
const static std::string DeepinVendor ;
const static std::string AppMimeTerminal;
};
#endif // APPINFOCOMMON_H

View File

@ -1,24 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "applaunchcontext.h"
AppLaunchContext::AppLaunchContext()
: m_count(0)
, m_timestamp(0)
{
}
// TODO
std::string AppLaunchContext::getStartupNotifyId(const DesktopInfo *info, std::vector<std::string> files)
{
}
// TODO
void AppLaunchContext::launchFailed(std::string startupNotifyId)
{
}

View File

@ -1,42 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef APPLAUNCHCONTEXT_H
#define APPLAUNCHCONTEXT_H
#include <string>
#include <vector>
#include <cstdint>
class DesktopInfo;
class AppLaunchContext
{
public:
AppLaunchContext();
void setEnv(const std::vector<std::string> &value) {m_env = value;}
std::vector<std::string> getEnv() {return m_env;}
void setTimestamp(uint32_t value) {m_timestamp = value;}
uint32_t getTimestamp() {return m_timestamp;}
void setCmdPrefixes(const std::vector<std::string> &value) {m_cmdPrefixes = value;}
std::vector<std::string> getCmdPrefixes() {return m_cmdPrefixes;}
void setCmdSuffixes(const std::vector<std::string> &value) {m_cmdSuffixes = value;}
std::vector<std::string> getCmdSuffixes() {return m_cmdSuffixes;}
std::string getStartupNotifyId(const DesktopInfo *info, std::vector<std::string> files);
void launchFailed(std::string startupNotifyId);
private:
uint m_count;
uint32_t m_timestamp;
std::vector<std::string> m_cmdPrefixes;
std::vector<std::string> m_cmdSuffixes;
std::vector<std::string> m_env;
};
#endif // APPLAUNCHCONTEXT_H

View File

@ -1,157 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "basedir.h"
#include "dfile.h"
#include "dstring.h"
#include <algorithm>
BaseDir::BaseDir()
{
}
std::string BaseDir::homeDir()
{
char *home = getenv("HOME");
if (!home)
return "";
return std::string(home) + "/";
}
std::string BaseDir::userDataDir()
{
// default $HOME/.local/share
std::string home = homeDir();
std::string defaultDir = (home.size() > 0) ? home + ".local/share/" : "";
const char *xdgDataHomePtr = getenv("XDG_DATA_HOME");
if (!xdgDataHomePtr)
return defaultDir;
if (!DFile::isDir(xdgDataHomePtr))
return defaultDir;
return std::string(xdgDataHomePtr) + "/";
}
std::vector<std::string> BaseDir::sysDataDirs()
{
std::vector<std::string> defaultDirs {"/usr/local/share/", "/usr/share/"};
const char *xdgDataDirsPtr = getenv("XDG_DATA_DIRS");
if (!xdgDataDirsPtr)
return defaultDirs;
std::string xdgDataDirsStr(xdgDataDirsPtr);
std::vector<std::string> xdgDataDirs = DString::splitStr(xdgDataDirsStr, ':');
if (xdgDataDirs.size() == 0)
return defaultDirs;
filterNotAbs(xdgDataDirs);
addSuffixSlash(xdgDataDirs);
return xdgDataDirs;
}
std::string BaseDir::userConfigDir()
{
// default $HOME/.config
std::string defaultDir = homeDir() + ".config/";
const char *xdgConfigHomePtr = getenv("XDG_CONFIG_HOME");
if (!xdgConfigHomePtr)
return defaultDir;
std::string xdgConfigHome(xdgConfigHomePtr);
if (!DFile::isDir(xdgConfigHome))
return defaultDir;
return xdgConfigHome + "/";
}
std::vector<std::string> BaseDir::sysConfigDirs()
{
std::vector<std::string> defaultDirs {"/etc/xdg/"};
const char *xdgConfigDirsPtr = getenv("XDG_CONFIG_DIRS");
if (!xdgConfigDirsPtr)
return defaultDirs;
std::string xdgConfigDirsStr(xdgConfigDirsPtr);
std::vector<std::string> xdgConfigDirs = DString::splitStr(xdgConfigDirsStr, ':');
if (xdgConfigDirs.size() == 0)
return defaultDirs;
filterNotAbs(xdgConfigDirs);
addSuffixSlash(xdgConfigDirs);
return xdgConfigDirs;
}
std::string BaseDir::userCacheDir()
{
std::string home = homeDir();
std::string defaultDir = (home.size() > 0) ? home + ".cache/" : "";
const char *xdgCacheHomePtr = getenv("XDG_CACHE_HOME");
if (!xdgCacheHomePtr)
return defaultDir;
std::string xdgCacheHome(xdgCacheHomePtr);
if (!DFile::isDir(xdgCacheHome))
return defaultDir;
return xdgCacheHome + "/";
}
std::string BaseDir::userAppDir()
{
std::string dataDir = userDataDir();
return (dataDir.size() > 0) ? dataDir + "applications/" : "";
}
std::vector<std::string> BaseDir::sysAppDirs()
{
auto dataDirs = sysDataDirs();
std::vector<std::string> sysAppDirs(dataDirs.size());
std::transform(dataDirs.begin(), dataDirs.end(), sysAppDirs.begin(),
[](std::string dir) -> std::string {return dir + "applications/";});
return sysAppDirs;
}
std::vector<std::string> BaseDir::appDirs()
{
std::vector<std::string> appDirs = sysAppDirs();
appDirs.push_back(userAppDir());
return appDirs;
}
std::vector<std::string> BaseDir::autoStartDirs()
{
std::vector<std::string> autoStartDirs = sysConfigDirs();
autoStartDirs.push_back(userConfigDir());
std::transform(autoStartDirs.begin(), autoStartDirs.end(), autoStartDirs.begin(),
[](std::string dir) -> std::string {return dir + "autostart/";});
return autoStartDirs;
}
std::string BaseDir::userAutoStartDir()
{
return userConfigDir() + "autostart/";
}
void BaseDir::filterNotAbs(std::vector<std::string> &dirs)
{
for (auto iter = dirs.begin(); iter != dirs.end();) { // erase element in vector
if (!DFile::isDir(*iter))
iter = dirs.erase(iter);
else
iter++;
}
}
void BaseDir::addSuffixSlash(std::vector<std::string> &dirs)
{
for (auto &dir : dirs) {
if (!DString::endWith(dir, "/"))
dir += "/";
}
}

View File

@ -1,34 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef BASEDIR_H
#define BASEDIR_H
#include <vector>
#include <string>
// 基础目录类, 目录结尾统一包含斜杠/
class BaseDir
{
public:
BaseDir();
static std::string homeDir();
static std::string userDataDir();
static std::vector<std::string> sysDataDirs();
static std::string userConfigDir();
static std::vector<std::string> sysConfigDirs();
static std::string userCacheDir();
static std::string userAppDir();
static std::vector<std::string> sysAppDirs();
static std::vector<std::string> appDirs();
static std::vector<std::string> autoStartDirs();
static std::string userAutoStartDir();
private:
static void filterNotAbs(std::vector<std::string>& dirs);
static void addSuffixSlash(std::vector<std::string>& dirs);
};
#endif // BASEDIR_H

View File

@ -1,42 +0,0 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "desktopfile.h"
DesktopFile::DesktopFile(char separtor)
: KeyFile(separtor)
{
}
DesktopFile::~DesktopFile() = default;
bool DesktopFile::saveToFile(const std::string &filePath){
FILE *sfp = fopen(filePath.data(), "w+");
if (!sfp) {
perror("open file failed...");
return false;
}
// NOTE(black_desk): XDG require the first section of desktop file
// is always "Desktop Entry"
auto mainSection = m_mainKeyMap.find("Desktop Entry");
if (mainSection != m_mainKeyMap.end()) {
// FIXME(black_desk): should handle write fail.
writeSectionToFile(mainSection->first, mainSection->second, sfp);
} else {
// FIXME(black_desk): should have some warning.
}
for (const auto &im : m_mainKeyMap) {
if (im.first == "Desktop Entry") {
continue;
}
// FIXME(black_desk): should handle write fail.
writeSectionToFile(im.first, im.second, sfp);
}
fclose(sfp);
return true;
}

View File

@ -1,24 +0,0 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef DESKTOPFILE_H
#define DESKTOPFILE_H
#include "keyfile.h"
#include <string>
#include <map>
#include <vector>
// 解析desktop文件类
class DesktopFile: public KeyFile
{
public:
explicit DesktopFile(char separtor = ';');
virtual ~DesktopFile();
virtual bool saveToFile(const std::string &filePath) override;
};
#endif // DESKTOPFILE_H

View File

@ -1,411 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "desktopinfo.h"
#include "locale.h"
#include "unistd.h"
#include "dstring.h"
#include "dfile.h"
#include "basedir.h"
#include <QDebug>
#include <algorithm>
#include <stdlib.h>
#include <iostream>
#include <dirent.h>
std::vector<std::string> DesktopInfo::currentDesktops;
DesktopInfo::DesktopInfo(const std::string &_fileName)
: m_isValid(true)
, m_desktopFile()
{
std::string fileNameWithSuffix(_fileName);
if (!DString::endWith(_fileName, ".desktop"))
fileNameWithSuffix += ".desktop";
m_fileName = fileNameWithSuffix;
if (DFile::dir(m_fileName).empty()) {
// fileName是文件名增加目录
bool isExisted = false;
for (const auto &dir : BaseDir::appDirs()) {
m_fileName = dir + fileNameWithSuffix;
if (DFile::isExisted(m_fileName)) {
isExisted = true;
break;
}
}
if (!isExisted) {
m_isValid = false;
return;
}
}
m_desktopFile.loadFile(m_fileName);
// check DesktopInfo valid
std::vector<std::string> mainKeys = m_desktopFile.getMainKeys();
if (mainKeys.size() == 0)
m_isValid = false;
bool found = std::any_of(mainKeys.begin(), mainKeys.end(),
[](const auto &key) {return key == MainSection;});
if (!found)
m_isValid = false;
if (m_desktopFile.getStr(MainSection, KeyType) != TypeApplication)
m_isValid = false;
m_name = m_desktopFile.getLocaleStr(MainSection, KeyName, "");
m_icon = m_desktopFile.getStr(MainSection, KeyIcon);
m_id = getId();
}
DesktopInfo::~DesktopInfo()
{
}
std::string DesktopInfo::getFileName()
{
return m_fileName;
}
bool DesktopInfo::isValidDesktop()
{
return m_isValid;
}
/** if return true, item is shown
* @brief DesktopInfo::shouldShow
* @return
*/
bool DesktopInfo::shouldShow()
{
if (getNoDisplay() || getIsHidden()) {
qDebug() << "hidden desktop file path: " << QString::fromStdString(m_fileName);
return false;
}
std::vector<std::string> desktopEnvs;
return getShowIn(desktopEnvs);
}
bool DesktopInfo::getNoDisplay()
{
return m_desktopFile.getBool(MainSection, KeyNoDisplay);
}
bool DesktopInfo::getIsHidden()
{
return m_desktopFile.getBool(MainSection, KeyHidden);
}
bool DesktopInfo::getShowIn(std::vector<std::string> desktopEnvs)
{
#ifdef QT_DEBUG
qDebug() << "desktop file path: " << QString::fromStdString(m_fileName);
#endif
if (desktopEnvs.size() == 0) {
const char *env = getenv(envDesktopEnv.c_str());
const auto &desktop = DString::splitChars(env, ':');
currentDesktops.assign(desktop.begin(), desktop.end());
desktopEnvs.assign(currentDesktops.begin(), currentDesktops.end());
}
std::vector<std::string> onlyShowIn = m_desktopFile.getStrList(MainSection, KeyOnlyShowIn);
std::vector<std::string> notShowIn = m_desktopFile.getStrList(MainSection, KeyNotShowIn);
#ifdef QT_DEBUG
auto strVector2qstrVector = [](const std::vector<std::string> &vector) {
QVector<QString> vectorString;
for (const std::string &str : vector)
vectorString.append(QString::fromStdString(str));
return vectorString;
};
qDebug() << "onlyShowIn:" << strVector2qstrVector(onlyShowIn) <<
", notShowIn:" << strVector2qstrVector(notShowIn) <<
", desktopEnvs:" << strVector2qstrVector(desktopEnvs);
#endif
for (const auto &desktop : desktopEnvs) {
bool ret = std::any_of(onlyShowIn.begin(), onlyShowIn.end(),
[&desktop](const auto &d) {return d == desktop;});
#ifdef QT_DEBUG
qInfo() << Q_FUNC_INFO << "onlyShowIn, result:" << ret;
#endif
if (ret)
return true;
ret = std::any_of(notShowIn.begin(), notShowIn.end(),
[&desktop](const auto &d) {return d == desktop;});
#ifdef QT_DEBUG
qInfo() << Q_FUNC_INFO << "notShowIn, result:" << ret;
#endif
if (ret)
return false;
}
return onlyShowIn.size() == 0;
}
std::string DesktopInfo::getExecutable()
{
return m_desktopFile.getStr(MainSection, KeyExec);
}
bool DesktopInfo::isExecutableOk()
{
// 检查TryExec字段
std::string value = getTryExec();
std::vector<std::string> parts = DString::splitStr(value, ' ');
if (parts.size() > 0 ) {
value.assign(parts[0]);
DString::delQuote(value);
if (strstr(value.c_str(), "/") && DFile::isExisted(value))
return true;
else
return findExecutable(value);
}
// 检查Exec字段
value.assign(getExecutable());
parts.clear();
parts = DString::splitStr(value, ' ');
if (parts.size() > 0) {
value.assign(parts[0]);
DString::delQuote(value);
if (strstr(value.c_str(), "/") && DFile::isExisted(value))
return true;
else
return findExecutable(value);
}
return false;
}
bool DesktopInfo::isInstalled()
{
const char *name = m_fileName.c_str();
const char *found = strstr(name, "/applications/");
if (!found)
return false;
auto appDirs = BaseDir::appDirs();
return std::any_of(appDirs.begin(), appDirs.end(),
[&name, &found] (std::string dir) -> bool {return strneq(dir.c_str(), name, size_t(found - name));});
}
// [Desktop Action new-window] or [Full_Screenshot Shortcut Group]
bool DesktopInfo::isDesktopAction(std::string name)
{
return DString::startWith(name.c_str(), "Desktop Action") || DString::endWith(name.c_str(), "Shortcut Group");
}
std::vector<DesktopAction> DesktopInfo::getActions()
{
std::vector<DesktopAction> actions;
for (const auto &mainKey : m_desktopFile.getMainKeys()) {
if (DString::startWith(mainKey, "Desktop Action")
|| DString::endWith(mainKey, "Shortcut Group")) {
DesktopAction action;
action.name = m_desktopFile.getLocaleStr(mainKey, KeyName, "");
action.exec = m_desktopFile.getStr(mainKey, KeyExec);
action.section = mainKey;
actions.push_back(action);
}
}
return actions;
}
// 使用appId获取DesktopInfo需检查有效性
DesktopInfo DesktopInfo::getDesktopInfoById(std::string appId)
{
if (!DString::endWith(appId, ".desktop"))
appId += ".desktop";
for (const auto & dir : BaseDir::appDirs()) {
std::string filePath = dir + appId;
//检测文件有效性
if (DFile::isExisted(filePath)) {
return DesktopInfo(filePath);
}
}
return DesktopInfo("");
}
bool DesktopInfo::getTerminal()
{
return m_desktopFile.getBool(MainSection, KeyTerminal);
}
// TryExec is Path to an executable file on disk used to determine if the program is actually installed
std::string DesktopInfo::getTryExec()
{
return m_desktopFile.getStr(MainSection, KeyTryExec);
}
// 按$PATH路径查找执行文件
bool DesktopInfo::findExecutable(std::string &exec)
{
static const char *path = getenv("PATH");
static std::vector<std::string> paths = DString::splitChars(path, ':');
return std::any_of(paths.begin(), paths.end(), [&exec](std::string path) {return DFile::isExisted(path + "/" +exec);});
}
/**
* @brief DesktopInfo::getId
* filename must has suffix desktopExt
* example:
* /usr/share/applications/a.desktop -> a
* /usr/share/applications/kde4/a.desktop -> kde4/a
* /xxxx/dir/a.desktop -> /xxxx/dir/a
* @return
*/
std::string DesktopInfo::getId()
{
if (!m_id.empty())
return m_id;
std::string idStr;
auto const suffixPos = m_fileName.find(".desktop");
if (suffixPos == std::string::npos)
return "";
idStr = m_fileName.substr(0, m_fileName.size() - 8); // trim suffix
size_t dirPos = idStr.find("/applications/");
if (dirPos == std::string::npos)
return idStr;
std::string baseDir(idStr.substr(0, dirPos + 14)); // length of "/applications/" is 14
std::vector<std::string> appDirs = BaseDir::appDirs();
bool installed = std::any_of(appDirs.begin(), appDirs.end(),
[&baseDir](const auto &dir) {return dir == baseDir;});
if (installed) {
m_id = idStr.substr(baseDir.size(), idStr.size());
}
return m_id;
}
std::string DesktopInfo::getGenericName()
{
return m_desktopFile.getLocaleStr(MainSection, KeyGenericName, "");
}
std::string DesktopInfo::getName()
{
return m_name;
}
std::string DesktopInfo::getIcon()
{
return m_icon;
}
std::string DesktopInfo::getCommandLine()
{
return m_desktopFile.getStr(MainSection, KeyExec);
}
std::vector<std::string> DesktopInfo::getKeywords()
{
return m_desktopFile.getLocaleStrList(MainSection, KeyKeywords, "");
}
std::vector<std::string> DesktopInfo::getCategories()
{
return m_desktopFile.getStrList(MainSection, KeyCategories);
}
void DesktopInfo::setDesktopOverrideExec(const std::string &execStr)
{
m_overRideExec = execStr;
}
DesktopFile *DesktopInfo::getDesktopFile()
{
return &m_desktopFile;
}
// class AppsDir
AppsDir::AppsDir(const std::string &dirPath)
: m_path(dirPath)
{
}
AppsDir::~AppsDir()
{
}
std::string AppsDir::getPath()
{
return m_path;
}
// 获取目录对应的应用名称
std::map<std::string, bool> AppsDir::getAppNames()
{
DIR* dp;
struct dirent* ep;
dp = opendir(m_path.c_str());
if (!dp) {
std::cout << "Couldn't open directory " << m_path << std::endl;
return m_appNames;
}
while ((ep = readdir(dp))) {
if (ep->d_type != DT_REG && ep->d_type != DT_LNK)
continue;
if (!DString::endWith(ep->d_name, ".desktop"))
continue;
m_appNames.insert({ep->d_name, true});
}
closedir(dp);
return m_appNames;
}
// 获取所有应用信息
std::vector<DesktopInfo> AppsDir::getAllDesktopInfos()
{
std::vector<DesktopInfo> desktopInfos;
for (auto dir : BaseDir::appDirs()) {
AppsDir appsDir(dir);
std::map<std::string, bool> appNames = appsDir.getAppNames();
if (appNames.size() == 0)
continue;
for (const auto &iter : appNames) {
std::string filePath = dir + iter.first;
DesktopInfo desktopInfo(filePath);
if (!DFile::isExisted(filePath) || !desktopInfo.isValidDesktop() || !desktopInfo.shouldShow()) {
qDebug() << QString("app item %1 doesn't show in the list..").arg(QString::fromStdString(filePath));
continue;
}
desktopInfos.push_back(desktopInfo);
}
}
return desktopInfos;
}

View File

@ -1,117 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef DESKTOPINFO_H
#define DESKTOPINFO_H
#include "desktopfile.h"
#include <string>
#include <vector>
const std::string MainSection = "Desktop Entry";
const std::string KeyType = "Type";
const std::string KeyVersion = "Version";
const std::string KeyName = "Name";
const std::string KeyGenericName = "GenericName";
const std::string KeyNoDisplay = "NoDisplay";
const std::string KeyComment = "Comment";
const std::string KeyIcon = "Icon";
const std::string KeyHidden = "Hidden";
const std::string KeyOnlyShowIn = "OnlyShowIn";
const std::string KeyNotShowIn = "NotShowIn";
const std::string KeyTryExec = "TryExec";
const std::string KeyExec = "Exec";
const std::string KeyPath = "Path";
const std::string KeyTerminal = "Terminal";
const std::string KeyMimeType = "MimeType";
const std::string KeyCategories = "Categories";
const std::string KeyKeywords = "Keywords";
const std::string KeyStartupNotify = "StartupNotify";
const std::string KeyStartupWMClass = "StartupWMClass";
const std::string KeyURL = "URL";
const std::string KeyActions = "Actions";
const std::string KeyDBusActivatable = "DBusActivatable";
const std::string TypeApplication = "Application";
const std::string TypeLink = "Link";
const std::string TypeDirectory = "Directory";
const std::string envDesktopEnv = "XDG_CURRENT_DESKTOP";
typedef struct DesktopAction
{
DesktopAction()
: section("")
, name("")
, exec("")
{
}
std::string section;
std::string name;
std::string exec;
} DesktopAction;
// 应用Desktop信息类
class DesktopInfo {
public:
explicit DesktopInfo(const std::string &_fileName);
~DesktopInfo();
std::string getFileName();
std::string getExecutable();
bool isValidDesktop();
bool shouldShow();
bool getNoDisplay();
bool getIsHidden();
bool getShowIn(std::vector<std::string> desktopEnvs);
bool isExecutableOk();
bool isInstalled();
static bool isDesktopAction(std::string name);
std::vector<DesktopAction> getActions();
static DesktopInfo getDesktopInfoById(std::string appId);
bool getTerminal();
std::string getId();
std::string getGenericName();
std::string getName();
std::string getIcon();
std::string getCommandLine();
std::vector<std::string> getKeywords();
std::vector<std::string> getCategories();
void setDesktopOverrideExec(const std::string &execStr);
DesktopFile *getDesktopFile();
private:
std::string getTryExec();
bool findExecutable(std::string &exec);
static std::vector<std::string> currentDesktops;
std::string m_fileName;
std::string m_id;
std::string m_name;
std::string m_icon;
std::string m_overRideExec;
bool m_isValid;
DesktopFile m_desktopFile;
};
// 应用目录类
class AppsDir {
public:
explicit AppsDir(const std::string &dirPath);
~AppsDir();
std::string getPath();
std::map<std::string, bool> getAppNames();
static std::vector<DesktopInfo> getAllDesktopInfos();
private:
std::string m_path;
std::map<std::string, bool> m_appNames;
};
#endif // DESKTOPINFO_H

View File

@ -1,91 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "dfile.h"
#include "macro.h"
#include "dstring.h"
#include <sys/stat.h>
#include <unistd.h>
#include <cstring>
DFile::DFile()
{
}
// 符号连接
bool DFile::isLink(std::string file)
{
if (file.empty())
return false;
struct stat fileStat;
if (!stat(file.c_str(), &fileStat))
return S_ISLNK(fileStat.st_mode);
return false;
}
bool DFile::isRegularFile(std::string file)
{
if (file.empty())
return false;
struct stat fileStat;
if (!stat(file.c_str(), &fileStat))
return S_ISREG(fileStat.st_mode);
return true;
}
bool DFile::isDir(std::string dir)
{
if (dir.empty())
return false;
struct stat fileStat;
if (!stat(dir.c_str(), &fileStat))
return S_ISDIR(fileStat.st_mode);
return false;
}
bool DFile::isExisted(std::string file)
{
return !access(file.c_str(), F_OK);
}
std::string DFile::dir(std::string path)
{
std::string ret;
if (isDir(path)) {
ret = path;
} else {
size_t pos = path.find_last_of("/");
if (pos != std::string::npos) {
ret.assign(path, 0, pos + 1); // 包含结尾斜杠/
}
}
return ret;
}
std::string DFile::base(std::string file)
{
std::string ret;
if (strstr(file.c_str(), "/")) { // 包含路径
size_t pos = file.find_last_of("/");
if (pos != std::string::npos) {
ret.assign(file, pos + 1, file.size() - pos); // 去除路径
}
}
size_t pos = file.find_last_of("."); // 去除后缀
if (pos != std::string::npos) {
ret.assign(file, 0, pos + 1);
}
return ret;
}

View File

@ -1,22 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef DFILE_H
#define DFILE_H
#include <string>
class DFile
{
public:
explicit DFile();
static bool isLink(std::string file);
static bool isRegularFile(std::string file);
static bool isDir(std::string dir);
static bool isExisted(std::string file);
static std::string dir(std::string path);
static std::string base(std::string file);
};
#endif // DFILE_H

View File

@ -1,193 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "dlocale.h"
#include "dstring.h"
#include <stdlib.h>
#include <pthread.h>
#define ComponentCodeset 1
#define ComponentTerritory 2
#define ComponentModifier 4
#define MAXLINELEN 256
const char *aliasFile = "/usr/share/locale/locale.alias";
const char charUscore = '_';
const char charDot = '.';
const char charAt = '@';
Locale::Locale()
{
pthread_mutex_init(&m_languageNames.mutex, nullptr);
// init aliases
FILE *fp = fopen(aliasFile, "r");
if (fp) {
char data[MAXLINELEN] = {0};
std::string line;
std::vector<std::string> parts;
while (fgets(data, MAXLINELEN, fp)) {
char *start = &data[0];
char *end = start;
// 移除行首
while (strneq(start, " ", 1) || strneq(start, "\t", 1))
start++;
// 过滤注释行和空行
if (strneq(start, "#", 1) || strneq(start, "\n", 1))
continue;
while (!strneq(end, "\n", 1))
end++;
// 移除行尾
while (strneq(end, "\n", 1) || strneq(end, "\r", 1)
|| strneq(end, " ", 1) || strneq(end, "\t", 1))
end--;
line.assign(start, ulong(end - start + 1));
parts = DString::splitStr(line, ' ');
// 使用\t分割
if (parts.size() != 2)
parts = DString::splitStr(line, '\t');
if (parts.size() == 2) {
m_aliases[parts[0]] = parts[1];
}
}
fclose(fp);
}
}
/**
* @brief Locale::explodeLocale 拆分locale
* @param locale
* @return
*/
Locale::Components Locale::explodeLocale(std::string locale)
{
Components cmp;
std::vector<std::string> parts;
if (locale.find(charAt) != std::string::npos) {
parts = DString::splitStr(locale, charAt);
if (parts.size() == 2) {
cmp.modifier = parts[1];
locale = parts[0];
cmp.mask |= ComponentModifier;
}
}
if (locale.find(charDot) != std::string::npos) {
parts = DString::splitStr(locale, charDot);
if (parts.size() == 2) {
cmp.codeset = parts[1];
locale = locale[0];
cmp.mask |= ComponentCodeset;
}
}
if (locale.find(charUscore) != std::string::npos) {
parts = DString::splitStr(locale, charUscore);
if (parts.size() == 2) {
cmp.territory = parts[1];
locale = parts[0];
cmp.mask |= ComponentTerritory;
}
}
cmp.language = locale;
return cmp;
}
std::string Locale::guessCategoryValue(std::string categoryName)
{
// The highest priority value is the 'LANGUAGE' environment
// variable. This is a GNU extension.
const char *language = getenv("LANGUAGE");
if (language)
return language;
// Setting of LC_ALL overwrites all other.
const char *lcAll = getenv("LC_ALL");
if (lcAll)
return lcAll;
// Next comes the name of the desired category.
const char *name = getenv(categoryName.c_str());
if (name)
return name;
// Last possibility is the LANG environment variable.
const char *lang = getenv("LANG");
if (lang)
return lang;
return "C";
}
std::string Locale::unaliasLang(std::string lang)
{
if (m_aliases.find(lang) != m_aliases.end())
return m_aliases[lang];
else
return lang;
}
/**
* @brief Locale::getLocaleVariants
* @param locale
* @return
*/
std::vector<std::string> Locale::getLocaleVariants(const std::string &locale)
{
auto cmp = explodeLocale(locale);
uint mask = cmp.mask;
std::vector<std::string> variants;
for (uint i = 0; i <= mask; i++) {
uint j = mask - i;
//if ((j & ^mask) == 0) {
std::string var(cmp.language);
if (j & ComponentTerritory)
var = var + charUscore + cmp.territory;
if (j & ComponentCodeset)
var = var + charDot + cmp.codeset;
if (j & ComponentModifier)
var = var + charAt + cmp.modifier;
variants.push_back(var);
//}
}
return variants;
}
std::vector<std::string> Locale::getLanguageNames()
{
std::vector<std::string> names;
std::string value(guessCategoryValue("LC_MESSAGES"));
if (value.empty()) {
names.push_back(value);
return names;
}
pthread_mutex_lock(&m_languageNames.mutex);
if (m_languageNames.language != value) {
m_languageNames.language = value;
m_languageNames.names.clear();
std::vector<std::string> langs = DString::splitStr(value, ':');
for (const auto & lang : langs) {
std::vector<std::string> localeVariant = getLocaleVariants(unaliasLang(lang));
for (const auto & var : localeVariant)
m_languageNames.names.push_back(var);
}
m_languageNames.names.push_back("C");
}
pthread_mutex_unlock(&m_languageNames.mutex);
return m_languageNames.names;
}

View File

@ -1,49 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef LOCALE_H
#define LOCALE_H
#include <string>
#include <vector>
#include <map>
// 本地化类
class Locale {
struct LanguageNameCache {
std::string language;
std::vector<std::string> names;
pthread_mutex_t mutex;
};
struct Components {
Components() : mask(0) {} // 数字必须初始化
std::string language;
std::string territory;
std::string codeset;
std::string modifier;
uint mask;
};
public:
std::vector<std::string> getLocaleVariants(const std::string &locale);
std::vector<std::string> getLanguageNames();
static inline Locale *instance() {
static Locale instance;
return &instance;
}
private:
Locale();
Locale(const Locale &);
Locale& operator= (const Locale &);
Components explodeLocale(std::string locale);
std::string guessCategoryValue(std::string categoryName);
std::string unaliasLang(std::string);
std::map<std::string, std::string> m_aliases;
LanguageNameCache m_languageNames;
};
#endif

View File

@ -1,122 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "dstring.h"
DString::DString()
{
}
DString::~DString()
{
}
std::vector<std::string> DString::splitChars(const char *cs, char c)
{
std::vector<std::string> ret;
if (!cs) {
return ret;
}
unsigned long idx = 0;
unsigned long size = strlen(cs);
bool found = false;
std::string sub;
for (unsigned long i=0; i < size; i++) {
if (!strneq(&cs[i], &c, 1))
continue;
sub.assign(cs, found ? idx+1:idx, found ? i-idx-1:i-idx);
if (idx < i && !sub.empty()) {
ret.push_back(sub);
}
idx = i;
found = true;
}
sub.assign(cs, found ? idx+1:idx, found ? size-idx-1:size-idx);
if (idx < size && !sub.empty()) {
ret.push_back(sub);
}
return ret;
}
std::vector<std::string> DString::splitStr(const std::string &str, char c)
{
return splitChars(str.c_str(), c);
}
bool DString::startWith(const char *chars, const char *prefix)
{
if (!chars || !prefix) {
return false;
}
size_t len;
len = strlen(prefix);
return strneq(chars, prefix, len);
}
bool DString::startWith(const std::string &str, const std::string &prefix)
{
return startWith(str.c_str(), prefix.c_str());
}
bool DString::endWith(const char *chars, const char *suffix)
{
if (!chars || !suffix) {
return false;
}
size_t charsLen = strlen(chars);
size_t suffixLen = strlen(suffix);
if (charsLen == 0 || charsLen < suffixLen)
return false;
return memcmp(chars + charsLen - suffixLen, suffix, suffixLen) == 0;
}
bool DString::endWith(const std::string &str, const std::string &suffix)
{
return endWith(str.c_str(), suffix.c_str());
}
char *DString::delQuote(const char *chars)
{
char *data = nullptr;
if (!chars)
return data;
if (strneq(chars, "\"", 1) && strneq(chars + strlen(chars) - 1, "\"", 1)) {
data = static_cast<char *>(calloc(1, strlen(chars) - 2));
memcpy(data, chars + 1, strlen(chars) - 1);
} else {
data = static_cast<char *>(calloc(1, strlen(chars) + 1));
memcpy(data, chars, strlen(chars) + 1);
}
return data;
}
void DString::delQuote(std::string &str)
{
while (*str.begin() == '\"' && *str.rbegin() == '\"')
str.assign(str.substr(1, str.size() - 2));
}
std::string DString::join(std::vector<std::string> strs, std::string joinStr)
{
std::string ret;
for (uint i = 0; i < strs.size(); i++) {
if (i < strs.size() - 1) {
ret += strs[i] + joinStr;
} else {
ret += strs[i];
}
}
return ret;
}

View File

@ -1,40 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef DSTRING_H
#define DSTRING_H
#include <vector>
#include <string>
#include <cstring>
#define streq(a,b) (strcmp((a),(b)) == 0)
#define strneq(a, b, n) (strncmp((a), (b), (n)) == 0)
#define strcaseeq(a,b) (strcasecmp((a),(b)) == 0)
#define strncaseeq(a, b, n) (strncasecmp((a), (b), (n)) == 0)
// 字符串操作
class DString
{
public:
DString();
~DString();
// 字符串拆分
static std::vector<std::string> splitChars(const char *cs, char c);
static std::vector<std::string> splitStr(const std::string &str, char c);
// 字符串前缀判断
static bool startWith(const char *chars, const char *prefix);
static bool startWith(const std::string &str, const std::string &prefix);
// 字符后缀判断
static bool endWith(const char *chars, const char *suffix);
static bool endWith(const std::string &str, const std::string &suffix);
// 去除首尾引用
static char *delQuote(const char *chars);
static void delQuote(std::string &str);
// 连接字符串
static std::string join(std::vector<std::string> strs, std::string joinStr);
};
#endif // DSTRING_H

View File

@ -1,89 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "gsetting.h"
#include <iostream>
GSetting::GSetting(std::string settings)
: m_gs(nullptr)
, m_settings(settings)
{
m_gs = g_settings_new(m_settings.c_str());
if (!m_gs) {
std::cout << "GSetting: g_settings_new error" << std::endl;
}
}
GSetting::~GSetting()
{
if (m_gs) {
g_object_unref(m_gs);
m_gs = nullptr;
}
}
std::string GSetting::getString(std::string key)
{
std::string ret;
if (m_gs) {
ret = g_settings_get_string(m_gs, key.c_str());
}
return ret;
}
void GSetting::setString(std::string key, std::string value)
{
if (m_gs) {
g_settings_set_string(m_gs, key.c_str(), value.c_str());
}
}
int GSetting::getInt(std::string key)
{
int ret = 0;
if (m_gs) {
ret = g_settings_get_int(m_gs, key.c_str());
}
return ret;
}
void GSetting::setInt(std::string key, int value)
{
if (m_gs) {
g_settings_set_int(m_gs, key.c_str(), value);
}
}
double GSetting::getDouble(std::string key)
{
double ret = 0;
if (m_gs) {
ret = g_settings_get_double(m_gs, key.c_str());
}
return ret;
}
void GSetting::setDouble(std::string key, double value)
{
if (m_gs) {
g_settings_set_double(m_gs, key.c_str(), value);
}
}
bool GSetting::getBool(std::string key)
{
bool ret = false;
if (m_gs) {
ret = g_settings_get_boolean(m_gs, key.c_str());
}
return ret;
}
void GSetting::setBool(std::string key, bool value)
{
if (m_gs) {
g_settings_set_double(m_gs, key.c_str(), value);
}
}

View File

@ -1,34 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef GSETTING_H
#define GSETTING_H
#include <string>
#include <gio/gio.h>
class GSetting
{
public:
explicit GSetting(std::string settings);
~GSetting();
std::string getString(std::string key);
void setString(std::string key, std::string value);
int getInt(std::string key);
void setInt(std::string key, int value);
double getDouble(std::string key);
void setDouble(std::string key, double value);
bool getBool(std::string key);
void setBool(std::string key, bool value);
private:
GSettings *m_gs;
std::string m_settings;
};
#endif // GSETTING_H

View File

@ -1,306 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "keyfile.h"
#include "dlocale.h"
#include "dstring.h"
#include "macro.h"
#include <cstring>
#include <fstream>
#include <string>
#include <iostream>
#include <algorithm>
KeyFile::KeyFile(char separtor)
: m_modified(false)
, m_listSeparator(separtor)
{
}
KeyFile::~KeyFile()
{
}
bool KeyFile::getBool(const std::string &section, const std::string &key, bool defaultValue)
{
if (m_mainKeyMap.find(section) == m_mainKeyMap.end())
return false;
std::string valueStr = m_mainKeyMap[section][key];
bool value = defaultValue;
if (valueStr == "true")
value = true;
else if (valueStr == "false")
value = false;
return value;
}
void KeyFile::setBool(const std::string &section, const std::string &key, const std::string &defaultValue)
{
if (m_mainKeyMap.find(section) == m_mainKeyMap.end())
m_mainKeyMap.insert({section, KeyMap()});
m_mainKeyMap[section][key] = defaultValue;
}
// TODO
std::vector<bool> KeyFile::getBoolList(const std::string &section, const std::string &key, bool defaultValue)
{
std::vector<bool> tmp;
return tmp;
}
int KeyFile::getInt(const std::string &section, const std::string &key, int defaultValue)
{
if (m_mainKeyMap.find(section) == m_mainKeyMap.end())
return defaultValue;
std::string valueStr = m_mainKeyMap[section][key];
int value;
try {
value = std::stoi(valueStr);
} catch (std::invalid_argument&) {
value = defaultValue;
}
return value;
}
// TODO
std::vector<int> KeyFile::getIntList(const std::string &section, const std::string &key, int defaultValue)
{
std::vector<int> tmp;
return tmp;
}
// TODO
int64_t KeyFile::getInt64(const std::string &section, const std::string &key, int64_t defaultValue)
{
return int64_t(0);
}
// TODO
uint64_t KeyFile::getUint64(const std::string &section, const std::string &key, int64_t defaultValue)
{
return uint64_t(0);
}
// TODO
float KeyFile::getFloat(const std::string &section, const std::string &key, float defaultValue)
{
return 1.0;
}
std::string KeyFile::getStr(const std::string &section, const std::string &key, std::string defaultValue)
{
if (m_mainKeyMap.find(section) == m_mainKeyMap.end())
return defaultValue;
std::string valueStr = m_mainKeyMap[section][key];
if (valueStr.empty())
valueStr = defaultValue;
return valueStr;
}
bool KeyFile::containKey(const std::string &section, const std::string &key)
{
if (m_mainKeyMap.find(section) == m_mainKeyMap.end())
return false;
return m_mainKeyMap[section].find(key) != m_mainKeyMap[section].end();
}
std::string KeyFile::getLocaleStr(const std::string &section, const std::string &key, std::string defaultLocale)
{
std::vector<std::string> languages = defaultLocale.empty()
? Locale::instance()->getLanguageNames()
: Locale::instance()->getLocaleVariants(defaultLocale);
std::string translated;
for (const auto &lang : languages) {
translated.assign(getStr(section, key + "[" + lang + "]"));
if (!translated.empty())
return translated;
}
// NOTE: not support key Gettext-Domain
// fallback to default key
return getStr(section, key);
}
std::vector<std::string> KeyFile::getStrList(const std::string &section, const std::string &key)
{
std::string value = getStr(section, key);
return DString::splitStr(value, m_listSeparator);
}
std::vector<std::string> KeyFile::getLocaleStrList(const std::string &section, const std::string &key, std::string defaultLocale)
{
std::vector<std::string> languages = defaultLocale.empty()
? Locale::instance()->getLanguageNames()
: Locale::instance()->getLocaleVariants(defaultLocale);
std::vector<std::string> translated;
for (const auto &lang : languages) {
translated = getStrList(section, key + "[" + lang + "]");
if (translated.size() > 0)
return translated;
}
//fallback to default key
return getStrList(section, key);
}
// 修改keyfile内容
void KeyFile::setKey(const std::string &section, const std::string &key, const std::string &value)
{
if (m_mainKeyMap.find(section) == m_mainKeyMap.end())
m_mainKeyMap.insert({section, KeyMap()});
m_mainKeyMap[section][key] = value;
}
// 写入文件
bool KeyFile::saveToFile(const std::string &filePath)
{
FILE *sfp = fopen(filePath.data(), "w+");
if (!sfp) {
perror("open file failed...");
return false;
}
for (const auto &im : m_mainKeyMap) {
if (!writeSectionToFile(im.first, im.second,sfp)){
return false;
}
}
fclose(sfp);
return true;
}
bool KeyFile::writeSectionToFile(const std::string& sectionName, const KeyMap& keyMap, FILE * file){
if (file == nullptr) {
return false;
}
std::string section = "[" + sectionName + "]\n";
fputs(section.c_str(), file);
for (const auto &ik : keyMap) {
std::string kv = ik.first + "=" + ik.second + "\n";
fputs(kv.c_str(), file);
}
// FIXME(black_desk): should handle fputs error
return true;
}
bool KeyFile::loadFile(const std::string &filePath)
{
m_mainKeyMap.clear();
std::string lastSection;
std::ifstream fs(filePath);
if (!fs.is_open()) {
perror("open file failed: ");
return false;
}
std::string line;
while (std::getline(fs, line)) {
line.erase(
line.begin(),
std::find_if(
line.begin(), line.end(),
std::not1(std::ptr_fun<int, int>(std::isspace))
)
);
if (line.front() == '#') {
continue;
}
line.erase(
std::find_if(
line.rbegin(), line.rend(),
std::not1(std::ptr_fun<int, int>(std::isspace))
).base(),
line.end()
);
if (line.front() == '[') {
auto rPos = line.find_first_of(']');
if ( rPos != std::string::npos && 0 < rPos ) {
// TODO(black_desk): lastSection might be empty string here.
// I cannot found a spec for the space before groupname in
// freedesktop.org
lastSection = line.substr(1, rPos-1);
m_mainKeyMap.insert({
lastSection,
KeyMap()
});
}
continue;
}
auto equalPos = line.find_first_of('=');
if (equalPos == std::string::npos) {
continue;
}
// 文件格式错误
if (lastSection.empty()) {
std::cout << "failed to load file " << filePath << std::endl;
return false;
}
// 子键
// TODO(black_desk): we should check chars in key here, as spec says
// that it can only contain a-z0-9A-Z
std::string key = line.substr(0, equalPos);
std::string value = equalPos + 1 < line.length() ?
line.substr(equalPos + 1) :
"";
// TODO(black_desk): space after value is removed before. But I cannot
// find a spec about this behavior.
m_mainKeyMap[lastSection][key] = value;
}
m_filePath = filePath;
return true;
}
std::vector<std::string> KeyFile::getMainKeys()
{
std::vector<std::string> mainKeys;
for (const auto &iter : m_mainKeyMap)
mainKeys.push_back(iter.first);
return mainKeys;
}
void KeyFile::print()
{
std::cout << "sectionMap: " << std::endl;
for (auto sectionMap : m_mainKeyMap) {
std::cout << "section=" << sectionMap.first << std::endl;
KeyMap keyMap = sectionMap.second;
for (auto iter : keyMap) {
std::cout << iter.first << "=" << iter.second << std::endl;
}
std::cout << std::endl;
}
}

View File

@ -1,58 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef KEYFILE_H
#define KEYFILE_H
#include <string>
#include <map>
#include <vector>
#include <cstdint>
typedef std::map<std::string, std::string> KeyMap;
typedef std::map<std::string, KeyMap> MainKeyMap;
// 解析ini文件类
class KeyFile
{
public:
explicit KeyFile(char separtor = ';');
virtual ~KeyFile();
bool getBool(const std::string &section, const std::string &key, bool defaultValue = false);
void setBool(const std::string &section, const std::string &key, const std::string &defaultValue = "false");
std::vector<bool> getBoolList(const std::string &section, const std::string &key, bool defaultValue = false);
int getInt(const std::string &section, const std::string &key, int defaultValue = 0);
std::vector<int> getIntList(const std::string &section, const std::string &key, int defaultValue = 0);
int64_t getInt64(const std::string &section, const std::string &key, int64_t defaultValue = 0);
uint64_t getUint64(const std::string &section, const std::string &key, int64_t defaultValue = 0);
float getFloat(const std::string &section, const std::string &key, float defaultValue = 0);
std::string getStr(const std::string &section, const std::string &key, std::string defaultValue = "");
bool containKey(const std::string &section, const std::string &key);
std::string getLocaleStr(const std::string &section, const std::string &key, std::string defaultLocale = "");
std::vector<std::string> getStrList(const std::string &section, const std::string &key);
std::vector<std::string> getLocaleStrList(const std::string &section, const std::string &key, std::string defaultLocale = "");
void setKey(const std::string &section, const std::string &key, const std::string &value);
virtual bool saveToFile(const std::string &filePath);
bool loadFile(const std::string &filePath);
std::vector<std::string> getMainKeys();
std::string getFilePath()
{
return m_filePath;
}
// for test
void print();
protected:
MainKeyMap m_mainKeyMap; // section -> key : value
std::string m_filePath;
bool m_modified;
char m_listSeparator;
static bool writeSectionToFile(const std::string& sectionName, const KeyMap& keyMap, FILE * file);
};
#endif // KEYFILE_H

View File

@ -1,55 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef LANG_H
#define LANG_H
#include "dstring.h"
#include <stdlib.h>
#include <cstring>
#include <string>
#include <vector>
#include <array>
// 返回用户语言,参见man gettext
inline std::vector<std::string> queryLangs() {
std::vector<std::string> ret;
const char *lcAll = getenv("LC_ALL");
const char *lcMessage = getenv("LC_MESSAGE");
const char *language = getenv("LANGUAGE");
const char *lang = getenv("LANG");
auto cutOff = [](std::string str)->std::string {
size_t idx = str.find(".");
if (idx == std::string::npos)
return str;
return std::string(str).substr(0, idx);
};
if (lcAll && std::string(lcAll) != "C"
&& language && std::string(language) != "")
{
std::vector<std::string> splits = DString::splitChars(language, ':');
for (const auto &l : splits) {
ret.push_back(cutOff(l));
}
return ret;
}
if (lcAll && std::string(lcAll) != "")
ret.push_back(cutOff(lcAll));
if (lcMessage && std::string(lcMessage) != "")
ret.push_back(cutOff(lcMessage));
if (lang && std::string(lang) != "")
ret.push_back(cutOff(lang));
return ret;
}
#endif // LANG_H

View File

@ -1,18 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef MACRO_H
#define MACRO_H
#define _likely_(x) (__builtin_expect(!!(x), 1))
#define _unlikely_(x) (__builtin_expect(!!(x), 0))
#define MAX(x, y) (x) > (y) ? (x) : (y)
#define MIN(x, y) (x) < (y) ? (x) : (y)
#define MAX_FILEPATH_LEN 256
#define MAX_LINE_LEN 256
#endif // MACRO_H

View File

@ -1,72 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "meminfo.h"
#include "macro.h"
#include "dstring.h"
#include <stdio.h>
#include <string>
#include <vector>
MemInfo::MemInfo()
{
}
MemoryInfo MemInfo::getMemoryInfo()
{
MemoryInfo ret;
FILE *fp = fopen("/proc/meminfo", "r");
if (!fp)
return ret;
char line[MAX_LINE_LEN] = {0};
while (fgets(line, MAX_LINE_LEN, fp)) {
std::string info(line);
std::vector<std::string> parts = DString::splitStr(info, ':');
if (parts.size() != 2)
continue;
uint64_t num = std::stoll(parts[1]);
if (parts[0] == "MemTotal") {
ret.memTotal = num;
} else if (parts[0] == "MemFree") {
ret.memFree = num;
} else if (parts[0] == "MemAvailable") {
ret.memAvailable = num;
} else if (parts[0] == "Buffers") {
ret.buffers = num;
} else if (parts[0] == "Cached") {
ret.cached = num;
} else if (parts[0] == "SwapTotal") {
ret.swapTotal = num;
} else if (parts[0] == "SwapFree") {
ret.swapFree = num;
} else if (parts[0] == "SwapCached") {
ret.swapCached = num;
}
}
fclose(fp);
return ret;
}
// IsSufficient check the memory whether reaches the qualified value
bool MemInfo::isSufficient(uint64_t minMemAvail, uint64_t maxSwapUsed)
{
if (minMemAvail == 0)
return true;
MemoryInfo info = getMemoryInfo();
uint64_t used = info.swapTotal - info.swapFree - info.swapCached;
if (info.memAvailable < minMemAvail)
return false;
if (maxSwapUsed == 0 || info.memAvailable > used)
return true;
return used < maxSwapUsed;
}

View File

@ -1,33 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef MEMINFO_H
#define MEMINFO_H
#include <stdint.h>
// MemoryInfo show the current memory stat, sum by kb
struct MemoryInfo
{
uint64_t memTotal;
uint64_t memFree;
uint64_t memAvailable;
uint64_t buffers;
uint64_t cached;
uint64_t swapTotal;
uint64_t swapFree;
uint64_t swapCached;
};
class MemInfo
{
public:
MemInfo();
static MemoryInfo getMemoryInfo();
static bool isSufficient(uint64_t minMemAvail, uint64_t maxSwapUsed);
};
#endif // MEMINFO_H

View File

@ -1,183 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "process.h"
#include "macro.h"
#include "dstring.h"
#include "dfile.h"
#include <algorithm>
#include <fstream>
#include <dirent.h>
#include <unistd.h>
#define FILECONTENLEN 2048
Process::Process()
: m_pid(0)
, m_ppid(0)
{
}
Process::Process(int _pid)
: m_pid(_pid)
, m_ppid(0)
{
}
bool Process::isExist()
{
std::string procDir = "/proc/" + std::to_string(m_pid);
return DFile::isExisted(procDir);
}
std::vector<std::string> Process::getCmdLine()
{
if (m_cmdLine.size() == 0) {
std::string cmdlineFile = getFile("cmdline");
m_cmdLine = readFile(cmdlineFile);
}
return m_cmdLine;
}
std::string Process::getCwd()
{
if (m_cwd.empty()) {
std::string cwdFile = getFile("cwd");
char path[MAX_FILEPATH_LEN] = {};
ssize_t len = readlink(cwdFile.c_str(), path, MAX_FILEPATH_LEN);
if (len > 0 && len < MAX_FILEPATH_LEN) {
m_cwd = std::string(path) + "/";
}
}
return m_cwd;
}
std::string Process::getExe()
{
if (m_exe.empty()) {
std::string cmdLineFile = getFile("exe");
char path[MAX_FILEPATH_LEN] = {};
ssize_t len = readlink(cmdLineFile.c_str(), path, MAX_FILEPATH_LEN);
if (len > 0 && len < MAX_FILEPATH_LEN) {
m_exe = std::string(path);
}
}
return m_exe;
}
std::vector<std::string> Process::getEnviron()
{
if (m_environ.size() == 0) {
std::string envFile = getFile("environ");
m_environ = readFile(envFile);
}
return m_environ;
}
std::string Process::getEnv(const std::string &key)
{
if (m_environ.size() == 0)
m_environ = getEnviron();
std::string keyPrefix = key + "=";
for (auto & env : m_environ) {
if (DString::startWith(env, keyPrefix)) {
ulong len = keyPrefix.size();
return env.substr(len, env.size() - len);
}
}
return "";
}
Status Process::getStatus()
{
if (!m_status.empty()){
return m_status;
}
std::string statusFile = getFile("status");
std::ifstream fs(statusFile);
if (!fs.is_open()) {
return m_status;
}
std::string tmp = "";
while (std::getline(fs, tmp)) {
auto pos = tmp.find_first_of(':');
if (pos == std::string::npos) {
continue;
}
std::string value;
if (pos + 1 < tmp.length()) {
value = tmp.substr(pos + 1);
}
m_status[tmp.substr(0, pos)] = value;
}
return m_status;
}
std::vector<int> Process::getUids()
{
if (m_uids.size() == 0) {
if (m_status.find("Uid") != m_status.end()) {
std::string uidGroup = m_status["Uid"];
std::vector<std::string> parts = DString::splitStr(uidGroup, '\t');
m_uids.reserve(parts.size());
std::transform(parts.begin(), parts.end(), m_uids.begin(),
[](std::string idStr) -> int {return std::stoi(idStr);});
}
}
return m_uids;
}
int Process::getPid()
{
return m_pid;
}
int Process::getPpid()
{
if (m_ppid == 0) {
if (m_status.find("PPid") != m_status.end()) {
m_ppid = std::stoi(m_status["PPid"]);
}
}
return m_ppid;
}
std::string Process::getFile(const std::string &name)
{
return "/proc/" + std::to_string(m_pid) + "/" + name;
}
// This funciton only can used to read `environ` and `cmdline`
std::vector<std::string> Process::readFile(std::string fileName)
{
std::vector<std::string> ret;
std::ifstream fs(fileName);
if (!fs.is_open()) {
return ret;
}
std::string tmp;
while (std::getline(fs, tmp, '\0')) {
ret.push_back(tmp);
}
return ret;
}

View File

@ -1,45 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef PROCESS_H
#define PROCESS_H
#include <map>
#include <vector>
#include <string>
typedef std::map<std::string, std::string> Status;
class Process
{
public:
explicit Process();
explicit Process(int _pid);
bool isExist();
std::vector<std::string> getCmdLine();
std::string getCwd();
std::string getExe();
std::vector<std::string> getEnviron();
std::string getEnv(const std::string &key);
Status getStatus();
std::vector<int> getUids();
int getPid();
int getPpid();
private:
std::string getFile(const std::string &name);
std::vector<std::string> readFile(std::string fileName);
int m_pid;
std::vector<std::string> m_cmdLine;
std::string m_cwd;
std::string m_exe;
std::vector<std::string> m_environ;
Status m_status;
std::vector<int> m_uids;
int m_ppid;
};
#endif // PROCESS_H

View File

@ -1,164 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "terminalinfo.h"
#include "utils.h"
#include "appinfocommon.h"
#include <QVariant>
TerminalInfo& TerminalInfo::getInstanceTerminal()
{
static TerminalInfo terminal;
return terminal;
}
TerminalInfo::TerminalInfo()
: gsSchemaDefaultTerminal("com.deepin.desktop.default-applications.terminal")
, gsKeyExec("exec")
, gsKeyExecArg("exec-arg")
, gsKeyAppId("app-id")
, categoryTerminalEmulator("TerminalEmulator")
, execXTerminalEmulator("x-terminal-emulator")
, defaultTerminal(new QGSettings(gsSchemaDefaultTerminal.c_str()))
{
init();
}
void TerminalInfo::resetTerminal()
{
defaultTerminal->reset(gsKeyExec.c_str());
defaultTerminal->reset(gsKeyExecArg.c_str());
defaultTerminal->reset(gsKeyExecArg.c_str());
}
std::string TerminalInfo::getPresetTerminalPath()
{
std::string path;
for (auto term : terms) {
path = lookPath(term);
if (!path.empty()) {
return path;
}
}
return "";
}
void TerminalInfo::init()
{
termBlackList = {"guake",
"tilda",
"org.kde.yakuake",
"qterminal_drop",
"Terminal"
};
execArgMap = {{"gnome-terminal", "-x"},
{"mate-terminal", "-x"},
{"terminator", "-x"},
{"xfce4-terminal", "-x"}
};
terms = {"deepin-terminal",
"gnome-terminal",
"terminator",
"xfce4-terminal",
"rxvt",
"xterm"
};
}
std::shared_ptr<AppInfoManger> TerminalInfo::getDefaultTerminal()
{
std::string appId = defaultTerminal->get(gsKeyAppId.c_str()).toString().toStdString();
if (!hasEnding(appId, AppinfoCommon::DesktopExt)) {
appId += AppinfoCommon::DesktopExt;
}
std::vector<std::shared_ptr<AppInfoManger>> appInfos = getTerminalInfos();
for (auto iter : appInfos) {
if (iter->getDesktopId() == appId) {
return iter;
}
}
for (auto appInfo : appInfos) {
for (auto term : terms) {
if (appInfo->getCmdline() == term) {
return appInfo;
}
}
}
return nullptr;
}
bool TerminalInfo::setDefaultTerminal(std::string id)
{
std::vector<std::shared_ptr<AppInfoManger>> appInfos = getTerminalInfos();
for (auto iter : appInfos) {
if (iter->getDesktopId() == id) {
std::string cmdline = iter->getCmdline();
std::string exec = cmdline.substr(0, cmdline.find(" "));
defaultTerminal->set(gsKeyExec.c_str(), exec.c_str());
std::string arg = "-e";
if (execArgMap.count(exec) != 0) {
arg = execArgMap[exec];
}
defaultTerminal->set(gsKeyExecArg.c_str(), arg.c_str());
if (hasEnding(id, AppinfoCommon::DesktopExt)) {
id = id.substr(0, id.find(AppinfoCommon::DesktopExt));
}
defaultTerminal->set(gsKeyAppId.c_str(), id.c_str());
return true;
}
}
return false;
}
std::vector<std::shared_ptr<AppInfoManger>> TerminalInfo::getTerminalInfos()
{
std::map<std::string, std::vector<std::string>> skipDirs;
std::vector<std::shared_ptr<AppInfoManger>> appInfos = AppInfoManger::getAll(skipDirs);
std::vector<std::shared_ptr<AppInfoManger>>::iterator iter = appInfos.begin();
while (iter != appInfos.end()) {
if (isTerminalApp(*iter)) {
(*iter)->setDesktopId((*iter)->getDesktopId() + AppinfoCommon::DesktopExt);
iter++;
} else {
iter = appInfos.erase(iter);
}
}
return appInfos;
}
bool TerminalInfo::isTerminalApp(std::shared_ptr<AppInfoManger> appInfo)
{
if (std::find(termBlackList.begin(), termBlackList.end(), appInfo->getDesktopId()) != termBlackList.end()) {
return false;
}
std::vector<std::string> categories = appInfo->getCategories();
if (std::find(categories.begin(), categories.end(), categoryTerminalEmulator) == categories.end()) {
return false;
}
std::string cmdline = appInfo->getCmdline();
if (cmdline.find(execXTerminalEmulator) != std::string::npos) {
return false;
}
return true;
}

View File

@ -1,47 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef TERMINALINFO_H
#define TERMINALINFO_H
#include "appinfo.h"
#include <memory>
#include <vector>
#include <map>
#include <QGSettings>
class TerminalInfo
{
public:
static TerminalInfo& getInstanceTerminal();
void resetTerminal();
std::string getPresetTerminalPath();
bool setDefaultTerminal(std::string id);
std::shared_ptr<AppInfoManger> getDefaultTerminal();
std::vector<std::shared_ptr<AppInfoManger>> getTerminalInfos();
TerminalInfo(const TerminalInfo& term) = delete;
TerminalInfo& operator=(const TerminalInfo& term) = delete;
private:
TerminalInfo();
void init();
bool isTerminalApp(std::shared_ptr<AppInfoManger> appInfo);
private:
std::vector<std::string> termBlackList;
std::map<std::string, std::string> execArgMap;
std::vector<std::string> terms;
const std::string gsSchemaDefaultTerminal;
const std::string gsKeyExec;
const std::string gsKeyExecArg;
const std::string gsKeyAppId;
const std::string categoryTerminalEmulator;
const std::string execXTerminalEmulator;
std::shared_ptr<QGSettings> defaultTerminal;
};
#endif // TERMINALINFO_H

View File

@ -1,199 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "utils.h"
#define HOME "HOME"
#include <unistd.h>
#include <fcntl.h>
std::string getUserDir(const char* envName);
std::vector<std::string> getSystemDirs(const char* envName);
std::string getUserHomeDir()
{
const char* dir = getenv(HOME);
if (dir) {
return dir;
}
struct passwd* user = getpwent();
if (user) {
return user->pw_dir;
}
return "";
}
std::string getUserDataDir()
{
// default $HOME/.local/share
std::string userDataDir = getUserDir("XDG_DATA_HOME");
if (userDataDir.empty()) {
userDataDir = getUserHomeDir();
if (!userDataDir.empty()) {
userDataDir += "/.local/share";
}
}
return userDataDir;
}
std::string getUserConfigDir()
{
// default $HOME/.config
std::string userConfigDir = getUserDir("XDG_CONFIG_HOME");
if (userConfigDir.empty()) {
userConfigDir = getUserHomeDir();
if (!userConfigDir.empty()) {
userConfigDir += "/.config";
}
}
return userConfigDir;
}
std::string getUserDir(const char* envName)
{
const char* envDir = getenv(envName);
if (!envDir) {
return "";
}
if (!QDir::isAbsolutePath(envDir)) {
return "";
}
return envDir;
}
std::vector<std::string> getSystemDataDirs()
{
std::vector<std::string> systemDir = getSystemDirs("XDG_DATA_DIRS");
if (systemDir.empty()) {
systemDir.push_back({"/usr/local/share", "/usr/share"});
}
return systemDir;
}
std::vector<std::string> getSystemConfigDirs()
{
std::vector<std::string> systemDir = getSystemDirs("XDG_CONFIG_DIRS");
if (systemDir.empty()) {
systemDir.push_back("/etc/xdg");
}
return systemDir;
}
std::vector<std::string> getSystemDirs(const char* envName)
{
std::vector<std::string> dirVector;
const char* envDir = getenv(envName);
if (envDir == nullptr) {
return dirVector;
}
QString tempDirs(envDir);
auto tempList = tempDirs.split(":");
for (auto iter : tempList) {
if (QDir::isAbsolutePath(iter)) {
dirVector.push_back(iter.toStdString());
}
}
return dirVector;
}
std::string lookPath(std::string file)
{
std::string path;
if (file.find("/") != std::string::npos) {
if (access(path.c_str(), X_OK) != -1) {
return file;
} else {
return path;
}
}
char* pathEnv = getenv("PATH");
char* temp = strtok(pathEnv, ";");
while (temp) {
path = std::string(temp) + "/" + file;
if (access(path.c_str(), X_OK) != -1) {
return path;
} else {
path = "";
temp = strtok(nullptr, "/");
}
}
return path;
}
void walk(std::string root, std::vector<std::string>& skipdir, std::map<std::string, int>& retMap)
{
walk(root, ".", skipdir, retMap);
}
void walk(std::string root, std::string name, std::vector<std::string>& skipdir, std::map<std::string, int>& retMap)
{
QDir dir(root.c_str());
if (dir.exists()) {
if (std::find(skipdir.begin(), skipdir.end(), name) != skipdir.end()) {
return;
}
} else {
return;
}
if (hasEnding(name, ".desktop")) {
retMap[name] = 0;
}
std::string path = root + "/" + name;
QDir temp(path.c_str());
QStringList entryList = temp.entryList();
for (auto iter : entryList) {
QFile file(iter);
if (file.exists()) {
continue;
}
walk(root, name + "/" + iter.toStdString(), skipdir, retMap);
}
}
bool hasEnding(std::string const& fullString, std::string const& ending)
{
if (fullString.length() >= ending.length()) {
return fullString.compare(fullString.length() - ending.length(), ending.length(), ending) == 0;
} else {
return false;
}
}
bool hasBeginWith(std::string const& fullString, std::string const& ending)
{
if (fullString.length() >= ending.length()) {
return (0 == fullString.compare(0, ending.length(), ending));
} else {
return false;
}
}

View File

@ -1,36 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef UTILS_H
#define UTILS_H
#include <string>
#include <pwd.h>
#include <QDir>
#include <vector>
std::string getUserHomeDir();
std::string getUserDataDir();
std::string getUserConfigDir();
std::string getUserDir(const char* envName);
std::vector<std::string> getSystemDataDirs();
std::vector<std::string> getSystemConfigDirs();
std::vector<std::string> getSystemDirs(const char* envName);
std::string lookPath(std::string file);
void walk(std::string root, std::vector<std::string>& skipdir, std::map<std::string, int>& retMap);
void walk(std::string root, std::string name, std::vector<std::string>& skipdir, std::map<std::string, int>& retMap);
bool hasEnding(std::string const& fullString, std::string const& ending);
bool hasBeginWith(std::string const& fullString, std::string const& ending);
#endif // UTILS_H

View File

@ -1,762 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "xcbutils.h"
#include <iostream>
#include <cstring>
#include <memory>
#include <algorithm>
#include <X11/Xlib.h>
#include <X11/extensions/XRes.h>
XCBUtils::XCBUtils()
{
m_connect = xcb_connect(nullptr, &m_screenNum); // nullptr表示默认使用环境变量$DISPLAY获取屏幕
if (xcb_connection_has_error(m_connect)) {
std::cout << "XCBUtils: init xcb_connect error" << std::endl;
return;
}
if (!xcb_ewmh_init_atoms_replies(&m_ewmh,
xcb_ewmh_init_atoms(m_connect, &m_ewmh), // 初始化Atom
nullptr))
std::cout << "XCBUtils: init ewmh error" << std::endl;
}
XCBUtils::~XCBUtils()
{
if (m_connect) {
xcb_disconnect(m_connect); // 关闭连接并释放
m_connect = nullptr;
}
}
XWindow XCBUtils::allocId()
{
return xcb_generate_id(m_connect);
}
void XCBUtils::flush()
{
xcb_flush(m_connect);
}
void XCBUtils::killClientChecked(XWindow xid)
{
xcb_kill_client_checked(m_connect, xid);
}
xcb_get_property_reply_t *XCBUtils::getPropertyValueReply(XWindow xid, XCBAtom property, XCBAtom type)
{
xcb_get_property_cookie_t cookie = xcb_get_property(m_connect,
0,
xid,
property,
type,
0,
MAXLEN);
return xcb_get_property_reply(m_connect, cookie, nullptr);
}
void *XCBUtils::getPropertyValue(XWindow xid, XCBAtom property, XCBAtom type)
{
void *value = nullptr;
xcb_get_property_reply_t *reply = getPropertyValueReply(xid, property, type);
if (reply) {
if (xcb_get_property_value_length(reply) > 0) {
value = xcb_get_property_value(reply);
}
free(reply);
}
return value;
}
std::string XCBUtils::getUTF8PropertyStr(XWindow xid, XCBAtom property)
{
std::string ret;
xcb_get_property_reply_t *reply = getPropertyValueReply(xid, property, m_ewmh.UTF8_STRING);
if (reply) {
ret = getUTF8StrFromReply(reply);
free(reply);
}
return ret;
}
XCBAtom XCBUtils::getAtom(const char *name)
{
XCBAtom ret = m_atomCache.getVal(name);
if (ret == ATOMNONE) {
xcb_intern_atom_cookie_t cookie = xcb_intern_atom(m_connect, false, strlen(name), name);
xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply (m_connect,
cookie,
nullptr);
if (reply) {
m_atomCache.store(name, reply->atom);
ret = reply->atom;
free(reply);
}
}
return ret;
}
std::string XCBUtils::getAtomName(XCBAtom atom)
{
std::string ret = m_atomCache.getName(atom);
if (ret.empty()) {
xcb_get_atom_name_cookie_t cookie = xcb_get_atom_name(m_connect, atom);
xcb_get_atom_name_reply_t *reply = xcb_get_atom_name_reply(m_connect,
cookie,
nullptr);
if (reply) {
char *name = xcb_get_atom_name_name(reply);
if (name) {
m_atomCache.store(name, atom);
ret = name;
}
free(reply);
}
}
return ret;
}
Geometry XCBUtils::getWindowGeometry(XWindow xid)
{
xcb_get_geometry_cookie_t cookie = xcb_get_geometry(m_connect, xcb_drawable_t(xid));
xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(m_connect, cookie, nullptr);
if (!reply) {
std::cout << xid << " getWindowGeometry err" << std::endl;
return Geometry();
}
Geometry ret;
ret.x = reply->x;
ret.y = reply->y;
ret.width = reply->width;
ret.height = reply->height;
free(reply);
const xcb_setup_t *xcbSetup = xcb_get_setup(m_connect);
if (!xcbSetup)
return Geometry();
xcb_screen_iterator_t xcbScreenIterator = xcb_setup_roots_iterator(xcbSetup);
xcb_translate_coordinates_reply_t *translateReply =
xcb_translate_coordinates_reply(m_connect,
xcb_translate_coordinates(m_connect, xid, xcbScreenIterator.data->root, 0, 0),
nullptr);
if (translateReply) {
ret.x = translateReply->dst_x;
ret.y = translateReply->dst_y;
free(translateReply);
}
XWindow dWin = getDecorativeWindow(xid);
reply = xcb_get_geometry_reply(m_connect, xcb_get_geometry(m_connect, xcb_drawable_t(dWin)), nullptr);
if (!reply)
return ret;
if (reply->x == ret.x && reply->y == ret.y) {
// 无标题的窗口比如deepin-editor, dconf-editor等
WindowFrameExtents windowFrameRect = getWindowFrameExtents(xid);
if (!windowFrameRect.isNull()) {
int x = ret.x + windowFrameRect.Left;
int y = ret.y + windowFrameRect.Top;
int width = ret.width - (windowFrameRect.Left + windowFrameRect.Right);
int height = ret.height - (windowFrameRect.Top + windowFrameRect.Bottom);
ret.x = x;
ret.y = y;
ret.width = width;
ret.height = height;
}
}
free(reply);
return ret;
}
XWindow XCBUtils::getDecorativeWindow(XWindow xid)
{
XWindow winId = xid;
for (int i = 0; i < 10; i++) {
xcb_query_tree_cookie_t cookie = xcb_query_tree(m_connect, winId);
xcb_query_tree_reply_t *reply = xcb_query_tree_reply(m_connect, cookie, nullptr);
if (!reply)
return 0;
if (reply->root == reply->parent)
return winId;
winId = reply->parent;
}
return 0;
}
WindowFrameExtents XCBUtils::getWindowFrameExtents(XWindow xid)
{
xcb_atom_t perp = getAtom("_NET_FRAME_EXTENTS");
xcb_get_property_cookie_t cookie = xcb_get_property(m_connect, false, xid, perp, XCB_ATOM_CARDINAL, 0, 4);
std::shared_ptr<xcb_get_property_reply_t> reply(
xcb_get_property_reply(m_connect, cookie, nullptr),
[](xcb_get_property_reply_t* ptr) { free(ptr); }
);
if (!reply || reply->format == 0) {
perp = getAtom("_GTK_FRAME_EXTENTS");
cookie = xcb_get_property(m_connect, false, xid, perp, XCB_ATOM_CARDINAL, 0, 4);
reply.reset(
xcb_get_property_reply(m_connect, cookie, nullptr),
[](xcb_get_property_reply_t* ptr) { free(ptr); }
);
if (!reply)
return WindowFrameExtents();
}
if (reply->format != 32 || reply->value_len != 4) {
return WindowFrameExtents();
}
uint32_t *data = static_cast<uint32_t *>(xcb_get_property_value(reply.get()));
if (!data)
return WindowFrameExtents();
WindowFrameExtents winFrame(data[0], data[1], data[2], data[3]);
return winFrame;
}
XWindow XCBUtils::getActiveWindow()
{
XWindow ret;
xcb_get_property_cookie_t cookie = xcb_ewmh_get_active_window(&m_ewmh, m_screenNum);
if (!xcb_ewmh_get_active_window_reply(&m_ewmh, cookie, &ret, nullptr)) {
std::cout << "getActiveWindow error" << std::endl;
}
return ret;
}
void XCBUtils::setActiveWindow(XWindow xid)
{
xcb_ewmh_set_active_window(&m_ewmh, m_screenNum, xid);
}
void XCBUtils::changeActiveWindow(XWindow newActiveXid)
{
xcb_ewmh_request_change_active_window(&m_ewmh, m_screenNum, newActiveXid, XCB_EWMH_CLIENT_SOURCE_TYPE_OTHER, XCB_CURRENT_TIME, XCB_WINDOW_NONE);
flush();
}
void XCBUtils::restackWindow(XWindow xid)
{
xcb_ewmh_request_restack_window(&m_ewmh, m_screenNum, xid, 0, XCB_STACK_MODE_ABOVE);
}
std::list<XWindow> XCBUtils::getClientList()
{
std::list<XWindow> ret;
xcb_get_property_cookie_t cookie = xcb_ewmh_get_client_list(&m_ewmh, m_screenNum);
xcb_ewmh_get_windows_reply_t reply;
if (xcb_ewmh_get_client_list_reply(&m_ewmh, cookie, &reply, nullptr)) {
for (uint32_t i = 0; i < reply.windows_len; i++) {
ret.push_back(reply.windows[i]);
}
xcb_ewmh_get_windows_reply_wipe(&reply);
} else {
std::cout << "getClientList error" << std::endl;
}
return ret;
}
std::list<XWindow> XCBUtils::getClientListStacking()
{
std::list<XWindow> ret;
xcb_get_property_cookie_t cookie = xcb_ewmh_get_client_list_stacking(&m_ewmh, m_screenNum);
xcb_ewmh_get_windows_reply_t reply;
if (xcb_ewmh_get_client_list_stacking_reply(&m_ewmh, cookie, &reply, nullptr)) {
for (uint32_t i = 0; i < reply.windows_len; i++) {
ret.push_back(reply.windows[i]);
}
xcb_ewmh_get_windows_reply_wipe(&reply);
} else {
std::cout << "getClientListStacking error" << std::endl;
}
return ret;
}
std::vector<XCBAtom> XCBUtils::getWMState(XWindow xid)
{
std::vector<XCBAtom> ret;
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_state(&m_ewmh, xid);
xcb_ewmh_get_atoms_reply_t reply; // a list of Atom
if (xcb_ewmh_get_wm_state_reply(&m_ewmh, cookie, &reply, nullptr)) {
for (uint32_t i = 0; i < reply.atoms_len; i++) {
ret.push_back(reply.atoms[i]);
}
xcb_ewmh_get_atoms_reply_wipe(&reply);
} else {
std::cout << xid << " getWMState error" << std::endl;
}
return ret;
}
std::vector<XCBAtom> XCBUtils::getWMWindoType(XWindow xid)
{
std::vector<XCBAtom> ret;
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_window_type(&m_ewmh, xid);
xcb_ewmh_get_atoms_reply_t reply; // a list of Atom
if (xcb_ewmh_get_wm_window_type_reply(&m_ewmh, cookie, &reply, nullptr)) {
for (uint32_t i = 0; i < reply.atoms_len; i++) {
ret.push_back(reply.atoms[i]);
}
xcb_ewmh_get_atoms_reply_wipe(&reply);
} else {
std::cout << xid << " getWMWindoType error" << std::endl;
}
return ret;
}
std::vector<XCBAtom> XCBUtils::getWMAllowedActions(XWindow xid)
{
std::vector<XCBAtom> ret;
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_allowed_actions(&m_ewmh, xid);
xcb_ewmh_get_atoms_reply_t reply; // a list of Atoms
if (xcb_ewmh_get_wm_allowed_actions_reply(&m_ewmh, cookie, &reply, nullptr)) {
for (uint32_t i = 0; i < reply.atoms_len; i++) {
ret.push_back(reply.atoms[i]);
}
xcb_ewmh_get_atoms_reply_wipe(&reply);
} else {
std::cout << xid << " getWMAllowedActions error" << std::endl;
}
return ret;
}
void XCBUtils::setWMAllowedActions(XWindow xid, std::vector<XCBAtom> actions)
{
XCBAtom list[MAXALLOWEDACTIONLEN] {0};
for (size_t i = 0; i < actions.size(); i++) {
list[i] = actions[i];
}
xcb_ewmh_set_wm_allowed_actions(&m_ewmh, xid, actions.size(), list);
}
std::string XCBUtils::getWMName(XWindow xid)
{
std::string ret;
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_name(&m_ewmh, xid);
xcb_ewmh_get_utf8_strings_reply_t reply;
if (xcb_ewmh_get_wm_name_reply(&m_ewmh, cookie, &reply, nullptr)) {
ret.assign(reply.strings, reply.strings_len);
// 释放utf8_strings_reply分配的内存
xcb_ewmh_get_utf8_strings_reply_wipe(&reply);
} else {
std::cout << xid << " getWMName error" << std::endl;
}
return ret;
}
uint32_t XCBUtils::getWMPid(XWindow xid)
{
// NOTE(black_desk): code copy from https://gitlab.gnome.org/GNOME/metacity/-/merge_requests/13/diffs
XResClientIdSpec spec = {
.client = xid,
.mask = XRES_CLIENT_ID_PID_MASK,
};
std::shared_ptr<Display> dpy = {
XOpenDisplay(nullptr),
[](Display *p){ XCloseDisplay(p); },
};
long num_ids;
XResClientIdValue *client_ids;
XResQueryClientIds(dpy.get(),
1,
&spec,
&num_ids,
&client_ids);
pid_t pid = -1;
for (long i = 0; i < num_ids; i++) {
if (client_ids[i].spec.mask == XRES_CLIENT_ID_PID_MASK) {
pid = XResGetClientPid(&client_ids[i]);
break;
}
}
XResClientIdsDestroy(num_ids, client_ids);
return pid;
}
std::string XCBUtils::getWMIconName(XWindow xid)
{
std::string ret;
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_icon_name(&m_ewmh, xid);
xcb_ewmh_get_utf8_strings_reply_t reply;
if (!xcb_ewmh_get_wm_icon_name_reply(&m_ewmh, cookie, &reply, nullptr)) {
std::cout << xid << " getWMIconName error" << std::endl;
}
ret.assign(reply.strings);
return ret;
}
WMIcon XCBUtils::getWMIcon(XWindow xid)
{
WMIcon wmIcon{};
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_icon(&m_ewmh, xid);
xcb_ewmh_get_wm_icon_reply_t reply;
xcb_generic_error_t *error;
auto ret = xcb_ewmh_get_wm_icon_reply(&m_ewmh, cookie, &reply, &error);
if (error) {
std::cout << "failed to get wm icon" << error->error_code;
std::free(error);
return wmIcon;
}
if (ret) {
auto fcn = [](xcb_ewmh_wm_icon_iterator_t it) {
// 根据宽高获取每个位置的数据每行前有两个位置offset
const auto size = 2 + it.width * it.height;
std::vector<uint32_t> ret(size);
// data数据是按行从左至右从上至下排列
uint32_t *data = it.data;
if (!data) {
return ret;
}
std::copy_n(data, size, ret.begin());
return ret;
};
// 获取icon中size最大的图标
xcb_ewmh_wm_icon_iterator_t iter = xcb_ewmh_get_wm_icon_iterator(&reply);
xcb_ewmh_wm_icon_iterator_t wmIconIt{0, 0, nullptr};
for (; iter.rem; xcb_ewmh_get_wm_icon_next(&iter)) {
const int size = iter.width * iter.height;
if (size > 0 && size > wmIconIt.width * wmIconIt.height) {
wmIconIt = iter;
}
}
wmIcon = WMIcon{wmIconIt.width, wmIconIt.height, fcn(wmIconIt)};
xcb_ewmh_get_wm_icon_reply_wipe(&reply); // clear
}
return wmIcon;
}
XWindow XCBUtils::getWMClientLeader(XWindow xid)
{
XWindow ret;
XCBAtom atom = getAtom("WM_CLIENT_LEADER");
void *value = getPropertyValue(xid, atom, XCB_ATOM_INTEGER);
std::cout << "getWMClientLeader:" << (char*)value << std::endl;
return ret;
}
void XCBUtils::requestCloseWindow(XWindow xid, uint32_t timestamp)
{
xcb_ewmh_request_close_window(&m_ewmh, m_screenNum, xid, timestamp, XCB_EWMH_CLIENT_SOURCE_TYPE_OTHER);
}
uint32_t XCBUtils::getWMDesktop(XWindow xid)
{
uint32_t ret;
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_desktop(&m_ewmh, xid);
if (!xcb_ewmh_get_wm_desktop_reply(&m_ewmh, cookie, &ret, nullptr)) {
std::cout << xid << " getWMDesktop error" << std::endl;
}
return ret;
}
void XCBUtils::setWMDesktop(XWindow xid, uint32_t desktop)
{
xcb_ewmh_set_wm_desktop(&m_ewmh, xid, desktop);
}
void XCBUtils::setCurrentWMDesktop(uint32_t desktop)
{
xcb_ewmh_set_current_desktop(&m_ewmh, m_screenNum, desktop);
}
void XCBUtils::changeCurrentDesktop(uint32_t newDesktop, uint32_t timestamp)
{
xcb_ewmh_request_change_current_desktop(&m_ewmh, m_screenNum, newDesktop, timestamp);
}
uint32_t XCBUtils::getCurrentWMDesktop()
{
uint32_t ret;
xcb_get_property_cookie_t cookie = xcb_ewmh_get_current_desktop(&m_ewmh, m_screenNum);
if (!xcb_ewmh_get_current_desktop_reply(&m_ewmh, cookie, &ret, nullptr)) {
std::cout << "getCurrentWMDesktop error" << std::endl;
}
return ret;
}
bool XCBUtils::isGoodWindow(XWindow xid)
{
bool ret = false;
xcb_get_geometry_cookie_t cookie = xcb_get_geometry(m_connect, xid);
xcb_generic_error_t **errStore = nullptr;
xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(m_connect, cookie, errStore);
if (reply) {
// 正常获取窗口geometry则判定为good
if (!errStore) {
ret = true;
} else {
free(errStore);
}
free(reply);
}
return ret;
}
// TODO XCB下无_MOTIF_WM_HINTS属性
MotifWMHints XCBUtils::getWindowMotifWMHints(XWindow xid)
{
XCBAtom atomWmHints = getAtom("_MOTIF_WM_HINTS");
xcb_get_property_cookie_t cookie = xcb_get_property(m_connect, false, xid, atomWmHints, atomWmHints, 0, 5);
xcb_get_property_reply_t *reply = xcb_get_property_reply(m_connect, cookie, nullptr);
if (!reply || reply->format != 32 || reply->value_len != 5)
return MotifWMHints{0, 0, 0, 0, 0};
uint32_t *data = static_cast<uint32_t *>(xcb_get_property_value(reply));
MotifWMHints ret;
ret.flags = data[0];
ret.functions = data[1];
ret.decorations = data[2];
ret.inputMode = data[3];
ret.status = data[4];
return ret;
}
bool XCBUtils::hasXEmbedInfo(XWindow xid)
{
//XCBAtom atom = getAtom("_XEMBED_INFO");
return false;
}
XWindow XCBUtils::getWMTransientFor(XWindow xid)
{
XWindow ret;
xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_transient_for(m_connect, xid);
if (!xcb_icccm_get_wm_transient_for_reply(m_connect, cookie, &ret, nullptr)) {
std::cout << xid << " getWMTransientFor error" << std::endl;
}
return ret;
}
uint32_t XCBUtils::getWMUserTime(XWindow xid)
{
uint32_t ret;
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_user_time(&m_ewmh, xid);
if (!xcb_ewmh_get_wm_user_time_reply(&m_ewmh, cookie, &ret, nullptr)) {
std::cout << xid << " getWMUserTime error" << std::endl;
}
return ret;
}
int XCBUtils::getWMUserTimeWindow(XWindow xid)
{
XCBAtom ret;
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_user_time_window(&m_ewmh, xid);
if (!xcb_ewmh_get_wm_user_time_window_reply(&m_ewmh, cookie, &ret, nullptr)) {
std::cout << xid << " getWMUserTimeWindow error" << std::endl;
}
return ret;
}
WMClass XCBUtils::getWMClass(XWindow xid)
{
WMClass ret;
xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_class(m_connect, xid);
xcb_icccm_get_wm_class_reply_t reply;
reply.instance_name = nullptr;
reply.class_name = nullptr;
xcb_icccm_get_wm_class_reply(m_connect, cookie, &reply, nullptr); // 返回值为0不一定表示失败 故不做返回值判断
if (reply.class_name)
ret.className.assign(reply.class_name);
if (reply.instance_name)
ret.instanceName.assign(reply.instance_name);
if (reply.class_name || reply.instance_name) {
xcb_icccm_get_wm_class_reply_wipe(&reply);
}
return ret;
}
void XCBUtils::minimizeWindow(XWindow xid)
{
uint32_t data[2];
data[0] = XCB_ICCCM_WM_STATE_ICONIC;
data[1] = XCB_NONE;
xcb_ewmh_send_client_message(m_connect, xid, getRootWindow(),getAtom("WM_CHANGE_STATE"), 2, data);
flush();
}
void XCBUtils::maxmizeWindow(XWindow xid)
{
xcb_ewmh_request_change_wm_state(&m_ewmh
, m_screenNum
, xid
, XCB_EWMH_WM_STATE_ADD
, getAtom("_NET_WM_STATE_MAXIMIZED_VERT")
, getAtom("_NET_WM_STATE_MAXIMIZED_HORZ")
, XCB_EWMH_CLIENT_SOURCE_TYPE_OTHER);
}
// TODO
std::vector<std::string> XCBUtils::getWMCommand(XWindow xid)
{
std::vector<std::string> ret;
xcb_get_property_reply_t *reply = getPropertyValueReply(xid, XCB_ATOM_WM_COMMAND, m_ewmh.UTF8_STRING);
if (reply) {
ret = getUTF8StrsFromReply(reply);
free(reply);
}
return ret;
}
std::string XCBUtils::getUTF8StrFromReply(xcb_get_property_reply_t *reply)
{
std::string ret;
if (!reply || reply->format != 8) {
return ret;
}
char data[12] = {0};
for (uint32_t i=0; i < reply->value_len; i++) {
data[i] = char(reply->pad0[i]);
}
ret.assign(data);
return ret;
}
std::vector<std::string> XCBUtils::getUTF8StrsFromReply(xcb_get_property_reply_t *reply)
{
std::vector<std::string> ret;
if (!reply) {
return ret;
}
if (reply->format != 8) {
return ret;
}
// 字符串拆分
uint32_t start = 0;
for (uint32_t i=0; i < reply->value_len; i++) {
if (reply->pad0[i] == 0) {
char data[12] = {0};
int count = 0;
for (uint32_t j=start; j < i; j++)
data[count++] = char(reply->pad0[j]);
data[count] = 0;
ret.push_back(data);
}
}
return ret;
}
XWindow XCBUtils::getRootWindow()
{
XWindow rootWindow = 0;
/* Get the first screen */
xcb_screen_t *screen = xcb_setup_roots_iterator(xcb_get_setup(m_connect)).data;
if (screen) {
rootWindow = screen->root;
}
std::cout << "getRootWinodw: " << rootWindow << std::endl;
return rootWindow;
}
void XCBUtils::registerEvents(XWindow xid, uint32_t eventMask)
{
uint32_t value[1] = {eventMask};
xcb_void_cookie_t cookie = xcb_change_window_attributes_checked(m_connect,
xid,
XCB_CW_EVENT_MASK,
&value);
flush();
xcb_generic_error_t *error = xcb_request_check(m_connect, cookie);
if (error != nullptr) {
std::cout << "window " << xid << "registerEvents error" << std::endl;
}
}
AtomCache::AtomCache()
{
}
XCBAtom AtomCache::getVal(std::string name)
{
XCBAtom atom = ATOMNONE;
auto search = m_atoms.find(name);
if (search != m_atoms.end()) {
atom = search->second;
}
return atom;
}
std::string AtomCache::getName(XCBAtom atom)
{
std::string ret;
auto search = m_atomNames.find(atom);
if (search != m_atomNames.end()) {
ret = search->second;
}
return ret;
}
void AtomCache::store(std::string name, XCBAtom value)
{
m_atoms[name] = value;
m_atomNames[value] = name;
}

View File

@ -1,276 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef XCBUTILS_H
#define XCBUTILS_H
#include <xcb/xproto.h>
#include <xcb/xcb_ewmh.h>
#include <xcb/xcb_icccm.h>
#include <list>
#include <string>
#include <vector>
#include <map>
#define MAXLEN 0xffff
#define MAXALLOWEDACTIONLEN 256
#define ATOMNONE 0
typedef xcb_window_t XWindow ;
typedef xcb_atom_t XCBAtom;
typedef xcb_destroy_notify_event_t DestroyEvent;
typedef xcb_map_notify_event_t MapEvent;
typedef xcb_configure_notify_event_t ConfigureEvent;
typedef xcb_property_notify_event_t PropertyEvent;
typedef xcb_event_mask_t EventMask;
typedef struct {
std::string instanceName;
std::string className;
} WMClass;
typedef struct {
int16_t x, y;
uint16_t width, height;
} Geometry;
typedef struct {
uint32_t flags;
uint32_t functions;
uint32_t decorations;
int32_t inputMode;
uint32_t status;
} MotifWMHints;
typedef struct {
uint32_t width; /** Icon width */
uint32_t height; /** Icon height */
std::vector<uint32_t> data; /** Rows, left to right and top to bottom of the CARDINAL ARGB */
} WMIcon;
typedef struct WindowFrameExtents {
uint32_t Left;
uint32_t Right;
uint32_t Top;
uint32_t Bottom;
WindowFrameExtents(int left = 0, int right = 0, int top = 0, int bottom = 0): Left(left), Right(right), Top(top), Bottom(bottom) {}
bool isNull() { return Left == 0 && Right == 0 && Top == 0 && Bottom == 0;}
} WindowFrameExtents;
// 缓存atom减少X访问 TODO 加读写锁
class AtomCache {
public:
AtomCache();
XCBAtom getVal(std::string name);
std::string getName(XCBAtom atom);
void store(std::string name, XCBAtom value);
public:
std::map<std::string, XCBAtom> m_atoms;
std::map<XCBAtom, std::string> m_atomNames;
};
// XCB接口封装 参考getCurrentWMDesktop
class XCBUtils
{
XCBUtils();
XCBUtils(const XCBUtils &other);
XCBUtils & operator= (const XCBUtils &other);
~XCBUtils();
public:
static XCBUtils *instance() {
static XCBUtils instance;
return &instance;
}
/************************* xcb method ***************************/
// 分配XID
XWindow allocId();
// 刷新
void flush();
/************************* xpropto method ***************************/
// 杀掉进程
void killClientChecked(XWindow xid);
// 获取属性reply, 返回值必须free
xcb_get_property_reply_t *getPropertyValueReply(XWindow xid, XCBAtom property, XCBAtom type = XCB_ATOM_ATOM);
// 获取属性
void *getPropertyValue(XWindow xid, XCBAtom property, XCBAtom type = XCB_ATOM_ATOM);
// 获取字符串属性
std::string getUTF8PropertyStr(XWindow xid, XCBAtom property);
// 获取名称对应的Atom
XCBAtom getAtom(const char *name);
// 获取Atom对应的名称
std::string getAtomName(XCBAtom atom);
// 获取窗口矩形
Geometry getWindowGeometry(XWindow xid);
// 判断当前窗口是否正常
bool isGoodWindow(XWindow xid);
// 获取窗口
MotifWMHints getWindowMotifWMHints(XWindow xid);
bool hasXEmbedInfo(XWindow xid);
/************************* ewmh method ***************************/
// 获取活动窗口 _NET_ACTIVE_WINDOW
XWindow getActiveWindow();
// 设置活动窗口 _NET_ACTIVE_WINDOW 属性
void setActiveWindow(XWindow xid);
// 改变活动窗口
void changeActiveWindow(XWindow newActiveXid);
// 重新排列窗口
void restackWindow(XWindow xid);
// 获取窗口列表 _NET_CLIENT_LIST
std::list<XWindow> getClientList();
// 获取窗口列表 _NET_CLIENT_LIST_STACKING
std::list<XWindow> getClientListStacking();
// 获取窗口状态 _NET_WM_STATE
/*
_NET_WM_STATE_MODAL, ATOM
_NET_WM_STATE_STICKY, ATOM
_NET_WM_STATE_MAXIMIZED_VERT, ATOM
_NET_WM_STATE_MAXIMIZED_HORZ, ATOM
_NET_WM_STATE_SHADED, ATOM
_NET_WM_STATE_SKIP_TASKBAR, ATOM
_NET_WM_STATE_SKIP_PAGER, ATOM
_NET_WM_STATE_HIDDEN, ATOM
_NET_WM_STATE_FULLSCREEN, ATOM
_NET_WM_STATE_ABOVE, ATOM
_NET_WM_STATE_BELOW, ATOM
_NET_WM_STATE_DEMANDS_ATTENTION, ATOM
*/
std::vector<XCBAtom> getWMState(XWindow xid);
// 获取窗口类型 _NET_WM_WINDOW_TYPE
// Rationale: This hint is intended to replace the MOTIF hints.
// One of the objections to the MOTIF hints is that they are a purely visual description of the window decoration.
// By describing the function of the window, the Window Manager can apply consistent decoration and behavior to windows of the same type.
// Possible examples of behavior include keeping dock/panels on top or allowing pinnable menus / toolbars to only be hidden
// when another window has focus
/*
_NET_WM_WINDOW_TYPE_DESKTOP, ATOM
_NET_WM_WINDOW_TYPE_DOCK, ATOM
_NET_WM_WINDOW_TYPE_TOOLBAR, ATOM
_NET_WM_WINDOW_TYPE_MENU, ATOM
_NET_WM_WINDOW_TYPE_UTILITY, ATOM
_NET_WM_WINDOW_TYPE_SPLASH, ATOM
_NET_WM_WINDOW_TYPE_DIALOG, ATOM
_NET_WM_WINDOW_TYPE_DROPDOWN_MENU, ATOM
_NET_WM_WINDOW_TYPE_POPUP_MENU, ATOM
_NET_WM_WINDOW_TYPE_TOOLTIP, ATOM
_NET_WM_WINDOW_TYPE_NOTIFICATION, ATOM
_NET_WM_WINDOW_TYPE_COMBO, ATOM
_NET_WM_WINDOW_TYPE_DND, ATOM
_NET_WM_WINDOW_TYPE_NORMAL, ATOM
* */
std::vector<XCBAtom> getWMWindoType(XWindow xid);
// 获取窗口许可动作 _NET_WM_ALLOWED_ACTIONS
std::vector<XCBAtom> getWMAllowedActions(XWindow xid);
// 设置窗口许可动作
void setWMAllowedActions(XWindow xid, std::vector<XCBAtom> actions);
// 获取窗口名称 _NET_WM_NAME
std::string getWMName(XWindow xid);
// 获取窗口所属进程 _NET_WM_PID
uint32_t getWMPid(XWindow xid);
// 获取窗口图标 _NET_WM_ICON_NAME
std::string getWMIconName(XWindow xid);
// 获取窗口图标信息 _NET_WM_ICON
WMIcon getWMIcon(XWindow xid);
// WM_CLIENT_LEADER
XWindow getWMClientLeader(XWindow xid);
// 关闭窗口 _NET_CLOSE_WINDOW
void requestCloseWindow(XWindow xid, uint32_t timestamp);
// 获取窗口对应桌面 _NET_WM_DESKTOP
uint32_t getWMDesktop(XWindow xid);
// 设置窗口当前桌面
void setWMDesktop(XWindow xid, uint32_t desktop);
// 设置当前桌面属性
void setCurrentWMDesktop(uint32_t desktop);
// 请求改变当前桌面
void changeCurrentDesktop(uint32_t newDesktop, uint32_t timestamp);
// 获取当前桌面 _NET_CURRENT_DESKTOP
uint32_t getCurrentWMDesktop();
/************************* icccm method ***************************/
// The WM_TRANSIENT_FOR hint of the ICCCM allows clients to specify that a toplevel window may be closed before the client finishes.
// A typical example of a transient window is a dialog.
// Some dialogs can be open for a long time, while the user continues to work in the main window.
// Other dialogs have to be closed before the user can continue to work in the main window
XWindow getWMTransientFor(XWindow xid);
uint32_t getWMUserTime(XWindow xid);
int getWMUserTimeWindow(XWindow xid);
// 获取窗口类型
WMClass getWMClass(XWindow xid);
// 最小化窗口
void minimizeWindow(XWindow xid);
// 最大化窗口
void maxmizeWindow(XWindow xid);
/************************* other method ***************************/
// 获取窗口command
std::vector<std::string> getWMCommand(XWindow xid);
// 解析属性为UTF8格式字符串
std::string getUTF8StrFromReply(xcb_get_property_reply_t *reply);
// 解析属性为UTF8格式字符串字符数组
std::vector<std::string> getUTF8StrsFromReply(xcb_get_property_reply_t *reply);
// 获取根窗口
XWindow getRootWindow();
// 注册事件
void registerEvents(XWindow xid, uint32_t eventMask);
private:
XWindow getDecorativeWindow(XWindow xid);
WindowFrameExtents getWindowFrameExtents(XWindow xid);
private:
xcb_connection_t *m_connect;
int m_screenNum;
xcb_ewmh_connection_t m_ewmh;
AtomCache m_atomCache; // 和ewmh中Atom类型存在重复部分扩张了自定义类型
};
#endif // XCBUTILS_H

View File

@ -1,42 +0,0 @@
set(BIN_NAME dde-application-loader)
pkg_check_modules(LIBCAP REQUIRED IMPORTED_TARGET libcap)
set(SRCS
./main.cpp
../modules/tools/desktop_deconstruction.hpp
../modules/socket/client.h
../modules/socket/client.cpp
../modules/methods/task.hpp
../modules/methods/basic.h
../modules/methods/instance.hpp
../modules/methods/process_status.hpp
../modules/methods/registe.hpp
../modules/methods/use_mime_app_info.h
../modules/util/common.cpp
../modules/util/common.h
../modules/util/filesystem.cpp
../modules/util/filesystem.h
../modules/util/json.h
../modules/util/logger.cpp
../modules/util/logger.h
../modules/util/macro.h
../modules/util/oci_runtime.h
../modules/util/platform.cpp
../modules/util/platform.h
../modules/util/semaphore.cpp
../modules/util/semaphore.h
../modules/util/util.h
../modules/util/debug/debug.h
../modules/util/debug/debug.cpp
)
add_executable(${BIN_NAME} ${SRCS})
target_link_libraries(${BIN_NAME}
pthread
PkgConfig::LIBCAP
stdc++fs
Qt5::Core
)
install(TARGETS ${BIN_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})

View File

@ -1,356 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include <getopt.h>
#include <grp.h>
#include <pwd.h>
#include <sched.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <sys/prctl.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/un.h>
#include <sys/wait.h>
#include <unistd.h>
#include <filesystem>
#include <iostream>
#include <thread>
#include <vector>
#include <QString>
#include <QProcess>
#include <QDir>
#include "../modules/methods/basic.h"
#include "../modules/methods/instance.hpp"
#include "../modules/methods/process_status.hpp"
#include "../modules/methods/registe.hpp"
#include "../modules/methods/task.hpp"
#include "../modules/socket/client.h"
#include "../modules/tools/desktop_deconstruction.hpp"
#include "../modules/util/oci_runtime.h"
extern char** environ;
// from linglong
#define LINGLONG 118
#define LL_VAL(str) #str
#define LL_TOSTRING(str) LL_VAL(str)
struct App {
std::string type;
std::string prefix;
std::string id;
};
static App parseApp(const QString& app)
{
QStringList values = app.split('/', QString::SkipEmptyParts);
qInfo() << "app:" << app << ", values size:" << values.size();
App result;
if (values.size() == 3) {
result.prefix = values.at(0).toStdString();
result.type = values.at(1).toStdString();
result.id = values.at(2).toStdString();
}
return result;
}
void quit() {}
void sig_handler(int num)
{
int status;
pid_t pid;
/* 由于该信号不能叠加,所以可能同时有多个子进程已经结束 所以循环wait */
while ((pid = waitpid(0, &status, WNOHANG)) > 0) {
if (WIFEXITED(status)) // 判断子进程的退出状态 是否是正常退出
printf("-----child %d exit with %d\n", pid, WEXITSTATUS(status));
else if (WIFSIGNALED(status)) // 判断子进程是否是 通过信号退出
printf("child %d killed by the %dth signal\n", pid, WTERMSIG(status));
}
}
// TODO: startManager合并流程
int childFreedesktop(Methods::Task* task, std::string path)
{
prctl(PR_SET_PDEATHSIG, SIGKILL);
prctl(PR_SET_PDEATHSIG, SIGTERM);
prctl(PR_SET_PDEATHSIG, SIGHUP);
DesktopDeconstruction dd(path);
dd.beginGroup("Desktop Entry");
std::cout << dd.value<std::string>("Exec") << std::endl;
QStringList envs;
for (auto it = task->environments.begin(); it != task->environments.end(); ++it) {
envs.append(it.key() + "=" + it.value());
}
QStringList exeArgs;
exeArgs << QString::fromStdString(dd.value<std::string>("Exec")).split(" ");
QString exec = exeArgs[0];
exeArgs.removeAt(0);
pid_t pid = fork();
if (pid == -1) {
perror("fork()");
return -1;
}
if (pid == 0) {
// 子进程
QProcess process;
qInfo() << "exec:" << exec;
qInfo() << "exeArgs:" << exeArgs;
process.setWorkingDirectory(QDir::homePath());
process.setEnvironment(envs);
process.start(exec, exeArgs);
process.waitForFinished(-1);
process.close();
qInfo() << "process finish";
exit(0);
}
return pid;
}
int childLinglong(Methods::Task* task, std::string path)
{
prctl(PR_SET_PDEATHSIG, SIGKILL);
prctl(PR_SET_PDEATHSIG, SIGTERM);
prctl(PR_SET_PDEATHSIG, SIGHUP);
DesktopDeconstruction dd(path);
dd.beginGroup("Desktop Entry");
std::cout << dd.value<std::string>("Exec") << std::endl;
linglong::Runtime runtime;
linglong::Annotations annotations;
linglong::Root root;
linglong::Mount mount;
annotations.container_root_path = "/run/user/1000/DAM/" + task->id;
annotations.native = { { mount } };
root.path = annotations.container_root_path + "/root";
mount.destination = "/";
mount.source = "/";
mount.type = "bind";
mount.data = { "ro" };
runtime.hostname = "hostname";
runtime.process.cwd = "/";
std::filesystem::path container_root_path(annotations.container_root_path.toStdString());
if (!std::filesystem::exists(container_root_path)) {
if (!std::filesystem::create_directories(container_root_path)) {
std::cout << "[Loader] [Warning] cannot create container root path." << std::endl;
return -1;
}
}
for (auto it = task->environments.begin(); it != task->environments.end(); ++it) {
runtime.process.env.append(it.key() + "=" + it.value());
}
std::istringstream stream(dd.value<std::string>("Exec"));
std::string s;
while (getline(stream, s, ' ')) {
if (s.empty()) {
continue;
}
// TODO: %U
if (s.length() == 2 && s[0] == '%') {
continue;
}
runtime.process.args.push_back(QString::fromStdString(s));
}
// 应用运行信息
QByteArray runtimeArray;
toJson(runtimeArray, runtime);
qWarning() << "runtimeArray: " << runtimeArray;
// 使用Pipe进行父子进程通信
int pipeEnds[2];
if (pipe(pipeEnds) != 0) {
return EXIT_FAILURE;
}
pid_t pid = fork();
if (pid == -1) {
perror("fork()");
return -1;
}
if (pid == 0) {
// 子进程
(void) close(pipeEnds[1]);
// 重定向到LINGLONG
if (dup2(pipeEnds[0], LINGLONG) == -1) {
return EXIT_FAILURE;
}
(void) close(pipeEnds[0]);
// 初始化运行命令和参数,并执行
char const* const args[] = { "/usr/bin/ll-box", LL_TOSTRING(LINGLONG), nullptr };
int ret = execvp(args[0], (char**) args);
std::cout << "[Loader] [Fork] " << ret << std::endl;
//std::filesystem::remove(container_root_path);
exit(ret);
} else {
// 父进程
QByteArray runtimeArray;
linglong::toJson(runtimeArray, runtime);
const std::string data = runtimeArray.data();
close(pipeEnds[0]);
// 将运行时信息通过pipe传递给子进程
write(pipeEnds[1], data.c_str(), data.size());
close(pipeEnds[1]);
}
return pid;
}
int childAndroid(Methods::Task* task, std::string path)
{
// TODO
return 0;
}
#define DAM_TASK_HASH "DAM_TASK_HASH"
#define DAM_TASK_TYPE "DAM_TASK_TYPE"
int main(int argc, char* argv[])
{
const char* dam_task_hash = getenv(DAM_TASK_HASH);
if (!dam_task_hash) {
return -1;
}
const char* dam_task_type = getenv(DAM_TASK_TYPE);
if (!dam_task_type) {
return -2;
}
char socketPath[50];
sprintf(socketPath, "/run/user/%d/dde-application-manager.socket", getuid());
// register client and run quitConnect
Socket::Client client;
client.connect(socketPath);
// 初始化应用注册信息
QByteArray registerArray;
Methods::Registe registe;
registe.id = dam_task_type;
registe.hash = dam_task_hash;
Methods::toJson(registerArray, registe);
// 向AM注册应用信息进行校验
Methods::Registe registe_result;
registe_result.state = false;
QByteArray result = client.get(registerArray);
if (!result.isEmpty()) {
Methods::fromJson(result, registe_result);
}
if (!registe_result.state) {
return -3;
}
// 初始化应用实例信息
Methods::Instance instance;
instance.hash = registe_result.hash;
QByteArray instanceArray;
Methods::toJson(instanceArray, instance);
// 向AM注册应用实例信息进行校验
result = client.get(instanceArray);
Methods::Task task;
Methods::fromJson(result, task); // fromJson TODO 数据解析异常
qInfo() << "[Task] " << result;
// 校验task内容
App app = parseApp(task.runId);
qInfo() << "[App] "
<< "prefix:" << QString::fromStdString(app.prefix)
<< "type:" << QString::fromStdString(app.type)
<< "id:" << QString::fromStdString(app.id);
if (task.id.isEmpty() || app.id.empty() || app.type.empty() || app.prefix.empty()) {
std::cout << "get task error" << std::endl;
return -4;
}
if (app.prefix != "freedesktop"
&& app.prefix != "linglong"
&& app.prefix != "android") {
qWarning() << "error app prefix :" << QString::fromStdString(app.type);
return -1;
}
pthread_attr_t attr;
size_t stack_size;
pthread_attr_init(&attr);
pthread_attr_getstacksize(&attr, &stack_size);
pthread_attr_destroy(&attr);
/* 先将SIGCHLD信号阻塞 保证在子进程结束前设置父进程的捕捉函数 */
sigset_t nmask, omask;
// sigemptyset(&nmask);
// sigaddset(&nmask, SIGCHLD);
// sigprocmask(SIG_BLOCK, &nmask, &omask);
//char* stack = (char*) malloc(stack_size);
//pid_t pid = clone(child, stack + stack_size, CLONE_NEWPID | SIGCHLD, static_cast<void*>(&task));
pid_t pid = -1;
if (app.prefix == "freedesktop") {
pid = childFreedesktop(&task, task.filePath.toStdString());
} else if (app.prefix == "linglong") {
pid = childLinglong(&task, task.filePath.toStdString());
} else if (app.prefix == "android") {
pid = childAndroid(&task, task.filePath.toStdString());
} else {
qWarning() << "error app prefix:" << QString::fromStdString(app.prefix);
}
if(pid != -1) {
Methods::ProcessStatus processSuccess;
processSuccess.code = 0;
processSuccess.id = task.id;
processSuccess.type = "success";
processSuccess.data = QString::number(pid);
QByteArray processArray;
Methods::toJson(processArray, processSuccess);
client.send(processArray);
}
// TODO: 启动线程,创建新的连接去接受服务器的消息
// TODO:信号处理有问题
/* 设置捕捉函数 */
// struct sigaction sig;
// sig.sa_handler = sig_handler;
// sigemptyset(&sig.sa_mask);
// sig.sa_flags = 0;
// sigaction(SIGCHLD, &sig, NULL);
/* 然后再unblock */
// sigdelset(&omask, SIGCHLD);
// sigprocmask(SIG_SETMASK, &omask, NULL);
int exitCode;
waitpid(pid, &exitCode, 0);
qInfo() << "app exitCode:" << exitCode;
Methods::ProcessStatus quit;
quit.code = exitCode;
quit.id = task.id;
quit.type = "quit";
QByteArray quitArray;
Methods::toJson(quitArray, quit);
client.send(quitArray);
return exitCode;
}

View File

@ -1,247 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "alrecorder.h"
#include "dfwatcher.h"
#include <QDir>
#include <QDBusConnection>
#include <QDBusError>
#include <QtDebug>
#include <QCryptographicHash>
const QString userAppsCfgDir = QDir::homePath() + "/.config/deepin/dde-daemon/apps/";
AlRecorder::AlRecorder(DFWatcher *_watcher, QObject *parent)
: QObject (parent)
, watcher(_watcher)
, mutex(QMutex(QMutex::NonRecursive))
{
connect(watcher, &DFWatcher::Event, this, &AlRecorder::onDFChanged, Qt::QueuedConnection);
Q_EMIT serviceRestarted();
}
AlRecorder::~AlRecorder()
{
}
/**
* @brief AlRecorder::getNew 获取未启动应用列表
* @return
*/
QMap<QString, QStringList> AlRecorder::getNew()
{
QMap<QString, QStringList> ret;
QMutexLocker locker(&mutex);
for (auto is = subRecoders.begin(); is != subRecoders.end(); is++) {
QStringList apps;
for (auto il = is.value().launchedMap.begin(); il != is.value().launchedMap.end(); il++) {
if (!il.value()) // 未启动应用
apps.push_back(il.key());
}
if (apps.size() > 0)
ret[is.key()] = apps;
}
return ret;
}
/**
* @brief AlRecorder::markLaunched 标记应用已启动状态
* @param filePath
*/
void AlRecorder::markLaunched(const QString &filePath)
{
if (!filePath.endsWith(".desktop"))
return;
QFileInfo info;
QMutexLocker locker(&mutex);
for (auto sri = subRecoders.begin(); sri != subRecoders.end(); sri++) {
if (!filePath.startsWith(sri.key()))
continue;
info.setFile(filePath);
QString name = info.completeBaseName();
for (auto li = sri.value().launchedMap.begin(); li != sri.value().launchedMap.end(); li++) {
// 查找同名且未启动过的应用
if (li.key() == name && !li.value()) {
li.value() = true;
Q_EMIT launched(filePath);
// 记录启动状态
saveStatusFile(info.absolutePath() + "/");
}
}
}
}
/**
* @brief AlRecorder::uninstallHints 记录Launcher服务卸载应用信息, 终端卸载不会调用该函数, desktopFiles为绝对路径
* @param desktopFiles
*/
void AlRecorder::uninstallHints(const QStringList &desktopFiles)
{
QMutexLocker locker(&mutex);
for (auto desktop : desktopFiles) {
for (auto sri = subRecoders.begin(); sri != subRecoders.end(); sri++) {
if (!desktop.contains(sri.key()))
continue;
QFileInfo info(desktop);
sri.value().uninstallMap[info.completeBaseName()] = true;
}
}
}
/**
* @brief AlRecorder::watchDirs 监控目录
* @param dataDirs
*/
void AlRecorder::watchDirs(const QStringList &dataDirs)
{
for (auto dirPath : dataDirs) {
if (subRecoders.contains(dirPath))
continue;
QDir dir(dirPath);
QStringList files = dir.entryList(QDir::Files);
for (auto &file : files)
file = dirPath + file;
// 监听目录和文件
watcher->addDir(dirPath);
if (files.size() > 0)
watcher->addPaths(files);
// 初始化对应目录和应用信息
initSubRecoder(dirPath);
}
}
/**
* @brief AlRecorder::initSubRecoder 初始化应用目录记录
* @param dirPath
*/
void AlRecorder::initSubRecoder(const QString &dirPath)
{
subRecorder sub;
QByteArray encryText = QCryptographicHash::hash(dirPath.toLatin1(), QCryptographicHash::Md5);
QString statusFile = userAppsCfgDir + "launched-" + encryText.toHex() + ".csv";
// 读取App状态记录
QMap<QString, bool> launchedApp;
QFile file(statusFile);
if (file.exists() && file.open(QIODevice::ReadWrite | QIODevice::Text)) {
while (!file.atEnd()){
QString line(file.readLine());
QStringList strs = line.split(",");
if (strs.length() != 2)
continue;
if (strs[1].size() > 0 && strs[1][0] == 't')
launchedApp[strs[0]] = true;
else
launchedApp[strs[0]] = false;
}
file.close();
} else {
// 读取app desktop
QDir dir(dirPath);
QStringList files = dir.entryList(QDir::Files);
QStringList apps;
for (QString file : files) {
if (!file.endsWith(".desktop"))
continue;
int index = file.lastIndexOf(".");
file.truncate(index);
qInfo() << "entry =" << file;
apps.push_back(file);
}
// fallback 都打开过
for (auto app : apps)
launchedApp[app] = true;
}
sub.statusFile = statusFile;
sub.launchedMap = launchedApp;
subRecoders[dirPath] = sub;
}
/**
* @brief AlRecorder::onDFChanged 处理desktopFile文件改变事件
* @param filePath
* @param op
*/
void AlRecorder::onDFChanged(const QString &filePath, uint32_t op)
{
QFileInfo info(filePath);
QString dirPath = info.absolutePath() + "/";
QString name = info.completeBaseName();
subRecorder &sub = subRecoders[dirPath];
QMap<QString, bool> &launchedMap = sub.launchedMap;
// 过滤文件, 仅保留.desktop类型
if (!filePath.endsWith(".desktop"))
return;
switch (op) {
case DFWatcher::event::Add:
qInfo() << "AlRecorder: Add " << filePath;
if (!launchedMap.contains(name)) {
bool launched = false;
if (sub.removedLaunchedMap.find(name) != sub.removedLaunchedMap.end()) {
launched = sub.removedLaunchedMap[name];
sub.removedLaunchedMap.remove(name);
}
launchedMap[name] = launched;
}
sub.uninstallMap.remove(name);
saveStatusFile(dirPath); // 刷新状态文件
break;
case DFWatcher::event::Del:
qInfo() << "AlRecorder: Del" << filePath;
if (launchedMap.contains(name)) {
if (!sub.uninstallMap.contains(name))
sub.removedLaunchedMap[name] = launchedMap[name];
launchedMap.remove(name);
}
saveStatusFile(dirPath); //刷新状态文件
break;
case DFWatcher::event::Mod:
break;
}
}
/**
* @brief AlRecorder::saveStatusFile 保存状态文件
* @param dirPath
*/
void AlRecorder::saveStatusFile(const QString &dirPath)
{
subRecorder sub = subRecoders[dirPath];
QString tmpFile = sub.statusFile + "_tmp";
QFile fp(tmpFile);
bool ok = false;
qInfo() << "saveStatusFile=" << dirPath << "create file=" << tmpFile;
if (fp.open(QIODevice::ReadWrite | QIODevice::Text)) {
QTextStream out(&fp);
out << "# " << dirPath << endl;
for (auto rl = sub.launchedMap.begin(); rl != sub.launchedMap.end(); rl++) {
out << rl.key() << "," << ((rl.value() == true) ? "t" : "f") << endl;
}
ok = true;
fp.close();
}
// 覆盖原文件
QFile::remove(sub.statusFile);
QFile::rename(tmpFile, sub.statusFile);
Q_EMIT statusSaved(dirPath, sub.statusFile, ok);
}

View File

@ -1,55 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef ALRECORDER_H
#define ALRECORDER_H
#include <QObject>
#include <QMap>
#include <QMutex>
class DFWatcher;
// 记录当前用户应用状态信息
class AlRecorder: public QObject
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.deepin.dde.AlRecorder1")
public:
// 各个应用目录中应用的启动记录
struct subRecorder {
QString statusFile; // 应用目录状态文件
QMap<QString, bool> launchedMap; // 应用启动记录
QMap<QString, bool> removedLaunchedMap; // desktop文件卸载记录
QMap<QString, bool> uninstallMap; // 记录应用将被卸载状态
};
AlRecorder(DFWatcher *_watcher, QObject *parent = nullptr);
~AlRecorder();
Q_SIGNALS:
void launched(const QString &file);
void statusSaved(const QString &root, const QString &file, bool ok);
void serviceRestarted();
private Q_SLOTS:
void onDFChanged(const QString &filePath, uint32_t op);
public Q_SLOTS:
QMap<QString, QStringList> getNew();
void markLaunched(const QString &filePath);
void uninstallHints(const QStringList &desktopFiles);
void watchDirs(const QStringList &dataDirs);
private:
void initSubRecoder(const QString &dirPath);
void saveStatusFile(const QString &dirPath);
QMap<QString,subRecorder> subRecoders; // 记录不同应用目录的文件状态
DFWatcher *watcher;
QMutex mutex;
};
#endif // ALRECODER_H

View File

@ -1,47 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "appmanager.h"
#include "dfwatcher.h"
#include "alrecorder.h"
#include "basedir.h"
#include "dbusalrecorderadaptor.h"
#include <QDebug>
#include <QDir>
AppManager::AppManager(QObject *parent)
: QObject(parent)
, watcher(new DFWatcher(this))
, recorder(new AlRecorder(watcher, this))
{
qInfo() << "AppManager";
new DBusAdaptorRecorder(recorder);
QDBusConnection con = QDBusConnection::sessionBus();
if (!con.registerService("org.deepin.dde.AlRecorder1"))
{
qWarning() << "register service AlRecorder1 error:" << con.lastError().message();
return;
}
if (!con.registerObject("/org/deepin/dde/AlRecorder1", recorder))
{
qWarning() << "register object AlRecorder1 error:" << con.lastError().message();
return;
}
QStringList dataDirs;
dataDirs << BaseDir::userAppDir().c_str();
for (auto &dir : BaseDir::sysAppDirs())
dataDirs << dir.c_str();
qInfo() << "get dataDirs: " << dataDirs;
recorder->watchDirs(dataDirs); // 监控应用desktop
}
AppManager::~AppManager()
{
}

View File

@ -1,24 +0,0 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef APPMANAGER_H
#define APPMANAGER_H
#include <QObject>
class DFWatcher;
class AlRecorder;
class AppManager: public QObject
{
Q_OBJECT
public:
explicit AppManager(QObject *parent = nullptr);
~AppManager();
private:
DFWatcher *watcher;
AlRecorder *recorder;
};
#endif // APPMANAGER_H

Some files were not shown because too many files have changed in this diff Show More